summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-16 21:51:51 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-16 21:51:51 +0000
commit70d3ca5f03432c9893f4231b9037138e2c5f79d4 (patch)
tree8f67b77f9ca1944a0946a513046b6a78b7620c30
parent2191b1e9ed92cdbb924b5adb5be121a018eea109 (diff)
downloadclasspath-70d3ca5f03432c9893f4231b9037138e2c5f79d4.tar.gz
2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for 2006/07/09 to 2006/07/16.
-rw-r--r--ChangeLog890
-rw-r--r--NEWS1
-rwxr-xr-xautogen.sh5
-rw-r--r--configure.ac3
-rw-r--r--doc/vmintegration.texinfo34
-rw-r--r--examples/.cvsignore2
-rw-r--r--examples/Makefile.am11
-rw-r--r--examples/Makefile.java2d.in17
-rw-r--r--examples/README17
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java15
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java25
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java11
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java6
-rw-r--r--examples/gnu/classpath/examples/java2d/bench.c606
-rw-r--r--examples/gnu/classpath/examples/java2d/bench.h64
-rw-r--r--examples/gnu/classpath/examples/swing/HtmlDemo.java133
-rw-r--r--gnu/CORBA/ForwardRequestHelper.java25
-rw-r--r--gnu/classpath/debug/Simple1LineFormatter.java7
-rw-r--r--gnu/classpath/debug/SystemLogger.java8
-rw-r--r--gnu/java/awt/ClasspathToolkit.java22
-rw-r--r--gnu/java/awt/java2d/CubicSegment.java22
-rw-r--r--gnu/java/awt/java2d/LineSegment.java17
-rw-r--r--gnu/java/awt/java2d/QuadSegment.java20
-rw-r--r--gnu/java/awt/peer/ClasspathFontPeer.java7
-rw-r--r--gnu/java/awt/peer/gtk/CairoGraphics2D.java95
-rw-r--r--gnu/java/awt/peer/gtk/CairoSurface.java6
-rw-r--r--gnu/java/awt/peer/gtk/ComponentGraphics.java17
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java6
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java6
-rw-r--r--gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java77
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java9
-rw-r--r--gnu/java/awt/peer/gtk/GtkWindowPeer.java9
-rw-r--r--gnu/java/awt/peer/x/XToolkit.java64
-rw-r--r--gnu/java/net/local/LocalSocketImpl.java19
-rw-r--r--gnu/java/security/OID.java24
-rw-r--r--gnu/java/security/PolicyFile.java19
-rw-r--r--gnu/java/security/Registry.java12
-rw-r--r--gnu/java/security/key/dss/DSSKey.java6
-rw-r--r--gnu/java/security/key/dss/DSSPrivateKey.java6
-rw-r--r--gnu/java/security/key/dss/DSSPublicKey.java6
-rw-r--r--gnu/java/security/key/rsa/GnuRSAKey.java6
-rw-r--r--gnu/java/security/key/rsa/GnuRSAPrivateKey.java6
-rw-r--r--gnu/java/security/key/rsa/GnuRSAPublicKey.java6
-rw-r--r--gnu/java/security/util/ByteArray.java109
-rw-r--r--gnu/javax/crypto/RSACipherImpl.java2
-rw-r--r--gnu/javax/crypto/cipher/DES.java2
-rw-r--r--gnu/javax/crypto/jce/GnuCrypto.java10
-rw-r--r--gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java54
-rw-r--r--gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java54
-rw-r--r--gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java54
-rw-r--r--gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java88
-rw-r--r--gnu/javax/crypto/jce/cipher/CipherAdapter.java6
-rw-r--r--gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java423
-rw-r--r--gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java54
-rw-r--r--gnu/javax/crypto/jce/params/BlockCipherParameters.java7
-rw-r--r--gnu/javax/crypto/key/dh/GnuDHKey.java6
-rw-r--r--gnu/javax/crypto/key/dh/GnuDHPrivateKey.java6
-rw-r--r--gnu/javax/crypto/key/dh/GnuDHPublicKey.java6
-rw-r--r--gnu/javax/crypto/kwa/AESKeyWrap.java168
-rw-r--r--gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java145
-rw-r--r--gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java160
-rw-r--r--gnu/javax/crypto/kwa/KeyUnwrappingException.java67
-rw-r--r--gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java110
-rw-r--r--gnu/javax/crypto/kwa/TripleDESKeyWrap.java292
-rw-r--r--gnu/javax/crypto/pad/BasePad.java23
-rw-r--r--gnu/javax/crypto/pad/IPad.java24
-rw-r--r--gnu/javax/crypto/sasl/plain/PasswordFile.java8
-rw-r--r--gnu/javax/imageio/gif/GIFImageReader.java3
-rw-r--r--gnu/javax/sound/sampled/AU/AUReader.java212
-rw-r--r--gnu/javax/swing/text/html/parser/GnuParserDelegator.java178
-rw-r--r--gnu/javax/swing/text/html/parser/HTML_401F.java47
-rw-r--r--gnu/javax/swing/text/html/parser/HTML_401Swing.java91
-rw-r--r--gnu/javax/swing/text/html/parser/htmlValidator.java39
-rw-r--r--include/Makefile.am1
-rw-r--r--include/gnu_java_awt_peer_gtk_CairoGraphics2D.h4
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkToolkit.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkWindowPeer.h1
-rw-r--r--include/gnu_java_net_local_LocalSocketImpl.h6
-rw-r--r--include/jvmti.h1811
-rw-r--r--java/awt/BasicStroke.java1
-rw-r--r--java/awt/Canvas.java4
-rw-r--r--java/awt/CardLayout.java1
-rw-r--r--java/awt/CheckboxMenuItem.java20
-rw-r--r--java/awt/Choice.java20
-rw-r--r--java/awt/Component.java487
-rw-r--r--java/awt/Container.java248
-rw-r--r--java/awt/Cursor.java15
-rw-r--r--java/awt/FlowLayout.java10
-rw-r--r--java/awt/GridBagLayout.java121
-rw-r--r--java/awt/Image.java38
-rw-r--r--java/awt/List.java20
-rw-r--r--java/awt/Menu.java20
-rw-r--r--java/awt/MenuBar.java22
-rw-r--r--java/awt/MenuComponent.java14
-rw-r--r--java/awt/MenuItem.java25
-rw-r--r--java/awt/MouseInfo.java95
-rw-r--r--java/awt/PointerInfo.java84
-rw-r--r--java/awt/PopupMenu.java24
-rw-r--r--java/awt/ScrollPane.java32
-rw-r--r--java/awt/TextField.java21
-rw-r--r--java/awt/Toolkit.java13
-rw-r--r--java/awt/Window.java64
-rw-r--r--java/awt/font/TextLayout.java3
-rw-r--r--java/awt/font/TextMeasurer.java2
-rw-r--r--java/awt/image/BandedSampleModel.java287
-rw-r--r--java/awt/image/BufferedImage.java48
-rw-r--r--java/awt/image/DataBuffer.java23
-rw-r--r--java/awt/image/MultiPixelPackedSampleModel.java309
-rw-r--r--java/awt/image/SampleModel.java461
-rw-r--r--java/awt/image/SinglePixelPackedSampleModel.java254
-rw-r--r--java/awt/peer/MouseInfoPeer.java61
-rw-r--r--java/awt/peer/WindowPeer.java5
-rw-r--r--java/io/PrintStream.java103
-rw-r--r--java/lang/management/MemoryNotificationInfo.java239
-rw-r--r--java/util/Arrays.java6
-rw-r--r--java/util/UUID.java372
-rw-r--r--java/util/zip/ZipFile.java30
-rw-r--r--javax/crypto/Cipher.java8
-rw-r--r--javax/crypto/spec/SecretKeySpec.java18
-rw-r--r--javax/management/ListenerNotFoundException.java75
-rw-r--r--javax/management/MBeanFeatureInfo.java6
-rw-r--r--javax/management/MBeanInfo.java24
-rw-r--r--javax/management/MBeanNotificationInfo.java201
-rw-r--r--javax/management/Notification.java314
-rw-r--r--javax/management/NotificationBroadcaster.java112
-rw-r--r--javax/management/NotificationEmitter.java76
-rw-r--r--javax/management/NotificationFilter.java66
-rw-r--r--javax/management/NotificationListener.java70
-rw-r--r--javax/management/OperationsException.java5
-rw-r--r--javax/rmi/ssl/SslRMIClientSocketFactory.java166
-rw-r--r--javax/rmi/ssl/SslRMIServerSocketFactory.java213
-rw-r--r--javax/swing/AbstractButton.java19
-rw-r--r--javax/swing/ButtonGroup.java53
-rw-r--r--javax/swing/DefaultBoundedRangeModel.java34
-rw-r--r--javax/swing/JFileChooser.java12
-rw-r--r--javax/swing/JTable.java24
-rw-r--r--javax/swing/plaf/basic/BasicDirectoryModel.java137
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java28
-rw-r--r--javax/swing/plaf/metal/MetalFileChooserUI.java35
-rw-r--r--javax/swing/text/html/HTMLDocument.java354
-rw-r--r--javax/swing/text/html/HTMLEditorKit.java6
-rw-r--r--javax/swing/text/html/parser/ParserDelegator.java3
-rw-r--r--native/jni/gconf-peer/GConfNativePeer.c39
-rw-r--r--native/jni/gconf-peer/Makefile.am6
-rw-r--r--native/jni/gtk-peer/Makefile.am1
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c44
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c32
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c31
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c15
-rw-r--r--native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c44
-rw-r--r--org/omg/CORBA/CompletionStatusHelper.java23
-rw-r--r--org/omg/CORBA/CurrentHelper.java12
-rw-r--r--org/omg/CORBA/DefinitionKindHelper.java39
-rw-r--r--org/omg/CORBA/IDLTypeHelper.java15
-rw-r--r--org/omg/CORBA/NameValuePairHelper.java25
-rw-r--r--org/omg/CORBA/ObjectHelper.java7
-rw-r--r--org/omg/CORBA/ParameterModeHelper.java11
-rw-r--r--org/omg/CORBA/PolicyErrorCodeHelper.java2
-rw-r--r--org/omg/CORBA/PolicyErrorHelper.java32
-rw-r--r--org/omg/CORBA/PolicyHelper.java10
-rw-r--r--org/omg/CORBA/PolicyListHelper.java10
-rw-r--r--org/omg/CORBA/PolicyTypeHelper.java4
-rw-r--r--org/omg/CORBA/ServiceDetailHelper.java40
-rw-r--r--org/omg/CORBA/ServiceInformationHelper.java59
-rw-r--r--org/omg/CORBA/SetOverrideTypeHelper.java29
-rw-r--r--org/omg/CORBA/StringValueHelper.java18
-rw-r--r--org/omg/CORBA/UnionMemberHelper.java2
-rw-r--r--org/omg/CORBA/UnknownUserExceptionHelper.java14
-rw-r--r--org/omg/CORBA/VisibilityHelper.java11
-rw-r--r--org/omg/CORBA/WStringValueHelper.java18
-rw-r--r--org/omg/CORBA/WrongTransactionHelper.java16
-rw-r--r--org/omg/CosNaming/BindingHelper.java32
-rw-r--r--org/omg/CosNaming/BindingIteratorHelper.java10
-rw-r--r--org/omg/CosNaming/BindingListHelper.java19
-rw-r--r--org/omg/CosNaming/BindingTypeHelper.java15
-rw-r--r--org/omg/CosNaming/NameComponentHelper.java34
-rw-r--r--org/omg/CosNaming/NameHelper.java18
-rw-r--r--org/omg/CosNaming/NamingContextExtHelper.java14
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java18
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java19
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java17
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java17
-rw-r--r--org/omg/CosNaming/NamingContextHelper.java10
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java12
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java32
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java17
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java12
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java32
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java24
-rw-r--r--org/omg/DynamicAny/AnySeqHelper.java19
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryHelper.java3
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java23
-rw-r--r--org/omg/DynamicAny/DynAnyHelper.java4
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java19
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java19
-rw-r--r--org/omg/DynamicAny/DynAnySeqHelper.java16
-rw-r--r--org/omg/DynamicAny/DynArrayHelper.java4
-rw-r--r--org/omg/DynamicAny/DynEnumHelper.java4
-rw-r--r--org/omg/DynamicAny/DynFixedHelper.java4
-rw-r--r--org/omg/DynamicAny/DynSequenceHelper.java4
-rw-r--r--org/omg/DynamicAny/DynStructHelper.java4
-rw-r--r--org/omg/DynamicAny/DynUnionHelper.java4
-rw-r--r--org/omg/DynamicAny/DynValueHelper.java4
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairHelper.java40
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairSeqHelper.java16
-rw-r--r--org/omg/DynamicAny/NameValuePairHelper.java40
-rw-r--r--org/omg/DynamicAny/NameValuePairSeqHelper.java16
-rw-r--r--org/omg/IOP/CodecFactoryHelper.java11
-rw-r--r--org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java18
-rw-r--r--org/omg/IOP/CodecPackage/FormatMismatchHelper.java16
-rw-r--r--org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java23
-rw-r--r--org/omg/IOP/CodecPackage/TypeMismatchHelper.java16
-rw-r--r--org/omg/IOP/ComponentIdHelper.java10
-rw-r--r--org/omg/IOP/IORHelper.java43
-rw-r--r--org/omg/IOP/MultipleComponentProfileHelper.java20
-rw-r--r--org/omg/IOP/ProfileIdHelper.java11
-rw-r--r--org/omg/IOP/ServiceContextHelper.java50
-rw-r--r--org/omg/IOP/ServiceContextListHelper.java11
-rw-r--r--org/omg/IOP/ServiceIdHelper.java4
-rw-r--r--org/omg/IOP/TaggedComponentHelper.java36
-rw-r--r--org/omg/IOP/TaggedProfileHelper.java31
-rw-r--r--org/omg/PortableInterceptor/AdapterManagerIdHelper.java11
-rw-r--r--org/omg/PortableInterceptor/AdapterNameHelper.java23
-rw-r--r--org/omg/PortableInterceptor/AdapterStateHelper.java4
-rw-r--r--org/omg/PortableInterceptor/CurrentHelper.java12
-rw-r--r--org/omg/PortableInterceptor/ForwardRequestHelper.java24
-rw-r--r--org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java11
-rw-r--r--org/omg/PortableInterceptor/InvalidSlotHelper.java16
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java33
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java21
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java21
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java21
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java19
-rw-r--r--org/omg/PortableServer/CurrentHelper.java4
-rw-r--r--org/omg/PortableServer/CurrentPackage/NoContextHelper.java24
-rw-r--r--org/omg/PortableServer/ForwardRequestHelper.java14
-rw-r--r--org/omg/PortableServer/POAHelper.java3
-rw-r--r--org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java16
-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/InvalidPolicyHelper.java3
-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/ServantActivatorHelper.java3
-rw-r--r--org/omg/PortableServer/ServantLocatorHelper.java3
-rw-r--r--resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader1
-rw-r--r--tools/gnu/classpath/tools/keytool/Command.java61
-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
256 files changed, 12101 insertions, 2085 deletions
diff --git a/ChangeLog b/ChangeLog
index 7637bcc77..f84cf6c06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,754 @@
+2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/MBeanInfo.java:
+ (getNotifications()): Implemented.
+ * javax/management/NotificationBroadcaster.java:
+ (removeNotificationListener(NotificationListener)):
+ Renamed from removeListener.
+ * javax/management/NotificationEmitter.java:
+ (removeNotificationListener(NotificationListener,
+ NotificationFilter, Object)): Likewise.
+ * javax/management/NotificationFilter.java:
+ Implement Serializable.
+ * javax/management/NotificationListener.java:
+ Implement java.util.EventListener.
+ * javax/rmi/ssl/SslRMIClientSocketFactory.java:
+ Implement Serializable.
+
+2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/MemoryNotificationInfo.java:
+ New file.
+
+2006-07-16 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28392
+ * gnu/javax/swing/text/html/parser/htmlValidator.java
+ (tagIsValidForContext): If it is not possible to insert any tag, but
+ is possible to insert a P, insert a P.
+ * gnu/javax/swing/text/html/parser/HTML_401Swing.java
+ (newInstance): Removed print statement. (getBodyElements):
+ Removed ABBR, ACRONYM, BDO, Q, S, SUB, SUP and ADDRESS from the
+ valid body level tags (will be enclosed into P's).
+
+2006-07-17 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/Command.java (setKeystoreURLParam):
+ Condition the creation of .keystore (a default keystore) based on the
+ createIfNotFound argument as well.
+
+2006-07-16 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28392
+ * examples/gnu/classpath/examples/swing/HtmlDemo.java:
+ Removed heading p tag from the parsing example.
+ * gnu/javax/swing/text/html/parser/HTML_401F.java:
+ (createHtmlContentModel): Explained.
+ (defineElements): Call getBodyElements to get the body
+ elements. (getBodyElements): New method. (model):
+ Made protected from private.
+ * gnu/javax/swing/text/html/parser/htmlValidator.java
+ (openTag): Mind that current content model may be null.
+ (tagIsValidForContext): If the tag is PCDATA, and it is not
+ valid for context, but the paragraph (P) is valid for context,
+ suggest to insert the P tag here.
+ * javax/swing/text/html/HTMLDocument.java (HTMLReader.addContent,
+ HTMLReader.blockOpen, HTMLReader.blockClose): Do not handle
+ implied P tags here.
+ * javax/swing/text/html/HTMLEditorKit.java (getParser):
+ Get the custom parser, using HTML_401Swing.java DTD.
+ * javax/swing/text/html/parser/ParserDelegator.java:
+ Removed the obsolete note that HTMLEditorKit does not exist.
+ * gnu/javax/swing/text/html/parser/GnuParserDelegator.java,
+ gnu/javax/swing/text/html/parser/HTML_401Swing.java: New files.
+
+2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/ListenerNotFoundException.java:
+ New file.
+ * javax/management/MBeanFeatureInfo.java:
+ (hashCode()): Use summation instead of multiplication
+ for consistency with other classes.
+ * javax/management/MBeanNotificationInfo.java,
+ * javax/management/Notification.java,
+ * javax/management/NotificationBroadcaster.java,
+ * javax/management/NotificationEmitter.java,
+ * javax/management/NotificationFilter.java,
+ * javax/management/NotificationListener.java:
+ New files.
+ * javax/management/OperationsException.java:
+ (serialVersionUID): Added.
+
+2006-07-16 Thomas Minor <1nocentrabidlamb@sexMagnet.com>
+ Mark Wielaard <mark@klomp.org>
+
+ * java/io/PrintStream.java: Added four constructors, for File and
+ String describing a filename with or without explicit encoding.
+
+2006-07-16 Sven de Marothy <sven@physto.se>
+
+ * javax/rmi/ssl/SslRMIServerSocketFactory.java,
+ * javax/rmi/ssl/SslRMIClientSocketFactory.java:
+ New files.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/28391
+ * tools/gnu/classpath/tools/keytool/Command.java (setKeyStoreParams(5)):
+ New method.
+ (setKeyStoreParams(4)): Call the above method with false as its 1st arg.
+ (setProviderClassNameParam): Made private.
+ (setKeystoreTypeParam): Likewise.
+ (setKeyPasswordParam): Likewise
+ (setKeystorePasswordParam): Likewise.
+ (setKeystoreURLParam): Now accepts 2 more arguments; the first a boolean to
+ create or not the keystore if it's not there, and the second is the store's
+ password to process before loading the keystore. Amended the code
+ accordingly.
+ * tools/gnu/classpath/tools/keytool/GenKeyCmd.java (setup): Call super's
+ setKeyStoreParams(5) with true as its first argument.
+ * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java (setup): Likewise.
+
+2006-07-16 Sven de Marothy <sven@physto.se>
+
+ * java/util/UUID.java: New file.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java: New file.
+ * gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java: New file.
+ * gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java: Likewise.
+ * gnu/javax/crypto/jce/GnuCrypto.java (.run): Added mappings for newly
+ added Key Wrapping Algorithm SPIs.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * javax/crypto/Cipher.java (getOutputSize): Allow SPIs initialised for key
+ wrapping/unwrapping to invoke their engineGetOutputSize.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/kwa/TripleDESKeyWrap.java (rnd): New field.
+ (engineInit): If a SecureRandom was specified then use it.
+ (nextRandomBytes): New method.
+ (engineWrap): Use above method.
+ * gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java (prng): New field.
+ (getDefaultPRNG): New method.
+ * gnu/javax/crypto/kwa/AESKeyWrap.java (engineInit): Reset underlying AES.
+ * gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java (SOURCE_OF_RANDOMNESS):
+ New constant.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/jce/params/BlockCipherParameters.java
+ (engineGetParameterSpec): Should be able to return an IvParameterSpec.
+
+2006-07-16 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/cipher/DES.java (adjustParity): Index limit now takes
+ offset into consideration.
+
+2006-07-16 Mario Torre <neugens@limasoftware.net>
+
+ * native/jni/gconf-peer/GConfNativePeer.c (init_gconf_client):
+ Fixed comment. This functions now requires to be called
+ with gdk lock held, the comment states that.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache):
+ Introduces gdk locks around critical regions of code.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class):
+ * native/jni/gconf-peer/Makefile.am: The GConf peer now depends on GTK.
+
+2006-07-15 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/JFileChooser.java
+ Change default selection mode to FILES_ONLY.
+ * javax/swing/plaf/basic/BasicDirectoryModel.java
+ Document, fix selection mode filtering.
+ (renameFile): Implement
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ (selectedDir): New field to handle selected directories,
+ disallow selecting of directories in FILES_ONLY mode.
+ * javax/swing/plaf/metal/MetalFileChooserUI.java:
+ (EditingActionListener.actionPerformed):
+ Stop editing on all actions (e.g. return-key press)
+
+2006-07-15 Mark Wielaard <mark@klomp.org>
+
+ * doc/vmintegration.texinfo (gnu.java.lang.management): Change xref
+ to code.
+ (JNI Implementation): Mark JVMTI Implementation as next.
+ (JVMTI Implementation): Mark JNI Implementation as prev.
+
+2006-07-15 Mark Wielaard <mark@klomp.org>
+
+ * include/Makefile.am: Remove
+ include/gnu_java_awt_peer_gtk_GdkTextLayout.h.
+ * include/gnu_java_awt_peer_gtk_GdkTextLayout.h: Removed.
+ * native/jni/gtk-peer/Makefile.am: Remove
+ gnu_java_awt_peer_gtk_GdkTextLayout.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c:
+ Removed.
+
+ * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h: Regenerated.
+
+2006-07-15 Mark Wielaard <mark@klomp.org>
+
+ * autogen.sh: Recognize autoconf 2.60.
+
+2006-07-15 Keith Seitz <keiths@redhat.com>
+
+ * NEWS: Update for JVMTI and jvmti.h.
+ * doc/vmintegration.texinfo: Likewise.
+ * include/jvmti.h: New file.
+
+2006-07-15 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c:
+ Removed C++ style comment.
+
+2006-07-15 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java,
+ * java/awt/MouseInfo.java,
+ * java/awt/PointerInfo.java,
+ * java/awt/peer/MouseInfoPeer.java:
+ New files.
+
+ * java/awt/Image.java
+ (accelerationPriority): New field.
+ (setAccelerationPriority, getAccelerationPriority): New methods..
+
+ * include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
+ * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
+ (getMouseCoordinates): New method.
+
+ * gnu/java/awt/peer/gtk/GtkFramePeer.java
+ (updateAlwaysOnTop): Remove stub overload.
+
+ * gnu/java/awt/ClasspathToolkit.java,
+ * gnu/java/awt/peer/gtk/GtkToolkit.java,
+ * include/gnu_java_awt_peer_gtk_GtkToolkit.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c:
+ (getMouseInfoPeer): New method.
+ (getMouseNumberOfButtons): New method.
+
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+ (gtkWindowSetAlwaysOnTop): New method.
+ (updateAlwaysOnTop): Implement.
+
+ * java/awt/Toolkit.java,
+ (getMouseInfoPeer): New method.
+
+ * java/awt/Window.java
+ (alwaysOnTop): New field.
+ (isAlwaysOnTop, setAlwaysOnTop): New methods.
+
+ * java/awt/peer/WindowPeer.java: Doc fix.
+
+2006-07-14 Sven de Marothy <sven@physto.se>
+
+ * java/awt/font/TextLayout.java:
+ (hitTestChar): Stub method.
+ * java/awt/font/TextMeasurer.java:
+ (getLayout): Throw exception on invalid argument.
+
+2006-07-14 Sven de Marothy <sven@physto.se>
+
+ * java/awt/image/DataBuffer.java
+ (DataBuffer): Call constructors in the correct order,
+
+2006-07-14 Mark Wielaard <mark@klomp.org>
+
+ Revert to previous implementation.
+ * java/awt/GridBagLayout.java (AdjustForGravity): Only adjust for
+ constraints insets.
+
+2006-07-14 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XToolkit.java
+ (XToolkit): Install properties to SystemProperties
+ rather than System, to avoid SecurityManager.
+ (getImage(String)): Return error image when string is invalid.
+ (createImage(URL)): Moved image loading to helper method.
+ (createImage(ImageProducer)): Implemented.
+ (createImage(byte[],int,int)): Implemented.
+ (createImage(InputStream)): New helper method.
+
+2006-07-14 Tania Bento <tbento@redhat.com>
+
+ * java/awt/FlowLayout.java
+ (setHgap): No Excpetion should be thrown if hgap has
+ a negative value.
+ (setVgap): No Exception should be thrown if vgap has
+ a negative value.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java:
+ Added API docs all over.
+
+2006-07-14 Matt Wringe <mwringe@redhat.com>
+
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java
+ (engineInit): Throw InvalidAlgorithmParameterException
+ for invalid IVParameterSpec IV length.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (createDataBuffer): Include dataBitOffset in calculating the size for
+ the data buffer.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (getSampleSize()): Return a copy of the array,
+ (getTransferType()): New method override.
+
+2006-07-14 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/CardLayout.java
+ (show): Validate parent to make sure that the layout is
+ valid.
+
+2006-07-14 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (enable): Added tree locking.
+ (disable): Added tree locking.
+ (show): Added tree locking.
+ (hide): Added tree locking.
+ (getLocationOnScreen): Added tree locking.
+ (reshape): Added tree locking.
+ (addHierarchyListener): Added tree locking.
+ (removeHierarchyListener): Added tree locking.
+ (addHierarchyBoundsListener): Added tree locking.
+ (removeHierarchyBoundsListener): Added tree locking.
+ (addNotify): Added tree locking.
+ (removeNotify): Added tree locking.
+ * java/awt/Container.java
+ (invalidateTree): Added tree locking.
+ (getAlignmentX): Added tree locking.
+ (getAlignmentY): Added tree locking.
+ (addNotify): Added tree locking.
+ (setComponentZOrder): Added tree locking.
+ (getComponentZOrder): Added tree locking.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (createSubsetSampleModel): Restored argument check, but let null
+ through.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (createSubsetSampleModel): Removed argument check.
+
+2006-07-14 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (numHierarchyListeners): New field.
+ (numHierarchyBoundsListeners): New field.
+ (show): Fire hierarchy events here. Only fire component event
+ if there is actually a listener for it.
+ (hide): Fire hierarchy events here. Only fire component event
+ if there is actually a listener for it.
+ (reshape): Fire hierarchy events here. Only fire component event
+ if there is actually a listener for it.
+ (addHierarchyListeners): Update listener counters.
+ (removeHierarchyListeners): Update listener counters.
+ (addHierarchyBoundsListeners): Update listener counters.
+ (removeHierarchyBoundsListeners): Update listener counters.
+ (fireHierarchyEvent): New helper method for firing hierarchy
+ events.
+ * java/awt/Container.java
+ (addImpl): Update listener counters. Fire hierarchy event.
+ (remove): Update listener counters. Fire hierarchy event.
+ (fireHierarchyEvent): New helper method for firing hierarchy
+ events.
+ (updateHierarchyListenerCount): New helper method for
+ updating the listener counters.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (equals): New method override,
+ (hashCode): Likewise.
+
+2006-07-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (MultiPixelPackedSampleModel(int, int, int, int, int, int)):
+ Corrected scanlineStride calculation.
+
+2006-07-14 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/Registry.java (KWA_PREFIX): New constant.
+ (AES_KWA): Likewise.
+ (AES128_KWA): Likewise.
+ (AES192_KWA): Likewise.
+ (AES256_KWA): Likewise.
+ (RIJNDAEL_KWA): Likewise.
+ (TRIPLEDES_KWA): Likewise.
+ (DESEDE_KWA): Likewise.
+ * gnu/javax/crypto/kwa/AESKeyWrap.java: New file
+ * gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java: Likewise.
+ * gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java: Likewise.
+ * gnu/javax/crypto/kwa/KeyUnwrappingException.java: Likewise.
+ * gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java: Likewise.
+ * gnu/javax/crypto/kwa/TripleDESKeyWrap.java: Likewise.
+
+2006-07-14 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/pad/IPad.java: Updated class documentation.
+ (PADDING_BLOCK_SIZE): New constant.
+ (init(Map attributes)): New method.
+ * gnu/javax/crypto/pad/BasePad.java (init): New method.
+
+2006-07-14 Mario Torre <neugens@limasoftware.net>
+
+ * gnu/java/security/OID.java (OID): Private Constructor removed as
+ it is not needed anymore.
+ (clone): Fixed. Now uses super.clone instead of the private
+ constructor as per specification of clone method.
+ (serialVersionUID): added new field to allow serialization.
+
+2006-07-13 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/imageio/gif/GIFImageReader.java
+ (read): Remove old debugging trace.
+
+2006-07-13 Andreas Tobler <a.tobler@schweiz.ch>
+
+ PR awt/28369:
+ * gnu/java/awt/peer/gtk/CairoSurface.java (ColorModel): Swap red and
+ blue mask.
+
+2006-07-13 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (DEFAULT_MAX_SIZE): New static constant.
+ (preferredSize): Return copy of the actual value computed
+ by new helper method.
+ (preferredSizeImpl): New helper method. Adds locking and
+ correct handling of cached value.
+ (minimumSize): Return copy of the actual value computed
+ by new helper method.
+ (minimumSizeImpl): New helper method. Adds locking and
+ correct handling of cached value.
+ (getMaximumSize): Return copy of the actual value computed
+ by new helper method.
+ (maximumSizeImpl): New helper method. Adds locking and
+ correct handling of cached value.
+ (invalidate): Correct handling of cached layout information.
+ Added locking.
+ * java/awt/Container.java
+ (preferredSize): Minimized locking. Corrected handling of cached
+ values. Return copy of real value.
+ (minimumSize): Minimized locking. Corrected handling of cached
+ values. Return copy of real value.
+ (getMaximumSize): Minimized locking. Corrected handling of cached
+ values. Return copy of real value.
+
+2006-07-13 Tania Bento <tbento@redhat.com>
+
+ * gnu/java/awt/peer/ClasspathFontPeer.java
+ (isLogicalFontName): Return true if name == default.
+ (logicalFontNameToFaceName): Check if name == default,
+ and if so, return "Dialog.plain".
+ (setStandardAttributes(String, Map)): If name == null,
+ it should be set to "Default", not "SansSerif".
+ * java/awt/Canvas.java
+ (generateName): Fixed documentation.
+ * java/awt/CheckboxMenuItem.java
+ Added static variable "next_chkmenuitem_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/Choice.java
+ Added static variable "next_choice_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/Cursor.java
+ (Cursor(int)): Set name depending on the type passed.
+ * java/awt/List.java
+ Added static variable "next_list_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/Menu.java
+ Added static variable "next_menu_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/MenuBar.java
+ Added static variable "next_menubar_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/MenuComponent.java
+ (getName): Before returning name, check if name == null
+ and name is not explicity set. If this is the case,
+ name will be generated.
+ (generateName): Added and implemented method.
+ * java/awt/MenuItem.java
+ Added static variable "next_menuitem_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/PopupMenu.java
+ Added static variable "next_popup_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/ScrollPane.java
+ Added static variable "next_scrollpane_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+ * java/awt/TextField.java
+ Added static variable "next_textfield_number".
+ (generateName): Added and implemented method.
+ (getUniqueLong): Likewise.
+
+
+2006-07-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/SinglePixelPackedSampleModel.java
+ (SinglePixelPackageSampleModel(int, int, int, int, int[])): Convert
+ mask correctly as an unsigned integer,
+ (equals): New method override.
+
+2006-07-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLDocument.java (insertAfterEnd,
+ insertAfterStart, insertBeforeEnd): Removed stub markings.
+
+2006-07-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java: API doc updates and source
+ code reformatting,
+ * java/awt/image/SinglePixelPackageSampleModel.java: Likewise.
+
+2006-07-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java: API doc updates.
+
+2006-07-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLDocument.java (HTMLReader.parseStack):
+ Made package private. (HTMLReader.charAttr, HTMLReader.charAttrStack,
+ HTMLReader.insertTag, HTMLReader.insertTagEncountered,
+ HTMLReader.pushDepth, HTMLReader.popDepth): Documented.
+ (HRMLReader.blockClose): Mind that parser stack may be empty.
+ (HTMLReader.handeComment, HTMLReader.handleStartTag,
+ HTMLReader.handleEndTag, HTMLReader.handleSimpleTag): Rewritten.
+ (HTMLReader.shouldInsert): New method. (getElement(String)):
+ Pass HTML.Atrribute.ID. (insertAfterEnd, insertBeforeEnd,
+ insertAfterStart, insertBeforeStart, setInnerHTML, setOuterHTML):
+ Implemented. (getInsertingReader): New method.
+ * examples/gnu/classpath/examples/swing/HtmlDemo.java:
+ Added buttons to demonstrate the work of the insert actions.
+
+2006-07-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/SampleModel.java: API doc updates and additions,
+ * java/awt/image/SinglePixelPackedSampleModel.java: Likewise.
+
+2006-07-12 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/JFileChooser.java:
+ (createDialog): Close operation should cause a cancel.
+
+2006-07-12 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Organized imports.
+ (cairoArc): New native method.
+ (cairoRestore): New native method.
+ (cairoSave): New native method.
+ (cairoScale): New native method.
+ (createPath): New method to centralize code from draw and fill.
+ (draw): Modified to use createPath method.
+ (fill): Modified to use createPath method.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Added
+ function declarations.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoScale): New
+ method.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSave): New
+ method.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoArc): New
+ method.
+
+2006-07-12 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/27271:
+ * java/util/zip/ZipFile.java (getInputStream): Call addDummyByte
+ on PartialInputStream.
+ (PartialInputStream.dummyByteCount): New field.
+ (PartialInputStream.fillBuffer): Handle dummy byte.
+ (PartialInputStream.read): Likewise.
+ (PartialInputStream.addDummyByte): New method.
+
+2006-07-12 Mario Torre <neugens@limasoftware.net>
+
+ * native/jni/gconf-peer/GConfNativePeer.c
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
+ Fixed C++ style comment.
+
+2006-07-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/util/Arrays.java
+ (asList): Updated API docs.
+
+2006-07-11 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR28350.
+ * native/jni/gconf-peer/GConfNativePeer.c:
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string):
+ Changed if-expression.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
+ Added check for _value not being NULL.
+
+2006-07-11 Roman Kennke <kennke@aicas.com>
+
+ * native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
+ (read): Use fd when local sockets are disabled to make the
+ compiler quite.
+ (write): Likewise.
+
+2006-07-11 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (MultiPixelPackedSampleModel): Substract -1 so that the integer
+ division gets rounded up.
+
+2006-07-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/ManageFactory.java:
+ (getMemoryManagerMXBeans()): Use addAll, not add.
+
+2006-07-11 Vivek Lakshmanan <vivekl@redhat.com>
+
+ PR 27649:
+ * gnu/classpath/ByteArray.java: Removed (moved).
+ * gnu/java/security/util/ByteArray.java: New File.
+ * gnu/javax/crypto/RSACipherImpl.java: Reference
+ gnu.java.security.util.ByteArray instead of gnu.classpath.ByteArray.
+
+2006-07-11 Roman Kennke <kennke@aicas.com>
+
+ * native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
+ (available): Pass fd as argument and avoid JNI class/field
+ lookup.
+ (read): Likewise.
+ (write): Likewise.
+ * include/gnu_java_net_local_LocalSocketImpl.h:
+ Regenerated.
+ * gnu/java/net/local/LocalSocketImpl.h
+ (available): Pass fd as argument and avoid JNI class/field
+ lookup.
+ (read): Likewise.
+ (write): Likewise.
+
+2006-07-11 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/sound/sampled/AU/AUReader.java:
+ Correct file extension from .as to .au.
+
+2006-07-11 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/sound/sampled/AU/AUReader.java:
+ New file.
+ * resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader:
+ Added new provider.
+
+2006-07-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTable.java
+ (setRowSelectionAllowed): Fire required PropertyChangeEvent,
+ (setColumnSelectionAllowed): Likewise.
+
+2006-07-10 Vivek Lakshmanan <vivekl@redhat.com>
+
+ PR 27649:
+ * gnu/classpath/debug/Simple1LineFormatter.java: Use
+ AccessController.doPrivileged instead of SystemProperties.getProperty.
+ * gnu/classpath/debug/SystemLogger.java: Likewise.
+ * gnu/java/security/PolicyFile.java: Likewise and cut unnecessary
+ repeated getProperty calls for "file.seperator".
+ (refresh): Since already in privileged block, call System.getProperty
+ instead of SystemProperties.getProperty.
+ * gnu/java/security/key/dss/DSSKey.java
+ (toString): Use AccessController.doPrivileged instead of
+ SystemProperties.getProperty.
+ * gnu/java/security/key/dss/DSSPrivateKey.java
+ (toString): Likewise.
+ * gnu/java/security/key/dss/DSSPublicKey.java
+ (toString): Likewise.
+ * gnu/java/security/key/rsa/GnuRSAKey.java
+ (toString): Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPrivateKey.java
+ (toString): Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPublicKey.java
+ (toString): Likewise.
+ * gnu/javax/crypto/sasl/plain/PasswordFile.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHKey.java
+ (toString): Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
+ (toString): Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHPublicKey.java
+ (toString): Likewise.
+
+2006-07-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (disabledIcon): Fixed name (was 'disabeldIcon'),
+ (getDisabledIcon): Updated for corrected field name,
+ (setDisabledIcon): Fire a PropertyChangeEvent.
+
+2006-07-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultBoundedRangeModel.java
+ (readObject): New private method,
+ (writeObject): Likewise.
+
+2006-07-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/ButtonGroup.java
+ (add): Ignore null argument,
+ (remove): Ignore null argument. If removing selected button, clear the
+ sel field,
+ (findButton): Changed case for method name, and documented,
+ (setSelected): Updated for modification to findButton() method name,
+ (isSelected): Updated API docs.
+
+2006-07-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BufferedImage.java
+ (BufferedImage(int, int, int)): Use correct color space for
+ TYPE_BYTE_GRAY and TYPE_USHORT_GRAY, and throw an
+ IllegalArgumentException for an unrecognised type.
+
2006-07-10 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/lang/management/ManagementFactory.java:
@@ -12,10 +763,149 @@
(getMemoryManagerMXBeans): Likewise.
(getGarbageCollectorMXBeans): Likewise.
+2006-07-10 Mario Torre <neugens@limasoftware.net>
+
+ * java/awt/BasicStroke.java: Removed unused import.
+ * gnu/java/awt/java2d/CubicSegment.java (clone): Fixed.
+ * gnu/java/awt/java2d/LineSegment.java (clone): Fixed.
+ * gnu/java/awt/java2d/QuadSegment.java (clone): Fixed.
+
+2006-07-10 Matt Wringe <mwringe@redhat.com>
+
+ PR classpath/28212:
+ * javax/crypto/spec/SecretKeySpec.java
+ (equals): Check object type.
+
+2006-07-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/StructureToPassHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/StructureToReturnHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/TreeNodeHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/WeThrowThisExceptionHelper.java,
+ gnu/CORBA/ForwardRequestHelper.java,
+ org/omg/CORBA/CompletionStatusHelper.java,
+ org/omg/CORBA/CurrentHelper.java,
+ org/omg/CORBA/DefinitionKindHelper.java,
+ org/omg/CORBA/IDLTypeHelper.java,
+ org/omg/CORBA/NameValuePairHelper.java,
+ org/omg/CORBA/ObjectHelper.java,
+ org/omg/CORBA/ParameterModeHelper.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/ServiceDetailHelper.java,
+ org/omg/CORBA/ServiceInformationHelper.java,
+ org/omg/CORBA/SetOverrideTypeHelper.java,
+ org/omg/CORBA/StringValueHelper.java,
+ org/omg/CORBA/UnionMemberHelper.java,
+ org/omg/CORBA/UnknownUserExceptionHelper.java,
+ org/omg/CORBA/VisibilityHelper.java,
+ org/omg/CORBA/WStringValueHelper.java,
+ org/omg/CORBA/WrongTransactionHelper.java,
+ org/omg/CosNaming/BindingHelper.java,
+ org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/BindingListHelper.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/StringNameHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java,
+ org/omg/CosNaming/NamingContextHelper.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java,
+ org/omg/DynamicAny/AnySeqHelper.java,
+ org/omg/DynamicAny/DynAnyFactoryHelper.java,
+ org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java,
+ org/omg/DynamicAny/DynAnyHelper.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/DynUnionHelper.java,
+ org/omg/DynamicAny/DynValueHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairSeqHelper.java,
+ org/omg/DynamicAny/NameValuePairHelper.java,
+ org/omg/DynamicAny/NameValuePairSeqHelper.java,
+ org/omg/IOP/CodecFactoryHelper.java,
+ org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.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/IORHelper.java,
+ org/omg/IOP/MultipleComponentProfileHelper.java,
+ org/omg/IOP/ProfileIdHelper.java,
+ org/omg/IOP/ServiceContextHelper.java,
+ org/omg/IOP/ServiceContextListHelper.java,
+ org/omg/IOP/ServiceIdHelper.java,
+ org/omg/IOP/TaggedComponentHelper.java,
+ org/omg/IOP/TaggedProfileHelper.java,
+ org/omg/PortableInterceptor/AdapterManagerIdHelper.java,
+ org/omg/PortableInterceptor/AdapterNameHelper.java,
+ org/omg/PortableInterceptor/AdapterStateHelper.java,
+ org/omg/PortableInterceptor/CurrentHelper.java,
+ org/omg/PortableInterceptor/ForwardRequestHelper.java,
+ org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java,
+ org/omg/PortableInterceptor/InvalidSlotHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java,
+ org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java,
+ org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java,
+ org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java,
+ org/omg/PortableServer/CurrentHelper.java,
+ org/omg/PortableServer/CurrentPackage/NoContextHelper.java,
+ org/omg/PortableServer/ForwardRequestHelper.java,
+ org/omg/PortableServer/POAHelper.java,
+ org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java,
+ org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java,
+ org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java,
+ org/omg/PortableServer/POAPackage/InvalidPolicyHelper.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/ServantActivatorHelper.java,
+ org/omg/PortableServer/ServantLocatorHelper.java: Remove the
+ typecode caching and always use OrbRestricted.Singleton.
+
2006-07-09 Tom Tromey <tromey@redhat.com>
* java/util/logging/LoggingMXBean.java (getLoggerNames): Genericized.
+2006-07-09 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java (hasXRenderExtension):
+ New static final boolean field.
+ (getComponentGraphics): Use hasXRenderExtension.
+ (setClip): Override method for locking.
+
+2006-07-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (setHorizontalTextPosition): Added check for illegal argument,
+ (setVerticalTextPosition): Likewise.
+
2006-07-09 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/Timer.java
diff --git a/NEWS b/NEWS
index e8840af0c..c010a068f 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,7 @@ New in release 0.92 (UNRELEASED)
* We've imported the JSR 166 (concurrency) reference implementation.
* javax.sound.midi providers have been added to read and
write standard MIDI files.
+* New Java Virtual Machine Tool Interface header, jvmti.h.
Runtime interface changes:
diff --git a/autogen.sh b/autogen.sh
index babfa4e5d..9919d15b4 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -41,11 +41,14 @@ if autoconf --version < /dev/null > /dev/null 2>&1 ; then
2.59*)
have_autoconf=true
;;
+ 2.60*)
+ have_autoconf=true
+ ;;
esac
fi
if $have_autoconf ; then : ; else
echo
- echo "You must have autoconf 2.59 installed to compile $PROJECT."
+ echo "You must have autoconf 2.59 or 2.60 installed for $PROJECT."
echo "Install the appropriate package for your distribution,"
echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
DIE=1
diff --git a/configure.ac b/configure.ac
index 6bee7cff2..f5a9a1c03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -811,7 +811,8 @@ lib/gen-classlist.sh
lib/copy-vmresources.sh
tools/Makefile
examples/Makefile
-examples/Makefile.jawt])
+examples/Makefile.jawt
+examples/Makefile.java2d])
if test "x${COMPILE_WRAPPERS}" = xno
then
diff --git a/doc/vmintegration.texinfo b/doc/vmintegration.texinfo
index 02c81b5cf..bd7464e49 100644
--- a/doc/vmintegration.texinfo
+++ b/doc/vmintegration.texinfo
@@ -12,7 +12,7 @@ This file contains important information you will need to know if you
are going to write an interface between GNU Classpath and a Virtual
Machine.
-Copyright (C) 1998-2002, 2004, 2005 Free Software Foundation, Inc.
+Copyright (C) 1998-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
@ifnotplaintext
@dircategory GNU Libraries
@@ -66,6 +66,7 @@ This document is incomplete, as we are still in alpha with the interface.
* Classpath Hooks:: Hooks from Classpath to the VM
* VM Hooks:: Hooks from the underlying VM to Classpath
* JNI Implementation:: Hooking the VM to jni.h
+* JVMTI Implementation:: Hooking the VM to jvmti.h
* Miscellaneous VM Requirements::
@end menu
@@ -1605,7 +1606,7 @@ number of milliseconds for which the garbage collector has run.
@end itemize
Note that each garbage collector is also a memory manager, and so an
-implementation of the @xref{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
+implementation of the @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
methods for its name should also be provided.
@node java.lang.management, Classpath Callbacks, gnu.java.lang.management, Classpath Hooks
@@ -1748,7 +1749,7 @@ reinitialize it yourself, there should be no harm.
@end itemize
-@node JNI Implementation, Miscellaneous VM Requirements, VM Hooks, Top
+@node JNI Implementation, JVMTI Implementation, VM Hooks, Top
@comment node-name, next, previous, up
@chapter JNI Implementation
@@ -1791,8 +1792,33 @@ be a sequence of field declarations.
@end itemize
+@node JVMTI Implementation, Miscellaneous VM Requirements, JNI Implementation, Top
+@comment node-name, next, previous, up
+@chapter JVMTI Implementation
+
+Classpath comes with its own implementation of @file{jvmti.h}. This
+file can be customized by the VM in a few ways by defining macros that
+affect the interpretation of the file. These macros are all intended
+for use for use by a VM which uses GNU Classpath and which wants to
+use a single copy of @file{jvmti.h} for both internal and external use.
+
+@itemize @bullet
+@item _CLASSPATH_VM_JVMTI_TYPES_DEFINED
+Some VMs like to define JVMTI ``object'' types in a special way. If
+this macro is defined, the Classpath @file{jvmti.h} will avoid defining
+these types. By default these types are defined in @file{jvmti.h}.
+The full list of types and macros treated this way is: @samp{jthread},
+@samp{jthreadGroup}, @samp{jlocation}, and @samp{jrawMonitorID}. By
+default @samp{jrawMonitorID} is defined as an opaque pointer which
+must be defined by the VM.
+
+@item _CLASSPATH_JVMTIENV_CONTENTS
+A VM can add fields to the @samp{jvmtiEnv} structure by defining this
+to be a sequence of field declarations.
+
+@end itemize
-@node Miscellaneous VM Requirements, , JNI Implementation, Top
+@node Miscellaneous VM Requirements, , JVMTI Implementation, Top
@comment node-name, next, previous, up
@chapter Miscellaneous VM Requirements
diff --git a/examples/.cvsignore b/examples/.cvsignore
index 56910f344..d79d635e8 100644
--- a/examples/.cvsignore
+++ b/examples/.cvsignore
@@ -2,3 +2,5 @@ Makefile
Makefile.in
examples.zip
Makefile.jawt
+Makefile.java2d
+
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 774abd021..ee5f7dfba 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -23,8 +23,9 @@ endif
# All our example java source files
EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java
-# The example C source files
+# The example C source & header files
EXAMPLE_C_FILES = $(srcdir)/gnu/classpath/examples/*/*.c
+EXAMPLE_CH_FILES = $(srcdir)/gnu/classpath/examples/*/*.h
# The zip files with classes we want to produce.
EXAMPLE_ZIP = examples.zip
@@ -39,7 +40,7 @@ EXAMPLE_ICONS = $(srcdir)/gnu/classpath/examples/icons/*.png
READMES = $(srcdir)/gnu/classpath/examples/CORBA/swing/README.html
# All the files we find "interesting"
-ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_ICONS) $(READMES)
+ALL_EXAMPLE_FILES = $(EXAMPLE_JAVA_FILES) $(EXAMPLE_C_FILES) $(EXAMPLE_CH_FILES) $(EXAMPLE_ICONS) $(READMES)
# Some architecture independent data to be installed.
example_DATA = $(EXAMPLE_ZIP) README
@@ -62,7 +63,9 @@ install-data-local:
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/examples/$$f; \
done
echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/"
+ echo "$(INSTALL_DATA) Makefile.java2d $(DESTDIR)$(pkgdatadir)/examples/"
$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/
+ $(INSTALL_DATA) Makefile.java2d $(DESTDIR)$(pkgdatadir)/examples/
uninstall-local:
srcdir_cnt=`echo $(srcdir) | wc -c`; \
@@ -72,10 +75,12 @@ uninstall-local:
rm -f $(DESTDIR)$(pkgdatadir)/examples/$$f; \
done
echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt"
+ echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.java2d"
rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt
+ rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.java2d
# Make sure everything is included in the distribution.
-EXTRA_DIST = README Makefile.jawt.in
+EXTRA_DIST = README Makefile.jawt.in Makefile.java2d.in
dist-hook:
srcdir_cnt=`echo $(srcdir) | wc -c`; \
for file in $(ALL_EXAMPLE_FILES); do \
diff --git a/examples/Makefile.java2d.in b/examples/Makefile.java2d.in
new file mode 100644
index 000000000..dac22068c
--- /dev/null
+++ b/examples/Makefile.java2d.in
@@ -0,0 +1,17 @@
+# @configure_input@
+
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+includedir = @includedir@
+libdir = @libdir@
+pkglibdir = $(libdir)/@PACKAGE@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+
+all: $(srcdir)/gnu/classpath/examples/java2d/bench.c $(srcdir)/gnu/classpath/examples/java2d/bench.h
+ gcc -g -O0 -Wall -I$(srcdir)/gnu/classpath/examples/java2d $(GTK_CFLAGS) -L$(GTK_LIBS) \
+ -o cairobench $(srcdir)/gnu/classpath/examples/java2d/bench.c
+
+clean:
+ rm -f gnu/classpath/examples/java2d/bench
diff --git a/examples/README b/examples/README
index 727677363..f7bf59962 100644
--- a/examples/README
+++ b/examples/README
@@ -46,6 +46,23 @@ You can then run the example as follows:
export LD_LIBRARY_PATH=.:/usr/local/classpath/lib/classpath
jamvm gnu.classpath.examples.jawt.DemoJAWT
+The java2d benchmarking demos include a GTK widget to measure the native
+speed of some basic java2d options, without the JNI overhead.
+
+You can invoke it with:
+
+ make -f Makefile.java2d
+
+Or you can compile by hand as follows:
+
+ gcc -g -O0 -Wall -I./gnu/classpath/examples/java2d \
+ -o cairobench gnu/classpath/examples/java2d/bench.c \
+ `pkg-config --libs --cflags gtk+-2.0`
+
+You can then run the example as follows:
+
+ ./cairobench
+
All example code is distributed under the GNU General Public License (GPL).
The example icons used in some of the examples come from gnome-icon-theme
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
index c41ebe237..652ee53cc 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
@@ -81,13 +83,14 @@ public abstract class StructureToPassHelper
*/
public static synchronized TypeCode type()
{
- StructMember[] members = new StructMember[ 2 ];
+ StructMember[] members = new StructMember[2];
TypeCode member = null;
- member = ORB.init().create_string_tc(0);
- members [ 0 ] = new StructMember("a", member, null);
- member = ORB.init().create_string_tc(0);
- members [ 1 ] = new StructMember("b", member, null);
- return ORB.init().create_struct_tc(StructureToPassHelper.id(), "StructureToPass", members);
+ member = OrbRestricted.Singleton.create_string_tc(0);
+ members[0] = new StructMember("a", member, null);
+ member = OrbRestricted.Singleton.create_string_tc(0);
+ members[1] = new StructMember("b", member, null);
+ return OrbRestricted.Singleton.create_struct_tc(StructureToPassHelper.id(),
+ "StructureToPass", members);
}
/**
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
index 42fb7a574..2ac03a895 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
@@ -86,17 +88,18 @@ public abstract class StructureToReturnHelper
*/
public static synchronized TypeCode type()
{
- StructMember[] members = new StructMember[ 3 ];
- TypeCode member = ORB.init().get_primitive_tc(TCKind.tk_long);
- members [ 0 ] = new StructMember("n", member, null);
- member = ORB.init().create_string_tc(0);
- members [ 1 ] = new StructMember("c", member, null);
- member = ORB.init().get_primitive_tc(TCKind.tk_long);
- member = ORB.init().create_array_tc(3, member);
- members [ 2 ] = new StructMember("arra", member, null);
- return ORB.init().create_struct_tc(StructureToReturnHelper.id(), "StructureToReturn",
- members
- );
+ StructMember[] members = new StructMember[3];
+ TypeCode member = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
+ members[0] = new StructMember("n", member, null);
+ member = OrbRestricted.Singleton.create_string_tc(0);
+ members[1] = new StructMember("c", member, null);
+ member = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
+ member = OrbRestricted.Singleton.create_array_tc(3, member);
+ members[2] = new StructMember("arra", member, null);
+ return OrbRestricted.Singleton.create_struct_tc(
+ StructureToReturnHelper.id(),
+ "StructureToReturn",
+ members);
}
/**
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
index f111d0eac..ccf792da8 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
@@ -38,6 +38,9 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
@@ -128,18 +131,18 @@ public abstract class TreeNodeHelper
// To avoid the infinite recursion loop, the
// recursive reference is handled in specific way.
if (active)
- return ORB.init().create_recursive_tc(_id);
+ return OrbRestricted.Singleton.create_recursive_tc(_id);
active = true;
// List all memebers of the TreeNode structure.
StructMember[] members = new StructMember[ 2 ];
TypeCode memberType;
- memberType = ORB.init().create_string_tc(0);
+ memberType = OrbRestricted.Singleton.create_string_tc(0);
members [ 0 ] = new StructMember("name", memberType, null);
- memberType = ORB.init().create_recursive_tc("");
+ memberType = OrbRestricted.Singleton.create_recursive_tc("");
members [ 1 ] = new StructMember("children", memberType, null);
typeCode =
- ORB.init().create_struct_tc(TreeNodeHelper.id(), "TreeNode", members);
+ OrbRestricted.Singleton.create_struct_tc(TreeNodeHelper.id(), "TreeNode", members);
active = false;
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
index 4d5eee74b..6ad13a9bb 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
@@ -96,9 +98,9 @@ public abstract class WeThrowThisExceptionHelper
{
StructMember[] members = new StructMember[ 1 ];
TypeCode member = null;
- member = ORB.init().get_primitive_tc(TCKind.tk_long);
+ member = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
members [ 0 ] = new StructMember("ourField", member, null);
- return ORB.init().create_struct_tc(WeThrowThisExceptionHelper.id(),
+ return OrbRestricted.Singleton.create_struct_tc(WeThrowThisExceptionHelper.id(),
"WeThrowThisException", members
);
}
diff --git a/examples/gnu/classpath/examples/java2d/bench.c b/examples/gnu/classpath/examples/java2d/bench.c
new file mode 100644
index 000000000..e5b45aa1c
--- /dev/null
+++ b/examples/gnu/classpath/examples/java2d/bench.c
@@ -0,0 +1,606 @@
+/* bench.c -- native benchmark for Cairo library (meant to test java2d)
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+#include "bench.h"
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <sys/timeb.h>
+
+G_DEFINE_TYPE (Benchmark, benchmark, GTK_TYPE_DRAWING_AREA);
+
+// Needed for the gtk widget, but not used:
+static void
+benchmark_class_init (BenchmarkClass *klass)
+{
+}
+
+static void
+benchmark_init (Benchmark *obj)
+{
+}
+
+// The Arc2D's PathIterator uses some transforms, so we condense the required
+// functionality of AffineTransform
+static void
+doTransform (double rx, double ry, double theta, double *cvec)
+{
+ // Define identity matrix (corresponds to new AffineTransform())
+ double m00 = 1;
+ double m10 = 0;
+ double m01 = 0;
+ double m11 = 1;
+ double m02 = 0;
+ double m12 = 0;
+
+ // AffineTransform.scale(rx, ry)
+ m00 = m00 * rx;
+ m01 = m01 * ry;
+ m10 = m10 * rx;
+ m11 = m11 * ry;
+
+ // AffineTransform.rotate(theta)
+ double c = cos(theta);
+ double s = sin(theta);
+ double n00 = m00 * c + m01 * s;
+ double n01 = m00 * -s + m01 * c;
+ double n10 = m10 * c + m11 * s;
+ double n11 = m10 * -s + m11 * c;
+
+ m00 = n00;
+ m01 = n01;
+ m10 = n10;
+ m11 = n11;
+
+ // AffineTransform.transform(cvec, 0, cvec, 0, 1)
+ double dstPts[2];
+ dstPts[0] = (float) (m00 * cvec[0] + m01 * cvec[1] + m02);
+ dstPts[1] = (float) (m10 * cvec[0] + m11 * cvec[1] + m12);
+ cvec[0] = dstPts[0];
+ cvec[1] = dstPts[1];
+}
+
+// Place an arc on the cairo path, simulating java2d's Arc2D
+static void
+setupArc(cairo_t *cr, GtkWidget *bench, int shift)
+{
+ double x, y;
+
+ // Normally passed into the Arc2D constructor
+ x = bench->allocation.x + (rand() % (bench->allocation.width - minSize + 1));
+ y = bench->allocation.y + (rand() % (bench->allocation.height - minSize + 1));
+
+ int angle = rand() % 360;
+ int length = (rand() % 360) - angle;
+ int width = rand() % (int)((bench->allocation.width - x - 10) + 10);
+ int height = rand() % (int)((bench->allocation.height - y - 10) + 10);
+
+ // This is from the ArcPath iterator
+ double start = angle * (M_PI / 180);
+ double extent = length * (M_PI / 180);
+
+ if (extent < 0)
+ {
+ extent = -extent;
+ start = 2 * M_PI - extent + start;
+ }
+
+ int limit;
+ if (width < 0 || height < 0) // We assume type == 0; ie, Arc2D.OPEN
+ limit = -1;
+ else if (extent == 0)
+ limit = 0;
+ else if (extent <= M_PI / 2.0)
+ limit = 1;
+ else if (extent <= M_PI)
+ limit = 2;
+ else if (extent <= 3.0 * (M_PI / 2.0))
+ limit = 3;
+ else
+ limit = 4;
+
+ // This is from CairoGraphics2D.walkPath
+ double xnew = 0;
+ double ynew = 0;
+ double coords[6];
+
+ cairo_fill_rule_t cfillrule = CAIRO_FILL_RULE_WINDING;
+ cairo_set_fill_rule(cr, cfillrule);
+
+ // First iteration will move to the starting point
+ double rx = width / 2;
+ double ry = height / 2;
+ double xmid = x + rx;
+ double ymid = y + ry;
+ coords[0] = xmid + rx * cos(start);
+ coords[1] = ymid - ry * sin(start);
+
+ if (shift == 1)
+ {
+ xnew = floor(coords[0]) + 0.5;
+ ynew = floor(coords[1]) + 0.5;
+ }
+ else
+ {
+ xnew = coords[0];
+ ynew = coords[1];
+ }
+
+ cairo_move_to(cr, xnew, ynew);
+
+ // Iterate through segments of the arc
+ int current;
+ for (current = 1; current <= limit; current++)
+ {
+ // Back to the ArcPath iterator's getCurrent
+ double kappa = (sqrt(2.0) - 1.0) * (4.0 / 3.0);
+ double quad = (M_PI / 2.0);
+
+ double curr_begin = start + (current - 1) * quad;
+ double curr_extent;
+
+ if (start + extent - curr_begin < quad)
+ curr_extent = (start + extent) - curr_begin;
+ else
+ curr_extent = quad;
+
+ double portion_of_a_quadrant = curr_extent / quad;
+
+ double x0 = xmid + rx * cos(curr_begin);
+ double y0 = ymid - ry * sin(curr_begin);
+
+ double x1 = xmid + rx * cos(curr_begin + curr_extent);
+ double y1 = ymid - ry * sin(curr_begin + curr_extent);
+
+ double cvec[2];
+ double len = kappa * portion_of_a_quadrant;
+ double angle = curr_begin;
+
+ cvec[0] = 0;
+ cvec[1] = len;
+ doTransform(rx, ry, angle, cvec);
+ coords[0] = x0 + cvec[0];
+ coords[1] = y0 - cvec[1];
+
+ cvec[0] = 0;
+ cvec[1] = -len;
+ doTransform(rx, ry, angle, cvec);
+ doTransform(1, 1, curr_extent, cvec);
+ coords[2] = x1 + cvec[0];
+ coords[3] = y1 - cvec[1];
+
+ coords[4] = x1;
+ coords[5] = y1;
+
+ // draw it, from CairoGraphics2D.walkPath
+ if (shift == 1)
+ {
+ xnew = floor(coords[4]) + 0.5;
+ ynew = floor(coords[5]) + 0.5;
+ cairo_curve_to(cr, floor(coords[0]) + 0.5, floor(coords[1]) + 0.5,
+ floor(coords[2]) + 0.5, floor(coords[3]) + 0.5,
+ xnew, ynew);
+ }
+ else
+ {
+ xnew = coords[4];
+ ynew = coords[5];
+ cairo_curve_to(cr, coords[0], coords[1], coords[2],
+ coords[3], xnew, ynew);
+ }
+ }
+
+ // Randomize the colour, just for asthetics =)
+ cairo_set_source_rgb(cr, (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100));
+
+}
+
+// Place a beizer curve on the cairo path, simulating java2d's CubicCurve2D
+static void
+setupCurve(cairo_t *cr, GtkWidget *bench, int shift)
+{
+ // These are options when creating a new curve
+ int x1 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y1 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+ int xc1 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int yc1 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+ int xc2 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int yc2 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+ int x2 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y2 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+
+ // From CairoGraphics2D.walkPath
+ double xnew = 0;
+ double ynew = 0;
+ double coords[6];
+
+ cairo_fill_rule_t cfillrule = CAIRO_FILL_RULE_WINDING;
+ cairo_set_fill_rule(cr, cfillrule);
+
+ // And into CubicCurve's PathIterator...
+ // start by moving to the starting coordinate
+ coords[0] = (float) x1;
+ coords[1] = (float) y1;
+
+ if (shift == 1)
+ {
+ xnew = floor(coords[0]) + 0.5;
+ ynew = floor(coords[1]) + 0.5;
+ }
+ else
+ {
+ xnew = coords[0];
+ ynew = coords[1];
+ }
+
+ cairo_move_to(cr, xnew, ynew);
+
+ // Now the curve itself
+ coords[0] = (float) xc1;
+ coords[1] = (float) yc1;
+ coords[2] = (float) xc2;
+ coords[3] = (float) yc2;
+ coords[4] = (float) x2;
+ coords[5] = (float) y2;
+
+ if (shift == 1)
+ {
+ xnew = floor(coords[4]) + 0.5;
+ ynew = floor(coords[5]) + 0.5;
+ cairo_curve_to(cr, floor(coords[0]) + 0.5, floor(coords[1]) + 0.5,
+ floor(coords[2]) + 0.5, floor(coords[3]) + 0.5,
+ xnew, ynew);
+ }
+ else
+ {
+ xnew = coords[4];
+ ynew = coords[5];
+ cairo_curve_to(cr, coords[0], coords[1], coords[2],
+ coords[3], xnew, ynew);
+ }
+
+ // Randomize colour for asthetics
+ cairo_set_source_rgb(cr, (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100));
+}
+
+// Place a line on the cairo path, simulating java2d's Line2D
+static void
+setupLine(cairo_t *cr, GtkWidget *bench, int shift)
+{
+ // These are set when you create a line
+ int x1 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y1 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+ int x2 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y2 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+
+ // This is from CairoGraphics2D.walkPath
+ double xnew = 0;
+ double ynew = 0;
+ double coords[6];
+
+ cairo_fill_rule_t cfillrule = CAIRO_FILL_RULE_WINDING;
+ cairo_set_fill_rule(cr, cfillrule);
+
+ // And into Line2D's PathIterator
+ coords[0] = (float) x1;
+ coords[1] = (float) y1;
+
+ if (shift == 1)
+ {
+ xnew = floor(coords[0]) + 0.5;
+ ynew = floor(coords[1]) + 0.5;
+ }
+ else
+ {
+ xnew = coords[0];
+ ynew = coords[1];
+ }
+
+ cairo_move_to(cr, xnew, ynew);
+
+ coords[0] = (float) x2;
+ coords[1] = (float) y2;
+
+ if (shift == 1)
+ {
+ xnew = floor(coords[0]) + 0.5;
+ ynew = floor(coords[1]) + 0.5;
+ }
+ else
+ {
+ xnew = coords[0];
+ ynew = coords[1];
+ }
+
+ cairo_line_to(cr, xnew, ynew);
+
+ // Randomize colour for asthetics
+ cairo_set_source_rgb(cr, (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100));
+}
+
+// Place a rectangle on the cairo path, simulating java2d's Rectangle2D
+static void
+setupRect(cairo_t *cr, GtkWidget *bench, int shift)
+{
+ // These are set when you create a rectangle
+ int x1 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y1 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+ int x2 = bench->allocation.x + (rand() % (bench->allocation.width - minSize));
+ int y2 = bench->allocation.y + (rand() % (bench->allocation.height - minSize));
+
+ // draw() and fill() have been optimized to ignore the PathIterator.
+ // We do the same here.
+ double xnew = 0;
+ double ynew = 0;
+
+ if (shift == 1)
+ {
+ xnew = floor(x1) + 0.5;
+ ynew = floor(y1) + 0.5;
+ }
+ else
+ {
+ xnew = x1;
+ ynew = y1;
+ }
+
+ cairo_rectangle(cr, x1, y1, x2, y2);
+
+ // Randomize colour for asthetics
+ cairo_set_source_rgb(cr, (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100),
+ (rand() % 100 / (float)100));
+}
+
+// The real work gets done here: this function is called when the widget
+// is drawn on screen.
+static void
+draw (GtkWidget *bench, cairo_t *cr)
+{
+ // Setup
+ struct timeb t1, t2;
+ int i, timeElapsed;
+
+ cairo_set_line_width(cr, lineWidth);
+
+ if (antialias == 0)
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+ else
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_GRAY);
+
+ // Tell the user what's going on
+ printf("Testing native cairo drawing..\n");
+ printf(" Screen size is %d x %d \n", screenWidth, screenHeight);
+ printf(" Line width is %d\n", lineWidth);
+ printf(" Test size: %d\n", testSize);
+
+ if (antialias == 0)
+ printf(" Anti-alias is off\n");
+ else
+ printf(" Anti-alias is on\n");
+
+ printf("\n");
+ fflush(stdout);
+
+ // Draw & fill Arc
+ if (arcTest == 1)
+ {
+ // Draw
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupArc(cr, bench, 1);
+ cairo_stroke (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Draw arc: %d ms\n", timeElapsed);
+ fflush(stdout);
+
+ // Fill
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupArc(cr, bench, 0);
+ cairo_fill (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Fill arc: %d ms\n", timeElapsed);
+ }
+
+ // Draw cubic curve
+ if (curveTest == 1)
+ {
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupCurve(cr, bench, 1);
+ cairo_stroke (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Draw cubic curve: %d ms\n", timeElapsed);
+ }
+
+ // Ellipse: skip; this is just a special case of arc
+ // General path: skip; this doesn't even work in java2d
+
+ // Draw Line
+ if (lineTest == 1)
+ {
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupLine(cr, bench, 1);
+ cairo_stroke (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Draw line: %d ms\n", timeElapsed);
+ }
+
+ // Draw & fill Rectangle
+ if (rectTest == 1)
+ {
+ // Draw
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupRect(cr, bench, 1);
+ cairo_stroke (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Draw rectangle: %d ms\n", timeElapsed);
+
+ // Fill
+ ftime(&t1);
+ for (i = 0; i < testSize; i++)
+ {
+ setupRect(cr, bench, 0);
+ cairo_fill (cr);
+ }
+
+ ftime(&t2);
+ timeElapsed = 1000 * (t2.time - t1.time) + (t2.millitm - t1.millitm);
+ printf("Fill rectangle: %d ms\n", timeElapsed);
+ }
+
+ // Round rectangle: skip, it's just a combination of lines and curves
+ // Image: skip?
+
+ printf("\n");
+}
+
+GtkWidget *
+benchmark_new (void)
+{
+ return g_object_new (BENCHMARK_TYPE, NULL);
+}
+
+int
+main (int argc, char **argv)
+{
+ // Set defaults
+ minSize = 10;
+ arcTest = 0;
+ curveTest = 0;
+ lineTest = 0;
+ rectTest = 0;
+ screenWidth = 320;
+ screenHeight = 240;
+ testSize = 1000;
+ antialias = 0;
+ lineWidth = 1;
+
+ // Process any command-line user options
+ int i;
+ for (i = 1; i < argc; i++)
+ {
+ // Process options first
+ if (!strcmp(argv[i], "-a"))
+ antialias = 1;
+ else if (!strcmp(argv[i], "-h"))
+ screenHeight = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-l"))
+ lineWidth = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-t"))
+ testSize = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-w"))
+ screenWidth = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--h")
+ || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help"))
+ {
+ printf("Cairo benchmarker, meant to measure JNI overhead\n");
+ printf("Usage: bench [-a] [-h height] [-t test size] [-w width] [tests...]\n");
+ printf("\n");
+ printf(" Valid options: -a turn on anti-aliasing (default off)\n");
+ printf(" -h set screen height (default 240)\n");
+ printf(" -l set stroke line width (default 1)\n");
+ printf(" -t set test size (default 1000)\n");
+ printf(" -w set screen width (default 320)\n");
+ printf(" -h | --help\n");
+ printf(" Valid tests: arc\n");
+ printf(" curve\n");
+ printf(" line\n");
+ printf(" rect\n");
+ printf(" (default: run all)\n");
+ exit (0);
+ }
+
+ // Process tests
+ else if (!strcmp(argv[i], "arc"))
+ arcTest = 1;
+ else if (!strcmp(argv[i], "curve"))
+ curveTest = 1;
+ else if (!strcmp(argv[i], "line"))
+ lineTest = 1;
+ else if (!strcmp(argv[i], "rect"))
+ rectTest = 1;
+ }
+
+ // If no tests were specified, we default to running all of them
+ if (arcTest == 0 && curveTest == 0 && lineTest == 0 && rectTest == 0)
+ {
+ arcTest = 1;
+ curveTest = 1;
+ lineTest = 1;
+ rectTest = 1;
+ }
+
+ // Set up gtk widget
+ GtkWidget *window, *bench;
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_resize(GTK_WINDOW(window), screenWidth, screenHeight);
+ gtk_window_set_title(GTK_WINDOW(window), "cairo benchmark");
+
+ // Set up benchmkar and cairo surface
+ bench = benchmark_new ();
+ gtk_container_add (GTK_CONTAINER (window), bench);
+ gtk_widget_show_all (window);
+
+ cairo_t *cr;
+ cr = gdk_cairo_create (bench->window);
+
+ // Run tests
+ draw (bench, cr);
+
+ // Hold output on screen until user exits.
+ printf("Press any key to exit.\n");
+ getchar();
+ exit(0);
+gtk_main();
+}
diff --git a/examples/gnu/classpath/examples/java2d/bench.h b/examples/gnu/classpath/examples/java2d/bench.h
new file mode 100644
index 000000000..aebd50a67
--- /dev/null
+++ b/examples/gnu/classpath/examples/java2d/bench.h
@@ -0,0 +1,64 @@
+/* bench.h -- native benchmark for Cairo library (meant to test java2d)
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+#ifndef __BENCH_H__
+#define __BENCH_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define BENCHMARK_TYPE (benchmark_get_type())
+#define BENCHMARK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj, BENCHMARK_TYPE, Benchmark)
+#define BENCHMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BENCHMARK_TYPE, BenchmarkClass);
+#define IS_BENCHMARK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BENCHMARK_TYPE))
+#define IS_BENCHMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BENCHMARK_TYPE))
+#define BENCHMARK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BENCHMARK_TYPE, BenchmarkClass))
+
+typedef struct _Benchmark Benchmark;
+typedef struct _BenchmarkClass BenchmarkClass;
+
+struct _Benchmark {
+ GtkDrawingArea parent;
+
+};
+
+struct _BenchmarkClass {
+ GtkDrawingAreaClass parent_class;
+};
+
+GType benchmark_get_type (void);
+GtkWidget *benchmark_new (void);
+
+static int minSize;
+static int antialias;
+static int arcTest;
+static int curveTest;
+static int lineTest;
+static int rectTest;
+
+static int screenHeight;
+static int screenWidth;
+static int testSize;
+static int lineWidth;
+
+G_END_DECLS
+
+#endif
diff --git a/examples/gnu/classpath/examples/swing/HtmlDemo.java b/examples/gnu/classpath/examples/swing/HtmlDemo.java
index 988b0bd0e..223ee07cd 100644
--- a/examples/gnu/classpath/examples/swing/HtmlDemo.java
+++ b/examples/gnu/classpath/examples/swing/HtmlDemo.java
@@ -52,6 +52,8 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
+import javax.swing.text.Element;
+import javax.swing.text.html.HTMLDocument;
/**
* Parses and displays HTML content.
@@ -63,14 +65,17 @@ public class HtmlDemo extends JPanel
JTextPane html = new JTextPane();
- JTextArea text = new JTextArea("<html><body><p>" +
+ JTextArea text = new JTextArea("<html><body>" +
"123456789HR!<hr>987654321"+
"123456789BR!<br>987654321"+
+ "<p id='insertHere'>Insertion target</p><p>"+
"<font color=red>ma</font>"+
"<sup>sup</sup>normal<sub>sub</sub>normal</p><p>Table:"+
"<table><tr>a<td>b<td>c<tr>x<td>y<td>z</table></body></html>");
JPanel buttons;
+
+ int n;
public HtmlDemo()
{
@@ -111,7 +116,131 @@ public class HtmlDemo extends JPanel
});
buttons.add(parse);
+
+ JButton insertBeforeEnd = new JButton("before end");
+ insertBeforeEnd.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.insertBeforeEnd(el,"before end "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ JButton insertBeforeStart = new JButton("before start");
+ insertBeforeStart.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.insertBeforeStart(el,"before start "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ JButton insertAfterEnd = new JButton("after end");
+ insertAfterEnd.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.insertAfterEnd(el,"after end "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ JButton insertAfterStart = new JButton("after start");
+ insertAfterStart.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.insertAfterStart(el,"after start "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+
+ JButton setInner = new JButton("inner");
+ setInner.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.setInnerHTML(el,"inner "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ JButton setOuter = new JButton("outer");
+ setOuter.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ HTMLDocument doc = (HTMLDocument) html.getDocument();
+ Element el = doc.getElement("insertHere");
+ System.out.println("Element found:"+el);
+ try
+ {
+ doc.setOuterHTML(el,"outer "+(n++));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ buttons.add(insertBeforeStart);
+ buttons.add(insertAfterStart);
+ buttons.add(insertBeforeEnd);
+ buttons.add(insertAfterEnd);
+
+ buttons.add(setInner);
+ buttons.add(setOuter);
+
add(center, BorderLayout.CENTER);
add(buttons, BorderLayout.SOUTH);
}
@@ -144,7 +273,7 @@ public class HtmlDemo extends JPanel
JFrame frame = new JFrame();
frame.getContentPane().add(demo);
- frame.setSize(new Dimension(640, 480));
+ frame.setSize(new Dimension(700, 480));
frame.setVisible(true);
}
});
diff --git a/gnu/CORBA/ForwardRequestHelper.java b/gnu/CORBA/ForwardRequestHelper.java
index cbdf46f25..5b77fa030 100644
--- a/gnu/CORBA/ForwardRequestHelper.java
+++ b/gnu/CORBA/ForwardRequestHelper.java
@@ -62,11 +62,6 @@ import org.omg.PortableServer.ForwardRequest;
public abstract class ForwardRequestHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the ForwardRequest from given Any.
* This method uses the ForwardRequestHolder.
*
@@ -132,18 +127,14 @@ public abstract class ForwardRequestHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 1 ];
-
- TypeCode field;
-
- field = ObjectHelper.type();
- members [ 0 ] = new StructMember("forward_reference", field, null);
- typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field = ObjectHelper.type();
+ members [ 0 ] = new StructMember("forward_reference", field, null);
+ return orb.create_exception_tc(id(), "ForwardRequest", members);
}
/**
diff --git a/gnu/classpath/debug/Simple1LineFormatter.java b/gnu/classpath/debug/Simple1LineFormatter.java
index a95f8a9d2..96573193a 100644
--- a/gnu/classpath/debug/Simple1LineFormatter.java
+++ b/gnu/classpath/debug/Simple1LineFormatter.java
@@ -38,10 +38,11 @@ exception statement from your version. */
package gnu.classpath.debug;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.security.AccessController;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@@ -94,8 +95,8 @@ public class Simple1LineFormatter
private static final String THREAD_PATTERN = " #########0;-#########0";
private static final String SPACES_32 = " ";
private static final String SPACES_6 = " ";
- private static final String LS = SystemProperties.getProperty("line.separator");
-
+ private static final String LS = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
private DateFormat dateFormat;
private NumberFormat threadFormat;
diff --git a/gnu/classpath/debug/SystemLogger.java b/gnu/classpath/debug/SystemLogger.java
index 94aa93f69..502b48870 100644
--- a/gnu/classpath/debug/SystemLogger.java
+++ b/gnu/classpath/debug/SystemLogger.java
@@ -38,7 +38,9 @@ version. */
package gnu.classpath.debug;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
+
+import java.security.AccessController;
import java.util.StringTokenizer;
import java.util.logging.Logger;
@@ -49,8 +51,8 @@ public final class SystemLogger
static
{
SYSTEM.setFilter (PreciseFilter.GLOBAL);
-
- String defaults = SystemProperties.getProperty ("gnu.classpath.debug.components");
+ String defaults = (String) AccessController.doPrivileged
+ (new GetPropertyAction("gnu.classpath.debug.components"));
if (defaults != null)
{
diff --git a/gnu/java/awt/ClasspathToolkit.java b/gnu/java/awt/ClasspathToolkit.java
index 5f093b71b..968cc3b16 100644
--- a/gnu/java/awt/ClasspathToolkit.java
+++ b/gnu/java/awt/ClasspathToolkit.java
@@ -1,5 +1,5 @@
/* ClasspathToolkit.java -- Abstract superclass for Classpath toolkits.
- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,6 +52,7 @@ import java.awt.FontMetrics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
+import java.awt.Point;
import java.awt.Toolkit;
import java.awt.font.FontRenderContext;
import java.awt.image.ColorModel;
@@ -188,6 +189,9 @@ public abstract class ClasspathToolkit
*/
public abstract Font createFont(int format, InputStream stream);
+ /**
+ * Creates a RobotPeer on a given GraphicsDevice.
+ */
public abstract RobotPeer createRobot (GraphicsDevice screen)
throws AWTException;
@@ -201,8 +205,24 @@ public abstract class ClasspathToolkit
/**
* Used to register ImageIO SPIs provided by the toolkit.
+ *
+ * Our default implementation does nothing.
*/
public void registerImageIOSpis(IIORegistry reg)
{
}
+
+ /**
+ * Returns the number of mouse buttons.
+ * (used by java.awt.MouseInfo).
+ *
+ * This dummy implementation returns -1 (no mouse).
+ * toolkit implementors should overload this method if possible.
+ * @since 1.5
+ */
+ public int getMouseNumberOfButtons()
+ {
+ return -1;
+ }
}
+
diff --git a/gnu/java/awt/java2d/CubicSegment.java b/gnu/java/awt/java2d/CubicSegment.java
index 1e568f722..7d169b78e 100644
--- a/gnu/java/awt/java2d/CubicSegment.java
+++ b/gnu/java/awt/java2d/CubicSegment.java
@@ -78,8 +78,25 @@ public class CubicSegment extends Segment
*/
public Object clone()
{
- return new CubicSegment(P1.getX(), P1.getY(), cp1.getX(), cp1.getY(),
- cp2.getX(), cp2.getY(), P2.getX(), P2.getY());
+ CubicSegment segment = null;
+
+ try
+ {
+ segment = (CubicSegment) super.clone();
+
+ segment.P1 = (Point2D) P1.clone();
+ segment.P2 = (Point2D) P2.clone();
+ segment.cp1 = (Point2D) cp1.clone();
+ segment.cp2 = (Point2D) cp2.clone();
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(cnse);
+ throw ie;
+ }
+
+ return segment;
}
/**
@@ -100,7 +117,6 @@ public class CubicSegment extends Segment
double[] p1 = normal(x0, y0, x1, y1);
double[] p2 = normal(x2, y2, x3, y3);
-
// FIXME: Doesn't compile.
// return new Segment[]{s1, s2};
return new Segment[0];
diff --git a/gnu/java/awt/java2d/LineSegment.java b/gnu/java/awt/java2d/LineSegment.java
index 9c0bcc7ea..4a34aa563 100644
--- a/gnu/java/awt/java2d/LineSegment.java
+++ b/gnu/java/awt/java2d/LineSegment.java
@@ -62,7 +62,22 @@ public class LineSegment extends Segment
*/
public Object clone()
{
- return new LineSegment(P1, P2);
+ LineSegment segment = null;
+
+ try
+ {
+ segment = (LineSegment) super.clone();
+ segment.P1 = (Point2D) P1.clone();
+ segment.P2 = (Point2D) P2.clone();
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(cnse);
+ throw ie;
+ }
+
+ return segment;
}
/**
diff --git a/gnu/java/awt/java2d/QuadSegment.java b/gnu/java/awt/java2d/QuadSegment.java
index 9c15a8cfd..c76804840 100644
--- a/gnu/java/awt/java2d/QuadSegment.java
+++ b/gnu/java/awt/java2d/QuadSegment.java
@@ -88,8 +88,24 @@ public class QuadSegment extends Segment
*/
public Object clone()
{
- return new QuadSegment(P1.getX(), P1.getY(), cp.getX(), cp.getY(),
- P2.getX(), P2.getY());
+ QuadSegment segment = null;
+
+ try
+ {
+ segment = (QuadSegment) super.clone();
+
+ segment.P1 = (Point2D) P1.clone();
+ segment.P2 = (Point2D) P2.clone();
+ segment.cp = (Point2D) cp.clone();
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(cnse);
+ throw ie;
+ }
+
+ return segment;
}
/**
diff --git a/gnu/java/awt/peer/ClasspathFontPeer.java b/gnu/java/awt/peer/ClasspathFontPeer.java
index 78ab3a9de..dad7bb0b0 100644
--- a/gnu/java/awt/peer/ClasspathFontPeer.java
+++ b/gnu/java/awt/peer/ClasspathFontPeer.java
@@ -145,7 +145,8 @@ public abstract class ClasspathFontPeer
uname.equals ("SERIF") ||
uname.equals ("MONOSPACED") ||
uname.equals ("DIALOG") ||
- uname.equals ("DIALOGINPUT"));
+ uname.equals ("DIALOGINPUT") ||
+ uname.equals ("DEFAULT"));
}
protected static String logicalFontNameToFaceName (String name)
@@ -161,6 +162,8 @@ public abstract class ClasspathFontPeer
return "Helvetica";
else if (uname.equals ("DIALOGINPUT"))
return "Helvetica";
+ else if (uname.equals ("DEFAULT"))
+ return "Dialog.plain";
else
return "Helvetica";
}
@@ -233,7 +236,7 @@ public abstract class ClasspathFontPeer
family = (String) attribs.get (TextAttribute.FAMILY);
if (name == null)
- name = "SansSerif";
+ name = "Default";
if (attribs.containsKey (TextAttribute.WEIGHT))
{
diff --git a/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
index 61871ccbc..e0da71850 100644
--- a/gnu/java/awt/peer/gtk/CairoGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
@@ -40,8 +40,8 @@ package gnu.java.awt.peer.gtk;
import gnu.java.awt.ClasspathToolkit;
-import java.awt.AlphaComposite;
import java.awt.AWTPermission;
+import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
@@ -53,11 +53,11 @@ import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
+import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
-import java.awt.Polygon;
import java.awt.TexturePaint;
import java.awt.Toolkit;
import java.awt.font.FontRenderContext;
@@ -66,6 +66,7 @@ import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
import java.awt.geom.Area;
+import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.PathIterator;
@@ -322,6 +323,11 @@ public abstract class CairoGraphics2D extends Graphics2D
* Set the current transform matrix
*/
private native void cairoSetMatrix(long pointer, double[] m);
+
+ /**
+ * Scaling method
+ */
+ private native void cairoScale(long pointer, double x, double y);
/**
* Set the compositing operator
@@ -369,6 +375,18 @@ public abstract class CairoGraphics2D extends Graphics2D
*/
private native void cairoRectangle(long pointer, double x, double y,
double width, double height);
+
+ /**
+ * Appends an arc to the current path
+ */
+ private native void cairoArc(long pointer, double x, double y,
+ double radius, double angle1, double angle2);
+
+ /**
+ * Save / restore a cairo path
+ */
+ private native void cairoSave(long pointer);
+ private native void cairoRestore(long pointer);
/**
* New current path
@@ -920,36 +938,71 @@ public abstract class CairoGraphics2D extends Graphics2D
return;
}
- cairoNewPath(nativePointer);
-
- if (s instanceof Rectangle2D)
- {
- Rectangle2D r = (Rectangle2D) s;
- cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls),
- shifted(r.getY(), shiftDrawCalls), r.getWidth(),
- r.getHeight());
- }
- else
- walkPath(s.getPathIterator(null), shiftDrawCalls);
+ createPath(s);
cairoStroke(nativePointer);
}
public void fill(Shape s)
{
+ createPath(s);
+
+ double alpha = 1.0;
+ if (comp instanceof AlphaComposite)
+ alpha = ((AlphaComposite) comp).getAlpha();
+ cairoFill(nativePointer, alpha);
+ }
+
+ private void createPath(Shape s)
+ {
cairoNewPath(nativePointer);
+
+ // Optimize rectangles, since there is a direct Cairo function
if (s instanceof Rectangle2D)
{
- Rectangle2D r = (Rectangle2D) s;
- cairoRectangle(nativePointer, r.getX(), r.getY(), r.getWidth(),
+ Rectangle2D r = (Rectangle2D) s;
+ cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls),
+ shifted(r.getY(), shiftDrawCalls), r.getWidth(),
r.getHeight());
}
- else
- walkPath(s.getPathIterator(null), false);
- double alpha = 1.0;
- if (comp instanceof AlphaComposite)
- alpha = ((AlphaComposite) comp).getAlpha();
- cairoFill(nativePointer, alpha);
+ // We can optimize ellipses too; however we don't bother optimizing arcs:
+ // the iterator is fast enough (an ellipse requires 5 steps using the
+ // iterator, while most arcs are only 2-3)
+ else if (s instanceof Ellipse2D)
+ {
+ Ellipse2D e = (Ellipse2D) s;
+
+ double radius = Math.min(e.getHeight(), e.getWidth()) / 2;
+
+ // Cairo only draws circular shapes, but we can use a stretch to make
+ // them into ellipses
+ double xscale = 1, yscale = 1;
+ if (e.getHeight() != e.getWidth())
+ {
+ cairoSave(nativePointer);
+
+ if (e.getHeight() < e.getWidth())
+ xscale = e.getWidth() / (radius * 2);
+ else
+ yscale = e.getHeight() / (radius * 2);
+
+ if (xscale != 1 || yscale != 1)
+ cairoScale(nativePointer, xscale, yscale);
+ }
+
+ cairoArc(nativePointer,
+ shifted(e.getCenterX() / xscale, shiftDrawCalls),
+ shifted(e.getCenterY() / yscale, shiftDrawCalls), radius, 0,
+ Math.PI * 2);
+
+ if (xscale != 1 || yscale != 1)
+ cairoRestore(nativePointer);
+ }
+
+ // All other shapes are broken down and drawn in steps using the
+ // PathIterator
+ else
+ walkPath(s.getPathIterator(null), shiftDrawCalls);
}
/**
diff --git a/gnu/java/awt/peer/gtk/CairoSurface.java b/gnu/java/awt/peer/gtk/CairoSurface.java
index b4d08c6ad..020d8eadd 100644
--- a/gnu/java/awt/peer/gtk/CairoSurface.java
+++ b/gnu/java/awt/peer/gtk/CairoSurface.java
@@ -80,10 +80,10 @@ public class CairoSurface extends DataBuffer
long bufferPointer;
- static ColorModel nativeModel = new DirectColorModel(32,
- 0x000000FF,
- 0x0000FF00,
+ static ColorModel nativeModel = new DirectColorModel(32,
0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
0xFF000000);
/**
diff --git a/gnu/java/awt/peer/gtk/ComponentGraphics.java b/gnu/java/awt/peer/gtk/ComponentGraphics.java
index cb8350265..193dec4c7 100644
--- a/gnu/java/awt/peer/gtk/ComponentGraphics.java
+++ b/gnu/java/awt/peer/gtk/ComponentGraphics.java
@@ -62,6 +62,8 @@ import java.awt.image.RenderedImage;
*/
public class ComponentGraphics extends CairoGraphics2D
{
+ private static final boolean hasXRenderExtension = hasXRender();
+
private GtkComponentPeer component;
protected long cairo_t;
@@ -175,7 +177,7 @@ public class ComponentGraphics extends CairoGraphics2D
*/
public static Graphics2D getComponentGraphics(GtkComponentPeer component)
{
- if( hasXRender() )
+ if( hasXRenderExtension )
return new ComponentGraphics(component);
Rectangle r = component.awtComponent.getBounds();
@@ -402,5 +404,18 @@ public class ComponentGraphics extends CairoGraphics2D
}
}
+ public void setClip(Shape s)
+ {
+ lock();
+ try
+ {
+ super.setClip(s);
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
}
diff --git a/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java b/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
index 035819d1c..e095c7dad 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
@@ -134,5 +134,9 @@ public class GdkGraphicsEnvironment extends GraphicsEnvironment
{
throw new java.lang.UnsupportedOperationException ();
}
-
+
+ /**
+ * Used by GtkMouseInfoPeer.
+ */
+ native int[] getMouseCoordinates();
}
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index 6ec0b7298..faac6d71d 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -218,11 +218,7 @@ public class GtkFramePeer extends GtkWindowPeer
// TODO Auto-generated method stub
}
- public void updateAlwaysOnTop()
- {
- // TODO Auto-generated method stub
-
- }
+
public boolean requestWindowFocus()
{
// TODO Auto-generated method stub
diff --git a/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
new file mode 100644
index 000000000..7f54da6d3
--- /dev/null
+++ b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
@@ -0,0 +1,77 @@
+/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.Point;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Window;
+import java.awt.peer.MouseInfoPeer;
+
+/**
+ * The MouseInfoPeer is so small, I'm including it here.
+ */
+public class GtkMouseInfoPeer implements MouseInfoPeer
+{
+ private static GdkGraphicsEnvironment gde = new GdkGraphicsEnvironment();
+
+ public int fillPointWithCoords(Point p)
+ {
+ int[] coords = gde.getMouseCoordinates();
+ p.x = coords[1];
+ p.y = coords[2];
+ return coords[0];
+ }
+
+ public boolean isWindowUnderMouse(Window w)
+ {
+ int[] coords = gde.getMouseCoordinates();
+ GraphicsDevice[] gds = gde.getScreenDevices();
+
+ // Check if the screen of the Window and the cursor match
+ if( gds[ coords[0] ] != w.getGraphicsConfiguration().getDevice() )
+ return false;
+
+ // Return the bounds-check.
+ Point p = w.getLocationOnScreen();
+ return (coords[1] >= p.x && coords[1] < p.x + w.getWidth() &&
+ coords[2] >= p.y && coords[2] < p.y + w.getHeight() );
+ }
+}
+
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index fdd7e09cb..62d497449 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -102,6 +102,7 @@ import java.awt.peer.LabelPeer;
import java.awt.peer.ListPeer;
import java.awt.peer.MenuBarPeer;
import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MouseInfoPeer;
import java.awt.peer.MenuPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.PopupMenuPeer;
@@ -653,4 +654,12 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
}
public static native void gtkMain();
+
+ protected MouseInfoPeer getMouseInfoPeer()
+ {
+ return new GtkMouseInfoPeer();
+ }
+
+ public native int getMouseNumberOfButtons();
+
} // class GtkToolkit
diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
index d15beacb4..ca79a6d21 100644
--- a/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
@@ -70,7 +70,7 @@ public class GtkWindowPeer extends GtkContainerPeer
native void gtkWindowSetTitle (String title);
native void gtkWindowSetResizable (boolean resizable);
native void gtkWindowSetModal (boolean modal);
-
+ native void gtkWindowSetAlwaysOnTop ( boolean alwaysOnTop );
native void realize ();
/** Returns the cached width of the AWT window component. */
@@ -275,10 +275,13 @@ public class GtkWindowPeer extends GtkContainerPeer
else
q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite));
}
+
+ /**
+ * Update the always-on-top status of the native window.
+ */
public void updateAlwaysOnTop()
{
- // TODO Auto-generated method stub
-
+ gtkWindowSetAlwaysOnTop( ((Window)awtComponent).isAlwaysOnTop() );
}
protected void postExposeEvent (int x, int y, int width, int height)
diff --git a/gnu/java/awt/peer/x/XToolkit.java b/gnu/java/awt/peer/x/XToolkit.java
index 05e8a5963..343a8f44f 100644
--- a/gnu/java/awt/peer/x/XToolkit.java
+++ b/gnu/java/awt/peer/x/XToolkit.java
@@ -71,7 +71,6 @@ import java.awt.Window;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.peer.DragSourceContextPeer;
-import java.awt.font.FontRenderContext;
import java.awt.im.InputMethodHighlight;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
@@ -101,12 +100,12 @@ import java.awt.peer.ScrollbarPeer;
import java.awt.peer.TextAreaPeer;
import java.awt.peer.TextFieldPeer;
import java.awt.peer.WindowPeer;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.text.AttributedString;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -114,6 +113,7 @@ import java.util.WeakHashMap;
import javax.imageio.ImageIO;
+import gnu.classpath.SystemProperties;
import gnu.java.awt.ClasspathToolkit;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.peer.ClasspathFontPeer;
@@ -155,7 +155,9 @@ public class XToolkit
public XToolkit()
{
- System.setProperty("gnu.javax.swing.noGraphics2D", "true");
+ SystemProperties.setProperty("gnu.javax.swing.noGraphics2D", "true");
+ SystemProperties.setProperty("java.awt.graphicsenv",
+ "gnu.java.awt.peer.x.XGraphicsEnvironment");
}
public GraphicsEnvironment getLocalGraphicsEnvironment()
@@ -176,15 +178,20 @@ public class XToolkit
public ClasspathFontPeer getClasspathFontPeer(String name, Map attrs)
{
String canonical = XFontPeer.encodeFont(name, attrs);
- XFontPeer font;
+ ClasspathFontPeer font;
if (!fontCache.containsKey(canonical))
{
- font = new XFontPeer(name, attrs);
+ String graphics2d =
+ SystemProperties.getProperty("gnu.xawt.graphics2d");
+ if (graphics2d != null && graphics2d.equals("gl"))
+ font = new XFontPeer2(name, attrs);
+ else
+ font = new XFontPeer(name, attrs);
fontCache.put(canonical, font);
}
else
{
- font = (XFontPeer) fontCache.get(canonical);
+ font = (ClasspathFontPeer) fontCache.get(canonical);
}
return font;
}
@@ -361,7 +368,7 @@ public class XToolkit
public FontMetrics getFontMetrics(Font name)
{
- XFontPeer peer = (XFontPeer) name.getPeer();
+ ClasspathFontPeer peer = (ClasspathFontPeer) name.getPeer();
return peer.getFontMetrics(name);
}
@@ -459,16 +466,7 @@ public class XToolkit
Image image;
try
{
- BufferedImage buffered = ImageIO.read(url);
- if (buffered != null)
- {
- ImageConverter conv = new ImageConverter();
- ImageProducer source = buffered.getSource();
- source.startProduction(conv);
- return conv.getXImage();
- }
- else return createErrorImage();
-
+ image = createImage(url.openStream());
}
catch (IOException ex)
{
@@ -510,8 +508,36 @@ public class XToolkit
public Image createImage(byte[] data, int offset, int len)
{
- // TODO: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
+ Image image;
+ try
+ {
+ ByteArrayInputStream i = new ByteArrayInputStream(data, offset, len);
+ image = createImage(i);
+ }
+ catch (IOException ex)
+ {
+ image = createErrorImage();
+ }
+ return image;
+ }
+
+ private Image createImage(InputStream i)
+ throws IOException
+ {
+ Image image;
+ BufferedImage buffered = ImageIO.read(i);
+ if (buffered != null)
+ {
+ ImageConverter conv = new ImageConverter();
+ ImageProducer source = buffered.getSource();
+ source.startProduction(conv);
+ image = conv.getXImage();
+ }
+ else
+ {
+ image = createErrorImage();
+ }
+ return image;
}
public PrintJob getPrintJob(Frame frame, String title, Properties props)
diff --git a/gnu/java/net/local/LocalSocketImpl.java b/gnu/java/net/local/LocalSocketImpl.java
index f907e5f46..f43305a80 100644
--- a/gnu/java/net/local/LocalSocketImpl.java
+++ b/gnu/java/net/local/LocalSocketImpl.java
@@ -57,7 +57,8 @@ final class LocalSocketImpl extends SocketImpl
private boolean created;
private InputStream in;
private OutputStream out;
- private int socket_fd;
+ // Package private to avoid synthetic accessor method.
+ int socket_fd;
private LocalSocketAddress local;
private LocalSocketAddress remote;
@@ -104,7 +105,7 @@ final class LocalSocketImpl extends SocketImpl
protected native void create (boolean stream) throws IOException;
protected native void listen (int timeout) throws IOException;
protected native void accept (LocalSocketImpl socket) throws IOException;
- protected native int available () throws IOException;
+ protected native int available (int fd) throws IOException;
protected native void close () throws IOException;
protected native void sendUrgentData (int data) throws IOException;
protected native void shutdownInput () throws IOException;
@@ -113,8 +114,14 @@ final class LocalSocketImpl extends SocketImpl
native void unlink () throws IOException;
native void localBind (LocalSocketAddress addr) throws IOException;
native void localConnect (LocalSocketAddress addr) throws IOException;
- native int read (byte[] buf, int off, int len) throws IOException;
- native void write (byte[] buf, int off, int len) throws IOException;
+ native int read (int fd, byte[] buf, int off, int len) throws IOException;
+ native void write (int fd, byte[] buf, int off, int len) throws IOException;
+
+ protected int available()
+ throws IOException
+ {
+ return available(socket_fd);
+ }
void doCreate () throws IOException
{
@@ -263,7 +270,7 @@ final class LocalSocketImpl extends SocketImpl
public int read (byte[] buf, int off, int len) throws IOException
{
- int ret = impl.read (buf, off, len);
+ int ret = impl.read (socket_fd, buf, off, len);
if (ret == 0)
{
@@ -316,7 +323,7 @@ final class LocalSocketImpl extends SocketImpl
public void write (byte[] buf, int off, int len) throws IOException
{
- impl.write (buf, off, len);
+ impl.write (socket_fd, buf, off, len);
}
}
}
diff --git a/gnu/java/security/OID.java b/gnu/java/security/OID.java
index 822ca3427..f61cf0fc3 100644
--- a/gnu/java/security/OID.java
+++ b/gnu/java/security/OID.java
@@ -71,6 +71,9 @@ public class OID implements Cloneable, Comparable, java.io.Serializable
// Fields.
// ------------------------------------------------------------------------
+ /* Serial version id for serialization. */
+ static final long serialVersionUID = 5722492029044597779L;
+
/**
* The numeric ID structure.
*/
@@ -229,13 +232,6 @@ public class OID implements Cloneable, Comparable, java.io.Serializable
}
}
- /**
- * Our private constructor.
- */
- private OID()
- {
- }
-
// Instance methods.
// ------------------------------------------------------------------------
@@ -325,10 +321,16 @@ public class OID implements Cloneable, Comparable, java.io.Serializable
*/
public Object clone()
{
- OID oid = new OID();
- oid.components = this.components;
- oid.strRep = this.strRep;
- return oid;
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(cnse);
+ throw ie;
+ }
}
/* Nice idea, but possibly too expensive for whatever benefit it
diff --git a/gnu/java/security/PolicyFile.java b/gnu/java/security/PolicyFile.java
index 8404eeb98..8da3a7d72 100644
--- a/gnu/java/security/PolicyFile.java
+++ b/gnu/java/security/PolicyFile.java
@@ -37,9 +37,9 @@ exception statement from your version. */
package gnu.java.security;
-import gnu.classpath.SystemProperties;
import gnu.classpath.debug.Component;
import gnu.classpath.debug.SystemLogger;
+import gnu.java.security.action.GetPropertyAction;
import java.io.File;
import java.io.IOException;
@@ -149,15 +149,16 @@ public final class PolicyFile extends Policy
// -------------------------------------------------------------------------
protected static final Logger logger = SystemLogger.SYSTEM;
-
+ // Added to cut redundant AccessController.doPrivileged calls
+ private static GetPropertyAction prop = new GetPropertyAction("file.seperator");
+ private static final String fs = (String) AccessController.doPrivileged(prop);
+
private static final String DEFAULT_POLICY =
- SystemProperties.getProperty("java.home")
- + SystemProperties.getProperty("file.separator") + "lib"
- + SystemProperties.getProperty("file.separator") + "security"
- + SystemProperties.getProperty("file.separator") + "java.policy";
+ (String) AccessController.doPrivileged(prop.setParameters("java.home"))
+ + fs + "lib" + fs + "security" + fs + "java.policy";
private static final String DEFAULT_USER_POLICY =
- SystemProperties.getProperty ("user.home") +
- SystemProperties.getProperty ("file.separator") + ".java.policy";
+ (String) AccessController.doPrivileged(prop.setParameters("user.home")) +
+ fs + ".java.policy";
private final Map cs2pc;
@@ -216,7 +217,7 @@ public final class PolicyFile extends Policy
String allow = Security.getProperty ("policy.allowSystemProperty");
if (allow == null || Boolean.getBoolean (allow))
{
- String s = SystemProperties.getProperty ("java.security.policy");
+ String s = System.getProperty ("java.security.policy");
logger.log (Component.POLICY, "java.security.policy={0}", s);
if (s != null)
{
diff --git a/gnu/java/security/Registry.java b/gnu/java/security/Registry.java
index b3df24c9e..053d71778 100644
--- a/gnu/java/security/Registry.java
+++ b/gnu/java/security/Registry.java
@@ -89,6 +89,18 @@ public interface Registry
String CAST_128_CIPHER = "cast-128";
+ // Key Wrapping Algorithm names and synonyms ...............................
+
+ String KWA_PREFIX = "kw-";
+ String AES_KWA = KWA_PREFIX + AES_CIPHER;
+ String AES128_KWA = AES_KWA + "128";
+ String AES192_KWA = AES_KWA + "192";
+ String AES256_KWA = AES_KWA + "256";
+ String RIJNDAEL_KWA = KWA_PREFIX + RIJNDAEL_CIPHER;
+
+ String TRIPLEDES_KWA = KWA_PREFIX + TRIPLEDES_CIPHER;
+ String DESEDE_KWA = KWA_PREFIX + DESEDE_CIPHER;
+
// Message digest algorithms and synonyms...................................
String WHIRLPOOL_HASH = "whirlpool";
diff --git a/gnu/java/security/key/dss/DSSKey.java b/gnu/java/security/key/dss/DSSKey.java
index 29205605b..c0cd10f30 100644
--- a/gnu/java/security/key/dss/DSSKey.java
+++ b/gnu/java/security/key/dss/DSSKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.java.security.key.dss;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import java.security.interfaces.DSAKey;
import java.security.interfaces.DSAParams;
@@ -167,7 +168,8 @@ public abstract class DSSKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("p=0x").append(p.toString(16)).append(",").append(ls)
diff --git a/gnu/java/security/key/dss/DSSPrivateKey.java b/gnu/java/security/key/dss/DSSPrivateKey.java
index 6c64987bc..6ed8de846 100644
--- a/gnu/java/security/key/dss/DSSPrivateKey.java
+++ b/gnu/java/security/key/dss/DSSPrivateKey.java
@@ -39,11 +39,12 @@ exception statement from your version. */
package gnu.java.security.key.dss;
import gnu.java.security.Configuration;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
@@ -188,7 +189,8 @@ public class DSSPrivateKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("x=0x").append(Configuration.DEBUG ? x.toString(16)
diff --git a/gnu/java/security/key/dss/DSSPublicKey.java b/gnu/java/security/key/dss/DSSPublicKey.java
index fa3ad04d0..9e1c4cf0a 100644
--- a/gnu/java/security/key/dss/DSSPublicKey.java
+++ b/gnu/java/security/key/dss/DSSPublicKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.java.security.key.dss;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PublicKey;
import java.security.interfaces.DSAPublicKey;
@@ -187,7 +188,8 @@ public class DSSPublicKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("y=0x").append(y.toString(16)).append(ls)
diff --git a/gnu/java/security/key/rsa/GnuRSAKey.java b/gnu/java/security/key/rsa/GnuRSAKey.java
index 6ff740184..4bdce4011 100644
--- a/gnu/java/security/key/rsa/GnuRSAKey.java
+++ b/gnu/java/security/key/rsa/GnuRSAKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import java.security.interfaces.RSAKey;
@@ -160,7 +161,8 @@ public abstract class GnuRSAKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("n=0x").append(n.toString(16)).append(",").append(ls)
diff --git a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
index ef466d020..00a1b822a 100644
--- a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
+++ b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
@@ -39,11 +39,12 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
import gnu.java.security.Configuration;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
@@ -286,7 +287,8 @@ public class GnuRSAPrivateKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("d=0x").append(Configuration.DEBUG ? d.toString(16)
diff --git a/gnu/java/security/key/rsa/GnuRSAPublicKey.java b/gnu/java/security/key/rsa/GnuRSAPublicKey.java
index 1bbca4fa2..fe28d0ba3 100644
--- a/gnu/java/security/key/rsa/GnuRSAPublicKey.java
+++ b/gnu/java/security/key/rsa/GnuRSAPublicKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
@@ -175,7 +176,8 @@ public class GnuRSAPublicKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append(")")
diff --git a/gnu/java/security/util/ByteArray.java b/gnu/java/security/util/ByteArray.java
new file mode 100644
index 000000000..0d04d9127
--- /dev/null
+++ b/gnu/java/security/util/ByteArray.java
@@ -0,0 +1,109 @@
+/* ByteArray.java -- wrapper around a byte array, with nice toString output.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.util;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public final class ByteArray
+{
+ private final byte[] value;
+
+ public ByteArray (final byte[] value)
+ {
+ this.value = value;
+ }
+
+ public byte[] getValue ()
+ {
+ return value;
+ }
+
+ public String toString ()
+ {
+ StringWriter str = new StringWriter ();
+ PrintWriter out = new PrintWriter (str);
+ int i = 0;
+ int len = value.length;
+ while (i < len)
+ {
+ out.print (formatInt (i, 16, 8));
+ out.print (" ");
+ int l = Math.min (16, len - i);
+ String s = toHexString (value, i, l, ' ');
+ out.print (s);
+ for (int j = 56 - (56 - s.length ()); j < 56; j++)
+ out.print (" ");
+ for (int j = 0; j < l; j++)
+ {
+ byte b = value[i+j];
+ if ((b & 0xFF) < 0x20 || (b & 0xFF) > 0x7E)
+ out.print (".");
+ else
+ out.print ((char) (b & 0xFF));
+ }
+ out.println ();
+ i += 16;
+ }
+ return str.toString ();
+ }
+
+ public static String toHexString (byte[] buf, int off, int len, char sep)
+ {
+ StringBuffer str = new StringBuffer();
+ for (int i = 0; i < len; i++)
+ {
+ str.append (Character.forDigit (buf[i+off] >>> 4 & 0x0F, 16));
+ str.append (Character.forDigit (buf[i+off] & 0x0F, 16));
+ if (i < len - 1)
+ str.append(sep);
+ }
+ return str.toString();
+ }
+
+ public static String formatInt (int value, int radix, int len)
+ {
+ String s = Integer.toString (value, radix);
+ StringBuffer buf = new StringBuffer ();
+ for (int j = 0; j < len - s.length(); j++)
+ buf.append ("0");
+ buf.append (s);
+ return buf.toString();
+ }
+}
diff --git a/gnu/javax/crypto/RSACipherImpl.java b/gnu/javax/crypto/RSACipherImpl.java
index 90fde9d7b..60504ecce 100644
--- a/gnu/javax/crypto/RSACipherImpl.java
+++ b/gnu/javax/crypto/RSACipherImpl.java
@@ -38,9 +38,9 @@ exception statement from your version. */
package gnu.javax.crypto;
-import gnu.classpath.ByteArray;
import gnu.classpath.debug.Component;
import gnu.classpath.debug.SystemLogger;
+import gnu.java.security.util.ByteArray;
import java.math.BigInteger;
import java.security.AlgorithmParameters;
diff --git a/gnu/javax/crypto/cipher/DES.java b/gnu/javax/crypto/cipher/DES.java
index 2bb897177..3ced62c3f 100644
--- a/gnu/javax/crypto/cipher/DES.java
+++ b/gnu/javax/crypto/cipher/DES.java
@@ -299,7 +299,7 @@ public class DES
*/
public static void adjustParity(byte[] kb, int offset)
{
- for (int i = offset; i < KEY_SIZE; i++)
+ for (int i = offset; i < offset + KEY_SIZE; i++)
kb[i] ^= (PARITY[kb[i] & 0xff] == 8) ? 1 : 0;
}
diff --git a/gnu/javax/crypto/jce/GnuCrypto.java b/gnu/javax/crypto/jce/GnuCrypto.java
index a65541ed1..8099fd13d 100644
--- a/gnu/javax/crypto/jce/GnuCrypto.java
+++ b/gnu/javax/crypto/jce/GnuCrypto.java
@@ -317,6 +317,16 @@ public final class GnuCrypto
put("Cipher.PBEWithHMacWhirlpoolAndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Twofish.class.getName());
+ // Key Wrapping Algorithm cipher
+ put("Cipher." + Registry.AES128_KWA,
+ gnu.javax.crypto.jce.cipher.AES128KeyWrapSpi.class.getName());
+ put("Cipher." + Registry.AES192_KWA,
+ gnu.javax.crypto.jce.cipher.AES192KeyWrapSpi.class.getName());
+ put("Cipher." + Registry.AES256_KWA,
+ gnu.javax.crypto.jce.cipher.AES256KeyWrapSpi.class.getName());
+ put("Cipher." + Registry.TRIPLEDES_KWA,
+ gnu.javax.crypto.jce.cipher.TripleDESKeyWrapSpi.class.getName());
+
// SecretKeyFactory interface to PBKDF2.
put("SecretKeyFactory.PBKDF2WithHMacHaval",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacHaval.class.getName());
diff --git a/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java b/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java
new file mode 100644
index 000000000..14ce480ae
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java
@@ -0,0 +1,54 @@
+/* AESKeyWrapSpi.java -- AES (128-bit key) Key Wrapping Algorithm JCE Adapter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+import gnu.java.security.Registry;
+
+/**
+ * The JCE Cipher Adapter implementation over the GNU AES Key Wrapping
+ * Algorithm with a 128-bit key-size.
+ */
+public final class AES128KeyWrapSpi
+ extends AESKeyWrapSpi
+{
+ public AES128KeyWrapSpi()
+ {
+ super(Registry.AES128_KWA, 128 / 8, Registry.ECB_MODE);
+ }
+}
diff --git a/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java b/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java
new file mode 100644
index 000000000..784fc5a15
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java
@@ -0,0 +1,54 @@
+/* AES192KeyWrapSpi.java -- AES (192-bit key) Key Wrapping Algorithm JCE Adapter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+import gnu.java.security.Registry;
+
+/**
+ * The JCE Cipher Adapter implementation over the GNU AES Key Wrapping
+ * Algorithm with a 192-bit key-size.
+ */
+public final class AES192KeyWrapSpi
+ extends AESKeyWrapSpi
+{
+ public AES192KeyWrapSpi()
+ {
+ super(Registry.AES192_KWA, 192 / 8, Registry.ECB_MODE);
+ }
+}
diff --git a/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java b/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java
new file mode 100644
index 000000000..dd7357b0e
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java
@@ -0,0 +1,54 @@
+/* AES256KeyWrapSpi.java -- AES (256-bit key) Key Wrapping Algorithm JCE Adapter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+import gnu.java.security.Registry;
+
+/**
+ * The JCE Cipher Adapter implementation over the GNU AES Key Wrapping
+ * Algorithm with a 256-bit key-size.
+ */
+public final class AES256KeyWrapSpi
+ extends AESKeyWrapSpi
+{
+ public AES256KeyWrapSpi()
+ {
+ super(Registry.AES256_KWA, 256 / 8, Registry.ECB_MODE);
+ }
+}
diff --git a/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java b/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java
new file mode 100644
index 000000000..973f5890b
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java
@@ -0,0 +1,88 @@
+/* AESKeyWrapSpi.java -- Common AES Key Wrapping Algorithm methods
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+/**
+ * Base abstract class to group common AES Key Wrapping Algorithm Adapter
+ * methods.
+ */
+abstract class AESKeyWrapSpi
+ extends KeyWrappingAlgorithmAdapter
+{
+ protected AESKeyWrapSpi(String name, int keySize, String supportedMode)
+ {
+ super(name, 16, keySize, supportedMode);
+ }
+
+ /**
+ * AES Key Wrapping algorithms operate on an 8-byte block; a block half the
+ * size of the AES block itself.
+ * <p>
+ * In wrapping, the number of 8-byte output blocks is ALWAYS one block longer
+ * than the input.
+ *
+ * @param inputLength the size of the plain text.
+ * @return the size in bytes of <code>n + 1</code> 8-byte blocks where
+ * <code>n</code> is the smallest number of 8-byte blocks that contain the
+ * designated number of input bytes.
+ */
+ protected int getOutputSizeForWrap(int inputLength)
+ {
+ int n = (inputLength + 7) / 8;
+ return 8 * (n + 1);
+ }
+
+ /**
+ * AES Key Wrapping algorithms operate on an 8-byte block; a block half the
+ * size of the AES block itself.
+ * <p>
+ * In unwrapping, the number of 8-byte output blocks is ALWAYS one block
+ * shorter than the input.
+ *
+ * @param inputLength the size of the cipher text.
+ * @return the size in bytes of <code>n - 1</code> 8-byte blocks where
+ * <code>n</code> is the smallest number of 8-byte blocks that contain the
+ * designated number of input bytes.
+ */
+ protected int getOutputSizeForUnwrap(int inputLength)
+ {
+ int n = (inputLength + 7) / 8;
+ return 8 * (n - 1);
+ }
+}
diff --git a/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
index 9dbc40df7..b7cd755f5 100644
--- a/gnu/javax/crypto/jce/cipher/CipherAdapter.java
+++ b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
@@ -343,6 +343,12 @@ class CipherAdapter
}
else if (params instanceof IvParameterSpec)
{
+ // The size of the IV must match the block size
+ if (((IvParameterSpec) params).getIV().length != cipher.defaultBlockSize())
+ {
+ throw new InvalidAlgorithmParameterException();
+ }
+
attributes.put(IMode.IV, ((IvParameterSpec) params).getIV());
blockLen = cipher.defaultBlockSize();
attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(blockLen));
diff --git a/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java b/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java
new file mode 100644
index 000000000..03356a236
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java
@@ -0,0 +1,423 @@
+/* KeyWrappingAlgorithmAdapter.java -- Base Adapter for Key Wrapping algorithms
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+import gnu.java.security.Configuration;
+import gnu.java.security.Registry;
+import gnu.javax.crypto.jce.spec.BlockCipherParameterSpec;
+import gnu.javax.crypto.kwa.IKeyWrappingAlgorithm;
+import gnu.javax.crypto.kwa.KeyUnwrappingException;
+import gnu.javax.crypto.kwa.KeyWrappingAlgorithmFactory;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherSpi;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * An abstract base class to facilitate implementations of JCE Adapters for
+ * symmetric key block ciphers capable of providing key-wrapping functionality.
+ */
+abstract class KeyWrappingAlgorithmAdapter
+ extends CipherSpi
+{
+ private static final Logger log = Logger.getLogger(KeyWrappingAlgorithmAdapter.class.getName());
+ /** JCE canonical name of a null-padder. */
+ private static final String NO_PADDING = "nopadding";
+ /** Concrete Key Wrapping Algorithm SPI. */
+ protected IKeyWrappingAlgorithm kwAlgorithm;
+ /** Size in bytes of the padding block to be provided by external padders. */
+ protected int kwaBlockSize;
+ /** KEK size in bytes. */
+ protected int kwaKeySize;
+ /** Name of the supported mode. */
+ protected String supportedMode;
+ /** Operational mode in which this instance was initialised. */
+ protected int opmode = -1;
+ /** Initialisation Vector if/when user wants to override default one. */
+ byte[] iv;
+
+ /**
+ * Creates a new JCE Adapter for the designated Key Wrapping Algorithm name.
+ *
+ * @param name the canonical name of the key-wrapping algorithm.
+ * @param blockSize the block size in bytes of the underlying symmetric-key
+ * block cipher algorithm.
+ * @param keySize the allowed size in bytes of the KEK bytes to initialise the
+ * underlying symmetric-key block cipher algorithm with.
+ * @param supportedMode canonical name of the block mode the underlying cipher
+ * is supporting.
+ */
+ protected KeyWrappingAlgorithmAdapter(String name, int blockSize, int keySize,
+ String supportedMode)
+ {
+ super();
+
+ this.kwAlgorithm = KeyWrappingAlgorithmFactory.getInstance(name);
+ this.kwaBlockSize = blockSize;
+ this.kwaKeySize = keySize;
+ this.supportedMode = supportedMode;
+ }
+
+ /**
+ * Wraps the encoded form of a designated {@link Key}.
+ *
+ * @param key the key-material to wrap.
+ * @return the wrapped key.
+ * @throws InvalidKeyException If the key cannot be wrapped.
+ */
+ protected byte[] engineWrap(Key key)
+ throws InvalidKeyException, IllegalBlockSizeException
+ {
+ byte[] keyMaterial = key.getEncoded();
+ byte[] result = kwAlgorithm.wrap(keyMaterial, 0, keyMaterial.length);
+ return result;
+ }
+
+ /**
+ * Unwraps a previously-wrapped key-material.
+ *
+ * @param wrappedKey the wrapped key-material to unwrap.
+ * @param wrappedKeyAlgorithm the canonical name of the algorithm, which the
+ * unwrapped key-material represents. This name is used to
+ * instantiate a concrete instance of a {@link Key} for that
+ * algorithm. For example, if the value of this parameter is
+ * <code>DSS</code> and the type (the next parameter) is
+ * {@link Cipher#PUBLIC_KEY} then an attempt to construct a concrete
+ * instance of a {@link java.security.interfaces.DSAPublicKey},
+ * using the unwrapped key material, shall be made.
+ * @param wrappedKeyType the type of wrapped key-material. MUST be one of
+ * {@link Cipher#PRIVATE_KEY}, {@link Cipher#PUBLIC_KEY}, or
+ * {@link Cipher#SECRET_KEY}.
+ * @return the unwrapped key-material as an instance of {@link Key} or one of
+ * its subclasses.
+ * @throws InvalidKeyException If the key cannot be unwrapped, or if
+ * <code>wrappedKeyType</code> is an inappropriate type for the
+ * unwrapped key.
+ * @throws NoSuchAlgorithmException If the <code>wrappedKeyAlgorithm</code>
+ * is unknown to every currently installed Security Provider.
+ */
+ protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
+ int wrappedKeyType)
+ throws InvalidKeyException, NoSuchAlgorithmException
+ {
+ byte[] keyBytes;
+ try
+ {
+ keyBytes = kwAlgorithm.unwrap(wrappedKey, 0, wrappedKey.length);
+ }
+ catch (KeyUnwrappingException x)
+ {
+ InvalidKeyException y = new InvalidKeyException("engineUnwrap()");
+ y.initCause(x);
+ throw y;
+ }
+ Key result;
+ switch (wrappedKeyType)
+ {
+ case Cipher.SECRET_KEY:
+ result = new SecretKeySpec(keyBytes, wrappedKeyAlgorithm);
+ break;
+ case Cipher.PRIVATE_KEY:
+ case Cipher.PUBLIC_KEY:
+ X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(wrappedKeyAlgorithm);
+ try
+ {
+ if (wrappedKeyType == Cipher.PRIVATE_KEY)
+ result = keyFactory.generatePrivate(keySpec);
+ else
+ result = keyFactory.generatePublic(keySpec);
+ }
+ catch (InvalidKeySpecException x)
+ {
+ InvalidKeyException y = new InvalidKeyException("engineUnwrap()");
+ y.initCause(x);
+ throw y;
+ }
+ break;
+ default:
+ IllegalArgumentException x = new IllegalArgumentException("Invalid 'wrappedKeyType': "
+ + wrappedKeyType);
+ InvalidKeyException y = new InvalidKeyException("engineUnwrap()");
+ y.initCause(x);
+ throw y;
+ }
+ return result;
+ }
+
+ protected int engineGetBlockSize()
+ {
+ return kwaBlockSize;
+ }
+
+ protected byte[] engineGetIV()
+ {
+ return iv == null ? null : (byte[]) iv.clone();
+ }
+
+ protected int engineGetOutputSize(int inputLength)
+ {
+ switch (opmode)
+ {
+ case Cipher.WRAP_MODE:
+ return getOutputSizeForWrap(inputLength);
+ case Cipher.UNWRAP_MODE:
+ return getOutputSizeForUnwrap(inputLength);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ protected AlgorithmParameters engineGetParameters()
+ {
+ BlockCipherParameterSpec spec = new BlockCipherParameterSpec(iv,
+ kwaBlockSize,
+ kwaKeySize);
+ AlgorithmParameters result = null;
+ try
+ {
+ result = AlgorithmParameters.getInstance("BlockCipherParameters");
+ result.init(spec);
+ }
+ catch (NoSuchAlgorithmException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Unable to find BlockCipherParameters. Return null");
+ }
+ catch (InvalidParameterSpecException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Unable to initialise BlockCipherParameters. Return null");
+ }
+ return result;
+ }
+
+ protected void engineInit(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException
+ {
+ checkOpMode(opmode);
+ byte[] kekBytes = checkAndGetKekBytes(key);
+ initAlgorithm(opmode, kekBytes, null, random);
+ }
+
+ protected void engineInit(int opmode, Key key, AlgorithmParameters params,
+ SecureRandom random)
+ throws InvalidAlgorithmParameterException, InvalidKeyException
+ {
+ AlgorithmParameterSpec spec = null;
+ try
+ {
+ if (params != null)
+ spec = params.getParameterSpec(BlockCipherParameterSpec.class);
+ }
+ catch (InvalidParameterSpecException x)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Unable to translate algorithm parameters into an instance "
+ + "of BlockCipherParameterSpec. Discard");
+ }
+ engineInit(opmode, key, spec, random);
+ }
+
+ protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params,
+ SecureRandom random)
+ throws InvalidAlgorithmParameterException, InvalidKeyException
+ {
+ checkOpMode(opmode);
+ byte[] kekBytes = checkAndGetKekBytes(key);
+ byte[] ivBytes = null;
+ if (params instanceof BlockCipherParameterSpec)
+ ivBytes = ((BlockCipherParameterSpec) params).getIV();
+ else if (params instanceof IvParameterSpec)
+ ivBytes = ((IvParameterSpec) params).getIV();
+
+ initAlgorithm(opmode, kekBytes, ivBytes, random);
+ }
+
+ protected void engineSetMode(String mode) throws NoSuchAlgorithmException
+ {
+ if (! supportedMode.equalsIgnoreCase(mode))
+ throw new UnsupportedOperationException("Only " + supportedMode
+ + " is supported");
+ }
+
+ /**
+ * NoPadding is the only padding algorithm supported by Key Wrapping Algorithm
+ * implementations in RI.
+ */
+ protected void engineSetPadding(String padding) throws NoSuchPaddingException
+ {
+ if (! NO_PADDING.equalsIgnoreCase(padding))
+ throw new UnsupportedOperationException("Only NoPadding is supported");
+ }
+
+ protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLength)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected int engineUpdate(byte[] input, int inputOffset, int inputLength,
+ byte[] output, int outputOffset)
+ throws ShortBufferException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLength)
+ throws IllegalBlockSizeException, BadPaddingException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected int engineDoFinal(byte[] input, int inputOffset, int inputLength,
+ byte[] output, int outputOffset)
+ throws IllegalBlockSizeException, BadPaddingException, ShortBufferException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Return the minimum size in bytes of a place holder large enough to receive
+ * the cipher text resulting from a wrap method with the designated size of
+ * the plain text.
+ * <p>
+ * This default implementation ALWAYS returns the smallest multiple of the
+ * <code>kwaBlockSize</code> --passed to this method through its
+ * constructor-- greater than or equal to the designated
+ * <code>inputLength</code>.
+ *
+ * @param inputLength the size of a plain text.
+ * @return an estimate of the size, in bytes, of the place holder to receive
+ * the resulting bytes of a wrap method.
+ */
+ protected int getOutputSizeForWrap(int inputLength)
+ {
+ return kwaBlockSize * (inputLength + kwaBlockSize - 1) / kwaBlockSize;
+ }
+
+ /**
+ * Return the minimum size in bytes of a place holder large enough to receive
+ * the plain text resulting from an unwrap method with the designated size of
+ * the cipher text.
+ * <p>
+ * This default implementation ALWAYS returns the smallest multiple of the
+ * <code>paddingBlockSize</code> --passed to this method through its
+ * constructor-- greater than or equal to the designated
+ * <code>inputLength</code>.
+ *
+ * @param inputLength the size of a cipher text.
+ * @return an estimate of the size, in bytes, of the place holder to receive
+ * the resulting bytes of an uwrap method.
+ */
+ protected int getOutputSizeForUnwrap(int inputLength)
+ {
+ return kwaBlockSize * (inputLength + kwaBlockSize - 1) / kwaBlockSize;
+ }
+
+ private void checkOpMode(int opmode)
+ {
+ switch (opmode)
+ {
+ case Cipher.WRAP_MODE:
+ case Cipher.UNWRAP_MODE:
+ return;
+ }
+ throw new IllegalArgumentException("Unsupported operational mode: " + opmode);
+ }
+
+ /**
+ * Returns the key bytes, iff it was in RAW format.
+ *
+ * @param key the opaque JCE secret key to use as the KEK.
+ * @return the bytes of the encoded form of the designated kek, iff it was in
+ * RAW format.
+ * @throws InvalidKeyException if the designated key is not in the RAW format.
+ */
+ private byte[] checkAndGetKekBytes(Key key) throws InvalidKeyException
+ {
+ if (! Registry.RAW_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
+ throw new InvalidKeyException("Only RAW key format is supported");
+ byte[] result = key.getEncoded();
+ int kekSize = result.length;
+ if (kekSize != kwaKeySize)
+ throw new InvalidKeyException("Invalid key material size. Expected "
+ + kwaKeySize + " but found " + kekSize);
+ return result;
+ }
+
+ private void initAlgorithm(int opmode, byte[] kek, byte[] ivBytes,
+ SecureRandom rnd)
+ throws InvalidKeyException
+ {
+ this.opmode = opmode;
+ Map attributes = new HashMap();
+ attributes.put(IKeyWrappingAlgorithm.KEY_ENCRYPTION_KEY_MATERIAL, kek);
+ if (ivBytes != null)
+ {
+ this.iv = (byte[]) ivBytes.clone();
+ attributes.put(IKeyWrappingAlgorithm.INITIAL_VALUE, this.iv);
+ }
+ else
+ this.iv = null;
+ if (rnd != null)
+ attributes.put(IKeyWrappingAlgorithm.SOURCE_OF_RANDOMNESS, rnd);
+
+ kwAlgorithm.init(attributes);
+ }
+}
diff --git a/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java b/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java
new file mode 100644
index 000000000..55087755e
--- /dev/null
+++ b/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java
@@ -0,0 +1,54 @@
+/* TripleDESKeyWrapSpi.java -- DES-EDE Key Wrapping Algorithm JCE Adapter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.jce.cipher;
+
+import gnu.java.security.Registry;
+
+/**
+ * The JCE Cipher Adapter implementation over the GNU TripleDES Key Wrapping
+ * Algorithm.
+ */
+public final class TripleDESKeyWrapSpi
+ extends KeyWrappingAlgorithmAdapter
+{
+ public TripleDESKeyWrapSpi()
+ {
+ super(Registry.TRIPLEDES_KWA, 8, 192 / 8, Registry.CBC_MODE);
+ }
+}
diff --git a/gnu/javax/crypto/jce/params/BlockCipherParameters.java b/gnu/javax/crypto/jce/params/BlockCipherParameters.java
index 4ed3015fd..a85c96223 100644
--- a/gnu/javax/crypto/jce/params/BlockCipherParameters.java
+++ b/gnu/javax/crypto/jce/params/BlockCipherParameters.java
@@ -49,6 +49,8 @@ import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.logging.Logger;
+import javax.crypto.spec.IvParameterSpec;
+
/**
* An implementation of algorithm parameters for the GNU block ciphers. This
* encompasses the cipher's block size, its key size, and an optional
@@ -132,6 +134,11 @@ public class BlockCipherParameters
{
if (c.isInstance(cipherSpec))
return cipherSpec;
+ if (IvParameterSpec.class.isAssignableFrom(c))
+ {
+ IvParameterSpec result = new IvParameterSpec(cipherSpec.getIV());
+ return result;
+ }
throw new InvalidParameterSpecException();
}
diff --git a/gnu/javax/crypto/key/dh/GnuDHKey.java b/gnu/javax/crypto/key/dh/GnuDHKey.java
index e37642f0a..1066830c3 100644
--- a/gnu/javax/crypto/key/dh/GnuDHKey.java
+++ b/gnu/javax/crypto/key/dh/GnuDHKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import javax.crypto.interfaces.DHKey;
@@ -154,7 +155,8 @@ public abstract class GnuDHKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
StringBuilder sb = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls);
if (q == null)
diff --git a/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java b/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
index 7321102de..d8150dcdf 100644
--- a/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
+++ b/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
@@ -38,12 +38,13 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Configuration;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import javax.crypto.interfaces.DHPrivateKey;
@@ -185,7 +186,8 @@ public class GnuDHPrivateKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("x=0x").append(Configuration.DEBUG ? x.toString(16)
diff --git a/gnu/javax/crypto/key/dh/GnuDHPublicKey.java b/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
index 5acc45299..5fb31f383 100644
--- a/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
+++ b/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import javax.crypto.interfaces.DHPublicKey;
@@ -182,7 +183,8 @@ public class GnuDHPublicKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("y=0x").append(y.toString(16)).append(ls)
diff --git a/gnu/javax/crypto/kwa/AESKeyWrap.java b/gnu/javax/crypto/kwa/AESKeyWrap.java
new file mode 100644
index 000000000..bb86c5477
--- /dev/null
+++ b/gnu/javax/crypto/kwa/AESKeyWrap.java
@@ -0,0 +1,168 @@
+/* AESWrap.java -- An implementation of RFC-3394 AES Key Wrap Algorithm
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.kwa;
+
+import gnu.java.security.Registry;
+import gnu.javax.crypto.cipher.IBlockCipher;
+import gnu.javax.crypto.cipher.Rijndael;
+
+import java.security.InvalidKeyException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The GNU implementation of the AES Key Wrap Algorithm as described in [1].
+ * <p>
+ * References:
+ * <ol>
+ * <li><a href="http://csrc.nist.gov/encryption/kms/key-wrap.pdf"></a>.</li>
+ * <li><a href="http://www.rfc-archive.org/getrfc.php?rfc=3394">Advanced
+ * Encryption Standard (AES) Key Wrap Algorithm</a>.</li>
+ * <li><a href="http://www.w3.org/TR/xmlenc-core/">XML Encryption Syntax and
+ * Processing</a>.</li>
+ * </ol>
+ */
+public class AESKeyWrap
+ extends BaseKeyWrappingAlgorithm
+{
+ private static final byte[] DEFAULT_IV = new byte[] {
+ (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6,
+ (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6 };
+
+ private Rijndael aes;
+ private byte[] iv;
+
+ public AESKeyWrap()
+ {
+ super(Registry.AES_KWA);
+
+ aes = new Rijndael();
+ }
+
+ protected void engineInit(Map attributes) throws InvalidKeyException
+ {
+ Map cipherAttributes = new HashMap();
+ cipherAttributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(16));
+ cipherAttributes.put(IBlockCipher.KEY_MATERIAL,
+ attributes.get(KEY_ENCRYPTION_KEY_MATERIAL));
+ aes.reset();
+ aes.init(cipherAttributes);
+ byte[] initialValue = (byte[]) attributes.get(INITIAL_VALUE);
+ iv = initialValue == null ? DEFAULT_IV : (byte[]) initialValue.clone();
+ }
+
+ protected byte[] engineWrap(byte[] in, int inOffset, int length)
+ {
+ // TODO: handle input length which is not a multiple of 8 as suggested by
+ // section 2.2.3.2 of RFC-3394
+ if (length % 8 != 0)
+ throw new IllegalArgumentException("Input length MUST be a multiple of 8");
+ int n = length / 8;
+ // output is always one block larger than input
+ byte[] result = new byte[length + 8];
+
+ // 1. init variables: we'll use out buffer for our work buffer;
+ // A will be the first block in out, while R will be the rest
+ System.arraycopy(iv, 0, result, 0, 8);
+ System.arraycopy(in, inOffset, result, 8, length);
+ byte[] B = new byte[2 * 8];
+ // 2. compute intermediate values
+ long t;
+ for (int j = 0; j < 6; j++)
+ for (int i = 1; i <= n; i++)
+ {
+ System.arraycopy(result, 0, B, 0, 8);
+ System.arraycopy(result, i * 8, B, 8, 8);
+ aes.encryptBlock(B, 0, B, 0);
+ t = (n * j) + i;
+ result[0] = (byte)(B[0] ^ (t >>> 56));
+ result[1] = (byte)(B[1] ^ (t >>> 48));
+ result[2] = (byte)(B[2] ^ (t >>> 40));
+ result[3] = (byte)(B[3] ^ (t >>> 32));
+ result[4] = (byte)(B[4] ^ (t >>> 24));
+ result[5] = (byte)(B[5] ^ (t >>> 16));
+ result[6] = (byte)(B[6] ^ (t >>> 8));
+ result[7] = (byte)(B[7] ^ t );
+ System.arraycopy(B, 8, result, i * 8, 8);
+ }
+ return result;
+ }
+
+ protected byte[] engineUnwrap(byte[] in, int inOffset, int length)
+ throws KeyUnwrappingException
+ {
+ // TODO: handle input length which is not a multiple of 8 as suggested by
+ // section 2.2.3.2 of RFC-3394
+ if (length % 8 != 0)
+ throw new IllegalArgumentException("Input length MUST be a multiple of 8");
+ // output is always one block shorter than input
+ byte[] result = new byte[length - 8];
+
+ // 1. init variables: we'll use out buffer for our R work buffer
+ byte[] A = new byte[8];
+ System.arraycopy(in, inOffset, A, 0, 8);
+ System.arraycopy(in, inOffset + 8, result, 0, result.length);
+ byte[] B = new byte[2 * 8];
+ // 2. compute intermediate values
+ int n = length / 8 - 1;
+ long t;
+ for (int j = 5; j >= 0; j--)
+ for (int i = n; i >= 1; i--)
+ {
+ t = (n * j) + i;
+ B[0] = (byte)(A[0] ^ (t >>> 56));
+ B[1] = (byte)(A[1] ^ (t >>> 48));
+ B[2] = (byte)(A[2] ^ (t >>> 40));
+ B[3] = (byte)(A[3] ^ (t >>> 32));
+ B[4] = (byte)(A[4] ^ (t >>> 24));
+ B[5] = (byte)(A[5] ^ (t >>> 16));
+ B[6] = (byte)(A[6] ^ (t >>> 8));
+ B[7] = (byte)(A[7] ^ t );
+ System.arraycopy(result, (i - 1) * 8, B, 8, 8);
+ aes.decryptBlock(B, 0, B, 0);
+ System.arraycopy(B, 0, A, 0, 8);
+ System.arraycopy(B, 8, result, (i - 1) * 8, 8);
+ }
+ if (! Arrays.equals(A, iv))
+ throw new KeyUnwrappingException();
+
+ return result;
+ }
+}
diff --git a/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java b/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java
new file mode 100644
index 000000000..206e01d13
--- /dev/null
+++ b/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java
@@ -0,0 +1,145 @@
+/* BaseKeyWrappingAlgorithm.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.javax.crypto.kwa;
+
+import gnu.java.security.util.PRNG;
+
+import java.security.InvalidKeyException;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.crypto.ShortBufferException;
+
+/**
+ * A base class to facilitate implementation of concrete Key Wrapping
+ * Algorithms.
+ */
+public abstract class BaseKeyWrappingAlgorithm
+ implements IKeyWrappingAlgorithm
+{
+ /** The canonical name of the key wrapping algorithm. */
+ protected String name;
+ /** A source of randomness if/when needed by concrete implementations. */
+ private PRNG prng;
+
+ /**
+ * Protected constructor.
+ *
+ * @param name the key wrapping algorithm canonical name.
+ */
+ protected BaseKeyWrappingAlgorithm(String name)
+ {
+ super();
+ }
+
+ public String name()
+ {
+ return this.name;
+ }
+
+ public void init(Map attributes) throws InvalidKeyException
+ {
+ if (attributes == null)
+ attributes = Collections.EMPTY_MAP;
+
+ engineInit(attributes);
+ }
+
+ public int wrap(byte[] in, int inOffset, int length, byte[] out, int outOffset)
+ throws ShortBufferException
+ {
+ if (outOffset < 0)
+ throw new IllegalArgumentException("Output offset MUST NOT be negative");
+ byte[] result = wrap(in, inOffset, length);
+ if (outOffset + result.length > out.length)
+ throw new ShortBufferException();
+ System.arraycopy(result, 0, out, outOffset, result.length);
+ return result.length;
+ }
+
+ public byte[] wrap(byte[] in, int inOffset, int length)
+ {
+ if (inOffset < 0)
+ throw new IllegalArgumentException("Input offset MUST NOT be negative");
+ if (length < 0)
+ throw new IllegalArgumentException("Input length MUST NOT be negative");
+
+ return engineWrap(in, inOffset, length);
+ }
+
+ public int unwrap(byte[] in, int inOffset, int length,
+ byte[] out, int outOffset)
+ throws ShortBufferException, KeyUnwrappingException
+ {
+ if (outOffset < 0)
+ throw new IllegalArgumentException("Output offset MUST NOT be negative");
+ byte[] result = engineUnwrap(in, inOffset, length);
+ if (outOffset + result.length > out.length)
+ throw new ShortBufferException();
+ System.arraycopy(result, 0, out, outOffset, result.length);
+ return result.length;
+ }
+
+ public byte[] unwrap(byte[] in, int inOffset, int length)
+ throws KeyUnwrappingException
+ {
+ if (inOffset < 0)
+ throw new IllegalArgumentException("Input offset MUST NOT be negative");
+ if (length < 0)
+ throw new IllegalArgumentException("Input length MUST NOT be negative");
+
+ return engineUnwrap(in, inOffset, length);
+ }
+
+ protected abstract void engineInit(Map attributes) throws InvalidKeyException;
+
+ protected abstract byte[] engineWrap(byte[] in, int inOffset, int length);
+
+ protected abstract byte[] engineUnwrap(byte[] in, int inOffset, int length)
+ throws KeyUnwrappingException;
+
+ /** @return a strong pseudo-random number generator if/when needed. */
+ protected PRNG getDefaultPRNG()
+ {
+ if (prng == null)
+ prng = PRNG.getInstance();
+
+ return prng;
+ }
+}
diff --git a/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java b/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java
new file mode 100644
index 000000000..d9c2bed14
--- /dev/null
+++ b/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java
@@ -0,0 +1,160 @@
+/* IKeyWrappingAlgorithm.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.javax.crypto.kwa;
+
+import java.security.InvalidKeyException;
+import java.security.SecureRandom;
+import java.util.Map;
+
+import javax.crypto.ShortBufferException;
+
+/**
+ * Constants and visible methods available to all GNU Key Wrapping Algorithm
+ * implementations.
+ */
+public interface IKeyWrappingAlgorithm
+{
+ /**
+ * Name of the property, in the attributes map, that references the Key
+ * Wrapping Algorithm KEK (Key Encryption Key) material. The object referenced
+ * by this property is a byte array containing the keying material for the
+ * underlying block cipher.
+ */
+ String KEY_ENCRYPTION_KEY_MATERIAL = "gnu.crypto.kwa.kek";
+ /**
+ * Name of the property, in the attributes map, that references the Initial
+ * Value (IV) material. The object referenced by this property is a byte array
+ * containing the initial integrity check register value.
+ */
+ String INITIAL_VALUE = "gnu.crypto.kwa.iv";
+ /**
+ * Property name of an optional {@link SecureRandom} instance to use. The
+ * default is to use a {@link gnu.java.security.util.PRNG} instance.
+ */
+ String SOURCE_OF_RANDOMNESS = "gnu.crypto.kwa.prng";
+
+ /**
+ * Returns the canonical name of this Key Wrapping Algorithm.
+ *
+ * @return the canonical name of this Key Wrapping Algorithm.
+ */
+ String name();
+
+ /**
+ * Initializes this instance with the designated algorithm specific
+ * attributes.
+ *
+ * @param attributes a map of name-to-value pairs the Key Wrapping Algorithm
+ * must use for its setup.
+ * @throws InvalidKeyException if an exception is encountered while seting up
+ * the Key Wrapping Algorithm keying material (KEK).
+ */
+ void init(Map attributes) throws InvalidKeyException;
+
+ /**
+ * Wraps the designated plain text bytes.
+ *
+ * @param in the input byte array containing the plain text.
+ * @param inOffset the offset into <code>in</code> where the first byte of
+ * the plain text (key material) to wrap is located.
+ * @param length the number of bytes to wrap.
+ * @param out the output byte array where the wrapped key material will be
+ * stored.
+ * @param outOffset the offset into <code>out</code> of the first wrapped
+ * byte.
+ * @return the number of bytes of the wrapped key material; i.e. the length,
+ * in <code>out</code>, starting from <code>outOffset</code>
+ * where the cipher text (wrapped key material) are stored.
+ * @throws ShortBufferException if the output buffer is not long enough to
+ * accomodate the number of bytes resulting from wrapping the plain
+ * text.
+ */
+ int wrap(byte[] in, int inOffset, int length, byte[] out, int outOffset)
+ throws ShortBufferException;
+
+ /**
+ * Wraps the designated plain text bytes.
+ *
+ * @param in the input byte array containing the plain text.
+ * @param inOffset the offset into <code>in</code> where the first byte of
+ * the plain text (key material) to wrap is located.
+ * @param length the number of bytes to wrap.
+ * @return a newly allocated byte array containing the cipher text.
+ */
+ byte[] wrap(byte[] in, int inOffset, int length);
+
+ /**
+ * Unwraps the designated cipher text bytes.
+ *
+ * @param in the input byte array containing the cipher text.
+ * @param inOffset the offset into <code>in</code> where the first byte of
+ * the cipher text (already wrapped key material) to unwrap is
+ * located.
+ * @param length the number of bytes to unwrap.
+ * @param out the output byte array where the unwrapped key material will be
+ * stored.
+ * @param outOffset the offset into <code>out</code> of the first unwrapped
+ * byte.
+ * @return the number of bytes of the unwrapped key material; i.e. the length,
+ * in <code>out</code>, starting from <code>outOffset</code>
+ * where the plain text (unwrapped key material) are stored.
+ * @throws ShortBufferException if the output buffer is not long enough to
+ * accomodate the number of bytes resulting from unwrapping the
+ * cipher text.
+ * @throws KeyUnwrappingException if after unwrapping the cipher text, the
+ * bytes at the begining did not match the initial value.
+ */
+ int unwrap(byte[] in, int inOffset, int length, byte[] out, int outOffset)
+ throws ShortBufferException, KeyUnwrappingException;
+
+ /**
+ * Unwraps the designated cipher text bytes.
+ *
+ * @param in the input byte array containing the cipher text.
+ * @param inOffset the offset into <code>in</code> where the first byte of
+ * the cipher text (already wrapped key material) to unwrap is
+ * located.
+ * @param length the number of bytes to unwrap.
+ * @return a newly allocated byte array containing the plain text.
+ * @throws KeyUnwrappingException if after unwrapping the cipher text, the
+ * bytes at the begining did not match the initial value.
+ */
+ byte[] unwrap(byte[] in, int inOffset, int length)
+ throws KeyUnwrappingException;
+}
diff --git a/gnu/javax/crypto/kwa/KeyUnwrappingException.java b/gnu/javax/crypto/kwa/KeyUnwrappingException.java
new file mode 100644
index 000000000..54b4aff0a
--- /dev/null
+++ b/gnu/javax/crypto/kwa/KeyUnwrappingException.java
@@ -0,0 +1,67 @@
+/* KeyUnwrappingException.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.javax.crypto.kwa;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * A checked security exception to denote an unexpected problem while unwrapping
+ * key material with a Key Wrapping Algorithm.
+ */
+public class KeyUnwrappingException
+ extends GeneralSecurityException
+{
+ /**
+ * Create a new instance with no descriptive error message.
+ */
+ public KeyUnwrappingException()
+ {
+ super();
+ }
+
+ /**
+ * Create a new instance with a descriptive error message.
+ *
+ * @param msg the descriptive error message
+ */
+ public KeyUnwrappingException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java b/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java
new file mode 100644
index 000000000..6f6cd1219
--- /dev/null
+++ b/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java
@@ -0,0 +1,110 @@
+/* KeyWrappingAlgorithmFactory.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.javax.crypto.kwa;
+
+import gnu.java.security.Registry;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A Factory class for the Key Wrapping Algorithm implementations.
+ */
+public class KeyWrappingAlgorithmFactory
+{
+ /** Names of Key Wrapping Algorihms cached for speed. */
+ private static Set names;
+
+ /** Trivial constructor to enforce Singleton pattern. */
+ private KeyWrappingAlgorithmFactory()
+ {
+ super();
+ }
+
+ /**
+ * Returns an instance of a key-wrapping algorithm given its name.
+ *
+ * @param name the case-insensitive name of the key-wrapping algorithm.
+ * @return an instance of the designated key-wrapping algorithm, or
+ * <code>null</code> if none was found.
+ * @exception InternalError if the implementation does not pass its self-test.
+ */
+ public static final IKeyWrappingAlgorithm getInstance(String name)
+ {
+ if (name == null)
+ return null;
+ name = name.trim();
+ IKeyWrappingAlgorithm result = null;
+ if (name.equalsIgnoreCase(Registry.AES_KWA)
+ || name.equalsIgnoreCase(Registry.AES128_KWA)
+ || name.equalsIgnoreCase(Registry.AES192_KWA)
+ || name.equalsIgnoreCase(Registry.AES256_KWA)
+ || name.equalsIgnoreCase(Registry.RIJNDAEL_KWA))
+ result = new AESKeyWrap();
+ else if (name.equalsIgnoreCase(Registry.TRIPLEDES_KWA)
+ || name.equalsIgnoreCase(Registry.DESEDE_KWA))
+ result = new TripleDESKeyWrap();
+
+ return result;
+ }
+
+ /**
+ * Returns a {@link Set} of key wrapping algorithm names supported by this
+ * <i>Factory</i>.
+ *
+ * @return a {@link Set} of key wrapping algorithm names (Strings).
+ */
+ public static synchronized final Set getNames()
+ {
+ if (names == null)
+ {
+ HashSet hs = new HashSet();
+ hs.add(Registry.AES_KWA);
+ hs.add(Registry.AES128_KWA);
+ hs.add(Registry.AES192_KWA);
+ hs.add(Registry.AES256_KWA);
+ hs.add(Registry.RIJNDAEL_KWA);
+ hs.add(Registry.TRIPLEDES_KWA);
+ hs.add(Registry.DESEDE_KWA);
+ names = Collections.unmodifiableSet(hs);
+ }
+ return names;
+ }
+}
diff --git a/gnu/javax/crypto/kwa/TripleDESKeyWrap.java b/gnu/javax/crypto/kwa/TripleDESKeyWrap.java
new file mode 100644
index 000000000..71562bd75
--- /dev/null
+++ b/gnu/javax/crypto/kwa/TripleDESKeyWrap.java
@@ -0,0 +1,292 @@
+/* TripleDESKeyWrap.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.javax.crypto.kwa;
+
+import gnu.java.security.Registry;
+import gnu.java.security.hash.Sha160;
+import gnu.javax.crypto.assembly.Assembly;
+import gnu.javax.crypto.assembly.Cascade;
+import gnu.javax.crypto.assembly.Direction;
+import gnu.javax.crypto.assembly.Stage;
+import gnu.javax.crypto.assembly.Transformer;
+import gnu.javax.crypto.assembly.TransformerException;
+import gnu.javax.crypto.cipher.IBlockCipher;
+import gnu.javax.crypto.cipher.TripleDES;
+import gnu.javax.crypto.mode.IMode;
+import gnu.javax.crypto.mode.ModeFactory;
+
+import java.security.InvalidKeyException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The GNU implementation of the Triple DES Key Wrap Algorithm as described in
+ * [1].
+ * <p>
+ * <b>IMPORTANT</b>: This class is NOT thread safe.
+ * <p>
+ * References:
+ * <ol>
+ * <li><a href="http://www.rfc-archive.org/getrfc.php?rfc=3217">Triple-DES and
+ * RC2 Key Wrapping</a>.</li>
+ * <li><a href="http://www.w3.org/TR/xmlenc-core/">XML Encryption Syntax and
+ * Processing</a>.</li>
+ * </ol>
+ */
+public class TripleDESKeyWrap
+ extends BaseKeyWrappingAlgorithm
+{
+ private static final byte[] DEFAULT_IV = new byte[] {
+ (byte) 0x4A, (byte) 0xDD, (byte) 0xA2, (byte) 0x2C,
+ (byte) 0x79, (byte) 0xE8, (byte) 0x21, (byte) 0x05 };
+
+ private Assembly asm;
+ private HashMap asmAttributes = new HashMap();
+ private HashMap modeAttributes = new HashMap();
+ private Sha160 sha = new Sha160();
+ private SecureRandom rnd;
+
+ public TripleDESKeyWrap()
+ {
+ super(Registry.TRIPLEDES_KWA);
+ }
+
+ protected void engineInit(Map attributes) throws InvalidKeyException
+ {
+ rnd = (SecureRandom) attributes.get(IKeyWrappingAlgorithm.SOURCE_OF_RANDOMNESS);
+ IMode des3CBC = ModeFactory.getInstance(Registry.CBC_MODE, new TripleDES(), 8);
+ Stage des3CBCStage = Stage.getInstance(des3CBC, Direction.FORWARD);
+ Cascade cascade = new Cascade();
+ Object modeNdx = cascade.append(des3CBCStage);
+
+ asmAttributes.put(modeNdx, modeAttributes);
+
+ asm = new Assembly();
+ asm.addPreTransformer(Transformer.getCascadeTransformer(cascade));
+
+ modeAttributes.put(IBlockCipher.KEY_MATERIAL,
+ attributes.get(KEY_ENCRYPTION_KEY_MATERIAL));
+ asmAttributes.put(Assembly.DIRECTION, Direction.FORWARD);
+ }
+
+ protected byte[] engineWrap(byte[] in, int inOffset, int length)
+ {
+ // The same key wrap algorithm is used for both Two-key Triple-DES and
+ // Three-key Triple-DES keys. When a Two-key Triple-DES key is to be
+ // wrapped, a third DES key with the same value as the first DES key is
+ // created. Thus, all wrapped Triple-DES keys include three DES keys.
+ if (length != 16 && length != 24)
+ throw new IllegalArgumentException("Only 2- and 3-key Triple DES keys are alowed");
+
+ byte[] CEK = new byte[24];
+ if (length == 16)
+ {
+ System.arraycopy(in, inOffset, CEK, 0, 16);
+ System.arraycopy(in, inOffset, CEK, 16, 8);
+ }
+ else
+ System.arraycopy(in, inOffset, CEK, 0, 24);
+
+ // TODO: check for the following:
+ // However, a Two-key Triple-DES key MUST NOT be used to wrap a Three-
+ // key Triple-DES key that is comprised of three unique DES keys.
+
+ // 1. Set odd parity for each of the DES key octets comprising the
+ // Three-Key Triple-DES key that is to be wrapped, call the result
+ // CEK.
+ TripleDES.adjustParity(CEK, 0);
+
+ // 2. Compute an 8 octet key checksum value on CEK as described above in
+ // Section 2, call the result ICV.
+ sha.update(CEK);
+ byte[] hash = sha.digest();
+ byte[] ICV = new byte[8];
+ System.arraycopy(hash, 0, ICV, 0, 8);
+
+ // 3. Let CEKICV = CEK || ICV.
+ byte[] CEKICV = new byte[CEK.length + ICV.length];
+ System.arraycopy(CEK, 0, CEKICV, 0, CEK.length);
+ System.arraycopy(ICV, 0, CEKICV, CEK.length, ICV.length);
+
+ // 4. Generate 8 octets at random, call the result IV.
+ byte[] IV = new byte[8];
+ nextRandomBytes(IV);
+
+ // 5. Encrypt CEKICV in CBC mode using the key-encryption key. Use the
+ // random value generated in the previous step as the initialization
+ // vector (IV). Call the ciphertext TEMP1.
+ modeAttributes.put(IMode.IV, IV);
+ asmAttributes.put(Assembly.DIRECTION, Direction.FORWARD);
+ byte[] TEMP1;
+ try
+ {
+ asm.init(asmAttributes);
+ TEMP1 = asm.lastUpdate(CEKICV);
+ }
+ catch (TransformerException x)
+ {
+ throw new RuntimeException(x);
+ }
+
+ // 6. Let TEMP2 = IV || TEMP1.
+ byte[] TEMP2 = new byte[IV.length + TEMP1.length];
+ System.arraycopy(IV, 0, TEMP2, 0, IV.length);
+ System.arraycopy(TEMP1, 0, TEMP2, IV.length, TEMP1.length);
+
+ // 7. Reverse the order of the octets in TEMP2. That is, the most
+ // significant (first) octet is swapped with the least significant
+ // (last) octet, and so on. Call the result TEMP3.
+ byte[] TEMP3 = new byte[TEMP2.length];
+ for (int i = 0, j = TEMP2.length - 1; i < TEMP2.length; i++, j--)
+ TEMP3[j] = TEMP2[i];
+
+ // 8. Encrypt TEMP3 in CBC mode using the key-encryption key. Use an
+ // initialization vector (IV) of 0x4adda22c79e82105. The ciphertext
+ // is 40 octets long.
+ modeAttributes.put(IMode.IV, DEFAULT_IV);
+ asmAttributes.put(Assembly.DIRECTION, Direction.FORWARD);
+ byte[] result;
+ try
+ {
+ asm.init(asmAttributes);
+ result = asm.lastUpdate(TEMP3);
+ }
+ catch (TransformerException x)
+ {
+ throw new RuntimeException(x);
+ }
+ return result;
+ }
+
+ protected byte[] engineUnwrap(byte[] in, int inOffset, int length)
+ throws KeyUnwrappingException
+ {
+ // 1. If the wrapped key is not 40 octets, then error.
+ if (length != 40)
+ throw new IllegalArgumentException("length MUST be 40");
+
+ // 2. Decrypt the wrapped key in CBC mode using the key-encryption key.
+ // Use an initialization vector (IV) of 0x4adda22c79e82105. Call the
+ // output TEMP3.
+ modeAttributes.put(IMode.IV, DEFAULT_IV);
+ asmAttributes.put(Assembly.DIRECTION, Direction.REVERSED);
+ byte[] TEMP3;
+ try
+ {
+ asm.init(asmAttributes);
+ TEMP3 = asm.lastUpdate(in, inOffset, 40);
+ }
+ catch (TransformerException x)
+ {
+ throw new RuntimeException(x);
+ }
+
+ // 3. Reverse the order of the octets in TEMP3. That is, the most
+ // significant (first) octet is swapped with the least significant
+ // (last) octet, and so on. Call the result TEMP2.
+ byte[] TEMP2 = new byte[40];
+ for (int i = 0, j = 40 - 1; i < 40; i++, j--)
+ TEMP2[j] = TEMP3[i];
+
+ // 4. Decompose TEMP2 into IV and TEMP1. IV is the most significant
+ // (first) 8 octets, and TEMP1 is the least significant (last) 32
+ // octets.
+ byte[] IV = new byte[8];
+ byte[] TEMP1 = new byte[32];
+ System.arraycopy(TEMP2, 0, IV, 0, 8);
+ System.arraycopy(TEMP2, 8, TEMP1, 0, 32);
+
+ // 5. Decrypt TEMP1 in CBC mode using the key-encryption key. Use the
+ // IV value from the previous step as the initialization vector.
+ // Call the ciphertext CEKICV.
+ modeAttributes.put(IMode.IV, IV);
+ asmAttributes.put(Assembly.DIRECTION, Direction.REVERSED);
+ byte[] CEKICV;
+ try
+ {
+ asm.init(asmAttributes);
+ CEKICV = asm.lastUpdate(TEMP1, 0, 32);
+ }
+ catch (TransformerException x)
+ {
+ throw new RuntimeException(x);
+ }
+
+ // 6. Decompose CEKICV into CEK and ICV. CEK is the most significant
+ // (first) 24 octets, and ICV is the least significant (last) 8
+ // octets.
+ byte[] CEK = new byte[24];
+ byte[] ICV = new byte[8];
+ System.arraycopy(CEKICV, 0, CEK, 0, 24);
+ System.arraycopy(CEKICV, 24, ICV, 0, 8);
+
+ // 7. Compute an 8 octet key checksum value on CEK as described above in
+ // Section 2. If the computed key checksum value does not match the
+ // decrypted key checksum value, ICV, then error.
+ sha.update(CEK);
+ byte[] hash = sha.digest();
+ byte[] computedICV = new byte[8];
+ System.arraycopy(hash, 0, computedICV, 0, 8);
+ if (! Arrays.equals(ICV, computedICV))
+ throw new KeyUnwrappingException("ICV and computed ICV MUST match");
+
+ // 8. Check for odd parity each of the DES key octets comprising CEK.
+ // If parity is incorrect, then error.
+ if (! TripleDES.isParityAdjusted(CEK, 0))
+ throw new KeyUnwrappingException("Triple-DES key parity MUST be adjusted");
+
+ // 9. Use CEK as a Triple-DES key.
+ return CEK;
+ }
+
+ /**
+ * Fills the designated byte array with random data.
+ *
+ * @param buffer the byte array to fill with random data.
+ */
+ private void nextRandomBytes(byte[] buffer)
+ {
+ if (rnd != null)
+ rnd.nextBytes(buffer);
+ else
+ getDefaultPRNG().nextBytes(buffer);
+ }
+}
diff --git a/gnu/javax/crypto/pad/BasePad.java b/gnu/javax/crypto/pad/BasePad.java
index 29ba159c6..8b475d2d8 100644
--- a/gnu/javax/crypto/pad/BasePad.java
+++ b/gnu/javax/crypto/pad/BasePad.java
@@ -40,6 +40,7 @@ package gnu.javax.crypto.pad;
import gnu.java.security.Configuration;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -80,6 +81,28 @@ public abstract class BasePad
setup();
}
+ /**
+ * Initialises the algorithm with designated attributes. Names, valid and/or
+ * recognisable by all concrete implementations are described in {@link IPad}
+ * class documentation. Other algorithm-specific attributes MUST be documented
+ * in the implementation class of that padding algorithm.
+ * <p>
+ * For compatibility reasons, this method is not declared <i>abstract</i>.
+ * Furthermore, and unless overridden, the default implementation will throw
+ * an {@link UnsupportedOperationException}. Concrete padding algorithms MUST
+ * override this method if they wish to offer an initialisation method that
+ * allows for other than the padding block size parameter to be specified.
+ *
+ * @param attributes a set of name-value pairs that describes the desired
+ * future behaviour of this instance.
+ * @exception IllegalStateException if the instance is already initialised.
+ * @exception IllegalArgumentException if the block size value is invalid.
+ */
+ public void init(Map attributes) throws IllegalStateException
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void reset()
{
blockSize = -1;
diff --git a/gnu/javax/crypto/pad/IPad.java b/gnu/javax/crypto/pad/IPad.java
index 4171220fa..0e3db7db1 100644
--- a/gnu/javax/crypto/pad/IPad.java
+++ b/gnu/javax/crypto/pad/IPad.java
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
+import java.util.Map;
+
/**
- * The basic visible methods of any padding algorithm.
+ * The basic visible methods, and attribute names, of every padding algorithm.
* <p>
* Padding algorithms serve to <i>pad</i> and <i>unpad</i> byte arrays usually
* as the last step in an <i>encryption</i> or respectively a <i>decryption</i>
@@ -49,6 +51,13 @@ package gnu.javax.crypto.pad;
*/
public interface IPad
{
+ /**
+ * Property name of the block size in which to operate the padding algorithm.
+ * The value associated with this property name is taken to be a positive
+ * {@link Integer} greater than zero.
+ */
+ String PADDING_BLOCK_SIZE = "gnu.crypto.pad.block.size";
+
/** @return the canonical name of this instance. */
String name();
@@ -62,6 +71,19 @@ public interface IPad
void init(int bs) throws IllegalStateException;
/**
+ * Initialises the algorithm with designated attributes. Names, valid and/or
+ * recognisable by all concrete implementations are described in the class
+ * documentation above. Other algorithm-specific attributes MUST be documented
+ * in the implementation class of that padding algorithm.
+ *
+ * @param attributes a set of name-value pairs that describes the desired
+ * future behaviour of this instance.
+ * @exception IllegalStateException if the instance is already initialised.
+ * @exception IllegalArgumentException if the block size value is invalid.
+ */
+ void init(Map attributes) throws IllegalStateException;
+
+ /**
* Returns the byte sequence that should be appended to the designated input.
*
* @param in the input buffer containing the bytes to pad.
diff --git a/gnu/javax/crypto/sasl/plain/PasswordFile.java b/gnu/javax/crypto/sasl/plain/PasswordFile.java
index 8ad225ab9..b6fb3f87e 100644
--- a/gnu/javax/crypto/sasl/plain/PasswordFile.java
+++ b/gnu/javax/crypto/sasl/plain/PasswordFile.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.plain;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import gnu.javax.crypto.sasl.NoSuchUserException;
import gnu.javax.crypto.sasl.UserAlreadyExistsException;
@@ -50,6 +50,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.security.AccessController;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;
@@ -63,8 +64,9 @@ public class PasswordFile
private static String DEFAULT_FILE;
static
{
- DEFAULT_FILE = SystemProperties.getProperty(PlainRegistry.PASSWORD_FILE,
- PlainRegistry.DEFAULT_PASSWORD_FILE);
+ DEFAULT_FILE = (String) AccessController.doPrivileged
+ (new GetPropertyAction(PlainRegistry.PASSWORD_FILE,
+ PlainRegistry.DEFAULT_PASSWORD_FILE));
}
private Hashtable entries;
private File passwdFile;
diff --git a/gnu/javax/imageio/gif/GIFImageReader.java b/gnu/javax/imageio/gif/GIFImageReader.java
index 24e3d46db..66484fd88 100644
--- a/gnu/javax/imageio/gif/GIFImageReader.java
+++ b/gnu/javax/imageio/gif/GIFImageReader.java
@@ -231,9 +231,6 @@ public class GIFImageReader extends ImageReader
new int[] {0xFF});
break;
}
- byte[] bits = f.getRawImage();
- for(int i = 0; i < 5; i++)
- System.out.println("Bits "+i+":"+bits[i]);
DataBuffer db = new DataBufferByte(f.getRawImage(), width * height, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);
diff --git a/gnu/javax/sound/sampled/AU/AUReader.java b/gnu/javax/sound/sampled/AU/AUReader.java
new file mode 100644
index 000000000..c9035df73
--- /dev/null
+++ b/gnu/javax/sound/sampled/AU/AUReader.java
@@ -0,0 +1,212 @@
+/* AUReader.java -- Read AU files.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.sound.sampled.AU;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.sound.sampled.spi.AudioFileReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.nio.ByteBuffer;
+
+public class AUReader extends AudioFileReader
+{
+ private static class AUHeader
+ {
+ // Magic number identifying the file. '.snd'
+ private static final int MAGIC = 0x2e736e64;
+
+ public static final int SIZE = 24; // size of the header
+
+ // Encoding types
+ public static final int ULAW = 1; // 8-bit u-law
+ public static final int PCM8 = 2; // 8-bit PCM
+ public static final int PCM16 = 3; // 16-bit PCM
+ public static final int PCM24 = 4; // 24-bit PCM
+ public static final int PCM32 = 5; // 32-bit PCM
+ public static final int IEEE32 = 6; // 32-bit IEEE f.p.
+ public static final int IEEE64 = 7; // 64-bit IEEE f.p.
+ public static final int G721 = 23;
+ public static final int G722 = 24;
+ public static final int G723 = 25;
+ public static final int G723_5BIT = 26;
+ public static final int ALAW = 27; // 8-bit a-law
+
+ // Header data.
+ public int headerSize;
+ public int fileSize; // this value may not be set.
+ public int encoding;
+ public int sampleRate;
+ public int channels;
+ public int sampleSizeInBits;
+
+ public AUHeader(InputStream stream)
+ throws IOException, UnsupportedAudioFileException
+ {
+ byte[] hdr = new byte[24];
+ stream.read( hdr );
+ ByteBuffer buf = ByteBuffer.wrap(hdr);
+
+ if( buf.getInt() != MAGIC )
+ throw new UnsupportedAudioFileException("Not an AU format audio file.");
+ headerSize = buf.getInt();
+ fileSize = buf.getInt();
+ encoding = buf.getInt();
+ sampleRate = buf.getInt();
+ channels = buf.getInt();
+
+ switch(encoding)
+ {
+ case ULAW:
+ case PCM8:
+ case ALAW:
+ sampleSizeInBits = 8;
+ break;
+ case PCM16:
+ sampleSizeInBits = 16;
+ break;
+ case PCM24:
+ sampleSizeInBits = 24;
+ break;
+ case PCM32:
+ sampleSizeInBits = 32;
+ break;
+ default: // other types exist but are not supported. Yet.
+ throw new UnsupportedAudioFileException("Unsupported encoding.");
+ }
+ }
+
+ public AudioFormat getAudioFormat()
+ {
+ AudioFormat.Encoding encType = AudioFormat.Encoding.PCM_SIGNED;
+ if(encoding == 1)
+ encType = AudioFormat.Encoding.ULAW;
+ if(encoding == 27)
+ encType = AudioFormat.Encoding.ALAW;
+
+ return new AudioFormat(encType,
+ (float)sampleRate,
+ sampleSizeInBits,
+ channels,
+ (sampleSizeInBits >> 3) * channels,
+ (float)sampleRate,
+ true);
+ }
+
+ public AudioFileFormat getAudioFileFormat()
+ {
+ return new AudioFileFormat(new AUFormatType(),
+ getAudioFormat(),
+ AudioSystem.NOT_SPECIFIED);
+ }
+ }
+
+ public static class AUFormatType extends AudioFileFormat.Type
+ {
+ public AUFormatType()
+ {
+ super("AU", ".au");
+ }
+ }
+
+ public AudioFileFormat getAudioFileFormat(File file)
+ throws IOException, UnsupportedAudioFileException
+ {
+ return getAudioFileFormat(new FileInputStream(file));
+ }
+
+ public AudioFileFormat getAudioFileFormat(InputStream stream)
+ throws IOException, UnsupportedAudioFileException
+ {
+ if(!stream.markSupported())
+ throw new IOException("Stream must support marking.");
+
+ stream.mark(25);
+ AUHeader header = new AUHeader(stream);
+ stream.reset();
+
+ return header.getAudioFileFormat();
+ }
+
+ public AudioFileFormat getAudioFileFormat(URL url)
+ throws IOException, UnsupportedAudioFileException
+ {
+ return getAudioFileFormat(new BufferedInputStream(url.openStream()));
+ }
+
+ public AudioInputStream getAudioInputStream(File file)
+ throws IOException, UnsupportedAudioFileException
+ {
+ InputStream stream = new FileInputStream(file);
+ long length = file.length();
+
+ AUHeader header = new AUHeader( stream );
+ if( header.headerSize > AUHeader.SIZE )
+ stream.skip(header.headerSize - AUHeader.SIZE);
+
+ length -= header.headerSize;
+
+ return new AudioInputStream(stream, header.getAudioFormat(), length);
+ }
+
+ public AudioInputStream getAudioInputStream(InputStream stream)
+ throws IOException, UnsupportedAudioFileException
+ {
+ AUHeader header = new AUHeader( stream );
+ if( header.headerSize > AUHeader.SIZE )
+ stream.skip(header.headerSize - AUHeader.SIZE);
+
+ return new AudioInputStream(stream, header.getAudioFormat(),
+ AudioSystem.NOT_SPECIFIED);
+ }
+
+ public AudioInputStream getAudioInputStream(URL url)
+ throws IOException, UnsupportedAudioFileException
+ {
+ return getAudioInputStream(new BufferedInputStream(url.openStream()));
+ }
+}
+
diff --git a/gnu/javax/swing/text/html/parser/GnuParserDelegator.java b/gnu/javax/swing/text/html/parser/GnuParserDelegator.java
new file mode 100644
index 000000000..841db667e
--- /dev/null
+++ b/gnu/javax/swing/text/html/parser/GnuParserDelegator.java
@@ -0,0 +1,178 @@
+/* GnuParserDelegator.java -- The parser delegator which uses Swing DTD
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Serializable;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.HTMLEditorKit.ParserCallback;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.ParserDelegator;
+import javax.swing.text.html.parser.TagElement;
+
+/**
+ * This parser delegator uses the different DTD ({@link HTML_401Swing}).
+ * It is derived from the ParserDelegator for the compatibility reasons.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class GnuParserDelegator extends ParserDelegator implements Serializable
+{
+ class gnuParser
+ extends gnu.javax.swing.text.html.parser.support.Parser
+ {
+ private static final long serialVersionUID = 1;
+
+ gnuParser(DTD d)
+ {
+ super(d);
+ }
+
+ protected final void handleComment(char[] comment)
+ {
+ callBack.handleComment(comment, hTag.where.startPosition);
+ }
+
+ protected final void handleEmptyTag(TagElement tag)
+ throws javax.swing.text.ChangedCharSetException
+ {
+ callBack.handleSimpleTag(tag.getHTMLTag(), getAttributes(),
+ hTag.where.startPosition
+ );
+ }
+
+ protected final void handleEndTag(TagElement tag)
+ {
+ callBack.handleEndTag(tag.getHTMLTag(), hTag.where.startPosition);
+ }
+
+ protected final void handleError(int line, String message)
+ {
+ callBack.handleError(message, hTag.where.startPosition);
+ }
+
+ protected final void handleStartTag(TagElement tag)
+ {
+ htmlAttributeSet attributes = gnu.getAttributes();
+
+ if (tag.fictional())
+ attributes.addAttribute(ParserCallback.IMPLIED, Boolean.TRUE);
+
+ callBack.handleStartTag(tag.getHTMLTag(), attributes,
+ hTag.where.startPosition
+ );
+ }
+
+ protected final void handleText(char[] text)
+ {
+ callBack.handleText(text, hTag.where.startPosition);
+ }
+
+ DTD getDTD()
+ {
+ // Accessing the inherited gnu.javax.swing.text.html.parser.support.Parser
+ // field. super. is a workaround, required to support JDK1.3's javac.
+ return super.dtd;
+ }
+ }
+
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -1276686502624777206L;
+
+ private DTD theDtd;
+
+ /**
+ * The callback.
+ * This is package-private to avoid an accessor method.
+ */
+ HTMLEditorKit.ParserCallback callBack;
+
+ /**
+ * The reference to the working class of HTML parser that is
+ * actually used to parse the document.
+ * This is package-private to avoid an accessor method.
+ */
+ gnuParser gnu;
+
+ /**
+ * Create the parser that uses the given DTD to parse the document.
+ *
+ * @param theDtd the DTD
+ */
+ public GnuParserDelegator(DTD theDtd)
+ {
+ this.theDtd = theDtd;
+ gnu = new gnuParser(theDtd);
+ }
+
+ /**
+ * Parses the HTML document, calling methods of the provided callback. This
+ * method must be multithread - safe.
+ *
+ * @param reader The reader to read the HTML document from
+ * @param a_callback The callback that is notifyed about the presence of HTML
+ * elements in the document.
+ * @param ignoreCharSet If thrue, any charset changes during parsing are
+ * ignored.
+ * @throws java.io.IOException
+ */
+ public void parse(Reader reader,
+ HTMLEditorKit.ParserCallback a_callback,
+ boolean ignoreCharSet) throws IOException
+ {
+ callBack = a_callback;
+ gnu.parse(reader);
+
+ callBack.handleEndOfLineString(gnu.getEndOfLineSequence());
+ try
+ {
+ callBack.flush();
+ }
+ catch (BadLocationException ex)
+ {
+ // Convert this into the supported type of exception.
+ throw new IOException(ex.getMessage());
+ }
+ }
+}
diff --git a/gnu/javax/swing/text/html/parser/HTML_401F.java b/gnu/javax/swing/text/html/parser/HTML_401F.java
index 1ed42a2ab..c3c347e36 100644
--- a/gnu/javax/swing/text/html/parser/HTML_401F.java
+++ b/gnu/javax/swing/text/html/parser/HTML_401F.java
@@ -759,23 +759,8 @@ public class HTML_401F
defElement(BODY, 0, true, true, null,
NONE
,
- new String[] {
- PCDATA, A, ABBR, ACRONYM,
- APPLET, B, BASEFONT, BDO, BIG,
- BR, BUTTON, CITE, CODE, DFN,
- EM, FONT, I, IFRAME, IMG,
- INPUT, KBD, LABEL, MAP, OBJECT,
- Q, S, SAMP, SCRIPT, SELECT,
- SMALL, SPAN, STRIKE, STRONG, SUB,
- SUP, TEXTAREA, TT, U, VAR,
- ADDRESS, BLOCKQUOTE, CENTER, DEL, DIR,
- DIV, DL, FIELDSET, FORM, H1,
- H2, H3, H4, H5, H6,
- HR, INS, ISINDEX, MENU, NOFRAMES,
- NOSCRIPT, OL, P, PRE, TABLE,
- UL
- }
- ,
+ getBodyElements()
+ ,
new AttributeList[] {
attr(sID, null, null, ID, IMPLIED),
attr(CLASS, null, null, 0, IMPLIED),
@@ -3634,7 +3619,7 @@ public class HTML_401F
* Crate a content model, consisting of the single
* element, specified by name.
*/
- private ContentModel model(String element)
+ protected ContentModel model(String element)
{
return new ContentModel(getElement(element));
}
@@ -3653,7 +3638,7 @@ public class HTML_401F
/**
* Create the model HEAD, BODY
- * @return
+ * @return the HTML content model of the whole document
*/
protected ContentModel createHtmlContentModel()
{
@@ -3725,5 +3710,27 @@ public class HTML_401F
li.type = ul.type = ol.type = '|';
return li;
}
-
+
+ /**
+ * Get elements that are allowed in the document body, at the zero level.
+ */
+ protected String[] getBodyElements()
+ {
+ return new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DEL, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, INS, ISINDEX, MENU, NOFRAMES,
+ NOSCRIPT, OL, P, PRE, TABLE,
+ UL
+ };
+ }
}
diff --git a/gnu/javax/swing/text/html/parser/HTML_401Swing.java b/gnu/javax/swing/text/html/parser/HTML_401Swing.java
new file mode 100644
index 000000000..9c934f647
--- /dev/null
+++ b/gnu/javax/swing/text/html/parser/HTML_401Swing.java
@@ -0,0 +1,91 @@
+/* HTML_401Swing.java -- The HTML 4.01 DTD, adapted for HTML rendering in Swing
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import javax.swing.text.html.parser.DTD;
+
+/**
+ * This class is necessary because the current implementation of the GNU
+ * Classpath Swing requires always enclose the text into paragraphs.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class HTML_401Swing extends HTML_401F
+{
+ /**
+ * The singleton instance;
+ */
+ final static HTML_401Swing singleton = new HTML_401Swing();
+
+ /**
+ * Either takes the document (by name) from DTD table, or
+ * creates a new instance and registers it in the tabe.
+ * The document is registerd under name "-//W3C//DTD HTML 4.01 Frameset//EN".
+ * @return The new or existing DTD for parsing HTML 4.01 Frameset.
+ */
+ public static DTD getInstance()
+ {
+ return singleton;
+ }
+
+ /**
+ * Get elements that are allowed in the document body, at the zero level.
+ * This list disallows the text at this level (the implied P tag will be
+ * generated). It also disallows A, B, I, U, CITE and other similar
+ * elements that have the plain text inside. They will also be placed
+ * inside the generated implied P tags.
+ */
+ protected String[] getBodyElements()
+ {
+ return new String[] {
+ APPLET, BASEFONT,
+ BR, BUTTON,
+ IFRAME, IMG,
+ INPUT, LABEL, MAP, OBJECT,
+ SCRIPT, SELECT,
+ TEXTAREA,
+ BLOCKQUOTE, CENTER, DEL, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, INS, ISINDEX, MENU, NOFRAMES,
+ NOSCRIPT, OL, P, PRE, TABLE,
+ UL
+ };
+ }
+}
diff --git a/gnu/javax/swing/text/html/parser/htmlValidator.java b/gnu/javax/swing/text/html/parser/htmlValidator.java
index 1f9eee03a..4d287a677 100644
--- a/gnu/javax/swing/text/html/parser/htmlValidator.java
+++ b/gnu/javax/swing/text/html/parser/htmlValidator.java
@@ -233,7 +233,9 @@ public abstract class htmlValidator
Element fe = (Element) v;
// notify the content model that we add the proposed tag
- getCurrentContentModel().show(fe);
+ node ccm = getCurrentContentModel();
+ if (ccm != null)
+ ccm.show(fe);
openFictionalTag(fe);
Object vv = tagIsValidForContext(tElement);
@@ -301,13 +303,12 @@ public abstract class htmlValidator
}
/**
- * Check if this tag is valid for the current context.
- * Return Boolean.True if it is OK, Boolean.False
- * if it is surely not OK or the Element that the
- * content model recommends to insert making the situation
- * ok. If Boolean.True is returned, the content model current
- * position is moved forward. Otherwise this position remains
- * the same.
+ * Check if this tag is valid for the current context. Return Boolean.True if
+ * it is OK, Boolean.False if it is surely not OK or the Element that the
+ * content model recommends to insert making the situation ok. If Boolean.True
+ * is returned, the content model current position is moved forward. Otherwise
+ * this position remains the same.
+ *
* @param tElement
* @return
*/
@@ -321,7 +322,7 @@ public abstract class htmlValidator
// Check exclusions and inclusions.
ListIterator iter = stack.listIterator(stack.size());
- hTag t;
+ hTag t = null;
final int idx = tElement.getElement().index;
// Check only known tags.
@@ -331,19 +332,27 @@ public abstract class htmlValidator
while (iter.hasPrevious())
{
t = (hTag) iter.previous();
- if (!t.forcibly_closed)
+ if (! t.forcibly_closed)
{
- if (t.element.exclusions != null &&
- t.element.exclusions.get(idx)
- )
+ if (t.element.exclusions != null
+ && t.element.exclusions.get(idx))
return Boolean.FALSE;
if (t.element.inclusions != null)
inclusions.or(t.element.inclusions);
}
}
- if (!inclusions.get(idx))
- return Boolean.FALSE;
+ if (! inclusions.get(idx))
+ {
+ // If we need to insert something, and cannot do this, but
+ // it is allowed to insert the paragraph here, insert the
+ // paragraph.
+ Element P = dtd.getElement(HTML_401F.P);
+ if (inclusions.get(P.index))
+ return P;
+ else
+ return Boolean.FALSE;
+ }
}
return Boolean.TRUE;
}
diff --git a/include/Makefile.am b/include/Makefile.am
index cce6fd636..7d7d51238 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -47,7 +47,6 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkRobotPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkTextLayout.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.h \
diff --git a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
index 7f8138fe1..a54c7117e 100644
--- a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
@@ -16,6 +16,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels (JN
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_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);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jlong, jint);
@@ -24,6 +25,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash (
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector (JNIEnv *env, jobject, jlong, jobject, jfloat, jfloat, jint, jintArray, jfloatArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelCurveTo (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoArc (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSave (JNIEnv *env, jobject, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRestore (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoNewPath (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClosePath (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoMoveTo (JNIEnv *env, jobject, jlong, jdouble, jdouble);
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h b/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
index 2a619c609..6177a6fb9 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
@@ -16,6 +16,7 @@ JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment
JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice (JNIEnv *env, jobject);
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies (JNIEnv *env, jobject, jobjectArray);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_getMouseCoordinates (JNIEnv *env, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkToolkit.h b/include/gnu_java_awt_peer_gtk_GtkToolkit.h
index ffeb39935..6cdcc622a 100644
--- a/include/gnu_java_awt_peer_gtk_GtkToolkit.h
+++ b/include/gnu_java_awt_peer_gtk_GtkToolkit.h
@@ -17,6 +17,7 @@ JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenResolution
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_sync (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors (JNIEnv *env, jobject, jintArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkMain (JNIEnv *env, jclass);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GtkToolkit_getMouseNumberOfButtons (JNIEnv *env, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h b/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
index ad447f16a..934e13e25 100644
--- a/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
@@ -13,6 +13,7 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetTitle (JNIEnv *env, jobject, jstring);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable (JNIEnv *env, jobject, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetModal (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetAlwaysOnTop (JNIEnv *env, jobject, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_realize (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create (JNIEnv *env, jobject, jint, jboolean, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNative (JNIEnv *env, jobject, jboolean);
diff --git a/include/gnu_java_net_local_LocalSocketImpl.h b/include/gnu_java_net_local_LocalSocketImpl.h
index 3309053f1..b1f1fcd84 100644
--- a/include/gnu_java_net_local_LocalSocketImpl.h
+++ b/include/gnu_java_net_local_LocalSocketImpl.h
@@ -13,7 +13,7 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_create (JNIEnv *env, jobject, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_listen (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_accept (JNIEnv *env, jobject, jobject);
-JNIEXPORT jint JNICALL Java_gnu_java_net_local_LocalSocketImpl_available (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_net_local_LocalSocketImpl_available (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_close (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_sendUrgentData (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_shutdownInput (JNIEnv *env, jobject);
@@ -21,8 +21,8 @@ JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_shutdownOutput (J
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_unlink (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_localBind (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_localConnect (JNIEnv *env, jobject, jobject);
-JNIEXPORT jint JNICALL Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject, jbyteArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject, jbyteArray, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject, jint, jbyteArray, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject, jint, jbyteArray, jint, jint);
#ifdef __cplusplus
}
diff --git a/include/jvmti.h b/include/jvmti.h
new file mode 100644
index 000000000..d93ecbec9
--- /dev/null
+++ b/include/jvmti.h
@@ -0,0 +1,1811 @@
+/* jvmti.h - Java Virtual Machine Tool Interface
+ 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. */
+
+
+/* Note: this file must be compilable by the C compiler (for now,
+ assuming GNU C is ok). This means you must never use `//'
+ comments, and all C++-specific code must be conditional on
+ __cplusplus. */
+
+#ifndef _CLASSPATH_JVMTI_H
+#define _CLASSPATH_JVMTI_H
+#include <jni.h>
+
+/* The VM might define JVMTI base types */
+#ifndef _CLASSPATH_VM_JVMTI_TYPES_DEFINED
+
+typedef jobject jthread;
+typedef jobject jthreadGroup;
+typedef jlong jlocation;
+typedef struct _Jv_rawMonitorID *jrawMonitorID;
+
+#endif /* !_CLASSPATH_VM_JVMTI_TYPES_DEFINED */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* These functions might be defined in libraries which we load; the
+ JVMTI implementation calls them at the appropriate times. */
+extern JNIEXPORT jint JNICALL Agent_OnLoad (JavaVM *vm, char *options,
+ void *reserved);
+extern JNIEXPORT void JNICALL Agent_OnUnload (JavaVM *vm);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Forward declarations */
+typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap;
+#ifdef __cplusplus
+typedef struct _Jv_JVMTIEnv jvmtiEnv;
+#else
+typedef const struct _Jv_jvmtiEnv jvmtiEnv;
+#endif
+
+/*
+ * Error constants
+ */
+
+typedef enum
+{
+ /* Universal Errors */
+ JVMTI_ERROR_NONE = 0,
+ JVMTI_ERROR_NULL_POINTER = 100,
+ JVMTI_ERROR_OUT_OF_MEMORY = 110,
+ JVMTI_ERROR_ACCESS_DENIED = 111,
+ JVMTI_ERROR_WRONG_PHASE = 112,
+ JVMTI_ERROR_INTERNAL = 113,
+ JVMTI_ERROR_UNATTACHED_THREAD = 115,
+ JVMTI_ERROR_INVALID_ENVIRONMENT = 116,
+
+ /* Function-specific Required Errors */
+ JVMTI_ERROR_INVALID_PRIORITY = 12,
+ JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13,
+ JVMTI_ERROR_THREAD_SUSPENDED = 14,
+ JVMTI_ERROR_THREAD_NOT_ALIVE = 15,
+ JVMTI_ERROR_CLASS_NOT_PREPARED = 22,
+ JVMTI_ERROR_NO_MORE_FRAMES = 31,
+ JVMTI_ERROR_OPAQUE_FRAME = 32,
+ JVMTI_ERROR_DUPLICATE = 40,
+ JVMTI_ERROR_NOT_FOUND = 41,
+ JVMTI_ERROR_NOT_MONITOR_OWNER = 51,
+ JVMTI_ERROR_INTERRUPT = 52,
+ JVMTI_ERROR_UNMODIFIABLE_CLASS = 79,
+ JVMTI_ERROR_NOT_AVAILABLE = 98,
+ JVMTI_ERROR_ABSENT_INFORMATION = 101,
+ JVMTI_ERROR_INVALID_EVENT_TYPE = 102,
+ JVMTI_ERROR_NATIVE_METHOD = 104,
+
+ /* Function-specific Agent Errors */
+ JVMTI_ERROR_INVALID_THREAD = 10,
+ JVMTI_ERROR_INVALID_THREAD_GROUP = 11,
+ JVMTI_ERROR_INVALID_OBJECT = 20,
+ JVMTI_ERROR_INVALID_CLASS = 21,
+ JVMTI_ERROR_INVALID_METHODID = 23,
+ JVMTI_ERROR_INVALID_LOCATION = 24,
+ JVMTI_ERROR_INVALID_FIELDID = 25,
+ JVMTI_ERROR_TYPE_MISMATCH = 34,
+ JVMTI_ERROR_INVALID_SLOT = 35,
+ JVMTI_ERROR_INVALID_MONITOR = 50,
+ JVMTI_ERROR_INVALID_CLASS_FORMAT = 60,
+ JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64,
+ JVMTI_ERROR_INVALID_TYPESTATE = 65,
+ JVMTI_ERROR_FAILS_VERIFICATION = 62,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67,
+ JVMTI_ERROR_UNSUPPORTED_VERSION = 68,
+ JVMTI_ERROR_NAMES_DONT_MATCH = 69,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71,
+ JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99,
+ JVMTI_ERROR_ILLEGAL_ARGUMENT = 103,
+} jvmtiError;
+
+/*
+ * Enumeration Definitions
+ */
+
+typedef enum
+{
+ JVMTI_DISABLE = 0,
+ JVMTI_ENABLE = 1
+} jvmtiEventMode;
+
+typedef enum
+{
+ JVMTI_HEAP_OBJECT_TAGGED = 1,
+ JVMTI_HEAP_OBJECT_UNTAGGED = 2,
+ JVMTI_HEAP_OBJECT_EITHER = 3
+} jvmtiHeapObjectFilter;
+
+typedef enum
+{
+ JVMTI_HEAP_ROOT_JNI_GLOBAL = 1,
+ JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2,
+ JVMTI_HEAP_ROOT_MONITOR = 3,
+ JVMTI_HEAP_ROOT_STACK_LOCAL = 4,
+ JVMTI_HEAP_ROOT_JNI_LOCAL = 5,
+ JVMTI_HEAP_ROOT_THREAD = 6,
+ JVMTI_HEAP_ROOT_OTHER = 7
+} jvmtiHeapRootKind;
+
+typedef enum
+{
+ JVMTI_ITERATION_ABORT = 0,
+ JVMTI_ITERATION_CONTINUE = 1,
+ JVMTI_ITERATION_IGNORE = 2
+} jvmtiIterationControl;
+
+typedef enum
+{
+ JVMTI_JLOCATION_OTHER = 0,
+ JVMTI_JLOCATION_JVMBCI = 1,
+ JVMTI_JLOCATION_MACHINEPC = 2
+} jvmtiJlocationFormat;
+
+typedef enum
+{
+ JVMTI_REFERENCE_CLASS = 1,
+ JVMTI_REFERENCE_FIELD = 2,
+ JVMTI_REFERENCE_ARRAY_ELEMENT = 3,
+ JVMTI_REFERENCE_CLASS_LOADER = 4,
+ JVMTI_REFERENCE_SIGNERS = 5,
+ JVMTI_REFERENCE_PROTECTION_DOMAIN = 6,
+ JVMTI_REFERENCE_INTERFACE = 7,
+ JVMTI_REFERENCE_STATIC_FIELD = 8,
+ JVMTI_REFERENCE_CONSTANT_POOL = 9
+} jvmtiObjectReferenceKind;
+
+typedef enum
+{
+ JVMTI_KIND_IN = 91,
+ JVMTI_KIND_IN_PTR = 92,
+ JVMTI_KIND_IN_BUF = 93,
+ JVMTI_KIND_ALLOC_BUF = 94,
+ JVMTI_KIND_ALLOC_ALLOC_BUF = 95,
+ JVMTI_KIND_OUT = 96,
+ JVMTI_KIND_OUT_BUF = 97
+} jvmtiParamKind;
+
+typedef enum
+{
+ JVMTI_TYPE_JBYTE = 101,
+ JVMTI_TYPE_JCHAR = 102,
+ JVMTI_TYPE_JSHORT = 103,
+ JVMTI_TYPE_JINT = 104,
+ JVMTI_TYPE_JLONG = 105,
+ JVMTI_TYPE_JFLOAT = 106,
+ JVMTI_TYPE_JDOUBLE = 107,
+ JVMTI_TYPE_JBOOLEAN = 108,
+ JVMTI_TYPE_JOBJECT = 109,
+ JVMTI_TYPE_JTHREAD = 110,
+ JVMTI_TYPE_JCLASS = 111,
+ JVMTI_TYPE_JVALUE = 112,
+ JVMTI_TYPE_JFIELDID = 113,
+ JVMTI_TYPE_JMETHODID = 114,
+ JVMTI_TYPE_CCHAR = 115,
+ JVMTI_TYPE_CVOID = 116,
+ JVMTI_TYPE_JNIENV = 117
+} jvmtiParamTypes;
+
+typedef enum
+{
+ JVMTI_PHASE_ONLOAD = 1,
+ JVMTI_PHASE_PRIMORDIAL = 2,
+ JVMTI_PHASE_LIVE = 4,
+ JVMTI_PHASE_START = 6,
+ JVMTI_PHASE_DEAD = 8
+} jvmtiPhase;
+
+typedef enum
+{
+ JVMTI_TIMER_USER_CPU = 30,
+ JVMTI_TIMER_TOTAL_CPU = 31,
+ JVMTI_TIMER_ELAPSED = 32
+} jvmtiTimerKind;
+
+typedef enum
+{
+ JVMTI_VERBOSE_OTHER = 0,
+ JVMTI_VERBOSE_GC = 1,
+ JVMTI_VERBOSE_CLASS = 2,
+ JVMTI_VERBOSE_JNI = 4
+} jvmtiVerboseFlag;
+
+/* Version information */
+#define JVMTI_VERSION_INTERFACE_JNI 0x00000000
+#define JVMTI_VERSION_INTERFACE_JVMTI 0x30000000
+#define JVMTI_VERSION_MASK_INTERFACE_TYPE 0x70000000
+#define JVMTI_VERSION_MASK_MAJOR 0x0FFF0000
+#define JVMTI_VERSION_MASK_MINOR 0x0000FF00
+#define JVMTI_VERSION_MASK_MICRO 0x000000FF
+#define JVMTI_VERSION_SHIFT_MAJOR 16
+#define JVMTI_VERSION_SHIFT_MINOR 8
+#define JVMTI_VERSION_SHIFT_MICRO 0
+
+/*
+ * Events and event callbacks
+ */
+
+typedef enum
+{
+ JVMTI_EVENT_VM_INIT = 50,
+ JVMTI_EVENT_VM_DEATH = 51,
+ JVMTI_EVENT_THREAD_START = 52,
+ JVMTI_EVENT_THREAD_END = 53,
+ JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54,
+ JVMTI_EVENT_CLASS_LOAD = 55,
+ JVMTI_EVENT_CLASS_PREPARE = 56,
+ JVMTI_EVENT_VM_START = 57,
+ JVMTI_EVENT_EXCEPTION = 58,
+ JVMTI_EVENT_EXCEPTION_CATCH = 59,
+ JVMTI_EVENT_SINGLE_STEP = 60,
+ JVMTI_EVENT_FRAME_POP = 61,
+ JVMTI_EVENT_BERAKPOINT = 62,
+ JVMTI_EVENT_FIELD_ACCESS = 63,
+ JVMTI_EVENT_FIELD_MODIFICATION = 64,
+ JVMTI_EVENT_METHOD_ENTRY = 65,
+ JVMTI_EVENT_METHOD_EXIT = 66,
+ JVMTI_EVENT_NATIVE_METHOD_BIND = 67,
+ JVMTI_EVENT_COMPILED_METHOD_LOAD = 68,
+ JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69,
+ JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70,
+ JVMTI_EVENT_DATA_DUMP_REQUEST = 71,
+ JVMTI_EVENT_MONITOR_WAIT = 73,
+ JVMTI_EVENT_MONITOR_WAITED = 74,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76,
+ JVMTI_EVENT_GARBAGE_COLLECTION_START = 81,
+ JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82,
+ JVMTI_EVENT_OBJECT_FREE = 83,
+ JVMTI_EVENT_VM_OBJECT_ALLOC = 84
+} jvmtiEvent;
+
+typedef void *jvmtiEventReserved;
+
+typedef void (JNICALL *jvmtiEventSingleStep)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventBreakpoint)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventFieldAccess)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jclass field_klass, jobject object, jfieldID field);
+
+typedef void (JNICALL *jvmtiEventFieldModification)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jclass field_klass, jobject object, jfieldID field,
+ char signature_type, jvalue new_value);
+
+typedef void (JNICALL *jvmtiEventFramePop)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jboolean was_popped_by_exception);
+
+typedef void (JNICALL *jvmtiEventMethodEntry)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method);
+
+typedef void (JNICALL *jvmtiEventMethodExit)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jboolean was_popped_by_exception, jvalue return_value);
+
+typedef void (JNICALL *jvmtiEventNativeMethodBind)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ void *address, void **new_address_ptr);
+
+typedef void (JNICALL *jvmtiEventException)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jobject exception, jmethodID catch_method,
+ jlocation catch_location);
+
+typedef void (JNICALL *jvmtiEventExceptionCatch)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jobject exception);
+
+typedef void (JNICALL *jvmtiEventThreadStart)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventThreadEnd)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventClassLoad)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jclass klass);
+
+typedef void (JNICALL *jvmtiEventClassPrepare)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thraed, jclass klass);
+
+typedef void (JNICALL *jvmtiEventClassFileLoadHook)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jclass class_being_redefined,
+ jobject loader, const char *name, jobject protection_domain,
+ jint class_data_len, const unsigned char *class_data,
+ jint *new_class_data_len, unsigned char **new_class_data);
+
+typedef void (JNICALL *jvmtiEventVMStart)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env);
+
+typedef void (JNICALL *jvmtiEventVMInit)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventVMDeath)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodLoad)
+ (jvmtiEnv *jvmti_env, jmethodID method, jint code_size,
+ const void *code_addr, jint map_length, const jvmtiAddrLocationMap *map,
+ const void *compile_info);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodUnload)
+ (jvmtiEnv *jvmti_env, jmethodID method, const void *code_addr);
+
+typedef void (JNICALL *jvmtiEventDynamicCodeGenerated)
+ (jvmtiEnv *jvmti_env, const char *name, const void *address, jint length);
+
+typedef void (JNICALL *jvmtiEventDataDumpRequest)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEnter)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEntered)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorWait)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jlong timeout);
+
+typedef void (JNICALL *jvmtiEventMonitorWaited)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jboolean timed_out);
+
+typedef void (JNICALL *jvmtiEventVMObjectAlloc)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jclass object_klass, jlong size);
+
+typedef void (JNICALL *jvmtiEventObjectFree)
+ (jvmtiEnv *jvmti_env, jlong tag);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionStart)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionFinish)
+ (jvmtiEnv *jvmti_env);
+
+typedef struct
+{
+ jvmtiEventVMInit VMInit;
+ jvmtiEventVMDeath VMDeath;
+ jvmtiEventThreadStart ThreadStart;
+ jvmtiEventThreadEnd ThreadEnd;
+ jvmtiEventClassFileLoadHook ClassFileLoadHook;
+ jvmtiEventClassLoad ClassLoad;
+ jvmtiEventClassPrepare ClassPrepare;
+ jvmtiEventVMStart VMStart;
+ jvmtiEventException Exception;
+ jvmtiEventExceptionCatch ExceptionCatch;
+ jvmtiEventSingleStep SingleStep;
+ jvmtiEventFramePop FramePop;
+ jvmtiEventBreakpoint Breakpoint;
+ jvmtiEventFieldAccess FieldAccess;
+ jvmtiEventFieldModification FieldModification;
+ jvmtiEventMethodEntry MethodEntry;
+ jvmtiEventMethodExit MethodExit;
+ jvmtiEventNativeMethodBind NativeMethodBind;
+ jvmtiEventCompiledMethodLoad CompiledMethodLoad;
+ jvmtiEventCompiledMethodUnload CompiledMethodUnload;
+ jvmtiEventDynamicCodeGenerated DynamicCodeGenerated;
+ jvmtiEventDataDumpRequest DataDumpRequest;
+ jvmtiEventReserved reserved72;
+ jvmtiEventMonitorWait MonitorWait;
+ jvmtiEventMonitorWaited MonitorWaited;
+ jvmtiEventMonitorContendedEnter MonitorContendedEnter;
+ jvmtiEventMonitorContendedEntered MonitorContendedEntered;
+ jvmtiEventReserved reserved77;
+ jvmtiEventReserved reserved78;
+ jvmtiEventReserved reserved79;
+ jvmtiEventReserved reserved80;
+ jvmtiEventGarbageCollectionStart GarbageCollectionStart;
+ jvmtiEventGarbageCollectionFinish GarbageCollectionFinish;
+ jvmtiEventObjectFree ObjectFree;
+ jvmtiEventVMObjectAlloc VMObjectAlloc;
+} jvmtiEventCallbacks;
+
+/*
+ * Function and Structure Type Definitions
+ */
+
+struct _jvmtiAddrLocationMap
+{
+ const void *start_address;
+ jlocation location;
+};
+
+typedef struct
+{
+ unsigned int can_tag_objects : 1;
+ unsigned int can_generate_field_modification_events : 1;
+ unsigned int can_generate_field_access_events : 1;
+ unsigned int can_get_bytecodes : 1;
+ unsigned int can_get_synthetic_attribute : 1;
+ unsigned int can_get_owned_monitor_info : 1;
+ unsigned int can_get_current_contended_monitor : 1;
+ unsigned int can_get_monitor_info : 1;
+ unsigned int can_pop_frame : 1;
+ unsigned int can_redefine_classes : 1;
+ unsigned int can_signal_thread : 1;
+ unsigned int can_get_source_file_name : 1;
+ unsigned int can_get_line_numbers : 1;
+ unsigned int can_get_source_debug_extension : 1;
+ unsigned int can_access_local_variables : 1;
+ unsigned int can_maintain_original_method_order : 1;
+ unsigned int can_generate_single_step_events : 1;
+ unsigned int can_generate_exception_events : 1;
+ unsigned int can_generate_frame_pop_events : 1;
+ unsigned int can_generate_breakpoint_events : 1;
+ unsigned int can_suspend : 1;
+ unsigned int can_redefine_any_class : 1;
+ unsigned int can_get_current_thread_cpu_time : 1;
+ unsigned int can_get_thread_cpu_time : 1;
+ unsigned int can_generate_method_entry_events : 1;
+ unsigned int can_generate_method_exit_events : 1;
+ unsigned int can_generate_all_class_hook_events : 1;
+ unsigned int can_generate_compiled_method_load_events : 1;
+ unsigned int can_generate_monitor_events : 1;
+ unsigned int can_generate_vm_object_alloc_events : 1;
+ unsigned int can_generate_native_method_bind_events : 1;
+ unsigned int can_generate_garbage_collection_events : 1;
+ unsigned int can_generate_object_free_events : 1;
+ unsigned int : 15;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+} jvmtiCapabilities;
+
+typedef struct
+{
+ jclass klass;
+ jint class_byte_count;
+ const unsigned char *class_bytes;
+} jvmtiClassDefinition;
+
+typedef struct
+{
+ char *name;
+ jvmtiParamKind kind;
+ jvmtiParamTypes base_type;
+ jboolean null_ok;
+} jvmtiParamInfo;
+
+typedef struct
+{
+ jint extension_event_index;
+ char *id;
+ char *short_description;
+ jint param_count;
+ jvmtiParamInfo* params;
+} jvmtiExtensionEventInfo;
+
+typedef jvmtiError (JNICALL *jvmtiExtensionFunction)
+ (jvmtiEnv *jvmti_enf, ...);
+
+typedef struct
+{
+ jvmtiExtensionFunction func;
+ char *id;
+ char *short_description;
+ jint param_count;
+ jvmtiParamInfo *params;
+ jint error_count;
+ jvmtiError *errors;
+} jvmtiExtensionFunctionInfo;
+
+typedef struct
+{
+ jmethodID method;
+ jlocation location;
+} jvmtiFrameInfo;
+
+typedef struct
+{
+ jlocation start_location;
+ jint line_number;
+} jvmtiLineNumberEntry;
+
+typedef struct
+{
+ jlocation start_location;
+ jint length;
+ char *name;
+ char *signature;
+ char *generic_signature;
+ jint slot;
+} jvmtiLocalVariableEntry;
+
+typedef struct
+{
+ jthread owner;
+ jint entry_count;
+ jint waiter_count;
+ jthread *waiters;
+ jint notify_waiter_count;
+ jthread *notify_waiters;
+} jvmtiMonitorUsage;
+
+typedef struct
+{
+ jthread thread;
+ jint state;
+ jvmtiFrameInfo *frame_buffer;
+ jint frame_count;
+} jvmtiStackInfo;
+
+typedef struct
+{
+ jthreadGroup parent;
+ char *name;
+ jint max_priority;
+ jboolean is_daemon;
+} jvmtiThreadGroupInfo;
+
+typedef struct
+{
+ char *name;
+ jint priority;
+ jboolean is_daemon;
+ jthreadGroup thread_group;
+ jobject context_class_loader;
+} jvmtiThreadInfo;
+
+typedef struct
+{
+ jlong max_value;
+ jboolean may_skip_forward;
+ jboolean may_skip_backward;
+ jvmtiTimerKind kind;
+ jlong reserved1;
+ jlong reserved2;
+} jvmtiTimerInfo;
+
+typedef void (JNICALL *jvmtiExtensionEvent)
+ (jvmtiEnv *jvmti_env, ...);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback)
+ (jlong class_tag, jlong size, jlong *tag_ptr, void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong *tag_ptr,
+ void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback)
+ (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size,
+ jlong *tag_ptr, jlong referrer_tag, jint referrer_index, void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong *tag_ptr,
+ jlong thread_tag, jint depth, jmethodID method, jint slot, void *user_data);
+
+typedef void (JNICALL *jvmtiStartFunction)
+ (jvmtiEnv *env, JNIEnv *jni_env, void *arg);
+
+/*
+ * JVM Tool Interface Base Types
+ */
+typedef struct JNINativeInterface jniNativeInterface;
+
+struct _Jv_jvmtiEnv
+{
+ void *reserved1;
+
+ jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv *env,
+ jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread, ...);
+ void *reserved3;
+
+ jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv *env,
+ jint *threads_count_ptr,
+ jthread **threads_ptr);
+
+ jvmtiError (JNICALL *SuspendThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *ResumeThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *StopThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *InterruptThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv *env,
+ jthread thread,
+ jvmtiThreadInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv *env,
+ jthread thread,
+ jint *owned_monitor_count_ptr,
+ jobject **owned_monitors_ptr);
+
+ jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv *env,
+ jthread thread,
+ jobject *monitor_ptr);
+
+ jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv *env,
+ jthread thread,
+ jvmtiStartFunction proc,
+ const void *arg,
+ jint priority);
+
+ jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv *env,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr);
+
+ jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv *env,
+ jthreadGroup group,
+ jvmtiThreadGroupInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv *env,
+ jthreadGroup group,
+ jint *thread_count_ptr,
+ jthread **threads_ptr,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr);
+ jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv *env,
+ jthread thread,
+ jint *count_ptr);
+
+ jvmtiError (JNICALL *GetThreadState) (jvmtiEnv *env,
+ jthread thread,
+ jint *thread_state_ptr);
+
+ void *reserved18;
+
+ jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jmethodID *method_ptr,
+ jlocation *location_ptr);
+
+ jvmtiError (JNICALL *NotifyPopFrame) (jvmtiEnv *env,
+ jthread thread,
+ jint depth);
+
+ jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble *value_ptr);
+
+ jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject value);
+
+ jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint value);
+
+ jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong value);
+
+ jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat value);
+
+ jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble value);
+
+ jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv *env,
+ const char *name,
+ jrawMonitorID *monitor_ptr);
+
+ jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation location);
+
+ jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation location);
+
+ void *reserved40;
+
+ jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ void *reserved45;
+
+ jvmtiError (JNICALL *Allocate) (jvmtiEnv *env,
+ jlong size,
+ unsigned char **mem_ptr);
+
+ jvmtiError (JNICALL *Deallocate) (jvmtiEnv *env,
+ unsigned char *mem);
+
+ jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv *env,
+ jclass klass,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv *env,
+ jclass klass,
+ jint *status_ptr);
+
+ jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv *env,
+ jclass klass,
+ char *source_name_ptr);
+
+ jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv *env,
+ jclass klass,
+ jint *modifiers_ptr);
+
+ jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv *env,
+ jclass klass,
+ jint *method_count_ptr,
+ jmethodID **methods_ptr);
+
+ jvmtiError (JNICALL *GetClassFields) (jvmtiEnv *env,
+ jclass klass,
+ jint *field_count_ptr,
+ jfieldID **fields_ptr);
+
+ jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv *env,
+ jclass klass,
+ jint *interface_count_ptr,
+ jclass **interfaces_ptr);
+
+ jvmtiError (JNICALL *IsInterface) (jvmtiEnv *env,
+ jclass klass,
+ jboolean *is_interface_ptr);
+
+ jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv *env,
+ jclass klass,
+ jboolean *is_array_class_ptr);
+
+ jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv *env,
+ jclass klass,
+ jobject *classloader_ptr);
+
+ jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv *env,
+ jobject object,
+ jint *hash_code_ptr);
+
+ jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv *env,
+ jobject object,
+ jvmtiMonitorUsage *info_ptr);
+
+ jvmtiError (JNICALL *GetFieldName) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ char **name_ptr,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jclass *declaring_class_ptr);
+
+ jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jint *modifiers_ptr);
+
+ jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jboolean *is_synthetic_ptr);
+
+ jvmtiError (JNICALL *GetMethodName) (jvmtiEnv *env,
+ jmethodID method,
+ char **name_ptr,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv *env,
+ jmethodID method,
+ jclass *declaring_class_ptr);
+
+
+ jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv *env,
+ jmethodID method,
+ jint *modifiers_ptr);
+
+ void *reserved67;
+
+ jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv *env,
+ jmethodID method,
+ jint *max_ptr);
+
+ jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv *env,
+ jmethodID method,
+ jint *size_ptr);
+
+ jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv *env,
+ jmethodID method,
+ jint *entry_count_ptr,
+ jvmtiLineNumberEntry **table_ptr);
+
+ jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation *start_location_ptr,
+ jlocation *end_location_ptr);
+
+ jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv *env,
+ jmethodID method,
+ jint *entry_count_ptr,
+ jvmtiLocalVariableEntry **table_ptr);
+
+ void *reserved73;
+
+ void *reserved74;
+
+ jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv *env,
+ jmethodID method,
+ jint *bytecode_count_ptr,
+ unsigned char **bytecodes_ptr);
+
+ jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_native_ptr);
+
+ jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_synthetic_ptr);
+
+ jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv *env,
+ jint *class_count_ptr,
+ jclass **classes_ptr);
+
+ jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv *env,
+ jobject initiating_loader,
+ jint *class_count_ptr,
+ jclass **classes_ptr);
+
+ jvmtiError (JNICALL *PopFrame) (jvmtiEnv *env,
+ jthread thread);
+
+ void *reserved81;
+
+ void *reserved82;
+
+ void *reserved83;
+
+ void *reserved84;
+
+ void *reserved85;
+
+ void *reserved86;
+
+ jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv *env,
+ jint class_count,
+ const jvmtiClassDefinition* class_definitions);
+
+ jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv *env,
+ jint *version_ptr);
+
+ jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv *env,
+ jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv *env,
+ jclass klass,
+ char **source_debug_extension_ptr);
+
+ jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_obsolete_ptr);
+
+ jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv *env,
+ jint request_count,
+ const jthread *request_list,
+ jvmtiError *results);
+
+ jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv *env,
+ jint request_count,
+ const jthread *request_list,
+ jvmtiError *results);
+
+ void *reserved94;
+
+ void *reserved95;
+
+ void *reserved96;
+
+ void *reserved97;
+
+ void *reserved98;
+
+ void *reserved99;
+
+ jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv *env,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr,
+ jint *thread_count_ptr);
+
+ jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv *env,
+ jint thread_count,
+ const jthread *thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr);
+
+ jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv *env,
+ jthread thread,
+ void **data_ptr);
+
+ jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv *env,
+ jthread thread,
+ const void *data);
+
+ jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv *env,
+ jthread thread,
+ jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo *frame_buffer,
+ jint *count_ptr);
+
+ void *reserved105;
+
+ jvmtiError (JNICALL *GetTag) (jvmtiEnv *env,
+ jobject object,
+ jlong *tag_ptr);
+
+ jvmtiError (JNICALL *SetTag) (jvmtiEnv *env,
+ jobject object,
+ jlong tag);
+
+ jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv *env);
+
+ jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv *env,
+ jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv *env,
+ jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv *env,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverInstanceOfClass) (jvmtiEnv *env,
+ jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data);
+
+ void *reserved113;
+
+ jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv *env,
+ jint tag_count,
+ const jlong *tags,
+ jint *count_ptr,
+ jobject **object_result_ptr,
+ jlong **tag_result_ptr);
+
+ void *reserved115;
+
+ void *reserved116;
+
+ void *reserved117;
+
+ void *reserved118;
+
+ void *reserved119;
+
+ jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv *env,
+ const jniNativeInterface *function_table);
+
+ jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv *env,
+ jniNativeInterface **function_table_ptr);
+
+ jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv *env,
+ const jvmtiEventCallbacks *callbacks,
+ jint size_of_callbacks);
+
+ jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv *env,
+ jvmtiEvent event_type);
+
+ jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv *env,
+ jint *extension_count_ptr,
+ jvmtiExtensionFunctionInfo **extensions);
+
+ jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv *env,
+ jint *extension_count_ptr,
+ jvmtiExtensionEventInfo **extensions);
+
+ jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv *env,
+ jint extension_event_index,
+ jvmtiExtensionEvent callback);
+
+ jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv *env);
+
+ jvmtiError (JNICALL *GetErrorName) (jvmtiEnv *env,
+ jvmtiError error,
+ char **name_ptr);
+
+ jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv *env,
+ jvmtiJlocationFormat *format_ptr);
+
+ jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv *env,
+ jint *count_ptr,
+ char ***property_ptr);
+
+ jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv *env,
+ const char *property,
+ char **value_ptr);
+
+ jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv *env,
+ const char *property,
+ const char *value);
+
+ jvmtiError (JNICALL *GetPhase) (jvmtiEnv *env,
+ jvmtiPhase *phase_ptr);
+
+ jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv *env,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv *env,
+ jthread thread,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetTime) (jvmtiEnv *env,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv *env,
+ jvmtiCapabilities *capabilities_ptr);
+
+ void *reserved141;
+
+ jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv *env,
+ const jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv *env,
+ const jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv *env,
+ jint *processor_count_ptr);
+
+ void *reserved145;
+
+ void *reserved146;
+
+ jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv *env,
+ void **data_ptr);
+
+ jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv *env,
+ const void *data);
+
+ jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv *env,
+ const char *segment);
+
+ jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv *env,
+ jvmtiVerboseFlag flag,
+ jboolean value);
+
+ void *reserved151;
+
+ void *reserved152;
+
+ void *reserved153;
+
+ jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv *env,
+ jobject object,
+ jlong *size_ptr);
+};
+
+#ifdef __cplusplus
+class _Jv_JVMTIEnv
+{
+ public:
+ /* Method table */
+ struct _Jv_jvmtiEnv *p;
+
+#ifdef _CLASSPATH_JVMTIENV_CONTENTS
+ _CLASSPATH_JVMTIENV_CONTENTS
+#endif
+
+ jvmtiError SetEventNotificationMode (jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread, ...)
+ {
+ va_list args;
+ va_start (args, event_thread);
+ jvmtiError result = p->SetEventNotificationMode (this, mode, event_type,
+ event_thread, args);
+ va_end (args);
+ return result;
+ }
+
+ jvmtiError GetAllThreads (jint *threads_count_ptr, jthread **threads_ptr)
+ { return p->GetAllThreads (this, threads_count_ptr, threads_ptr); }
+
+ jvmtiError SuspendThread (jthread thread)
+ { return p->SuspendThread (this, thread); }
+
+ jvmtiError ResumeThread (jthread thread)
+ { return p->ResumeThread (this, thread); }
+
+ jvmtiError StopThread (jthread thread)
+ { return p->StopThread (this, thread); }
+
+ jvmtiError InterruptThread (jthread thread)
+ { return p->InterruptThread (this, thread); }
+
+ jvmtiError GetThreadInfo (jthread thread, jvmtiThreadInfo *info_ptr)
+ { return p->GetThreadInfo (this, thread, info_ptr); }
+
+ jvmtiError GetOwnedMonitorInfo (jthread thread,
+ jint *owned_monitor_count_ptr,
+ jobject **owned_monitors_ptr)
+ {
+ return p->GetOwnedMonitorInfo (this, thread, owned_monitor_count_ptr,
+ owned_monitors_ptr);
+ }
+
+ jvmtiError GetCurrentContendedMonitor (jthread thread, jobject *monitor_ptr)
+ { return p->GetCurrentContendedMonitor (this, thread, monitor_ptr); }
+
+ jvmtiError RunAgentThread (jthread thread, jvmtiStartFunction proc,
+ const void *arg, jint priority)
+ { return p->RunAgentThread (this, thread, proc, arg, priority); }
+
+ jvmtiError GetTopThreadGroups (jint *group_count_ptr,
+ jthreadGroup **groups_ptr)
+ { return p->GetTopThreadGroups (this, group_count_ptr, groups_ptr); }
+
+ jvmtiError GetThreadGroupInfo (jthreadGroup group,
+ jvmtiThreadGroupInfo *info_ptr)
+ { return p->GetThreadGroupInfo (this, group, info_ptr); }
+
+ jvmtiError GetThreadGroupChildren (jthreadGroup group,
+ jint *thread_count_ptr,
+ jthread **threads_ptr,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr)
+ {
+ return p->GetThreadGroupChildren (this, group, thread_count_ptr,
+ threads_ptr, group_count_ptr,
+ groups_ptr);
+ }
+
+ jvmtiError GetFrameCount (jthread thread, jint *count_ptr)
+ { return p->GetFrameCount (this, thread, count_ptr); }
+
+ jvmtiError GetThreadState (jthread thread, jint *thread_state_ptr)
+ { return p->GetThreadState (this, thread, thread_state_ptr); }
+
+ jvmtiError GetFrameLocation (jthread thread, jint depth,
+ jmethodID *method_ptr, jlocation *location_ptr)
+ {
+ return p->GetFrameLocation (this, thread, depth, method_ptr,
+ location_ptr);
+ }
+
+ jvmtiError NotifyPopFrame (jthread thread, jint depth)
+ { return p->NotifyPopFrame (this, thread, depth); }
+
+ jvmtiError GetLocalObject (jthread thread, jint depth, jint slot,
+ jobject *value_ptr)
+ { return p->GetLocalObject (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalInt (jthread thread, jint depth, jint slot,
+ jint *value_ptr)
+ { return p->GetLocalInt (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalLong (jthread thread, jint depth, jint slot,
+ jlong *value_ptr)
+ { return p->GetLocalLong (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalFloat (jthread thread, jint depth, jint slot,
+ jfloat *value_ptr)
+ { return p->GetLocalFloat (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalDouble (jthread thread, jint depth, jint slot,
+ jdouble *value_ptr)
+ { return p->GetLocalDouble (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError SetLocalObject (jthread thread, jint depth, jint slot,
+ jobject value)
+ { return p->SetLocalObject (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalInt (jthread thread, jint depth, jint slot,
+ jint value)
+ { return p->SetLocalInt (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalLong (jthread thread, jint depth, jint slot,
+ jlong value)
+ { return p->SetLocalLong (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalFloat (jthread thread, jint depth, jint slot,
+ jfloat value)
+ { return p->SetLocalFloat (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalDouble (jthread thread, jint depth, jint slot,
+ jdouble value)
+ { return p->SetLocalDouble (this, thread, depth, slot, value); }
+
+ jvmtiError CreateRawMonitor (const char *name, jrawMonitorID *monitor_ptr)
+ { return p->CreateRawMonitor (this, name, monitor_ptr); }
+
+ jvmtiError DestroyRawMonitor (jrawMonitorID monitor)
+ { return p->DestroyRawMonitor (this, monitor); }
+
+ jvmtiError RawMonitorEnter (jrawMonitorID monitor)
+ { return p->RawMonitorEnter (this, monitor); }
+
+ jvmtiError RawMonitorExit (jrawMonitorID monitor)
+ { return p->RawMonitorExit (this, monitor); }
+
+ jvmtiError RawMonitorWait (jrawMonitorID monitor)
+ { return p->RawMonitorWait (this, monitor); }
+
+ jvmtiError RawMonitorNotify (jrawMonitorID monitor)
+ { return p->RawMonitorNotify (this, monitor); }
+
+ jvmtiError RawMonitorNotifyAll (jrawMonitorID monitor)
+ { return p->RawMonitorNotifyAll (this, monitor); }
+
+ jvmtiError SetBreakpoint (jmethodID method, jlocation location)
+ { return p->SetBreakpoint (this, method, location); }
+
+ jvmtiError ClearBreakpoint (jmethodID method, jlocation location)
+ { return p->ClearBreakpoint (this, method, location); }
+
+ jvmtiError SetFieldAccessWatch (jclass klass, jfieldID field)
+ { return p->SetFieldAccessWatch (this, klass, field); }
+
+ jvmtiError ClearFieldAccessWatch (jclass klass, jfieldID field)
+ { return p->ClearFieldAccessWatch (this, klass, field); }
+
+ jvmtiError SetFieldModificationWatch (jclass klass, jfieldID field)
+ { return p->SetFieldModificationWatch (this, klass, field); }
+
+ jvmtiError ClearFieldModificationWatch (jclass klass, jfieldID field)
+ { return p->ClearFieldModificationWatch (this, klass, field); }
+
+ jvmtiError Allocate (jlong size, unsigned char **mem_ptr)
+ { return p->Allocate (this, size, mem_ptr); }
+
+ jvmtiError Deallocate (unsigned char *mem)
+ { return p->Deallocate (this, mem); }
+
+ jvmtiError GetClassSignature (jclass klass, char **signature_ptr,
+ char **generic_ptr)
+ { return p->GetClassSignature (this, klass, signature_ptr, generic_ptr); }
+
+ jvmtiError GetClassStatus (jclass klass, jint *status_ptr)
+ { return p->GetClassStatus (this, klass, status_ptr); }
+
+ jvmtiError GetSourceFileName (jclass klass, char *source_name_ptr)
+ { return p->GetSourceFileName (this, klass, source_name_ptr); }
+
+ jvmtiError GetClassModifiers (jclass klass, jint *modifiers_ptr)
+ { return p->GetClassModifiers (this, klass, modifiers_ptr); }
+
+ jvmtiError GetClassMethods (jclass klass, jint *method_count_ptr,
+ jmethodID **methods_ptr)
+ { return p->GetClassMethods (this, klass, method_count_ptr, methods_ptr); }
+
+ jvmtiError GetClassFields (jclass klass, jint *field_count_ptr,
+ jfieldID **fields_ptr)
+ { return p->GetClassFields (this, klass, field_count_ptr, fields_ptr); }
+
+ jvmtiError GetImplementedInterfaces (jclass klass,
+ jint *interface_count_ptr,
+ jclass **interfaces_ptr)
+ {
+ return p->GetImplementedInterfaces (this, klass, interface_count_ptr,
+ interfaces_ptr);
+ }
+
+ jvmtiError IsInterface (jclass klass, jboolean *is_interface_ptr)
+ { return p->IsInterface (this, klass, is_interface_ptr); }
+
+ jvmtiError IsArrayClass (jclass klass, jboolean *is_array_class_ptr)
+ { return p->IsArrayClass (this, klass, is_array_class_ptr); }
+
+ jvmtiError GetClassLoader (jclass klass, jobject *classloader_ptr)
+ { return p->GetClassLoader (this, klass, classloader_ptr); }
+
+ jvmtiError GetObjectHashCode (jobject object, jint *hash_code_ptr)
+ { return p->GetObjectHashCode (this, object, hash_code_ptr); }
+
+ jvmtiError GetObjectMonitorUsage (jobject object,
+ jvmtiMonitorUsage *info_ptr)
+ { return p->GetObjectMonitorUsage (this, object, info_ptr); }
+
+ jvmtiError GetFieldName (jclass klass, jfieldID field, char **name_ptr,
+ char **signature_ptr, char **generic_ptr)
+ {
+ return p->GetFieldName (this, klass, field, name_ptr,
+ signature_ptr, generic_ptr);
+ }
+
+ jvmtiError GetFieldDeclaringClass (jclass klass, jfieldID field,
+ jclass *declaring_class_ptr)
+ {
+ return p->GetFieldDeclaringClass (this, klass, field,
+ declaring_class_ptr);
+ }
+
+ jvmtiError GetFieldModifiers (jclass klass, jfieldID field,
+ jint *modifiers_ptr)
+ { return p->GetFieldModifiers (this, klass, field, modifiers_ptr); }
+
+ jvmtiError IsFieldSynthetic (jclass klass, jfieldID field,
+ jboolean *is_synthetic_ptr)
+ { return p->IsFieldSynthetic (this, klass, field, is_synthetic_ptr); }
+
+ jvmtiError GetMethodName (jmethodID method, char **name_ptr,
+ char **signature_ptr, char **generic_ptr)
+ {
+ return p->GetMethodName (this, method, name_ptr, signature_ptr,
+ generic_ptr);
+ }
+
+ jvmtiError GetMethodDeclaringClass (jmethodID method,
+ jclass *declaring_class_ptr)
+ { return p->GetMethodDeclaringClass (this, method, declaring_class_ptr); }
+
+
+ jvmtiError GetMethodModifiers (jmethodID method, jint *modifiers_ptr)
+ { return p->GetMethodModifiers (this, method, modifiers_ptr); }
+
+ jvmtiError GetMaxLocals (jmethodID method, jint *max_ptr)
+ { return p->GetMaxLocals (this, method, max_ptr); }
+
+ jvmtiError GetArgumentsSize (jmethodID method, jint *size_ptr)
+ { return p->GetArgumentsSize (this, method, size_ptr); }
+
+ jvmtiError GetLineNumberTable (jmethodID method, jint *entry_count_ptr,
+ jvmtiLineNumberEntry **table_ptr)
+ { return p->GetLineNumberTable (this, method, entry_count_ptr, table_ptr); }
+
+ jvmtiError GetMethodLocation (jmethodID method,
+ jlocation *start_location_ptr,
+ jlocation *end_location_ptr)
+ {
+ return p->GetMethodLocation (this, method, start_location_ptr,
+ end_location_ptr);
+ }
+
+ jvmtiError GetLocalVariableTable (jmethodID method, jint *entry_count_ptr,
+ jvmtiLocalVariableEntry **table_ptr)
+ {
+ return p->GetLocalVariableTable (this, method, entry_count_ptr,
+ table_ptr);
+ }
+
+ jvmtiError GetBytecodes (jmethodID method, jint *bytecode_count_ptr,
+ unsigned char **bytecodes_ptr)
+ {
+ return p->GetBytecodes (this, method, bytecode_count_ptr,
+ bytecodes_ptr);
+ }
+
+ jvmtiError IsMethodNative (jmethodID method, jboolean *is_native_ptr)
+ { return p->IsMethodNative (this, method, is_native_ptr); }
+
+ jvmtiError IsMethodSynthetic (jmethodID method, jboolean *is_synthetic_ptr)
+ { return p->IsMethodSynthetic (this, method, is_synthetic_ptr); }
+
+ jvmtiError GetLoadedClasses (jint *class_count_ptr, jclass **classes_ptr)
+ { return p->GetLoadedClasses (this, class_count_ptr, classes_ptr); }
+
+ jvmtiError GetClassLoaderClasses (jobject initiating_loader,
+ jint *class_count_ptr,
+ jclass **classes_ptr)
+ {
+ return p->GetClassLoaderClasses (this, initiating_loader,
+ class_count_ptr, classes_ptr);
+ }
+
+ jvmtiError PopFrame (jthread thread)
+ { return p->PopFrame (this, thread); }
+
+ jvmtiError RedefineClasses (jint class_count,
+ const jvmtiClassDefinition* class_definitions)
+ { return p->RedefineClasses (this, class_count, class_definitions); }
+
+ jvmtiError GetVersionNumber (jint *version_ptr)
+ { return p->GetVersionNumber (this, version_ptr); }
+
+ jvmtiError GetCapabilities (jvmtiCapabilities *capabilities_ptr)
+ { return p->GetCapabilities (this, capabilities_ptr); }
+
+ jvmtiError GetSourceDebugExtension (jclass klass,
+ char **source_debug_extension_ptr)
+ {
+ return p->GetSourceDebugExtension (this, klass,
+ source_debug_extension_ptr);
+ }
+
+ jvmtiError IsMethodObsolete (jmethodID method, jboolean *is_obsolete_ptr)
+ { return p->IsMethodObsolete (this, method, is_obsolete_ptr); }
+
+
+ jvmtiError SuspendThreadList (jint request_count,
+ const jthread *request_list,
+ jvmtiError *results)
+ { return p->SuspendThreadList (this, request_count, request_list, results); }
+
+ jvmtiError ResumeThreadList (jint request_count,
+ const jthread *request_list,
+ jvmtiError *results)
+ { return p->ResumeThreadList (this, request_count, request_list, results); }
+
+ jvmtiError GetAllStackTraces (jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr,
+ jint *thread_count_ptr)
+ {
+ return p->GetAllStackTraces (this, max_frame_count, stack_info_ptr,
+ thread_count_ptr);
+ }
+
+ jvmtiError GetThreadListStackTraces (jint thread_count,
+ const jthread *thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr)
+ {
+ return p->GetThreadListStackTraces (this, thread_count, thread_list,
+ max_frame_count, stack_info_ptr);
+ }
+
+ jvmtiError GetThreadLocalStorage (jthread thread, void **data_ptr)
+ { return p->GetThreadLocalStorage (this, thread, data_ptr); }
+
+ jvmtiError SetThreadLocalStorage (jthread thread, const void *data)
+ { return p->SetThreadLocalStorage (this, thread, data); }
+
+ jvmtiError GetStackTrace (jthread thread, jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo *frame_buffer, jint *count_ptr)
+ {
+ return p->GetStackTrace (this, thread, start_depth, max_frame_count,
+ frame_buffer, count_ptr);
+ }
+
+ jvmtiError GetTag (jobject object, jlong *tag_ptr)
+ { return p->GetTag (this, object, tag_ptr); }
+
+ jvmtiError SetTag (jobject object, jlong tag)
+ { return p->SetTag (this, object, tag); }
+
+ jvmtiError ForceGarbageCollection (void)
+ { return p->ForceGarbageCollection (this); }
+
+ jvmtiError IterateOverObjectsReachableFromObject (jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void *user_data)
+ {
+ return p->IterateOverObjectsReachableFromObject (this, object,
+ object_reference_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverReachableObjects (jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void *user_data)
+ {
+ return p->IterateOverReachableObjects (this, heap_root_callback,
+ stack_ref_callback,
+ object_ref_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverHeap (jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data)
+ {
+ return p->IterateOverHeap (this, object_filter, heap_object_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverInstanceOfClass (jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data)
+ {
+ return p->IterateOverInstanceOfClass (this, klass, object_filter,
+ heap_object_callback, user_data);
+ }
+
+ jvmtiError GetObjectsWithTags (jint tag_count, const jlong *tags,
+ jint *count_ptr, jobject **object_result_ptr,
+ jlong **tag_result_ptr)
+ {
+ return p->GetObjectsWithTags (this, tag_count, tags, count_ptr,
+ object_result_ptr, tag_result_ptr);
+ }
+
+ jvmtiError SetJNIFunctionTable (const jniNativeInterface *function_table)
+ { return p->SetJNIFunctionTable (this, function_table); }
+
+ jvmtiError GetJNIFunctionTable (jniNativeInterface **function_table_ptr)
+ { return p->GetJNIFunctionTable (this, function_table_ptr); }
+
+ jvmtiError SetEventCallbacks (const jvmtiEventCallbacks *callbacks,
+ jint size_of_callbacks)
+ { return p->SetEventCallbacks (this, callbacks, size_of_callbacks); }
+
+ jvmtiError GenerateEvents (jvmtiEvent event_type)
+ { return p->GenerateEvents (this, event_type); }
+
+ jvmtiError GetExtensionFunctions (jint *extension_count_ptr,
+ jvmtiExtensionFunctionInfo **extensions)
+ { return p->GetExtensionFunctions (this, extension_count_ptr, extensions); }
+
+ jvmtiError GetExtensionEvents (jint *extension_count_ptr,
+ jvmtiExtensionEventInfo **extensions)
+ { return p->GetExtensionEvents (this, extension_count_ptr, extensions); }
+
+ jvmtiError SetExtensionEventCallback (jint extension_event_index,
+ jvmtiExtensionEvent callback)
+ {
+ return p->SetExtensionEventCallback (this, extension_event_index,
+ callback);
+ }
+
+ jvmtiError DisposeEnvironment (void)
+ { return p->DisposeEnvironment (this); }
+
+ jvmtiError GetErrorName (jvmtiError error, char **name_ptr)
+ { return p->GetErrorName (this, error, name_ptr); }
+
+ jvmtiError GetJLocationFormat (jvmtiJlocationFormat *format_ptr)
+ { return p->GetJLocationFormat (this, format_ptr); }
+
+ jvmtiError GetSystemProperties (jint *count_ptr, char ***property_ptr)
+ { return p->GetSystemProperties (this, count_ptr, property_ptr); }
+
+ jvmtiError GetSystemProperty (const char *property, char **value_ptr)
+ { return p->GetSystemProperty (this, property, value_ptr); }
+
+ jvmtiError SetSystemProperty (const char *property, const char *value)
+ { return p->SetSystemProperty (this, property, value); }
+
+ jvmtiError GetPhase (jvmtiPhase *phase_ptr)
+ { return p->GetPhase (this, phase_ptr); }
+
+ jvmtiError GetCurrentThreadCpuTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetCurrentThreadCpuTimerInfo (this, info_ptr); }
+
+ jvmtiError GetCurrentThreadCpuTime (jlong *nanos_ptr)
+ { return p->GetCurrentThreadCpuTime (this, nanos_ptr); }
+
+ jvmtiError GetThreadCpuTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetThreadCpuTimerInfo (this, info_ptr); }
+
+ jvmtiError GetThreadCpuTime (jthread thread, jlong *nanos_ptr)
+ { return p->GetThreadCpuTime (this, thread, nanos_ptr); }
+
+ jvmtiError GetTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetTimerInfo (this, info_ptr); }
+
+ jvmtiError GetTime (jlong *nanos_ptr)
+ {return p->GetTime (this, nanos_ptr); }
+
+ jvmtiError GetPotentialCapabilities (jvmtiCapabilities *capabilities_ptr)
+ { return p->GetPotentialCapabilities (this, capabilities_ptr); }
+
+ jvmtiError AddCapabilities (const jvmtiCapabilities *capabilities_ptr)
+ { return p->AddCapabilities (this, capabilities_ptr); }
+
+ jvmtiError RelinquishCapabilities (const jvmtiCapabilities *capabilities_ptr)
+ { return p->RelinquishCapabilities (this, capabilities_ptr); }
+
+ jvmtiError GetAvailableProcessors (jint *processor_count_ptr)
+ { return p->GetAvailableProcessors (this, processor_count_ptr); }
+
+ jvmtiError GetEnvironmentLocalStorage (void **data_ptr)
+ { return p->GetEnvironmentLocalStorage (this, data_ptr); }
+
+ jvmtiError SetEnvironmentLocalStorage (const void *data)
+ { return p->SetEnvironmentLocalStorage (this, data); }
+
+ jvmtiError AddToBootstrapClassLoaderSearch (const char *segment)
+ { return p->AddToBootstrapClassLoaderSearch (this, segment); }
+
+ jvmtiError SetVerboseFlag (jvmtiVerboseFlag flag, jboolean value)
+ { return p->SetVerboseFlag (this, flag, value); }
+
+ jvmtiError GetObjectSize (jobject object, jlong *size_ptr)
+ { return p->GetObjectSize (this, object, size_ptr); }
+};
+#endif /* __cplusplus */
+
+/*
+ * Miscellaneous flags, constants, etc
+ */
+
+/* Class status flags */
+#define JVMTI_CLASS_STATUS_VERIFIED 1
+#define JVMTI_CLASS_STATUS_PREPARED 2
+#define JVMTI_CLASS_STATUS_INITIALIZED 4
+#define JVMTI_CLASS_STATUS_ERROR 8
+#define JVMTI_CLASS_STATUS_ARRAY 16
+#define JVMTI_CLASS_STATUS_PRIMITIVE 32
+
+/* Thread state flags */
+#define JVMTI_THREAD_STATE_ALIVE 0x0001
+#define JVMTI_THREAD_STATE_TERMINATED 0x0002
+#define JVMTI_THREAD_STATE_RUNNABLE 0x0004
+#define JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER 0x0400
+#define JVMTI_THREAD_STATE_WAITING 0x0080
+#define JVMTI_THREAD_STATE_WAITING_INDEFINITELY 0x0010
+#define JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT 0x0020
+#define JVMTI_THREAD_STATE_SLEEPING 0x0040
+#define JVMTI_THREAD_STATE_IN_OBJECT_WAIT 0x0100
+#define JVMTI_THREAD_STATE_PARKED 0x0200
+#define JVMTI_THREAD_STATE_SUSPENDED 0x100000
+#define JVMTI_THREAD_STATE_INTERRUPTED 0x200000
+#define JVMTI_THREAD_STATE_IN_NATIVE 0x400000
+#define JVMTI_THREAD_STATE_VENDOR_1 0x10000000
+#define JVMTI_THREAD_STATE_VENDOR_2 0x20000000
+#define JVMTI_THREAD_STATE_VENDOR_3 0x40000000
+
+/* java.lang.Thread.State conversion masks */
+#define JVMTI_JAVA_LANG_THREAD_STATE_MASK \
+ (JVMTI_THREAD_STATE_TERMINATED \
+ | JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_RUNNABLE \
+ | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_INDEFINITELY \
+ | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT)
+#define JVMTI_JAVA_LANG_THREAD_STATE_NEW 0
+#define JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED JVMTI_THREAD_STATE_TERMINATED
+#define JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_RUNNABLE)
+#define JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER)
+#define JVMTI_JAVA_LANG_THREAD_STATE_WAITING \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_INDEFINITELY)
+#define JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT)
+
+/* Thread priorities */
+#define JVMTI_THREAD_MIN_PRIORITY 1
+#define JVMTI_THREAD_NORM_PRIORITY 5
+#define JVMTI_THREAD_MAX_PRIORITY 10
+
+/* Keep c-font-lock-extra-types in order: JNI followed by JVMTI,
+ all in alphabetical order */
+/* Local Variables: */
+/* c-font-lock-extra-types: ("\\sw+_t"
+ "JNIEnv" "JNINativeMethod" "JavaVM" "JavaVMOption" "jarray"
+ "jboolean" "jbooleanArray" "jbyte" "jbyteArray" "jchar" "jcharArray"
+ "jclass" "jdouble" "jdoubleArray" "jfieldID" "jfloat" "jfloatArray"
+ "jint" "jintArray" "jlong" "jlongArray" "jmethodID" "jobject" "jstring" "jthrowable"
+ "jvalue" "jweak"
+ "jvmtiEnv" "jvmtiError"
+ "jthread" "jthreadGroup" "jlocation" "jrawMonitorID") */
+/* End: */
+#endif /* !_CLASSPATH_JVMTI_H */
diff --git a/java/awt/BasicStroke.java b/java/awt/BasicStroke.java
index cb8ef49ae..a7e958890 100644
--- a/java/awt/BasicStroke.java
+++ b/java/awt/BasicStroke.java
@@ -43,7 +43,6 @@ import gnu.java.awt.java2d.LineSegment;
import gnu.java.awt.java2d.QuadSegment;
import gnu.java.awt.java2d.Segment;
-import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
diff --git a/java/awt/Canvas.java b/java/awt/Canvas.java
index 2f838d60e..843fded44 100644
--- a/java/awt/Canvas.java
+++ b/java/awt/Canvas.java
@@ -350,9 +350,9 @@ public class Canvas
}
/**
- * Generate a unique name for this canvas.
+ * Generate a unique name for this <code>Canvas</code>.
*
- * @return A unique name for this canvas.
+ * @return A unique name for this <code>Canvas</code>.
*/
String generateName()
{
diff --git a/java/awt/CardLayout.java b/java/awt/CardLayout.java
index 8b3fea2ca..fcb05215a 100644
--- a/java/awt/CardLayout.java
+++ b/java/awt/CardLayout.java
@@ -350,6 +350,7 @@ public class CardLayout implements LayoutManager2, Serializable
}
}
((Component) target).setVisible (true);
+ parent.validate();
}
}
diff --git a/java/awt/CheckboxMenuItem.java b/java/awt/CheckboxMenuItem.java
index e01c9ca9a..c886fc672 100644
--- a/java/awt/CheckboxMenuItem.java
+++ b/java/awt/CheckboxMenuItem.java
@@ -63,6 +63,11 @@ public class CheckboxMenuItem extends MenuItem
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_chkmenuitem_number;
+
// Serialization constant
private static final long serialVersionUID = 6190621106981774043L;
@@ -352,6 +357,21 @@ paramString()
accessibleContext = new AccessibleAWTCheckboxMenuItem();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>CheckboxMenuItem</code>.
+ *
+ * @return A unique name for this <code>CheckboxMenuItem</code>.
+ */
+ String generateName()
+ {
+ return "chkmenuitem" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_chkmenuitem_number++;
+ }
} // class CheckboxMenuItem
diff --git a/java/awt/Choice.java b/java/awt/Choice.java
index 47ca540bd..73aaeb1db 100644
--- a/java/awt/Choice.java
+++ b/java/awt/Choice.java
@@ -63,6 +63,11 @@ public class Choice extends Component
* Static Variables
*/
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_choice_number;
+
// Serialization constant
private static final long serialVersionUID = -4075310674757313071L;
@@ -639,4 +644,19 @@ paramString()
accessibleContext = new AccessibleAWTChoice();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>Choice</code>.
+ *
+ * @return A unique name for this <code>Choice</code>.
+ */
+ String generateName()
+ {
+ return "choice" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_choice_number++;
+ }
} // class Choice
diff --git a/java/awt/Component.java b/java/awt/Component.java
index c778c4921..879d57211 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -214,6 +214,12 @@ public abstract class Component
*/
static final Object treeLock = new String("AWT_TREE_LOCK");
+ /**
+ * The default maximum size.
+ */
+ private static final Dimension DEFAULT_MAX_SIZE
+ = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+
// Serialized fields from the serialization spec.
/**
@@ -588,6 +594,17 @@ public abstract class Component
transient BufferStrategy bufferStrategy;
/**
+ * The number of hierarchy listeners of this container plus all of its
+ * children. This is needed for efficient handling of HierarchyEvents.
+ * These must be propagated to all child components with HierarchyListeners
+ * attached. To avoid traversal of the whole subtree, we keep track of
+ * the number of HierarchyListeners here and only walk the paths that
+ * actually have listeners.
+ */
+ int numHierarchyListeners;
+ int numHierarchyBoundsListeners;
+
+ /**
* true if requestFocus was called on this component when its
* top-level ancestor was not focusable.
*/
@@ -834,9 +851,17 @@ public abstract class Component
*/
public void enable()
{
- this.enabled = true;
- if (peer != null)
- peer.setEnabled (true);
+ if (! enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = true;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.enable();
+ }
+ }
}
/**
@@ -861,9 +886,17 @@ public abstract class Component
*/
public void disable()
{
- this.enabled = false;
- if (peer != null)
- peer.setEnabled (false);
+ if (enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = false;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.disable();
+ }
+ }
}
/**
@@ -928,15 +961,38 @@ public abstract class Component
// and its children.
if(!isVisible())
{
- this.visible = true;
- // Avoid NullPointerExceptions by creating a local reference.
- ComponentPeer currentPeer=peer;
- if (currentPeer != null)
- currentPeer.show();
- // The JDK repaints the component before invalidating the parent.
- // So do we.
- if (isShowing() && isLightweight())
- repaint();
+ // 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;
+ if (currentPeer != null)
+ {
+ currentPeer.show();
+
+ // Fire HierarchyEvent.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (isLightweight())
+ repaint();
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
@@ -944,9 +1000,6 @@ public abstract class Component
if (currentParent != null)
currentParent.invalidate();
- ComponentEvent ce =
- new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
@@ -974,27 +1027,45 @@ public abstract class Component
{
if (isVisible())
{
- // Avoid NullPointerExceptions by creating a local reference.
- ComponentPeer currentPeer=peer;
- if (currentPeer != null)
- currentPeer.setVisible(false);
- boolean wasShowing = isShowing();
- this.visible = false;
-
- // The JDK repaints the component before invalidating the parent.
- // So do we.
- if (wasShowing)
- repaint();
- // Invalidate the parent if we have one. The component itself must
+ // Need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ visible = false;
+
+ // Avoid NullPointerExceptions by creating a local reference.
+ ComponentPeer currentPeer=peer;
+ if (currentPeer != null)
+ {
+ currentPeer.hide();
+
+ // Fire hierarchy event.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+ // The JDK repaints the component before invalidating the
+ // parent. So do we. This only applies for lightweights.
+ if (peer instanceof LightweightPeer)
+ repaint();
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ // Invalidate the parent if we have one. The component itself need
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
currentParent.invalidate();
- ComponentEvent ce =
- new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
@@ -1215,8 +1286,15 @@ public abstract class Component
throw new IllegalComponentStateException("component "
+ getClass().getName()
+ " not showing");
- // We know peer != null here.
- return peer.getLocationOnScreen();
+
+ // Need to lock the tree here. We get crazy races and explosions when
+ // the tree changes while we are trying to find the location of this
+ // component.
+ synchronized (getTreeLock())
+ {
+ // We know peer != null here.
+ return peer.getLocationOnScreen();
+ }
}
/**
@@ -1410,53 +1488,91 @@ public abstract class Component
*/
public void reshape(int x, int y, int width, int height)
{
- int oldx = this.x;
- int oldy = this.y;
- int oldwidth = this.width;
- int oldheight = this.height;
+ // We need to lock the tree here, otherwise we risk races and
+ // inconsistencies.
+ synchronized (getTreeLock())
+ {
+ int oldx = this.x;
+ int oldy = this.y;
+ int oldwidth = this.width;
+ int oldheight = this.height;
- if (this.x == x && this.y == y && this.width == width
- && this.height == height)
- return;
+ if (this.x == x && this.y == y && this.width == width
+ && this.height == height)
+ return;
- invalidate();
+ invalidate();
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- if (peer != null)
- peer.setBounds (x, y, width, height);
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ if (peer != null)
+ peer.setBounds (x, y, width, height);
- // Erase old bounds and repaint new bounds for lightweights.
- if (isLightweight() && isShowing())
- {
- if (parent != null)
+ // Erase old bounds and repaint new bounds for lightweights.
+ if (isLightweight() && isShowing())
{
- Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
- oldheight);
- Rectangle newBounds = new Rectangle(x, y, width, height);
- Rectangle destroyed = oldBounds.union(newBounds);
- if (!destroyed.isEmpty())
- parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
- destroyed.height);
+ if (parent != null)
+ {
+ Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
+ oldheight);
+ Rectangle newBounds = new Rectangle(x, y, width, height);
+ Rectangle destroyed = oldBounds.union(newBounds);
+ if (!destroyed.isEmpty())
+ parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
+ destroyed.height);
+ }
}
- }
- // Only post event if this component is visible and has changed size.
- if (isShowing ()
- && (oldx != x || oldy != y))
- {
- ComponentEvent ce = new ComponentEvent(this,
+ boolean resized = oldwidth != width || oldheight != height;
+ boolean moved = oldx != x || oldy != y;
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ // Fire component event on this component.
+ if (moved)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
ComponentEvent.COMPONENT_MOVED);
- getToolkit().getSystemEventQueue().postEvent(ce);
- }
- if (isShowing ()
- && (oldwidth != width || oldheight != height))
- {
- ComponentEvent ce = new ComponentEvent(this,
- ComponentEvent.COMPONENT_RESIZED);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ if (resized)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_RESIZED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+ else
+ {
+ // Otherwise we might need to notify child components when this is
+ // a Container.
+ if (this instanceof Container)
+ {
+ Container cont = (Container) this;
+ if (resized)
+ {
+ for (int i = 0; i < cont.getComponentCount(); i++)
+ {
+ Component child = cont.getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_RESIZED,
+ this, parent, 0);
+ }
+ }
+ if (moved)
+ {
+ for (int i = 0; i < cont.getComponentCount(); i++)
+ {
+ Component child = cont.getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_MOVED,
+ this, parent, 0);
+ }
+ }
+ }
+ }
}
}
@@ -1660,14 +1776,36 @@ public abstract class Component
*/
public Dimension preferredSize()
{
- if (!prefSizeSet)
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(preferredSizeImpl());
+ }
+
+ /**
+ * The actual calculation is pulled out of preferredSize() so that
+ * we can call it from Container.preferredSize() and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the preferredSize of the component
+ */
+ Dimension preferredSizeImpl()
+ {
+ Dimension size = prefSize;
+ // Try to use a cached value.
+ if (size == null || !(valid || prefSizeSet))
{
- if (peer == null)
- prefSize = minimumSize();
- else
- prefSize = peer.getPreferredSize();
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.preferredSize();
+ else
+ size = minimumSizeImpl();
+ }
}
- return prefSize;
+ return size;
}
/**
@@ -1724,10 +1862,36 @@ public abstract class Component
*/
public Dimension minimumSize()
{
- if (minSize == null)
- minSize = (peer != null ? peer.getMinimumSize()
- : new Dimension(width, height));
- return minSize;
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(minimumSizeImpl());
+ }
+
+ /**
+ * The actual calculation is pulled out of minimumSize() so that
+ * we can call it from Container.preferredSize() and
+ * Component.preferredSizeImpl and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the minimum size of the component
+ */
+ Dimension minimumSizeImpl()
+ {
+ Dimension size = minSize;
+ if (size == null || !(valid || minSizeSet))
+ {
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.minimumSize();
+ else
+ size = size();
+ }
+ }
+ return size;
}
/**
@@ -1741,10 +1905,24 @@ public abstract class Component
*/
public Dimension getMaximumSize()
{
+ return new Dimension(maximumSizeImpl());
+ }
+
+ /**
+ * This is pulled out from getMaximumSize(), so that we can access it
+ * from Container.getMaximumSize() without creating an additional
+ * intermediate Dimension object.
+ *
+ * @return the maximum size of the component
+ */
+ Dimension maximumSizeImpl()
+ {
+ Dimension size;
if (maxSizeSet)
- return maxSize;
+ size = maxSize;
else
- return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+ size = DEFAULT_MAX_SIZE;
+ return size;
}
/**
@@ -1848,11 +2026,25 @@ public abstract class Component
*/
public void invalidate()
{
- valid = false;
- prefSize = null;
- minSize = null;
- if (parent != null && parent.isValid())
- parent.invalidate();
+ // Need to lock here, to avoid races and other ugly stuff when doing
+ // layout or structure changes in other threads.
+ synchronized (getTreeLock())
+ {
+ // Invalidate.
+ valid = false;
+
+ // Throw away cached layout information.
+ if (! minSizeSet)
+ minSize = null;
+ if (! prefSizeSet)
+ prefSize = null;
+ if (! maxSizeSet)
+ maxSize = null;
+
+ // Also invalidate the parent, if it hasn't already been invalidated.
+ if (parent != null && parent.isValid())
+ parent.invalidate();
+ }
}
/**
@@ -2592,6 +2784,14 @@ public abstract class Component
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())
+ {
+ numHierarchyListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK, 1);
+ }
}
/**
@@ -2607,6 +2807,15 @@ public abstract class Component
public synchronized void removeHierarchyListener(HierarchyListener listener)
{
hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, listener);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners--;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -1);
+ }
}
/**
@@ -2642,6 +2851,16 @@ public abstract class Component
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())
+ {
+ numHierarchyBoundsListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ 1);
+ }
}
/**
@@ -2659,6 +2878,16 @@ public abstract class Component
{
hierarchyBoundsListener =
AWTEventMulticaster.remove(hierarchyBoundsListener, listener);
+
+ // 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);
+ }
}
/**
@@ -2677,6 +2906,40 @@ public abstract class Component
}
/**
+ * Fires a HierarchyEvent or HierarchyChangeEvent on this component.
+ *
+ * @param id the event id
+ * @param changed the changed component
+ * @param parent the parent
+ * @param flags the event flags
+ */
+ void fireHierarchyEvent(int id, Component changed, Container parent,
+ long flags)
+ {
+ boolean enabled = false;
+ switch (id)
+ {
+ case HierarchyEvent.HIERARCHY_CHANGED:
+ enabled = hierarchyListener != null
+ || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0;
+ break;
+ case HierarchyEvent.ANCESTOR_MOVED:
+ case HierarchyEvent.ANCESTOR_RESIZED:
+ enabled = hierarchyBoundsListener != null
+ || (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0;
+ break;
+ default:
+ assert false : "Should not reach here";
+ }
+ if (enabled)
+ {
+ HierarchyEvent ev = new HierarchyEvent(this, id, changed, parent,
+ flags);
+ dispatchEvent(ev);
+ }
+ }
+
+ /**
* Adds the specified listener to this component. This is harmless if the
* listener is null, but if the listener has already been registered, it
* will now be registered twice.
@@ -3578,18 +3841,22 @@ public abstract class Component
*/
public void addNotify()
{
- if (peer == null)
- peer = getToolkit().createComponent(this);
- else if (parent != null && parent.isLightweight())
- new HeavyweightInLightweightListener(parent);
- /* Now that all the children has gotten their peers, we should
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ if (peer == null)
+ 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. */
- peer.setEventMask(eventMask);
- /* We do not invalidate here, but rather leave that job up to
+ 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. */
+ }
}
/**
@@ -3603,17 +3870,21 @@ public abstract class Component
*/
public void removeNotify()
{
- // We null our peer field before disposing of it, such that if we're
- // not the event dispatch thread and the dispatch thread is awoken by
- // the dispose call, there will be no race checking the peer's null
- // status.
-
- ComponentPeer tmp = peer;
- peer = null;
- if (tmp != null)
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
{
- tmp.hide();
- tmp.dispose();
+ // We null our peer field before disposing of it, such that if we're
+ // not the event dispatch thread and the dispatch thread is awoken by
+ // the dispose call, there will be no race checking the peer's null
+ // status.
+
+ ComponentPeer tmp = peer;
+ peer = null;
+ if (tmp != null)
+ {
+ tmp.hide();
+ tmp.dispose();
+ }
}
}
diff --git a/java/awt/Container.java b/java/awt/Container.java
index daca76efb..778041150 100644
--- a/java/awt/Container.java
+++ b/java/awt/Container.java
@@ -42,6 +42,7 @@ package java.awt;
import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyEvent;
import java.awt.event.KeyEvent;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
@@ -363,6 +364,16 @@ public class Container extends Component
++ncomponents;
}
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = comp.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ childHierarchyListeners);
+ int childHierarchyBoundsListeners = comp.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ childHierarchyListeners);
+
// Notify the layout manager.
if (layoutMgr != null)
{
@@ -389,6 +400,10 @@ public class Container extends Component
ContainerListener[] listeners = getContainerListeners();
for (int i = 0; i < listeners.length; i++)
listeners[i].componentAdded(ce);
+
+ // Notify hierarchy listeners.
+ comp.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, comp,
+ this, HierarchyEvent.PARENT_CHANGED);
}
}
@@ -413,6 +428,16 @@ public class Container extends Component
ncomponents - index - 1);
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);
+
invalidate();
if (layoutMgr != null)
@@ -424,10 +449,14 @@ public class Container extends Component
{
// Post event to notify of removing the component.
ContainerEvent ce = new ContainerEvent(this,
- ContainerEvent.COMPONENT_REMOVED,
- r);
+ ContainerEvent.COMPONENT_REMOVED,
+ r);
getToolkit().getSystemEventQueue().postEvent(ce);
}
+
+ // Notify hierarchy listeners.
+ r.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r,
+ this, HierarchyEvent.PARENT_CHANGED);
}
}
@@ -574,19 +603,22 @@ public class Container extends Component
*/
void invalidateTree()
{
- super.invalidate(); // Clean cached layout state.
- for (int i = 0; i < ncomponents; i++)
+ synchronized (getTreeLock())
{
- Component comp = component[i];
- comp.invalidate();
- if (comp instanceof Container)
- ((Container) comp).invalidateTree();
- }
+ 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();
+ }
- if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
- {
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- lm2.invalidateLayout(this);
+ if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.invalidateLayout(this);
+ }
}
}
@@ -673,21 +705,25 @@ public class Container extends Component
*/
public Dimension preferredSize()
{
- synchronized(treeLock)
- {
- if(valid && prefSize != null)
- return new Dimension(prefSize);
- LayoutManager layout = getLayout();
- if (layout != null)
+ Dimension size = prefSize;
+ // Try to return cached value if possible.
+ if (size == null || !(prefSizeSet || valid))
+ {
+ // Need to lock here.
+ synchronized (getTreeLock())
{
- Dimension layoutSize = layout.preferredLayoutSize(this);
- if(valid)
- prefSize = layoutSize;
- return new Dimension(layoutSize);
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ prefSize = l.preferredLayoutSize(this);
+ else
+ prefSize = super.preferredSizeImpl();
+ size = prefSize;
}
- else
- return super.preferredSize ();
}
+ if (size != null)
+ return new Dimension(size);
+ else
+ return size;
}
/**
@@ -709,17 +745,25 @@ public class Container extends Component
*/
public Dimension minimumSize()
{
- if(valid && minSize != null)
- return new Dimension(minSize);
-
- LayoutManager layout = getLayout();
- if (layout != null)
+ Dimension size = minSize;
+ // Try to return cached value if possible.
+ if (size == null || !(minSizeSet || valid))
{
- minSize = layout.minimumLayoutSize (this);
- return minSize;
- }
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ minSize = l.minimumLayoutSize(this);
+ else
+ minSize = super.minimumSizeImpl();
+ size = minSize;
+ }
+ }
+ if (size != null)
+ return new Dimension(size);
else
- return super.minimumSize ();
+ return size;
}
/**
@@ -729,18 +773,25 @@ public class Container extends Component
*/
public Dimension getMaximumSize()
{
- if (valid && maxSize != null)
- return new Dimension(maxSize);
-
- LayoutManager layout = getLayout();
- if (layout != null && layout instanceof LayoutManager2)
+ Dimension size = maxSize;
+ // Try to return cached value if possible.
+ if (size == null || !(maxSizeSet || valid))
{
- LayoutManager2 lm2 = (LayoutManager2) layout;
- maxSize = lm2.maximumLayoutSize(this);
- return maxSize;
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l instanceof LayoutManager2)
+ maxSize = ((LayoutManager2) l).maximumLayoutSize(this);
+ else
+ maxSize = super.maximumSizeImpl();
+ size = maxSize;
+ }
}
+ if (size != null)
+ return new Dimension(size);
else
- return super.getMaximumSize();
+ return size;
}
/**
@@ -756,8 +807,11 @@ public class Container extends Component
float alignmentX = 0.0F;
if (layout != null && layout instanceof LayoutManager2)
{
- LayoutManager2 lm2 = (LayoutManager2) layout;
- alignmentX = lm2.getLayoutAlignmentX(this);
+ synchronized (getTreeLock())
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentX = lm2.getLayoutAlignmentX(this);
+ }
}
else
alignmentX = super.getAlignmentX();
@@ -777,8 +831,11 @@ public class Container extends Component
float alignmentY = 0.0F;
if (layout != null && layout instanceof LayoutManager2)
{
- LayoutManager2 lm2 = (LayoutManager2) layout;
- alignmentY = lm2.getLayoutAlignmentY(this);
+ synchronized (getTreeLock())
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentY = lm2.getLayoutAlignmentY(this);
+ }
}
else
alignmentY = super.getAlignmentY();
@@ -1175,8 +1232,11 @@ public class Container extends Component
*/
public void addNotify()
{
- super.addNotify();
- addNotifyContainerChildren();
+ synchronized (getTreeLock())
+ {
+ super.addNotify();
+ addNotifyContainerChildren();
+ }
}
/**
@@ -1659,24 +1719,27 @@ public class Container extends Component
if (comp == this)
throw new IllegalArgumentException("cannot add component to itself");
- // FIXME: Implement reparenting.
- if ( comp.getParent() != this)
- throw new AssertionError("Reparenting is not implemented yet");
- else
+ synchronized (getTreeLock())
{
- // Find current component index.
- int currentIndex = getComponentZOrder(comp);
- if (currentIndex < index)
- {
- System.arraycopy(component, currentIndex + 1, component,
- currentIndex, index - currentIndex);
- }
+ // FIXME: Implement reparenting.
+ if ( comp.getParent() != this)
+ throw new AssertionError("Reparenting is not implemented yet");
else
{
- System.arraycopy(component, index, component, index + 1,
- currentIndex - index);
+ // Find current component index.
+ int currentIndex = getComponentZOrder(comp);
+ if (currentIndex < index)
+ {
+ System.arraycopy(component, currentIndex + 1, component,
+ currentIndex, index - currentIndex);
+ }
+ else
+ {
+ System.arraycopy(component, index, component, index + 1,
+ currentIndex - index);
+ }
+ component[index] = comp;
}
- component[index] = comp;
}
}
@@ -1695,19 +1758,22 @@ public class Container extends Component
*/
public final int getComponentZOrder(Component comp)
{
- int index = -1;
- if (component != null)
+ synchronized (getTreeLock())
{
- for (int i = 0; i < ncomponents; i++)
+ int index = -1;
+ if (component != null)
{
- if (component[i] == comp)
+ for (int i = 0; i < ncomponents; i++)
{
- index = i;
- break;
+ if (component[i] == comp)
+ {
+ index = i;
+ break;
+ }
}
}
+ return index;
}
- return index;
}
// Hidden helper methods.
@@ -1863,6 +1929,48 @@ public class Container extends Component
}
}
+ /**
+ * Fires hierarchy events to the children of this container and this
+ * container itself. This overrides {@link Component#fireHierarchyEvent}
+ * in order to forward this event to all children.
+ */
+ void fireHierarchyEvent(int id, Component changed, Container parent,
+ long flags)
+ {
+ // Only propagate event if there is actually a listener waiting for it.
+ if ((id == HierarchyEvent.HIERARCHY_CHANGED && numHierarchyListeners > 0)
+ || ((id == HierarchyEvent.ANCESTOR_MOVED
+ || id == HierarchyEvent.ANCESTOR_RESIZED)
+ && numHierarchyBoundsListeners > 0))
+ {
+ for (int i = 0; i < ncomponents; i++)
+ component[i].fireHierarchyEvent(id, changed, parent, flags);
+ super.fireHierarchyEvent(id, changed, parent, flags);
+ }
+ }
+
+ /**
+ * Adjusts the number of hierarchy listeners of this container and all of
+ * its parents. This is called by the add/remove listener methods and
+ * structure changing methods in Container.
+ *
+ * @param type the type, either {@link AWTEvent#HIERARCHY_BOUNDS_EVENT_MASK}
+ * or {@link AWTEvent#HIERARCHY_EVENT_MASK}
+ * @param delta the number of listeners added or removed
+ */
+ void updateHierarchyListenerCount(long type, int delta)
+ {
+ if (type == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)
+ numHierarchyBoundsListeners += delta;
+ else if (type == AWTEvent.HIERARCHY_EVENT_MASK)
+ numHierarchyListeners += delta;
+ else
+ assert false : "Should not reach here";
+
+ if (parent != null)
+ parent.updateHierarchyListenerCount(type, delta);
+ }
+
private void addNotifyContainerChildren()
{
synchronized (getTreeLock ())
diff --git a/java/awt/Cursor.java b/java/awt/Cursor.java
index 0ff987cd9..4d339b721 100644
--- a/java/awt/Cursor.java
+++ b/java/awt/Cursor.java
@@ -116,6 +116,16 @@ public class Cursor implements java.io.Serializable
*/
public static final int MOVE_CURSOR = 13;
+ private static String[] NAMES = { "Default Cursor", "Crosshair Cursor",
+ "Text Cursor", "Wait Cursor",
+ "Southwest Resize Cursor",
+ "Southeast Resize Cursor",
+ "Northwest Resize Cursor",
+ "Northeast Resize Cursor",
+ "North Resize Cursor", "South Resize Cursor",
+ "West Resize Cursor", "East Resize Cursor",
+ "Hand Cursor", "Move Cursor" };
+
public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
private static final int PREDEFINED_COUNT = 14;
@@ -142,7 +152,10 @@ public class Cursor implements java.io.Serializable
throw new IllegalArgumentException ("invalid cursor " + type);
this.type = type;
- // FIXME: lookup and set name?
+
+ name = NAMES[type];
+
+ // FIXME: lookup?
}
/** This constructor is used internally only.
diff --git a/java/awt/FlowLayout.java b/java/awt/FlowLayout.java
index 7d0771d91..8c9919528 100644
--- a/java/awt/FlowLayout.java
+++ b/java/awt/FlowLayout.java
@@ -276,26 +276,24 @@ public class FlowLayout implements LayoutManager, Serializable
}
/**
- * Sets the horizontal gap between components to the specified value.
- *
+ * Sets the horizontal gap between lines of components to the specified value.
+ * No Exception is thrown if hgap < 0.
+ *
* @param hgap The new horizontal gap between components.
*/
public void setHgap (int hgap)
{
- if (hgap < 0)
- throw new IllegalArgumentException ("horizontal gap must be nonnegative");
this.hgap = hgap;
}
/**
* Sets the vertical gap between lines of components to the specified value.
+ * No Exception is thrown if vgap < 0.
*
* @param vgap The new vertical gap.
*/
public void setVgap (int vgap)
{
- if (vgap < 0)
- throw new IllegalArgumentException ("vertical gap must be nonnegative");
this.vgap = vgap;
}
diff --git a/java/awt/GridBagLayout.java b/java/awt/GridBagLayout.java
index c8d204396..4853ba908 100644
--- a/java/awt/GridBagLayout.java
+++ b/java/awt/GridBagLayout.java
@@ -1,5 +1,5 @@
/* GridBagLayout - Layout manager for components according to GridBagConstraints
- 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.
@@ -331,117 +331,14 @@ public class GridBagLayout
protected void AdjustForGravity (GridBagConstraints constraints,
Rectangle r)
{
- Rectangle result = new Rectangle (0, 0, 0, 0);
-
- // Calculate width and height.
-
- // Adjust width and height for fill value.
- switch (constraints.fill)
- {
- case GridBagConstraints.NONE:
- result.width = 0;
- result.height = 0;
- break;
- case GridBagConstraints.BOTH:
- result.width = r.width;
- result.height = r.height;
- break;
- case GridBagConstraints.HORIZONTAL:
- result.width = r.width;
- result.height = 0;
- break;
- case GridBagConstraints.VERTICAL:
- result.width = 0;
- result.height = r.height;
- break;
- }
-
- // Adjust width and height for insets, and clamp to minimum
- // values of ipadx and ipady.
- result.width = Math.max(result.width
- - constraints.insets.left
- - constraints.insets.right,
- constraints.ipadx);
- result.height = Math.max(result.height
- - constraints.insets.top
- - constraints.insets.bottom,
- constraints.ipady);
-
- // Calculate x and y.
-
- // Do not account for the internal padding when setting the
- // result rectangle's x and y co-ordinates.
- int rect_width = r.width - constraints.ipadx;
- int rect_height = r.height - constraints.ipady;
-
- int half_width = (rect_width + constraints.insets.left
- - constraints.insets.right) / 2;
- int half_height = (rect_height + constraints.insets.top
- - constraints.insets.bottom) / 2;
-
- // Adjust x and y for anchor value.
- switch (constraints.anchor)
- {
- case GridBagConstraints.CENTER:
- result.x = r.x + half_width;
- result.y = r.y + half_height;
- break;
- case GridBagConstraints.NORTH:
- result.x = r.x + half_width;
- result.y = r.y + constraints.insets.top;
- break;
- case GridBagConstraints.NORTHEAST:
- result.x = r.x + rect_width - constraints.insets.right;
- result.y = r.y + constraints.insets.top;
- break;
- case GridBagConstraints.EAST:
- result.x = r.x + rect_width - constraints.insets.right;
- result.y = r.y + half_height;
- break;
- case GridBagConstraints.SOUTHEAST:
- result.x = r.x + rect_width - constraints.insets.right;
- result.y = r.y + rect_height - constraints.insets.bottom;
- break;
- case GridBagConstraints.SOUTH:
- result.x = r.x + half_width;
- result.y = r.y + rect_height - constraints.insets.bottom;
- break;
- case GridBagConstraints.SOUTHWEST:
- result.x = r.x + constraints.insets.left;
- result.y = r.y + rect_height - constraints.insets.bottom;
- break;
- case GridBagConstraints.WEST:
- result.x = r.x + constraints.insets.left;
- result.y = r.y + half_height;
- break;
- case GridBagConstraints.NORTHWEST:
- result.x = r.x + constraints.insets.left;
- result.y = r.y + constraints.insets.top;
- break;
- }
-
- // Adjust x and y for fill, clamping values to the external
- // padding boundaries where necessary.
- switch (constraints.fill)
- {
- case GridBagConstraints.NONE:
- break;
- case GridBagConstraints.BOTH:
- result.x = r.x + constraints.insets.left;
- result.y = r.y + constraints.insets.top;
- break;
- case GridBagConstraints.HORIZONTAL:
- result.x = r.x + constraints.insets.left;
- break;
- case GridBagConstraints.VERTICAL:
- result.y = r.y + constraints.insets.top;
- break;
- }
-
- r.x = result.x;
- r.y = result.y;
- r.width = result.width;
- r.height = result.height;
+ Insets insets = constraints.insets;
+ if (insets != null)
+ {
+ r.x += insets.left;
+ r.y += insets.top;
+ r.width -= insets.left + insets.right;
+ r.height -= insets.top + insets.bottom;
+ }
}
/**
diff --git a/java/awt/Image.java b/java/awt/Image.java
index 6ade302a1..8a1cc0f00 100644
--- a/java/awt/Image.java
+++ b/java/awt/Image.java
@@ -1,5 +1,5 @@
/* Image.java -- superclass for images
- Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.awt.image.ReplicateScaleFilter;
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @since 1.0
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public abstract class Image
{
@@ -102,6 +102,12 @@ public abstract class Image
public static final int SCALE_AREA_AVERAGING = 16;
/**
+ * The acceleration priority of the image
+ * @since 1.5
+ */
+ protected float accelerationPriority;
+
+ /**
* A default constructor for subclasses.
*/
public Image()
@@ -205,4 +211,32 @@ public abstract class Image
* includes the actual image data.
*/
public abstract void flush();
+
+ /**
+ * Sets the acceleration priority of the image.
+ * This is a value from 0 (lowest) to 1 (highest), which may
+ * be used as a hint for image acceleration.
+ * E.g. higher priority images may be stored in video memory.
+ * @param priority - the priority
+ * @throws IllegalArgumentException if priority is not >= 0 and <= 1.
+ *
+ * @since 1.5
+ */
+ public void setAccelerationPriority(float priority)
+ {
+ if( priority < 0f || priority > 1f)
+ throw new IllegalArgumentException("Invalid priority value.");
+ accelerationPriority = priority;
+ }
+
+ /**
+ * Returns the acceleration priority of the image.
+ *
+ * @see #setAccelerationPriority(float)
+ * @since 1.5
+ */
+ public float getAccelerationPriority()
+ {
+ return accelerationPriority;
+ }
} // class Image
diff --git a/java/awt/List.java b/java/awt/List.java
index 1d703e5a6..ba398dd83 100644
--- a/java/awt/List.java
+++ b/java/awt/List.java
@@ -66,6 +66,11 @@ public class List extends Component
* 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;
@@ -1266,4 +1271,19 @@ paramString()
accessibleContext = new AccessibleAWTList();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>List</code>.
+ *
+ * @return A unique name for this <code>List</code>.
+ */
+ String generateName()
+ {
+ return "list" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_list_number++;
+ }
} // class List
diff --git a/java/awt/Menu.java b/java/awt/Menu.java
index 6daec72cf..f900d9295 100644
--- a/java/awt/Menu.java
+++ b/java/awt/Menu.java
@@ -58,6 +58,11 @@ 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;
@@ -485,5 +490,20 @@ paramString()
accessibleContext = new AccessibleAWTMenu();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>Menu</code>.
+ *
+ * @return A unique name for this <code>Menu</code>.
+ */
+ String generateName()
+ {
+ return "menu" + getUniqueLong();
+ }
+ private static synchronized long getUniqueLong()
+ {
+ return next_menu_number++;
+ }
+
} // class Menu
diff --git a/java/awt/MenuBar.java b/java/awt/MenuBar.java
index 3cf708cd5..6737d0419 100644
--- a/java/awt/MenuBar.java
+++ b/java/awt/MenuBar.java
@@ -60,10 +60,15 @@ public class MenuBar extends MenuComponent
implements MenuContainer, Serializable, Accessible
{
-//Serialization Constant
+ // Serialization Constant
private static final long serialVersionUID = -4930327919388951260L;
/**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menubar_number;
+
+ /**
* @serial The menu used for providing help information
*/
private Menu helpMenu;
@@ -331,6 +336,21 @@ public class MenuBar extends MenuComponent
accessibleContext = new AccessibleAWTMenuBar();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>MenuBar</code>.
+ *
+ * @return A unique name for this <code>MenuBar</code>.
+ */
+ String generateName()
+ {
+ return "menubar" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_menubar_number++;
+ }
/**
* This class provides accessibility support for AWT menu bars.
diff --git a/java/awt/MenuComponent.java b/java/awt/MenuComponent.java
index 9bb875069..163092685 100644
--- a/java/awt/MenuComponent.java
+++ b/java/awt/MenuComponent.java
@@ -200,8 +200,22 @@ public abstract class MenuComponent implements Serializable
*/
public String getName()
{
+ if (name == null && ! nameExplicitlySet)
+ name = generateName();
return name;
}
+
+ /**
+ * Subclasses should override this to return unique component names like
+ * "menuitem0".
+ *
+ * @return the generated name for this menu component
+ */
+ String generateName()
+ {
+ // MenuComponent is abstract.
+ return null;
+ }
/**
* Sets the name of this component to the specified name.
diff --git a/java/awt/MenuItem.java b/java/awt/MenuItem.java
index 075ff75a8..b80ee4c1a 100644
--- a/java/awt/MenuItem.java
+++ b/java/awt/MenuItem.java
@@ -63,9 +63,15 @@ public class MenuItem extends MenuComponent
/*
* Static Variables
*/
+
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menuitem_number;
-// Serialization Constant
-private static final long serialVersionUID = -21757335363267194L;
+ // Serialization Constant
+ private static final long serialVersionUID = - 21757335363267194L;
/*************************************************************************/
@@ -599,4 +605,19 @@ public AccessibleContext getAccessibleContext()
return accessibleContext;
}
+/**
+ * Generate a unique name for this <code>MenuItem</code>.
+ *
+ * @return A unique name for this <code>MenuItem</code>.
+ */
+String generateName()
+{
+ return "menuitem" + getUniqueLong();
+}
+
+private static synchronized long getUniqueLong()
+{
+ return next_menuitem_number++;
+}
+
} // class MenuItem
diff --git a/java/awt/MouseInfo.java b/java/awt/MouseInfo.java
new file mode 100644
index 000000000..957b6bccb
--- /dev/null
+++ b/java/awt/MouseInfo.java
@@ -0,0 +1,95 @@
+/* MouseInfo.java -- utility methods for mice.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt;
+
+import gnu.java.awt.ClasspathToolkit;
+import java.awt.peer.MouseInfoPeer;
+
+/**
+ * MouseInfo is a class containing utility functions for mouse information.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public class MouseInfo
+{
+ private static MouseInfoPeer peer;
+
+ /**
+ * Returns a PointerInfo object containing information about the current
+ * location of the mouse pointer
+ *
+ * @throws HeadlessException if the current GraphicsEnvironment is headless.
+ * @return a PointerInfo object.
+ */
+ public static PointerInfo getPointerInfo() throws HeadlessException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission( new AWTPermission("watchMousePointer") );
+
+ if( GraphicsEnvironment.isHeadless() )
+ throw new HeadlessException();
+
+ if( peer == null )
+ peer = Toolkit.getDefaultToolkit().getMouseInfoPeer();
+
+ Point p = new Point();
+ int screen = peer.fillPointWithCoords( p );
+
+ GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getScreenDevices();
+
+ return new PointerInfo( gds[ screen ], p );
+ }
+
+ /**
+ * Returns the number of mouse buttons, or -1 if no mouse is connected.
+ * (mentioned in the 1.5 release notes)
+ *
+ * @throws HeadlessException if the current GraphicsEnvironment is headless.
+ * @return an integer number of buttons.
+ */
+ public static int getNumberOfButtons() throws HeadlessException
+ {
+ if( GraphicsEnvironment.isHeadless() )
+ throw new HeadlessException();
+ return ((ClasspathToolkit)Toolkit.getDefaultToolkit()).
+ getMouseNumberOfButtons();
+ }
+}
diff --git a/java/awt/PointerInfo.java b/java/awt/PointerInfo.java
new file mode 100644
index 000000000..14d44a69b
--- /dev/null
+++ b/java/awt/PointerInfo.java
@@ -0,0 +1,84 @@
+/* PointerInfo.java -- mouse pointer data
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt;
+
+/**
+ * PointerInfo represents information about the mouse pointer,
+ * i.e. its GraphicsDevice and location.
+ *
+ * PointerInfo objects cannot be instantiated directly, but are
+ * retrieved from MouseInfo.getPointerInfo(). PointerInfo objects
+ * are immutable and will not be updated for future mouse motions.
+ *
+ * @since 1.5
+ * @author Sven de Marothy
+ */
+public class PointerInfo
+{
+ private GraphicsDevice gd;
+ private Point p;
+
+ /**
+ * Package-private constructor used by MouseInfo.
+ */
+ PointerInfo( GraphicsDevice gd, Point p )
+ {
+ this.gd = gd;
+ this.p = p;
+ }
+
+ /**
+ * Returns the GraphicsDevice on which the mouse pointer was located
+ *
+ * @return a GraphicsDevice object.
+ */
+ public GraphicsDevice getDevice()
+ {
+ return gd;
+ }
+
+ /**
+ * Returns the coordinates of the mouse pointer.
+ *
+ * @return a Point object containing the pointer coordinates.
+ */
+ public Point getLocation()
+ {
+ return p;
+ }
+}
diff --git a/java/awt/PopupMenu.java b/java/awt/PopupMenu.java
index 540fffda7..926867802 100644
--- a/java/awt/PopupMenu.java
+++ b/java/awt/PopupMenu.java
@@ -55,8 +55,13 @@ public class PopupMenu extends Menu
* Static Variables
*/
-// Serialization Constant
-private static final long serialVersionUID = -4620452533522760060L;
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_popup_number;
+
+ // Serialization Constant
+ private static final long serialVersionUID = - 4620452533522760060L;
/*************************************************************************/
@@ -166,6 +171,21 @@ show(Component component, int x, int y)
accessibleContext = new AccessibleAWTPopupMenu();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>PopupMenu</code>.
+ *
+ * @return A unique name for this <code>PopupMenu</code>.
+ */
+ String generateName()
+ {
+ return "popup" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_popup_number++;
+ }
} // class PopupMenu
diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java
index 525d9d3e7..65ce484b8 100644
--- a/java/awt/ScrollPane.java
+++ b/java/awt/ScrollPane.java
@@ -46,6 +46,7 @@ import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
+
/**
* This widget provides a scrollable region that allows a single
* subcomponent to be viewed through a smaller window.
@@ -76,6 +77,11 @@ public static final int SCROLLBARS_ALWAYS = 1;
*/
public static final int SCROLLBARS_NEVER = 2;
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_scrollpane_number;
+
// Serialization constant
private static final long serialVersionUID = 7956609840827222915L;
@@ -221,7 +227,7 @@ getVAdjustable()
* @return The viewport size.
*/
public Dimension getViewportSize ()
-{
+{
Dimension viewsize = getSize ();
Insets insets = getInsets ();
@@ -231,9 +237,9 @@ public Dimension getViewportSize ()
Component[] list = getComponents();
if ((list == null) || (list.length <= 0))
return viewsize;
-
+
Dimension dim = list[0].getPreferredSize();
-
+
if (dim.width <= 0 && dim.height <= 0)
return viewsize;
@@ -276,7 +282,7 @@ public Dimension getViewportSize ()
needHorizontal = true;
else if (dim.width > (viewsize.width - vScrollbarWidth))
mayNeedHorizontal = true;
-
+
if (needVertical && mayNeedHorizontal)
needHorizontal = true;
@@ -288,7 +294,7 @@ public Dimension getViewportSize ()
if (needVertical)
viewsize.width -= vScrollbarWidth;
-
+
return viewsize;
}
@@ -613,5 +619,21 @@ paramString()
accessibleContext = new AccessibleAWTScrollPane();
return accessibleContext;
}
+
+ /**
+ * Generate a unique name for this <code>ScrollPane</code>.
+ *
+ * @return A unique name for this <code>ScrollPane</code>.
+ */
+ String generateName()
+ {
+ return "scrollpane" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_scrollpane_number++;
+ }
+
} // class ScrollPane
diff --git a/java/awt/TextField.java b/java/awt/TextField.java
index 17e9c1f4a..2aff0ca64 100644
--- a/java/awt/TextField.java
+++ b/java/awt/TextField.java
@@ -54,7 +54,13 @@ import javax.accessibility.AccessibleStateSet;
*/
public class TextField extends TextComponent
{
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_textfield_number;
+
private static final long serialVersionUID = -2966288784432217853L;
@@ -434,6 +440,21 @@ public class TextField extends TextComponent
{
return (ActionListener[]) getListeners (ActionListener.class);
}
+
+ /**
+ * Generate a unique name for this <code>TextField</code>.
+ *
+ * @return A unique name for this <code>TextField</code>.
+ */
+ String generateName()
+ {
+ return "textfield" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_textfield_number++;
+ }
protected class AccessibleAWTTextField extends AccessibleAWTTextComponent
{
diff --git a/java/awt/Toolkit.java b/java/awt/Toolkit.java
index e2db04837..b5ab39b5f 100644
--- a/java/awt/Toolkit.java
+++ b/java/awt/Toolkit.java
@@ -71,6 +71,7 @@ import java.awt.peer.ListPeer;
import java.awt.peer.MenuBarPeer;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuPeer;
+import java.awt.peer.MouseInfoPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.PopupMenuPeer;
import java.awt.peer.ScrollPanePeer;
@@ -335,6 +336,18 @@ public abstract class Toolkit
protected abstract MenuItemPeer createMenuItem(MenuItem target);
/**
+ * Returns a MouseInfoPeer.
+ * The default implementation of this method throws
+ * UnsupportedOperationException.
+ *
+ * Toolkit implementations should overload this if possible, however.
+ */
+ protected MouseInfoPeer getMouseInfoPeer()
+ {
+ throw new UnsupportedOperationException("No mouse info peer.");
+ }
+
+ /**
* Creates a peer object for the specified <code>FileDialog</code>.
*
* @param target The <code>FileDialog</code> to create the peer for.
diff --git a/java/awt/Window.java b/java/awt/Window.java
index b9661f1de..10b8c0d12 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -80,6 +80,8 @@ public class Window extends Container implements Accessible
private int state = 0;
/** @since 1.4 */
private boolean focusableWindowState = true;
+ /** @since 1.5 */
+ private boolean alwaysOnTop = false;
// A list of other top-level windows owned by this window.
private transient Vector ownedWindows = new Vector();
@@ -426,13 +428,17 @@ public class Window extends Container implements Accessible
/**
* Sends this window to the back so that all other windows display in
* front of it.
+ *
+ * If the window is set to be always-on-top, this will remove its
+ * always-on-top status.
*/
public void toBack()
{
if (peer != null)
{
- WindowPeer wp = (WindowPeer) peer;
- wp.toBack();
+ if( alwaysOnTop )
+ setAlwaysOnTop( false );
+ ( (WindowPeer) peer ).toBack();
}
}
@@ -443,10 +449,7 @@ public class Window extends Container implements Accessible
public void toFront()
{
if (peer != null)
- {
- WindowPeer wp = (WindowPeer) peer;
- wp.toFront();
- }
+ ( (WindowPeer) peer ).toFront();
}
/**
@@ -1242,6 +1245,55 @@ public class Window extends Container implements Accessible
}
/**
+ * Returns whether the Windows is an always-on-top window,
+ * meaning whether the window can be obscured by other windows or not.
+ *
+ * @return <code>true</code> if the windows is always-on-top,
+ * <code>false</code> otherwise.
+ * @since 1.5
+ */
+ public final boolean isAlwaysOnTop()
+ {
+ return alwaysOnTop;
+ }
+
+ /**
+ * Sets the always-on-top state of this window (if supported).
+ *
+ * Setting a window to always-on-top means it will not be obscured
+ * by any other windows (with the exception of other always-on-top
+ * windows). Not all platforms may support this.
+ *
+ * If an window's always-on-top status is changed to false, the window
+ * will remain at the front but not be anchored there.
+ *
+ * Calling toBack() on an always-on-top window will change its
+ * always-on-top status to false.
+ *
+ * @since 1.5
+ */
+ public final void setAlwaysOnTop(boolean alwaysOnTop)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission( new AWTPermission("setWindowAlwaysOnTop") );
+
+ if( this.alwaysOnTop == alwaysOnTop )
+ return;
+
+ if( alwaysOnTop )
+ toFront();
+
+ firePropertyChange("alwaysOnTop", this.alwaysOnTop, alwaysOnTop );
+ this.alwaysOnTop = alwaysOnTop;
+
+ if (peer != null)
+ ( (WindowPeer) peer).updateAlwaysOnTop();
+ else
+ System.out.println("Null peer?!");
+ }
+
+ /**
* Generate a unique name for this window.
*
* @return A unique name for this window.
diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java
index 9b85d7003..435e21f30 100644
--- a/java/awt/font/TextLayout.java
+++ b/java/awt/font/TextLayout.java
@@ -666,8 +666,9 @@ public final class TextLayout implements Cloneable
}
public TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds)
+ throws NotImplementedException
{
- return hitTestChar( x, y, getBounds() );
+ throw new Error ("not implemented");
}
public boolean isLeftToRight ()
diff --git a/java/awt/font/TextMeasurer.java b/java/awt/font/TextMeasurer.java
index e91c7ef16..00cab8a87 100644
--- a/java/awt/font/TextMeasurer.java
+++ b/java/awt/font/TextMeasurer.java
@@ -128,6 +128,8 @@ public final class TextMeasurer implements Cloneable
*/
public TextLayout getLayout (int start, int limit)
{
+ if( start >= limit )
+ throw new IllegalArgumentException("Start position must be < limit.");
return new TextLayout( totalLayout, start, limit );
}
diff --git a/java/awt/image/BandedSampleModel.java b/java/awt/image/BandedSampleModel.java
index 24d315a1c..ed6abcf4f 100644
--- a/java/awt/image/BandedSampleModel.java
+++ b/java/awt/image/BandedSampleModel.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, Free Software Foundation
+/* Copyright (C) 2004, 2005, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -37,9 +37,8 @@ exception statement from your version. */
package java.awt.image;
/**
- * MultiPixelPackedSampleModel provides a single band model that supports
- * multiple pixels in a single unit. Pixels have 2^n bits and 2^k pixels fit
- * per data element.
+ * A sample model that reads each sample value from a separate band in the
+ * {@link DataBuffer}.
*
* @author Jerry Quinn (jlquinn@optonline.net)
*/
@@ -61,17 +60,45 @@ public final class BandedSampleModel extends ComponentSampleModel
return result;
}
+ /**
+ * Creates a new <code>BandedSampleModel</code>.
+ *
+ * @param dataType the data buffer type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param numBands the number of bands.
+ */
public BandedSampleModel(int dataType, int w, int h, int numBands)
{
this(dataType, w, h, w, createBankArray(numBands), new int[numBands]);
}
+ /**
+ * Creates a new <code>BandedSampleModel</code>.
+ *
+ * @param dataType the data buffer type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param scanlineStride the number of data elements from a pixel in one
+ * row to the corresponding pixel in the next row.
+ * @param bankIndices the bank indices.
+ * @param bandOffsets the band offsets.
+ */
public BandedSampleModel(int dataType, int w, int h, int scanlineStride,
int[] bankIndices, int[] bandOffsets)
{
super(dataType, w, h, 1, scanlineStride, bankIndices, bandOffsets);
}
+ /**
+ * Creates a new <code>SampleModel</code> that is compatible with this
+ * model and has the specified width and height.
+ *
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ *
+ * @return The new sample model.
+ */
public SampleModel createCompatibleSampleModel(int w, int h)
{
// NOTE: blackdown 1.4.1 sets all offsets to 0. Sun's 1.4.2 docs
@@ -80,12 +107,12 @@ public final class BandedSampleModel extends ComponentSampleModel
// Compress offsets so minimum is 0, others w*scanlineStride
int[] newoffsets = new int[bandOffsets.length];
int[] order = new int[bandOffsets.length];
- for (int i=0; i < bandOffsets.length; i++)
+ for (int i = 0; i < bandOffsets.length; i++)
order[i] = i;
// FIXME: This is N^2, but not a big issue, unless there's a lot of
// bands...
- for (int i=0; i < bandOffsets.length; i++)
- for (int j=i+1; j < bandOffsets.length; i++)
+ for (int i = 0; i < bandOffsets.length; i++)
+ for (int j = i + 1; j < bandOffsets.length; i++)
if (bankIndices[order[i]] > bankIndices[order[j]]
|| (bankIndices[order[i]] == bankIndices[order[j]]
&& bandOffsets[order[i]] > bandOffsets[order[j]]))
@@ -94,7 +121,7 @@ public final class BandedSampleModel extends ComponentSampleModel
}
int bank = 0;
int offset = 0;
- for (int i=0; i < bandOffsets.length; i++)
+ for (int i = 0; i < bandOffsets.length; i++)
{
if (bankIndices[order[i]] != bank)
{
@@ -105,7 +132,8 @@ public final class BandedSampleModel extends ComponentSampleModel
offset += w * scanlineStride;
}
- return new BandedSampleModel(dataType, w, h, scanlineStride, bankIndices, newoffsets);
+ return new BandedSampleModel(dataType, w, h, scanlineStride, bankIndices,
+ newoffsets);
}
@@ -117,7 +145,7 @@ public final class BandedSampleModel extends ComponentSampleModel
+" many bands");
int[] newoff = new int[bands.length];
int[] newbanks = new int[bands.length];
- for (int i=0; i < bands.length; i++)
+ for (int i = 0; i < bands.length; i++)
{
int b = bands[i];
newoff[i] = bandOffsets[b];
@@ -134,57 +162,61 @@ public final class BandedSampleModel extends ComponentSampleModel
* Extracts the pixel at x, y from data and stores samples into the array
* obj. If obj is null, a new array of getTransferType() is created.
*
- * @param x The x-coordinate of the pixel rectangle to store in <code>obj</code>.
- * @param y The y-coordinate of the pixel rectangle to store in <code>obj</code>.
- * @param obj The primitive array to store the pixels into or null to force creation.
+ * @param x The x-coordinate of the pixel rectangle to store in
+ * <code>obj</code>.
+ * @param y The y-coordinate of the pixel rectangle to store in
+ * <code>obj</code>.
+ * @param obj The primitive array to store the pixels into or null to force
+ * creation.
* @param data The DataBuffer that is the source of the pixel data.
* @return The primitive array containing the pixel data.
- * @see java.awt.image.SampleModel#getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)
+ * @see java.awt.image.SampleModel#getDataElements(int, int,
+ * java.lang.Object, java.awt.image.DataBuffer)
*/
- public Object getDataElements(int x, int y, Object obj,
- DataBuffer data)
+ public Object getDataElements(int x, int y, Object obj, DataBuffer data)
{
int pixel = getSample(x, y, 0, data);
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
{
- byte[] b = (byte[])obj;
+ byte[] b = (byte[]) obj;
if (b == null) b = new byte[numBands];
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
b[i] = (byte)getSample(x, y, i, data);
return b;
}
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_USHORT:
{
- short[] b = (short[])obj;
+ short[] b = (short[]) obj;
if (b == null) b = new short[numBands];
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
b[i] = (short)getSample(x, y, i, data);
return b;
}
case DataBuffer.TYPE_INT:
{
- int[] b = (int[])obj;
+ int[] b = (int[]) obj;
if (b == null) b = new int[numBands];
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
b[i] = getSample(x, y, i, data);
return b;
}
case DataBuffer.TYPE_FLOAT:
{
- float[] b = (float[])obj;
+ float[] b = (float[]) obj;
if (b == null) b = new float[numBands];
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
b[i] = getSampleFloat(x, y, i, data);
return b;
}
case DataBuffer.TYPE_DOUBLE:
{
- double[] b = (double[])obj;
- if (b == null) b = new double[numBands];
- for (int i=0; i < numBands; i++)
+ double[] b = (double[]) obj;
+ if (b == null)
+ b = new double[numBands];
+ for (int i = 0; i < numBands; i++)
b[i] = getSample(x, y, i, data);
return b;
}
@@ -195,10 +227,27 @@ public final class BandedSampleModel extends ComponentSampleModel
}
}
+ /**
+ * Returns all the samples for the pixel at location <code>(x, y)</code>
+ * stored in the specified data buffer.
+ *
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param iArray an array that will be populated with the sample values and
+ * returned as the result. The size of this array should be equal to the
+ * number of bands in the model. If the array is <code>null</code>, a new
+ * array is created.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The samples for the specified pixel.
+ *
+ * @see #setPixel(int, int, int[], DataBuffer)
+ */
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
- if (iArray == null) iArray = new int[numBands];
- for (int i=0; i < numBands; i++)
+ if (iArray == null)
+ iArray = new int[numBands];
+ for (int i = 0; i < numBands; i++)
iArray[i] = getSample(x, y, i, data);
return iArray;
@@ -228,7 +277,8 @@ public final class BandedSampleModel extends ComponentSampleModel
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
- if (iArray == null) iArray = new int[w*h*numBands];
+ if (iArray == null)
+ iArray = new int[w * h * numBands];
int outOffset = 0;
int maxX = x + w;
int maxY = y + h;
@@ -247,18 +297,64 @@ public final class BandedSampleModel extends ComponentSampleModel
return iArray;
}
+ /**
+ * Returns a sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int getSample(int x, int y, int b, DataBuffer data)
{
int offset = bandOffsets[b] + y * scanlineStride + x;
return data.getElem(bankIndices[b], offset);
}
+ /**
+ * Returns a sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ *
+ * @see #getSample(int, int, int, DataBuffer)
+ */
public float getSampleFloat(int x, int y, int b, DataBuffer data)
{
int offset = bandOffsets[b] + y * scanlineStride + x;
return data.getElemFloat(bankIndices[b], offset);
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ *
+ * @see #getSample(int, int, int, DataBuffer)
+ */
public double getSampleDouble(int x, int y, int b, DataBuffer data)
{
int offset = bandOffsets[b] + y * scanlineStride + x;
@@ -288,7 +384,8 @@ public final class BandedSampleModel extends ComponentSampleModel
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray,
DataBuffer data)
{
- if (iArray == null) iArray = new int[w*h];
+ if (iArray == null)
+ iArray = new int[w * h];
int outOffset = 0;
int maxX = x + w;
int maxY = y + h;
@@ -304,7 +401,6 @@ public final class BandedSampleModel extends ComponentSampleModel
return iArray;
}
-
/**
* Set the pixel at x, y to the value in the first element of the primitive
* array obj.
@@ -338,7 +434,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferByte out = (DataBufferByte) data;
byte[] in = (byte[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -346,7 +442,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferShort out = (DataBufferShort) data;
short[] in = (short[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -354,7 +450,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferUShort out = (DataBufferUShort) data;
short[] in = (short[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -362,7 +458,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferInt out = (DataBufferInt) data;
int[] in = (int[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -370,7 +466,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferFloat out = (DataBufferFloat) data;
float[] in = (float[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -378,7 +474,7 @@ public final class BandedSampleModel extends ComponentSampleModel
{
DataBufferDouble out = (DataBufferDouble) data;
double[] in = (double[]) obj;
- for (int i=0; i < numBands; i++)
+ for (int i = 0; i < numBands; i++)
out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[i];
return;
}
@@ -388,26 +484,54 @@ public final class BandedSampleModel extends ComponentSampleModel
}
catch (ArrayIndexOutOfBoundsException aioobe)
{
- String msg = "While writing data elements" +
- ", x="+x+", y="+y+
- ", width="+width+", height="+height+
- ", scanlineStride="+scanlineStride+
- ", offset="+offset+
- ", data.getSize()="+data.getSize()+
- ", data.getOffset()="+data.getOffset()+
- ": " +
- aioobe;
+ String msg = "While writing data elements"
+ + ", x=" + x + ", y=" + y
+ + ", width=" + width + ", height=" + height
+ + ", scanlineStride=" + scanlineStride
+ + ", offset=" + offset
+ + ", data.getSize()=" + data.getSize()
+ + ", data.getOffset()=" + data.getOffset()
+ + ": " + aioobe;
throw new ArrayIndexOutOfBoundsException(msg);
}
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the specified data buffer to
+ * the specified values.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
- for (int b=0; b < numBands; b++)
+ for (int b = 0; b < numBands; b++)
data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x,
iArray[b]);
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param iArray the pixel sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
@@ -417,7 +541,7 @@ public final class BandedSampleModel extends ComponentSampleModel
for (int ww = 0; ww < w; ww++)
{
int offset = y * scanlineStride + (x + ww);
- for (int b=0; b < numBands; b++)
+ for (int b = 0; b < numBands; b++)
data.setElem(bankIndices[b], bandOffsets[b] + offset,
iArray[inOffset++]);
}
@@ -425,21 +549,77 @@ public final class BandedSampleModel extends ComponentSampleModel
}
}
+ /**
+ * Sets the sample value for band <code>b</code> of the pixel at location
+ * <code>(x, y)</code> in the specified data buffer.
+ *
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param b the band index.
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @see #getSample(int, int, int, DataBuffer)
+ */
public void setSample(int x, int y, int b, int s, DataBuffer data)
{
data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, float s, DataBuffer data)
{
- data.setElemFloat(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s);
+ data.setElemFloat(bankIndices[b], bandOffsets[b] + y * scanlineStride + x,
+ s);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, double s, DataBuffer data)
{
- data.setElemDouble(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s);
+ data.setElemDouble(bankIndices[b], bandOffsets[b] + y * scanlineStride + x,
+ s);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer.
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param iArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b, int[] iArray,
DataBuffer data)
{
@@ -537,9 +717,10 @@ public final class BandedSampleModel extends ComponentSampleModel
result.append(getClass().getName());
result.append("[");
result.append("scanlineStride=").append(scanlineStride);
- for(int i=0; i < bitMasks.length; i+=1)
+ for(int i = 0; i < bitMasks.length; i+=1)
{
- result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i]));
+ result.append(", mask[").append(i).append("]=0x").append(
+ Integer.toHexString(bitMasks[i]));
}
result.append("]");
diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java
index 6026e7898..c6de10fa4 100644
--- a/java/awt/image/BufferedImage.java
+++ b/java/awt/image/BufferedImage.java
@@ -100,11 +100,33 @@ public class BufferedImage extends Image
Vector observers;
/**
- * Creates a new buffered image.
+ * Creates a new <code>BufferedImage</code> with the specified width, height
+ * and type. Valid <code>type</code> values are:
*
- * @param w the width.
- * @param h the height.
- * @param type the image type (see the constants defined by this class).
+ * <ul>
+ * <li>{@link #TYPE_INT_RGB}</li>
+ * <li>{@link #TYPE_INT_ARGB}</li>
+ * <li>{@link #TYPE_INT_ARGB_PRE}</li>
+ * <li>{@link #TYPE_INT_BGR}</li>
+ * <li>{@link #TYPE_3BYTE_BGR}</li>
+ * <li>{@link #TYPE_4BYTE_ABGR}</li>
+ * <li>{@link #TYPE_4BYTE_ABGR_PRE}</li>
+ * <li>{@link #TYPE_USHORT_565_RGB}</li>
+ * <li>{@link #TYPE_USHORT_555_RGB}</li>
+ * <li>{@link #TYPE_BYTE_GRAY}</li>
+ * <li>{@link #TYPE_USHORT_GRAY}</li>
+ * <li>{@link #TYPE_BYTE_BINARY}</li>
+ * <li>{@link #TYPE_BYTE_INDEXED}</li>
+ * </ul>
+ *
+ * @param w the width (must be > 0).
+ * @param h the height (must be > 0).
+ * @param type the image type (see the list of valid types above).
+ *
+ * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is
+ * less than or equal to zero.
+ * @throws IllegalArgumentException if <code>type</code> is not one of the
+ * specified values.
*/
public BufferedImage(int w, int h, int type)
{
@@ -181,13 +203,15 @@ public class BufferedImage extends Image
case TYPE_4BYTE_ABGR_PRE:
bits = bits4;
break;
- case TYPE_BYTE_GRAY:
- bits = bits1byte;
- break;
- case TYPE_USHORT_GRAY:
- bits = bits1ushort;
- dataType = DataBuffer.TYPE_USHORT;
- break;
+ case TYPE_BYTE_GRAY:
+ bits = bits1byte;
+ cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ break;
+ case TYPE_USHORT_GRAY:
+ bits = bits1ushort;
+ cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ dataType = DataBuffer.TYPE_USHORT;
+ break;
}
cm = new ComponentColorModel(cs, bits, alpha, premultiplied,
alpha ?
@@ -203,6 +227,8 @@ public class BufferedImage extends Image
String msg2 = "type not implemented yet";
throw new UnsupportedOperationException(msg2);
// FIXME: build color-cube and create color model
+ default:
+ throw new IllegalArgumentException("Unknown image type " + type);
}
init(cm,
diff --git a/java/awt/image/DataBuffer.java b/java/awt/image/DataBuffer.java
index 9e4f71418..5a2cfd3b0 100644
--- a/java/awt/image/DataBuffer.java
+++ b/java/awt/image/DataBuffer.java
@@ -114,8 +114,7 @@ public abstract class DataBuffer
*/
protected DataBuffer(int dataType, int size)
{
- this.dataType = dataType;
- this.size = size;
+ this(dataType, size, 1);
}
/**
@@ -132,9 +131,7 @@ public abstract class DataBuffer
* @param numBanks the number of data banks.
*/
protected DataBuffer(int dataType, int size, int numBanks) {
- this(dataType, size);
- banks = numBanks;
- offsets = new int[numBanks];
+ this(dataType, size, numBanks, 0);
}
/**
@@ -153,11 +150,14 @@ public abstract class DataBuffer
* @param offset the offset to the first element for all banks.
*/
protected DataBuffer(int dataType, int size, int numBanks, int offset) {
- this(dataType, size, numBanks);
-
- java.util.Arrays.fill(offsets, offset);
-
+ banks = numBanks;
+ this.dataType = dataType;
+ this.size = size;
this.offset = offset;
+
+ offsets = new int[ numBanks ];
+ for(int i = 0; i < numBanks; i++ )
+ offsets[i] = offset;
}
/**
@@ -179,10 +179,11 @@ public abstract class DataBuffer
* <code>numBanks != offsets.length</code>.
*/
protected DataBuffer(int dataType, int size, int numBanks, int[] offsets) {
- this(dataType, size);
if (numBanks != offsets.length)
throw new ArrayIndexOutOfBoundsException();
-
+
+ this.dataType = dataType;
+ this.size = size;
banks = numBanks;
this.offsets = offsets;
diff --git a/java/awt/image/MultiPixelPackedSampleModel.java b/java/awt/image/MultiPixelPackedSampleModel.java
index 18a6e5552..ddd38208d 100644
--- a/java/awt/image/MultiPixelPackedSampleModel.java
+++ b/java/awt/image/MultiPixelPackedSampleModel.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.
@@ -56,12 +56,43 @@ public class MultiPixelPackedSampleModel extends SampleModel
private int numberOfBits;
private int numElems;
+ /**
+ * Creates a new <code>MultiPixelPackedSampleModel</code> with the specified
+ * data type, which should be one of:
+ * <ul>
+ * <li>{@link DataBuffer#TYPE_BYTE};</li>
+ * <li>{@link DataBuffer#TYPE_USHORT};</li>
+ * <li>{@link DataBuffer#TYPE_INT};</li>
+ * </ul>
+ *
+ * @param dataType the data type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param numberOfBits the number of bits per pixel (must be a power of 2).
+ */
public MultiPixelPackedSampleModel(int dataType, int w, int h,
int numberOfBits)
{
this(dataType, w, h, numberOfBits, 0, 0);
}
+ /**
+ * Creates a new <code>MultiPixelPackedSampleModel</code> with the specified
+ * data type, which should be one of:
+ * <ul>
+ * <li>{@link DataBuffer#TYPE_BYTE};</li>
+ * <li>{@link DataBuffer#TYPE_USHORT};</li>
+ * <li>{@link DataBuffer#TYPE_INT};</li>
+ * </ul>
+ *
+ * @param dataType the data type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param numberOfBits the number of bits per pixel (must be a power of 2).
+ * @param scanlineStride the number of data elements from a pixel on one
+ * row to the corresponding pixel in the next row.
+ * @param dataBitOffset the offset to the first data bit.
+ */
public MultiPixelPackedSampleModel(int dataType, int w, int h,
int numberOfBits, int scanlineStride,
int dataBitOffset)
@@ -101,7 +132,7 @@ public class MultiPixelPackedSampleModel extends SampleModel
// Compute scan line large enough for w pixels.
if (scanlineStride == 0)
- scanlineStride = ((dataBitOffset + w * numberOfBits) / elemBits);
+ scanlineStride = ((dataBitOffset + w * numberOfBits) - 1) / elemBits + 1;
this.scanlineStride = scanlineStride;
@@ -118,6 +149,16 @@ public class MultiPixelPackedSampleModel extends SampleModel
}
}
+ /**
+ * Creates a new <code>MultiPixelPackedSample</code> model with the same
+ * data type and bits per pixel as this model, but with the specified
+ * dimensions.
+ *
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ *
+ * @return The new sample model.
+ */
public SampleModel createCompatibleSampleModel(int w, int h)
{
/* FIXME: We can avoid recalculation of bit offsets and sample
@@ -126,78 +167,161 @@ public class MultiPixelPackedSampleModel extends SampleModel
return new MultiPixelPackedSampleModel(dataType, w, h, numberOfBits);
}
-
/**
* Creates a DataBuffer for holding pixel data in the format and
* layout described by this SampleModel. The returned buffer will
* consist of one single bank.
+ *
+ * @return A new data buffer.
*/
public DataBuffer createDataBuffer()
{
- int size;
-
- // FIXME: The comment refers to SinglePixelPackedSampleModel. See if the
- // same can be done for MultiPixelPackedSampleModel.
- // We can save (scanlineStride - width) pixels at the very end of
- // the buffer. The Sun reference implementation (J2SE 1.3.1 and
- // 1.4.1_01) seems to do this; tested with Mauve test code.
- size = scanlineStride * height;
-
+ int size = scanlineStride * height;
+ if (dataBitOffset > 0)
+ size += (dataBitOffset - 1) / elemBits + 1;
return Buffers.createBuffer(getDataType(), size);
}
-
+ /**
+ * Returns the number of data elements required to transfer a pixel in the
+ * get/setDataElements() methods.
+ *
+ * @return <code>1</code>.
+ */
public int getNumDataElements()
{
return 1;
}
+ /**
+ * Returns an array containing the size (in bits) of the samples in each
+ * band. The <code>MultiPixelPackedSampleModel</code> class supports only
+ * one band, so this method returns an array with length <code>1</code>.
+ *
+ * @return An array containing the size (in bits) of the samples in band zero.
+ *
+ * @see #getSampleSize(int)
+ */
public int[] getSampleSize()
{
- return sampleSize;
+ return (int[]) sampleSize.clone();
}
+ /**
+ * Returns the size of the samples in the specified band. Note that the
+ * <code>MultiPixelPackedSampleModel</code> supports only one band -- this
+ * method ignored the <code>band</code> argument, and always returns the size
+ * of band zero.
+ *
+ * @param band the band (this parameter is ignored).
+ *
+ * @return The size of the samples in band zero.
+ *
+ * @see #getSampleSize()
+ */
public int getSampleSize(int band)
{
return sampleSize[0];
}
+ /**
+ * Returns the index in the data buffer that stores the pixel at (x, y).
+ *
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return The index in the data buffer that stores the pixel at (x, y).
+ */
public int getOffset(int x, int y)
{
return scanlineStride * y + ((dataBitOffset + x*numberOfBits) / elemBits);
}
+ /**
+ * The bit offset (within an element in the data buffer) of the pixels with
+ * the specified x-coordinate.
+ *
+ * @param x the x-coordinate.
+ *
+ * @return The bit offset.
+ */
public int getBitOffset(int x)
{
return (dataBitOffset + x*numberOfBits) % elemBits;
}
+ /**
+ * Returns the offset to the first data bit.
+ *
+ * @return The offset to the first data bit.
+ */
public int getDataBitOffset()
{
return dataBitOffset;
}
+ /**
+ * Returns the number of data elements from a pixel in one row to the
+ * corresponding pixel in the next row.
+ *
+ * @return The scanline stride.
+ */
public int getScanlineStride()
{
return scanlineStride;
}
+ /**
+ * Returns the number of bits per pixel.
+ *
+ * @return The number of bits per pixel.
+ */
public int getPixelBitStride()
{
return numberOfBits;
}
+
+ /**
+ * Returns the transfer type, which is one of the following (depending on
+ * the number of bits per sample for this model):
+ * <ul>
+ * <li>{@link DataBuffer#TYPE_BYTE};</li>
+ * <li>{@link DataBuffer#TYPE_USHORT};</li>
+ * <li>{@link DataBuffer#TYPE_INT};</li>
+ * </ul>
+ *
+ * @return The transfer type.
+ */
+ public int getTransferType()
+ {
+ if (numberOfBits <= DataBuffer.getDataTypeSize(DataBuffer.TYPE_BYTE))
+ return DataBuffer.TYPE_BYTE;
+ else if (numberOfBits <= DataBuffer.getDataTypeSize(DataBuffer.TYPE_USHORT))
+ return DataBuffer.TYPE_USHORT;
+ return DataBuffer.TYPE_INT;
+ }
-
+ /**
+ * Normally this method returns a sample model for accessing a subset of
+ * bands of image data, but since <code>MultiPixelPackedSampleModel</code>
+ * only supports a single band, this overridden implementation just returns
+ * a new instance of <code>MultiPixelPackedSampleModel</code>, with the same
+ * attributes as this instance.
+ *
+ * @param bands the bands to include in the subset (this is ignored, except
+ * that if it is non-<code>null</code> a check is made to ensure that the
+ * array length is equal to <code>1</code>).
+ *
+ * @throws RasterFormatException if <code>bands</code> is not
+ * <code>null</code> and <code>bands.length != 1</code>.
+ */
public SampleModel createSubsetSampleModel(int[] bands)
{
- int numBands = bands.length;
- if (numBands != 1)
+ if (bands != null && bands.length != 1)
throw new RasterFormatException("MultiPixelPackedSampleModel only"
- + " supports one band");
-
- return new MultiPixelPackedSampleModel(dataType, width, height,
- numberOfBits, scanlineStride,
- dataBitOffset);
+ + " supports one band");
+ return new MultiPixelPackedSampleModel(dataType, width, height,
+ numberOfBits, scanlineStride, dataBitOffset);
}
/**
@@ -238,6 +362,23 @@ public class MultiPixelPackedSampleModel extends SampleModel
}
}
+ /**
+ * Returns an array (of length 1) containing the sample for the pixel at
+ * (x, y) in the specified data buffer. If <code>iArray</code> is not
+ * <code>null</code>, it will be populated with the sample value and
+ * returned as the result of this function (this avoids allocating a new
+ * array instance).
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return An array containing the pixel sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
if (iArray == null) iArray = new int[1];
@@ -246,6 +387,25 @@ public class MultiPixelPackedSampleModel extends SampleModel
return iArray;
}
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer. If
+ * <code>iArray</code> is not <code>null</code>, it will be populated with
+ * the sample values and returned as the result of this function (this
+ * avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
@@ -269,6 +429,20 @@ public class MultiPixelPackedSampleModel extends SampleModel
return iArray;
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int getSample(int x, int y, int b, DataBuffer data)
{
int pos =
@@ -347,11 +521,38 @@ public class MultiPixelPackedSampleModel extends SampleModel
}
}
+ /**
+ * Sets the sample value for the pixel at (x, y) in the specified data
+ * buffer to the specified value.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray the sample value (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ *
+ * @see #setSample(int, int, int, int, DataBuffer)
+ */
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
setSample(x, y, 0, iArray[0], data);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, int s, DataBuffer data)
{
int bitpos =
@@ -367,6 +568,70 @@ public class MultiPixelPackedSampleModel extends SampleModel
}
/**
+ * Tests this sample model for equality with an arbitrary object. This
+ * method returns <code>true</code> if and only if:
+ * <ul>
+ * <li><code>obj</code> is not <code>null</code>;
+ * <li><code>obj</code> is an instance of
+ * <code>MultiPixelPackedSampleModel</code>;
+ * <li>both models have the same:
+ * <ul>
+ * <li><code>dataType</code>;
+ * <li><code>width</code>;
+ * <li><code>height</code>;
+ * <li><code>numberOfBits</code>;
+ * <li><code>scanlineStride</code>;
+ * <li><code>dataBitOffsets</code>.
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @param obj the object (<code>null</code> permitted)
+ *
+ * @return <code>true</code> if this model is equal to <code>obj</code>, and
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (! (obj instanceof MultiPixelPackedSampleModel))
+ return false;
+ MultiPixelPackedSampleModel that = (MultiPixelPackedSampleModel) obj;
+ if (this.dataType != that.dataType)
+ return false;
+ if (this.width != that.width)
+ return false;
+ if (this.height != that.height)
+ return false;
+ if (this.numberOfBits != that.numberOfBits)
+ return false;
+ if (this.scanlineStride != that.scanlineStride)
+ return false;
+ if (this.dataBitOffset != that.dataBitOffset)
+ return false;
+ return true;
+ }
+
+ /**
+ * Returns a hash code for this <code>MultiPixelPackedSampleModel</code>.
+ *
+ * @return A hash code.
+ */
+ public int hashCode()
+ {
+ // this hash code won't match Sun's, but that shouldn't matter...
+ int result = 193;
+ result = 37 * result + dataType;
+ result = 37 * result + width;
+ result = 37 * result + height;
+ result = 37 * result + numberOfBits;
+ result = 37 * result + scanlineStride;
+ result = 37 * result + dataBitOffset;
+ return result;
+ }
+
+ /**
* Creates a String with some information about this SampleModel.
* @return A String describing this SampleModel.
* @see java.lang.Object#toString()
diff --git a/java/awt/image/SampleModel.java b/java/awt/image/SampleModel.java
index 6e3fd4069..cb352bb4d 100644
--- a/java/awt/image/SampleModel.java
+++ b/java/awt/image/SampleModel.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package java.awt.image;
/**
+ * A <code>SampleModel</code> is used to access pixel data from a
+ * {@link DataBuffer}. This is used by the {@link Raster} class.
+ *
* @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
*/
public abstract class SampleModel
@@ -100,16 +103,37 @@ public abstract class SampleModel
this.numBands = numBands;
}
+ /**
+ * Returns the width of the pixel data accessible via this
+ * <code>SampleModel</code>.
+ *
+ * @return The width.
+ *
+ * @see #getHeight()
+ */
public final int getWidth()
{
return width;
}
+ /**
+ * Returns the height of the pixel data accessible via this
+ * <code>SampleModel</code>.
+ *
+ * @return The height.
+ *
+ * @see #getWidth()
+ */
public final int getHeight()
{
return height;
}
+ /**
+ * Returns the number of bands for this <code>SampleModel</code>.
+ *
+ * @return The number of bands.
+ */
public final int getNumBands()
{
return numBands;
@@ -117,6 +141,12 @@ public abstract class SampleModel
public abstract int getNumDataElements();
+ /**
+ * Returns the type of the {@link DataBuffer} that this
+ * <code>SampleModel</code> accesses.
+ *
+ * @return The data buffer type.
+ */
public final int getDataType()
{
return dataType;
@@ -128,6 +158,22 @@ public abstract class SampleModel
return dataType;
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * specified data buffer. If <code>iArray</code> is not <code>null</code>,
+ * it will be populated with the sample values and returned as the result of
+ * this function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
if (iArray == null)
@@ -234,6 +280,22 @@ public abstract class SampleModel
}
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * specified data buffer. If <code>fArray</code> is not <code>null</code>,
+ * it will be populated with the sample values and returned as the result of
+ * this function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param fArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
{
if (fArray == null)
@@ -246,6 +308,22 @@ public abstract class SampleModel
return fArray;
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * specified data buffer. If <code>dArray</code> is not <code>null</code>,
+ * it will be populated with the sample values and returned as the result of
+ * this function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param dArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) {
if (dArray == null)
dArray = new double[numBands];
@@ -256,8 +334,27 @@ public abstract class SampleModel
return dArray;
}
- /* FIXME: Should it return a banded or pixel interleaved array of
- samples? (Assume interleaved.) */
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on). If <code>iArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
@@ -278,8 +375,27 @@ public abstract class SampleModel
return iArray;
}
- /* FIXME: Should it return a banded or pixel interleaved array of
- samples? (Assume interleaved.) */
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on). If <code>fArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param fArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public float[] getPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
{
@@ -299,8 +415,27 @@ public abstract class SampleModel
return fArray;
}
- /* FIXME: Should it return a banded or pixel interleaved array of
- samples? (Assume interleaved.) */
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on). If <code>dArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param dArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public double[] getPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
{
@@ -321,18 +456,85 @@ public abstract class SampleModel
return dArray;
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public abstract int getSample(int x, int y, int b, DataBuffer data);
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ *
+ * @see #getSample(int, int, int, DataBuffer)
+ */
public float getSampleFloat(int x, int y, int b, DataBuffer data)
{
return getSample(x, y, b, data);
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ *
+ * @see #getSample(int, int, int, DataBuffer)
+ */
public double getSampleDouble(int x, int y, int b, DataBuffer data)
{
return getSampleFloat(x, y, b, data);
}
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the specified data buffer. If
+ * <code>iArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
{
@@ -350,6 +552,27 @@ public abstract class SampleModel
return iArray;
}
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the specified data buffer. If
+ * <code>fArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param fArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public float[] getSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
{
@@ -367,6 +590,27 @@ public abstract class SampleModel
return fArray;
}
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the specified data buffer. If
+ * <code>dArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param dArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public double[] getSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data)
{
@@ -384,24 +628,77 @@ public abstract class SampleModel
return dArray;
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the specified data buffer to
+ * the specified values.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
for (int b = 0; b < numBands; b++)
setSample(x, y, b, iArray[b], data);
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the specified data buffer to
+ * the specified values.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param fArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>fArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, float[] fArray, DataBuffer data)
{
for (int b = 0; b < numBands; b++)
setSample(x, y, b, fArray[b], data);
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the specified data buffer to
+ * the specified values.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param dArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>dArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, double[] dArray, DataBuffer data)
{
for (int b = 0; b < numBands; b++)
setSample(x, y, b, dArray[b], data);
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param iArray the pixel sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
@@ -418,6 +715,23 @@ public abstract class SampleModel
}
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param fArray the pixel sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>fArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
{
@@ -434,6 +748,23 @@ public abstract class SampleModel
}
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param dArray the pixel sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>dArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
{
@@ -450,21 +781,76 @@ public abstract class SampleModel
}
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public abstract void setSample(int x, int y, int b, int s,
DataBuffer data);
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, float s,
DataBuffer data)
{
setSample(x, y, b, (int) s, data);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, double s,
DataBuffer data)
{
setSample(x, y, b, (float) s, data);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer.
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param iArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
{
@@ -475,6 +861,22 @@ public abstract class SampleModel
setSample(xx, yy, b, iArray[inOffset++], data);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer.
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param fArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
{
@@ -486,6 +888,22 @@ public abstract class SampleModel
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer.
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param b the band (in the range <code>0</code> to
+ * </code>getNumBands() - 1</code>).
+ * @param dArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data) {
int size = w * h;
@@ -495,6 +913,15 @@ public abstract class SampleModel
setSample(xx, yy, b, dArray[inOffset++], data);
}
+ /**
+ * Creates a new <code>SampleModel</code> that is compatible with this
+ * model and has the specified width and height.
+ *
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ *
+ * @return The new sample model.
+ */
public abstract SampleModel createCompatibleSampleModel(int w, int h);
/**
@@ -510,9 +937,31 @@ public abstract class SampleModel
*/
public abstract SampleModel createSubsetSampleModel(int[] bands);
+ /**
+ * Creates a new {@link DataBuffer} of the correct type and size for this
+ * <code>SampleModel</code>.
+ *
+ * @return The data buffer.
+ */
public abstract DataBuffer createDataBuffer();
+ /**
+ * Returns an array containing the size (in bits) for each band accessed by
+ * the <code>SampleModel</code>.
+ *
+ * @return An array.
+ *
+ * @see #getSampleSize(int)
+ */
public abstract int[] getSampleSize();
+ /**
+ * Returns the size (in bits) of the samples for the specified band.
+ *
+ * @param band the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ *
+ * @return The sample size (in bits).
+ */
public abstract int getSampleSize(int band);
}
diff --git a/java/awt/image/SinglePixelPackedSampleModel.java b/java/awt/image/SinglePixelPackedSampleModel.java
index 6ccce753b..548865a40 100644
--- a/java/awt/image/SinglePixelPackedSampleModel.java
+++ b/java/awt/image/SinglePixelPackedSampleModel.java
@@ -1,4 +1,4 @@
-/* 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.
@@ -36,10 +36,16 @@ exception statement from your version. */
package java.awt.image;
+import java.util.Arrays;
+
import gnu.java.awt.BitMaskExtent;
import gnu.java.awt.Buffers;
/**
+ * A <code>SampleModel</code> used when all samples are stored in a single
+ * data element in the {@link DataBuffer}, and each data element contains
+ * samples for one pixel only.
+ *
* @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
*/
public class SinglePixelPackedSampleModel extends SampleModel
@@ -49,12 +55,32 @@ public class SinglePixelPackedSampleModel extends SampleModel
private int[] bitOffsets;
private int[] sampleSize;
+ /**
+ * Creates a new <code>SinglePixelPackedSampleModel</code>.
+ *
+ * @param dataType the data buffer type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param bitMasks an array containing the bit mask used to extract the
+ * sample value for each band.
+ */
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int[] bitMasks)
{
this(dataType, w, h, w, bitMasks);
}
+ /**
+ * Creates a new <code>SinglePixelPackedSampleModel</code>.
+ *
+ * @param dataType the data buffer type.
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ * @param scanlineStride the number of data elements between a pixel on one
+ * row and the corresponding pixel on the next row.
+ * @param bitMasks an array containing the bit mask used to extract the
+ * sample value for each band.
+ */
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int scanlineStride, int[] bitMasks)
{
@@ -67,7 +93,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
case DataBuffer.TYPE_INT:
break;
default:
- throw new IllegalArgumentException("SinglePixelPackedSampleModel unsupported dataType");
+ throw new IllegalArgumentException(
+ "SinglePixelPackedSampleModel unsupported dataType");
}
this.scanlineStride = scanlineStride;
@@ -77,19 +104,35 @@ public class SinglePixelPackedSampleModel extends SampleModel
sampleSize = new int[numBands];
BitMaskExtent extent = new BitMaskExtent();
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
{
- extent.setMask(bitMasks[b]);
- sampleSize[b] = extent.bitWidth;
- bitOffsets[b] = extent.leastSignificantBit;
+ // the mask is an unsigned integer
+ long mask = bitMasks[b] & 0xFFFFFFFFL;
+ extent.setMask(mask);
+ sampleSize[b] = extent.bitWidth;
+ bitOffsets[b] = extent.leastSignificantBit;
}
}
+ /**
+ * Returns the number of data elements.
+ *
+ * @return <code>1</code>.
+ */
public int getNumDataElements()
{
return 1;
}
+ /**
+ * Creates a new <code>SampleModel</code> that is compatible with this
+ * model and has the specified width and height.
+ *
+ * @param w the width (in pixels).
+ * @param h the height (in pixels).
+ *
+ * @return The new sample model.
+ */
public SampleModel createCompatibleSampleModel(int w, int h)
{
/* FIXME: We can avoid recalculation of bit offsets and sample
@@ -103,6 +146,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
* Creates a DataBuffer for holding pixel data in the format and
* layout described by this SampleModel. The returned buffer will
* consist of one single bank.
+ *
+ * @return The data buffer.
*/
public DataBuffer createDataBuffer()
{
@@ -116,12 +161,27 @@ public class SinglePixelPackedSampleModel extends SampleModel
return Buffers.createBuffer(getDataType(), size);
}
-
+ /**
+ * Returns an array containing the size (in bits) for each band accessed by
+ * the <code>SampleModel</code>.
+ *
+ * @return An array.
+ *
+ * @see #getSampleSize(int)
+ */
public int[] getSampleSize()
{
return sampleSize;
}
+ /**
+ * Returns the size (in bits) of the samples for the specified band.
+ *
+ * @param band the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ *
+ * @return The sample size (in bits).
+ */
public int getSampleSize(int band)
{
return sampleSize[band];
@@ -155,7 +215,7 @@ public class SinglePixelPackedSampleModel extends SampleModel
int[] bitMasks = new int[numBands];
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
bitMasks[b] = this.bitMasks[bands[b]];
return new SinglePixelPackedSampleModel(dataType, width, height,
@@ -174,16 +234,20 @@ public class SinglePixelPackedSampleModel extends SampleModel
}
/**
- * This is a more efficient implementation of the default implementation in the super
- * class.
- * @param x The x-coordinate of the pixel rectangle to store in <code>obj</code>.
- * @param y The y-coordinate of the pixel rectangle to store in <code>obj</code>.
+ * This is a more efficient implementation of the default implementation in
+ * the super class.
+ * @param x The x-coordinate of the pixel rectangle to store in
+ * <code>obj</code>.
+ * @param y The y-coordinate of the pixel rectangle to store in
+ * <code>obj</code>.
* @param w The width of the pixel rectangle to store in <code>obj</code>.
* @param h The height of the pixel rectangle to store in <code>obj</code>.
- * @param obj The primitive array to store the pixels into or null to force creation.
+ * @param obj The primitive array to store the pixels into or null to force
+ * creation.
* @param data The DataBuffer that is the source of the pixel data.
* @return The primitive array containing the pixel data.
- * @see java.awt.image.SampleModel#getDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)
+ * @see java.awt.image.SampleModel#getDataElements(int, int, int, int,
+ * java.lang.Object, java.awt.image.DataBuffer)
*/
public Object getDataElements(int x, int y, int w, int h, Object obj,
DataBuffer data)
@@ -209,10 +273,11 @@ public class SinglePixelPackedSampleModel extends SampleModel
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
- if(x==0 && scanlineStride == w)
+ if(x == 0 && scanlineStride == w)
{
// The full width need to be copied therefore we can copy in one shot.
- System.arraycopy(pixelData, scanlineStride*y + data.getOffset(), obj, 0, size);
+ System.arraycopy(pixelData, scanlineStride*y + data.getOffset(), obj,
+ 0, size);
}
else
{
@@ -229,32 +294,68 @@ public class SinglePixelPackedSampleModel extends SampleModel
return obj;
}
-
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * specified data buffer. If <code>iArray</code> is not <code>null</code>,
+ * it will be populated with the sample values and returned as the result of
+ * this function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
int offset = scanlineStride*y + x;
if (iArray == null) iArray = new int[numBands];
int samples = data.getElem(offset);
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
iArray[b] = (samples & bitMasks[b]) >>> bitOffsets[b];
return iArray;
}
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the specified data buffer. The array is
+ * ordered by pixels (that is, all the samples for the first pixel are
+ * grouped together, followed by all the samples for the second pixel, and so
+ * on). If <code>iArray</code> is not <code>null</code>, it will be
+ * populated with the sample values and returned as the result of this
+ * function (this avoids allocating a new array instance).
+ *
+ * @param x the x-coordinate of the top-left pixel.
+ * @param y the y-coordinate of the top-left pixel.
+ * @param w the width of the region of pixels.
+ * @param h the height of the region of pixels.
+ * @param iArray an array to populate with the sample values and return as
+ * the result (if <code>null</code>, a new array will be allocated).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The pixel sample values.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
{
int offset = scanlineStride*y + x;
if (iArray == null) iArray = new int[numBands*w*h];
int outOffset = 0;
- for (y=0; y<h; y++)
+ for (y = 0; y < h; y++)
{
int lineOffset = offset;
- for (x=0; x<w; x++)
+ for (x = 0; x < w; x++)
{
int samples = data.getElem(lineOffset++);
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
iArray[outOffset++] = (samples & bitMasks[b]) >>> bitOffsets[b];
}
offset += scanlineStride;
@@ -262,6 +363,20 @@ public class SinglePixelPackedSampleModel extends SampleModel
return iArray;
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the specified data
+ * buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @return The sample value.
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public int getSample(int x, int y, int b, DataBuffer data)
{
int offset = scanlineStride*y + x;
@@ -270,16 +385,18 @@ public class SinglePixelPackedSampleModel extends SampleModel
}
/**
- * This method implements a more efficient way to set data elements than the default
- * implementation of the super class. It sets the data elements line by line instead
- * of pixel by pixel.
+ * This method implements a more efficient way to set data elements than the
+ * default implementation of the super class. It sets the data elements line
+ * by line instead of pixel by pixel.
+ *
* @param x The x-coordinate of the data elements in <code>obj</code>.
* @param y The y-coordinate of the data elements in <code>obj</code>.
* @param w The width of the data elements in <code>obj</code>.
* @param h The height of the data elements in <code>obj</code>.
* @param obj The primitive array containing the data elements to set.
* @param data The DataBuffer to store the data elements into.
- * @see java.awt.image.SampleModel#setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)
+ * @see java.awt.image.SampleModel#setDataElements(int, int, int, int,
+ * java.lang.Object, java.awt.image.DataBuffer)
*/
public void setDataElements(int x, int y, int w, int h,
Object obj, DataBuffer data)
@@ -373,12 +490,24 @@ public class SinglePixelPackedSampleModel extends SampleModel
}
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the specified data buffer to
+ * the specified values.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param iArray the sample values (<code>null</code> not permitted).
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if either <code>iArray</code> or
+ * <code>data</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
int offset = scanlineStride*y + x;
int samples = 0;
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
samples |= (iArray[b] << bitOffsets[b]) & bitMasks[b];
data.setElem(offset, samples);
@@ -394,7 +523,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
* @param h The height of the pixel rectangle in <code>obj</code>.
* @param iArray The primitive array containing the pixels to set.
* @param data The DataBuffer to store the pixels into.
- * @see java.awt.image.SampleModel#setPixels(int, int, int, int, int[], java.awt.image.DataBuffer)
+ * @see java.awt.image.SampleModel#setPixels(int, int, int, int, int[],
+ * java.awt.image.DataBuffer)
*/
public void setPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
@@ -407,7 +537,7 @@ public class SinglePixelPackedSampleModel extends SampleModel
for (int xx=x; xx<(x+w); xx++)
{
int samples = 0;
- for (int b=0; b<numBands; b++)
+ for (int b = 0; b < numBands; b++)
samples |= (iArray[inOffset+b] << bitOffsets[b]) & bitMasks[b];
data.setElem(0, offset, samples);
inOffset += numBands;
@@ -416,7 +546,19 @@ public class SinglePixelPackedSampleModel extends SampleModel
}
}
-
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the
+ * specified data buffer.
+ *
+ * @param x the x-coordinate of the pixel.
+ * @param y the y-coordinate of the pixel.
+ * @param b the band (in the range <code>0</code> to
+ * <code>getNumBands() - 1</code>).
+ * @param s the sample value.
+ * @param data the data buffer (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
+ */
public void setSample(int x, int y, int b, int s, DataBuffer data)
{
int offset = scanlineStride*y + x;
@@ -428,6 +570,55 @@ public class SinglePixelPackedSampleModel extends SampleModel
}
/**
+ * Tests this sample model for equality with an arbitrary object. This
+ * method returns <code>true</code> if and only if:
+ * <ul>
+ * <li><code>obj</code> is not <code>null</code>;
+ * <li><code>obj</code> is an instance of
+ * <code>SinglePixelPackedSampleModel</code>;
+ * <li>both models have the same:
+ * <ul>
+ * <li><code>dataType</code>;
+ * <li><code>width</code>;
+ * <li><code>height</code>;
+ * <li><code>numBands</code>;
+ * <li><code>scanlineStride</code>;
+ * <li><code>bitMasks</code>;
+ * <li><code>bitOffsets</code>.
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @param obj the object (<code>null</code> permitted)
+ *
+ * @return <code>true</code> if this model is equal to <code>obj</code>, and
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (! (obj instanceof SinglePixelPackedSampleModel))
+ return false;
+ SinglePixelPackedSampleModel that = (SinglePixelPackedSampleModel) obj;
+ if (this.dataType != that.dataType)
+ return false;
+ if (this.width != that.width)
+ return false;
+ if (this.height != that.height)
+ return false;
+ if (this.numBands != that.numBands)
+ return false;
+ if (this.scanlineStride != that.scanlineStride)
+ return false;
+ if (!Arrays.equals(this.bitMasks, that.bitMasks))
+ return false;
+ if (!Arrays.equals(this.bitOffsets, that.bitOffsets))
+ return false;
+ return true;
+ }
+
+ /**
* Creates a String with some information about this SampleModel.
* @return A String describing this SampleModel.
* @see java.lang.Object#toString()
@@ -438,9 +629,10 @@ public class SinglePixelPackedSampleModel extends SampleModel
result.append(getClass().getName());
result.append("[");
result.append("scanlineStride=").append(scanlineStride);
- for(int i=0; i < bitMasks.length; i+=1)
+ for(int i = 0; i < bitMasks.length; i+=1)
{
- result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i]));
+ result.append(", mask[").append(i).append("]=0x").append(
+ Integer.toHexString(bitMasks[i]));
}
result.append("]");
diff --git a/java/awt/peer/MouseInfoPeer.java b/java/awt/peer/MouseInfoPeer.java
new file mode 100644
index 000000000..e9923a653
--- /dev/null
+++ b/java/awt/peer/MouseInfoPeer.java
@@ -0,0 +1,61 @@
+/* MouseInfoPeer.java -- peer interface for MouseInfo
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt.peer;
+
+import java.awt.Point;
+import java.awt.Window;
+
+/**
+ * MouseInfoPeer is the peer interface java.awt.MouseInfo.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public interface MouseInfoPeer
+{
+ /**
+ * Get the mouse pointer coordinates and store them in p (obviously non-null)
+ * returns the index of the current screen device of the mouse.
+ */
+ public int fillPointWithCoords(Point p);
+
+ /**
+ * Returns whether a given Window is under the mouse.
+ */
+ public boolean isWindowUnderMouse(Window w);
+}
diff --git a/java/awt/peer/WindowPeer.java b/java/awt/peer/WindowPeer.java
index 6c014de0b..00d103579 100644
--- a/java/awt/peer/WindowPeer.java
+++ b/java/awt/peer/WindowPeer.java
@@ -1,5 +1,5 @@
/* WindowPeer.java -- Interface for window peers
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,8 @@ public interface WindowPeer extends ContainerPeer
void toFront();
/**
- * FIXME: unknown.
+ * Update the always-on-top status of the Window.
+ *
* @since 1.5
*/
void updateAlwaysOnTop();
diff --git a/java/io/PrintStream.java b/java/io/PrintStream.java
index 4a0716516..9726ccdba 100644
--- a/java/io/PrintStream.java
+++ b/java/io/PrintStream.java
@@ -91,8 +91,76 @@ public class PrintStream extends FilterOutputStream implements Appendable
private boolean auto_flush;
/**
- * This method intializes a new <code>PrintStream</code> object to write
- * to the specified output sink.
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param file The <code>File</code> to write to.
+ * @throws FileNotFoundException if an error occurs while opening the file.
+ *
+ * @since 1.5
+ */
+ public PrintStream (File file)
+ throws FileNotFoundException
+ {
+ this (new FileOutputStream(file), false);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param file The <code>File</code> to write to.
+ * @param encoding The name of the character encoding to use for this
+ * object.
+ * @throws FileNotFoundException If an error occurs while opening the file.
+ * @throws UnsupportedEncodingException If the charset specified by
+ * <code>encoding</code> is invalid.
+ *
+ * @since 1.5
+ */
+ public PrintStream (File file, String encoding)
+ throws FileNotFoundException,UnsupportedEncodingException
+ {
+ this (new FileOutputStream(file), false, encoding);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param fileName The name of the <code>File</code> to write to.
+ * @throws FileNotFoundException if an error occurs while opening the file,
+ *
+ * @since 1.5
+ */
+ public PrintStream (String fileName)
+ throws FileNotFoundException
+ {
+ this (new FileOutputStream(new File(fileName)), false);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output File. Doesn't autoflush.
+ *
+ * @param fileName The name of the <code>File</code> to write to.
+ * @param encoding The name of the character encoding to use for this
+ * object.
+ * @throws FileNotFoundException if an error occurs while opening the file.
+ * @throws UnsupportedEncodingException If the charset specified by
+ * <code>encoding</code> is invalid.
+ *
+ * @since 1.5
+ */
+ public PrintStream (String fileName, String encoding)
+ throws FileNotFoundException,UnsupportedEncodingException
+ {
+ this (new FileOutputStream(new File(fileName)), false, encoding);
+ }
+
+ /**
+ * This method initializes a new <code>PrintStream</code> object to write
+ * to the specified output sink. Doesn't autoflush.
*
* @param out The <code>OutputStream</code> to write to.
*/
@@ -102,7 +170,7 @@ public class PrintStream extends FilterOutputStream implements Appendable
}
/**
- * This method intializes a new <code>PrintStream</code> object to write
+ * This method initializes a new <code>PrintStream</code> object to write
* to the specified output sink. This constructor also allows "auto-flush"
* functionality to be specified where the stream will be flushed after
* every <code>print</code> or <code>println</code> call, when the
@@ -131,7 +199,7 @@ public class PrintStream extends FilterOutputStream implements Appendable
}
/**
- * This method intializes a new <code>PrintStream</code> object to write
+ * This method initializes a new <code>PrintStream</code> object to write
* to the specified output sink. This constructor also allows "auto-flush"
* functionality to be specified where the stream will be flushed after
* every <code>print</code> or <code>println</code> call, when the
@@ -155,33 +223,6 @@ public class PrintStream extends FilterOutputStream implements Appendable
this.auto_flush = auto_flush;
}
- /** @since 1.5 */
- public PrintStream (String filename)
- throws FileNotFoundException
- {
- this(new FileOutputStream (filename));
- }
-
- /** @since 1.5 */
- public PrintStream (String filename, String encoding)
- throws FileNotFoundException, UnsupportedEncodingException
- {
- this(new FileOutputStream (filename),false,encoding);
- }
-
- /** @since 1.5 */
- public PrintStream (File file) throws FileNotFoundException
- {
- this(new FileOutputStream (file));
- }
-
- /** @since 1.5 */
- public PrintStream (File file, String encoding)
- throws FileNotFoundException, UnsupportedEncodingException
- {
- this(new FileOutputStream (file),false,encoding);
- }
-
/**
* This method checks to see if an error has occurred on this stream. Note
* that once an error has occurred, this method will continue to report
diff --git a/java/lang/management/MemoryNotificationInfo.java b/java/lang/management/MemoryNotificationInfo.java
new file mode 100644
index 000000000..c97fe6bb5
--- /dev/null
+++ b/java/lang/management/MemoryNotificationInfo.java
@@ -0,0 +1,239 @@
+/* MemoryNotificationInfo.java - Emitted memory notification info.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * <p>
+ * Represents the content of a notification emitted by the
+ * {@link MemoryMXBean}. Such notifications are emitted when
+ * one of the memory pools exceeds its usage or collection
+ * usage threshold. This object contains the following information,
+ * representing the state of the pool at the time of the
+ * notification:
+ * </p>
+ * <ul>
+ * <li>The name of the pool.</li>
+ * <li>The memory usage of the pool at the time of notification.</li>
+ * <li>The number of times the pool has exceeded this particular
+ * threshold in the past.</li>
+ * </ul>
+ * <p>
+ * Two types of notification are emitted by the {@link MemoryMXBean}:
+ * one for exceeding the usage threshold and one for exceeding the
+ * collection usage threshold. The value returned by {@link #getCount()}
+ * is dependent on this type; if the threshold exceeded is the usage
+ * threshold, then the usage threshold count is returned. If, instead,
+ * the collection usage threshold is exceeded, then the collection usage
+ * threshold count is returned.
+ * </p>
+ * <p>
+ * This data is held in the user data part of the notification (returned
+ * by {@link javax.management.Notification#getUserData()}) encapsulated in
+ * a {@link javax.management.openmbean.CompositeData} object. The
+ * {@link #from(javax.management.openmbean.CompositeData)} method may be
+ * used to unwrap the value and obtain an instance of this class.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MemoryNotificationInfo
+{
+
+ /**
+ * The type of notification emitted when the usage threshold is exceeded.
+ * After a notification is emitted, the usage level must drop below the
+ * threshold again before another notification is emitted. The value is
+ * <code>java.management.memory.threshold.exceeded</code>.
+ */
+ public static final String MEMORY_THRESHOLD_EXCEEDED =
+ "java.management.memory.threshold.exceeded";
+
+ /**
+ * The type of notification emitted when the collection usage threshold
+ * is exceeded, following a garbage collection cycle. The value is
+ * <code>java.management.memory.collection.threshold.exceeded</code>.
+ */
+ public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED =
+ "java.management.memory.collection.threshold.exceeded";
+
+ /**
+ * The name of the memory pool which exceeded the threshold.
+ */
+ private String poolName;
+
+ /**
+ * The usage level of the memory pool at the time of notification.
+ */
+ private MemoryUsage usage;
+
+ /**
+ * The number of times the threshold has been crossed.
+ */
+ private long count;
+
+ /**
+ * Constructs a new {@link MemoryNotificationInfo} object using the
+ * specified pool name, usage level and threshold crossing count.
+ *
+ * @param poolName the name of the pool which has exceeded a threshold.
+ * @param usage the usage level of the pool at the time of notification.
+ * @param count the number of times the threshold has been crossed.
+ */
+ public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
+ {
+ this.poolName = poolName;
+ this.usage = usage;
+ this.count = count;
+ }
+
+ /**
+ * <p>
+ * Returns a {@link MemoryNotificationInfo} instance using the values
+ * given in the supplied
+ * {@link javax.management.openmbean.CompositeData} object.
+ * The composite data instance should contain the following
+ * attributes with the specified types:
+ * </p>
+ * <table>
+ * <th><td>Name</td><td>Type</td></th>
+ * <tr><td>poolName</td><td>java.lang.String</td></tr>
+ * <tr><td>usage</td><td>javax.management.openmbean.CompositeData
+ * </td></tr>
+ * <tr><td>count</td><td>java.lang.Long</td></tr>
+ * </table>
+ * <p>
+ * The usage level is further described as:
+ * </p>
+ * <table>
+ * <th><td>Name</td><td>Type</td></th>
+ * <tr><td>init</td><td>java.lang.Long</td></tr>
+ * <tr><td>used</td><td>java.lang.Long</td></tr>
+ * <tr><td>committed</td><td>java.lang.Long</td></tr>
+ * <tr><td>max</td><td>java.lang.Long</td></tr>
+ * </table>
+ *
+ * @param data the composite data structure to take values from.
+ * @return a new instance containing the values from the
+ * composite data structure, or <code>null</code>
+ * if the data structure was also <code>null</code>.
+ * @throws IllegalArgumentException if the composite data structure
+ * does not match the structure
+ * outlined above.
+ */
+ public static MemoryNotificationInfo from(CompositeData data)
+ {
+ if (data == null)
+ return null;
+ CompositeType type = data.getCompositeType();
+ ThreadInfo.checkAttribute(type, "poolName", SimpleType.STRING);
+ try
+ {
+ CompositeType uType =
+ new CompositeType(MemoryUsage.class.getName(),
+ "Describes the usage levels of a pool",
+ new String[] { "init", "used",
+ "committed", "max"
+ },
+ new String[] { "Initial level",
+ "Used level",
+ "Committed level",
+ "Maximum level"
+ },
+ new OpenType[] {
+ SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG, SimpleType.LONG
+ });
+ ThreadInfo.checkAttribute(type, "usage", uType);
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalStateException("Something went wrong in creating " +
+ "the composite data type for the " +
+ "memory usage element.", e);
+ }
+ ThreadInfo.checkAttribute(type, "count", SimpleType.LONG);
+ MemoryUsage usage = MemoryUsage.from((CompositeData) data.get("usage"));
+ return new MemoryNotificationInfo(((String) data.get("poolName")),
+ usage,
+ ((Long) data.get("count")).longValue());
+ }
+
+ /**
+ * Returns the number of times the memory pool has crossed the usage
+ * threshold, as of the time of notification. If this is the notification
+ * represented by the type {@link #MEMORY_THRESHOLD_EXCEEDED}, then the
+ * count is the usage threshold count. If this is the notification
+ * represented by the type {@link #MEMORY_COLLECTION_THRESHOLD_EXCEEDED},
+ * then the count is the collection usage threshold count.
+ *
+ * @return the number of times the appropriate threshold has been crossed.
+ */
+ public long getCount()
+ {
+ return count;
+ }
+
+ /**
+ * Returns the name of the pool which has crossed a threshold.
+ *
+ * @return the name of the pool.
+ */
+ public String getPoolName()
+ {
+ return poolName;
+ }
+
+ /**
+ * Returns the usage levels at the time of notification.
+ *
+ * @return the usage levels.
+ */
+ public MemoryUsage getUsage()
+ {
+ return usage;
+ }
+
+}
+
diff --git a/java/util/Arrays.java b/java/util/Arrays.java
index 540765a8e..fbbf43f20 100644
--- a/java/util/Arrays.java
+++ b/java/util/Arrays.java
@@ -1,5 +1,5 @@
/* Arrays.java -- Utility class with methods to operate on arrays
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -2342,8 +2342,10 @@ public class Arrays
* value modification. The returned list implements both Serializable and
* RandomAccess.
*
- * @param a the array to return a view of
+ * @param a the array to return a view of (<code>null</code> not permitted)
* @return a fixed-size list, changes to which "write through" to the array
+ *
+ * @throws NullPointerException if <code>a</code> is <code>null</code>.
* @see Serializable
* @see RandomAccess
* @see Arrays.ArrayList
diff --git a/java/util/UUID.java b/java/util/UUID.java
new file mode 100644
index 000000000..9a402d159
--- /dev/null
+++ b/java/util/UUID.java
@@ -0,0 +1,372 @@
+/* UUID.java -- Class that represents a UUID object.
+ 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.util;
+
+import java.io.Serializable;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * This class represents a 128-bit UUID value.
+ *
+ * There are several types of UUID, and while this class can be used to store
+ * them, only the Leach-Salz (variant 2) UUID specified in RFC-4122 will
+ * give meaningful results from the method calls.
+ * See: http://tools.ietf.org/html/4122 for the details
+ *
+ * The format of a Leach-Salz (variant 2) time-based (version 1) UUID
+ * is as follows:
+ * time_low - upper 32 bits of the most significant 64 bits,
+ * this is the least-significant part of the timestamp.
+ *
+ * time_mid - bits 16-31 of the most significant 64 bits,
+ * this is the middle portion of the timestamp.
+ *
+ * version - bits 8-15 of the most significant 64 bits.
+ *
+ * time_hi - bits 0-7 of the most significant 64 bits,
+ * the most significant portion of the timestamp.
+ *
+ * clock_and_reserved - bits 48-63 of the least significant 64 bits.
+ * a variable number of bits hold the variant
+ * (see the spec)
+ *
+ * node identifier - bits 0-47 of the least signficant 64 bits.
+ *
+ * These fields are valid only for version 1, in the remaining versions,
+ * only the version and variant fields are set, all others are used for data.
+ *
+ * @since 1.5
+ * @author Sven de Marothy
+ */
+public final class UUID
+ extends Object
+ implements Serializable, Comparable<UUID>
+{
+ private static final long serialVersionUID = -4856846361193249489L;
+
+ /**
+ * Serialized field - most significant 64 bits.
+ */
+ private long mostSigBits;
+
+ /**
+ * Serialized field - least significant 64 bits.
+ */
+ private long leastSigBits;
+
+ /**
+ * Random-number generator.
+ */
+ private static transient Random r = new Random();
+
+ /**
+ * Constructs a new UUID.
+ *
+ * @since 1.5
+ */
+ public UUID(long mostSigBits, long leastSigBits)
+ {
+ this.mostSigBits = mostSigBits;
+ this.leastSigBits = leastSigBits;
+ }
+
+ /**
+ * Returns the clock-sequence value of this UUID.
+ * This field only exists in a time-based (version 1) UUID.
+ *
+ * @throws UnsupportedOperationException if the UUID type is not 1.
+ * @returns an int containing the clock-sequence value.
+ */
+ public int clockSequence()
+ {
+ if( version() != 1 )
+ throw new UnsupportedOperationException("Not a type 1 UUID");
+ return (int)((leastSigBits & 0x3FFF000000000000L) >> 48);
+ }
+
+ /**
+ * Compare this UUID to another.
+ * The comparison is performed as between two 128-bit integers.
+ *
+ * @return -1 if this < val, 0 if they are equal, 1 if this > val.
+ */
+ public int compareTo(UUID o)
+ {
+ if( mostSigBits < o.mostSigBits )
+ return -1;
+ if( mostSigBits > o.mostSigBits )
+ return 1;
+ if( leastSigBits < o.leastSigBits )
+ return -1;
+ if( leastSigBits > o.mostSigBits )
+ return 1;
+ return 0;
+ }
+
+ /**
+ * Compare a (UUID) object to this one
+ */
+ public boolean equals(Object obj)
+ {
+ if( !(obj instanceof UUID ) )
+ return false;
+ return ( ((UUID)obj).mostSigBits == mostSigBits &&
+ ((UUID)obj).leastSigBits == leastSigBits );
+ }
+
+ /**
+ * Creates a UUID object from a Sting representation.
+ *
+ * For the format of the string,
+ * @see #toString()
+ *
+ * @return a new UUID object.
+ */
+ public static UUID fromString(String name)
+ {
+ StringTokenizer st = new StringTokenizer( name.trim(), "-" );
+ if( st.countTokens() < 5 )
+ throw new IllegalArgumentException( "Incorrect UUID string"+
+ " representation:"+name );
+
+ long msb = (Long.parseLong(st.nextToken(), 16) << 32); // time low
+ msb |= (Long.parseLong(st.nextToken(), 16) << 16); // time mid
+ msb |= Long.parseLong(st.nextToken(), 16); // time high
+
+ long lsb = (Long.parseLong(st.nextToken(), 16) << 48); // clock
+ lsb |= Long.parseLong(st.nextToken(), 16); // node
+
+ return new UUID(msb, lsb);
+ }
+
+ /**
+ * Returns a String representation of the UUID.
+ *
+ * The format of the standard string representation (given in RFC4122) is:
+ *
+ * time-low "-" time-mid "-"
+ * time-high-and-version "-"
+ * clock-seq-and-reserved
+ * clock-seq-low "-" node
+ *
+ * Where each field is represented as a hex string.
+ *
+ * @return the String representation.
+ */
+ public String toString()
+ {
+ return // time-low first
+ padHex( (( mostSigBits & 0xFFFFFFFF00000000L) >> 32) & 0xFFFFFFFFL, 8)
+ + "-" + // then time-mid
+ padHex( (( mostSigBits & 0xFFFF0000L ) >> 16), 4 )
+ + "-" + // time-high
+ padHex( ( mostSigBits & 0x0000000000000000FFFFL ), 4 )
+ + "-" + // clock (note - no reason to separate high and low here)
+ padHex( (((leastSigBits & 0xFFFF000000000000L) >> 48) & 0xFFFF), 4 )
+ + "-" + // finally the node value.
+ padHex(leastSigBits & 0xFFFFFFFFFFFFL, 12);
+ }
+
+ /**
+ * Returns the least significant 64 bits of the UUID as a <code>long</code>.
+ */
+ public long getLeastSignificantBits()
+ {
+ return leastSigBits;
+ }
+
+ /**
+ * Returns the most significant 64 bits of the UUID as a <code>long</code>.
+ */
+ public long getMostSignificantBits()
+ {
+ return mostSigBits;
+ }
+
+ /**
+ * Returns a hash of this UUID.
+ */
+ public int hashCode()
+ {
+ int l1 = (int)(leastSigBits & 0xFFFFFFFFL);
+ int l2 = (int)((leastSigBits & 0xFFFFFFFF00000000L) >> 32);
+ int m1 = (int)(mostSigBits & 0xFFFFFFFFL);
+ int m2 = (int)((mostSigBits & 0xFFFFFFFF00000000L) >> 32);
+
+ return (l1 ^ l2) ^ (m1 ^ m2);
+ }
+
+ /**
+ * Creates a UUID version 3 object (name based with MD5 hashing)
+ * from a series of bytes representing a name.
+ */
+ public static UUID nameUUIDFromBytes(byte[] name)
+ {
+ long msb, lsb;
+ byte[] hash;
+
+ try
+ {
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+ hash = md5.digest( name );
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new UnsupportedOperationException("No MD5 algorithm available.");
+ }
+
+ msb = ((hash[0] & 0xFFL) << 56) | ((hash[1] & 0xFFL) << 48) |
+ ((hash[2] & 0xFFL) << 40) | ((hash[3] & 0xFFL) << 32) |
+ ((hash[4] & 0xFFL) << 24) | ((hash[5] & 0xFFL) << 16) |
+ ((hash[6] & 0xFFL) << 8) | (hash[7] & 0xFFL);
+
+ lsb = ((hash[8] & 0xFFL) << 56) | ((hash[9] & 0xFFL) << 48) |
+ ((hash[10] & 0xFFL) << 40) | ((hash[11] & 0xFFL) << 32) |
+ ((hash[12] & 0xFFL) << 24) | ((hash[13] & 0xFFL) << 16) |
+ ((hash[14] & 0xFFL) << 8) | (hash[15] & 0xFFL);
+
+ lsb &= 0x3FFFFFFFFFFFFFFFL;
+ lsb |= 0x8000000000000000L; // set top two bits to variant 2
+
+ msb &= 0xFFFFFFFFFFFF0FFFL;
+ msb |= 0x3000; // Version 3;
+
+ return new UUID(msb, lsb);
+ }
+
+ /**
+ * Returns the 48-bit node value in a long.
+ * This field only exists in a time-based (version 1) UUID.
+ *
+ * @throws UnsupportedOperationException if the UUID type is not 1.
+ * @returns a long with the node value in the lower 48 bits.
+ */
+ public long node()
+ {
+ if( version() != 1 )
+ throw new UnsupportedOperationException("Not a type 1 UUID");
+ return (leastSigBits & 0xFFFFFFFFFFFFL);
+ }
+
+ /**
+ * Returns the 60-bit timestamp value of the UUID in a long.
+ * This field only exists in a time-based (version 1) UUID.
+ *
+ * @throws UnsupportedOperationException if the UUID type is not 1.
+ * @returns a long with the timestamp value.
+ */
+ public long timestamp()
+ {
+ if( version() != 1 )
+ throw new UnsupportedOperationException("Not a type 1 UUID");
+ long time = (( mostSigBits & 0xFFFFFFFF00000000L) >> 32);
+ time |= (( mostSigBits & 0xFFFF0000L ) << 16);
+ long time_hi = ( mostSigBits & 0xFFFL );
+ time |= (time_hi << 48);
+ return time;
+ }
+
+ /**
+ * Generate a Leach-Salz (Variant 2) randomly generated (version 4)
+ * UUID.
+ *
+ */
+ public static UUID randomUUID()
+ {
+ long lsb = r.nextLong();
+ long msb = r.nextLong();
+
+ lsb &= 0x3FFFFFFFFFFFFFFFL;
+ lsb |= 0x8000000000000000L; // set top two bits to variant 2
+
+ msb &= 0xFFFFFFFFFFFF0FFFL;
+ msb |= 0x4000; // Version 4;
+
+ return new UUID( msb, lsb );
+ }
+
+ /**
+ * Returns a hex String from l, padded to n spaces.
+ */
+ private String padHex( long l, int n )
+ {
+ String s = Long.toHexString( l );
+ while( s.length() < n )
+ s = "0" + s;
+ return s;
+ }
+
+ /**
+ * Returns the variant of the UUID
+ *
+ * This may be:
+ * 0 = Reserved for NCS backwards-compatibility
+ * 2 = Leach-Salz (supports the other methods in this class)
+ * 6 = Reserved for Microsoft backwards-compatibility
+ * 7 = (reserved for future use)
+ */
+ public int variant()
+ {
+ // Get the top 3 bits (not all may be part of the variant)
+ int v = (int)((leastSigBits & 0xE000000000000000L) >> 61);
+ if( (v & 0x04) == 0 ) // msb of the variant is 0
+ return 0;
+ if( (v & 0x02) == 0 ) // variant is 0 1 (Leach-Salz)
+ return 2;
+ return v; // 6 or 7
+ }
+
+ /**
+ * Returns the version # of the UUID.
+ *
+ * Valid version numbers for a variant 2 UUID are:
+ * 1 = Time based UUID
+ * 2 = DCE security UUID
+ * 3 = Name-based UUID using MD5 hashing
+ * 4 = Randomly generated UUID
+ * 5 = Name-based UUID using SHA-1 hashing
+ *
+ * @return the version number
+ */
+ public int version()
+ {
+ return (int)((mostSigBits & 0xF000L) >> 12);
+ }
+}
diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java
index d031f5329..00ba19b15 100644
--- a/java/util/zip/ZipFile.java
+++ b/java/util/zip/ZipFile.java
@@ -445,6 +445,7 @@ public class ZipFile implements ZipConstants
case ZipOutputStream.STORED:
return inp;
case ZipOutputStream.DEFLATED:
+ inp.addDummyByte();
final Inflater inf = new Inflater(true);
final int sz = (int) entry.getSize();
return new InflaterInputStream(inp, inf)
@@ -520,6 +521,11 @@ public class ZipFile implements ZipConstants
private long bufferOffset;
private int pos;
private long end;
+ // We may need to supply an extra dummy byte to our reader.
+ // See Inflater. We use a count here to simplify the logic
+ // elsewhere in this class. Note that we ignore the dummy
+ // byte in methods where we know it is not needed.
+ private int dummyByteCount;
public PartialInputStream(RandomAccessFile raf, int bufferSize)
throws IOException
@@ -540,8 +546,17 @@ public class ZipFile implements ZipConstants
{
synchronized (raf)
{
- raf.seek(bufferOffset);
- raf.readFully(buffer, 0, (int) Math.min(buffer.length, end - bufferOffset));
+ long len = end - bufferOffset;
+ if (len == 0 && dummyByteCount > 0)
+ {
+ buffer[0] = 0;
+ dummyByteCount = 0;
+ }
+ else
+ {
+ raf.seek(bufferOffset);
+ raf.readFully(buffer, 0, (int) Math.min(buffer.length, len));
+ }
}
}
@@ -555,7 +570,7 @@ public class ZipFile implements ZipConstants
public int read() throws IOException
{
- if (bufferOffset + pos >= end)
+ if (bufferOffset + pos >= end + dummyByteCount)
return -1;
if (pos == buffer.length)
{
@@ -569,9 +584,9 @@ public class ZipFile implements ZipConstants
public int read(byte[] b, int off, int len) throws IOException
{
- if (len > end - (bufferOffset + pos))
+ if (len > end + dummyByteCount - (bufferOffset + pos))
{
- len = (int) (end - (bufferOffset + pos));
+ len = (int) (end + dummyByteCount - (bufferOffset + pos));
if (len == 0)
return -1;
}
@@ -681,5 +696,10 @@ public class ZipFile implements ZipConstants
throw new AssertionError(uee);
}
}
+
+ public void addDummyByte()
+ {
+ dummyByteCount = 1;
+ }
}
}
diff --git a/javax/crypto/Cipher.java b/javax/crypto/Cipher.java
index 1f68ea605..1b56a07f4 100644
--- a/javax/crypto/Cipher.java
+++ b/javax/crypto/Cipher.java
@@ -639,13 +639,7 @@ public class Cipher
public final int getOutputSize(int inputLength) throws IllegalStateException
{
if (cipherSpi == null)
- {
- return inputLength;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException("neither encrypting nor decrypting");
- }
+ return inputLength;
return cipherSpi.engineGetOutputSize(inputLength);
}
diff --git a/javax/crypto/spec/SecretKeySpec.java b/javax/crypto/spec/SecretKeySpec.java
index 4caf51a46..86c4e05d4 100644
--- a/javax/crypto/spec/SecretKeySpec.java
+++ b/javax/crypto/spec/SecretKeySpec.java
@@ -133,14 +133,22 @@ public class SecretKeySpec implements KeySpec, SecretKey
public boolean equals(Object o)
{
- byte[] okey = ((SecretKeySpec) o).getEncoded();
- if (key.length != okey.length) return false;
- for (int i = 0; i < key.length; i++)
+ if (o instanceof SecretKeySpec)
{
- if (key[i] != okey[i])
+ byte[] okey = ((SecretKeySpec) o).getEncoded();
+ if (key.length != okey.length)
return false;
+ for (int i = 0; i < key.length; i++)
+ {
+ if (key[i] != okey[i])
+ return false;
+ }
+ return algorithm.equals(((SecretKeySpec) o).getAlgorithm());
+ }
+ else
+ {
+ return false;
}
- return algorithm.equals(((SecretKeySpec) o).getAlgorithm());
}
public int hashCode()
diff --git a/javax/management/ListenerNotFoundException.java b/javax/management/ListenerNotFoundException.java
new file mode 100644
index 000000000..ea3cb7416
--- /dev/null
+++ b/javax/management/ListenerNotFoundException.java
@@ -0,0 +1,75 @@
+/* ListenerNotFoundException.java -- Thrown when a listener does not exist.
+ 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 a requested listener does not exist.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ListenerNotFoundException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -7242605822448519061L;
+
+ /**
+ * Constructs a new <code>ListenerNotFoundException</code>.
+ */
+ public ListenerNotFoundException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>ListenerNotFoundException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public ListenerNotFoundException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/javax/management/MBeanFeatureInfo.java b/javax/management/MBeanFeatureInfo.java
index 72dc85996..df49ec50f 100644
--- a/javax/management/MBeanFeatureInfo.java
+++ b/javax/management/MBeanFeatureInfo.java
@@ -141,14 +141,14 @@ public class MBeanFeatureInfo
/**
* Returns the hashcode of the feature as
- * the multiplication of the hashcodes of
- * its name and description.
+ * the sum of the hashcodes of its name
+ * and description.
*
* @return the hashcode of this feature.
*/
public int hashCode()
{
- return name.hashCode() * description.hashCode();
+ return name.hashCode() + description.hashCode();
}
}
diff --git a/javax/management/MBeanInfo.java b/javax/management/MBeanInfo.java
index 3aad20e31..1fd3951f5 100644
--- a/javax/management/MBeanInfo.java
+++ b/javax/management/MBeanInfo.java
@@ -104,6 +104,13 @@ public class MBeanInfo
private String className;
/**
+ * Descriptions of the notifications emitted by the bean.
+ *
+ * @serial The bean's notifications.
+ */
+ private MBeanNotificationInfo[] notifications;
+
+ /**
* Returns a shallow clone of the information. This is
* simply a new copy of each string and a clone
* of each array, which still references the same objects,
@@ -149,4 +156,21 @@ public class MBeanInfo
return description;
}
+ /**
+ * Returns descriptions of each of the notifications emitted
+ * by this management bean. The returned value is a shallow
+ * copy of the notification array maintained by this instance.
+ * Hence, changing the elements of the returned array will not
+ * affect the notification array, and the elements (instances
+ * of the {@link MBeanNotificationInfo} class) are immutable.
+ *
+ * @return an array of {@link MBeanNotificationInfo} objects,
+ * representing the notifications emitted by this
+ * management bean.
+ */
+ public MBeanNotificationInfo[] getNotifications()
+ {
+ return (MBeanNotificationInfo[]) notifications.clone();
+ }
+
}
diff --git a/javax/management/MBeanNotificationInfo.java b/javax/management/MBeanNotificationInfo.java
new file mode 100644
index 000000000..b1950cdd9
--- /dev/null
+++ b/javax/management/MBeanNotificationInfo.java
@@ -0,0 +1,201 @@
+/* MBeanNotificationInfo.java -- Information about a bean's 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;
+
+import java.util.Arrays;
+
+/**
+ * <p>
+ * Describes the notifications emitted by a management bean.
+ * An instance of this class is specific to notifications
+ * involving a particular type of object. A new instance
+ * should be created for each Java class used for notifications,
+ * and the Java class name forms the name of the instance.
+ * Each instance lists a number of notification types; these
+ * are not types in the sense of different Java classes, but
+ * instead form the names of notifications following the same
+ * syntax as Java property and package names.
+ * </p>
+ * <p>
+ * For instance, a management bean may emit two notifications
+ * containing {@link java.lang.String} objects. Both would be described
+ * using one instance of this class, with a member of the array
+ * returned by {@link #getNotifTypes()} for each one. If another
+ * notification containing a {@link java.util.Date} object were to
+ * be added, this would require a new instance of this class.
+ * </p>
+ * <p>
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanNotificationInfo
+ extends MBeanFeatureInfo
+ implements Cloneable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -3888371564530107064L;
+
+ /**
+ * The types of notification described by this instance.
+ *
+ * @serial the types of notification.
+ */
+ private String[] types;
+
+ /**
+ * Constructs a new {@link MBeanNotificationInfo} with the
+ * specified name, description and notification types. The
+ * notification types array may be <code>null</code> or of
+ * zero length, in order to indicate the absence of any types.
+ *
+ * @param types an array of {@link java.lang.String} objects,
+ * containing the names of the notifications emitted
+ * of this Java type. The names use the dot notation
+ * familiar from Java property and package names.
+ * @param name the name of the Java class the notifications described
+ * by this object are instances of.
+ * @param description a description of the data.
+ * @throws IllegalArgumentException for some reason...
+ */
+ public MBeanNotificationInfo(String[] types, String name,
+ String description)
+ {
+ super(name, description);
+ this.types = types;
+ }
+
+ /**
+ * Returns a clone of this instance. The clone is created
+ * using just the method provided by {@link java.lang.Object}.
+ * Thus, the clone is just a shallow clone as returned by
+ * that method, and does not contain any deeper cloning based
+ * on the subject of this class.
+ *
+ * @return a clone of this instance.
+ * @see java.lang.Cloneable
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ /* This shouldn't happen; we implement Cloneable */
+ throw new IllegalStateException("clone() called on " +
+ "non-cloneable object.");
+ }
+ }
+
+ /**
+ * Compares this feature with the supplied object. This
+ * returns true iff the object is an instance of
+ * {@link MBeanNotificationInfo}, {@link Object#equals()}
+ * returns true for a comparison of both the name and
+ * description of this notification with that of the specified
+ * object, and the two notification type arrays contain the
+ * same elements in the same order (but one may be longer than
+ * the other).
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link MBeanNotificationInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>description.equals(object.getDescription</code>
+ * and the corresponding elements of the type arrays are
+ * equal.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof MBeanNotificationInfo)
+ {
+ if (!(super.equals(obj)))
+ return false;
+ MBeanNotificationInfo o = (MBeanNotificationInfo) obj;
+ String[] oTypes = o.getNotifTypes();
+ for (int a = 0; a < types.length; ++a)
+ {
+ if (a == oTypes.length)
+ return true;
+ if (!(types[a].equals(oTypes[a])))
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Returns the notification types that the management bean
+ * may emit. The notification types are strings using the
+ * dot notation familiar from Java property and package
+ * names. Changing the returned array does not affect
+ * the values retained by this instance.
+ *
+ * @return the notification types.
+ */
+ public String[] getNotifTypes()
+ {
+ return types;
+ }
+
+ /**
+ * Returns the hashcode of the notification
+ * information as the sum of the hashcode of
+ * the superclass and the hashcode of the
+ * types array.
+ *
+ * @return the hashcode of the notification
+ * information.
+ */
+ public int hashCode()
+ {
+ return super.hashCode() + Arrays.hashCode(types);
+ }
+
+}
diff --git a/javax/management/Notification.java b/javax/management/Notification.java
new file mode 100644
index 000000000..52c11de06
--- /dev/null
+++ b/javax/management/Notification.java
@@ -0,0 +1,314 @@
+/* Notification.java -- A notification emitted by a bean.
+ 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.util.Date;
+import java.util.EventObject;
+
+/**
+ * <p>
+ * A notification message that may be emitted by a bean.
+ * Notifications have both a message and a type, so individual
+ * notifications can be grouped by type. They also incorporate
+ * sequencing, so that the recipient can order the delivered
+ * messages correctly (there is no guarantee that they will
+ * be delivered in order).
+ * </p>
+ * <p>
+ * Notifications also include a reference to the source of
+ * the notification. The source bean is represented either
+ * by an {@link ObjectName} or by a direct reference to the
+ * bean. The former is preferable, and notifications emitted
+ * via a {@link MBeanServer} will automatically have the source
+ * transformed into an {@link ObjectName}.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class Notification
+ extends EventObject
+{
+
+ /**
+ * The notification message.
+ *
+ * @serial the notification message.
+ */
+ private String message;
+
+ /**
+ * The notification's sequence number, relative to the notifications
+ * emitted by the bean.
+ *
+ * @serial the notification sequence number.
+ */
+ private long sequenceNumber;
+
+ /**
+ * The source of the notification. This is redeclared in order to
+ * replace the <code>source</code> variable in {@link java.util.EventObject}
+ * with a non-transient version.
+ *
+ * @serial the notification source.
+ */
+ protected Object source;
+
+ /**
+ * The time the notification was generated.
+ *
+ * @serial the notification timestamp.
+ */
+ private long timeStamp;
+
+ /**
+ * The type of notification sent. This utilises the same style
+ * as Java property and package names. For example,
+ * <code>gnu.gcj.compiler</code> may be one type of notifications.
+ *
+ * @serial the notification type.
+ */
+ private String type;
+
+ /**
+ * The user data associated with the notification. This includes
+ * any additional data which should be transmitted with the notification,
+ * but can't be achieved using the {@link java.lang.String} format
+ * of the <code>message</code>.
+ *
+ * @serial the notification user data.
+ */
+ private Object userData;
+
+ /**
+ * Creates a new {@link Notification} object with the specified type,
+ * source and sequence number. The timestamp is created using the
+ * current date and time.
+ *
+ * @param type the type of the notification.
+ * @param source the source of the notification.
+ * @param sequenceNumber the sequence number of the notifcation.
+ */
+ public Notification(String type, Object source, long sequenceNumber)
+ {
+ this(type, source, sequenceNumber, new Date().getTime());
+ }
+
+ /**
+ * Creates a new {@link Notification} object with the specified type,
+ * source, sequence number and timestamp.
+ *
+ * @param type the type of the notification.
+ * @param source the source of the notification.
+ * @param sequenceNumber the sequence number of the notifcation.
+ * @param timeStamp the time the notification was emitted.
+ */
+ public Notification(String type, Object source, long sequenceNumber,
+ long timeStamp)
+ {
+ this(type, source, sequenceNumber, timeStamp, null);
+ }
+
+ /**
+ * Creates a new {@link Notification} object with the specified type,
+ * source, sequence number, timestamp and message.
+ *
+ * @param type the type of the notification.
+ * @param source the source of the notification.
+ * @param sequenceNumber the sequence number of the notifcation.
+ * @param timeStamp the time the notification was emitted.
+ * @param message the message contained in the notification.
+ */
+ public Notification(String type, Object source, long sequenceNumber,
+ long timeStamp, String message)
+ {
+ super(source);
+ this.type = type;
+ this.sequenceNumber = sequenceNumber;
+ this.timeStamp = timeStamp;
+ this.message = message;
+ }
+
+ /**
+ * Creates a new {@link Notification} object with the specified type,
+ * source, sequence number and message. The timestamp is created using
+ * the current date and time.
+ *
+ * @param type the type of the notification.
+ * @param source the source of the notification.
+ * @param sequenceNumber the sequence number of the notifcation.
+ * @param message the message contained in the notification.
+ */
+ public Notification(String type, Object source, long sequenceNumber,
+ String message)
+ {
+ this(type, source, sequenceNumber, new Date().getTime(), message);
+ }
+
+ /**
+ * Returns the message contained in this notification. The message
+ * is in {@link java.lang.String} form, and is thus intended for
+ * display to the end-user. Data transferred as part of the notification
+ * which shouldn't be displayed is included in the <code>userData</code>
+ * field.
+ *
+ * @return the notification message.
+ * @see #getUserData()
+ * @see #setUserData(java.lang.Object)
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Returns the sequence number of this notification. This
+ * can be used to determine the order in which notifications
+ * were emitted by the broadcasting bean.
+ *
+ * @return the sequence number.
+ * @see #setSequenceNumber(long)
+ */
+ public long getSequenceNumber()
+ {
+ return sequenceNumber;
+ }
+
+ /**
+ * Returns the date and time at which this notification was
+ * emitted.
+ *
+ * @return the notification timestamp.
+ * @see #setTimeStamp(long)
+ */
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ /**
+ * Returns the type of this notification. Types take the same
+ * form as Java package and property names.
+ *
+ * @return the type of the notification.
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * Returns the additional user data associated with the notification.
+ * This is used to attach additional non-textual information to the
+ * notification.
+ *
+ * @return the user data associated with the notification.
+ * @see #setUserData(java.lang.Object)
+ */
+ public Object getUserData()
+ {
+ return userData;
+ }
+
+ /**
+ * Sets the sequence number to the value specified.
+ *
+ * @param sequenceNumber the new sequence number.
+ * @see #getSequenceNumber()
+ */
+ public void setSequenceNumber(long sequenceNumber)
+ {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ /**
+ * Sets the source of this notification to the value
+ * specified.
+ *
+ * @param source the new source of the notification.
+ * @see java.util.EventSource#getSource()
+ */
+ public void setSource(Object source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Sets the date and time at which this notification
+ * was emitted.
+ *
+ * @param timeStamp the new time stamp of the notification.
+ * @see #getTimeStamp()
+ */
+ public void setTimeStamp(long timeStamp)
+ {
+ this.timeStamp = timeStamp;
+ }
+
+ /**
+ * Sets the additional user data associated with the notification
+ * to the specified value. This is used to attach additional
+ * non-textual information to the notification.
+ *
+ * @param userData the new user data associated with the notification.
+ * @see #getUserData()
+ */
+ public void setUserData(Object userData)
+ {
+ this.userData = userData;
+ }
+
+ /**
+ * A textual representation of the notification.
+ *
+ * @return the notification in {@link java.lang.String} form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[message=" + message
+ + ", sequenceNumber=" + sequenceNumber
+ + ", source=" + source
+ + ", timeStamp=" + timeStamp
+ + ", type=" + type
+ + ", userData=" + userData
+ + "]";
+ }
+
+}
+
diff --git a/javax/management/NotificationBroadcaster.java b/javax/management/NotificationBroadcaster.java
new file mode 100644
index 000000000..139d842bb
--- /dev/null
+++ b/javax/management/NotificationBroadcaster.java
@@ -0,0 +1,112 @@
+/* NotificationBroadcaster.java -- Interface for broadcasters.
+ 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;
+
+/**
+ * <p>
+ * Represents a bean that can emit notifications when
+ * events occur. Other beans can use this interface
+ * to add themselves to the list of recipients of such
+ * notifications.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: New classes should use
+ * {@link NotificationEmitter}, a subinterface of this,
+ * in preference to using this interface directly.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationBroadcaster
+{
+
+ /**
+ * Registers the specified listener as a new recipient of
+ * notifications from this bean. 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)
+ */
+ void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws IllegalArgumentException;
+
+ /**
+ * 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.
+ */
+ MBeanNotificationInfo[] getNotificationInfo();
+
+ /**
+ * 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 the subinterface
+ * {@link NotificationEmitter}.
+ *
+ * @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)
+ */
+ void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException;
+
+}
+
diff --git a/javax/management/NotificationEmitter.java b/javax/management/NotificationEmitter.java
new file mode 100644
index 000000000..002e2fe18
--- /dev/null
+++ b/javax/management/NotificationEmitter.java
@@ -0,0 +1,76 @@
+/* NotificationEmitter.java -- Refined interface for broadcasters.
+ 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;
+
+/**
+ * Represents a bean that can emit notifications when
+ * events occur. Other beans can use this interface
+ * to add themselves to the list of recipients of such
+ * notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationEmitter
+ extends NotificationBroadcaster
+{
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from this 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 the details
+ * of the same method in {@link NotificationBroadcaster}.
+ *
+ * @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)
+ */
+ void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws ListenerNotFoundException;
+
+}
+
diff --git a/javax/management/NotificationFilter.java b/javax/management/NotificationFilter.java
new file mode 100644
index 000000000..a8e41c93f
--- /dev/null
+++ b/javax/management/NotificationFilter.java
@@ -0,0 +1,66 @@
+/* NotificationFilter.java -- Interface for notification filters.
+ 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 a object that acts as a filter for notifications.
+ * Implementations of this class are used to determine which
+ * notifications should be passed to a receiving bean, and which
+ * should not.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationFilter
+ extends Serializable
+{
+
+ /**
+ * Returns true if the specified notification should be passed
+ * on to the listener.
+ *
+ * @param notification the notification being delivered.
+ * @return true if the notification should be passed to the
+ * listener, false otherwise.
+ */
+ boolean isNotificationEnabled(Notification notification);
+
+}
+
diff --git a/javax/management/NotificationListener.java b/javax/management/NotificationListener.java
new file mode 100644
index 000000000..69b08eee3
--- /dev/null
+++ b/javax/management/NotificationListener.java
@@ -0,0 +1,70 @@
+/* NotificationListener.java -- Interface for receivers of notifications.
+ 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.util.EventListener;
+
+/**
+ * Represents a object that can receive notifications from
+ * a bean.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface NotificationListener
+ extends EventListener
+{
+
+ /**
+ * Invoked by the notifying bean when a notification is to
+ * be delivered to the recipient. As the transmission of
+ * notifications takes place sequentially, implementors of
+ * this method should avoid performing lengthy operations,
+ * as the notifying bean will stall until the method is
+ * complete.
+ *
+ * @param notification the notification from the bean.
+ * @param passback the object that was passed to the notifying
+ * bean as part of the registration process.
+ * @see NotificationBroadcaster#addListener(NotificationListener,
+ * NotificationFilter, Object)
+ */
+ void handleNotification(Notification notification, Object passback);
+
+}
+
diff --git a/javax/management/OperationsException.java b/javax/management/OperationsException.java
index 33be4bb01..cbd90d637 100644
--- a/javax/management/OperationsException.java
+++ b/javax/management/OperationsException.java
@@ -49,6 +49,11 @@ public class OperationsException
{
/**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -4967597595580536216L;
+
+ /**
* Constructs a new <code>OperationsException</code>.
*/
public OperationsException()
diff --git a/javax/rmi/ssl/SslRMIClientSocketFactory.java b/javax/rmi/ssl/SslRMIClientSocketFactory.java
new file mode 100644
index 000000000..1fed5824c
--- /dev/null
+++ b/javax/rmi/ssl/SslRMIClientSocketFactory.java
@@ -0,0 +1,166 @@
+/* SslRMIClientSocketFactory.java --
+ 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 javax.rmi.ssl;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import java.util.StringTokenizer;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.SSLSocket;
+import java.net.Socket;
+import java.rmi.server.RMIClientSocketFactory;
+
+/**
+ * SslRMIClientSocketFactory
+ *
+ * This class implements an RMIClientSocketFactory for SSL sockets.
+ * it uses the defeult SSLClientSocketFactory.
+ *
+ * This class can optionally use the following system properties, if set:
+ * <code>javax.rmi.ssl.client.enabledCipherSuites</code>
+ * <code>javax.rmi.ssl.client.enabledProtocols</code>
+ *
+ * These properties will specify a list of SSL/TLS cipher suites and protocols,
+ * respectively, to enable on the created sockets.
+ *
+ * Both properties should consist of a comma-separated list.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public class SslRMIClientSocketFactory
+ implements RMIClientSocketFactory, Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -8310631444933958385L;
+
+ private String[] enabledCipherSuites, enabledProtocols;
+
+ /**
+ * The SSL Socket factory.
+ */
+ private static SSLSocketFactory socketFactory =
+ (SSLSocketFactory)SSLSocketFactory.getDefault();
+
+ /**
+ * Creates a new SslRMIClientSocketFactory
+ */
+ public SslRMIClientSocketFactory()
+ {
+ enabledCipherSuites = getProp("javax.rmi.ssl.client.enabledCipherSuites");
+ enabledProtocols = getProp("javax.rmi.ssl.client.enabledProtocols");
+ }
+
+ private String[] getProp(String p)
+ {
+ StringTokenizer st;
+ try
+ {
+ String o = (String)System.getProperty( p );
+ st = new StringTokenizer( o, "," );
+ }
+ catch(SecurityException se)
+ {
+ return null;
+ }
+
+ int n = st.countTokens();
+ if( n < 1 )
+ return null;
+ String[] strs = new String[ n ];
+ for( int i = 0; i < n; i++ )
+ strs[i] = st.nextToken().trim();
+
+ return strs;
+ }
+
+ /**
+ * Creates an SSLSocket on a given port
+ *
+ * @throws IOException if an error occurs on socket creation.
+ */
+ public Socket createSocket(String host, int port) throws IOException
+ {
+ SSLSocket socket = (SSLSocket)socketFactory.
+ createSocket( host, port );
+ if( enabledCipherSuites != null )
+ socket.setEnabledCipherSuites( enabledCipherSuites );
+ if( enabledProtocols != null )
+ socket.setEnabledProtocols( enabledProtocols );
+ return socket;
+ }
+
+ /**
+ * Compare two SslRMIServerSocketFactor instances
+ */
+ public boolean equals(Object obj)
+ {
+ if( !(obj instanceof SslRMIClientSocketFactory) )
+ return false;
+ SslRMIClientSocketFactory s = (SslRMIClientSocketFactory)obj;
+
+ if(!SslRMIServerSocketFactory.
+ cmpStrArray(enabledCipherSuites, s.enabledCipherSuites))
+ return false;
+
+ if(!SslRMIServerSocketFactory.
+ cmpStrArray(enabledProtocols, s.enabledProtocols))
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Returns the hash code of this object.
+ */
+ public int hashCode()
+ {
+ int hash = 0;
+ if( enabledCipherSuites != null )
+ for(int i = 0; i < enabledCipherSuites.length; i++ )
+ hash = hash ^ enabledCipherSuites[i].hashCode();
+ if( enabledProtocols != null )
+ for(int i = 0; i < enabledProtocols.length; i++ )
+ hash = hash ^ enabledProtocols[i].hashCode();
+ return hash;
+ }
+}
diff --git a/javax/rmi/ssl/SslRMIServerSocketFactory.java b/javax/rmi/ssl/SslRMIServerSocketFactory.java
new file mode 100644
index 000000000..56f6de11c
--- /dev/null
+++ b/javax/rmi/ssl/SslRMIServerSocketFactory.java
@@ -0,0 +1,213 @@
+/* SslRMIServerSocketFactory.java --
+ 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 javax.rmi.ssl;
+
+import java.io.IOException;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLServerSocket;
+import java.net.ServerSocket;
+import java.rmi.server.RMIServerSocketFactory;
+
+/**
+ * SslRMIServerSocketFactory
+ *
+ * This class implements an RMIServerSocketFactory for SSL sockets.
+ * it uses the defeult SSLServerSocketFactory.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public class SslRMIServerSocketFactory implements RMIServerSocketFactory
+{
+ private String[] enabledCipherSuites, enabledProtocols;
+ private boolean needClientAuth;
+
+ /**
+ * The SSL ServerSocket factory.
+ */
+ private static SSLServerSocketFactory socketFactory =
+ (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+
+ /**
+ * Creates a new SslRMIServerSocketFactory with the default socket
+ * cipher suites and protocols, and without requiring client authorisation.
+ */
+ public SslRMIServerSocketFactory()
+ {
+ enabledCipherSuites = enabledProtocols = null;
+ needClientAuth = false;
+ }
+
+ /**
+ * Creates a new SslRMIServerSocketFactory with a given set of socket
+ * cipher suites and protocols. needClientAuth specifies if client
+ * authorization is required.
+ *
+ * @param enabledCipherSuites - the cypher suites to enable
+ * or <code>null</code> for the defauls.
+ * @param enabledCipherSuites - the protocols to enable,
+ * or <code>null</code> for the defauls.
+ * @param needClientAuth - specify client authorization requirement.
+ * @throws IllegalArgumentException if any of the ciphers or protocols
+ * specified are not available.
+ */
+ public SslRMIServerSocketFactory(String[] enabledCipherSuites,
+ String[] enabledProtocols,
+ boolean needClientAuth)
+ {
+ this.enabledCipherSuites = enabledCipherSuites;
+ this.enabledProtocols = enabledProtocols;
+ this.needClientAuth = needClientAuth;
+ try
+ {
+ if( enabledProtocols != null || enabledCipherSuites != null )
+ createServerSocket( 0 ); // stupid way to test the parameters
+ }
+ catch(IOException e)
+ {
+ // Can this happen? FIXME.
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Creates an SSLServerSocket on a given port
+ *
+ * @throws IOException if an error occurs on socket creation.
+ */
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ SSLServerSocket socket = (SSLServerSocket)socketFactory.
+ createServerSocket( port );
+ if( enabledCipherSuites != null )
+ socket.setEnabledCipherSuites( enabledCipherSuites );
+ if( enabledProtocols != null )
+ socket.setEnabledProtocols( enabledProtocols );
+ socket.setNeedClientAuth( needClientAuth );
+ return socket;
+ }
+
+ /**
+ * Compare two SslRMIServerSocketFactor instances
+ */
+ public boolean equals(Object obj)
+ {
+ if( !(obj instanceof SslRMIServerSocketFactory) )
+ return false;
+ SslRMIServerSocketFactory s = (SslRMIServerSocketFactory)obj;
+ if( needClientAuth != s.needClientAuth )
+ return false;
+
+ if(!cmpStrArray(enabledCipherSuites, s.enabledCipherSuites))
+ return false;
+
+ if(!cmpStrArray(enabledProtocols, s.enabledProtocols))
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Compare two string arrays.
+ */
+ static boolean cmpStrArray(String[] a, String[] b)
+ {
+ if( ( a == null || b == null ) && a != b )
+ return false;
+
+ if( a != null )
+ {
+ if( a.length != b.length )
+ return false;
+ for( int i = 0; i < a.length; i++ )
+ if(!a[i].equals(b[i]))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the enabled cipher suites, or <code>null</code>
+ * if the defaults are to be used.
+ * @returns a string array of cipher suite names
+ */
+ public String[] getEnabledCipherSuites()
+ {
+ if( enabledCipherSuites == null )
+ return null;
+ return (String[])enabledCipherSuites.clone();
+ }
+
+ /**
+ * Returns the enabled protocols, or <code>null</code> if the defaults are
+ * to be used.
+ *
+ * @returns a string array of protocol names
+ */
+ public String[] getEnabledProtocols()
+ {
+ if( enabledProtocols == null )
+ return null;
+ return (String[])enabledProtocols.clone();
+ }
+
+ /**
+ * Returns whether client authorization is needed.
+ */
+ public boolean getNeedClientAuth()
+ {
+ return needClientAuth;
+ }
+
+ /**
+ * Returns the hash code of this object.
+ */
+ public int hashCode()
+ {
+ int hash = 0;
+ if( enabledCipherSuites != null )
+ for(int i = 0; i < enabledCipherSuites.length; i++ )
+ hash = hash ^ enabledCipherSuites[i].hashCode();
+ if( enabledProtocols != null )
+ for(int i = 0; i < enabledProtocols.length; i++ )
+ hash = hash ^ enabledProtocols[i].hashCode();
+ hash = ( needClientAuth ) ? (hash^0xFFFF) : hash;
+ return hash;
+ }
+} \ No newline at end of file
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index a9ec0c037..63f827a1a 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -199,7 +199,7 @@ public abstract class AbstractButton extends JComponent
Icon pressed_icon;
/** The icon displayed when the button is disabled. */
- Icon disabeldIcon;
+ Icon disabledIcon;
/** The icon displayed when the button is selected. */
Icon selectedIcon;
@@ -1364,6 +1364,9 @@ public abstract class AbstractButton extends JComponent
{
if (horizontalTextPosition == t)
return;
+ if (t != LEFT && t != CENTER && t != RIGHT && t != LEADING
+ && t != TRAILING)
+ throw new IllegalArgumentException("Invalid alignment.");
int old = horizontalTextPosition;
horizontalTextPosition = t;
@@ -1442,6 +1445,8 @@ public abstract class AbstractButton extends JComponent
{
if (verticalTextPosition == t)
return;
+ if (t != TOP && t != CENTER && t != BOTTOM)
+ throw new IllegalArgumentException("Invalid alignment.");
int old = verticalTextPosition;
verticalTextPosition = t;
@@ -1720,14 +1725,14 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getDisabledIcon()
{
- if (disabeldIcon == null && default_icon instanceof ImageIcon)
+ if (disabledIcon == null && default_icon instanceof ImageIcon)
{
Image iconImage = ((ImageIcon) default_icon).getImage();
Image grayImage = GrayFilter.createDisabledImage(iconImage);
- disabeldIcon = new ImageIcon(grayImage);
+ disabledIcon = new ImageIcon(grayImage);
}
- return disabeldIcon;
+ return disabledIcon;
}
/**
@@ -1741,7 +1746,11 @@ public abstract class AbstractButton extends JComponent
*/
public void setDisabledIcon(Icon d)
{
- disabeldIcon = d;
+ if (disabledIcon == d)
+ return;
+ Icon old = disabledIcon;
+ disabledIcon = d;
+ firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, old, d);
revalidate();
repaint();
}
diff --git a/javax/swing/ButtonGroup.java b/javax/swing/ButtonGroup.java
index 3d11713cf..70ec4ad8a 100644
--- a/javax/swing/ButtonGroup.java
+++ b/javax/swing/ButtonGroup.java
@@ -1,5 +1,5 @@
/* ButtonGroup.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,10 +65,9 @@ import java.util.Vector;
*/
public class ButtonGroup implements Serializable
{
- /** DOCUMENT ME! */
private static final long serialVersionUID = 4259076101881721375L;
- /** The buttons added to this button group. */
+ /** Stores references to the buttons added to this button group. */
protected Vector<AbstractButton> buttons = new Vector<AbstractButton>();
/** The currently selected button model. */
@@ -83,12 +82,20 @@ public class ButtonGroup implements Serializable
}
/**
- * Adds a button to this group.
+ * Adds a button to this group. If the button is in the selected state, then:
+ * <ul>
+ * <li>if the group has no current selection, the new button becomes the
+ * selected button for the group;</li>
+ * <li>if the group already has a selected button, the new button is set to
+ * "not selected".</li>
+ * </ul>
*
- * @param b the button to add
+ * @param b the button to add (<code>null</code> is ignored).
*/
public void add(AbstractButton b)
{
+ if (b == null)
+ return;
b.getModel().setGroup(this);
if (b.isSelected())
{
@@ -96,17 +103,24 @@ public class ButtonGroup implements Serializable
sel = b.getModel();
else
b.setSelected(false);
- } buttons.addElement(b);
+ }
+ buttons.addElement(b);
}
/**
- * Removed a given button from this group.
+ * Removes the specified button from this group. If the button is the
+ * selected button, the current selection is set to <code>null</code>.
+ * The group for the removed button's model is set to <code>null</code>.
*
- * @param b the button to remove
+ * @param b the button to remove (<code>null</code> is ignored).
*/
public void remove(AbstractButton b)
{
+ if (b == null)
+ return;
b.getModel().setGroup(null);
+ if (b.getModel() == sel)
+ sel = null;
buttons.removeElement(b);
}
@@ -132,19 +146,20 @@ public class ButtonGroup implements Serializable
}
/**
- * DOCUMENT ME!
+ * Returns the button that has the specified model, or <code>null</code> if
+ * there is no such button in the group.
*
- * @param m DOCUMENT ME!
+ * @param m the button model.
*
- * @return DOCUMENT ME!
+ * @return The button that has the specified model, or <code>null</code>.
*/
- AbstractButton FindButton(ButtonModel m)
+ AbstractButton findButton(ButtonModel m)
{
for (int i = 0; i < buttons.size(); i++)
{
- AbstractButton a = (AbstractButton) buttons.get(i);
- if (a.getModel() == m)
- return a;
+ AbstractButton a = (AbstractButton) buttons.get(i);
+ if (a.getModel() == m)
+ return a;
}
return null;
}
@@ -168,7 +183,7 @@ public class ButtonGroup implements Serializable
if (old != null)
old.setSelected(false);
- AbstractButton button = FindButton(old);
+ AbstractButton button = findButton(old);
if (button != null)
button.repaint();
}
@@ -180,10 +195,10 @@ public class ButtonGroup implements Serializable
* Checks if the given <code>ButtonModel</code> is selected in this button
* group.
*
- * @param m DOCUMENT ME!
+ * @param m the button model (<code>null</code> permitted).
*
- * @return true of given <code>ButtonModel</code> is selected, false
- * otherwise
+ * @return <code>true</code> if <code>m</code> is the selected button model
+ * in this group, and <code>false</code> otherwise.
*/
public boolean isSelected(ButtonModel m)
{
diff --git a/javax/swing/DefaultBoundedRangeModel.java b/javax/swing/DefaultBoundedRangeModel.java
index 88026efa7..786e4ee92 100644
--- a/javax/swing/DefaultBoundedRangeModel.java
+++ b/javax/swing/DefaultBoundedRangeModel.java
@@ -1,6 +1,6 @@
/* DefaultBoundedRangeModel.java -- Default implementation
of BoundedRangeModel.
- 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.
@@ -39,6 +39,9 @@ exception statement from your version. */
package javax.swing;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.EventListener;
@@ -440,4 +443,33 @@ public class DefaultBoundedRangeModel
{
return (ChangeListener[]) getListeners(ChangeListener.class);
}
+
+ /**
+ * Provides serialization support.
+ *
+ * @param stream the output stream (<code>null</code> not permitted).
+ *
+ * @throws IOException if there is an I/O error.
+ */
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException
+ {
+ stream.defaultWriteObject();
+ }
+
+ /**
+ * Provides serialization support.
+ *
+ * @param stream the input stream (<code>null</code> not permitted).
+ *
+ * @throws IOException if there is an I/O error.
+ * @throws ClassNotFoundException if there is a classpath problem.
+ */
+ private void readObject(ObjectInputStream stream)
+ throws ClassNotFoundException, IOException
+ {
+ stream.defaultReadObject();
+ listenerList = new EventListenerList();
+ }
+
}
diff --git a/javax/swing/JFileChooser.java b/javax/swing/JFileChooser.java
index 64f9bd0f4..a508b8fcb 100644
--- a/javax/swing/JFileChooser.java
+++ b/javax/swing/JFileChooser.java
@@ -43,6 +43,8 @@ import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowAdapter;
import java.beans.PropertyChangeEvent;
import java.io.File;
import java.util.ArrayList;
@@ -351,7 +353,7 @@ public class JFileChooser extends JComponent implements Accessible
* The file selection mode.
* @see #setFileSelectionMode(int)
*/
- private int fileSelectionMode = FILES_AND_DIRECTORIES;
+ private int fileSelectionMode = FILES_ONLY;
/**
* The file view.
@@ -744,10 +746,16 @@ public class JFileChooser extends JComponent implements Accessible
JDialog dialog = new JDialog(toUse);
setSelectedFile(null);
dialog.getContentPane().add(this);
+ dialog.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ cancelSelection();
+ }
+ });
dialog.setModal(true);
dialog.invalidate();
dialog.repaint();
-
return dialog;
}
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index f61ce47da..026d1b899 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -3468,6 +3468,8 @@ public class JTable
* Get the value of the {@link #rowSelectionAllowed} property.
*
* @return The current value of the property
+ *
+ * @see #setRowSelectionAllowed(boolean)
*/
public boolean getRowSelectionAllowed()
{
@@ -3621,6 +3623,8 @@ public class JTable
* Get the value of the <code>columnSelectionAllowed</code> property.
*
* @return The current value of the columnSelectionAllowed property
+ *
+ * @see #setColumnSelectionAllowed(boolean)
*/
public boolean getColumnSelectionAllowed()
{
@@ -3874,11 +3878,17 @@ public class JTable
* Set the value of the {@link #rowSelectionAllowed} property.
*
* @param r The new value of the rowSelectionAllowed property
+ *
+ * @see #getRowSelectionAllowed()
*/
public void setRowSelectionAllowed(boolean r)
{
- rowSelectionAllowed = r;
- repaint();
+ if (rowSelectionAllowed != r)
+ {
+ rowSelectionAllowed = r;
+ firePropertyChange("rowSelectionAllowed", !r, r);
+ repaint();
+ }
}
/**
@@ -3988,11 +3998,17 @@ public class JTable
* Set the value of the <code>columnSelectionAllowed</code> property.
*
* @param c The new value of the property
+ *
+ * @see #getColumnSelectionAllowed()
*/
public void setColumnSelectionAllowed(boolean c)
{
- getColumnModel().setColumnSelectionAllowed(c);
- repaint();
+ if (columnModel.getColumnSelectionAllowed() != c)
+ {
+ columnModel.setColumnSelectionAllowed(c);
+ firePropertyChange("columnSelectionAllowed", !c, c);
+ repaint();
+ }
}
/**
diff --git a/javax/swing/plaf/basic/BasicDirectoryModel.java b/javax/swing/plaf/basic/BasicDirectoryModel.java
index 0c46a5112..058f5586e 100644
--- a/javax/swing/plaf/basic/BasicDirectoryModel.java
+++ b/javax/swing/plaf/basic/BasicDirectoryModel.java
@@ -1,5 +1,5 @@
/* BasicDirectoryModel.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,24 +51,29 @@ import javax.swing.filechooser.FileSystemView;
/**
- * DOCUMENT ME!
+ * Implements an AbstractListModel for directories where the source
+ * of the files is a JFileChooser object.
+ *
+ * This class is used for sorting and ordering the file list in
+ * a JFileChooser L&F object.
*/
public class BasicDirectoryModel extends AbstractListModel
implements PropertyChangeListener
{
- /** DOCUMENT ME! */
+ /** The list of files itself */
private Vector contents;
- /** DOCUMENT ME! */
+ /** The number of directories in the list */
private int directories;
- /** DOCUMENT ME! */
+ /** The listing mode of the associated JFileChooser,
+ either FILES_ONLY, DIRECTORIES_ONLY or FILES_AND_DIRECTORIES */
private int listingMode;
- /** DOCUMENT ME! */
+ /** The JFileCooser associated with this model */
private JFileChooser filechooser;
- /** DOCUMENT ME! */
+ /** A Comparator class/object for sorting the file list. */
private Comparator comparator = new Comparator()
{
public int compare(Object o1, Object o2)
@@ -91,14 +96,15 @@ public class BasicDirectoryModel extends AbstractListModel
filechooser.addPropertyChangeListener(this);
listingMode = filechooser.getFileSelectionMode();
contents = new Vector();
+ validateFileCache();
}
/**
- * DOCUMENT ME!
+ * Returns whether a given (File) object is included in the list.
*
- * @param o DOCUMENT ME!
+ * @param o - The file object to test.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the list contains the given object.
*/
public boolean contains(Object o)
{
@@ -106,7 +112,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Fires a content change event.
*/
public void fireContentsChanged()
{
@@ -114,9 +120,10 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Returns a Vector of (java.io.File) objects containing
+ * the directories in this list.
*
- * @return DOCUMENT ME!
+ * @return a Vector
*/
public Vector<File> getDirectories()
{
@@ -127,26 +134,24 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Returns the (java.io.File) object at
+ * an index in the list.
*
- * @param index DOCUMENT ME!
- *
- * @return DOCUMENT ME!
+ * @param index The list index
+ * @return a File object
*/
public Object getElementAt(int index)
{
if (index > getSize() - 1)
return null;
- if (listingMode == JFileChooser.FILES_ONLY)
- return contents.get(directories + index);
- else
- return contents.elementAt(index);
+ return contents.elementAt(index);
}
/**
- * DOCUMENT ME!
+ * Returns a Vector of (java.io.File) objects containing
+ * the files in this list.
*
- * @return DOCUMENT ME!
+ * @return a Vector
*/
public Vector<File> getFiles()
{
@@ -157,37 +162,34 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Returns the size of the list, which only includes directories
+ * if the JFileChooser is set to DIRECTORIES_ONLY.
+ *
+ * Otherwise, both directories and files are included in the count.
*
- * @return DOCUMENT ME!
+ * @return The size of the list.
*/
public int getSize()
{
if (listingMode == JFileChooser.DIRECTORIES_ONLY)
return directories;
- else if (listingMode == JFileChooser.FILES_ONLY)
- return contents.size() - directories;
return contents.size();
}
/**
- * DOCUMENT ME!
+ * Returns the index of an (java.io.File) object in the list.
*
- * @param o DOCUMENT ME!
+ * @param o The object - normally a File.
*
- * @return DOCUMENT ME!
+ * @return the index of that object, or -1 if it is not in the list.
*/
public int indexOf(Object o)
{
- if (listingMode == JFileChooser.FILES_ONLY)
- return contents.indexOf(o) - directories;
return contents.indexOf(o);
}
/**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ * Obsoleted method which does nothing.
*/
public void intervalAdded(ListDataEvent e)
{
@@ -195,9 +197,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ * Obsoleted method which does nothing.
*/
public void intervalRemoved(ListDataEvent e)
{
@@ -205,7 +205,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Obsoleted method which does nothing.
*/
public void invalidateFileCache()
{
@@ -213,12 +213,16 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Less than, determine the relative order in the list of two files
+ * for sorting purposes.
*
- * @param a DOCUMENT ME!
- * @param b DOCUMENT ME!
+ * The order is: directories < files, and thereafter alphabetically,
+ * using the default locale collation.
*
- * @return DOCUMENT ME!
+ * @param a the first file
+ * @param b the second file
+ *
+ * @return <code>true</code> if a > b, <code>false</code> if a < b.
*/
protected boolean lt(File a, File b)
{
@@ -241,34 +245,38 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Listens for a property change; the change in file selection mode of the
+ * associated JFileChooser. Reloads the file cache on that event.
*
- * @param e DOCUMENT ME!
+ * @param e - A PropertyChangeEvent.
*/
public void propertyChange(PropertyChangeEvent e)
{
if (e.getPropertyName().equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY))
- listingMode = filechooser.getFileSelectionMode();
+ {
+ listingMode = filechooser.getFileSelectionMode();
+ validateFileCache();
+ }
}
/**
- * DOCUMENT ME!
+ * Renames a file - However, does <I>not</I> re-sort the list
+ * or replace the old file with the new one in the list.
*
- * @param oldFile DOCUMENT ME!
- * @param newFile DOCUMENT ME!
+ * @param oldFile The old file
+ * @param newFile The new file name
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the rename succeeded
*/
public boolean renameFile(File oldFile, File newFile)
{
- // FIXME: implement
- return false;
+ return oldFile.renameTo( newFile );
}
/**
- * DOCUMENT ME!
+ * Sorts a Vector of File objects.
*
- * @param v DOCUMENT ME!
+ * @param v The Vector to sort.
*/
protected void sort(Vector<? extends File> v)
{
@@ -282,10 +290,13 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Re-loads the list of files
*/
public void validateFileCache()
{
+ // FIXME: Get the files and sort them in a seperate thread and deliver
+ // them a few at a time to be filtered, so that the file selector is
+ // responsive even with long file lists.
contents.clear();
directories = 0;
FileSystemView fsv = filechooser.getFileSystemView();
@@ -299,15 +310,19 @@ public class BasicDirectoryModel extends AbstractListModel
{
if (list[i] == null)
continue;
- if (filechooser.accept(list[i]))
- {
- contents.add(list[i]);
- if (filechooser.isTraversable(list[i]))
- directories++;
- }
+ boolean isDir = filechooser.isTraversable(list[i]);
+
+ if( listingMode != JFileChooser.DIRECTORIES_ONLY || isDir )
+ if (filechooser.accept(list[i]))
+ {
+ contents.add(list[i]);
+ if (isDir)
+ directories++;
+ }
}
sort(contents);
filechooser.revalidate();
filechooser.repaint();
}
}
+
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
index d97e0cf2b..f5b667299 100644
--- a/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -160,6 +160,8 @@ public class BasicFileChooserUI extends FileChooserUI
else
{
File f = new File(filechooser.getCurrentDirectory(), getFileName());
+ if ( selectedDir != null )
+ f = selectedDir;
if (filechooser.isTraversable(f))
{
filechooser.setCurrentDirectory(f);
@@ -409,7 +411,7 @@ public class BasicFileChooserUI extends FileChooserUI
closeDialog();
}
}
- else
+ else // single click
{
String path = p.toString();
File f = fsv.createFileObject(path);
@@ -436,10 +438,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
lastSelected = path;
parentPath = path.substring(0, path.lastIndexOf("/") + 1);
+
if (f.isFile())
setFileName(path.substring(path.lastIndexOf("/") + 1));
- else if (filechooser.getFileSelectionMode() ==
- JFileChooser.DIRECTORIES_ONLY)
+ else if (filechooser.getFileSelectionMode() !=
+ JFileChooser.FILES_ONLY)
setFileName(path);
}
}
@@ -538,7 +541,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the JFileChooser to the selected file on an update
*
* @param e DOCUMENT ME!
*/
@@ -550,9 +553,15 @@ public class BasicFileChooserUI extends FileChooserUI
return;
File file = filechooser.getFileSystemView().createFileObject(f.toString());
if (! filechooser.isTraversable(file))
- filechooser.setSelectedFile(file);
+ {
+ selectedDir = null;
+ filechooser.setSelectedFile(file);
+ }
else
- filechooser.setSelectedFile(null);
+ {
+ selectedDir = file;
+ filechooser.setSelectedFile(null);
+ }
}
}
@@ -752,6 +761,13 @@ public class BasicFileChooserUI extends FileChooserUI
* @see #getUpdateAction()
*/
private UpdateAction updateAction;
+
+ /**
+ * When in FILES_ONLY, mode a directory cannot be selected, so
+ * we save a reference to any it here. This is used to enter
+ * the directory on "Open" when in that mode.
+ */
+ private File selectedDir;
// -- end private --
diff --git a/javax/swing/plaf/metal/MetalFileChooserUI.java b/javax/swing/plaf/metal/MetalFileChooserUI.java
index 1219ad9fd..fc8024d7b 100644
--- a/javax/swing/plaf/metal/MetalFileChooserUI.java
+++ b/javax/swing/plaf/metal/MetalFileChooserUI.java
@@ -303,8 +303,9 @@ public class MetalFileChooserUI
if (file == null)
setFileName(null);
- else
- setFileName(file.getName());
+ else if (file.isFile() || filechooser.getFileSelectionMode()
+ != JFileChooser.FILES_ONLY)
+ setFileName(file.getName());
int index = -1;
index = getModel().indexOf(file);
if (index >= 0)
@@ -956,9 +957,12 @@ public class MetalFileChooserUI
{
String text = editField.getText();
if (text != null && text != "" && !text.equals(fc.getName(editFile)))
- if (editFile.renameTo(fc.getFileSystemView().createFileObject(
- fc.getCurrentDirectory(), text)))
+ {
+ File f = fc.getFileSystemView().
+ createFileObject(fc.getCurrentDirectory(), text);
+ if ( editFile.renameTo(f) )
rescanCurrentDirectory(fc);
+ }
list.remove(editField);
}
startEditing = false;
@@ -982,17 +986,8 @@ public class MetalFileChooserUI
*/
public void actionPerformed(ActionEvent e)
{
- if (e.getActionCommand().equals("notify-field-accept"))
+ if (editField != null)
completeEditing();
- else if (editField != null)
- {
- list.remove(editField);
- startEditing = false;
- editFile = null;
- lastSelected = null;
- editField = null;
- list.repaint();
- }
}
}
}
@@ -1101,7 +1096,7 @@ public class MetalFileChooserUI
lastSelected = selVal;
if (f.isFile())
setFileName(path.substring(path.lastIndexOf("/") + 1));
- else if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY)
+ else if (fc.getFileSelectionMode() != JFileChooser.FILES_ONLY)
setFileName(path);
}
fileTable.repaint();
@@ -1171,16 +1166,8 @@ public class MetalFileChooserUI
*/
public void actionPerformed(ActionEvent e)
{
- if (e.getActionCommand().equals("notify-field-accept"))
+ if (editField != null)
completeEditing();
- else if (editField != null)
- {
- table.remove(editField);
- startEditing = false;
- editFile = null;
- editField = null;
- table.repaint();
- }
}
}
diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java
index 354ec6c0c..f7b081c6a 100644
--- a/javax/swing/text/html/HTMLDocument.java
+++ b/javax/swing/text/html/HTMLDocument.java
@@ -40,14 +40,18 @@ package javax.swing.text.html;
import gnu.classpath.NotImplementedException;
import gnu.javax.swing.text.html.CharacterAttributeTranslator;
+import gnu.javax.swing.text.html.parser.htmlAttributeSet;
import java.io.IOException;
+import java.io.StringReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Stack;
import java.util.Vector;
import javax.swing.JEditorPane;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
@@ -515,19 +519,23 @@ public class HTMLDocument extends DefaultStyledDocument
*/
public class HTMLReader extends HTMLEditorKit.ParserCallback
{
- /** Holds the current character attribute set **/
+ /**
+ * Holds the current character attribute set *
+ */
protected MutableAttributeSet charAttr = new SimpleAttributeSet();
protected Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
- /** A stack for character attribute sets **/
+ /**
+ * A stack for character attribute sets *
+ */
Stack charAttrStack = new Stack();
/**
* The parse stack. This stack holds HTML.Tag objects that reflect the
* current position in the parsing process.
*/
- private Stack parseStack = new Stack();
+ Stack parseStack = new Stack();
/** A mapping between HTML.Tag objects and the actions that handle them **/
HashMap tagToAction;
@@ -535,10 +543,31 @@ public class HTMLDocument extends DefaultStyledDocument
/** Tells us whether we've received the '</html>' tag yet **/
boolean endHTMLEncountered = false;
- /** Variables related to the constructor with explicit insertTag **/
- int popDepth, pushDepth, offset;
+ /**
+ * Related to the constructor with explicit insertTag
+ */
+ int popDepth;
+
+ /**
+ * Related to the constructor with explicit insertTag
+ */
+ int pushDepth;
+
+ /**
+ * Related to the constructor with explicit insertTag
+ */
+ int offset;
+
+ /**
+ * The tag (inclusve), after that the insertion should start.
+ */
HTML.Tag insertTag;
- boolean insertTagEncountered = false;
+
+ /**
+ * This variable becomes true after the insert tag has been encountered.
+ */
+ boolean insertTagEncountered;
+
/** A temporary variable that helps with the printing out of debug information **/
boolean debug = false;
@@ -1139,8 +1168,21 @@ public class HTMLDocument extends DefaultStyledDocument
}
/**
- * This method is called by the parser and should route the call to
- * the proper handler for the tag.
+ * Checks if the HTML tag should be inserted. The tags before insert tag (if
+ * specified) are not inserted. Also, the tags after the end of the html are
+ * not inserted.
+ *
+ * @return true if the tag should be inserted, false otherwise.
+ */
+ private boolean shouldInsert()
+ {
+ return ! endHTMLEncountered
+ && (insertTagEncountered || insertTag == null);
+ }
+
+ /**
+ * This method is called by the parser and should route the call to the
+ * proper handler for the tag.
*
* @param t the HTML.Tag
* @param a the attribute set
@@ -1148,13 +1190,15 @@ public class HTMLDocument extends DefaultStyledDocument
*/
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
{
- // Don't call the Action if we've already seen </html>.
- if (endHTMLEncountered)
- return;
-
- TagAction action = (TagAction) tagToAction.get(t);
- if (action != null)
- action.start(t, a);
+ if (t == insertTag)
+ insertTagEncountered = true;
+
+ if (shouldInsert())
+ {
+ TagAction action = (TagAction) tagToAction.get(t);
+ if (action != null)
+ action.start(t, a);
+ }
}
/**
@@ -1165,42 +1209,41 @@ public class HTMLDocument extends DefaultStyledDocument
*/
public void handleComment(char[] data, int pos)
{
- // Don't call the Action if we've already seen </html>.
- if (endHTMLEncountered)
- return;
-
- TagAction action = (TagAction) tagToAction.get(HTML.Tag.COMMENT);
- if (action != null)
+ if (shouldInsert())
{
- action.start(HTML.Tag.COMMENT, new SimpleAttributeSet());
- action.end (HTML.Tag.COMMENT);
+ TagAction action = (TagAction) tagToAction.get(HTML.Tag.COMMENT);
+ if (action != null)
+ {
+ action.start(HTML.Tag.COMMENT,
+ htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET);
+ action.end(HTML.Tag.COMMENT);
+ }
}
}
/**
- * This method is called by the parser and should route the call to
- * the proper handler for the tag.
+ * This method is called by the parser and should route the call to the
+ * proper handler for the tag.
*
* @param t the HTML.Tag
* @param pos the position at which the tag was encountered
*/
public void handleEndTag(HTML.Tag t, int pos)
{
- // Don't call the Action if we've already seen </html>.
- if (endHTMLEncountered)
- return;
-
- // If this is the </html> tag we need to stop calling the Actions
- if (t == HTML.Tag.HTML)
- endHTMLEncountered = true;
-
- TagAction action = (TagAction) tagToAction.get(t);
- if (action != null)
- action.end(t);
+ if (shouldInsert())
+ {
+ // If this is the </html> tag we need to stop calling the Actions
+ if (t == HTML.Tag.HTML)
+ endHTMLEncountered = true;
+
+ TagAction action = (TagAction) tagToAction.get(t);
+ if (action != null)
+ action.end(t);
+ }
}
/**
- * This is a callback from the parser that should be routed to the
+ * This is a callback from the parser that should be routed to the
* appropriate handler for the tag.
*
* @param t the HTML.Tag that was encountered
@@ -1209,15 +1252,17 @@ public class HTMLDocument extends DefaultStyledDocument
*/
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
{
- // Don't call the Action if we've already seen </html>.
- if (endHTMLEncountered)
- return;
-
- TagAction action = (TagAction) tagToAction.get (t);
- if (action != null)
+ if (t == insertTag)
+ insertTagEncountered = true;
+
+ if (shouldInsert())
{
- action.start(t, a);
- action.end(t);
+ TagAction action = (TagAction) tagToAction.get(t);
+ if (action != null)
+ {
+ action.start(t, a);
+ action.end(t);
+ }
}
}
@@ -1230,7 +1275,6 @@ public class HTMLDocument extends DefaultStyledDocument
* @since 1.3
*/
public void handleEndOfLineString(String eol)
- throws NotImplementedException
{
// FIXME: Implement.
print ("HTMLReader.handleEndOfLineString not implemented yet");
@@ -1273,16 +1317,6 @@ public class HTMLDocument extends DefaultStyledDocument
printBuffer();
DefaultStyledDocument.ElementSpec element;
- // If the previous tag is content and the parent is p-implied, then
- // we must also close the p-implied.
- if (parseStack.size() > 0 && parseStack.peek() == HTML.Tag.IMPLIED)
- {
- element = new DefaultStyledDocument.ElementSpec(null,
- DefaultStyledDocument.ElementSpec.EndTagType);
- parseBuffer.addElement(element);
- parseStack.pop();
- }
-
parseStack.push(t);
AbstractDocument.AttributeContext ctx = getAttributeContext();
AttributeSet copy = attr.copyAttributes();
@@ -1320,16 +1354,6 @@ public class HTMLDocument extends DefaultStyledDocument
new char[0], 0, 0);
parseBuffer.add(element);
}
- // If the previous tag is content and the parent is p-implied, then
- // we must also close the p-implied.
- else if (parseStack.peek() == HTML.Tag.IMPLIED)
- {
- element = new DefaultStyledDocument.ElementSpec(null,
- DefaultStyledDocument.ElementSpec.EndTagType);
- parseBuffer.addElement(element);
- if (parseStack.size() > 0)
- parseStack.pop();
- }
element = new DefaultStyledDocument.ElementSpec(null,
DefaultStyledDocument.ElementSpec.EndTagType);
@@ -1369,27 +1393,6 @@ public class HTMLDocument extends DefaultStyledDocument
DefaultStyledDocument.ElementSpec element;
AttributeSet attributes = null;
- // Content must always be embedded inside a paragraph element,
- // so we create this if the previous element is not one of
- // <p>, <h1> .. <h6>.
- boolean createImpliedParagraph = false;
- HTML.Tag parent = (HTML.Tag) parseStack.peek();
- if (parent != HTML.Tag.P && parent != HTML.Tag.H1
- && parent != HTML.Tag.H2
- && parent != HTML.Tag.H3 && parent != HTML.Tag.H4
- && parent != HTML.Tag.H5 && parent != HTML.Tag.H6
- && parent != HTML.Tag.TD)
- {
- attributes = ctx.getEmptySet();
- attributes = ctx.addAttribute(attributes,
- StyleConstants.NameAttribute,
- HTML.Tag.IMPLIED);
- element = new DefaultStyledDocument.ElementSpec(attributes,
- DefaultStyledDocument.ElementSpec.StartTagType);
- parseBuffer.add(element);
- parseStack.push(HTML.Tag.IMPLIED);
- }
-
// Copy the attribute set, don't use the same object because
// it may change
if (charAttr != null)
@@ -1481,7 +1484,61 @@ public class HTMLDocument extends DefaultStyledDocument
HTML.Tag insertTag)
{
return new HTMLReader(pos, popDepth, pushDepth, insertTag);
- }
+ }
+
+ /**
+ * Gets the reader for the parser to use when inserting the HTML fragment into
+ * the document. Checks if the parser is present, sets the parent in the
+ * element stack and removes any actions for BODY (it can be only one body in
+ * a HTMLDocument).
+ *
+ * @param pos - the starting position
+ * @param popDepth - the number of EndTagTypes to generate before inserting
+ * @param pushDepth - the number of StartTagTypes with a direction of
+ * JoinNextDirection that should be generated before inserting, but
+ * after the end tags have been generated.
+ * @param insertTag - the first tag to start inserting into document
+ * @param parent the element that will be the parent in the document. HTML
+ * parsing includes checks for the parent, so it must be available.
+ * @return - the reader
+ * @throws IllegalStateException if the parsert is not set.
+ */
+ public HTMLEditorKit.ParserCallback getInsertingReader(int pos, int popDepth,
+ int pushDepth,
+ HTML.Tag insertTag,
+ final Element parent)
+ throws IllegalStateException
+ {
+ if (parser == null)
+ throw new IllegalStateException("Parser has not been set");
+
+ HTMLReader reader = new HTMLReader(pos, popDepth, pushDepth, insertTag)
+ {
+ /**
+ * Ignore BODY.
+ */
+ public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
+ {
+ if (t != HTML.Tag.BODY)
+ super.handleStartTag(t, a, pos);
+ }
+
+ /**
+ * Ignore BODY.
+ */
+ public void handleEndTag(HTML.Tag t, int pos)
+ {
+ if (t != HTML.Tag.BODY)
+ super.handleEndTag(t, pos);
+ }
+ };
+
+ // Set the parent HTML tag.
+ reader.parseStack.push(parent.getAttributes().getAttribute(
+ StyleConstants.NameAttribute));
+
+ return reader;
+ }
/**
* Gets the child element that contains the attribute with the value or null.
@@ -1490,8 +1547,8 @@ public class HTMLDocument extends DefaultStyledDocument
* @param e - the element to begin search at
* @param attribute - the desired attribute
* @param value - the desired value
- * @return the element found with the attribute and value specified or null
- * if it is not found.
+ * @return the element found with the attribute and value specified or null if
+ * it is not found.
*/
public Element getElement(Element e, Object attribute, Object value)
{
@@ -1516,16 +1573,17 @@ public class HTMLDocument extends DefaultStyledDocument
}
/**
- * Returns the element that has the given id Attribute. If it is not found,
- * null is returned. This method works on an Attribute, not a character tag.
- * This is not thread-safe.
+ * Returns the element that has the given id Attribute (for instance, &lt;p id
+ * ='my paragraph &gt;'). If it is not found, null is returned. The HTML tag,
+ * having this attribute, is not checked by this method and can be any. The
+ * method is not thread-safe.
*
- * @param attrId - the Attribute id to look for
+ * @param attrId - the value of the attribute id to look for
* @return the element that has the given id.
*/
public Element getElement(String attrId)
{
- return getElement(getDefaultRootElement(), HTML.getAttributeKey(attrId),
+ return getElement(getDefaultRootElement(), HTML.Attribute.ID,
attrId);
}
@@ -1542,22 +1600,30 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IllegalStateException - if an HTMLEditorKit.Parser has not been set
*/
public void setInnerHTML(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
+ throws BadLocationException, IOException
{
if (elem.isLeaf())
throw new IllegalArgumentException("Element is a leaf");
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("setInnerHTML not implemented");
+
+ int start = elem.getStartOffset();
+ int end = elem.getEndOffset();
+
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ end, 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
+
+ // Remove the previous content
+ remove(start, end - start);
}
/**
- * Replaces the given element in the parent with the string. When replacing
- * a leaf, this will attempt to make sure there is a newline present if one is
- * needed. This may result in an additional element being inserted.
- * This will be seen as at least two events, n inserts followed by a remove.
- * The HTMLEditorKit.Parser must be set.
+ * Replaces the given element in the parent with the string. When replacing a
+ * leaf, this will attempt to make sure there is a newline present if one is
+ * needed. This may result in an additional element being inserted. This will
+ * be seen as at least two events, n inserts followed by a remove. The
+ * HTMLEditorKit.Parser must be set.
*
* @param elem - the branch element whose parent will be replaced
* @param htmlText - the string to be parsed and assigned to elem
@@ -1565,18 +1631,25 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IOException
* @throws IllegalStateException - if parser is not set
*/
- public void setOuterHTML(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
- {
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("setOuterHTML not implemented");
- }
+public void setOuterHTML(Element elem, String htmlText)
+ throws BadLocationException, IOException
+ {
+ // Remove the current element:
+ int start = elem.getStartOffset();
+ int end = elem.getEndOffset();
+
+ remove(start, end-start);
+
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ start, 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
+ }
/**
- * Inserts the string before the start of the given element.
- * The parser must be set.
+ * Inserts the string before the start of the given element. The parser must
+ * be set.
*
* @param elem - the element to be the root for the new text.
* @param htmlText - the string to be parsed and assigned to elem
@@ -1585,18 +1658,19 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IllegalStateException - if parser has not been set
*/
public void insertBeforeStart(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
+ throws BadLocationException, IOException
{
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("insertBeforeStart not implemented");
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ elem.getStartOffset(), 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
}
/**
- * Inserts the string at the end of the element. If elem's children
- * are leaves, and the character at elem.getEndOffset() - 1 is a newline,
- * then it will be inserted before the newline. The parser must be set.
+ * Inserts the string at the end of the element. If elem's children are
+ * leaves, and the character at elem.getEndOffset() - 1 is a newline, then it
+ * will be inserted before the newline. The parser must be set.
*
* @param elem - the element to be the root for the new text
* @param htmlText - the text to insert
@@ -1605,12 +1679,14 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IllegalStateException - if parser is not set
*/
public void insertBeforeEnd(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
+ throws BadLocationException, IOException
{
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("insertBeforeEnd not implemented");
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ elem.getEndOffset(), 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
+
}
/**
@@ -1624,12 +1700,13 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IllegalStateException - if parser is not set
*/
public void insertAfterEnd(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
+ throws BadLocationException, IOException
{
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("insertAfterEnd not implemented");
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ elem.getEndOffset(), 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
}
/**
@@ -1643,11 +1720,12 @@ public class HTMLDocument extends DefaultStyledDocument
* @throws IllegalStateException - if parser is not set
*/
public void insertAfterStart(Element elem, String htmlText)
- throws BadLocationException, IOException, NotImplementedException
+ throws BadLocationException, IOException
{
- if (parser == null)
- throw new IllegalStateException("Parser has not been set");
- // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
- System.out.println("insertAfterStart not implemented");
+ HTMLEditorKit.ParserCallback reader = getInsertingReader(
+ elem.getStartOffset(), 0, 0, HTML.Tag.BODY, elem);
+
+ // TODO charset
+ getParser().parse(new StringReader(htmlText), reader, true);
}
}
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java
index 68f2b1571..138a42fbc 100644
--- a/javax/swing/text/html/HTMLEditorKit.java
+++ b/javax/swing/text/html/HTMLEditorKit.java
@@ -40,6 +40,8 @@ package javax.swing.text.html;
import gnu.classpath.NotImplementedException;
+import gnu.javax.swing.text.html.parser.GnuParserDelegator;
+import gnu.javax.swing.text.html.parser.HTML_401Swing;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
@@ -886,7 +888,9 @@ public class HTMLEditorKit
protected Parser getParser()
{
if (parser == null)
- parser = new ParserDelegator();
+ {
+ parser = new GnuParserDelegator(HTML_401Swing.getInstance());
+ }
return parser;
}
diff --git a/javax/swing/text/html/parser/ParserDelegator.java b/javax/swing/text/html/parser/ParserDelegator.java
index e5d2db4df..70636d929 100644
--- a/javax/swing/text/html/parser/ParserDelegator.java
+++ b/javax/swing/text/html/parser/ParserDelegator.java
@@ -52,9 +52,6 @@ import javax.swing.text.html.HTMLEditorKit.ParserCallback;
* This class instantiates and starts the working instance of
* html parser, being responsible for providing the default DTD.
*
- * TODO Later this class must be derived from the totally abstract class
- * HTMLEditorKit.Parser. HTMLEditorKit that does not yet exist.
- *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ParserDelegator
diff --git a/native/jni/gconf-peer/GConfNativePeer.c b/native/jni/gconf-peer/GConfNativePeer.c
index bc8f78067..011fe8c26 100644
--- a/native/jni/gconf-peer/GConfNativePeer.c
+++ b/native/jni/gconf-peer/GConfNativePeer.c
@@ -41,6 +41,7 @@
#include <jni.h>
#include <glib.h>
+#include <gdk/gdk.h>
#include <gconf/gconf-client.h>
#include "jcl.h"
@@ -72,6 +73,7 @@ static jmethodID jlist_add_id = NULL;
* Gets the reference of the default GConfClient and initialize the
* the type system.
* The client reference should be released with g_object_unref after use.
+ * This functions must be called with gdk lock held.
*/
static void init_gconf_client (void);
@@ -131,7 +133,9 @@ JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
{
reference_count++;
+ gdk_threads_enter ();
init_gconf_client ();
+ gdk_threads_leave ();
/* if client is null, there is probably an out of memory */
if (client == NULL)
@@ -160,6 +164,8 @@ JNIEXPORT jobject JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_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;
GError *err = NULL;
GSList *entries = NULL;
@@ -174,7 +180,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
return NULL;
}
+ gdk_threads_enter ();
entries = gconf_client_all_entries (client, dir, &err);
+ gdk_threads_leave ();
if (err != NULL)
{
throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -212,7 +220,7 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
JCL_free_cstring (env, node, dir);
g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
g_slist_free (entries);
-
+
return jlist;
}
@@ -239,7 +247,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
return NULL;
}
+ gdk_threads_enter ();
entries = gconf_client_all_dirs (client, dir, &err);
+ gdk_threads_leave ();
if (err != NULL)
{
throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -291,7 +301,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync
{
GError *err = NULL;
+ gdk_threads_enter ();
gconf_client_suggest_sync (client, &err);
+ gdk_threads_leave ();
if (err != NULL)
{
throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
@@ -320,7 +332,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset
return JNI_FALSE;
}
+ gdk_threads_enter ();
result = gconf_client_unset (client, _key, &err);
+ gdk_threads_leave ();
if (err != NULL)
{
result = JNI_FALSE;
@@ -353,7 +367,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string
return NULL;
}
+ gdk_threads_enter ();
_value = gconf_client_get_string (client, _key, &err);
+ gdk_threads_leave ();
JCL_free_cstring (env, key, _key);
if (err != NULL)
{
@@ -365,8 +381,13 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string
return NULL;
}
- result = (*env)->NewStringUTF (env, _value);
- g_free ((gpointer) _value);
+ /* Even if Gconf reported no error it is possible that NULL was returned */
+ /* and it should be prevented to create a Java string from that value. */
+ if (_value != NULL)
+ {
+ result = (*env)->NewStringUTF (env, _value);
+ g_free ((gpointer) _value);
+ }
return result;
}
@@ -390,12 +411,14 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string
/* load an UTF string from the virtual machine. */
_key = JCL_jstring_to_cstring (env, key);
_value = JCL_jstring_to_cstring (env, value);
- if (_key == NULL && _value == NULL)
+ if (_key == NULL || _value == NULL)
{
return JNI_FALSE;
}
+ gdk_threads_enter ();
result = gconf_client_set_string (client, _key, _value, &err);
+ gdk_threads_leave ();
if (err != NULL)
{
g_error_free (err);
@@ -424,7 +447,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir
if (dir == NULL)
return;
+ gdk_threads_enter ();
gconf_client_remove_dir (client, dir, NULL);
+ gdk_threads_leave ();
JCL_free_cstring (env, node, dir);
}
@@ -445,7 +470,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir
return;
/* ignore errors */
+ gdk_threads_enter ();
gconf_client_add_dir (client, dir, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gdk_threads_leave ();
JCL_free_cstring (env, node, dir);
}
@@ -468,7 +495,9 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
return value;
/* on error return false */
+ gdk_threads_enter ();
value = gconf_client_dir_exists (client, dir, &err);
+ gdk_threads_leave ();
if (err != NULL)
value = JNI_FALSE;
@@ -489,7 +518,9 @@ JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
if (reference_count == 0)
{
/* last reference, free all resources and return */
+ gdk_threads_enter ();
g_object_unref (G_OBJECT (client));
+ gdk_threads_leave ();
(*env)->DeleteGlobalRef (env, jlist_class);
diff --git a/native/jni/gconf-peer/Makefile.am b/native/jni/gconf-peer/Makefile.am
index 4c728fd8c..8192ddc04 100644
--- a/native/jni/gconf-peer/Makefile.am
+++ b/native/jni/gconf-peer/Makefile.am
@@ -5,10 +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
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GCONF_LIBS@
-#@CLASSPATH_MODULE@ @GCONF_LIBS@ @CAIRO_LIBS@ @FREETYPE2_LIBS@ \
-# @PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GCONF_LIBS@ @GTK_LIBS@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
-AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GCONF_CFLAGS@
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GCONF_CFLAGS@ @GTK_CFLAGS@
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index 397240270..1e0c97156 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -12,7 +12,6 @@ libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_CairoSurface.c \
gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
gnu_java_awt_peer_gtk_GdkRobotPeer.c \
gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c \
- gnu_java_awt_peer_gtk_GdkTextLayout.c \
gnu_java_awt_peer_gtk_GtkButtonPeer.c \
gnu_java_awt_peer_gtk_GtkCanvasPeer.c \
gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c \
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 0057c3b8d..f80ae3838 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
@@ -263,6 +263,17 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoScale
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
+ jlong pointer, jdouble x, jdouble y)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_scale (gr->cr, x, y);
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
(JNIEnv *env, jobject obj, jlong pointer,
jobject font,
@@ -473,6 +484,28 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSave
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
+ jlong pointer)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_save (gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRestore
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
+ jlong pointer)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_restore (gr->cr);
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoNewPath
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer)
@@ -561,6 +594,17 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoArc
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
+ jlong pointer, jdouble x, jdouble y, jdouble radius, jdouble angle1,
+ jdouble angle2)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+
+ cairo_arc (gr->cr, x, y, radius, angle1, angle2);
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClosePath
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
index 89adcd1e5..6528ad43a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
@@ -241,3 +241,35 @@ Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice
return defaultDevice;
}
+
+JNIEXPORT jintArray JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_getMouseCoordinates
+(JNIEnv *env, jobject obj)
+{
+ jintArray retArray;
+ jint *values;
+ GdkDisplay *display;
+ gint x, y, screenIndex;
+ GdkScreen *screen;
+
+ display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, obj);
+ g_assert (display != NULL);
+
+ gdk_threads_enter ();
+
+ gdk_display_get_pointer (display, &screen, &x, &y, NULL);
+ screenIndex = gdk_screen_get_number( screen );
+
+ gdk_threads_leave ();
+
+ retArray = (*env)->NewIntArray (env, 3);
+ values = (*env)->GetIntArrayElements (env, retArray, NULL);
+
+ values[0] = screenIndex;
+ values[1] = x;
+ values[2] = y;
+
+ (*env)->ReleaseIntArrayElements (env, retArray, values, 0);
+
+ return retArray;
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index c966f6331..8949fa927 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -387,6 +387,37 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenResolution
return res;
}
+/**
+ * Report the number of mouse buttons
+ * Returns the number of buttons of the first mouse found, or -1 if no mouse
+ * seems to be connected.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkToolkit_getMouseNumberOfButtons
+ (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
+{
+ jint res = -1;
+ GList *devices;
+ GdkDevice *d;
+
+ gdk_threads_enter ();
+
+ /* FIXME: Why doesn't this return the correct number? */
+ devices = gdk_devices_list();
+
+ while( res == -1 && devices != NULL )
+ {
+ d = GDK_DEVICE( devices->data );
+ if( d->source == GDK_SOURCE_MOUSE )
+ res = d->num_keys;
+ devices = devices->next;
+ }
+
+ gdk_threads_leave ();
+
+ return res;
+}
+
#define CONVERT(type, state) \
gdk_color_to_java_color (style->type[GTK_STATE_ ## state])
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index c3ecb00c8..851e2cf48 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -1245,6 +1245,21 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetModal
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetAlwaysOnTop
+ (JNIEnv *env, jobject obj, jboolean alwaysOnTop)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_window_set_keep_above (GTK_WINDOW (ptr), alwaysOnTop);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNative
(JNIEnv *env, jobject obj, jboolean visible)
{
diff --git a/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c b/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
index 3b29001a7..35fb6bcdc 100644
--- a/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
@@ -200,22 +200,15 @@ Java_gnu_java_net_local_LocalSocketImpl_accept (JNIEnv *env, jobject this, jobje
jint
-Java_gnu_java_net_local_LocalSocketImpl_available (JNIEnv *env, jobject this)
+Java_gnu_java_net_local_LocalSocketImpl_available
+(JNIEnv *env, jobject this __attribute__((unused)), jint fd)
{
#ifdef ENABLE_LOCAL_SOCKETS
- jfieldID socket_fd;
- jclass clazz;
jint avail;
TRACE("begin");
- clazz = (*env)->GetObjectClass (env, this);
- socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
- if (!socket_fd)
- {
- return 0;
- }
- avail = (jint) local_available ((int) (*env)->GetIntField (env, this, socket_fd));
+ avail = (jint) local_available (fd);
if (avail < 0)
{
_throw (env, "java/io/IOException", local_error ());
@@ -227,6 +220,7 @@ Java_gnu_java_net_local_LocalSocketImpl_available (JNIEnv *env, jobject this)
return avail;
#else
(void) this;
+ (void) fd;
_throw (env, "java/lang/Error", "support for local sockets not available");
return -1;
#endif /* ENABLE_LOCAL_SOCKETS */
@@ -452,14 +446,13 @@ Java_gnu_java_net_local_LocalSocketImpl_localConnect (JNIEnv *env, jobject this,
jint
-Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject this, jbyteArray buf, jint off, jint len)
+Java_gnu_java_net_local_LocalSocketImpl_read
+(JNIEnv *env, jobject this __attribute__((unused)), jint fd, jbyteArray buf,
+ jint off, jint len)
{
#ifdef ENABLE_LOCAL_SOCKETS
- jfieldID socket_fd;
- jclass clazz;
jbyte *buffer;
jint count;
- int fd;
TRACE("begin");
@@ -468,13 +461,6 @@ Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject this, jbyteAr
_throw (env, "java/lang/ArrayIndexOutOfBoundsException", "");
}
- clazz = (*env)->GetObjectClass (env, this);
- socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
- if (!socket_fd)
- {
- return 0;
- }
- fd = (int) (*env)->GetIntField (env, this, socket_fd);
buffer = (*env)->GetByteArrayElements (env, buf, NULL);
count = (jint) local_read (fd, (void *) (buffer + off), (int) len);
if (count < 0)
@@ -488,6 +474,7 @@ Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject this, jbyteAr
return count;
#else
(void) this;
+ (void) fd;
(void) buf;
(void) off;
(void) len;
@@ -498,13 +485,12 @@ Java_gnu_java_net_local_LocalSocketImpl_read (JNIEnv *env, jobject this, jbyteAr
void
-Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject this, jbyteArray buf, jint off, jint len)
+Java_gnu_java_net_local_LocalSocketImpl_write
+(JNIEnv *env, jobject this __attribute__((unused)), jint fd, jbyteArray buf,
+ jint off, jint len)
{
#ifdef ENABLE_LOCAL_SOCKETS
- jfieldID socket_fd;
- jclass clazz;
jbyte *buffer;
- int fd;
TRACE("begin");
@@ -513,13 +499,6 @@ Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject this, jbyteA
_throw (env, "java/lang/ArrayIndexOutOfBoundsException", "");
}
- clazz = (*env)->GetObjectClass (env, this);
- socket_fd = (*env)->GetFieldID (env, clazz, "socket_fd", "I");
- if (!socket_fd)
- {
- return;
- }
- fd = (int) (*env)->GetIntField (env, this, socket_fd);
buffer = (*env)->GetByteArrayElements (env, buf, NULL);
if (local_write (fd, (void *) (buffer + off), (int) len) < 0)
{
@@ -530,6 +509,7 @@ Java_gnu_java_net_local_LocalSocketImpl_write (JNIEnv *env, jobject this, jbyteA
TRACE("end");
#else
(void) this;
+ (void) fd;
(void) buf;
(void) off;
(void) len;
diff --git a/org/omg/CORBA/CompletionStatusHelper.java b/org/omg/CORBA/CompletionStatusHelper.java
index 43b6b8c10..bf1c37532 100644
--- a/org/omg/CORBA/CompletionStatusHelper.java
+++ b/org/omg/CORBA/CompletionStatusHelper.java
@@ -52,11 +52,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class CompletionStatusHelper
{
/**
- * The cached typecode value, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the {@link CompletionStatus} from the
* given {@link Any}. This implementation expects
* the integer (Corba long) value, stating the completion
@@ -125,16 +120,12 @@ public abstract class CompletionStatusHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- String[] members =
- new String[] { "COMPLETED_YES", "COMPLETED_NO", "COMPLETED_MAYBE" };
-
- typeCode =
- OrbRestricted.Singleton.create_enum_tc(id(), "CompletionStatus",
- members
- );
- }
- return typeCode;
+ String[] members =
+ new String[] { "COMPLETED_YES", "COMPLETED_NO", "COMPLETED_MAYBE" };
+
+ return
+ OrbRestricted.Singleton.create_enum_tc(id(), "CompletionStatus",
+ members
+ );
}
} \ No newline at end of file
diff --git a/org/omg/CORBA/CurrentHelper.java b/org/omg/CORBA/CurrentHelper.java
index 51bd65fc1..f292449ec 100644
--- a/org/omg/CORBA/CurrentHelper.java
+++ b/org/omg/CORBA/CurrentHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -85,18 +87,12 @@ public abstract class CurrentHelper
}
/**
- * The cached {@link Current} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link Current}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "Current");
- return typeCode;
+ return
+ OrbRestricted.Singleton.create_interface_tc(id(), "Current");
}
/**
diff --git a/org/omg/CORBA/DefinitionKindHelper.java b/org/omg/CORBA/DefinitionKindHelper.java
index fddbb585a..ef7e26725 100644
--- a/org/omg/CORBA/DefinitionKindHelper.java
+++ b/org/omg/CORBA/DefinitionKindHelper.java
@@ -55,11 +55,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class DefinitionKindHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Insert the definition kind into the given Any.
*/
public static void insert(Any a, DefinitionKind that)
@@ -83,25 +78,21 @@ public abstract class DefinitionKindHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- String[] members =
- new String[]
- {
- "dk_none", "dk_all", "dk_Attribute", "dk_Constant", "dk_Exception",
- "dk_Interface", "dk_Module", "dk_Operation", "dk_Typedef",
- "dk_Alias", "dk_Struct", "dk_Union", "dk_Enum", "dk_Primitive",
- "dk_String", "dk_Sequence", "dk_Array", "dk_Repository",
- "dk_Wstring", "dk_Fixed", "dk_Value", "dk_ValueBox",
- "dk_ValueMember", "dk_Native"
- };
-
- typeCode =
- OrbRestricted.Singleton.create_enum_tc(id(), "DefinitionKind",
- members
- );
- }
- return typeCode;
+ String[] members =
+ new String[]
+ {
+ "dk_none", "dk_all", "dk_Attribute", "dk_Constant", "dk_Exception",
+ "dk_Interface", "dk_Module", "dk_Operation", "dk_Typedef",
+ "dk_Alias", "dk_Struct", "dk_Union", "dk_Enum", "dk_Primitive",
+ "dk_String", "dk_Sequence", "dk_Array", "dk_Repository",
+ "dk_Wstring", "dk_Fixed", "dk_Value", "dk_ValueBox",
+ "dk_ValueMember", "dk_Native"
+ };
+
+ return
+ OrbRestricted.Singleton.create_enum_tc(id(), "DefinitionKind",
+ members
+ );
}
/**
diff --git a/org/omg/CORBA/IDLTypeHelper.java b/org/omg/CORBA/IDLTypeHelper.java
index 635168eb8..ff874947f 100644
--- a/org/omg/CORBA/IDLTypeHelper.java
+++ b/org/omg/CORBA/IDLTypeHelper.java
@@ -53,11 +53,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class IDLTypeHelper
{
/**
- * The cached typecode value, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Insert the IDL type into the given Any.
*/
public static void insert(Any a, IDLType that)
@@ -81,14 +76,8 @@ public abstract class IDLTypeHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode =
- OrbRestricted.Singleton.create_interface_tc(IDLTypeHelper.id(),
- "IDLType"
- );
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(IDLTypeHelper.id(),
+ "IDLType");
}
/**
diff --git a/org/omg/CORBA/NameValuePairHelper.java b/org/omg/CORBA/NameValuePairHelper.java
index 5d2430b23..f6d933930 100644
--- a/org/omg/CORBA/NameValuePairHelper.java
+++ b/org/omg/CORBA/NameValuePairHelper.java
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.AliasTypeCode;
import gnu.CORBA.typecodes.PrimitiveTypeCode;
import gnu.CORBA.typecodes.StringTypeCode;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -61,11 +62,6 @@ public abstract class NameValuePairHelper
private static String _id = "IDL:omg.org/CORBA/NameValuePair:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the NameValuePair from the given {@link Any}.
*/
public static NameValuePair extract(Any a)
@@ -115,21 +111,18 @@ public abstract class NameValuePairHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- StructMember[] members = new StructMember[ 2 ];
+ StructMember[] members = new StructMember[2];
- TypeCode t_id =
- new AliasTypeCode(new StringTypeCode(TCKind.tk_string), "", "id");
+ TypeCode t_id = new AliasTypeCode(new StringTypeCode(TCKind.tk_string), "",
+ "id");
- members [ 0 ] = new StructMember("id", t_id, null);
+ members[0] = new StructMember("id", t_id, null);
- members [ 1 ] =
- new StructMember("value", new PrimitiveTypeCode(TCKind.tk_any), null);
+ members[1] = new StructMember("value",
+ new PrimitiveTypeCode(TCKind.tk_any), null);
- typeCode = ORB.init().create_struct_tc(id(), "NameValuePair", members);
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_struct_tc(id(), "NameValuePair",
+ members);
}
/**
diff --git a/org/omg/CORBA/ObjectHelper.java b/org/omg/CORBA/ObjectHelper.java
index 220f2dace..f662a7888 100644
--- a/org/omg/CORBA/ObjectHelper.java
+++ b/org/omg/CORBA/ObjectHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -51,8 +52,6 @@ import org.omg.CORBA.portable.OutputStream;
*/
public abstract class ObjectHelper
{
- static TypeCode typeCode;
-
/**
* Extract the array of object from the given {@link Any}.
*/
@@ -100,9 +99,7 @@ public abstract class ObjectHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().get_primitive_tc(TCKind.tk_objref);
- return typeCode;
+ return OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_objref);
}
/**
diff --git a/org/omg/CORBA/ParameterModeHelper.java b/org/omg/CORBA/ParameterModeHelper.java
index ac17a9235..c96ce94ac 100644
--- a/org/omg/CORBA/ParameterModeHelper.java
+++ b/org/omg/CORBA/ParameterModeHelper.java
@@ -54,11 +54,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ParameterModeHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Insert the parameter mode into the given Any.
*/
public static void insert(Any any, ParameterMode that)
@@ -81,15 +76,11 @@ public abstract class ParameterModeHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
String[] members =
new String[] { "PARAM_IN", "PARAM_OUT", "PARAM_INOUT" };
- typeCode =
+ return
OrbRestricted.Singleton.create_enum_tc(id(), "ParameterMode", members);
- }
- return typeCode;
}
/**
diff --git a/org/omg/CORBA/PolicyErrorCodeHelper.java b/org/omg/CORBA/PolicyErrorCodeHelper.java
index ab7ac9547..6feabdcfd 100644
--- a/org/omg/CORBA/PolicyErrorCodeHelper.java
+++ b/org/omg/CORBA/PolicyErrorCodeHelper.java
@@ -106,7 +106,7 @@ public abstract class PolicyErrorCodeHelper
}
/**
- * Delegates call to {@link OutputStream.write_short()}.
+ * Delegates call to {@link OutputStream#write_short()}.
*/
public static void write(OutputStream ostream, short value)
{
diff --git a/org/omg/CORBA/PolicyErrorHelper.java b/org/omg/CORBA/PolicyErrorHelper.java
index 49db768cd..27b5b465e 100644
--- a/org/omg/CORBA/PolicyErrorHelper.java
+++ b/org/omg/CORBA/PolicyErrorHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -57,32 +58,23 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class PolicyErrorHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the PolicyError typecode. The typecode defines a structure, named
* "PolicyError", containing the {@link PolicyErrorCode} (alias int) field,
* named "reason".
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 1 ];
-
- TypeCode field;
-
- field =
- orb.create_alias_tc("IDL:omg.org/CORBA/PolicyErrorCode:1.0",
- "PolicyErrorCode", orb.get_primitive_tc(TCKind.tk_short)
- );
- members [ 0 ] = new StructMember("reason", field, null);
- typeCode = orb.create_exception_tc(id(), "PolicyError", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/CORBA/PolicyErrorCode:1.0",
+ "PolicyErrorCode", orb.get_primitive_tc(TCKind.tk_short)
+ );
+ members [ 0 ] = new StructMember("reason", field, null);
+ return orb.create_exception_tc(id(), "PolicyError", members);
}
/**
diff --git a/org/omg/CORBA/PolicyHelper.java b/org/omg/CORBA/PolicyHelper.java
index 66fb0aa08..53b56244e 100644
--- a/org/omg/CORBA/PolicyHelper.java
+++ b/org/omg/CORBA/PolicyHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,20 +61,13 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class PolicyHelper
{
/**
- * The cached {@link Policy} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link Policy}.
*
* @return interface typecode, named "Policy".
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "Policy");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "Policy");
}
/**
diff --git a/org/omg/CORBA/PolicyListHelper.java b/org/omg/CORBA/PolicyListHelper.java
index 6e4d329b8..da0135c02 100644
--- a/org/omg/CORBA/PolicyListHelper.java
+++ b/org/omg/CORBA/PolicyListHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,18 +61,11 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class PolicyListHelper
{
/**
- * The cached {@link Policy[]} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link Policy[]}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "Policy[]");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "Policy[]");
}
/**
diff --git a/org/omg/CORBA/PolicyTypeHelper.java b/org/omg/CORBA/PolicyTypeHelper.java
index dadd3a9e6..7d5f9bf76 100644
--- a/org/omg/CORBA/PolicyTypeHelper.java
+++ b/org/omg/CORBA/PolicyTypeHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -65,7 +67,7 @@ public abstract class PolicyTypeHelper
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "PolicyType",
orb.get_primitive_tc(TCKind.tk_ulong)
);
diff --git a/org/omg/CORBA/ServiceDetailHelper.java b/org/omg/CORBA/ServiceDetailHelper.java
index 58000f2c5..76fbda610 100644
--- a/org/omg/CORBA/ServiceDetailHelper.java
+++ b/org/omg/CORBA/ServiceDetailHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.ServiceDetailHolder;
import org.omg.CORBA.portable.InputStream;
@@ -57,11 +58,6 @@ public abstract class ServiceDetailHelper
private static String _id = "IDL:omg.org/CORBA/ServiceDetail:1.0";
/**
- * The cached typecode value, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the service detail info from the given {@link Any}
*
* @param a the Any to extract from.
@@ -137,25 +133,21 @@ public abstract class ServiceDetailHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
-
- TypeCode type =
- orb.create_alias_tc(_id, "ServiceDetailType",
- orb.get_primitive_tc(TCKind.tk_ulong)
- );
- members [ 0 ] = new StructMember("service_detail_type", type, null);
-
- TypeCode data =
- orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
- members [ 1 ] = new StructMember("service_detail", data, null);
-
- typeCode = orb.create_struct_tc(id(), "ServiceDetail", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode type =
+ orb.create_alias_tc(_id, "ServiceDetailType",
+ orb.get_primitive_tc(TCKind.tk_ulong)
+ );
+ members [ 0 ] = new StructMember("service_detail_type", type, null);
+
+ TypeCode data =
+ orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
+ members [ 1 ] = new StructMember("service_detail", data, null);
+
+ return orb.create_struct_tc(id(), "ServiceDetail", members);
}
/**
diff --git a/org/omg/CORBA/ServiceInformationHelper.java b/org/omg/CORBA/ServiceInformationHelper.java
index 78a21d182..f77378fd7 100644
--- a/org/omg/CORBA/ServiceInformationHelper.java
+++ b/org/omg/CORBA/ServiceInformationHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -57,11 +59,6 @@ public abstract class ServiceInformationHelper
private static String _id = "IDL:org/omg/CORBA/ServiceInformation:1.0";
/**
- * The caches typecode value, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the service information from the given Any.
*/
public static ServiceInformation extract(Any a)
@@ -109,34 +106,30 @@ public abstract class ServiceInformationHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
- TypeCode member;
-
- member =
- orb.create_alias_tc("IDL:omg.org/CORBA/ServiceOptionSeq:1.0",
- "ServiceOptionSeq", LongSeqHelper.type()
- );
-
- members [ 0 ] = new StructMember("service_options", member, null);
-
- member = ServiceDetailHelper.type();
- member = orb.create_sequence_tc(0, member);
- member =
- orb.create_alias_tc("IDL:omg.org/CORBA/ServiceDetailSeq:1.0",
- "ServiceDetailSeq", member
- );
- members [ 1 ] = new StructMember("service_details", member, null);
-
- typeCode =
- orb.create_struct_tc(ServiceInformationHelper.id(),
- "ServiceInformation", members
- );
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+
+ member =
+ orb.create_alias_tc("IDL:omg.org/CORBA/ServiceOptionSeq:1.0",
+ "ServiceOptionSeq", LongSeqHelper.type()
+ );
+
+ members [ 0 ] = new StructMember("service_options", member, null);
+
+ member = ServiceDetailHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member =
+ orb.create_alias_tc("IDL:omg.org/CORBA/ServiceDetailSeq:1.0",
+ "ServiceDetailSeq", member
+ );
+ members [ 1 ] = new StructMember("service_details", member, null);
+
+ return
+ orb.create_struct_tc(ServiceInformationHelper.id(),
+ "ServiceInformation", members
+ );
}
/**
diff --git a/org/omg/CORBA/SetOverrideTypeHelper.java b/org/omg/CORBA/SetOverrideTypeHelper.java
index 1fa1ef868..fb2c8235a 100644
--- a/org/omg/CORBA/SetOverrideTypeHelper.java
+++ b/org/omg/CORBA/SetOverrideTypeHelper.java
@@ -52,11 +52,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class SetOverrideTypeHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Insert the definition kind into the given Any.
*/
public static void insert(Any any, SetOverrideType that)
@@ -79,20 +74,16 @@ public abstract class SetOverrideTypeHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- String[] members =
- new String[]
- {
- "SET_OVERRIDE" ,"ADD_OVERRIDE"
- };
-
- typeCode =
- OrbRestricted.Singleton.create_enum_tc(id(), "SetOverrideType",
- members
- );
- }
- return typeCode;
+ String[] members =
+ new String[]
+ {
+ "SET_OVERRIDE" ,"ADD_OVERRIDE"
+ };
+
+ return
+ OrbRestricted.Singleton.create_enum_tc(id(), "SetOverrideType",
+ members
+ );
}
/**
diff --git a/org/omg/CORBA/StringValueHelper.java b/org/omg/CORBA/StringValueHelper.java
index 24e79ce57..5273f5cfb 100644
--- a/org/omg/CORBA/StringValueHelper.java
+++ b/org/omg/CORBA/StringValueHelper.java
@@ -66,11 +66,6 @@ public class StringValueHelper
private static final String id = "IDL:omg.org/CORBA/StringValue:1.0";
/**
- * The cached typecode value, computed once.
- */
- private static TypeCode typecode;
-
- /**
* The String typecode.
*/
private static final TypeCode tString =
@@ -175,18 +170,13 @@ public class StringValueHelper
}
/**
- * Create and return the value box typecode, named "StringValue",
- * with the content typecode being unbounded string.
+ * Create and return the value box typecode, named "StringValue", with the
+ * content typecode being unbounded string.
*/
public static TypeCode type()
{
- if (typecode == null)
- {
- ORB orb = OrbRestricted.Singleton;
- typecode =
- orb.create_value_box_tc(id(), "StringValue", tString);
- }
- return typecode;
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_value_box_tc(id(), "StringValue", tString);
}
/**
diff --git a/org/omg/CORBA/UnionMemberHelper.java b/org/omg/CORBA/UnionMemberHelper.java
index c599542fb..ef69329b7 100644
--- a/org/omg/CORBA/UnionMemberHelper.java
+++ b/org/omg/CORBA/UnionMemberHelper.java
@@ -94,7 +94,7 @@ public abstract class UnionMemberHelper
{
if (active)
{
- return ORB.init().create_recursive_tc(id());
+ return OrbRestricted.Singleton.create_recursive_tc(id());
}
active = true;
diff --git a/org/omg/CORBA/UnknownUserExceptionHelper.java b/org/omg/CORBA/UnknownUserExceptionHelper.java
index e93dc7403..0ca50cb88 100644
--- a/org/omg/CORBA/UnknownUserExceptionHelper.java
+++ b/org/omg/CORBA/UnknownUserExceptionHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -57,30 +58,21 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class UnknownUserExceptionHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the UnknownUserException typecode (structure,
* named "UnknownUserException", containing a single field of
* type {@link Any}, named "except".
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 1 ];
TypeCode field;
field = orb.get_primitive_tc(TCKind.tk_any);
members [ 0 ] = new StructMember("except", field, null);
- typeCode =
+ return
orb.create_exception_tc(id(), "UnknownUserException", members);
- }
- return typeCode;
}
/**
diff --git a/org/omg/CORBA/VisibilityHelper.java b/org/omg/CORBA/VisibilityHelper.java
index a09e5b686..a00f96e14 100644
--- a/org/omg/CORBA/VisibilityHelper.java
+++ b/org/omg/CORBA/VisibilityHelper.java
@@ -53,11 +53,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class VisibilityHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Insert the Visibility into the given Any.
* Uses {@link Any#insert_short}.
*/
@@ -80,14 +75,10 @@ public abstract class VisibilityHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
TypeCode tshort =
OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_short);
- typeCode =
+ return
OrbRestricted.Singleton.create_alias_tc(id(), "Visibility", tshort);
- }
- return typeCode;
}
/**
diff --git a/org/omg/CORBA/WStringValueHelper.java b/org/omg/CORBA/WStringValueHelper.java
index 1c63a408e..17f23214c 100644
--- a/org/omg/CORBA/WStringValueHelper.java
+++ b/org/omg/CORBA/WStringValueHelper.java
@@ -66,11 +66,6 @@ public class WStringValueHelper
private static final String id = "IDL:omg.org/CORBA/WStringValue:1.0";
/**
- * The cached typecode value, computed once.
- */
- private static TypeCode typecode;
-
- /**
* The Wide String typecode.
*/
private static final TypeCode twString =
@@ -175,18 +170,13 @@ public class WStringValueHelper
}
/**
- * Create and return the value box typecode, named "WStringValue",
- * with the content typecode being unbounded string.
+ * Create and return the value box typecode, named "WStringValue", with the
+ * content typecode being unbounded string.
*/
public static TypeCode type()
{
- if (typecode == null)
- {
- ORB orb = OrbRestricted.Singleton;
- typecode =
- orb.create_value_box_tc(id(), "WStringValue", twString);
- }
- return typecode;
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_value_box_tc(id(), "WStringValue", twString);
}
/**
diff --git a/org/omg/CORBA/WrongTransactionHelper.java b/org/omg/CORBA/WrongTransactionHelper.java
index 5bb5baff2..27368a4c0 100644
--- a/org/omg/CORBA/WrongTransactionHelper.java
+++ b/org/omg/CORBA/WrongTransactionHelper.java
@@ -40,6 +40,7 @@ package org.omg.CORBA;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,14 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class WrongTransactionHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the WrongTransaction typecode (structure,
* named "WrongTransaction"), no fields.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "WrongTransaction", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 0 ];
+ return orb.create_exception_tc(id(), "WrongTransaction", members);
}
/* Every user exception with no user defined
diff --git a/org/omg/CosNaming/BindingHelper.java b/org/omg/CosNaming/BindingHelper.java
index b5b420772..86b077016 100644
--- a/org/omg/CosNaming/BindingHelper.java
+++ b/org/omg/CosNaming/BindingHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -61,11 +62,6 @@ public abstract class BindingHelper
private static String _id = "IDL:omg.org/CosNaming/Binding:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the binding from the given {@link Any}.
*/
public static Binding extract(Any a)
@@ -115,21 +111,17 @@ public abstract class BindingHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
- TypeCode member;
- member = NameComponentHelper.type();
- member = orb.create_sequence_tc(0, member);
- member = orb.create_alias_tc(NameHelper.id(), "Name", member);
- members [ 0 ] = new StructMember("binding_name", member, null);
- member = BindingTypeHelper.type();
- members [ 1 ] = new StructMember("binding_type", member, null);
- typeCode = orb.create_struct_tc(id(), "Binding", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 0 ] = new StructMember("binding_name", member, null);
+ member = BindingTypeHelper.type();
+ members [ 1 ] = new StructMember("binding_type", member, null);
+ return orb.create_struct_tc(id(), "Binding", members);
}
/**
diff --git a/org/omg/CosNaming/BindingIteratorHelper.java b/org/omg/CosNaming/BindingIteratorHelper.java
index 64f7b4dfa..cb17d5748 100644
--- a/org/omg/CosNaming/BindingIteratorHelper.java
+++ b/org/omg/CosNaming/BindingIteratorHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -63,11 +64,6 @@ public abstract class BindingIteratorHelper
private static String _id = "IDL:omg.org/CosNaming/BindingIterator:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode = null;
-
- /**
* Extract the binding iterator from the given {@link Any}.
*/
public static BindingIterator extract(Any a)
@@ -167,9 +163,7 @@ public abstract class BindingIteratorHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "BindingIterator");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "BindingIterator");
}
/**
diff --git a/org/omg/CosNaming/BindingListHelper.java b/org/omg/CosNaming/BindingListHelper.java
index 44fe39dca..de04989e0 100644
--- a/org/omg/CosNaming/BindingListHelper.java
+++ b/org/omg/CosNaming/BindingListHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -58,11 +60,6 @@ public abstract class BindingListHelper
private static String _id = "IDL:omg.org/CosNaming/BindingList:1.0";
/**
- * The cached binding list type code.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the array of bindings from the given {@link Any}.
*/
public static Binding[] extract(Any a)
@@ -112,13 +109,11 @@ public abstract class BindingListHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- typeCode = BindingHelper.type();
- typeCode = orb.create_sequence_tc(0, typeCode);
- typeCode = orb.create_alias_tc(id(), "BindingList", typeCode);
- }
+ TypeCode typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ typeCode = BindingHelper.type();
+ typeCode = orb.create_sequence_tc(0, typeCode);
+ typeCode = orb.create_alias_tc(id(), "BindingList", typeCode);
return typeCode;
}
diff --git a/org/omg/CosNaming/BindingTypeHelper.java b/org/omg/CosNaming/BindingTypeHelper.java
index 2f0dc71c4..8f456ee70 100644
--- a/org/omg/CosNaming/BindingTypeHelper.java
+++ b/org/omg/CosNaming/BindingTypeHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,8 +59,6 @@ public abstract class BindingTypeHelper
* The binding type repository id.
*/
private static String id = "IDL:omg.org/CosNaming/BindingType:1.0";
- private static TypeCode typeCode = null;
-
/**
* Extract the binding type from the given {@link Any}.
*/
@@ -105,16 +104,10 @@ public abstract class BindingTypeHelper
/**
* Get the type code of this enumeration.
*/
- public static synchronized TypeCode type()
+ public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode =
- ORB.init().create_enum_tc(id(), "BindingType",
- new String[] { "nobject", "ncontext" }
- );
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_enum_tc(id(), "BindingType",
+ new String[] { "nobject", "ncontext" });
}
/**
diff --git a/org/omg/CosNaming/NameComponentHelper.java b/org/omg/CosNaming/NameComponentHelper.java
index 8499edfe6..8127aa01d 100644
--- a/org/omg/CosNaming/NameComponentHelper.java
+++ b/org/omg/CosNaming/NameComponentHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -61,11 +62,6 @@ public abstract class NameComponentHelper
private static String _id = "IDL:omg.org/CosNaming/NameComponent:1.0";
/**
- * The cached type code.
- */
- private static TypeCode typeCode = null;
-
- /**
* Extract the name component from this {@link Any}
*/
public static NameComponent extract(Any a)
@@ -116,22 +112,18 @@ public abstract class NameComponentHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
- TypeCode member;
- member = orb.create_string_tc(0);
- members [ 0 ] = new StructMember("id", member, null);
- member = orb.create_string_tc(0);
- members [ 1 ] = new StructMember("kind", member, null);
- typeCode =
- orb.create_struct_tc(NameComponentHelper.id(), "NameComponent",
- members
- );
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = orb.create_string_tc(0);
+ members [ 0 ] = new StructMember("id", member, null);
+ member = orb.create_string_tc(0);
+ members [ 1 ] = new StructMember("kind", member, null);
+ return
+ orb.create_struct_tc(NameComponentHelper.id(), "NameComponent",
+ members
+ );
}
/**
diff --git a/org/omg/CosNaming/NameHelper.java b/org/omg/CosNaming/NameHelper.java
index 18faf3182..f66fa4f09 100644
--- a/org/omg/CosNaming/NameHelper.java
+++ b/org/omg/CosNaming/NameHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -62,11 +63,6 @@ public abstract class NameHelper
private static String _id = "IDL:omg.org/CosNaming/Name:1.0";
/**
- * The cached typecode of the Name.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the Name the given {@link Any}.
*/
public static NameComponent[] extract(Any a)
@@ -118,13 +114,11 @@ public abstract class NameHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode = NameComponentHelper.type();
- typeCode = ORB.init().create_sequence_tc(0, typeCode);
- typeCode =
- ORB.init().create_alias_tc(NameHelper.id(), "Name", typeCode);
- }
+ TypeCode typeCode;
+ typeCode = NameComponentHelper.type();
+ typeCode = OrbRestricted.Singleton.create_sequence_tc(0, typeCode);
+ typeCode =
+ OrbRestricted.Singleton.create_alias_tc(NameHelper.id(), "Name", typeCode);
return typeCode;
}
diff --git a/org/omg/CosNaming/NamingContextExtHelper.java b/org/omg/CosNaming/NamingContextExtHelper.java
index 86bf8c55d..aca0e9dfd 100644
--- a/org/omg/CosNaming/NamingContextExtHelper.java
+++ b/org/omg/CosNaming/NamingContextExtHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -63,11 +64,6 @@ public abstract class NamingContextExtHelper
private static String _id = "IDL:omg.org/CosNaming/NamingContextExt:1.0";
/**
- * The cached {@link NamingContextExt} typecode.
- */
- private static TypeCode typeCode = null;
-
- /**
* Extract the naming context from the given {@link Any}.
*/
public static NamingContextExt extract(Any a)
@@ -168,12 +164,8 @@ public abstract class NamingContextExtHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_interface_tc(NamingContextExtHelper.id(),
- "NamingContextExt"
- );
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(NamingContextExtHelper.id(),
+ "NamingContextExt");
}
/**
diff --git a/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
index cf4029ccf..810460744 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextExtPackage;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
@@ -60,11 +62,6 @@ public abstract class AddressHelper
"IDL:omg.org/CosNaming/NamingContextExt/Address:1.0";
/**
- * The cached type code (string alias).
- */
- private static TypeCode typeCode = null;
-
- /**
* Just extracts string from this {@link Any}.
*/
public static String extract(Any a)
@@ -99,13 +96,12 @@ public abstract class AddressHelper
/**
* Return the "Address", alias of String, typecode.
*/
- public static synchronized TypeCode type()
+ public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode = ORB.init().create_string_tc(0);
- typeCode = ORB.init().create_alias_tc(id(), "Address", typeCode);
- }
+ ORB orb = OrbRestricted.Singleton;
+ TypeCode typeCode;
+ typeCode = orb.create_string_tc(0);
+ typeCode = orb.create_alias_tc(id(), "Address", typeCode);
return typeCode;
}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
index 02f8fccb6..c7f3849a0 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextExtPackage;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
@@ -59,11 +61,6 @@ public abstract class InvalidAddressHelper
"IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static InvalidAddress extract(Any a)
@@ -102,16 +99,10 @@ public abstract class InvalidAddressHelper
/**
* Create the type code for this exception.
*/
- public static synchronized TypeCode type()
+ public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode =
- ORB.init().create_struct_tc(InvalidAddressHelper.id(),
- "InvalidAddress", new StructMember[ 0 ]
- );
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_struct_tc(InvalidAddressHelper.id(),
+ "InvalidAddress", new StructMember[0]);
}
public static void write(OutputStream ostream, InvalidAddress value)
diff --git a/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
index 24c69fcb9..06faa2ff9 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextExtPackage;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
@@ -61,11 +63,6 @@ public abstract class StringNameHelper
"IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0";
/**
- * The cached type code (string alias).
- */
- private static TypeCode typeCode;
-
- /**
* Just extracts string from this {@link Any}.
*/
public static String extract(Any a)
@@ -100,13 +97,11 @@ public abstract class StringNameHelper
/**
* Return the "StringName", alias of String, typecode.
*/
- public static synchronized TypeCode type()
+ public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode = ORB.init().create_string_tc(0);
- typeCode = ORB.init().create_alias_tc(id(), "StringName", typeCode);
- }
+ TypeCode typeCode;
+ typeCode = OrbRestricted.Singleton.create_string_tc(0);
+ typeCode = OrbRestricted.Singleton.create_alias_tc(id(), "StringName", typeCode);
return typeCode;
}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
index 503fe22d6..173bb989e 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextExtPackage;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
@@ -60,11 +62,6 @@ public abstract class URLStringHelper
"IDL:omg.org/CosNaming/NamingContextExt/URLString:1.0";
/**
- * The cached type code (string alias).
- */
- private static TypeCode typeCode;
-
- /**
* Just extracts string from this {@link Any}.
*/
public static String extract(Any a)
@@ -99,13 +96,11 @@ public abstract class URLStringHelper
/**
* Return the "URLString", alias of String, typecode.
*/
- public static synchronized TypeCode type()
+ public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode = ORB.init().create_string_tc(0);
- typeCode = ORB.init().create_alias_tc(id(), "URLString", typeCode);
- }
+ TypeCode typeCode;
+ typeCode = OrbRestricted.Singleton.create_string_tc(0);
+ typeCode = OrbRestricted.Singleton.create_alias_tc(id(), "URLString", typeCode);
return typeCode;
}
diff --git a/org/omg/CosNaming/NamingContextHelper.java b/org/omg/CosNaming/NamingContextHelper.java
index fb9b091a6..48b90c25a 100644
--- a/org/omg/CosNaming/NamingContextHelper.java
+++ b/org/omg/CosNaming/NamingContextHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -63,11 +64,6 @@ public abstract class NamingContextHelper
private static String _id = "IDL:omg.org/CosNaming/NamingContext:1.0";
/**
- * The cached {@link NamingContext} typecode.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the naming context from the given {@link Any}.
*/
public static NamingContext extract(Any a)
@@ -176,9 +172,7 @@ public abstract class NamingContextHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "NamingContext");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "NamingContext");
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
index 6bf7bd7a6..f43111cb2 100644
--- a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -62,11 +63,6 @@ public abstract class AlreadyBoundHelper
"IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static AlreadyBound extract(Any a)
@@ -117,10 +113,8 @@ public abstract class AlreadyBoundHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_struct_tc(id(), "AlreadyBound", new StructMember[ 0 ]);
- return typeCode;
+ return
+ OrbRestricted.Singleton.create_struct_tc(id(), "AlreadyBound", new StructMember[ 0 ]);
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
index 1d0b6049b..85e391cf8 100644
--- a/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -65,11 +66,6 @@ public abstract class CannotProceedHelper
"IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static CannotProceed extract(Any a)
@@ -122,21 +118,17 @@ public abstract class CannotProceedHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
- TypeCode member;
- member = NamingContextHelper.type();
- members [ 0 ] = new StructMember("cxt", member, null);
- member = NameComponentHelper.type();
- member = orb.create_sequence_tc(0, member);
- member = orb.create_alias_tc(NameHelper.id(), "Name", member);
- members [ 1 ] = new StructMember("rest_of_name", member, null);
- typeCode = orb.create_struct_tc(id(), "CannotProceed", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = NamingContextHelper.type();
+ members [ 0 ] = new StructMember("cxt", member, null);
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 1 ] = new StructMember("rest_of_name", member, null);
+ return orb.create_struct_tc(id(), "CannotProceed", members);
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
index 8f1133602..5893332b8 100644
--- a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -62,11 +63,6 @@ public abstract class InvalidNameHelper
"IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static InvalidName extract(Any a)
@@ -117,15 +113,8 @@ public abstract class InvalidNameHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- if (typeCode == null)
- typeCode =
- ORB.init().create_struct_tc(id(), "InvalidName",
- new StructMember[ 0 ]
- );
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_struct_tc(id(),
+ "InvalidName", new StructMember[0]);
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
index 6333dfcbc..a9b802f95 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -62,11 +63,6 @@ public abstract class NotEmptyHelper
"IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static NotEmpty extract(Any a)
@@ -117,10 +113,8 @@ public abstract class NotEmptyHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_struct_tc(id(), "NotEmpty", new StructMember[ 0 ]);
- return typeCode;
+ return OrbRestricted.Singleton.create_struct_tc(id(),
+ "NotEmpty", new StructMember[0]);
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
index 442b7db9e..0be9b75bc 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -64,11 +65,6 @@ public abstract class NotFoundHelper
"IDL:omg.org/CosNaming/NamingContext/NotFound:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode = null;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static NotFound extract(Any a)
@@ -121,21 +117,17 @@ public abstract class NotFoundHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
-
- StructMember[] members = new StructMember[ 2 ];
- TypeCode member = null;
- member = NotFoundReasonHelper.type();
- members [ 0 ] = new StructMember("why", member, null);
- member = NameComponentHelper.type();
- member = orb.create_sequence_tc(0, member);
- member = orb.create_alias_tc(NameHelper.id(), "Name", member);
- members [ 1 ] = new StructMember("rest_of_name", member, null);
- typeCode = orb.create_struct_tc(id(), "NotFound", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member = null;
+ member = NotFoundReasonHelper.type();
+ members [ 0 ] = new StructMember("why", member, null);
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 1 ] = new StructMember("rest_of_name", member, null);
+ return orb.create_struct_tc(id(), "NotFound", members);
}
/**
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
index 45a42a0ba..9d44dcbf3 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -61,11 +62,6 @@ public abstract class NotFoundReasonHelper
"IDL:omg.org/CosNaming/NamingContext/NotFoundReason:1.0";
/**
- * The cached type code value.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the exception from the given {@link Any}.
*/
public static NotFoundReason extract(Any a)
@@ -112,15 +108,15 @@ public abstract class NotFoundReasonHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_enum_tc(id(), "NotFoundReason",
- new String[]
- {
- "missing_node", "not_context", "not_object"
- }
- );
- return typeCode;
+ return
+ OrbRestricted.Singleton.create_enum_tc(id(), "NotFoundReason",
+ new String[]
+ {
+ "missing_node",
+ "not_context",
+ "not_object"
+ }
+ );
}
/**
diff --git a/org/omg/DynamicAny/AnySeqHelper.java b/org/omg/DynamicAny/AnySeqHelper.java
index 60e4e6ea7..ddf1422ff 100644
--- a/org/omg/DynamicAny/AnySeqHelper.java
+++ b/org/omg/DynamicAny/AnySeqHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
@@ -54,11 +56,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class AnySeqHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Delegates call to {@link org.omg.CORBA.AnySeqHelper#extract}.
*/
public static Any[] extract(Any any)
@@ -102,14 +99,10 @@ public abstract class AnySeqHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- TypeCode t =
- orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_any));
- typeCode = orb.create_alias_tc(id(), "AnySeq", t);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ TypeCode t =
+ orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_any));
+ return orb.create_alias_tc(id(), "AnySeq", t);
}
/**
diff --git a/org/omg/DynamicAny/DynAnyFactoryHelper.java b/org/omg/DynamicAny/DynAnyFactoryHelper.java
index b8e3aafef..97b54873f 100644
--- a/org/omg/DynamicAny/DynAnyFactoryHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryHelper.java
@@ -40,6 +40,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
@@ -107,7 +108,7 @@ public abstract class DynAnyFactoryHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynAnyFactory");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynAnyFactory");
}
/**
diff --git a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
index a9f45c4b7..96dbb5fb6 100644
--- a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny.DynAnyFactoryPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,29 +59,19 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class InconsistentTypeCodeHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the InconsistentTypeCode typecode (structure,
- * named "InconsistentTypeCode").
+ * Create the InconsistentTypeCode typecode (structure, named
+ * "InconsistentTypeCode").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode =
- orb.create_exception_tc(id(), "InconsistentTypeCode", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "InconsistentTypeCode", members);
}
/**
* Insert the InconsistentTypeCode into the given Any.
- *
+ *
* @param any the Any to insert into.
* @param that the InconsistentTypeCode to insert.
*/
diff --git a/org/omg/DynamicAny/DynAnyHelper.java b/org/omg/DynamicAny/DynAnyHelper.java
index 73e2d9856..a238bf48b 100644
--- a/org/omg/DynamicAny/DynAnyHelper.java
+++ b/org/omg/DynamicAny/DynAnyHelper.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -104,7 +106,7 @@ public abstract class DynAnyHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynAny");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynAny");
}
/**
diff --git a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
index 1b5004f07..0258d3589 100644
--- a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny.DynAnyPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,13 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class InvalidValueHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the InvalidValue typecode (structure,
- * named "InvalidValue").
+ * Create the InvalidValue typecode (structure, named "InvalidValue").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "InvalidValue", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "InvalidValue", members);
}
/* Every user exception with no user defined
diff --git a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
index b09ab4db8..244a98aa0 100644
--- a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny.DynAnyPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,13 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class TypeMismatchHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the TypeMismatch typecode (structure,
- * named "TypeMismatch").
+ * Create the TypeMismatch typecode (structure, named "TypeMismatch").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "TypeMismatch", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "TypeMismatch", members);
}
/* Every user exception with no user defined
diff --git a/org/omg/DynamicAny/DynAnySeqHelper.java b/org/omg/DynamicAny/DynAnySeqHelper.java
index ec3f0c481..66208ea19 100644
--- a/org/omg/DynamicAny/DynAnySeqHelper.java
+++ b/org/omg/DynamicAny/DynAnySeqHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.DynAnySeqHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -63,20 +64,11 @@ import org.omg.CORBA.portable.OutputStream;
*/
public abstract class DynAnySeqHelper
{
- /**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- TypeCode t = orb.create_sequence_tc(0, DynAnyHelper.type());
- typeCode = orb.create_alias_tc(id(), "DynAnySeq", t);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ TypeCode t = orb.create_sequence_tc(0, DynAnyHelper.type());
+ return orb.create_alias_tc(id(), "DynAnySeq", t);
}
/**
diff --git a/org/omg/DynamicAny/DynArrayHelper.java b/org/omg/DynamicAny/DynArrayHelper.java
index f2892c856..26824d747 100644
--- a/org/omg/DynamicAny/DynArrayHelper.java
+++ b/org/omg/DynamicAny/DynArrayHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -103,7 +105,7 @@ public abstract class DynArrayHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynArray");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynArray");
}
/**
diff --git a/org/omg/DynamicAny/DynEnumHelper.java b/org/omg/DynamicAny/DynEnumHelper.java
index 8db1a2006..9af2e1194 100644
--- a/org/omg/DynamicAny/DynEnumHelper.java
+++ b/org/omg/DynamicAny/DynEnumHelper.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -104,7 +106,7 @@ public abstract class DynEnumHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynEnum");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynEnum");
}
/**
diff --git a/org/omg/DynamicAny/DynFixedHelper.java b/org/omg/DynamicAny/DynFixedHelper.java
index 84bb59d9f..4471bb26b 100644
--- a/org/omg/DynamicAny/DynFixedHelper.java
+++ b/org/omg/DynamicAny/DynFixedHelper.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -104,7 +106,7 @@ public abstract class DynFixedHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynFixed");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynFixed");
}
/**
diff --git a/org/omg/DynamicAny/DynSequenceHelper.java b/org/omg/DynamicAny/DynSequenceHelper.java
index ad3013371..0aa7cdd2a 100644
--- a/org/omg/DynamicAny/DynSequenceHelper.java
+++ b/org/omg/DynamicAny/DynSequenceHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -103,7 +105,7 @@ public abstract class DynSequenceHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynSequence");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynSequence");
}
/**
diff --git a/org/omg/DynamicAny/DynStructHelper.java b/org/omg/DynamicAny/DynStructHelper.java
index 021c5d031..c683260f6 100644
--- a/org/omg/DynamicAny/DynStructHelper.java
+++ b/org/omg/DynamicAny/DynStructHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -103,7 +105,7 @@ public abstract class DynStructHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynStruct");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynStruct");
}
/**
diff --git a/org/omg/DynamicAny/DynUnionHelper.java b/org/omg/DynamicAny/DynUnionHelper.java
index 8f924c086..e868ea412 100644
--- a/org/omg/DynamicAny/DynUnionHelper.java
+++ b/org/omg/DynamicAny/DynUnionHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -103,7 +105,7 @@ public abstract class DynUnionHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynUnion");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynUnion");
}
/**
diff --git a/org/omg/DynamicAny/DynValueHelper.java b/org/omg/DynamicAny/DynValueHelper.java
index 026ca4990..ad75bc31f 100644
--- a/org/omg/DynamicAny/DynValueHelper.java
+++ b/org/omg/DynamicAny/DynValueHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -103,7 +105,7 @@ public abstract class DynValueHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "DynValue");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "DynValue");
}
/**
diff --git a/org/omg/DynamicAny/NameDynAnyPairHelper.java b/org/omg/DynamicAny/NameDynAnyPairHelper.java
index a0e5c6b85..a9d9edba7 100644
--- a/org/omg/DynamicAny/NameDynAnyPairHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.Minor;
import gnu.CORBA.NameDynAnyPairHolder;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -64,11 +65,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class NameDynAnyPairHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the NameDynAnyPair from given Any.
* This method uses the NameDynAnyPairHolder.
*
@@ -107,25 +103,21 @@ public abstract class NameDynAnyPairHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 2 ];
-
- TypeCode field;
-
- field =
- orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
- "FieldName",
- orb.get_primitive_tc(TCKind.tk_string)
- );
- members [ 0 ] = new StructMember("id", field, null);
-
- field = DynAnyHelper.type();
- members [ 1 ] = new StructMember("value", field, null);
- typeCode = orb.create_struct_tc(id(), "NameDynAnyPair", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = DynAnyHelper.type();
+ members [ 1 ] = new StructMember("value", field, null);
+ return orb.create_struct_tc(id(), "NameDynAnyPair", members);
}
/**
diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
index ec4f72822..56e6104ec 100644
--- a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.Minor;
import gnu.CORBA.NameDynAnyPairSeqHolder;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -62,20 +63,11 @@ import org.omg.CORBA.portable.OutputStream;
*/
public abstract class NameDynAnyPairSeqHelper
{
- /**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- TypeCode t = orb.create_sequence_tc(0, NameDynAnyPairHelper.type());
- typeCode = orb.create_alias_tc(id(), "NameDynAnyPairSeq", t);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ TypeCode t = orb.create_sequence_tc(0, NameDynAnyPairHelper.type());
+ return orb.create_alias_tc(id(), "NameDynAnyPairSeq", t);
}
/**
diff --git a/org/omg/DynamicAny/NameValuePairHelper.java b/org/omg/DynamicAny/NameValuePairHelper.java
index 1e0f52b59..75bbf9a74 100644
--- a/org/omg/DynamicAny/NameValuePairHelper.java
+++ b/org/omg/DynamicAny/NameValuePairHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.Minor;
import gnu.CORBA.NameValuePairHolder;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,11 +59,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class NameValuePairHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the NameValuePair typecode (structure,
* named "NameValuePair").
* The typecode states that the structure contains the
@@ -70,25 +66,21 @@ public abstract class NameValuePairHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 2 ];
-
- TypeCode field;
-
- field =
- orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
- "FieldName",
- orb.get_primitive_tc(TCKind.tk_string)
- );
- members [ 0 ] = new StructMember("id", field, null);
-
- field = orb.get_primitive_tc(TCKind.tk_any);
- members [ 1 ] = new StructMember("value", field, null);
- typeCode = orb.create_struct_tc(id(), "NameValuePair", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = orb.get_primitive_tc(TCKind.tk_any);
+ members [ 1 ] = new StructMember("value", field, null);
+ return orb.create_struct_tc(id(), "NameValuePair", members);
}
/**
diff --git a/org/omg/DynamicAny/NameValuePairSeqHelper.java b/org/omg/DynamicAny/NameValuePairSeqHelper.java
index 62481534e..018ee7d2d 100644
--- a/org/omg/DynamicAny/NameValuePairSeqHelper.java
+++ b/org/omg/DynamicAny/NameValuePairSeqHelper.java
@@ -40,6 +40,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.Minor;
import gnu.CORBA.NameValuePairSeqHolder;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -55,20 +56,11 @@ import org.omg.CORBA.portable.OutputStream;
*/
public abstract class NameValuePairSeqHelper
{
- /**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- TypeCode t = orb.create_sequence_tc(0, NameValuePairHelper.type());
- typeCode = orb.create_alias_tc(id(), "NameValuePairSeq", t);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ TypeCode t = orb.create_sequence_tc(0, NameValuePairHelper.type());
+ return orb.create_alias_tc(id(), "NameValuePairSeq", t);
}
/**
diff --git a/org/omg/IOP/CodecFactoryHelper.java b/org/omg/IOP/CodecFactoryHelper.java
index fea0b887b..89404f7d5 100644
--- a/org/omg/IOP/CodecFactoryHelper.java
+++ b/org/omg/IOP/CodecFactoryHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -56,18 +58,11 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class CodecFactoryHelper
{
/**
- * The cached {@link CodecFactory} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link CodecFactory}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "CodecFactory");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "CodecFactory");
}
/**
diff --git a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
index e036dbf1f..8861e43da 100644
--- a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
+++ b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
@@ -40,6 +40,7 @@ package org.omg.IOP.CodecFactoryPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
@@ -59,25 +60,16 @@ import org.omg.CORBA.BAD_OPERATION;
public abstract class UnknownEncodingHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the UnknownEncoding typecode (structure,
* named "UnknownEncoding").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[0];
- typeCode =
- orb.create_exception_tc (id(), "UnknownEncoding", members);
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return
+ orb.create_exception_tc (id(), "UnknownEncoding", members);
- }
- return typeCode;
}
/* Every user exception with no user defined fields can use EmptyExceptionHolder */
diff --git a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
index e353be8f9..2a9295ae8 100644
--- a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
@@ -40,6 +40,7 @@ package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,14 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class FormatMismatchHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the FormatMismatch typecode (structure,
* named "FormatMismatch").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "FormatMismatch", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 0 ];
+ return orb.create_exception_tc(id(), "FormatMismatch", members);
}
/**
diff --git a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
index 8a93c5895..e2a8c9057 100644
--- a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
+++ b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
@@ -40,6 +40,7 @@ package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,29 +59,19 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class InvalidTypeForEncodingHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the InvalidTypeForEncoding typecode (structure,
- * named "InvalidTypeForEncoding").
+ * Create the InvalidTypeForEncoding typecode (structure, named
+ * "InvalidTypeForEncoding").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode =
- orb.create_exception_tc(id(), "InvalidTypeForEncoding", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "InvalidTypeForEncoding", members);
}
/**
* Insert the InvalidTypeForEncoding into the given Any.
- *
+ *
* @param any the Any to insert into.
* @param that the InvalidTypeForEncoding to insert.
*/
diff --git a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
index 33951de70..432e84d24 100644
--- a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
@@ -40,6 +40,7 @@ package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,14 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class TypeMismatchHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the TypeMismatch typecode (structure,
* named "TypeMismatch").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "TypeMismatch", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 0 ];
+ return orb.create_exception_tc(id(), "TypeMismatch", members);
}
/**
diff --git a/org/omg/IOP/ComponentIdHelper.java b/org/omg/IOP/ComponentIdHelper.java
index 64fbdfd74..35ffd9a69 100644
--- a/org/omg/IOP/ComponentIdHelper.java
+++ b/org/omg/IOP/ComponentIdHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -65,10 +67,10 @@ public abstract class ComponentIdHelper
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
- return orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0", "ComponentId",
- orb.get_primitive_tc(TCKind.tk_ulong)
- );
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0",
+ "ComponentId",
+ orb.get_primitive_tc(TCKind.tk_ulong));
}
/**
diff --git a/org/omg/IOP/IORHelper.java b/org/omg/IOP/IORHelper.java
index 77f18d9b9..197e15a12 100644
--- a/org/omg/IOP/IORHelper.java
+++ b/org/omg/IOP/IORHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -57,42 +58,30 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class IORHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the IOR typecode (structure,
- * named "IOR").
- * The typecode states that the structure contains the
- * following fields: type_id, profiles.
+ * Create the IOR typecode (structure, named "IOR"). The typecode states that
+ * the structure contains the following fields: type_id, profiles.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 2 ];
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[2];
- TypeCode field;
+ TypeCode field;
- field = orb.get_primitive_tc(TCKind.tk_string);
- members [ 0 ] = new StructMember("type_id", field, null);
+ field = orb.get_primitive_tc(TCKind.tk_string);
+ members[0] = new StructMember("type_id", field, null);
- field = orb.create_sequence_tc(0, TaggedProfileHelper.type());
- members [ 1 ] = new StructMember("profiles", field, null);
- typeCode = orb.create_struct_tc(id(), "IOR", members);
- }
- return typeCode;
+ field = orb.create_sequence_tc(0, TaggedProfileHelper.type());
+ members[1] = new StructMember("profiles", field, null);
+ return orb.create_struct_tc(id(), "IOR", members);
}
/**
- * Insert the IOR into the given Any.
- * This method uses the IORHolder.
- *
- * @param any the Any to insert into.
- * @param that the IOR to insert.
- */
+ * Insert the IOR into the given Any. This method uses the IORHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the IOR to insert.
+ */
public static void insert(Any any, IOR that)
{
any.insert_Streamable(new IORHolder(that));
diff --git a/org/omg/IOP/MultipleComponentProfileHelper.java b/org/omg/IOP/MultipleComponentProfileHelper.java
index 6f5156fe2..1c04ec54f 100644
--- a/org/omg/IOP/MultipleComponentProfileHelper.java
+++ b/org/omg/IOP/MultipleComponentProfileHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
@@ -57,24 +58,15 @@ import org.omg.CORBA.portable.InputStream;
*/
public abstract class MultipleComponentProfileHelper
{
- /**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- typeCode = orb.create_sequence_tc(0, TaggedComponentHelper.type());
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_sequence_tc(0, TaggedComponentHelper.type());
}
/**
- * Insert the MultipleComponentProfile into the given Any.
- * This method uses the MultipleComponentProfileHolder.
- *
+ * Insert the MultipleComponentProfile into the given Any. This method uses
+ * the MultipleComponentProfileHolder.
+ *
* @param any the Any to insert into.
* @param those the TaggedComponent[] to insert.
*/
diff --git a/org/omg/IOP/ProfileIdHelper.java b/org/omg/IOP/ProfileIdHelper.java
index 2e3c8f08d..340fa27d5 100644
--- a/org/omg/IOP/ProfileIdHelper.java
+++ b/org/omg/IOP/ProfileIdHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -65,15 +67,14 @@ public abstract class ProfileIdHelper
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0", "ProfileId",
- orb.get_primitive_tc(TCKind.tk_ulong)
- );
+ orb.get_primitive_tc(TCKind.tk_ulong));
}
/**
- * Insert the int into the given Any.
- */
+ * Insert the int into the given Any.
+ */
public static void insert(Any any, int that)
{
any.insert_ulong(that);
diff --git a/org/omg/IOP/ServiceContextHelper.java b/org/omg/IOP/ServiceContextHelper.java
index 5693a3235..d6549fa54 100644
--- a/org/omg/IOP/ServiceContextHelper.java
+++ b/org/omg/IOP/ServiceContextHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -57,46 +58,33 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ServiceContextHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the ServiceContext typecode (structure,
- * named "ServiceContext").
- * The typecode states that the structure contains the
- * following fields: context_id, context_data.
+ * Create the ServiceContext typecode (structure, named "ServiceContext"). The
+ * typecode states that the structure contains the following fields:
+ * context_id, context_data.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 2 ];
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[2];
- TypeCode field;
+ TypeCode field;
- field =
- orb.create_alias_tc("IDL:omg.org/IOP/ServiceId:1.0", "ServiceId",
- orb.get_primitive_tc(TCKind.tk_ulong)
- );
- members [ 0 ] = new StructMember("context_id", field, null);
+ field = orb.create_alias_tc("IDL:omg.org/IOP/ServiceId:1.0", "ServiceId",
+ orb.get_primitive_tc(TCKind.tk_ulong));
+ members[0] = new StructMember("context_id", field, null);
- field =
- orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
- members [ 1 ] = new StructMember("context_data", field, null);
- typeCode = orb.create_struct_tc(id(), "ServiceContext", members);
- }
- return typeCode;
+ field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
+ members[1] = new StructMember("context_data", field, null);
+ return orb.create_struct_tc(id(), "ServiceContext", members);
}
/**
- * Insert the ServiceContext into the given Any.
- * This method uses the ServiceContextHolder.
- *
- * @param any the Any to insert into.
- * @param that the ServiceContext to insert.
- */
+ * Insert the ServiceContext into the given Any. This method uses the
+ * ServiceContextHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the ServiceContext to insert.
+ */
public static void insert(Any any, ServiceContext that)
{
any.insert_Streamable(new ServiceContextHolder(that));
diff --git a/org/omg/IOP/ServiceContextListHelper.java b/org/omg/IOP/ServiceContextListHelper.java
index fa436cbb8..7875db29e 100644
--- a/org/omg/IOP/ServiceContextListHelper.java
+++ b/org/omg/IOP/ServiceContextListHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -56,18 +57,12 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ServiceContextListHelper
{
/**
- * The cached {@link ServiceContext[]} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link ServiceContext[]}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "ServiceContextList");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(),
+ "ServiceContextList");
}
/**
diff --git a/org/omg/IOP/ServiceIdHelper.java b/org/omg/IOP/ServiceIdHelper.java
index fac0746a8..084dbd06d 100644
--- a/org/omg/IOP/ServiceIdHelper.java
+++ b/org/omg/IOP/ServiceIdHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -65,7 +67,7 @@ public abstract class ServiceIdHelper
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc("IDL:omg.org/IOP/ServiceId:1.0", "ServiceId",
orb.get_primitive_tc(TCKind.tk_ulong)
);
diff --git a/org/omg/IOP/TaggedComponentHelper.java b/org/omg/IOP/TaggedComponentHelper.java
index eaee120f0..633891b9b 100644
--- a/org/omg/IOP/TaggedComponentHelper.java
+++ b/org/omg/IOP/TaggedComponentHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,34 +61,25 @@ import java.io.IOException;
public abstract class TaggedComponentHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the TaggedComponent typecode (structure, named "TaggedComponent").
* The typecode states that the structure contains the following fields: tag,
* component_data.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[2];
-
- TypeCode field;
-
- field = orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0",
- "ComponentId",
- orb.get_primitive_tc(TCKind.tk_ulong));
- members[0] = new StructMember("tag", field, null);
-
- field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
- members[1] = new StructMember("component_data", field, null);
- typeCode = orb.create_struct_tc(id(), "TaggedComponent", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[2];
+
+ TypeCode field;
+
+ field = orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0",
+ "ComponentId",
+ orb.get_primitive_tc(TCKind.tk_ulong));
+ members[0] = new StructMember("tag", field, null);
+
+ field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
+ members[1] = new StructMember("component_data", field, null);
+ return orb.create_struct_tc(id(), "TaggedComponent", members);
}
/**
diff --git a/org/omg/IOP/TaggedProfileHelper.java b/org/omg/IOP/TaggedProfileHelper.java
index 2943657c0..9dbbfdaff 100644
--- a/org/omg/IOP/TaggedProfileHelper.java
+++ b/org/omg/IOP/TaggedProfileHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
@@ -62,40 +63,30 @@ import java.io.IOException;
public abstract class TaggedProfileHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the TaggedProfile typecode (structure, named "TaggedProfile"). The
* typecode states that the structure contains the following fields: tag,
* profile_data.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[2];
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[2];
- TypeCode field;
+ TypeCode field;
- field = orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0",
- "ProfileId",
- orb.get_primitive_tc(TCKind.tk_ulong));
- members[0] = new StructMember("tag", field, null);
+ field = orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0", "ProfileId",
+ orb.get_primitive_tc(TCKind.tk_ulong));
+ members[0] = new StructMember("tag", field, null);
- field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
- members[1] = new StructMember("profile_data", field, null);
- typeCode = orb.create_struct_tc(id(), "TaggedProfile", members);
- }
- return typeCode;
+ field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
+ members[1] = new StructMember("profile_data", field, null);
+ return orb.create_struct_tc(id(), "TaggedProfile", members);
}
/**
* Insert the TaggedProfile into the given Any. This method uses the
* TaggedProfileHolder.
- *
+ *
* @param any the Any to insert into.
* @param that the TaggedProfile to insert.
*/
diff --git a/org/omg/PortableInterceptor/AdapterManagerIdHelper.java b/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
index f3f7e6441..936e6bc1b 100644
--- a/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
+++ b/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -57,15 +59,14 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class AdapterManagerIdHelper
{
/**
- * Create the AdapterManagerId typecode (alias of CORBA long (java int),
- * named "AdapterManagerId").
+ * Create the AdapterManagerId typecode (alias of CORBA long (java int), named
+ * "AdapterManagerId").
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "AdapterManagerId",
- orb.get_primitive_tc(TCKind.tk_long)
- );
+ orb.get_primitive_tc(TCKind.tk_long));
}
/**
diff --git a/org/omg/PortableInterceptor/AdapterNameHelper.java b/org/omg/PortableInterceptor/AdapterNameHelper.java
index 1cda311b2..05844560a 100644
--- a/org/omg/PortableInterceptor/AdapterNameHelper.java
+++ b/org/omg/PortableInterceptor/AdapterNameHelper.java
@@ -61,11 +61,6 @@ public abstract class AdapterNameHelper
{
/**
- * The cached typecode, computed once.
- */
- static TypeCode typecode;
-
- /**
* Extract the adapter name (<code>String[]</code>) from the given {@link Any}.
*
* @param a an Any to extract the array from.
@@ -114,26 +109,22 @@ public abstract class AdapterNameHelper
}
/**
- * Creates and returns a new instance of the TypeCode,
- * corresponding the adapter name.
+ * Creates and returns a new instance of the TypeCode, corresponding the
+ * adapter name.
*
* @return the alias of the string sequence, named "AdapterName".
*/
public static TypeCode type()
{
- if (typecode == null)
- {
- ORB orb = OrbRestricted.Singleton;
-
- TypeCode component = orb.create_string_tc(0);
- typecode = orb.create_alias_tc(id(), "AdapterName", component);
- }
- return typecode;
+ ORB orb = OrbRestricted.Singleton;
+
+ TypeCode component = orb.create_string_tc(0);
+ return orb.create_alias_tc(id(), "AdapterName", component);
}
/**
* Writes the <code>String[]</code> into the given stream.
- *
+ *
* @param output the CORBA output stream to write.
* @param value the value that must be written.
*/
diff --git a/org/omg/PortableInterceptor/AdapterStateHelper.java b/org/omg/PortableInterceptor/AdapterStateHelper.java
index ceb7ac8d5..f0522caac 100644
--- a/org/omg/PortableInterceptor/AdapterStateHelper.java
+++ b/org/omg/PortableInterceptor/AdapterStateHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -62,7 +64,7 @@ public abstract class AdapterStateHelper
*/
public static TypeCode type()
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "AdapterState",
orb.get_primitive_tc(TCKind.tk_short)
);
diff --git a/org/omg/PortableInterceptor/CurrentHelper.java b/org/omg/PortableInterceptor/CurrentHelper.java
index df3bcaef7..e453f6010 100644
--- a/org/omg/PortableInterceptor/CurrentHelper.java
+++ b/org/omg/PortableInterceptor/CurrentHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -57,20 +58,11 @@ import org.omg.PortableServer.ServantActivator;
public abstract class CurrentHelper
{
/**
- * The cached {@link Current} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link Current}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- typeCode = ORB.init().create_interface_tc(id(), "Current");
- }
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(), "Current");
}
/**
diff --git a/org/omg/PortableInterceptor/ForwardRequestHelper.java b/org/omg/PortableInterceptor/ForwardRequestHelper.java
index 5db56d745..8aa19a991 100644
--- a/org/omg/PortableInterceptor/ForwardRequestHelper.java
+++ b/org/omg/PortableInterceptor/ForwardRequestHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.Interceptor.ForwardRequestHolder;
import org.omg.CORBA.Any;
@@ -58,32 +59,23 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ForwardRequestHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the ForwardRequest typecode (structure, named "ForwardRequest"). The
+ * Create the ForwardRequest typecode (structure, named "ForwardRequest"). The
* typecode states that the structure contains the following fields: forward.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 1 ];
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[1];
- TypeCode field = ObjectHelper.type();
- members [ 0 ] = new StructMember("forward", field, null);
- typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
- }
- return typeCode;
+ TypeCode field = ObjectHelper.type();
+ members[0] = new StructMember("forward", field, null);
+ return orb.create_exception_tc(id(), "ForwardRequest", members);
}
/**
* Insert the ForwardRequest into the given Any. This method uses the
* ForwardRequestHolder.
- *
+ *
* @param any the Any to insert into.
* @param that the ForwardRequest to insert.
*/
diff --git a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
index 565242477..926974f1a 100644
--- a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
+++ b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,18 +61,12 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class IORInterceptor_3_0Helper
{
/**
- * The cached {@link IORInterceptor_3_0} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link IORInterceptor_3_0}.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode = ORB.init().create_interface_tc(id(), "IORInterceptor_3_0");
- return typeCode;
+ return OrbRestricted.Singleton.create_interface_tc(id(),
+ "IORInterceptor_3_0");
}
/**
diff --git a/org/omg/PortableInterceptor/InvalidSlotHelper.java b/org/omg/PortableInterceptor/InvalidSlotHelper.java
index 98b259677..28558a000 100644
--- a/org/omg/PortableInterceptor/InvalidSlotHelper.java
+++ b/org/omg/PortableInterceptor/InvalidSlotHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableInterceptor;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -57,22 +58,13 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class InvalidSlotHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the InvalidSlot typecode (structure, named "InvalidSlot").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "InvalidSlot", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "InvalidSlot", members);
}
/*
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
index 648e9679b..2d9740a85 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
@@ -57,36 +57,25 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class DuplicateNameHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the DuplicateName typecode (structure,
- * named "DuplicateName").
- * The typecode states that the structure contains the
- * following fields: name.
+ * Create the DuplicateName typecode (structure, named "DuplicateName"). The
+ * typecode states that the structure contains the following fields: name.
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 1 ];
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[1];
- TypeCode field;
+ TypeCode field;
- field = orb.get_primitive_tc(TCKind.tk_string);
- members [ 0 ] = new StructMember("name", field, null);
- typeCode = orb.create_exception_tc(id(), "DuplicateName", members);
- }
- return typeCode;
+ field = orb.get_primitive_tc(TCKind.tk_string);
+ members[0] = new StructMember("name", field, null);
+ return orb.create_exception_tc(id(), "DuplicateName", members);
}
/**
- * Insert the DuplicateName into the given Any.
- * This method uses the DuplicateNameHolder.
- *
+ * Insert the DuplicateName into the given Any. This method uses the
+ * DuplicateNameHolder.
+ *
* @param any the Any to insert into.
* @param that the DuplicateName to insert.
*/
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
index f89f9d4c6..a87a3b747 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableInterceptor.ORBInitInfoPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,28 +59,18 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class InvalidNameHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the InvalidName typecode (structure,
- * named "InvalidName").
+ * Create the InvalidName typecode (structure, named "InvalidName").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "InvalidName", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "InvalidName", members);
}
/**
* Insert the InvalidName into the given Any.
- *
+ *
* @param any the Any to insert into.
* @param that the InvalidName to insert.
*/
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
index 55ee0be18..72c864811 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableInterceptor;
import gnu.CORBA.CDR.Vio;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,24 +61,16 @@ import org.omg.CORBA.VM_ABSTRACT;
public abstract class ObjectReferenceFactoryHelper
{
/**
- * The cached {@link ObjectReferenceFactory} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link ObjectReferenceFactory}.
- *
- * @return value type code with the agreed id, named
- * "ObjectReferenceFactory", abstract, no members, no base type.
+ *
+ * @return value type code with the agreed id, named "ObjectReferenceFactory",
+ * abstract, no members, no base type.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_value_tc(id(), "ObjectReferenceFactory",
- VM_ABSTRACT.value, null, new ValueMember[ 0 ]
- );
- return typeCode;
+ return OrbRestricted.Singleton.create_value_tc(id(), "ObjectReferenceFactory",
+ VM_ABSTRACT.value, null,
+ new ValueMember[0]);
}
/**
diff --git a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
index 258a73ae8..014c11308 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,24 +59,16 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ObjectReferenceTemplateHelper
{
/**
- * The cached {@link ObjectReferenceTemplate} typecode, computed once.
- */
- private static TypeCode typeCode;
-
- /**
* Get the type code of the {@link ObjectReferenceTemplate}.
- *
- * @return value type type code, named ObjectReferenceTemplate,
- * no members, abstract.
+ *
+ * @return value type type code, named ObjectReferenceTemplate, no members,
+ * abstract.
*/
public static TypeCode type()
{
- if (typeCode == null)
- typeCode =
- ORB.init().create_value_tc(id(), "ObjectReferenceTemplate",
- VM_ABSTRACT.value, null, new ValueMember[ 0 ]
- );
- return typeCode;
+ return OrbRestricted.Singleton.create_value_tc(id(), "ObjectReferenceTemplate",
+ VM_ABSTRACT.value, null,
+ new ValueMember[0]);
}
/**
diff --git a/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java b/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java
index c4f09896f..e84f3e6be 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java
@@ -57,11 +57,6 @@ import org.omg.CORBA.portable.Streamable;
public abstract class ObjectReferenceTemplateSeqHelper
{
/**
- * The type code, computed once.
- */
- static TypeCode typecode;
-
- /**
* Extract the <code>ObjectReferenceTemplate[]</code> from the given
* {@link Any}. This implementation expects the {@link Any} to hold the
* instance of {@link ObjectReferenceTemplateSeqHolder} that is returned by
@@ -142,15 +137,11 @@ public abstract class ObjectReferenceTemplateSeqHelper
*/
public static TypeCode type()
{
- if (typecode == null)
- {
- GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_sequence);
- t.setId(id());
- t.setLength(0);
- t.setContentType(ObjectReferenceTemplateHelper.type());
- typecode = t;
- }
- return typecode;
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_sequence);
+ t.setId(id());
+ t.setLength(0);
+ t.setContentType(ObjectReferenceTemplateHelper.type());
+ return t;
}
/**
diff --git a/org/omg/PortableServer/CurrentHelper.java b/org/omg/PortableServer/CurrentHelper.java
index 281cefa6d..3afbf669b 100644
--- a/org/omg/PortableServer/CurrentHelper.java
+++ b/org/omg/PortableServer/CurrentHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.OrbRestricted;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.NO_IMPLEMENT;
@@ -61,7 +63,7 @@ public abstract class CurrentHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "Current");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "Current");
}
/**
diff --git a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
index 848a3c3d3..02c74c535 100644
--- a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
+++ b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.CurrentPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,26 +59,19 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class NoContextHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
- * Create the NoContext typecode (structure,
- * named "NoContext").
+ * Create the NoContext typecode (structure, named "NoContext").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "NoContext", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[0];
+ return orb.create_exception_tc(id(), "NoContext", members);
}
- /* Every user exception with no user defined fields can use EmptyExceptionHolder */
+ /*
+ * Every user exception with no user defined fields can use
+ * EmptyExceptionHolder
+ */
/**
* Insert the NoContext into the given Any.
diff --git a/org/omg/PortableServer/ForwardRequestHelper.java b/org/omg/PortableServer/ForwardRequestHelper.java
index f4b0619b0..b30a2abeb 100644
--- a/org/omg/PortableServer/ForwardRequestHelper.java
+++ b/org/omg/PortableServer/ForwardRequestHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.Poa.ForwardRequestHolder;
import org.omg.CORBA.Any;
@@ -62,11 +63,6 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ForwardRequestHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Extract the ForwardRequest from given Any.
* This method uses the ForwardRequestHolder.
*
@@ -132,18 +128,14 @@ public abstract class ForwardRequestHelper
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 1 ];
TypeCode field;
field = ObjectHelper.type();
members [ 0 ] = new StructMember("forward_reference", field, null);
- typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
- }
- return typeCode;
+ return orb.create_exception_tc(id(), "ForwardRequest", members);
}
/**
diff --git a/org/omg/PortableServer/POAHelper.java b/org/omg/PortableServer/POAHelper.java
index 3712da00d..d6a951be5 100644
--- a/org/omg/PortableServer/POAHelper.java
+++ b/org/omg/PortableServer/POAHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
@@ -80,7 +81,7 @@ public abstract class POAHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "POA");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "POA");
}
/**
diff --git a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
index 2a587a412..e23d11997 100644
--- a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
+++ b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAManagerPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -58,23 +59,14 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class AdapterInactiveHelper
{
/**
- * The cached typecode value, computed only once.
- */
- private static TypeCode typeCode;
-
- /**
* Create the AdapterInactive typecode (structure,
* named "AdapterInactive").
*/
public static TypeCode type()
{
- if (typeCode == null)
- {
- ORB orb = ORB.init();
- StructMember[] members = new StructMember[ 0 ];
- typeCode = orb.create_exception_tc(id(), "AdapterInactive", members);
- }
- return typeCode;
+ ORB orb = OrbRestricted.Singleton;
+ StructMember[] members = new StructMember[ 0 ];
+ return orb.create_exception_tc(id(), "AdapterInactive", members);
}
/* Every user exception with no user defined
diff --git a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
index 61a410891..f616637ae 100644
--- a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class AdapterAlreadyExistsHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode =
orb.create_exception_tc(id(), "AdapterAlreadyExists", members);
diff --git a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
index dd318bf09..bad920a5a 100644
--- a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class AdapterNonExistentHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "AdapterNonExistent", members);
}
diff --git a/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java b/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
index 5e9e627c7..32ddae858 100644
--- a/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.Poa.InvalidPolicyHolder;
import org.omg.CORBA.Any;
@@ -72,7 +73,7 @@ public abstract class InvalidPolicyHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 1 ];
TypeCode field;
diff --git a/org/omg/PortableServer/POAPackage/NoServantHelper.java b/org/omg/PortableServer/POAPackage/NoServantHelper.java
index fd2c189fc..b9afb8ed7 100644
--- a/org/omg/PortableServer/POAPackage/NoServantHelper.java
+++ b/org/omg/PortableServer/POAPackage/NoServantHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class NoServantHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "NoServant", members);
}
diff --git a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
index 011867473..bf5e9cd9e 100644
--- a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class ObjectAlreadyActiveHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode =
orb.create_exception_tc(id(), "ObjectAlreadyActive", members);
diff --git a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
index 0d8ff473c..2f5867cbd 100644
--- a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class ObjectNotActiveHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "ObjectNotActive", members);
}
diff --git a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
index a74e67401..33ca06674 100644
--- a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class ServantAlreadyActiveHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode =
orb.create_exception_tc(id(), "ServantAlreadyActive", members);
diff --git a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
index 5fb52cf35..e86f4e948 100644
--- a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class ServantNotActiveHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "ServantNotActive", members);
}
diff --git a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
index cd862b081..7650014c1 100644
--- a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class WrongAdapterHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "WrongAdapter", members);
}
diff --git a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
index a1f27cbb0..a9e7fc594 100644
--- a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
@@ -40,6 +40,7 @@ package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -70,7 +71,7 @@ public abstract class WrongPolicyHelper
{
if (typeCode == null)
{
- ORB orb = ORB.init();
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 0 ];
typeCode = orb.create_exception_tc(id(), "WrongPolicy", members);
}
diff --git a/org/omg/PortableServer/ServantActivatorHelper.java b/org/omg/PortableServer/ServantActivatorHelper.java
index 8aa58b2f6..e1c4f09c8 100644
--- a/org/omg/PortableServer/ServantActivatorHelper.java
+++ b/org/omg/PortableServer/ServantActivatorHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -61,7 +62,7 @@ public abstract class ServantActivatorHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "ServantActivator");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "ServantActivator");
}
/**
diff --git a/org/omg/PortableServer/ServantLocatorHelper.java b/org/omg/PortableServer/ServantLocatorHelper.java
index 082c4c586..7bb933f7b 100644
--- a/org/omg/PortableServer/ServantLocatorHelper.java
+++ b/org/omg/PortableServer/ServantLocatorHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -60,7 +61,7 @@ public abstract class ServantLocatorHelper
*/
public static TypeCode type()
{
- return ORB.init().create_interface_tc(id(), "ServantLocator");
+ return OrbRestricted.Singleton.create_interface_tc(id(), "ServantLocator");
}
/**
diff --git a/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader b/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader
index b1a18ace3..4fd59badb 100644
--- a/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader
+++ b/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader
@@ -1 +1,2 @@
gnu.javax.sound.sampled.WAV.WAVReader
+gnu.javax.sound.sampled.AU.AUReader
diff --git a/tools/gnu/classpath/tools/keytool/Command.java b/tools/gnu/classpath/tools/keytool/Command.java
index da9293116..bc5cff2aa 100644
--- a/tools/gnu/classpath/tools/keytool/Command.java
+++ b/tools/gnu/classpath/tools/keytool/Command.java
@@ -374,6 +374,11 @@ abstract class Command
/**
* Convenience method to setup the key store given its type, its password, its
* location and portentially a specialized security provider.
+ * <p>
+ * Calls the method with the same name and 5 arguments passing
+ * <code>false</code> to the first argument implying that no attempt to
+ * create the keystore will be made if one was not found at the designated
+ * location.
*
* @param className the potentially null fully qualified class name of a
* security provider to add at runtime, if no installed provider is
@@ -388,10 +393,31 @@ abstract class Command
throws IOException, UnsupportedCallbackException, KeyStoreException,
NoSuchAlgorithmException, CertificateException
{
+ setKeyStoreParams(false, className, type, password, url);
+ }
+
+ /**
+ * Convenience method to setup the key store given its type, its password, its
+ * location and portentially a specialized security provider.
+ *
+ * @param createIfNotFound if <code>true</code> then create the keystore if
+ * it was not found; otherwise do not.
+ * @param className the potentially null fully qualified class name of a
+ * security provider to add at runtime, if no installed provider is
+ * able to provide a key store implementation of the desired type.
+ * @param type the potentially null type of the key store to request from the
+ * key store factory.
+ * @param password the potentially null password protecting the key store.
+ * @param url the URL of the key store.
+ */
+ protected void setKeyStoreParams(boolean createIfNotFound, String className,
+ String type, String password, String url)
+ throws IOException, UnsupportedCallbackException, KeyStoreException,
+ NoSuchAlgorithmException, CertificateException
+ {
setProviderClassNameParam(className);
setKeystoreTypeParam(type);
- setKeystorePasswordParam(password);
- setKeystoreURLParam(url);
+ setKeystoreURLParam(createIfNotFound, url, password);
}
/**
@@ -402,7 +428,7 @@ abstract class Command
* security provider to add, if it is not already installed, to the
* set of available providers.
*/
- protected void setProviderClassNameParam(String className)
+ private void setProviderClassNameParam(String className)
{
if (Configuration.DEBUG)
log.fine("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -430,7 +456,7 @@ abstract class Command
* For GNU Classpath this is <i>gkr</i> which stands for the "Gnu
* KeyRing" specifications.
*/
- protected void setKeystoreTypeParam(String type)
+ private void setKeystoreTypeParam(String type)
{
if (Configuration.DEBUG)
log.fine("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -491,7 +517,7 @@ abstract class Command
* @throws SecurityException if no password is available, even after prompting
* the user.
*/
- protected void setKeyPasswordParam() throws IOException,
+ private void setKeyPasswordParam() throws IOException,
UnsupportedCallbackException
{
String prompt = Messages.getFormattedString("Command.21", alias); //$NON-NLS-1$
@@ -503,7 +529,7 @@ abstract class Command
throw new SecurityException(Messages.getString("Command.23")); //$NON-NLS-1$
}
- protected void setKeystorePasswordParam(String password) throws IOException,
+ private void setKeystorePasswordParam(String password) throws IOException,
UnsupportedCallbackException
{
if (password != null)
@@ -521,14 +547,20 @@ abstract class Command
/**
* Set the key store URL to use.
*
- * @param url
+ * @param createIfNotFound when <code>true</code> an attempt to create a
+ * keystore at the designated location will be made. If
+ * <code>false</code> then no file creation is carried out, which
+ * may cause an exception to be thrown later.
+ * @param url the full, or partial, URL to the keystore location.
+ * @param password an eventually null string to use when loading the keystore.
* @throws IOException
* @throws KeyStoreException
* @throws UnsupportedCallbackException
* @throws NoSuchAlgorithmException
* @throws CertificateException
*/
- protected void setKeystoreURLParam(String url) throws IOException,
+ private void setKeystoreURLParam(boolean createIfNotFound, String url,
+ String password) throws IOException,
KeyStoreException, UnsupportedCallbackException, NoSuchAlgorithmException,
CertificateException
{
@@ -541,16 +573,19 @@ abstract class Command
throw new InvalidParameterException(Messages.getString("Command.36")); //$NON-NLS-1$
url = userHome.trim() + "/.keystore"; //$NON-NLS-1$
- // if it does not exist create it
- new File(url).createNewFile();
+ // if it does not exist create it if required
+ if (createIfNotFound)
+ new File(url).createNewFile();
url = "file:" + url; //$NON-NLS-1$
}
else
{
url = url.trim();
if (url.indexOf(":") == -1) // if it does not exist create it //$NON-NLS-1$
- new File(url).createNewFile();
-
+ {
+ if (createIfNotFound)
+ new File(url).createNewFile();
+ }
url = "file:" + url; //$NON-NLS-1$
}
@@ -590,6 +625,8 @@ abstract class Command
store = KeyStore.getInstance(storeType, provider);
}
+ setKeystorePasswordParam(password);
+
// now we have a KeyStore instance. load it
// KeyStore public API claims: "...In order to create an empty keystore,
// you pass null as the InputStream argument to the load method.
diff --git a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
index e9034eac2..03a1555a8 100644
--- a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
+++ b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -303,7 +303,7 @@ class GenKeyCmd extends Command
void setup() throws Exception
{
- setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
setAliasParam(_alias);
setKeyPasswordParam(_password);
setAlgorithmParams(_keyAlgorithm, _sigAlgorithm);
diff --git a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
index 94234c5b9..d0de589d9 100644
--- a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
+++ b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -149,7 +149,7 @@ class IdentityDBCmd extends Command
void setup() throws Exception
{
setInputStreamParam(_idbFileName);
- setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
if (Configuration.DEBUG)
{
log.fine("-identitydb handler will use the following options:"); //$NON-NLS-1$
diff --git a/tools/gnu/classpath/tools/keytool/ImportCmd.java b/tools/gnu/classpath/tools/keytool/ImportCmd.java
index e733ad4c1..3a6ed872b 100644
--- a/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -292,7 +292,7 @@ class ImportCmd extends Command
void setup() throws Exception
{
setInputStreamParam(_certFileName);
- setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
setAliasParam(_alias);
setKeyPasswordNoPrompt(_password);
if (Configuration.DEBUG)