summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-14 23:12:35 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-14 23:12:35 +0000
commitffde862e033a0825e1e9972a89c0f1f80b261a8e (patch)
tree97037d2c09c8384d80531f67ec36a01205df6bdb
parentb415ff10527e977c3758234fd930e2c027bfa17d (diff)
downloadppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz
ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.zip
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog38
-rw-r--r--libjava/HACKING13
-rw-r--r--libjava/Makefile.in575
-rw-r--r--libjava/classpath/ChangeLog10772
-rw-r--r--libjava/classpath/INSTALL37
-rw-r--r--libjava/classpath/Makefile.in26
-rw-r--r--libjava/classpath/NEWS98
-rw-r--r--libjava/classpath/README56
-rw-r--r--libjava/classpath/THANKYOU1
-rw-r--r--libjava/classpath/aclocal.m423
-rwxr-xr-xlibjava/classpath/autogen.sh5
-rwxr-xr-xlibjava/classpath/config.guess50
-rwxr-xr-xlibjava/classpath/config.sub73
-rwxr-xr-xlibjava/classpath/configure532
-rw-r--r--libjava/classpath/configure.ac112
-rw-r--r--libjava/classpath/doc/Makefile.in10
-rw-r--r--libjava/classpath/doc/api/Makefile.in10
-rw-r--r--libjava/classpath/doc/tools.texinfo617
-rw-r--r--libjava/classpath/doc/vmintegration.texinfo438
-rw-r--r--libjava/classpath/examples/Makefile.am11
-rw-r--r--libjava/classpath/examples/Makefile.in27
-rw-r--r--libjava/classpath/examples/Makefile.java2d.in17
-rw-r--r--libjava/classpath/examples/README17
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java15
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java25
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java11
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java6
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java1018
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java296
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java1571
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java891
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java390
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/java2d/bench.c606
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/java2d/bench.h64
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java55
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java41
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java48
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java53
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java52
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java49
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java93
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestOS.java37
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestRuntime.java54
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java118
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java54
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java298
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java5
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java16
-rw-r--r--libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java180
-rw-r--r--libjava/classpath/external/Makefile.in10
-rw-r--r--libjava/classpath/external/relaxngDatatype/Makefile.in10
-rw-r--r--libjava/classpath/external/sax/Makefile.in10
-rw-r--r--libjava/classpath/external/w3c_dom/Makefile.in10
-rw-r--r--libjava/classpath/gnu/CORBA/ForwardRequestHelper.java25
-rw-r--r--libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java22
-rw-r--r--libjava/classpath/gnu/classpath/debug/SystemLogger.java8
-rw-r--r--libjava/classpath/gnu/classpath/debug/TeeInputStream.java98
-rw-r--r--libjava/classpath/gnu/classpath/debug/TeeOutputStream.java93
-rw-r--r--libjava/classpath/gnu/classpath/debug/TeeReader.java98
-rw-r--r--libjava/classpath/gnu/classpath/debug/TeeWriter.java93
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/Jdwp.java46
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java15
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java6
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java96
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/Event.java37
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/EventManager.java9
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java157
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java118
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java115
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java121
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java4
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java4
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java2
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java2
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java3
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java2
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java62
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java2
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java4
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java8
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java2
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java8
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java8
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java6
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/util/Location.java40
-rw-r--r--libjava/classpath/gnu/java/awt/ClasspathToolkit.java27
-rw-r--r--libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java172
-rw-r--r--libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java174
-rw-r--r--libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java125
-rw-r--r--libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java68
-rw-r--r--libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java42
-rw-r--r--libjava/classpath/gnu/java/awt/java2d/CubicSegment.java98
-rw-r--r--libjava/classpath/gnu/java/awt/java2d/LineSegment.java21
-rw-r--r--libjava/classpath/gnu/java/awt/java2d/QuadSegment.java24
-rw-r--r--libjava/classpath/gnu/java/awt/java2d/Segment.java37
-rw-r--r--libjava/classpath/gnu/java/awt/peer/ClasspathFontPeer.java7
-rw-r--r--libjava/classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java104
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java2
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java222
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java63
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java146
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java6
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java44
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java6
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java393
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java167
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java93
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java8
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java2
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java7
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkLabelPeer.java8
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java76
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java1
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java2
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java111
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java48
-rw-r--r--libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java16
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java16
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImage.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java7
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java21
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java5
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java4
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java3
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java35
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java6
-rw-r--r--libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java76
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/GLGraphics.java123
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/ImageConverter.java113
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/KeyboardMapping.java415
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XDialogPeer.java61
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XEventPump.java287
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XFontPeer.java766
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XFontPeer2.java335
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XFramePeer.java140
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XGraphics.java792
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XGraphics2D.java295
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XGraphicsConfiguration.java118
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XGraphicsDevice.java166
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XGraphicsEnvironment.java202
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XImage.java111
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XLightweightPeer.java56
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XToolkit.java608
-rw-r--r--libjava/classpath/gnu/java/awt/peer/x/XWindowPeer.java255
-rw-r--r--libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java4
-rw-r--r--libjava/classpath/gnu/java/io/PlatformHelper.java94
-rw-r--r--libjava/classpath/gnu/java/lang/management/BeanImpl.java84
-rw-r--r--libjava/classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java99
-rw-r--r--libjava/classpath/gnu/java/lang/management/CompilationMXBeanImpl.java105
-rw-r--r--libjava/classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java84
-rw-r--r--libjava/classpath/gnu/java/lang/management/MemoryMXBeanImpl.java322
-rw-r--r--libjava/classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java112
-rw-r--r--libjava/classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java225
-rw-r--r--libjava/classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java90
-rw-r--r--libjava/classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java197
-rw-r--r--libjava/classpath/gnu/java/lang/management/ThreadMXBeanImpl.java291
-rw-r--r--libjava/classpath/gnu/java/lang/management/package.html46
-rw-r--r--libjava/classpath/gnu/java/net/IndexListParser.java6
-rw-r--r--libjava/classpath/gnu/java/net/loader/FileResource.java82
-rw-r--r--libjava/classpath/gnu/java/net/loader/FileURLLoader.java145
-rw-r--r--libjava/classpath/gnu/java/net/loader/JarURLLoader.java215
-rw-r--r--libjava/classpath/gnu/java/net/loader/JarURLResource.java94
-rw-r--r--libjava/classpath/gnu/java/net/loader/RemoteResource.java78
-rw-r--r--libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java101
-rw-r--r--libjava/classpath/gnu/java/net/loader/Resource.java110
-rw-r--r--libjava/classpath/gnu/java/net/loader/URLLoader.java147
-rw-r--r--libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java84
-rw-r--r--libjava/classpath/gnu/java/net/local/LocalSocket.java5
-rw-r--r--libjava/classpath/gnu/java/net/local/LocalSocketImpl.java19
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java5
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java28
-rw-r--r--libjava/classpath/gnu/java/net/protocol/jar/Connection.java2
-rw-r--r--libjava/classpath/gnu/java/nio/PipeImpl.java32
-rw-r--r--libjava/classpath/gnu/java/nio/SelectionKeyImpl.java22
-rw-r--r--libjava/classpath/gnu/java/nio/SelectorImpl.java9
-rw-r--r--libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java69
-rw-r--r--libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java49
-rw-r--r--libjava/classpath/gnu/java/nio/charset/Provider.java30
-rw-r--r--libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java2
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java2
-rw-r--r--libjava/classpath/gnu/java/security/Configuration.java.in56
-rw-r--r--libjava/classpath/gnu/java/security/Engine.java56
-rw-r--r--libjava/classpath/gnu/java/security/OID.java27
-rw-r--r--libjava/classpath/gnu/java/security/PolicyFile.java23
-rw-r--r--libjava/classpath/gnu/java/security/Properties.java160
-rw-r--r--libjava/classpath/gnu/java/security/Registry.java69
-rw-r--r--libjava/classpath/gnu/java/security/hash/BaseHash.java61
-rw-r--r--libjava/classpath/gnu/java/security/hash/HashFactory.java89
-rw-r--r--libjava/classpath/gnu/java/security/hash/Haval.java410
-rw-r--r--libjava/classpath/gnu/java/security/hash/IMessageDigest.java72
-rw-r--r--libjava/classpath/gnu/java/security/hash/MD2.java163
-rw-r--r--libjava/classpath/gnu/java/security/hash/MD4.java169
-rw-r--r--libjava/classpath/gnu/java/security/hash/MD5.java166
-rw-r--r--libjava/classpath/gnu/java/security/hash/RipeMD128.java148
-rw-r--r--libjava/classpath/gnu/java/security/hash/RipeMD160.java163
-rw-r--r--libjava/classpath/gnu/java/security/hash/Sha160.java141
-rw-r--r--libjava/classpath/gnu/java/security/hash/Sha256.java150
-rw-r--r--libjava/classpath/gnu/java/security/hash/Sha384.java203
-rw-r--r--libjava/classpath/gnu/java/security/hash/Sha512.java209
-rw-r--r--libjava/classpath/gnu/java/security/hash/Tiger.java1339
-rw-r--r--libjava/classpath/gnu/java/security/hash/Whirlpool.java177
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/HavalSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/MD2Spi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/MD4Spi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/MD5Spi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/MessageDigestAdapter.java50
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/RipeMD128Spi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/RipeMD160Spi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/Sha160Spi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/Sha256Spi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/Sha384Spi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/Sha512Spi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/TigerSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/hash/WhirlpoolSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/HavalRandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/MD2RandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/MD4RandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/MD5RandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/RipeMD128RandomSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/RipeMD160RandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java53
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/Sha160RandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/Sha256RandomSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/Sha384RandomSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/Sha512RandomSpi.java20
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/TigerRandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java18
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/DSSKeyFactory.java35
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java63
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/DSSParameters.java2
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/DSSRawSignatureSpi.java22
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java97
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java44
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/RSAKeyFactory.java50
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java47
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java21
-rw-r--r--libjava/classpath/gnu/java/security/jce/sig/SignatureAdapter.java75
-rw-r--r--libjava/classpath/gnu/java/security/key/IKeyPairCodec.java56
-rw-r--r--libjava/classpath/gnu/java/security/key/IKeyPairGenerator.java23
-rw-r--r--libjava/classpath/gnu/java/security/key/KeyPairCodecFactory.java2
-rw-r--r--libjava/classpath/gnu/java/security/key/KeyPairGeneratorFactory.java61
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSKey.java128
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java259
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java20
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSKeyPairRawCodec.java250
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSKeyPairX509Codec.java98
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSPrivateKey.java78
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java72
-rw-r--r--libjava/classpath/gnu/java/security/key/dss/FIPS186.java108
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/GnuRSAKey.java72
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java119
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java74
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java110
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java58
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java210
-rw-r--r--libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java21
-rw-r--r--libjava/classpath/gnu/java/security/pkcs/PKCS7SignedData.java66
-rw-r--r--libjava/classpath/gnu/java/security/pkcs/SignerInfo.java79
-rw-r--r--libjava/classpath/gnu/java/security/prng/BasePRNG.java39
-rw-r--r--libjava/classpath/gnu/java/security/prng/EntropySource.java1
-rw-r--r--libjava/classpath/gnu/java/security/prng/IRandom.java156
-rw-r--r--libjava/classpath/gnu/java/security/prng/LimitReachedException.java18
-rw-r--r--libjava/classpath/gnu/java/security/prng/MDGenerator.java60
-rw-r--r--libjava/classpath/gnu/java/security/prng/PRNGFactory.java41
-rw-r--r--libjava/classpath/gnu/java/security/prng/RandomEvent.java11
-rw-r--r--libjava/classpath/gnu/java/security/prng/RandomEventListener.java8
-rw-r--r--libjava/classpath/gnu/java/security/provider/Gnu.java82
-rw-r--r--libjava/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java253
-rw-r--r--libjava/classpath/gnu/java/security/provider/X509CertificateFactory.java61
-rw-r--r--libjava/classpath/gnu/java/security/sig/BaseSignature.java98
-rw-r--r--libjava/classpath/gnu/java/security/sig/ISignature.java111
-rw-r--r--libjava/classpath/gnu/java/security/sig/ISignatureCodec.java11
-rw-r--r--libjava/classpath/gnu/java/security/sig/SignatureFactory.java24
-rw-r--r--libjava/classpath/gnu/java/security/sig/dss/DSSSignature.java204
-rw-r--r--libjava/classpath/gnu/java/security/sig/dss/DSSSignatureRawCodec.java105
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java142
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java190
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java267
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/RSA.java182
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java145
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java219
-rw-r--r--libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java79
-rw-r--r--libjava/classpath/gnu/java/security/util/Base64.java237
-rw-r--r--libjava/classpath/gnu/java/security/util/ByteArray.java (renamed from libjava/classpath/gnu/classpath/ByteArray.java)2
-rw-r--r--libjava/classpath/gnu/java/security/util/ExpirableObject.java70
-rw-r--r--libjava/classpath/gnu/java/security/util/IntegerUtil.java109
-rw-r--r--libjava/classpath/gnu/java/security/util/PRNG.java31
-rw-r--r--libjava/classpath/gnu/java/security/util/Prime2.java417
-rw-r--r--libjava/classpath/gnu/java/security/util/Sequence.java64
-rw-r--r--libjava/classpath/gnu/java/security/util/SimpleList.java50
-rw-r--r--libjava/classpath/gnu/java/security/util/Util.java353
-rw-r--r--libjava/classpath/gnu/java/security/x509/Util.java4
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509CRL.java73
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509CRLEntry.java41
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509Certificate.java16
-rw-r--r--libjava/classpath/gnu/java/security/x509/ext/Extension.java26
-rw-r--r--libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java5
-rw-r--r--libjava/classpath/gnu/java/util/prefs/EventDispatcher.java3
-rw-r--r--libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java78
-rw-r--r--libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java412
-rw-r--r--libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java298
-rw-r--r--libjava/classpath/gnu/java/util/regex/BacktrackStack.java (renamed from libjava/classpath/gnu/regexp/BacktrackStack.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexed.java (renamed from libjava/classpath/gnu/regexp/CharIndexed.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexedCharArray.java (renamed from libjava/classpath/gnu/regexp/CharIndexedCharArray.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexedCharSequence.java (renamed from libjava/classpath/gnu/regexp/CharIndexedCharSequence.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexedInputStream.java (renamed from libjava/classpath/gnu/regexp/CharIndexedInputStream.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexedString.java (renamed from libjava/classpath/gnu/regexp/CharIndexedString.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/CharIndexedStringBuffer.java (renamed from libjava/classpath/gnu/regexp/CharIndexedStringBuffer.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RE.java (renamed from libjava/classpath/gnu/regexp/RE.java)34
-rw-r--r--libjava/classpath/gnu/java/util/regex/REException.java (renamed from libjava/classpath/gnu/regexp/REException.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/REFilterInputStream.java (renamed from libjava/classpath/gnu/regexp/REFilterInputStream.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/REMatch.java (renamed from libjava/classpath/gnu/regexp/REMatch.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/REMatchEnumeration.java (renamed from libjava/classpath/gnu/regexp/REMatchEnumeration.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RESyntax.java (renamed from libjava/classpath/gnu/regexp/RESyntax.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/REToken.java (renamed from libjava/classpath/gnu/regexp/REToken.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenAny.java (renamed from libjava/classpath/gnu/regexp/RETokenAny.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenBackRef.java (renamed from libjava/classpath/gnu/regexp/RETokenBackRef.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenChar.java (renamed from libjava/classpath/gnu/regexp/RETokenChar.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenEnd.java (renamed from libjava/classpath/gnu/regexp/RETokenEnd.java)22
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenEndOfPreviousMatch.java (renamed from libjava/classpath/gnu/regexp/RETokenEndOfPreviousMatch.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenEndSub.java (renamed from libjava/classpath/gnu/regexp/RETokenEndSub.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenIndependent.java (renamed from libjava/classpath/gnu/regexp/RETokenIndependent.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenLookAhead.java (renamed from libjava/classpath/gnu/regexp/RETokenLookAhead.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenLookBehind.java (renamed from libjava/classpath/gnu/regexp/RETokenLookBehind.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenNamedProperty.java (renamed from libjava/classpath/gnu/regexp/RETokenNamedProperty.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenOneOf.java (renamed from libjava/classpath/gnu/regexp/RETokenOneOf.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenPOSIX.java (renamed from libjava/classpath/gnu/regexp/RETokenPOSIX.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenRange.java (renamed from libjava/classpath/gnu/regexp/RETokenRange.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenRepeated.java (renamed from libjava/classpath/gnu/regexp/RETokenRepeated.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenStart.java (renamed from libjava/classpath/gnu/regexp/RETokenStart.java)25
-rw-r--r--libjava/classpath/gnu/java/util/regex/RETokenWordBoundary.java (renamed from libjava/classpath/gnu/regexp/RETokenWordBoundary.java)2
-rw-r--r--libjava/classpath/gnu/java/util/regex/UncheckedRE.java (renamed from libjava/classpath/gnu/regexp/UncheckedRE.java)4
-rw-r--r--libjava/classpath/gnu/javax/crypto/RSACipherImpl.java211
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Assembly.java109
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Cascade.java203
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java22
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java24
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/DeflateTransformer.java124
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Direction.java30
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java20
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java33
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Operation.java32
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java52
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Stage.java103
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Transformer.java194
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/TransformerException.java58
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Anubis.java532
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/BaseCipher.java127
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java842
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Cast5.java1290
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/CipherFactory.java96
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/DES.java758
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/IBlockCipher.java130
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/IBlockCipherSpi.java64
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Khazad.java450
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/NullCipher.java45
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java783
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Serpent.java249
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Square.java415
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/TripleDES.java199
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Twofish.java678
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/WeakKeyException.java22
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/DiffieHellmanImpl.java67
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/GnuCrypto.java182
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/GnuSasl.java94
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java77
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java54
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java54
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java54
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java88
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java24
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java49
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java20
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java285
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java423
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java513
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java54
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java31
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java28
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java28
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java34
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java58
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java266
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacHavalSpi.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java44
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacAnubisImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacCast5Impl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacDESImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacImpl.java43
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacKhazadImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacSerpentImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacSquareImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/OMacTwofishImpl.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java16
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java22
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/params/BlockCipherParameters.java146
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/params/DEREncodingException.java5
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/params/DERReader.java35
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/params/DERWriter.java29
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java33
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java38
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java26
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java125
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java83
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyFactory.java29
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java6
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java57
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java40
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java25
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/BaseKeyAgreementParty.java88
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/GnuSecretKey.java48
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/IKeyAgreementParty.java43
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/IncomingMessage.java114
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/KeyAgreementException.java107
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/KeyAgreementFactory.java88
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/OutgoingMessage.java79
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java286
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java11
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java91
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java50
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java51
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java91
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/ElGamalReceiver.java36
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/ElGamalSender.java34
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java106
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java120
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java86
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java82
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/RFC2631.java98
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6Host.java82
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java113
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslClient.java53
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslServer.java53
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSClient.java62
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java69
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6User.java72
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPAlgorithm.java136
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPKey.java79
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java127
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java292
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPPrivateKey.java129
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRPPublicKey.java95
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/AuthenticatedEntry.java108
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/BaseKeyring.java78
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/BinaryDataEntry.java39
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/CertPathEntry.java31
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/CertificateEntry.java42
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/CompressedEntry.java34
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/EncryptedEntry.java90
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/Entry.java81
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java275
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java185
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java69
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/IKeyring.java102
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/IPrivateKeyring.java76
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/IPublicKeyring.java35
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/MalformedKeyringException.java7
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java57
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/MeteredInputStream.java18
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java203
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java174
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PasswordProtectedEntry.java15
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PrimitiveEntry.java41
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java79
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/Properties.java68
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java62
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/AESKeyWrap.java168
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java145
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java160
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/KeyUnwrappingException.java67
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java110
-rw-r--r--libjava/classpath/gnu/javax/crypto/kwa/TripleDESKeyWrap.java292
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/BaseMac.java43
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/HMac.java195
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/HMacFactory.java65
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/IMac.java154
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/MacFactory.java78
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/MacInputStream.java42
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/MacOutputStream.java59
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/OMAC.java211
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/TMMH16.java195
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/UHash32.java499
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/UMac32.java287
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/BaseMode.java153
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/CBC.java62
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/CFB.java116
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/CTR.java127
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/EAX.java127
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/ECB.java74
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java18
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/ICM.java139
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/IMode.java114
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/ModeFactory.java95
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/OFB.java128
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/BasePad.java148
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/IPad.java63
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/ISO10126.java109
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java90
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/PKCS7.java174
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/PadFactory.java87
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/SSL3.java44
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/TBC.java104
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/TLS1.java52
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/ARCFour.java88
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java1019
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/Fortuna.java110
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java252
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java103
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/PRNGFactory.java66
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/UMacGenerator.java136
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/AuthInfo.java40
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/AuthInfoProviderFactory.java34
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ClientFactory.java86
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java150
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProvider.java59
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java17
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java8
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/InputBuffer.java211
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/IntegrityException.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/NoSuchMechanismException.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/NoSuchUserException.java10
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/OutputBuffer.java113
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/SaslEncodingException.java8
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/SaslInputStream.java316
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java123
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/SaslUtil.java16
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ServerFactory.java76
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ServerMechanism.java157
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/UserAlreadyExistsException.java6
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousClient.java36
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousServer.java27
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java44
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java62
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Client.java63
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java8
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Server.java51
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Util.java33
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/crammd5/PasswordFile.java121
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java150
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java72
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/plain/PlainClient.java73
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/plain/PlainRegistry.java12
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/plain/PlainServer.java83
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/CALG.java173
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/ClientStore.java66
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java49
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/KDF.java69
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/PasswordFile.java308
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRP.java94
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java77
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java795
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRPRegistry.java80
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java814
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SecurityContext.java28
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/ServerStore.java73
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java24
-rw-r--r--libjava/classpath/gnu/javax/imageio/IIOInputStream.java102
-rw-r--r--libjava/classpath/gnu/javax/imageio/gif/GIFFile.java709
-rw-r--r--libjava/classpath/gnu/javax/imageio/gif/GIFImageReader.java241
-rw-r--r--libjava/classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java124
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/DCT.java347
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/HuffmanTable.java207
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGComponent.java351
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java630
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGException.java55
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGFrame.java108
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java195
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java141
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java137
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarker.java205
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java50
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/JPEGScan.java151
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java113
-rw-r--r--libjava/classpath/gnu/javax/imageio/jpeg/ZigZag.java520
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGChunk.java284
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGData.java (renamed from libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java)90
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGDecoder.java331
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGEncoder.java235
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGException.java48
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGFile.java258
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGFilter.java237
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGGamma.java89
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGHeader.java257
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGICCProfile.java114
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGImageReader.java224
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java128
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGPalette.java127
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGPhys.java112
-rw-r--r--libjava/classpath/gnu/javax/imageio/png/PNGTime.java83
-rw-r--r--libjava/classpath/gnu/javax/net/ssl/provider/KeyPool.java13
-rw-r--r--libjava/classpath/gnu/javax/print/CupsServer.java31
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppRequest.java16
-rw-r--r--libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java2
-rw-r--r--libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java72
-rw-r--r--libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java21
-rw-r--r--libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java100
-rw-r--r--libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java77
-rw-r--r--libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java (renamed from libjava/classpath/javax/swing/text/html/HTMLTableView.java)59
-rw-r--r--libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java114
-rw-r--r--libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java378
-rw-r--r--libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java199
-rw-r--r--libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java212
-rw-r--r--libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java236
-rw-r--r--libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java1
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java2
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java178
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java47
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java91
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java2
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java39
-rw-r--r--libjava/classpath/gnu/xml/dom/DomIterator.java14
-rw-r--r--libjava/classpath/gnu/xml/stream/SAXParser.java54
-rw-r--r--libjava/classpath/gnu/xml/stream/XMLParser.java261
-rw-r--r--libjava/classpath/gnu/xml/transform/ApplyTemplatesNode.java2
-rw-r--r--libjava/classpath/gnu/xml/transform/ForEachNode.java2
-rw-r--r--libjava/classpath/gnu/xml/transform/TransformerImpl.java19
-rw-r--r--libjava/classpath/include/GtkDragSourceContextPeer.h23
-rw-r--r--libjava/classpath/include/Makefile.am27
-rw-r--r--libjava/classpath/include/Makefile.in37
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h7
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h3
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h1
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h27
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h20
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h7
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h2
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h2
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h1
-rw-r--r--libjava/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h2
-rw-r--r--libjava/classpath/include/gnu_java_net_local_LocalSocketImpl.h6
-rw-r--r--libjava/classpath/include/gnu_java_nio_VMChannel.h24
-rw-r--r--libjava/classpath/include/gnu_java_util_prefs_gconf_GConfNativePeer.h30
-rw-r--r--libjava/classpath/include/java_io_VMFile.h1
-rw-r--r--libjava/classpath/include/java_lang_VMSystem.h2
-rw-r--r--libjava/classpath/include/java_net_VMURLConnection.h22
-rw-r--r--libjava/classpath/include/jni.h41
-rw-r--r--libjava/classpath/java/awt/AWTEvent.java5
-rw-r--r--libjava/classpath/java/awt/BasicStroke.java123
-rw-r--r--libjava/classpath/java/awt/Canvas.java20
-rw-r--r--libjava/classpath/java/awt/CardLayout.java1
-rw-r--r--libjava/classpath/java/awt/CheckboxMenuItem.java20
-rw-r--r--libjava/classpath/java/awt/Choice.java20
-rw-r--r--libjava/classpath/java/awt/Component.java1039
-rw-r--r--libjava/classpath/java/awt/Container.java334
-rw-r--r--libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java36
-rw-r--r--libjava/classpath/java/awt/Cursor.java15
-rw-r--r--libjava/classpath/java/awt/DefaultKeyboardFocusManager.java140
-rw-r--r--libjava/classpath/java/awt/EventDispatchThread.java12
-rw-r--r--libjava/classpath/java/awt/FileDialog.java52
-rw-r--r--libjava/classpath/java/awt/FlowLayout.java10
-rw-r--r--libjava/classpath/java/awt/Font.java39
-rw-r--r--libjava/classpath/java/awt/Graphics2D.java12
-rw-r--r--libjava/classpath/java/awt/GridBagConstraints.java139
-rw-r--r--libjava/classpath/java/awt/GridBagLayout.java116
-rw-r--r--libjava/classpath/java/awt/GridLayout.java12
-rw-r--r--libjava/classpath/java/awt/Image.java38
-rw-r--r--libjava/classpath/java/awt/Insets.java7
-rw-r--r--libjava/classpath/java/awt/KeyboardFocusManager.java92
-rw-r--r--libjava/classpath/java/awt/Label.java434
-rw-r--r--libjava/classpath/java/awt/LightweightDispatcher.java44
-rw-r--r--libjava/classpath/java/awt/List.java38
-rw-r--r--libjava/classpath/java/awt/Menu.java20
-rw-r--r--libjava/classpath/java/awt/MenuBar.java22
-rw-r--r--libjava/classpath/java/awt/MenuComponent.java14
-rw-r--r--libjava/classpath/java/awt/MenuItem.java25
-rw-r--r--libjava/classpath/java/awt/MouseInfo.java95
-rw-r--r--libjava/classpath/java/awt/Point.java13
-rw-r--r--libjava/classpath/java/awt/PointerInfo.java84
-rw-r--r--libjava/classpath/java/awt/PopupMenu.java24
-rw-r--r--libjava/classpath/java/awt/ScrollPane.java32
-rw-r--r--libjava/classpath/java/awt/Shape.java12
-rw-r--r--libjava/classpath/java/awt/TextArea.java64
-rw-r--r--libjava/classpath/java/awt/TextComponent.java680
-rw-r--r--libjava/classpath/java/awt/TextField.java738
-rw-r--r--libjava/classpath/java/awt/Toolkit.java21
-rw-r--r--libjava/classpath/java/awt/Window.java128
-rw-r--r--libjava/classpath/java/awt/datatransfer/Clipboard.java8
-rw-r--r--libjava/classpath/java/awt/datatransfer/DataFlavor.java114
-rw-r--r--libjava/classpath/java/awt/dnd/DragGestureEvent.java97
-rw-r--r--libjava/classpath/java/awt/dnd/DragGestureRecognizer.java1
-rw-r--r--libjava/classpath/java/awt/dnd/DragSource.java124
-rw-r--r--libjava/classpath/java/awt/dnd/DragSourceContext.java191
-rw-r--r--libjava/classpath/java/awt/dnd/DropTarget.java70
-rw-r--r--libjava/classpath/java/awt/dnd/DropTargetContext.java37
-rw-r--r--libjava/classpath/java/awt/dnd/DropTargetDragEvent.java17
-rw-r--r--libjava/classpath/java/awt/dnd/DropTargetDropEvent.java5
-rw-r--r--libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java1
-rw-r--r--libjava/classpath/java/awt/event/KeyEvent.java21
-rw-r--r--libjava/classpath/java/awt/font/FontRenderContext.java10
-rw-r--r--libjava/classpath/java/awt/font/LineBreakMeasurer.java107
-rw-r--r--libjava/classpath/java/awt/font/TextLayout.java232
-rw-r--r--libjava/classpath/java/awt/font/TextMeasurer.java149
-rw-r--r--libjava/classpath/java/awt/geom/GeneralPath.java8
-rw-r--r--libjava/classpath/java/awt/image/BandedSampleModel.java342
-rw-r--r--libjava/classpath/java/awt/image/BufferedImage.java53
-rw-r--r--libjava/classpath/java/awt/image/BufferedImageOp.java58
-rw-r--r--libjava/classpath/java/awt/image/ByteLookupTable.java17
-rw-r--r--libjava/classpath/java/awt/image/ColorConvertOp.java15
-rw-r--r--libjava/classpath/java/awt/image/ColorModel.java29
-rw-r--r--libjava/classpath/java/awt/image/ComponentSampleModel.java13
-rw-r--r--libjava/classpath/java/awt/image/ConvolveOp.java178
-rw-r--r--libjava/classpath/java/awt/image/DataBuffer.java23
-rw-r--r--libjava/classpath/java/awt/image/Kernel.java62
-rw-r--r--libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java458
-rw-r--r--libjava/classpath/java/awt/image/Raster.java780
-rw-r--r--libjava/classpath/java/awt/image/RasterOp.java50
-rw-r--r--libjava/classpath/java/awt/image/SampleModel.java461
-rw-r--r--libjava/classpath/java/awt/image/ShortLookupTable.java39
-rw-r--r--libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java307
-rw-r--r--libjava/classpath/java/awt/image/WritableRaster.java346
-rw-r--r--libjava/classpath/java/awt/peer/ComponentPeer.java33
-rw-r--r--libjava/classpath/java/awt/peer/MouseInfoPeer.java61
-rw-r--r--libjava/classpath/java/awt/peer/WindowPeer.java5
-rw-r--r--libjava/classpath/java/beans/VetoableChangeSupport.java16
-rw-r--r--libjava/classpath/java/beans/beancontext/BeanContextSupport.java291
-rw-r--r--libjava/classpath/java/io/File.java46
-rw-r--r--libjava/classpath/java/io/FilePermission.java7
-rw-r--r--libjava/classpath/java/io/ObjectInputStream.java18
-rw-r--r--libjava/classpath/java/io/ObjectOutputStream.java17
-rw-r--r--libjava/classpath/java/io/ObjectStreamClass.java11
-rw-r--r--libjava/classpath/java/io/ObjectStreamConstants.java126
-rw-r--r--libjava/classpath/java/io/OutputStream.java4
-rw-r--r--libjava/classpath/java/io/PrintStream.java76
-rw-r--r--libjava/classpath/java/lang/Iterable.java3
-rw-r--r--libjava/classpath/java/lang/SecurityManager.java4
-rw-r--r--libjava/classpath/java/lang/StrictMath.java498
-rw-r--r--libjava/classpath/java/lang/String.java2
-rw-r--r--libjava/classpath/java/lang/System.java31
-rw-r--r--libjava/classpath/java/lang/Thread.java184
-rw-r--r--libjava/classpath/java/lang/ThreadGroup.java41
-rw-r--r--libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java106
-rw-r--r--libjava/classpath/java/lang/management/ClassLoadingMXBean.java103
-rw-r--r--libjava/classpath/java/lang/management/CompilationMXBean.java85
-rw-r--r--libjava/classpath/java/lang/management/GarbageCollectorMXBean.java79
-rw-r--r--libjava/classpath/java/lang/management/ManagementFactory.java331
-rw-r--r--libjava/classpath/java/lang/management/ManagementPermission.java132
-rw-r--r--libjava/classpath/java/lang/management/MemoryMXBean.java172
-rw-r--r--libjava/classpath/java/lang/management/MemoryManagerMXBean.java77
-rw-r--r--libjava/classpath/java/lang/management/MemoryNotificationInfo.java215
-rw-r--r--libjava/classpath/java/lang/management/MemoryPoolMXBean.java318
-rw-r--r--libjava/classpath/java/lang/management/MemoryUsage.java265
-rw-r--r--libjava/classpath/java/lang/management/OperatingSystemMXBean.java103
-rw-r--r--libjava/classpath/java/lang/management/RuntimeMXBean.java278
-rw-r--r--libjava/classpath/java/lang/management/ThreadInfo.java704
-rw-r--r--libjava/classpath/java/lang/management/ThreadMXBean.java497
-rw-r--r--libjava/classpath/java/lang/management/package.html64
-rw-r--r--libjava/classpath/java/math/BigDecimal.java1077
-rw-r--r--libjava/classpath/java/math/BigInteger.java2
-rw-r--r--libjava/classpath/java/math/MathContext.java144
-rw-r--r--libjava/classpath/java/net/Inet6Address.java171
-rw-r--r--libjava/classpath/java/net/InetSocketAddress.java9
-rw-r--r--libjava/classpath/java/net/URL.java15
-rw-r--r--libjava/classpath/java/net/URLClassLoader.java758
-rw-r--r--libjava/classpath/java/net/URLConnection.java47
-rw-r--r--libjava/classpath/java/net/URLStreamHandler.java21
-rw-r--r--libjava/classpath/java/nio/CharBuffer.java12
-rw-r--r--libjava/classpath/java/nio/DirectByteBufferImpl.java1
-rw-r--r--libjava/classpath/java/nio/channels/FileChannel.java14
-rw-r--r--libjava/classpath/java/nio/channels/SelectionKey.java6
-rw-r--r--libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java6
-rw-r--r--libjava/classpath/java/rmi/server/UID.java30
-rw-r--r--libjava/classpath/java/security/Provider.java92
-rw-r--r--libjava/classpath/java/security/SecureRandom.java9
-rw-r--r--libjava/classpath/java/security/UnresolvedPermission.java41
-rw-r--r--libjava/classpath/java/security/cert/X509CertSelector.java4
-rw-r--r--libjava/classpath/java/text/AttributedString.java11
-rw-r--r--libjava/classpath/java/util/Arrays.java22
-rw-r--r--libjava/classpath/java/util/Calendar.java1
-rw-r--r--libjava/classpath/java/util/Collections.java181
-rw-r--r--libjava/classpath/java/util/DuplicateFormatFlagsException.java88
-rw-r--r--libjava/classpath/java/util/FormatFlagsConversionMismatchException.java111
-rw-r--r--libjava/classpath/java/util/Formattable.java92
-rw-r--r--libjava/classpath/java/util/FormattableFlags.java123
-rw-r--r--libjava/classpath/java/util/Formatter.java1294
-rw-r--r--libjava/classpath/java/util/FormatterClosedException.java60
-rw-r--r--libjava/classpath/java/util/GregorianCalendar.java4
-rw-r--r--libjava/classpath/java/util/IllegalFormatCodePointException.java85
-rw-r--r--libjava/classpath/java/util/IllegalFormatConversionException.java110
-rw-r--r--libjava/classpath/java/util/IllegalFormatException.java75
-rw-r--r--libjava/classpath/java/util/IllegalFormatFlagsException.java86
-rw-r--r--libjava/classpath/java/util/IllegalFormatPrecisionException.java85
-rw-r--r--libjava/classpath/java/util/IllegalFormatWidthException.java84
-rw-r--r--libjava/classpath/java/util/InputMismatchException.java73
-rw-r--r--libjava/classpath/java/util/MissingFormatArgumentException.java90
-rw-r--r--libjava/classpath/java/util/MissingFormatWidthException.java88
-rw-r--r--libjava/classpath/java/util/UUID.java383
-rw-r--r--libjava/classpath/java/util/UnknownFormatConversionException.java86
-rw-r--r--libjava/classpath/java/util/UnknownFormatFlagsException.java88
-rw-r--r--libjava/classpath/java/util/Vector.java6
-rw-r--r--libjava/classpath/java/util/jar/JarOutputStream.java2
-rw-r--r--libjava/classpath/java/util/jar/Manifest.java4
-rw-r--r--libjava/classpath/java/util/logging/FileHandler.java75
-rw-r--r--libjava/classpath/java/util/logging/LogManager.java82
-rw-r--r--libjava/classpath/java/util/logging/Logger.java2
-rw-r--r--libjava/classpath/java/util/logging/LoggingMXBean.java85
-rw-r--r--libjava/classpath/java/util/prefs/Preferences.java13
-rw-r--r--libjava/classpath/java/util/regex/Matcher.java6
-rw-r--r--libjava/classpath/java/util/regex/Pattern.java14
-rw-r--r--libjava/classpath/java/util/zip/ZipFile.java12
-rw-r--r--libjava/classpath/javax/accessibility/AccessibleContext.java2
-rw-r--r--libjava/classpath/javax/crypto/Cipher.java8
-rw-r--r--libjava/classpath/javax/crypto/spec/PBEKeySpec.java161
-rw-r--r--libjava/classpath/javax/crypto/spec/SecretKeySpec.java18
-rw-r--r--libjava/classpath/javax/imageio/spi/IIORegistry.java9
-rw-r--r--libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java195
-rw-r--r--libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java43
-rw-r--r--libjava/classpath/javax/management/Attribute.java5
-rw-r--r--libjava/classpath/javax/management/AttributeList.java220
-rw-r--r--libjava/classpath/javax/management/AttributeNotFoundException.java71
-rw-r--r--libjava/classpath/javax/management/DynamicMBean.java162
-rw-r--r--libjava/classpath/javax/management/IntrospectionException.java78
-rw-r--r--libjava/classpath/javax/management/InvalidAttributeValueException.java71
-rw-r--r--libjava/classpath/javax/management/JMException.java71
-rw-r--r--libjava/classpath/javax/management/JMRuntimeException.java71
-rw-r--r--libjava/classpath/javax/management/ListenerNotFoundException.java75
-rw-r--r--libjava/classpath/javax/management/MBeanAttributeInfo.java301
-rw-r--r--libjava/classpath/javax/management/MBeanConstructorInfo.java228
-rw-r--r--libjava/classpath/javax/management/MBeanException.java118
-rw-r--r--libjava/classpath/javax/management/MBeanFeatureInfo.java186
-rw-r--r--libjava/classpath/javax/management/MBeanInfo.java397
-rw-r--r--libjava/classpath/javax/management/MBeanNotificationInfo.java227
-rw-r--r--libjava/classpath/javax/management/MBeanOperationInfo.java344
-rw-r--r--libjava/classpath/javax/management/MBeanParameterInfo.java176
-rw-r--r--libjava/classpath/javax/management/NotCompliantMBeanException.java78
-rw-r--r--libjava/classpath/javax/management/Notification.java314
-rw-r--r--libjava/classpath/javax/management/NotificationBroadcaster.java112
-rw-r--r--libjava/classpath/javax/management/NotificationEmitter.java76
-rw-r--r--libjava/classpath/javax/management/NotificationFilter.java66
-rw-r--r--libjava/classpath/javax/management/NotificationListener.java70
-rw-r--r--libjava/classpath/javax/management/OperationsException.java76
-rw-r--r--libjava/classpath/javax/management/ReflectionException.java118
-rw-r--r--libjava/classpath/javax/management/RuntimeOperationsException.java121
-rw-r--r--libjava/classpath/javax/management/StandardMBean.java925
-rw-r--r--libjava/classpath/javax/management/openmbean/ArrayType.java313
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeData.java154
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeDataSupport.java349
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeType.java324
-rw-r--r--libjava/classpath/javax/management/openmbean/InvalidKeyException.java77
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenDataException.java79
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenType.java230
-rw-r--r--libjava/classpath/javax/management/openmbean/SimpleType.java342
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularData.java258
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularType.java269
-rw-r--r--libjava/classpath/javax/management/openmbean/package.html64
-rw-r--r--libjava/classpath/javax/naming/CompositeName.java9
-rw-r--r--libjava/classpath/javax/naming/CompoundName.java4
-rw-r--r--libjava/classpath/javax/naming/Context.java558
-rw-r--r--libjava/classpath/javax/naming/ContextNotEmptyException.java7
-rw-r--r--libjava/classpath/javax/naming/InitialContext.java424
-rw-r--r--libjava/classpath/javax/naming/NameParser.java22
-rw-r--r--libjava/classpath/javax/naming/NamingEnumeration.java49
-rw-r--r--libjava/classpath/javax/naming/PartialResultException.java6
-rw-r--r--libjava/classpath/javax/naming/Reference.java158
-rw-r--r--libjava/classpath/javax/naming/Referenceable.java14
-rw-r--r--libjava/classpath/javax/naming/SizeLimitExceededException.java7
-rw-r--r--libjava/classpath/javax/naming/spi/InitialContextFactory.java23
-rw-r--r--libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java17
-rw-r--r--libjava/classpath/javax/naming/spi/NamingManager.java394
-rw-r--r--libjava/classpath/javax/naming/spi/ObjectFactory.java32
-rw-r--r--libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java26
-rw-r--r--libjava/classpath/javax/naming/spi/ResolveResult.java82
-rw-r--r--libjava/classpath/javax/naming/spi/Resolver.java35
-rw-r--r--libjava/classpath/javax/naming/spi/StateFactory.java28
-rw-r--r--libjava/classpath/javax/rmi/ssl/SslRMIClientSocketFactory.java166
-rw-r--r--libjava/classpath/javax/rmi/ssl/SslRMIServerSocketFactory.java213
-rw-r--r--libjava/classpath/javax/security/auth/login/LoginContext.java8
-rw-r--r--libjava/classpath/javax/sound/midi/SysexMessage.java4
-rw-r--r--libjava/classpath/javax/sound/midi/Track.java4
-rw-r--r--libjava/classpath/javax/swing/AbstractButton.java57
-rw-r--r--libjava/classpath/javax/swing/AbstractCellEditor.java12
-rw-r--r--libjava/classpath/javax/swing/AbstractSpinnerModel.java2
-rw-r--r--libjava/classpath/javax/swing/Box.java10
-rw-r--r--libjava/classpath/javax/swing/BoxLayout.java2
-rw-r--r--libjava/classpath/javax/swing/ButtonGroup.java53
-rw-r--r--libjava/classpath/javax/swing/DefaultBoundedRangeModel.java34
-rw-r--r--libjava/classpath/javax/swing/DefaultButtonModel.java4
-rw-r--r--libjava/classpath/javax/swing/DefaultComboBoxModel.java4
-rw-r--r--libjava/classpath/javax/swing/DefaultListModel.java4
-rw-r--r--libjava/classpath/javax/swing/DefaultListSelectionModel.java117
-rw-r--r--libjava/classpath/javax/swing/GrayFilter.java5
-rw-r--r--libjava/classpath/javax/swing/InputMap.java131
-rw-r--r--libjava/classpath/javax/swing/JCheckBoxMenuItem.java187
-rw-r--r--libjava/classpath/javax/swing/JComboBox.java47
-rw-r--r--libjava/classpath/javax/swing/JComponent.java753
-rw-r--r--libjava/classpath/javax/swing/JFileChooser.java12
-rw-r--r--libjava/classpath/javax/swing/JInternalFrame.java195
-rw-r--r--libjava/classpath/javax/swing/JLabel.java351
-rw-r--r--libjava/classpath/javax/swing/JLayeredPane.java145
-rw-r--r--libjava/classpath/javax/swing/JList.java124
-rw-r--r--libjava/classpath/javax/swing/JMenu.java60
-rw-r--r--libjava/classpath/javax/swing/JMenuItem.java2
-rw-r--r--libjava/classpath/javax/swing/JOptionPane.java42
-rw-r--r--libjava/classpath/javax/swing/JPopupMenu.java2
-rw-r--r--libjava/classpath/javax/swing/JRadioButtonMenuItem.java1
-rw-r--r--libjava/classpath/javax/swing/JSplitPane.java3
-rw-r--r--libjava/classpath/javax/swing/JTabbedPane.java30
-rw-r--r--libjava/classpath/javax/swing/JTable.java236
-rw-r--r--libjava/classpath/javax/swing/JTree.java7
-rw-r--r--libjava/classpath/javax/swing/LookAndFeel.java18
-rw-r--r--libjava/classpath/javax/swing/ProgressMonitor.java26
-rw-r--r--libjava/classpath/javax/swing/ProgressMonitorInputStream.java2
-rw-r--r--libjava/classpath/javax/swing/RepaintManager.java208
-rw-r--r--libjava/classpath/javax/swing/ScrollPaneLayout.java9
-rw-r--r--libjava/classpath/javax/swing/SizeSequence.java6
-rw-r--r--libjava/classpath/javax/swing/SpringLayout.java2
-rw-r--r--libjava/classpath/javax/swing/SwingUtilities.java26
-rw-r--r--libjava/classpath/javax/swing/Timer.java10
-rw-r--r--libjava/classpath/javax/swing/ToolTipManager.java18
-rw-r--r--libjava/classpath/javax/swing/UIManager.java139
-rw-r--r--libjava/classpath/javax/swing/border/TitledBorder.java8
-rw-r--r--libjava/classpath/javax/swing/event/EventListenerList.java2
-rw-r--r--libjava/classpath/javax/swing/event/ListDataEvent.java60
-rw-r--r--libjava/classpath/javax/swing/event/MenuEvent.java28
-rw-r--r--libjava/classpath/javax/swing/event/TreeExpansionListener.java26
-rw-r--r--libjava/classpath/javax/swing/filechooser/FileSystemView.java21
-rw-r--r--libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java27
-rw-r--r--libjava/classpath/javax/swing/plaf/IconUIResource.java9
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java50
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java29
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java8
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java99
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java464
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java57
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java174
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java280
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java72
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicListUI.java124
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java26
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java98
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java30
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java28
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java220
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java675
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java78
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java50
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java17
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java1218
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java329
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTextFieldUI.java19
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java264
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java196
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java309
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java13
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java4
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java134
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java162
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java26
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java5
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java1
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java148
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalUtils.java90
-rw-r--r--libjava/classpath/javax/swing/table/DefaultTableColumnModel.java10
-rw-r--r--libjava/classpath/javax/swing/text/AbstractDocument.java208
-rw-r--r--libjava/classpath/javax/swing/text/BoxView.java264
-rw-r--r--libjava/classpath/javax/swing/text/CompositeView.java82
-rw-r--r--libjava/classpath/javax/swing/text/DefaultCaret.java86
-rw-r--r--libjava/classpath/javax/swing/text/EmptyAttributeSet.java153
-rw-r--r--libjava/classpath/javax/swing/text/FlowView.java75
-rw-r--r--libjava/classpath/javax/swing/text/GapContent.java371
-rw-r--r--libjava/classpath/javax/swing/text/IconView.java18
-rw-r--r--libjava/classpath/javax/swing/text/JTextComponent.java302
-rw-r--r--libjava/classpath/javax/swing/text/ParagraphView.java37
-rw-r--r--libjava/classpath/javax/swing/text/PlainDocument.java201
-rw-r--r--libjava/classpath/javax/swing/text/Segment.java10
-rw-r--r--libjava/classpath/javax/swing/text/SimpleAttributeSet.java6
-rw-r--r--libjava/classpath/javax/swing/text/StringContent.java6
-rw-r--r--libjava/classpath/javax/swing/text/TabSet.java121
-rw-r--r--libjava/classpath/javax/swing/text/TabStop.java68
-rw-r--r--libjava/classpath/javax/swing/text/View.java113
-rw-r--r--libjava/classpath/javax/swing/text/html/BRView.java71
-rw-r--r--libjava/classpath/javax/swing/text/html/HRuleView.java189
-rw-r--r--libjava/classpath/javax/swing/text/html/HTMLDocument.java370
-rw-r--r--libjava/classpath/javax/swing/text/html/HTMLEditorKit.java20
-rw-r--r--libjava/classpath/javax/swing/text/html/StyleSheet.java52
-rw-r--r--libjava/classpath/javax/swing/text/html/TableView.java137
-rw-r--r--libjava/classpath/javax/swing/text/html/parser/ParserDelegator.java3
-rw-r--r--libjava/classpath/javax/swing/text/rtf/RTFParser.java14
-rw-r--r--libjava/classpath/javax/swing/text/rtf/RTFScanner.java28
-rw-r--r--libjava/classpath/javax/swing/tree/TreePath.java2
-rw-r--r--libjava/classpath/lib/Makefile.am30
-rw-r--r--libjava/classpath/lib/Makefile.in41
-rw-r--r--libjava/classpath/lib/copy-vmresources.sh.in2
-rwxr-xr-xlibjava/classpath/lib/gen-classlist.sh.in6
-rwxr-xr-xlibjava/classpath/lib/mkcollections.pl.in3
-rw-r--r--libjava/classpath/lib/standard.omit3
-rw-r--r--libjava/classpath/lib/standard.omit.in1
-rw-r--r--libjava/classpath/native/Makefile.in10
-rw-r--r--libjava/classpath/native/fdlibm/Makefile.in10
-rw-r--r--libjava/classpath/native/jawt/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/Makefile.am9
-rw-r--r--libjava/classpath/native/jni/Makefile.in16
-rw-r--r--libjava/classpath/native/jni/classpath/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/gconf-peer/GConfNativePeer.c598
-rw-r--r--libjava/classpath/native/jni/gconf-peer/Makefile.am12
-rw-r--r--libjava/classpath/native/jni/gconf-peer/Makefile.in591
-rw-r--r--libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c256
-rw-r--r--libjava/classpath/native/jni/gtk-peer/Makefile.am3
-rw-r--r--libjava/classpath/native/jni/gtk-peer/Makefile.in22
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c95
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c46
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c32
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c547
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c318
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c36
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c27
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c2
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c31
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c3
-rw-r--r--libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c63
-rw-r--r--libjava/classpath/native/jni/java-io/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/java-io/java_io_VMFile.c236
-rw-r--r--libjava/classpath/native/jni/java-lang/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c9
-rw-r--r--libjava/classpath/native/jni/java-net/Makefile.am3
-rw-r--r--libjava/classpath/native/jni/java-net/Makefile.in21
-rw-r--r--libjava/classpath/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c44
-rw-r--r--libjava/classpath/native/jni/java-net/java_net_VMURLConnection.c (renamed from libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c)97
-rw-r--r--libjava/classpath/native/jni/java-nio/Makefile.am1
-rw-r--r--libjava/classpath/native/jni/java-nio/Makefile.in14
-rw-r--r--libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c525
-rw-r--r--libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c2
-rw-r--r--libjava/classpath/native/jni/java-util/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/midi-alsa/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/midi-dssi/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/midi-dssi/dssi_data.h7
-rw-r--r--libjava/classpath/native/jni/qt-peer/Makefile.am1
-rw-r--r--libjava/classpath/native/jni/qt-peer/Makefile.in10
-rw-r--r--libjava/classpath/native/jni/xmlj/Makefile.in10
-rw-r--r--libjava/classpath/native/plugin/Makefile.in10
-rw-r--r--libjava/classpath/native/target/Linux/Makefile.in10
-rw-r--r--libjava/classpath/native/target/Makefile.in10
-rw-r--r--libjava/classpath/native/target/generic/Makefile.in10
-rw-r--r--libjava/classpath/native/target/generic/target_generic_network.h3
-rw-r--r--libjava/classpath/org/omg/CORBA/CompletionStatusHelper.java23
-rw-r--r--libjava/classpath/org/omg/CORBA/CurrentHelper.java12
-rw-r--r--libjava/classpath/org/omg/CORBA/DefinitionKindHelper.java39
-rw-r--r--libjava/classpath/org/omg/CORBA/IDLTypeHelper.java15
-rw-r--r--libjava/classpath/org/omg/CORBA/NameValuePairHelper.java25
-rw-r--r--libjava/classpath/org/omg/CORBA/ObjectHelper.java7
-rw-r--r--libjava/classpath/org/omg/CORBA/ParameterModeHelper.java11
-rw-r--r--libjava/classpath/org/omg/CORBA/PolicyErrorCodeHelper.java2
-rw-r--r--libjava/classpath/org/omg/CORBA/PolicyErrorHelper.java32
-rw-r--r--libjava/classpath/org/omg/CORBA/PolicyHelper.java10
-rw-r--r--libjava/classpath/org/omg/CORBA/PolicyListHelper.java10
-rw-r--r--libjava/classpath/org/omg/CORBA/PolicyTypeHelper.java4
-rw-r--r--libjava/classpath/org/omg/CORBA/ServiceDetailHelper.java40
-rw-r--r--libjava/classpath/org/omg/CORBA/ServiceInformationHelper.java59
-rw-r--r--libjava/classpath/org/omg/CORBA/SetOverrideTypeHelper.java29
-rw-r--r--libjava/classpath/org/omg/CORBA/StringValueHelper.java18
-rw-r--r--libjava/classpath/org/omg/CORBA/UnionMemberHelper.java2
-rw-r--r--libjava/classpath/org/omg/CORBA/UnknownUserExceptionHelper.java14
-rw-r--r--libjava/classpath/org/omg/CORBA/VisibilityHelper.java11
-rw-r--r--libjava/classpath/org/omg/CORBA/WStringValueHelper.java18
-rw-r--r--libjava/classpath/org/omg/CORBA/WrongTransactionHelper.java16
-rw-r--r--libjava/classpath/org/omg/CosNaming/BindingHelper.java32
-rw-r--r--libjava/classpath/org/omg/CosNaming/BindingIteratorHelper.java10
-rw-r--r--libjava/classpath/org/omg/CosNaming/BindingListHelper.java19
-rw-r--r--libjava/classpath/org/omg/CosNaming/BindingTypeHelper.java15
-rw-r--r--libjava/classpath/org/omg/CosNaming/NameComponentHelper.java34
-rw-r--r--libjava/classpath/org/omg/CosNaming/NameHelper.java18
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextExtHelper.java14
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java18
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java19
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java17
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java17
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextHelper.java10
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java12
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java32
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java17
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java12
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java32
-rw-r--r--libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java24
-rw-r--r--libjava/classpath/org/omg/DynamicAny/AnySeqHelper.java19
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnyFactoryHelper.java3
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java23
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnyHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java19
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java19
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynAnySeqHelper.java16
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynArrayHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynEnumHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynFixedHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynSequenceHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynStructHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynUnionHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/DynValueHelper.java4
-rw-r--r--libjava/classpath/org/omg/DynamicAny/NameDynAnyPairHelper.java40
-rw-r--r--libjava/classpath/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java16
-rw-r--r--libjava/classpath/org/omg/DynamicAny/NameValuePairHelper.java40
-rw-r--r--libjava/classpath/org/omg/DynamicAny/NameValuePairSeqHelper.java16
-rw-r--r--libjava/classpath/org/omg/IOP/CodecFactoryHelper.java11
-rw-r--r--libjava/classpath/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java18
-rw-r--r--libjava/classpath/org/omg/IOP/CodecPackage/FormatMismatchHelper.java16
-rw-r--r--libjava/classpath/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java23
-rw-r--r--libjava/classpath/org/omg/IOP/CodecPackage/TypeMismatchHelper.java16
-rw-r--r--libjava/classpath/org/omg/IOP/ComponentIdHelper.java10
-rw-r--r--libjava/classpath/org/omg/IOP/IORHelper.java43
-rw-r--r--libjava/classpath/org/omg/IOP/MultipleComponentProfileHelper.java20
-rw-r--r--libjava/classpath/org/omg/IOP/ProfileIdHelper.java11
-rw-r--r--libjava/classpath/org/omg/IOP/ServiceContextHelper.java50
-rw-r--r--libjava/classpath/org/omg/IOP/ServiceContextListHelper.java11
-rw-r--r--libjava/classpath/org/omg/IOP/ServiceIdHelper.java4
-rw-r--r--libjava/classpath/org/omg/IOP/TaggedComponentHelper.java36
-rw-r--r--libjava/classpath/org/omg/IOP/TaggedProfileHelper.java31
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/AdapterManagerIdHelper.java11
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/AdapterNameHelper.java23
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/AdapterStateHelper.java4
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/CurrentHelper.java12
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ForwardRequestHelper.java24
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java11
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/InvalidSlotHelper.java16
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java33
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java21
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java21
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java21
-rw-r--r--libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java19
-rw-r--r--libjava/classpath/org/omg/PortableServer/CurrentHelper.java4
-rw-r--r--libjava/classpath/org/omg/PortableServer/CurrentPackage/NoContextHelper.java24
-rw-r--r--libjava/classpath/org/omg/PortableServer/ForwardRequestHelper.java14
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java16
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/NoServantHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/ServantActivatorHelper.java3
-rw-r--r--libjava/classpath/org/omg/PortableServer/ServantLocatorHelper.java3
-rw-r--r--libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory1
-rw-r--r--libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in1
-rw-r--r--libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader1
-rw-r--r--libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter1
-rw-r--r--libjava/classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader2
-rw-r--r--libjava/classpath/resource/Makefile.in10
-rw-r--r--libjava/classpath/resource/gnu/classpath/tools/jarsigner/messages.properties4
-rw-r--r--libjava/classpath/resource/gnu/classpath/tools/keytool/messages.properties28
-rw-r--r--libjava/classpath/resource/gnu/java/awt/peer/x/fonts.properties61
-rw-r--r--libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties (renamed from libjava/classpath/resource/gnu/regexp/MessagesBundle.properties)0
-rw-r--r--libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties (renamed from libjava/classpath/resource/gnu/regexp/MessagesBundle_fr.properties)0
-rw-r--r--libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties (renamed from libjava/classpath/resource/gnu/regexp/MessagesBundle_it.properties)2
-rw-r--r--libjava/classpath/resource/java/security/classpath.security10
-rw-r--r--libjava/classpath/scripts/Makefile.am2
-rw-r--r--libjava/classpath/scripts/Makefile.in12
-rwxr-xr-xlibjava/classpath/scripts/check_jni_methods.sh5
-rwxr-xr-xlibjava/classpath/scripts/import-cacerts.sh43
-rw-r--r--libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java340
-rwxr-xr-xlibjava/classpath/tools/Makefile.am40
-rw-r--r--libjava/classpath/tools/Makefile.in70
-rw-r--r--libjava/classpath/tools/gappletviewer.in46
-rw-r--r--libjava/classpath/tools/gjar.in47
-rw-r--r--libjava/classpath/tools/gjarsigner.in (renamed from libjava/classpath/tools/jarsigner.sh.in)18
-rw-r--r--libjava/classpath/tools/gkeytool.in (renamed from libjava/classpath/tools/keytool.sh.in)18
-rw-r--r--libjava/classpath/tools/gnative2ascii.in47
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java2
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java8
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java8
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java24
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java45
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java125
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java7
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java148
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java313
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java39
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java128
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java33
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java42
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java65
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java27
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java129
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java35
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java35
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java54
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java69
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java7
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java27
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java39
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java31
-rw-r--r--libjava/classpath/tools/gserialver.in47
-rw-r--r--libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java4
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java89
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java66
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java80
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java109
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java95
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java195
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java89
-rw-r--r--libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java207
-rw-r--r--libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java197
-rw-r--r--libjava/classpath/vm/reference/java/io/VMFile.java16
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMClassLoader.java8
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMSystem.java10
-rw-r--r--libjava/classpath/vm/reference/java/lang/VMThread.java12
-rw-r--r--libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java75
-rw-r--r--libjava/classpath/vm/reference/java/net/VMURLConnection.java79
-rw-r--r--libjava/classpath/vm/reference/sun/misc/Unsafe.java (renamed from libjava/classpath/vm/reference/gnu/classpath/Unsafe.java)6
-rw-r--r--libjava/classpath/vm/reference/sun/reflect/Reflection.java51
-rw-r--r--libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java92
-rwxr-xr-xlibjava/configure24
-rw-r--r--libjava/configure.ac15
-rw-r--r--libjava/gcj/Makefile.in1
-rw-r--r--libjava/gnu/awt/xlib/XToolkit.java7
-rw-r--r--libjava/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java100
-rw-r--r--libjava/gnu/java/lang/management/VMCompilationMXBeanImpl.java69
-rw-r--r--libjava/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java86
-rw-r--r--libjava/gnu/java/lang/management/VMMemoryMXBeanImpl.java120
-rw-r--r--libjava/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java98
-rw-r--r--libjava/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java231
-rw-r--r--libjava/gnu/java/lang/management/VMRuntimeMXBeanImpl.java95
-rw-r--r--libjava/gnu/java/lang/management/VMThreadMXBeanImpl.java233
-rw-r--r--libjava/gnu/java/nio/VMChannel.java199
-rw-r--r--libjava/include/Makefile.in1
-rw-r--r--libjava/java/lang/Class.h1
-rw-r--r--libjava/java/lang/Class.java13
-rw-r--r--libjava/java/lang/Thread.java13
-rw-r--r--libjava/java/lang/management/VMManagementFactory.java84
-rw-r--r--libjava/java/net/VMURLConnection.java76
-rw-r--r--libjava/javax/naming/spi/NamingManager.java654
-rwxr-xr-xlibjava/scripts/makemake.tcl3
-rw-r--r--libjava/sources.am538
-rw-r--r--libjava/testsuite/Makefile.in1
1294 files changed, 99369 insertions, 35823 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 836c083280f..fe6746d9267 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,41 @@
+2006-08-14 Mark Wielaard <mark@klomp.org>
+
+ Imported GNU Classpath 0.92
+ * HACKING: Add more importing hints. Update automake version
+ requirement.
+
+ * configure.ac (gconf-peer): New enable AC argument.
+ Add --disable-gconf-peer and --enable-default-preferences-peer
+ to classpath configure when gconf is disabled.
+ * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
+ gnu/java/awt/dnd/peer/gtk to bc. Classify
+ gnu/java/security/Configuration.java as generated source file.
+
+ * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
+ gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
+ gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
+ gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
+ gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
+ gnu/java/lang/management/VMThreadMXBeanImpl.java,
+ gnu/java/lang/management/VMMemoryMXBeanImpl.java,
+ gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
+ classes.
+ * java/lang/management/VMManagementFactory.java: Likewise.
+ * java/net/VMURLConnection.java: Likewise.
+ * gnu/java/nio/VMChannel.java: Likewise.
+
+ * java/lang/Thread.java (getState): Add stub implementation.
+ * java/lang/Class.java (isEnum): Likewise.
+ * java/lang/Class.h (isEnum): Likewise.
+
+ * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
+
+ * javax/naming/spi/NamingManager.java: New override for StackWalker
+ functionality.
+
+ * configure, sources.am, Makefile.in, gcj/Makefile.in,
+ include/Makefile.in, testsuite/Makefile.in: Regenerated.
+
2006-08-14 Gary Benson <gbenson@redhat.com>
* java/lang/Thread.java (accessControlState): New field.
diff --git a/libjava/HACKING b/libjava/HACKING
index 401cac2a37a..ec7ad418812 100644
--- a/libjava/HACKING
+++ b/libjava/HACKING
@@ -17,18 +17,23 @@ To import a new release:
- Check out a classpath snapshot or take a release tar.gz file.
I use 'cvs export' for this. Make a tag to ensure future hackers
know exactly what revision was checked out; tags are of the form
- 'libgcj-import-DATE'.
+ 'libgcj-import-DATE' (when using a tagged checkout do:
+ - ./autogen.sh && ./configure && make dist
+ to get a proper .tar.gz for importing below).
- Get a svn checkout of
svn+ssh://gcc.gnu.org/svn/gcc/branches/CLASSPATH/libjava/classpath
this contains "pure" GNU Classpath inside the GCC tree.
- Clean it up and get the files from a new version:
- - find classpath -type f | grep -v /\.svn | grep -v /\.cvs
+ - find classpath -type f | grep -v /\.svn | grep -v /\.cvs | xargs rm
- tar zxf classpath-x.tar.gz
- cp -r classpath-x/* classpath
- Add/Remove files:
- svn status classpath | grep ^\! | cut -c8- | xargs svn remove
- svn status classpath | grep ^\? | cut -c8- | xargs svn add
-- If there are any empty directories now they can be removed.
+- If there are any empty directories now they can be removed. You can find
+ candidates (dirs with files removed) with:
+ - for i in `svn status classpath | grep ^D | cut -c8-`; \
+ do ls -d `dirname $i`; done | uniq
- Update vendor branch
- svn commit classpath
- Note the new revision number (Xrev)
@@ -43,7 +48,7 @@ To import a new release:
in the classpath/ChangeLog.gcj file.
(Don't forget to svn resolved files.)
- Use auto* to create configure, Makefile.in, etc
- Make sure you have Automake 1.9.3 installed. Exactly that version!
+ Make sure you have Automake 1.9.6 installed. Exactly that version!
You have to make sure to use the gcc libtool.m4 and gcc lt* scripts
cd .../classpath
cp ../../lt* .
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 01ce21c38b2..d0c360f4767 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -149,12 +149,14 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
gnu/classpath/jdwp/transport.lo gnu/classpath/jdwp/util.lo \
gnu/gcj.lo gnu/gcj/convert.lo gnu/gcj/io.lo gnu/gcj/runtime.lo \
gnu/gcj/util.lo gnu/java/awt.lo gnu/java/awt/color.lo \
- gnu/java/awt/font.lo gnu/java/awt/font/opentype.lo \
+ gnu/java/awt/dnd.lo gnu/java/awt/font.lo \
+ gnu/java/awt/font/opentype.lo \
gnu/java/awt/font/opentype/truetype.lo gnu/java/awt/image.lo \
gnu/java/awt/java2d.lo gnu/java/awt/peer.lo \
gnu/java/awt/print.lo gnu/java/io.lo gnu/java/lang.lo \
- gnu/java/lang/reflect.lo gnu/java/locale.lo gnu/java/math.lo \
- gnu/java/net.lo gnu/java/net/local.lo \
+ gnu/java/lang/management.lo gnu/java/lang/reflect.lo \
+ gnu/java/locale.lo gnu/java/math.lo gnu/java/net.lo \
+ gnu/java/net/loader.lo gnu/java/net/local.lo \
gnu/java/net/protocol/core.lo gnu/java/net/protocol/file.lo \
gnu/java/net/protocol/ftp.lo gnu/java/net/protocol/gcjlib.lo \
gnu/java/net/protocol/http.lo gnu/java/net/protocol/https.lo \
@@ -174,20 +176,23 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
gnu/java/security/util.lo gnu/java/security/x509.lo \
gnu/java/security/x509/ext.lo gnu/java/text.lo \
gnu/java/util.lo gnu/java/util/jar.lo gnu/java/util/prefs.lo \
- gnu/javax/crypto.lo gnu/javax/crypto/assembly.lo \
- gnu/javax/crypto/cipher.lo gnu/javax/crypto/jce.lo \
- gnu/javax/crypto/jce/cipher.lo gnu/javax/crypto/jce/key.lo \
- gnu/javax/crypto/jce/keyring.lo gnu/javax/crypto/jce/mac.lo \
- gnu/javax/crypto/jce/params.lo gnu/javax/crypto/jce/prng.lo \
- gnu/javax/crypto/jce/sig.lo gnu/javax/crypto/jce/spec.lo \
- gnu/javax/crypto/key.lo gnu/javax/crypto/key/dh.lo \
- gnu/javax/crypto/key/srp6.lo gnu/javax/crypto/keyring.lo \
+ gnu/java/util/regex.lo gnu/javax/crypto.lo \
+ gnu/javax/crypto/assembly.lo gnu/javax/crypto/cipher.lo \
+ gnu/javax/crypto/jce.lo gnu/javax/crypto/jce/cipher.lo \
+ gnu/javax/crypto/jce/key.lo gnu/javax/crypto/jce/keyring.lo \
+ gnu/javax/crypto/jce/mac.lo gnu/javax/crypto/jce/params.lo \
+ gnu/javax/crypto/jce/prng.lo gnu/javax/crypto/jce/sig.lo \
+ gnu/javax/crypto/jce/spec.lo gnu/javax/crypto/key.lo \
+ gnu/javax/crypto/key/dh.lo gnu/javax/crypto/key/srp6.lo \
+ gnu/javax/crypto/keyring.lo gnu/javax/crypto/kwa.lo \
gnu/javax/crypto/mac.lo gnu/javax/crypto/mode.lo \
gnu/javax/crypto/pad.lo gnu/javax/crypto/prng.lo \
gnu/javax/crypto/sasl.lo gnu/javax/crypto/sasl/anonymous.lo \
gnu/javax/crypto/sasl/crammd5.lo \
gnu/javax/crypto/sasl/plain.lo gnu/javax/crypto/sasl/srp.lo \
- gnu/javax/imageio/bmp.lo gnu/javax/net/ssl.lo \
+ gnu/javax/imageio.lo gnu/javax/imageio/bmp.lo \
+ gnu/javax/imageio/gif.lo gnu/javax/imageio/jpeg.lo \
+ gnu/javax/imageio/png.lo gnu/javax/net/ssl.lo \
gnu/javax/net/ssl/provider.lo gnu/javax/print.lo \
gnu/javax/print/ipp.lo gnu/javax/print/ipp/attribute.lo \
gnu/javax/print/ipp/attribute/defaults.lo \
@@ -195,21 +200,22 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
gnu/javax/print/ipp/attribute/printer.lo \
gnu/javax/print/ipp/attribute/supported.lo \
gnu/javax/security/auth.lo gnu/javax/security/auth/callback.lo \
- gnu/javax/security/auth/login.lo gnu/javax/swing/plaf/gnu.lo \
+ gnu/javax/security/auth/login.lo gnu/javax/sound/sampled/AU.lo \
+ gnu/javax/sound/sampled/WAV.lo gnu/javax/swing/plaf/gnu.lo \
gnu/javax/swing/plaf/metal.lo gnu/javax/swing/text/html.lo \
gnu/javax/swing/text/html/parser.lo \
gnu/javax/swing/text/html/parser/models.lo \
gnu/javax/swing/text/html/parser/support.lo \
gnu/javax/swing/text/html/parser/support/low.lo \
- gnu/javax/swing/tree.lo gnu/regexp.lo java/applet.lo \
- java/awt.lo java/awt/color.lo java/awt/datatransfer.lo \
- java/awt/dnd.lo java/awt/dnd/peer.lo java/awt/event.lo \
- java/awt/font.lo java/awt/geom.lo java/awt/im.lo \
- java/awt/im/spi.lo java/awt/image.lo \
- java/awt/image/renderable.lo java/awt/peer.lo \
- java/awt/print.lo java/beans.lo java/beans/beancontext.lo \
- java/io.lo java/lang.lo java/lang/annotation.lo \
- java/lang/instrument.lo java/lang/ref.lo java/lang/reflect.lo \
+ gnu/javax/swing/tree.lo java/applet.lo java/awt.lo \
+ java/awt/color.lo java/awt/datatransfer.lo java/awt/dnd.lo \
+ java/awt/dnd/peer.lo java/awt/event.lo java/awt/font.lo \
+ java/awt/geom.lo java/awt/im.lo java/awt/im/spi.lo \
+ java/awt/image.lo java/awt/image/renderable.lo \
+ java/awt/peer.lo java/awt/print.lo java/beans.lo \
+ java/beans/beancontext.lo java/io.lo java/lang.lo \
+ java/lang/annotation.lo java/lang/instrument.lo \
+ java/lang/management.lo java/lang/ref.lo java/lang/reflect.lo \
java/math.lo java/net.lo java/nio.lo java/nio/channels.lo \
java/nio/channels/spi.lo java/nio/charset.lo \
java/nio/charset/spi.lo java/rmi.lo java/rmi/activation.lo \
@@ -220,7 +226,8 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
java/util/logging.lo java/util/prefs.lo java/util/regex.lo \
java/util/zip.lo javax/accessibility.lo javax/crypto.lo \
javax/crypto/interfaces.lo javax/crypto/spec.lo \
- javax/management.lo javax/naming.lo javax/naming/directory.lo \
+ javax/management.lo javax/management/openmbean.lo \
+ javax/naming.lo javax/naming/directory.lo \
javax/naming/event.lo javax/naming/ldap.lo javax/naming/spi.lo \
javax/net.lo javax/net/ssl.lo javax/print.lo \
javax/print/attribute.lo javax/print/attribute/standard.lo \
@@ -241,11 +248,13 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
javax/swing/text/rtf.lo javax/swing/tree.lo \
javax/swing/undo.lo javax/transaction.lo \
javax/transaction/xa.lo org/ietf/jgss.lo
-am__DEPENDENCIES_2 = gnu-CORBA.lo gnu-java-awt-peer-gtk.lo \
- gnu-java-awt-peer-qt.lo gnu-java-awt-peer-swing.lo \
- gnu-java-beans.lo gnu-javax-rmi.lo gnu-javax-sound-midi.lo \
- gnu-xml.lo javax-imageio.lo javax-rmi.lo javax-xml.lo \
- org-omg.lo org-relaxng.lo org-w3c.lo org-xml.lo
+am__DEPENDENCIES_2 = gnu-CORBA.lo gnu-java-awt-dnd-peer-gtk.lo \
+ gnu-java-awt-peer-gtk.lo gnu-java-awt-peer-qt.lo \
+ gnu-java-awt-peer-swing.lo gnu-java-beans.lo \
+ gnu-java-util-prefs-gconf.lo gnu-javax-rmi.lo \
+ gnu-javax-sound-midi.lo gnu-xml.lo javax-imageio.lo \
+ javax-rmi.lo javax-xml.lo org-omg.lo org-relaxng.lo org-w3c.lo \
+ org-xml.lo
am__DEPENDENCIES_3 = $(patsubst classpath/resource/%,%,$(addsuffix \
.lo,$(property_files)))
am__DEPENDENCIES_4 =
@@ -1019,7 +1028,6 @@ gnu/awt/xlib/XToolkit.java
gnu_awt_xlib_header_files = $(patsubst %.java,%.h,$(gnu_awt_xlib_source_files))
gnu_classpath_source_files = \
-classpath/gnu/classpath/ByteArray.java \
classpath/gnu/classpath/Configuration.java \
classpath/gnu/classpath/NotImplementedException.java \
classpath/gnu/classpath/Pointer.java \
@@ -1034,7 +1042,11 @@ gnu_classpath_debug_source_files = \
classpath/gnu/classpath/debug/Component.java \
classpath/gnu/classpath/debug/PreciseFilter.java \
classpath/gnu/classpath/debug/Simple1LineFormatter.java \
-classpath/gnu/classpath/debug/SystemLogger.java
+classpath/gnu/classpath/debug/SystemLogger.java \
+classpath/gnu/classpath/debug/TeeInputStream.java \
+classpath/gnu/classpath/debug/TeeOutputStream.java \
+classpath/gnu/classpath/debug/TeeReader.java \
+classpath/gnu/classpath/debug/TeeWriter.java
gnu_classpath_debug_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_classpath_debug_source_files)))
gnu_classpath_jdwp_source_files = \
@@ -1049,9 +1061,14 @@ gnu_classpath_jdwp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h
gnu_classpath_jdwp_event_source_files = \
classpath/gnu/classpath/jdwp/event/BreakpointEvent.java \
classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java \
+classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java \
classpath/gnu/classpath/jdwp/event/Event.java \
classpath/gnu/classpath/jdwp/event/EventManager.java \
classpath/gnu/classpath/jdwp/event/EventRequest.java \
+classpath/gnu/classpath/jdwp/event/ExceptionEvent.java \
+classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java \
+classpath/gnu/classpath/jdwp/event/MethodExitEvent.java \
+classpath/gnu/classpath/jdwp/event/SingleStepEvent.java \
classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java \
classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java \
classpath/gnu/classpath/jdwp/event/VmDeathEvent.java \
@@ -1260,6 +1277,15 @@ classpath/gnu/java/awt/color/TagEntry.java \
classpath/gnu/java/awt/color/ToneReproductionCurve.java
gnu_java_awt_color_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_color_source_files)))
+gnu_java_awt_dnd_source_files = \
+classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
+
+gnu_java_awt_dnd_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_dnd_source_files)))
+gnu_java_awt_dnd_peer_gtk_source_files = \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java
+
gnu_java_awt_font_source_files = \
classpath/gnu/java/awt/font/FontDelegate.java \
classpath/gnu/java/awt/font/FontFactory.java \
@@ -1308,7 +1334,6 @@ classpath/gnu/java/awt/java2d/TexturePaintContext.java
gnu_java_awt_java2d_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_java2d_source_files)))
gnu_java_awt_peer_source_files = \
classpath/gnu/java/awt/peer/ClasspathFontPeer.java \
-classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java \
classpath/gnu/java/awt/peer/EmbeddedWindowPeer.java \
classpath/gnu/java/awt/peer/GLightweightPeer.java
@@ -1330,10 +1355,8 @@ classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
classpath/gnu/java/awt/peer/gtk/GdkRobotPeer.java \
classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java \
-classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java \
classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java \
-classpath/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java \
@@ -1355,6 +1378,7 @@ classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuPeer.java \
+classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java \
@@ -1537,6 +1561,27 @@ gnu/java/lang/MainThread.java \
gnu/java/lang/VMInstrumentationImpl.java
gnu_java_lang_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_lang_source_files)))
+gnu_java_lang_management_source_files = \
+classpath/gnu/java/lang/management/BeanImpl.java \
+classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java \
+classpath/gnu/java/lang/management/CompilationMXBeanImpl.java \
+classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java \
+classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java \
+classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java \
+classpath/gnu/java/lang/management/ThreadMXBeanImpl.java \
+gnu/java/lang/management/VMClassLoadingMXBeanImpl.java \
+gnu/java/lang/management/VMCompilationMXBeanImpl.java \
+gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java \
+gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
+gnu/java/lang/management/VMThreadMXBeanImpl.java
+
+gnu_java_lang_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_lang_management_source_files)))
gnu_java_lang_reflect_source_files = \
classpath/gnu/java/lang/reflect/ClassSignatureParser.java \
classpath/gnu/java/lang/reflect/FieldSignatureParser.java \
@@ -1709,6 +1754,18 @@ gnu/java/net/PlainSocketImpl.java \
classpath/gnu/java/net/URLParseError.java
gnu_java_net_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_source_files)))
+gnu_java_net_loader_source_files = \
+classpath/gnu/java/net/loader/FileResource.java \
+classpath/gnu/java/net/loader/FileURLLoader.java \
+classpath/gnu/java/net/loader/JarURLLoader.java \
+classpath/gnu/java/net/loader/JarURLResource.java \
+classpath/gnu/java/net/loader/RemoteResource.java \
+classpath/gnu/java/net/loader/RemoteURLLoader.java \
+classpath/gnu/java/net/loader/Resource.java \
+classpath/gnu/java/net/loader/URLLoader.java \
+classpath/gnu/java/net/loader/URLStreamHandlerCache.java
+
+gnu_java_net_loader_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_loader_source_files)))
gnu_java_net_local_source_files = \
classpath/gnu/java/net/local/LocalServerSocket.java \
classpath/gnu/java/net/local/LocalSocket.java \
@@ -1802,6 +1859,8 @@ gnu/java/nio/ServerSocketChannelImpl.java \
gnu/java/nio/ServerSocketChannelSelectionKey.java \
gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/SocketChannelSelectionKey.java \
+classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java \
+gnu/java/nio/VMChannel.java \
gnu/java/nio/VMPipe.java \
gnu/java/nio/VMSelector.java
@@ -1933,6 +1992,7 @@ classpath/gnu/java/rmi/server/UnicastServerRef.java
gnu_java_rmi_server_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_rmi_server_source_files)))
gnu_java_security_source_files = \
+classpath/gnu/java/security/Configuration.java \
classpath/gnu/java/security/Engine.java \
classpath/gnu/java/security/OID.java \
classpath/gnu/java/security/PolicyFile.java \
@@ -2115,12 +2175,13 @@ classpath/gnu/java/security/sig/rsa/RSASignatureFactory.java
gnu_java_security_sig_rsa_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_security_sig_rsa_source_files)))
gnu_java_security_util_source_files = \
classpath/gnu/java/security/util/Base64.java \
+classpath/gnu/java/security/util/ByteArray.java \
classpath/gnu/java/security/util/DerUtil.java \
classpath/gnu/java/security/util/ExpirableObject.java \
classpath/gnu/java/security/util/FormatUtil.java \
+classpath/gnu/java/security/util/IntegerUtil.java \
classpath/gnu/java/security/util/PRNG.java \
classpath/gnu/java/security/util/Prime.java \
-classpath/gnu/java/security/util/Prime2.java \
classpath/gnu/java/security/util/Sequence.java \
classpath/gnu/java/security/util/SimpleList.java \
classpath/gnu/java/security/util/Util.java
@@ -2183,12 +2244,51 @@ gnu_java_util_prefs_source_files = \
classpath/gnu/java/util/prefs/EventDispatcher.java \
classpath/gnu/java/util/prefs/FileBasedFactory.java \
classpath/gnu/java/util/prefs/FileBasedPreferences.java \
+classpath/gnu/java/util/prefs/GConfBasedFactory.java \
+classpath/gnu/java/util/prefs/GConfBasedPreferences.java \
classpath/gnu/java/util/prefs/MemoryBasedFactory.java \
classpath/gnu/java/util/prefs/MemoryBasedPreferences.java \
classpath/gnu/java/util/prefs/NodeReader.java \
classpath/gnu/java/util/prefs/NodeWriter.java
gnu_java_util_prefs_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_util_prefs_source_files)))
+gnu_java_util_prefs_gconf_source_files = \
+classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
+
+gnu_java_util_regex_source_files = \
+classpath/gnu/java/util/regex/BacktrackStack.java \
+classpath/gnu/java/util/regex/CharIndexed.java \
+classpath/gnu/java/util/regex/CharIndexedCharArray.java \
+classpath/gnu/java/util/regex/CharIndexedCharSequence.java \
+classpath/gnu/java/util/regex/CharIndexedInputStream.java \
+classpath/gnu/java/util/regex/CharIndexedString.java \
+classpath/gnu/java/util/regex/CharIndexedStringBuffer.java \
+classpath/gnu/java/util/regex/RE.java \
+classpath/gnu/java/util/regex/REException.java \
+classpath/gnu/java/util/regex/REFilterInputStream.java \
+classpath/gnu/java/util/regex/REMatch.java \
+classpath/gnu/java/util/regex/REMatchEnumeration.java \
+classpath/gnu/java/util/regex/RESyntax.java \
+classpath/gnu/java/util/regex/REToken.java \
+classpath/gnu/java/util/regex/RETokenAny.java \
+classpath/gnu/java/util/regex/RETokenBackRef.java \
+classpath/gnu/java/util/regex/RETokenChar.java \
+classpath/gnu/java/util/regex/RETokenEnd.java \
+classpath/gnu/java/util/regex/RETokenEndOfPreviousMatch.java \
+classpath/gnu/java/util/regex/RETokenEndSub.java \
+classpath/gnu/java/util/regex/RETokenIndependent.java \
+classpath/gnu/java/util/regex/RETokenLookAhead.java \
+classpath/gnu/java/util/regex/RETokenLookBehind.java \
+classpath/gnu/java/util/regex/RETokenNamedProperty.java \
+classpath/gnu/java/util/regex/RETokenOneOf.java \
+classpath/gnu/java/util/regex/RETokenPOSIX.java \
+classpath/gnu/java/util/regex/RETokenRange.java \
+classpath/gnu/java/util/regex/RETokenRepeated.java \
+classpath/gnu/java/util/regex/RETokenStart.java \
+classpath/gnu/java/util/regex/RETokenWordBoundary.java \
+classpath/gnu/java/util/regex/UncheckedRE.java
+
+gnu_java_util_regex_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_util_regex_source_files)))
gnu_javax_crypto_source_files = \
classpath/gnu/javax/crypto/RSACipherImpl.java
@@ -2236,6 +2336,10 @@ classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java
gnu_javax_crypto_jce_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_crypto_jce_source_files)))
gnu_javax_crypto_jce_cipher_source_files = \
+classpath/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java \
classpath/gnu/javax/crypto/jce/cipher/AESSpi.java \
classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java \
classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java \
@@ -2243,12 +2347,14 @@ classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java \
classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java \
classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java \
classpath/gnu/javax/crypto/jce/cipher/DESSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java \
classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java \
classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java \
classpath/gnu/javax/crypto/jce/cipher/PBES2.java \
classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java \
classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java \
classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java \
classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java \
classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
@@ -2410,6 +2516,15 @@ classpath/gnu/javax/crypto/keyring/Properties.java \
classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java
gnu_javax_crypto_keyring_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_crypto_keyring_source_files)))
+gnu_javax_crypto_kwa_source_files = \
+classpath/gnu/javax/crypto/kwa/AESKeyWrap.java \
+classpath/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java \
+classpath/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java \
+classpath/gnu/javax/crypto/kwa/KeyUnwrappingException.java \
+classpath/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java \
+classpath/gnu/javax/crypto/kwa/TripleDESKeyWrap.java
+
+gnu_javax_crypto_kwa_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_crypto_kwa_source_files)))
gnu_javax_crypto_mac_source_files = \
classpath/gnu/javax/crypto/mac/BaseMac.java \
classpath/gnu/javax/crypto/mac/HMac.java \
@@ -2441,6 +2556,7 @@ gnu_javax_crypto_mode_header_files = $(patsubst classpath/%,%,$(patsubst %.java,
gnu_javax_crypto_pad_source_files = \
classpath/gnu/javax/crypto/pad/BasePad.java \
classpath/gnu/javax/crypto/pad/IPad.java \
+classpath/gnu/javax/crypto/pad/ISO10126.java \
classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java \
classpath/gnu/javax/crypto/pad/PKCS7.java \
classpath/gnu/javax/crypto/pad/PadFactory.java \
@@ -2523,6 +2639,10 @@ classpath/gnu/javax/crypto/sasl/srp/ServerStore.java \
classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java
gnu_javax_crypto_sasl_srp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_crypto_sasl_srp_source_files)))
+gnu_javax_imageio_source_files = \
+classpath/gnu/javax/imageio/IIOInputStream.java
+
+gnu_javax_imageio_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_source_files)))
gnu_javax_imageio_bmp_source_files = \
classpath/gnu/javax/imageio/bmp/BMPDecoder.java \
classpath/gnu/javax/imageio/bmp/BMPEncoder.java \
@@ -2551,6 +2671,47 @@ classpath/gnu/javax/imageio/bmp/EncodeRLE4.java \
classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
gnu_javax_imageio_bmp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_bmp_source_files)))
+gnu_javax_imageio_gif_source_files = \
+classpath/gnu/javax/imageio/gif/GIFFile.java \
+classpath/gnu/javax/imageio/gif/GIFImageReader.java \
+classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java
+
+gnu_javax_imageio_gif_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_gif_source_files)))
+gnu_javax_imageio_jpeg_source_files = \
+classpath/gnu/javax/imageio/jpeg/DCT.java \
+classpath/gnu/javax/imageio/jpeg/HuffmanTable.java \
+classpath/gnu/javax/imageio/jpeg/JPEGComponent.java \
+classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java \
+classpath/gnu/javax/imageio/jpeg/JPEGException.java \
+classpath/gnu/javax/imageio/jpeg/JPEGFrame.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java \
+classpath/gnu/javax/imageio/jpeg/JPEGMarker.java \
+classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java \
+classpath/gnu/javax/imageio/jpeg/JPEGScan.java \
+classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java \
+classpath/gnu/javax/imageio/jpeg/ZigZag.java
+
+gnu_javax_imageio_jpeg_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_jpeg_source_files)))
+gnu_javax_imageio_png_source_files = \
+classpath/gnu/javax/imageio/png/PNGChunk.java \
+classpath/gnu/javax/imageio/png/PNGData.java \
+classpath/gnu/javax/imageio/png/PNGDecoder.java \
+classpath/gnu/javax/imageio/png/PNGEncoder.java \
+classpath/gnu/javax/imageio/png/PNGException.java \
+classpath/gnu/javax/imageio/png/PNGFile.java \
+classpath/gnu/javax/imageio/png/PNGFilter.java \
+classpath/gnu/javax/imageio/png/PNGGamma.java \
+classpath/gnu/javax/imageio/png/PNGHeader.java \
+classpath/gnu/javax/imageio/png/PNGICCProfile.java \
+classpath/gnu/javax/imageio/png/PNGImageReader.java \
+classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java \
+classpath/gnu/javax/imageio/png/PNGPalette.java \
+classpath/gnu/javax/imageio/png/PNGPhys.java \
+classpath/gnu/javax/imageio/png/PNGTime.java
+
+gnu_javax_imageio_png_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_png_source_files)))
gnu_javax_net_ssl_source_files = \
classpath/gnu/javax/net/ssl/Base64.java \
classpath/gnu/javax/net/ssl/EntropySource.java \
@@ -2763,8 +2924,21 @@ classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java \
classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java \
classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java \
classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java \
-classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java
+classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java \
+classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java \
+classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java \
+classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java \
+classpath/gnu/javax/sound/midi/file/MidiFileReader.java \
+classpath/gnu/javax/sound/midi/file/MidiFileWriter.java
+gnu_javax_sound_sampled_AU_source_files = \
+classpath/gnu/javax/sound/sampled/AU/AUReader.java
+
+gnu_javax_sound_sampled_AU_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_sound_sampled_AU_source_files)))
+gnu_javax_sound_sampled_WAV_source_files = \
+classpath/gnu/javax/sound/sampled/WAV/WAVReader.java
+
+gnu_javax_sound_sampled_WAV_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_sound_sampled_WAV_source_files)))
gnu_javax_swing_plaf_gnu_source_files = \
classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
@@ -2780,7 +2954,9 @@ classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
gnu_javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_swing_text_html_source_files)))
gnu_javax_swing_text_html_parser_source_files = \
+classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java \
classpath/gnu/javax/swing/text/html/parser/HTML_401F.java \
+classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java \
classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java \
classpath/gnu/javax/swing/text/html/parser/gnuDTD.java \
classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java \
@@ -2819,40 +2995,6 @@ gnu_javax_swing_tree_source_files = \
classpath/gnu/javax/swing/tree/GnuPath.java
gnu_javax_swing_tree_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_swing_tree_source_files)))
-gnu_regexp_source_files = \
-classpath/gnu/regexp/BacktrackStack.java \
-classpath/gnu/regexp/CharIndexed.java \
-classpath/gnu/regexp/CharIndexedCharArray.java \
-classpath/gnu/regexp/CharIndexedCharSequence.java \
-classpath/gnu/regexp/CharIndexedInputStream.java \
-classpath/gnu/regexp/CharIndexedString.java \
-classpath/gnu/regexp/CharIndexedStringBuffer.java \
-classpath/gnu/regexp/RE.java \
-classpath/gnu/regexp/REException.java \
-classpath/gnu/regexp/REFilterInputStream.java \
-classpath/gnu/regexp/REMatch.java \
-classpath/gnu/regexp/REMatchEnumeration.java \
-classpath/gnu/regexp/RESyntax.java \
-classpath/gnu/regexp/REToken.java \
-classpath/gnu/regexp/RETokenAny.java \
-classpath/gnu/regexp/RETokenBackRef.java \
-classpath/gnu/regexp/RETokenChar.java \
-classpath/gnu/regexp/RETokenEnd.java \
-classpath/gnu/regexp/RETokenEndOfPreviousMatch.java \
-classpath/gnu/regexp/RETokenEndSub.java \
-classpath/gnu/regexp/RETokenIndependent.java \
-classpath/gnu/regexp/RETokenLookAhead.java \
-classpath/gnu/regexp/RETokenLookBehind.java \
-classpath/gnu/regexp/RETokenNamedProperty.java \
-classpath/gnu/regexp/RETokenOneOf.java \
-classpath/gnu/regexp/RETokenPOSIX.java \
-classpath/gnu/regexp/RETokenRange.java \
-classpath/gnu/regexp/RETokenRepeated.java \
-classpath/gnu/regexp/RETokenStart.java \
-classpath/gnu/regexp/RETokenWordBoundary.java \
-classpath/gnu/regexp/UncheckedRE.java
-
-gnu_regexp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_regexp_source_files)))
gnu_xml_source_files = \
classpath/gnu/xml/aelfred2/JAXPFactory.java \
classpath/gnu/xml/aelfred2/SAXDriver.java \
@@ -3354,11 +3496,13 @@ classpath/java/awt/MenuComponent.java \
classpath/java/awt/MenuContainer.java \
classpath/java/awt/MenuItem.java \
classpath/java/awt/MenuShortcut.java \
+classpath/java/awt/MouseInfo.java \
classpath/java/awt/PageAttributes.java \
classpath/java/awt/Paint.java \
classpath/java/awt/PaintContext.java \
classpath/java/awt/Panel.java \
classpath/java/awt/Point.java \
+classpath/java/awt/PointerInfo.java \
classpath/java/awt/Polygon.java \
classpath/java/awt/PopupMenu.java \
classpath/java/awt/PrintGraphics.java \
@@ -3621,6 +3765,7 @@ classpath/java/awt/peer/MenuBarPeer.java \
classpath/java/awt/peer/MenuComponentPeer.java \
classpath/java/awt/peer/MenuItemPeer.java \
classpath/java/awt/peer/MenuPeer.java \
+classpath/java/awt/peer/MouseInfoPeer.java \
classpath/java/awt/peer/PanelPeer.java \
classpath/java/awt/peer/PopupMenuPeer.java \
classpath/java/awt/peer/RobotPeer.java \
@@ -3886,7 +4031,8 @@ java_lang_header_files = $(filter-out java/lang/Object.h java/lang/Class.h,$(pat
java_lang_annotation_source_files = \
classpath/java/lang/annotation/Annotation.java \
classpath/java/lang/annotation/AnnotationFormatError.java \
-classpath/java/lang/annotation/AnnotationTypeMismatchException.java
+classpath/java/lang/annotation/AnnotationTypeMismatchException.java \
+classpath/java/lang/annotation/IncompleteAnnotationException.java
java_lang_annotation_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_annotation_source_files)))
java_lang_instrument_source_files = \
@@ -3897,6 +4043,24 @@ classpath/java/lang/instrument/Instrumentation.java \
classpath/java/lang/instrument/UnmodifiableClassException.java
java_lang_instrument_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_instrument_source_files)))
+java_lang_management_source_files = \
+classpath/java/lang/management/ClassLoadingMXBean.java \
+classpath/java/lang/management/CompilationMXBean.java \
+classpath/java/lang/management/GarbageCollectorMXBean.java \
+classpath/java/lang/management/ManagementFactory.java \
+classpath/java/lang/management/ManagementPermission.java \
+classpath/java/lang/management/MemoryMXBean.java \
+classpath/java/lang/management/MemoryManagerMXBean.java \
+classpath/java/lang/management/MemoryNotificationInfo.java \
+classpath/java/lang/management/MemoryPoolMXBean.java \
+classpath/java/lang/management/MemoryUsage.java \
+classpath/java/lang/management/OperatingSystemMXBean.java \
+classpath/java/lang/management/RuntimeMXBean.java \
+classpath/java/lang/management/ThreadInfo.java \
+classpath/java/lang/management/ThreadMXBean.java \
+java/lang/management/VMManagementFactory.java
+
+java_lang_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_management_source_files)))
java_lang_ref_source_files = \
classpath/java/lang/ref/PhantomReference.java \
java/lang/ref/Reference.java \
@@ -3932,7 +4096,8 @@ classpath/java/lang/reflect/WildcardType.java
java_lang_reflect_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_reflect_source_files)))
java_math_source_files = \
classpath/java/math/BigDecimal.java \
-classpath/java/math/BigInteger.java
+classpath/java/math/BigInteger.java \
+classpath/java/math/MathContext.java
java_math_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_math_source_files)))
java_net_source_files = \
@@ -3981,7 +4146,8 @@ classpath/java/net/URLStreamHandler.java \
classpath/java/net/URLStreamHandlerFactory.java \
classpath/java/net/UnknownHostException.java \
classpath/java/net/UnknownServiceException.java \
-java/net/VMNetworkInterface.java
+java/net/VMNetworkInterface.java \
+java/net/VMURLConnection.java
java_net_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_net_source_files)))
java_nio_source_files = \
@@ -4404,16 +4570,29 @@ classpath/java/util/ConcurrentModificationException.java \
java/util/Currency.java \
classpath/java/util/Date.java \
classpath/java/util/Dictionary.java \
+classpath/java/util/DuplicateFormatFlagsException.java \
classpath/java/util/EmptyStackException.java \
classpath/java/util/Enumeration.java \
classpath/java/util/EventListener.java \
classpath/java/util/EventListenerProxy.java \
classpath/java/util/EventObject.java \
+classpath/java/util/FormatFlagsConversionMismatchException.java \
+classpath/java/util/Formattable.java \
+classpath/java/util/FormattableFlags.java \
+classpath/java/util/Formatter.java \
+classpath/java/util/FormatterClosedException.java \
java/util/GregorianCalendar.java \
classpath/java/util/HashMap.java \
classpath/java/util/HashSet.java \
classpath/java/util/Hashtable.java \
classpath/java/util/IdentityHashMap.java \
+classpath/java/util/IllegalFormatCodePointException.java \
+classpath/java/util/IllegalFormatConversionException.java \
+classpath/java/util/IllegalFormatException.java \
+classpath/java/util/IllegalFormatFlagsException.java \
+classpath/java/util/IllegalFormatPrecisionException.java \
+classpath/java/util/IllegalFormatWidthException.java \
+classpath/java/util/InputMismatchException.java \
classpath/java/util/InvalidPropertiesFormatException.java \
classpath/java/util/Iterator.java \
classpath/java/util/LinkedHashMap.java \
@@ -4424,6 +4603,8 @@ classpath/java/util/ListIterator.java \
classpath/java/util/ListResourceBundle.java \
java/util/Locale.java \
classpath/java/util/Map.java \
+classpath/java/util/MissingFormatArgumentException.java \
+classpath/java/util/MissingFormatWidthException.java \
classpath/java/util/MissingResourceException.java \
classpath/java/util/NoSuchElementException.java \
classpath/java/util/Observable.java \
@@ -4447,6 +4628,9 @@ classpath/java/util/TimerTask.java \
classpath/java/util/TooManyListenersException.java \
classpath/java/util/TreeMap.java \
classpath/java/util/TreeSet.java \
+classpath/java/util/UUID.java \
+classpath/java/util/UnknownFormatConversionException.java \
+classpath/java/util/UnknownFormatFlagsException.java \
java/util/VMTimeZone.java \
classpath/java/util/Vector.java \
classpath/java/util/WeakHashMap.java
@@ -4473,6 +4657,7 @@ classpath/java/util/logging/Level.java \
java/util/logging/LogManager.java \
classpath/java/util/logging/LogRecord.java \
java/util/logging/Logger.java \
+classpath/java/util/logging/LoggingMXBean.java \
classpath/java/util/logging/LoggingPermission.java \
classpath/java/util/logging/MemoryHandler.java \
classpath/java/util/logging/SimpleFormatter.java \
@@ -4651,9 +4836,48 @@ classpath/javax/imageio/stream/MemoryCacheImageInputStream.java \
classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java
javax_management_source_files = \
-classpath/javax/management/Attribute.java
+classpath/javax/management/Attribute.java \
+classpath/javax/management/AttributeList.java \
+classpath/javax/management/AttributeNotFoundException.java \
+classpath/javax/management/DynamicMBean.java \
+classpath/javax/management/IntrospectionException.java \
+classpath/javax/management/InvalidAttributeValueException.java \
+classpath/javax/management/JMException.java \
+classpath/javax/management/JMRuntimeException.java \
+classpath/javax/management/ListenerNotFoundException.java \
+classpath/javax/management/MBeanAttributeInfo.java \
+classpath/javax/management/MBeanConstructorInfo.java \
+classpath/javax/management/MBeanException.java \
+classpath/javax/management/MBeanFeatureInfo.java \
+classpath/javax/management/MBeanInfo.java \
+classpath/javax/management/MBeanNotificationInfo.java \
+classpath/javax/management/MBeanOperationInfo.java \
+classpath/javax/management/MBeanParameterInfo.java \
+classpath/javax/management/NotCompliantMBeanException.java \
+classpath/javax/management/Notification.java \
+classpath/javax/management/NotificationBroadcaster.java \
+classpath/javax/management/NotificationEmitter.java \
+classpath/javax/management/NotificationFilter.java \
+classpath/javax/management/NotificationListener.java \
+classpath/javax/management/OperationsException.java \
+classpath/javax/management/ReflectionException.java \
+classpath/javax/management/RuntimeOperationsException.java \
+classpath/javax/management/StandardMBean.java
javax_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_management_source_files)))
+javax_management_openmbean_source_files = \
+classpath/javax/management/openmbean/ArrayType.java \
+classpath/javax/management/openmbean/CompositeData.java \
+classpath/javax/management/openmbean/CompositeDataSupport.java \
+classpath/javax/management/openmbean/CompositeType.java \
+classpath/javax/management/openmbean/InvalidKeyException.java \
+classpath/javax/management/openmbean/OpenDataException.java \
+classpath/javax/management/openmbean/OpenType.java \
+classpath/javax/management/openmbean/SimpleType.java \
+classpath/javax/management/openmbean/TabularData.java \
+classpath/javax/management/openmbean/TabularType.java
+
+javax_management_openmbean_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_management_openmbean_source_files)))
javax_naming_source_files = \
classpath/javax/naming/AuthenticationException.java \
classpath/javax/naming/AuthenticationNotSupportedException.java \
@@ -4751,7 +4975,7 @@ classpath/javax/naming/spi/DirStateFactory.java \
classpath/javax/naming/spi/DirectoryManager.java \
classpath/javax/naming/spi/InitialContextFactory.java \
classpath/javax/naming/spi/InitialContextFactoryBuilder.java \
-classpath/javax/naming/spi/NamingManager.java \
+javax/naming/spi/NamingManager.java \
classpath/javax/naming/spi/ObjectFactory.java \
classpath/javax/naming/spi/ObjectFactoryBuilder.java \
classpath/javax/naming/spi/ResolveResult.java \
@@ -4942,7 +5166,9 @@ classpath/javax/rmi/CORBA/Util.java \
classpath/javax/rmi/CORBA/UtilDelegate.java \
classpath/javax/rmi/CORBA/ValueHandler.java \
classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java \
-classpath/javax/rmi/PortableRemoteObject.java
+classpath/javax/rmi/PortableRemoteObject.java \
+classpath/javax/rmi/ssl/SslRMIClientSocketFactory.java \
+classpath/javax/rmi/ssl/SslRMIServerSocketFactory.java
javax_security_auth_source_files = \
classpath/javax/security/auth/AuthPermission.java \
@@ -5545,6 +5771,7 @@ classpath/javax/swing/text/DocumentFilter.java \
classpath/javax/swing/text/EditorKit.java \
classpath/javax/swing/text/Element.java \
classpath/javax/swing/text/ElementIterator.java \
+classpath/javax/swing/text/EmptyAttributeSet.java \
classpath/javax/swing/text/FieldView.java \
classpath/javax/swing/text/FlowView.java \
classpath/javax/swing/text/GapContent.java \
@@ -5587,15 +5814,16 @@ classpath/javax/swing/text/WrappedPlainView.java
javax_swing_text_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_text_source_files)))
javax_swing_text_html_source_files = \
+classpath/javax/swing/text/html/BRView.java \
classpath/javax/swing/text/html/BlockView.java \
classpath/javax/swing/text/html/CSS.java \
classpath/javax/swing/text/html/CSSParser.java \
classpath/javax/swing/text/html/FormView.java \
+classpath/javax/swing/text/html/HRuleView.java \
classpath/javax/swing/text/html/HTML.java \
classpath/javax/swing/text/html/HTMLDocument.java \
classpath/javax/swing/text/html/HTMLEditorKit.java \
classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java \
-classpath/javax/swing/text/html/HTMLTableView.java \
classpath/javax/swing/text/html/ImageView.java \
classpath/javax/swing/text/html/InlineView.java \
classpath/javax/swing/text/html/ListView.java \
@@ -5604,7 +5832,8 @@ classpath/javax/swing/text/html/NullView.java \
classpath/javax/swing/text/html/ObjectView.java \
classpath/javax/swing/text/html/Option.java \
classpath/javax/swing/text/html/ParagraphView.java \
-classpath/javax/swing/text/html/StyleSheet.java
+classpath/javax/swing/text/html/StyleSheet.java \
+classpath/javax/swing/text/html/TableView.java
javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_text_html_source_files)))
javax_swing_text_html_parser_source_files = \
@@ -6537,6 +6766,7 @@ all_packages_source_files = \
gnu/gcj/util.list \
gnu/java/awt.list \
gnu/java/awt/color.list \
+ gnu/java/awt/dnd.list \
gnu/java/awt/font.list \
gnu/java/awt/font/opentype.list \
gnu/java/awt/font/opentype/truetype.list \
@@ -6546,10 +6776,12 @@ all_packages_source_files = \
gnu/java/awt/print.list \
gnu/java/io.list \
gnu/java/lang.list \
+ gnu/java/lang/management.list \
gnu/java/lang/reflect.list \
gnu/java/locale.list \
gnu/java/math.list \
gnu/java/net.list \
+ gnu/java/net/loader.list \
gnu/java/net/local.list \
gnu/java/net/protocol/core.list \
gnu/java/net/protocol/file.list \
@@ -6591,6 +6823,7 @@ all_packages_source_files = \
gnu/java/util.list \
gnu/java/util/jar.list \
gnu/java/util/prefs.list \
+ gnu/java/util/regex.list \
gnu/javax/crypto.list \
gnu/javax/crypto/assembly.list \
gnu/javax/crypto/cipher.list \
@@ -6607,6 +6840,7 @@ all_packages_source_files = \
gnu/javax/crypto/key/dh.list \
gnu/javax/crypto/key/srp6.list \
gnu/javax/crypto/keyring.list \
+ gnu/javax/crypto/kwa.list \
gnu/javax/crypto/mac.list \
gnu/javax/crypto/mode.list \
gnu/javax/crypto/pad.list \
@@ -6616,7 +6850,11 @@ all_packages_source_files = \
gnu/javax/crypto/sasl/crammd5.list \
gnu/javax/crypto/sasl/plain.list \
gnu/javax/crypto/sasl/srp.list \
+ gnu/javax/imageio.list \
gnu/javax/imageio/bmp.list \
+ gnu/javax/imageio/gif.list \
+ gnu/javax/imageio/jpeg.list \
+ gnu/javax/imageio/png.list \
gnu/javax/net/ssl.list \
gnu/javax/net/ssl/provider.list \
gnu/javax/print.list \
@@ -6629,6 +6867,8 @@ all_packages_source_files = \
gnu/javax/security/auth.list \
gnu/javax/security/auth/callback.list \
gnu/javax/security/auth/login.list \
+ gnu/javax/sound/sampled/AU.list \
+ gnu/javax/sound/sampled/WAV.list \
gnu/javax/swing/plaf/gnu.list \
gnu/javax/swing/plaf/metal.list \
gnu/javax/swing/text/html.list \
@@ -6637,7 +6877,6 @@ all_packages_source_files = \
gnu/javax/swing/text/html/parser/support.list \
gnu/javax/swing/text/html/parser/support/low.list \
gnu/javax/swing/tree.list \
- gnu/regexp.list \
java/applet.list \
java/awt.list \
java/awt/color.list \
@@ -6659,6 +6898,7 @@ all_packages_source_files = \
java/lang.list \
java/lang/annotation.list \
java/lang/instrument.list \
+ java/lang/management.list \
java/lang/ref.list \
java/lang/reflect.list \
java/math.list \
@@ -6691,6 +6931,7 @@ all_packages_source_files = \
javax/crypto/interfaces.list \
javax/crypto/spec.list \
javax/management.list \
+ javax/management/openmbean.list \
javax/naming.list \
javax/naming/directory.list \
javax/naming/event.list \
@@ -6756,6 +6997,7 @@ ordinary_header_files = \
$(gnu_gcj_util_header_files) \
$(gnu_java_awt_header_files) \
$(gnu_java_awt_color_header_files) \
+ $(gnu_java_awt_dnd_header_files) \
$(gnu_java_awt_font_header_files) \
$(gnu_java_awt_font_opentype_header_files) \
$(gnu_java_awt_font_opentype_truetype_header_files) \
@@ -6765,10 +7007,12 @@ ordinary_header_files = \
$(gnu_java_awt_print_header_files) \
$(gnu_java_io_header_files) \
$(gnu_java_lang_header_files) \
+ $(gnu_java_lang_management_header_files) \
$(gnu_java_lang_reflect_header_files) \
$(gnu_java_locale_header_files) \
$(gnu_java_math_header_files) \
$(gnu_java_net_header_files) \
+ $(gnu_java_net_loader_header_files) \
$(gnu_java_net_local_header_files) \
$(gnu_java_net_protocol_core_header_files) \
$(gnu_java_net_protocol_file_header_files) \
@@ -6810,6 +7054,7 @@ ordinary_header_files = \
$(gnu_java_util_header_files) \
$(gnu_java_util_jar_header_files) \
$(gnu_java_util_prefs_header_files) \
+ $(gnu_java_util_regex_header_files) \
$(gnu_javax_crypto_header_files) \
$(gnu_javax_crypto_assembly_header_files) \
$(gnu_javax_crypto_cipher_header_files) \
@@ -6826,6 +7071,7 @@ ordinary_header_files = \
$(gnu_javax_crypto_key_dh_header_files) \
$(gnu_javax_crypto_key_srp6_header_files) \
$(gnu_javax_crypto_keyring_header_files) \
+ $(gnu_javax_crypto_kwa_header_files) \
$(gnu_javax_crypto_mac_header_files) \
$(gnu_javax_crypto_mode_header_files) \
$(gnu_javax_crypto_pad_header_files) \
@@ -6835,7 +7081,11 @@ ordinary_header_files = \
$(gnu_javax_crypto_sasl_crammd5_header_files) \
$(gnu_javax_crypto_sasl_plain_header_files) \
$(gnu_javax_crypto_sasl_srp_header_files) \
+ $(gnu_javax_imageio_header_files) \
$(gnu_javax_imageio_bmp_header_files) \
+ $(gnu_javax_imageio_gif_header_files) \
+ $(gnu_javax_imageio_jpeg_header_files) \
+ $(gnu_javax_imageio_png_header_files) \
$(gnu_javax_net_ssl_header_files) \
$(gnu_javax_net_ssl_provider_header_files) \
$(gnu_javax_print_header_files) \
@@ -6848,6 +7098,8 @@ ordinary_header_files = \
$(gnu_javax_security_auth_header_files) \
$(gnu_javax_security_auth_callback_header_files) \
$(gnu_javax_security_auth_login_header_files) \
+ $(gnu_javax_sound_sampled_AU_header_files) \
+ $(gnu_javax_sound_sampled_WAV_header_files) \
$(gnu_javax_swing_plaf_gnu_header_files) \
$(gnu_javax_swing_plaf_metal_header_files) \
$(gnu_javax_swing_text_html_header_files) \
@@ -6856,7 +7108,6 @@ ordinary_header_files = \
$(gnu_javax_swing_text_html_parser_support_header_files) \
$(gnu_javax_swing_text_html_parser_support_low_header_files) \
$(gnu_javax_swing_tree_header_files) \
- $(gnu_regexp_header_files) \
$(java_applet_header_files) \
$(java_awt_header_files) \
$(java_awt_color_header_files) \
@@ -6878,6 +7129,7 @@ ordinary_header_files = \
$(java_lang_header_files) \
$(java_lang_annotation_header_files) \
$(java_lang_instrument_header_files) \
+ $(java_lang_management_header_files) \
$(java_lang_ref_header_files) \
$(java_lang_reflect_header_files) \
$(java_math_header_files) \
@@ -6910,6 +7162,7 @@ ordinary_header_files = \
$(javax_crypto_interfaces_header_files) \
$(javax_crypto_spec_header_files) \
$(javax_management_header_files) \
+ $(javax_management_openmbean_header_files) \
$(javax_naming_header_files) \
$(javax_naming_directory_header_files) \
$(javax_naming_event_header_files) \
@@ -6957,10 +7210,12 @@ ordinary_header_files = \
bc_objects = \
gnu-CORBA.lo \
+ gnu-java-awt-dnd-peer-gtk.lo \
gnu-java-awt-peer-gtk.lo \
gnu-java-awt-peer-qt.lo \
gnu-java-awt-peer-swing.lo \
gnu-java-beans.lo \
+ gnu-java-util-prefs-gconf.lo \
gnu-javax-rmi.lo \
gnu-javax-sound-midi.lo \
gnu-xml.lo \
@@ -6982,16 +7237,22 @@ property_files = \
classpath/resource/gnu/classpath/tools/native2ascii/messages.properties \
classpath/resource/gnu/classpath/tools/serialver/messages.properties \
classpath/resource/gnu/java/awt/peer/gtk/font.properties \
+ classpath/resource/gnu/java/awt/peer/x/fonts.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties \
classpath/resource/gnu/javax/print/PrinterDialog.properties \
classpath/resource/gnu/javax/print/PrinterDialog_de.properties \
classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties \
- classpath/resource/gnu/regexp/MessagesBundle.properties \
- classpath/resource/gnu/regexp/MessagesBundle_fr.properties \
- classpath/resource/gnu/regexp/MessagesBundle_it.properties \
classpath/resource/java/util/iso4217.properties \
classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties \
classpath/resource/org/ietf/jgss/MessagesBundle.properties \
+ classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory \
+ classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in \
classpath/resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider \
+ classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader \
+ classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter \
+ classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader \
classpath/resource/META-INF/services/javax.xml.parsers.DocumentBuilderFactory \
classpath/resource/META-INF/services/javax.xml.parsers.SAXParserFactory \
classpath/resource/META-INF/services/javax.xml.parsers.TransformerFactory \
@@ -9160,6 +9421,21 @@ gnu/java/awt/color.list: $(gnu_java_awt_color_source_files)
-include gnu/java/awt/color.deps
+gnu/java/awt/dnd.list: $(gnu_java_awt_dnd_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_awt_dnd_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/awt/dnd.list
+
+-include gnu/java/awt/dnd.deps
+
+gnu-java-awt-dnd-peer-gtk.lo: $(gnu_java_awt_dnd_peer_gtk_source_files)
+ @find classpath/lib/gnu/java/awt/dnd/peer/gtk -name '*.class' > gnu-java-awt-dnd-peer-gtk.list
+ $(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-awt-dnd-peer-gtk.lo @gnu-java-awt-dnd-peer-gtk.list
+ @rm -f gnu-java-awt-dnd-peer-gtk.list
+
gnu/java/awt/font.list: $(gnu_java_awt_font_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_java_awt_font_source_files); do \
@@ -9270,6 +9546,16 @@ gnu/java/lang.list: $(gnu_java_lang_source_files)
-include gnu/java/lang.deps
+gnu/java/lang/management.list: $(gnu_java_lang_management_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_lang_management_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/lang/management.list
+
+-include gnu/java/lang/management.deps
+
gnu/java/lang/reflect.list: $(gnu_java_lang_reflect_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_java_lang_reflect_source_files); do \
@@ -9310,6 +9596,16 @@ gnu/java/net.list: $(gnu_java_net_source_files)
-include gnu/java/net.deps
+gnu/java/net/loader.list: $(gnu_java_net_loader_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_net_loader_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/net/loader.list
+
+-include gnu/java/net/loader.deps
+
gnu/java/net/local.list: $(gnu_java_net_local_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_java_net_local_source_files); do \
@@ -9720,6 +10016,21 @@ gnu/java/util/prefs.list: $(gnu_java_util_prefs_source_files)
-include gnu/java/util/prefs.deps
+gnu-java-util-prefs-gconf.lo: $(gnu_java_util_prefs_gconf_source_files)
+ @find classpath/lib/gnu/java/util/prefs/gconf -name '*.class' > gnu-java-util-prefs-gconf.list
+ $(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-util-prefs-gconf.lo @gnu-java-util-prefs-gconf.list
+ @rm -f gnu-java-util-prefs-gconf.list
+
+gnu/java/util/regex.list: $(gnu_java_util_regex_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_util_regex_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/util/regex.list
+
+-include gnu/java/util/regex.deps
+
gnu/javax/crypto.list: $(gnu_javax_crypto_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_javax_crypto_source_files); do \
@@ -9880,6 +10191,16 @@ gnu/javax/crypto/keyring.list: $(gnu_javax_crypto_keyring_source_files)
-include gnu/javax/crypto/keyring.deps
+gnu/javax/crypto/kwa.list: $(gnu_javax_crypto_kwa_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_crypto_kwa_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/crypto/kwa.list
+
+-include gnu/javax/crypto/kwa.deps
+
gnu/javax/crypto/mac.list: $(gnu_javax_crypto_mac_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_javax_crypto_mac_source_files); do \
@@ -9970,6 +10291,16 @@ gnu/javax/crypto/sasl/srp.list: $(gnu_javax_crypto_sasl_srp_source_files)
-include gnu/javax/crypto/sasl/srp.deps
+gnu/javax/imageio.list: $(gnu_javax_imageio_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio.list
+
+-include gnu/javax/imageio.deps
+
gnu/javax/imageio/bmp.list: $(gnu_javax_imageio_bmp_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_javax_imageio_bmp_source_files); do \
@@ -9980,6 +10311,36 @@ gnu/javax/imageio/bmp.list: $(gnu_javax_imageio_bmp_source_files)
-include gnu/javax/imageio/bmp.deps
+gnu/javax/imageio/gif.list: $(gnu_javax_imageio_gif_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_gif_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/gif.list
+
+-include gnu/javax/imageio/gif.deps
+
+gnu/javax/imageio/jpeg.list: $(gnu_javax_imageio_jpeg_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_jpeg_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/jpeg.list
+
+-include gnu/javax/imageio/jpeg.deps
+
+gnu/javax/imageio/png.list: $(gnu_javax_imageio_png_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_png_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/png.list
+
+-include gnu/javax/imageio/png.deps
+
gnu/javax/net/ssl.list: $(gnu_javax_net_ssl_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_javax_net_ssl_source_files); do \
@@ -10110,6 +10471,26 @@ gnu-javax-sound-midi.lo: $(gnu_javax_sound_midi_source_files)
$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-javax-sound-midi.lo @gnu-javax-sound-midi.list
@rm -f gnu-javax-sound-midi.list
+gnu/javax/sound/sampled/AU.list: $(gnu_javax_sound_sampled_AU_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_sound_sampled_AU_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/sound/sampled/AU.list
+
+-include gnu/javax/sound/sampled/AU.deps
+
+gnu/javax/sound/sampled/WAV.list: $(gnu_javax_sound_sampled_WAV_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_sound_sampled_WAV_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/sound/sampled/WAV.list
+
+-include gnu/javax/sound/sampled/WAV.deps
+
gnu/javax/swing/plaf/gnu.list: $(gnu_javax_swing_plaf_gnu_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(gnu_javax_swing_plaf_gnu_source_files); do \
@@ -10190,16 +10571,6 @@ gnu/javax/swing/tree.list: $(gnu_javax_swing_tree_source_files)
-include gnu/javax/swing/tree.deps
-gnu/regexp.list: $(gnu_regexp_source_files)
- @$(mkinstalldirs) $(dir $@)
- @for file in $(gnu_regexp_source_files); do \
- if test -f $(srcdir)/$$file; then \
- echo $(srcdir)/$$file; \
- else echo $$file; fi; \
- done > gnu/regexp.list
-
--include gnu/regexp.deps
-
gnu-xml.lo: $(gnu_xml_source_files)
@find classpath/lib/gnu/xml -name '*.class' > gnu-xml.list
$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-xml.lo @gnu-xml.list
@@ -10415,6 +10786,16 @@ java/lang/instrument.list: $(java_lang_instrument_source_files)
-include java/lang/instrument.deps
+java/lang/management.list: $(java_lang_management_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(java_lang_management_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > java/lang/management.list
+
+-include java/lang/management.deps
+
java/lang/ref.list: $(java_lang_ref_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(java_lang_ref_source_files); do \
@@ -10740,6 +11121,16 @@ javax/management.list: $(javax_management_source_files)
-include javax/management.deps
+javax/management/openmbean.list: $(javax_management_openmbean_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(javax_management_openmbean_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > javax/management/openmbean.list
+
+-include javax/management/openmbean.deps
+
javax/naming.list: $(javax_naming_source_files)
@$(mkinstalldirs) $(dir $@)
@for file in $(javax_naming_source_files); do \
diff --git a/libjava/classpath/ChangeLog b/libjava/classpath/ChangeLog
index 4e401a4a3cc..8aca3f97844 100644
--- a/libjava/classpath/ChangeLog
+++ b/libjava/classpath/ChangeLog
@@ -14,58 +14,9879 @@
* ltconfig: chmod 644 before ranlib during install.
+2006-08-09 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac (VERSION): Set to 0.92.
+ * NEWS: Add updates for 0.92 release.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ PR 28650
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ (getActionMap): Store ActionMap in MenuBar.actionMap, rather
+ than Tree.actionMap.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (action): Removed obsolete field.
+ (uninstallKeyboardActions): Removed action field handling.
+ (installKeyboardActions): Removed action field handling.
+ (createDefaultActions): Don't install removed TreeAction.
+ (TreeAction): Removed obsolete inner class.
+ (ActionListenerProxy): Removed obsolete inner class.
+ (MouseHandler.mousePressed): Request focus on JTree component
+ on mouse press.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicListUI.java
+ (MouseInputHandler.mousePressed): Request focus on list
+ component.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (MouseInputHandler.mousePressed): Request focus on list
+ component.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (damageRange(JTextComponent,int,int)): Call damageRange() with
+ correct biases, rather than null.
+ (damageRange(JTextComponent,int,int,Bias,Bias)): Rewritten
+ to use simpler modelToView() approach without much special
+ casing. This seems not worth the effort and actually
+ caused problems. Added locking of the document.
+ * javax/swing/text/BoxView.java
+ (requirementsValid): New field.
+ (calculateMajorAxisRequirements): Rewritten without using
+ SizeRequirements. The SizeRequirements algorithms are slightly
+ different and too inefficient.
+ (calculateMinorAxisRequirements): Rewritten without using
+ SizeRequirements. The SizeRequirements algorithms are slightly
+ different and too inefficient.
+ (getAlignment): Simply return the alignment of the cached
+ requirements.
+ (getMaximumSpan): Add insets.
+ (getMinimumSpan): Add insets.
+ (getPreferredSpan): Add insets.
+ (layoutMajorAxis): Rewritten without using
+ SizeRequirements. The SizeRequirements algorithms are slightly
+ different and too inefficient.
+ (layoutMinorAxis): Rewritten without using
+ SizeRequirements. The SizeRequirements algorithms are slightly
+ different and too inefficient.
+ (modelToView): Call setSize() rather than layout().
+ (paint): Check clip for more efficient painting.
+ (preferenceChanged): Invalidate requirements here.
+ (replace): Invalidate requirements here.
+ (updateRequirements): Update requirements only when requirements
+ are marked invalid.
+ * javax/swing/text/CompositeView.java
+ (modelToView): Added some more checks and handling of corner cases.
+ * javax/swing/text/FlowView.java
+ (calculateMinorAxisRequirements): Set aligment to 0.5 and maximum
+ span to Integer.MAX_VALUE. Limit preferredSize to minimumSize.
+ * javax/swing/text/IconView.java
+ (getAlignment): Implemented to return 1.0 for vertical alignment.
+ * javax/swing/text/ParagraphView.java
+ (Row.getMaximumSpan): Implemented to let Rows span the whole
+ ParagraphView.
+ (getAlignment): Fixed horizontal alignment and vertical alignment
+ for empty paragraphs to be 0.5.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/View.java
+ (modelToView): Added special handling for corner case at the end
+ of the view and for multiline views.
+
+2006-08-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (modelToView): Read-lock the document. Set size of the
+ root view before fetching the model-to-view mapping.
+ (getViewIndex): Check of the position is inside the range and
+ return -1 if this is not the case.
+ (getViewAtPosition(int,Rectangle): Update child allocation for valid
+ view index.
+ (getViewIndexAtPosition(int)): Delegate the index search to
+ the element since we have a 1:1 mapping between elements and
+ views here.
+ * javax/swing/text/DefaultCaret.java
+ (appear): Ignore BadLocationException.
+ (paint): Ignore BadLocationException.
+ * javax/swing/text/FlowView.java
+ (changedUpdate): Also notify the layoutPool view.
+ (removeUpdate): Also notify the layoutPool view.
+ * javax/swing/text/ParagraphView.java
+ (Row.getViewIndexAtPosition): Overridden to search linearily
+ through the view instead of relying on a 1:1 model to view
+ mapping.
+ * javax/swing/text/View.java
+ (removeUpdate): Clear ElementChange object if updateChildren
+ returns false.
+ (forwardUpdate): Special handle some boundary cases.
+
+2006-08-07 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/key/dss/DSSKey.java: Updated documentation.
+ (hasInheritedParameters): New method.
+ (equals): Updated documentation.
+ Take into consideration the outcome of hasInheritedParameters invocation.
+ (toString): Call hasInheritedParameters and adjust the result accordingly.
+ * gnu/java/security/key/dss/DSSKeyPairX509Codec.java (encodePublicKey):
+ Updated documentation.
+ Handle case of public keys with null p, q, and g MPIs.
+ (decodePublicKey): Handle case of absent or NULL p, q and g MPIs.
+
+2006-08-07 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/23682:
+ * java/nio/channels/SelectionKey.java (attach): Now synchronized.
+ (attachment): Likewise.
+ * java/nio/channels/spi/AbstractSelectionKey.java (cancel): Now
+ synchronized.
+ (isValid): Likewise.
+ * gnu/java/nio/SelectionKeyImpl.java (impl): Now final
+ (ch): Likewise.
+ (interestOps): Synchronize.
+ (readyOps): Likewise.
+ * gnu/java/nio/SelectorImpl.java (register): Synchronize around
+ interestOps call.
+
+2006-08-07 C. Scott Marshall <csm@gnu.org>
+
+ Fixes PR 28608.
+ * java/nio/DirectByteBufferImpl.java (duplicate): only reset if
+ the mark has been set.
+ * native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+ (Java_java_nio_VMDirectByteBuffer_allocate): zero out the
+ allocated data.
+
+2006-08-07 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawGlyphVector): Synchronize against font object when drawing.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (nativeDrawGlyphVector): Use pango locking when drawing.
+ (install_font_peer): Use pango locking when creating the cairo face.
+
+2006-08-06 Roman Kennke <kennke@aicas.com>
+
+ PR 28571
+ * gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+ (getPreferredSize): Renamed method to preferredSize(). That's
+ the one that gets called from java.awt.*.
+ * java/awt/peer/ComponentPeer.java
+ (getPreferredSize): Added specnote about this method never
+ beeing called in the RI.
+ (getMinimumSize): Added specnote about this method never
+ beeing called in the RI.
+
+2006-08-06 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (grab, nativeGrab): New methods.
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (nativeGrab): New method.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (print): Implement.
+ * java/awt/Component.java
+ (printAll): Should call peer print method.
+
+2006-08-06 Thomas Minor <1nocentrabidlamb@sexMagnet.com>
+
+ * java/net/URL.java (getContent(Class[])): Implement.
+
+2006-08-06 Mark Wielaard <mark@klomp.org>
+
+ PR 28555
+ Suggested by Matthew Burgess <matthew@linuxfromscratch.org>
+ * gnu/xml/transform/ApplyTemplatesNode.java (clone): Check whether
+ withParams is null.
+ * gnu/xml/transform/ForEachNode.java (clone): Check whether
+ sortKeys is null.
+
+2006-08-06 Roman Kennke <kennke@aicas.com>
+
+ * NEWS: Added note about the X peers.
+ * INSTALL: Added install notes about the X peers.
+
+2006-08-06 Raif S. Naffah <raif@swiftdsl.com.au>
+ Paul Jenner <psj@harker.dyndns.org>
+
+ * README: Update bug, patches and cvs instructions plus new URLs of
+ various external projects.
+
+2006-08-06 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac (MOZILLA_FOUND): Fall back to
+ mozilla-firefox-plugin.
+
+2006-08-06 Mario Torre <neugens@limasoftware.net>
+
+ Reported by Raif S. Naffah <raif@swiftdsl.com.au>
+ * native/jni/gconf-peer/GConfNativePeer.c (init_gconf_client):
+ g_type_init earlier in function to correctly initialize the
+ type system used by the backend.
+
+2006-08-05 Robert Schuster <robertschuster@fsfe.org>
+
+ Reported by Henrik Gulbrandsen <henrik@gulbra.net>
+ Fixes PR27864.
+ * gnu/xml/dom/DomIterator.java:
+ (successor): Added if-statement.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 27606
+ * javax/swing/plaf/basic/BasicListUI.java
+ (paintCell): Pass row index to cell renderer.
+ * javax/swing/plaf/basic/MetalFileChooserUI.java
+ (DirectoryComboBoxRenderer.indentIcon): New field.
+ (DirectoryComboBoxRenderer.DirectoryComboBoxRenderer):
+ Initialize indentIcon.
+ (DirectoryComboBoxRenderer.getListCellRendererComponent):
+ Fall back to super and removed standard functionality.
+ Handle indentation.
+ (IndentIcon): New class. Wraps and indents another icon.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 27605
+ * javax/swing/JComboBox.java
+ (setSelectedItem): Fire ActionEvent here.
+ * javax/swing/plaf/basic/BasicDirectoryModel.java
+ (directories): Changed to type Vector.
+ (files): New field.
+ (loadThread): New field.
+ (DirectoryLoadThread): New inner class. This loads the contents
+ of directories asynchronously.
+ (getDirectories): Return cached Vector.
+ (getFiles): Return cached Vector.
+ (getSize): Return plain size of contents Vector.
+ (propertyChange): Reread directory also for DIRECTORY_CHANGED,
+ FILE_FILTER_CHANGED, FILE_HIDING_CHANGED and FILE_VIEW_CHANGED.
+ (sort): Don't store sorted list in contents. This must be done
+ asynchronously from the EventThread.
+ (validateFileCache): Rewritten for asynchronous reading
+ of directory contents.
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ (installListeners): Install model as PropertyChangeListener.
+ (uninstallListeners): Uninstall model as PropertyChangeListener.
+ (createPropertyChangeListener): Return null just like the
+ RI.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 27604
+ * javax/swing/plaf/basic/BasicChooserUI.java
+ (BasicFileView.getName): Fetch the real name from the
+ file chooser's FileSystemView.
+ * javax/swing/plaf/metal/MetalChooserUI.java
+ (DirectoryComboBoxRenderer.getListCellRendererComponent):
+ Set the text fetched from the JFileChooser.getName().
+ * javax/swing/FileSystemView.java
+ (createFileObject): When file is a filesystem root,
+ create a filesystem root object first.
+ (getSystemDisplayName): Return the filename. Added specnote
+ about ShellFolder class that is mentioned in the spec.
+ * javax/swing/UnixFileSystemView.java
+ (getSystemDisplayName): Implemented to return the real name
+ of a file, special handling files like '.' or '..'.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 28562
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (PropertyChangeHandler.propertyChange): Cleanly reinstall
+ components when visual property chanegs.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 28562
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (PropertyChangeHandler.propertyChange): Uninstall and reinstall
+ component when visual properties change.
+
+2006-08-03 Roman Kennke <kennke@aicas.com>
+
+ PR 28534
+ * javax/swing/JTree.java
+ (JTree(TreeModel)): Set cell renderer to null.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (setCellRenderer): Finish editing before setting the
+ cell renderer. Refresh the layout. Don't set the
+ currentCellRenderer field here (that's done in updateRenderer).
+ (updateRenderer): Handle createdRenderer field here too.
+ Set renderer to a default handler when the current renderer
+ in the JTree is null.
+
+2006-08-03 Mark Wielaard <mark@klomp.org>
+
+ * scripts/Makefile.am (EXTRA_DIST): Add import-cacerts.sh.
+
+2006-08-03 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * scripts/import-cacerts.sh: Batch CA certificates import script.
+
+2006-08-03 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/28556
+ * gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
+ (encodePrivateKey): Updated documentation to clarify that RFC-2459
+ states that the parameters field of the AlgorithmIdentifier element
+ MUST be NULL if present. Amended the code to reflect the specs.
+ (decodePrivateKey): Handle case of NULL AlgorithmIdentifier.parameters.
+
+2006-08-03 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/23899
+ * java/security/SecureRandom.java (next): Call nextBytes as per specs.
+
+2006-08-03 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jawt/Makefile.am (libjawt_la_LDFLAGS): Add
+ -avoid-version.
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_LDFLAGS):
+ Likewise.
+ * native/jni/midi-alsa/Makefile.am (libgjsmalsa_la_LDFLAGS):
+ Likewise.
+ * native/jni/midi-dssi/Makefile.am (libgjsmdssi_la_LDFLAGS):
+ Likewise.
+
+2006-08-03 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/qt-peer/Makefile.am (libqtpeer_la_LDFLAGS): Add
+ -avoid-version.
+
+2006-08-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * examples/gnu/classpath/examples/management/TestBeans.java:
+ New file.
+ * javax/management/MBeanAttributeInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanConstructorInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanFeatureInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanNotificationInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanOperationInfo.java:
+ (toString()): Implemented.
+ * javax/management/MBeanParameterInfo.java:
+ (toString()): Implemented.
+ * javax/management/StandardMBean.java:
+ (getMBeanInfo()): Fix attribute naming.
+
+2006-08-02 Mark Wielaard <mark@klomp.org>
+
+ PR 28535
+ * configure.ac (gconf-peer): Check for gdk-2.0.
+ * native/jni/gconf-peer/Makefile.am
+ (AM_LDFLAGS): Use GDK_LIBS.
+ (AM_CFLAGS): Use GDK_CFLAGS.
+
+2006-07-31 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/security/Provider.java: Updated copyright year.
+ Updated documentation.
+ Formatting.
+ (put): Updated documentation.
+ Added security manager check.
+ Canonicalize the key before adding its mapping.
+ (get): Override superclass implementation to use canonicalized keys.
+ (remove): Updated documentation.
+ Added security manager check.
+ Canonicalize the key before removing its mapping.
+ (clear): Updated documentation.
+ Added security manager check.
+ (toCanonicalKey): New method.
+
+2006-07-30 Matt Wringe <mwringe@redhat.com>
+
+ * gnu/java/security/Engine.java
+ (getInstance): Ignore self referencing aliases.
+
+2006-07-30 Mark Wielaard <mark@klomp.org>
+
+ * resource/java/security/classpath.security: Add /dev/urandom as
+ default securerandom.source.
+
+2006-07-30 Mark Wielaard <mark@klomp.org>
+
+ * java/util/GregorianCalendar.java (maximums): Months can have up to
+ 6 weeks.
+ (nonLeniencyCheck): weeks is either 5 or 6.
+
+2006-07-29 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/JComponent.java (paintingDoubleBuffered): Renamed
+ static field isPaintingDoubleBuffered to not have the same name
+ as a method.
+
+2006-07-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/BeanImpl.java:
+ Extended javax.management.StandardMBean.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java,
+ * gnu/java/lang/management/CompilationMXBeanImpl.java,
+ * gnu/java/lang/management/GarbageCollectorMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryManagerMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryPoolMXBeanImpl.java,
+ * gnu/java/lang/management/OperatingSystemMXBeanImpl.java,
+ * gnu/java/lang/management/RuntimeMXBeanImpl.java,
+ * gnu/java/lang/management/ThreadMXBeanImpl.java:
+ Call the superclass with the appropriate class.
+ * java/lang/management/ManagementFactory.java:
+ (getOperatingSystemMXBean()): Catch exception from
+ StandardMBean.
+ (getRuntimeMXBean()): Likewise.
+ (getClassLoadingMXBean()): Likewise.
+ (getThreadMXBean()): Likewise.
+ (getMemoryMXBean()): Likewise.
+ (getCompilationMXBean()): Likewise.
+ (getMemoryPoolMXBeans()): Likewise.
+ (getMemoryManagerMXBeans()): Likewise.
+ (getGarbageCollectorMXBeans()): Likewise.
+ * javax/management/MBeanFeatureInfo.java:
+ (hashCode()): Fixed to check for null values.
+
+2006-07-29 Matt Wringe <mwringe@redhat.com>
+
+ * gnu/java/security/Engine.java
+ (getInstance): Add case insentivity to algorithm names
+ * java/security/Provider.java
+ (put): Stop using canonical key naming
+ (remove): Likewise
+ (toCanonicalKey): Method removed
+ (get): Method removed, no longer needs to overwrite
+ parent implementation
+
+2006-07-29 Sven de Marothy <sven@physto.se>
+
+ * java/math/BigDecimal.java
+ Adjust copyright date.
+ (divide(BigDecimal): Implement.
+ (precision): Reimplement.
+ (numDigitsInBigInteger, numDigitsInLong): Removed.
+ (toString): Get exponent from string length,
+ fix negative values with exponential form.
+ (toEngineeringString): Same as for toString.
+ (setScale): Throw ArithmeticException if scale < 0.
+
+2006-07-27 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/java2d/CubicSegment.java: Added import.
+ (cp1): Renamed from first().
+ (c2): Renamed from last().
+ (first): Renamed to cp1().
+ (getDisplacedSegments): Implemented.
+ (last): Renamed to cp2().
+ * gnu/java/awt/java2d/LineSegment.java
+ (cp1): Renamed from first().
+ (c2): Renamed from last().
+ (first): Renamed to cp1().
+ (last): Renamed to cp2().
+ * gnu/java/awt/java2d/QuadSegment.java
+ (cp1): Renamed from first().
+ (c2): Renamed from last().
+ (first): Renamed to cp1().
+ (last): Renamed to cp2().
+ * gnu/java/awt/java2d/Segment.java: Added comments.
+ (first): New field.
+ (Segment): Keep track of first element in list.
+ (add): Update first & last element variables.
+ (cp1): Renamed from first().
+ (c2): Renamed from last().
+ (first()): Renamed to cp1() to reduce ambiguity.
+ (last()): Renamed to cp2() to reduce ambiguity.
+ (reverseAll): Update first element variable..
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (draw): Remove flattening path iterator.
+ * java/awt/BasicStroke.java: Clarified comments.
+ (addSegments): Refactored some code into joinSegments and
+ joinInnerSegments.
+ (capEnd): Rename of Segment.first() and Segment.end().
+ (joinInnerSegments): New method.
+ (joinOuterSegments): New method.
+ (joinSegments): Refactored some code into joinOuterSegments.
+ (solidStroke): Connect segments together properly.
+
+2006-07-27 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/28486:
+ * java/net/URLStreamHandler.java (equals): Properly handle default
+ port. Rewrote javadoc. Don't compare 'authority' parts of URLs.
+
+2006-07-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/AbstractDocument.java
+ (documentCV): Made field private.
+ (bypass): Made field private.
+ (bidiRoot): New field.
+ (AbstractDocument): Initialize bidiRoot.
+ (getBidiRootElement): Return bidiRoot.
+ (getRootElements): Adjusted to also return the bidiRoot element.
+ (BranchElement.startOffset): Removed unneeded field.
+ (BranchElement.endOffset): Removed unneeded field.
+ (BranchElement.BranchElement): Removed unneeded fields.
+ (BranchElement.getEndOffset): Don't explicitly throw NPE here. This is
+ done automatically when there's no element left in the array.
+ (BranchElement.getStartOffset): Likewise.
+ (BranchElement.replace): Reordered calculations to avoid double
+ calculations.
+ (removeImpl): Silently ignore requests with length <= 0.
+ * javax/swing/text/GapContent.java
+ (createPosition): Removed explicit check for correct offset.
+ This class can deal with offsets outside the document.
+ (shiftEnd): Update all positions, even those outside the
+ document.
+ (adjustPositionsInRange): Fixed to also adjust positions outside
+ the document boundary.
+
+2006-07-18 Kyle Galloway <kgallowa@redhat.com>
+
+ * gnu/classpath/jdwp/event/ExceptionEvent.java: Added _klass field to hold
+ defining class.
+ (getParameter): Returns _klass field instead of determining
+ class from _instance.
+ (setCatchLoc): New method.
+ (writeData): Now assumes Location deals with empty locations instead of
+ using null.
+ * gnu/classpath/jdwp/util/Location.java (write): Check for empty
+ locations and write out accordingly.
+ (getEmptyLocation): New method.
+
+2006-07-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/SimpleAttributeSet.java
+ (EMPTY): Use EmptyAttributeSet for this field rather than
+ SimpleAttributeSet.
+ * javax/swing/text/EmptyAttributeSet.java: New class. Implements
+ an empty and immutable AttributeSet.
+
+2006-07-27 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (reshape): Invalidate the component itself only when the
+ size has changed. Invalidate the parent always. Fixed
+ repainting. Pulled out the notification into
+ notifyReshape().
+ (notifyReshape): New helper method. Notify interested listeners
+ about a reshape.
+ (update): Simply call paint() without clearing the background.
+ This is done in Container.update() if appropriate.
+ (repaint): Delagate the repaint to the nearest heavyweight
+ parent (for lightweights) and send an UPDATE event, rather than
+ calling ComponentPeer.repaint().
+ * java/awt/Container.java
+ (backCleared): Removed field.
+ (paint): Removed handling of backCleared flag.
+ (update): Only paint if the container is actually
+ showing. Removed handling of backCleared flag.
+
+2006-07-27 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java: Fixed copyright and
+ authorship.
+ (NavigateAction): New inner class.
+ (NavigatePageDownAction): New inner class.
+ (NavigatePageUpAction): New inner class.
+ (RequestFocusAction): New inner class.
+ (RequestFocusForVisibleComponentAction): New inner class.
+ (FocusHandler.focusGained): Implemented.
+ (FocusHandler.focusLost): Implemented.
+ (MouseHandler.mouseReleased): Implemented.
+ (MouseHandler.mousePressed): Rewritten.
+ (PropertyChangeHandler.propertyChange): Reset currentScrollOffset and
+ currentScrollLocation to 0.
+ (TabbedPaneLayout.calculateSize): Stored tab count in local variable,
+ removed local variables, fixed indentation to stay under 80 column
+ limit.
+ (TabbedPaneLayout.calculateTabRects): Decrease tab area position by
+ one, set selectedIndex to 0 if its negative, corrected start values
+ for normalization, suppressed padding when only one tab run,
+ (TabbedPaneLayout.minimumLayoutSize): Toggled argument value.
+ (TabbedPaneLayout.normalizeTabRuns): Fixed indentation to stay under
+ 80 column limit, corrected the starting value for the bounds fixing
+ phase.
+ (TabbedPaneLayout.preferredTabAreaWidth): Fixed indentation.
+ (TabbedPaneLayout.rotateTabInRuns): Corrected comparison value for
+ selectedRun, set start index for loop to 0.
+ (TabbedPaneScrollLayout.preferredLayoutSize): Toggled argument value.
+ (TabbedPaneScrollLayout.calculateTabRects): Rewritten.
+ (TabbedPaneScrollLayout.layoutContainer): Added scrolling button
+ alignment and visibility handling.
+ (TabSelectionHandler.stateChanged): Do revalidation only in wrap tab
+ layout mode.
+ (ScrollingPanel.ScrollingPanelUI.paint): Rewritten.
+ (currentScrollOffset): New field.
+ (tabRuns): Rewritten documentation.
+ (selectedColor): New field.
+ (tempTextRect): New field.
+ (tempIconRect): New field.
+ (scrollTab): New method.
+ (updateButtons): New method.
+ (updateViewPosition): New method.
+ (createLayoutManager): Reordered method calls, predefine new fields,
+ register proper listeners.
+ (uninstallComponents): Implemented.
+ (installDefaults): Corrected property names, fixed indentation,.
+ (uninstallDefaults): Set new fields to null.
+ (uninstallListeners): Remove listeners from components neccessary for
+ scrolling tab layout.
+ (installKeyboardActions): Implemented.
+ (uninstallKeyboardActions): Implemented.
+ (paint): Paint tab area background.
+ (paintTabArea): Fixed indentation, removed usage of local Rectangle
+ objects.
+ (getTabLabelShiftX): Rewritten.
+ (getTabLabelShiftY): Rewritten.
+ (paintFocusIndicator): Reindented.
+ (paintTabBorder): Rewritten.
+ (paintTabBackground): Corrected color usage, rewritten background
+ rectangle painting.
+ (paintContentBorderTopEdge): Rewritten.
+ (paintContentBorderBottomEdge): Rewritten.
+ (paintContentBorderLeftEdge): Rewritten.
+ (paintContentBorderRightEdge): Rewritten.
+ (tabForCoordinate): Return selected index when no tab could be
+ found, removed FIXME note.
+ (getRunForTab): Changed return value for first if-statement.
+ (navigateSelectedTab): Fixed last argument for both
+ getTabRunOffset() calls.
+ (selectedNextTabInRun): Added scrolling code.
+ (selectedPreviousTabInRun): Added scrolling code.
+ (selectedNextTab): Added scrolling code.
+ (selectedPreviousTab): Added scrolling code.
+ (selectAdjacentRunTab): Added scrolling code.
+ (getTextViewForTab): Added FIXME note.
+ (calculateTabHeight): Changed FIXME note.
+ (getTabRunOffset): Fixed indentation.
+ (getNextTabIndexInRun): Corrected return value.
+ (rotateInsets): Make TOP case the default in switch-statement.
+ (getActionMap): New method.
+ (createActionMap): New method.
+ * javax/swing/plaf/metal/MetalTabbedPaneUI.java:
+ (createLayoutManager): Rewritten.
+ (paintLeftTabBorder): Do not paint left line when previous tab
+ is selected but current tab is the first in its run, do not paint
+ left line when current tab is selected and is first in its run.
+ (paintRightTabBorder): Added missing setColor() call, fixed color
+ usage, do not paint right line if previous tab is selected but
+ current tab is the first in its run.
+ (paintBottomTabBorder): Do not paint left line if tab is selected
+ and is the first tab in the last run.
+ (paintFocusIndicator): New method.
+ (getLabelShiftX): New method.
+ (getLabelShiftY): New method.
+
+2006-07-27 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix): Remove
+ g_assert from unused obj.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector): Mark
+ obj as unused and remove g_assert on it.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/RepaintManager.java
+ (markCompletelyDirty): Add dirty region with Integer.MAX_VALUE
+ for the component.
+ (isCompletelyDirty): Consider a component completely dirty
+ when it has a dirty region with Integer.MAX_VALUE.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/KeyboardFocusManager.java
+ (getGlobalFocusOwner): Explicitly check for thread security.
+ (getGlobalPermanentFocusOwner): Explicitly check for thread security.
+ (getGlobalFocusedWindow): Explicitly check for thread security.
+ (getGlobalActiveWindow): Explicitly check for thread security.
+ (getGlobalCurrentFocusCycleRoot): Explicitly check for thread security.
+ (getGlobalObject): Added new argument for specifying if
+ a security check should be performed or not.
+ (setGlobalObject): Don't check for thread security when
+ calling getGlobalObject.
+
+2006-07-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/MBeanConstructorInfo.java:
+ Documentation fix.
+ * javax/management/MBeanInfo.java:
+ (MBeanInfo(String,String,MBeanAttributeInfo[],
+ MBeanConstructorInfo[], MBeanOperationInfo[],
+ MBeanNotificationInfo[])): Implemented.
+ (equals(Object)): Likewise.
+ (getAttributes()): Likewise.
+ (getConstructors()): Likewise.
+ (getOperations()): Likewise.
+ (hashCode()): Likewise.
+ * javax/management/MBeanOperationInfo.java,
+ * javax/management/NotCompliantMBeanException.java,
+ * javax/management/StandardMBean.java:
+ New files.
+
+2006-07-26 Sven de Marothy <sven@physto.se>
+
+ * java/awt/geom/GeneralPath.java: Fix severe typo.
+
+2006-07-26 Sven de Marothy <sven@physto.se>
+
+ * include/java_lang_VMSystem.h
+ * vm/reference/java/lang/VMSystem.java
+ * native/jni/java-lang/java_lang_VMSystem.c
+ (nanoTime, currentTimeMillis): Switch the former to native code and
+ the latter to java.
+
+2006-07-26 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/qt/QtCheckboxPeer.java: Removed unneeded imports.
+ * gnu/java/awt/peer/qt/QtComponentGraphics.java: Likewise.
+ * gnu/java/awt/peer/qt/QtComponentPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtContainerPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtDialogPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtFontMetrics.java: Likewise.
+ * gnu/java/awt/peer/qt/QtFontPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
+ * gnu/java/awt/peer/qt/QtGraphicsEnvironment.java: Likewise.
+ * gnu/java/awt/peer/qt/QtImage.java: Likewise.
+ * gnu/java/awt/peer/qt/QtImageConsumer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtImageDirectGraphics.java: Likewise.
+ * gnu/java/awt/peer/qt/QtImageGraphics.java: Likewise.
+ * gnu/java/awt/peer/qt/QtMenuBarPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtMenuItemPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtPopupMenuPeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java: Likewise.
+ * gnu/java/awt/peer/qt/QtScrollPanePeer.java: Likewise.
+ * gnu/java/awt/peer/qt/QtToolkit.java: Likewise.
+ * gnu/java/awt/peer/qt/QtVolatileImage.java: Likewise.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/KeyboardFocusManager.java
+ (getFocusOwner): Don't check permanent owner.
+ (getGlobalFocusOwner): Don't check permanent owner.
+
+2006-07-26 Carsten Neumann <cn-develop@gmx.net>
+
+ * StrictMath.java (cosh): New method.
+ (expm1): New method.
+ (EXPM1_Q1): New field.
+ (EXPM1_Q2): Likewise.
+ (EXPM1_Q3): Likewise.
+ (EXPM1_Q4): Likewise.
+ (EXPM1_Q6): Likewise.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonListener.java
+ (mousePressed): Request focus if appropriate.
+ * javax/swing/text/DefaultCaret.java
+ (mousePressed): Also handle the focus of the text component
+ as specified. Don't consume events.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (focusRequest): Removed field.
+ (postFocusEvent(int,boolean,Component)): Removed.
+ (postFocusEvent(int,boolean)): Reverted to post event using
+ the heavyweight component.
+ (requestFocus): Post focus event using the heavyweight
+ component.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (requestFocus): Post focus event using the heavyweight
+ component.
+ * java/awt/AWTEvent.java
+ (isFocusManagerEvent): New field, indicating if this is
+ an event that is redispatched by the KeyboardFocusManager.
+ * java/awt/Component.java
+ (requestFocusImpl): Register component for
+ heavyweight->lightweight mapping.
+ (dispatchEventImpl): Retarget focus events before dispatching
+ to the KeyboardFocusManager. Use new AWTEvent flag instead
+ of locking hack. Dispatch all events through the
+ KeyboardFocusManager. Don't request focus on lightweight
+ components.
+ * java/awt/DefaultKeyboardFocusManager.java
+ (dispatchEvent): Pulled out handling of FOCUS_GAINED and
+ FOCUS_LOST.
+ (handleFocusGained): Fixed handling of temporary vs permanent
+ focus changes. Added some checks.
+ (handleFocusLost): Fixed handling of temporary vs permanent
+ focus changes. Added some checks.
+ * java/awt/EventDispatchThread.java
+ (run): Don't dispatch to KeyboardFocusManager here. This
+ is done in Component.dispatchEventImpl().
+ * java/awt/KeyboardFocusManager.java
+ (redispatchEvent): Use new AWTEvent flag instead of locking hack.
+ (focusRequests): New field.
+ (retargetFocusEvent): New method. Retargets focus events
+ that come from heavyweights to the correct lightweight component.
+ (addLightweightFocusRequest): New method. Stores a mapping
+ for later retargetting of heavyweight focus events.
+ * java/awt/Window.java
+ (addFocusListener): Removed bogus method. If at all, this
+ should be performed in the KeyboardFocusManager.
+ (Window): Don't install a focus listener on the Window.
+
+2006-07-26 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java:
+ (drawLine): Apply shift to line coordinates.
+
+2006-07-26 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/image/ColorConvertOp.java: Fixed copyright header.
+ (copyimage): Do not call setRenderingHints() when the respective map
+ does not exist.
+ (filter): Removed code to clone the ColorModel instance.
+ * java/awt/image/ColorModel.java:
+ (cloneColorModel): Removed.
+
+2006-07-26 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/JTabbedPane.java:
+ (setSelectedIndex): Removed updating of component visibility status,
+ added note.
+ (remove(Component)): Use indexOfComponent() to find whether we have
+ to use super.remove(int) or removeTabAt().
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JOptionPane.java
+ (createDialog): Add property change handler for closing
+ the dialog when the value property changes.
+ (ValuePropertyHandler): New inner helper class.
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (OptionPaneCloseAction): New class.
+ (messageForeground): Removed field.
+ (messageBorder): Removed field.
+ (buttonBorder): Removed field.
+ (addIcon): Configure the new label.
+ (addMessageComponents): Configure newly created labels.
+ (burstStringInto): Likewise.
+ (createButtonArea): Install border here.
+ (createMessageArea): Install border and foreground here.
+ (createSeparator): Added comment and removed
+ NotImplementedException.
+ (installComponents): Don't install the UI defaults for the
+ message and button area here. This is moved to the
+ corresponding create* methods. Adjusted comment about
+ separator.
+ (installDefaults): Removed initialization of removed fields.
+ (installKeyboardActions): Implemented.
+ (getActionMap): New helper method.
+ (createDefaultActions): New helper method.
+ (uninstallDefaults): Removed de-initialization of removed fields.
+ (uninstallKeyboardActions): Implemented.
+ (configureLabel): New helper method.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (getActionMap): Fixed the UI property names.
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (getActionMap): Fixed the UI property names.
+
+2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java
+ (getDataElements): Check for negative x or y,
+ (getPixels): Likewise,
+ (getSamples): Likewise,
+ (setSamples): Likewise.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (ToolBarAction): New inner class for handling keyboard
+ actions.
+ (installKeyboardActions): Implemented.
+ (getActionMap): New helper method.
+ (createDefaultActions): New helper method.
+ (installListeners): Install focus listener on toolbar's
+ children, rather than the toolbar itself.
+ (navigateFocusedComp): Implemented.
+ (uninstallKeyboardActions): Implemented.
+ (uninstallListeners): Uninstall focus listener from
+ toolbar's children, rather than the toolbar itself.
+ (ToolBarContListener.componentAdded): Install focus
+ listener on added child.
+ (ToolBarContListener.componentRemoved): Uninstall focus
+ listener from removed child.
+ (ToolBarFocusListener.ToolBarFocusListener): Nothing to do here.
+ (ToolBarFocusListener.focusGained): Implemented.
+ (ToolBarFocusListener.focusLost): Implemented.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/DefaultKeyboardFocusManager.java
+ (dispatchEvent): Notify old focus owner when it has lost
+ focus.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (FocusHandler.focusGained): Implemented to refresh the
+ lead cell.
+ (FocusHandler.focusLost): Implemented to refresh the
+ lead cell.
+ (FocusHandler.repaintLeadCell): New helper method.
+ (MouseInputHandler.mouseEntered): Do nothing here.
+ (MouseInputHandler.mouseExited): Do nothing here.
+ (MouseInputHandler.mouseMoved): Do nothing here.
+ (installKeyboardActions): Rewritten to use a shared InputMap
+ and ActionMap and correctly install the maps via SwingUtilities
+ methods.
+ (getActionMap): New helper method.
+ (createDefaultActions): New helper method.
+ (ActionListenerProxy): Removed unneeded class.
+ (TableAction): Made class static.
+ (TableAction.actionPerformed): Determine table by fetching
+ the event source. Pass the table to helper methods.
+ Use __command__ hack to determine the action command.
+ (TableAction.getFirstVisibleColumnIndex): Get table as argument.
+ (TableAction.getLastVisibleColumnIndex): Get table as argument.
+ (TableAction.getFirstVisibleRowIndex): Get table as argument.
+ (TableAction.getLastVisibleRowIndex): Get table as argument.
+ (TableAction.advanceMultipleSelection): Get table as argument.
+ (uninstallDefaults): Do nothing here.
+ (uninstallKeyboardActions): Uninstall the keyboard actions.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (processKeyBinding): Store the action command as property
+ in the Action instance that we call. This allows for
+ improvement on the side of the Action.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalUtils.java
+ (fillMetalPattern): Use fillRect() instead of drawLine() to
+ fill single pixels.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/GapContent.java
+ (getChars): Check for negative length and throw
+ BadLocationException.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ (FocusAction): Made class static.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Add keyboard bindings for
+ PopupMenu.
+
+2006-07-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/UIManager.java
+ (getLookAndFeelDefaults): Return the look and feel defaults.
+ (setLookAndFeel): Improved exception messsage.
+
+2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/StringContent.java
+ (StringContent): Changed initialLength to 10.
+
+2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/util/Vector.java: Fixed API doc typo.
+
+2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java
+ (createCompatibleSampleModel): Fixed typo in loop increment, set
+ correct scanlineStride, and updated API docs.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicPopupMenuUI.java
+ (NavigateAction): New inner class. This is responsible for
+ keyboard navigation through menus.
+ (KeyboardHelper): New inner class. This manages the
+ keyboard mappings and focus when a popup opens or closes.
+ (keyboardHelper): New static field.
+ (numPopups): New static field.
+ (installUI): Create KeyboardHelper for first popup.
+ Call installKeyboardActions().
+ (installKeyboardActions): Removed NotImplementedException.
+ This method is a no-op.
+ (installKeyboardActionsImpl): New method. Installs keyboard
+ mapping when a popup is opened.
+ (getActionMap): New helper method.
+ (createDefaultActions): New helper method.
+ (uninstallUI): Uninstall KeyboardHelper when last Popup is
+ uninstalled. Call uninstallKeyboardActions().
+ (uninstallKeyboardActions): Removed NotImplementedException.
+ This method is a no-op.
+ (uninstallKeyboardActionsImpl): New method. Uninstalls keyboard
+ mapping when a popup is closed.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (requestFocus()): Reimplemented to use requestFocusImpl().
+ (requestFocus(boolean)): Reimplemented to use requestFocusImpl().
+ (requestFocusInWindow()): Reimplemented to use requestFocusImpl().
+ (requestFocusInWindow(boolean)): Reimplemented to use
+ requestFocusImpl().
+ (requestFocusImpl): Reimplemented focus request to use
+ new peer method. Also added some obvious additional checks
+ for rejecting focus requests early.
+ * java/awt/ComponentPeer.java
+ (requestFocus(Component,boolean,boolean,long)): Documented
+ this method.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (requestFocus): New field.
+ (gtkWidgetHasFocus): New native method.
+ (gtkWidgetCanFocus): New native method.
+ (requestFocus): Replaced with assert false to prevent
+ usage of obsolete method.
+ (postFocusEvent(int,boolean,Component)): New overloaded method
+ for posting the focus event to a specific target.
+ (postFocusEvent(int,boolean)): Post event to requestFocus
+ component.
+ (requestFocus(Component,boolean,boolean,long)): Implemented.
+ (getWindowFor): New helper method.
+ (isLightweightDescendant): New helper method.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java
+ (gtkWindowHasFocus): New native method.
+ (requestFocus(Component,boolean,boolean,long)): New method.
+ Overrides GtkComponentPeer method to specially handly the
+ case when a Window receives a focus request for a lightweight
+ child.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (gtkWidgetHasFocus): New native method.
+ (gtkWidgetCanFocus): New native method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+ (gtkWindowHasFocus): New native method.
+ * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h,
+ * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h:
+ Regenerated.
+
+2006-07-25 Francis Kung <fkung@redhat.com>
+
+ * java/awt/DefaultKeyboardFocusManager.java
+ (dispatchEvent): Add check for valid component.
+
+2006-07-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/MBeanConstructorInfo.java:
+ New file.
+ * javax/management/MBeanNotificationInfo.java:
+ Documentation fix.
+ * javax/management/MBeanParameterInfo.java:
+ New file.
+
+2006-07-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/peer/gtk/CairoGraphics.java:
+ (drawLine): Added special case for 1 pixel lines.
+
+2006-07-25 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR27844.
+ * java/awt/peer/gtk/CairoGraphics.java:
+ (drawLine): Removed calls to shifted().
+
+2006-07-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/JTabbedPane.java:
+ (remove(Component)): Rewritten.
+ (setSelectedIndex): Implemented updating of component visibility state.
+
+2006-07-25 Sven de Marothy <sven@physto.se>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+ (init): Default to the actual depth in the worst case.
+
+ * java/awt/Font.java
+ (createFont(int, File)): New method.
+
+2006-07-25 Ito Kazumitsu <kaz@maczuka.gcd.org>
+
+ Fixes bug #28413
+ * gnu/java/util/regex/RETokenEnd.java(check_java_line_terminators):
+ New field.
+ (RETokenEnd): New constructer to set check_java_line_terminators.
+ (matchThis): Checck line terminators if check_java_line_terminators.
+ * gnu/java/util/regex/RETokenStart.java: Likewise.
+ * gnu/regexp/RE.java(initialize): Use the new constructors for
+ RETokenEnd and RETokenStart if REG_MULTILINE is set.
+ * java/util/regex/Pattern.java(Patteren): Changed so that
+ gnu/regexp/RE.java may use the new the new constructors.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Container.java
+ (focusTraversalPolicyProvider): New field.
+ (isFocusTraversalPolicyProvider): New method.
+ (setFocusTraversalPolicyProvider): New method.
+ * java/awt/ContainerOrderFocusTraversalPolicy.java
+ (getFirstComponent): Use accept() instead of lengthy checks.
+ Don't fetch getComponents() to avoid copying of array.
+ Traverse down the hierarchy to find the first focused component.
+ * java/awt/DefaultKeyboardFocusManager.java
+ (dispatchEvent): Let the initial component request focus.
+
+2006-07-25 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/Segment.java
+ (last): Update current index before returning DONE for zero count.
+
+2006-07-24 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/tree/TreePath.java (equals): Swap path equals call.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ (FocusAction): New inner class. Used to grab focus.
+ (installKeyboardActions): Implemented.
+ (uninstallKeyboardActions): Implemented.
+ (getActionMap): New helper method.
+ (createDefaultActions): New helper method.
+
+2006-07-25 Robert Schuster <robertschuster@fsfe.org>
+
+ * examples/gnu/classpath/examples/swing/Demo.java:
+ (mkMenuBar): Install instantiable basic look and feel.
+ (InstantiableBasicLookAndFeel): New inner class.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (GlassPaneDispatcher.dragTarget): New field.
+ (GlassPaneDispatcher.isDragging): New field.
+ (GlassPaneDispatcher.pressedComponent): Removed field.
+ (GlassPaneDispatcher.tempComponent): Removed field.
+ (GlassPaneDispatcher.pressCount): Removed field.
+ (GlassPaneDispatcher.mousePressed): Call
+ borderListener.mousePressed() to activate the frame.
+ (acquireComponentForMouseEvent): Removed method.
+ (handleEvent): Rewritten.
+ (redispatch): New method.
+ (InternalFramePropertyChangeListener.propertyChange):
+ Make glasspane invisible when frame is selected, and visible
+ if it gets deselected.
+
+2006-07-25 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (handleMouseEvent): Dispatch event to real target if
+ the dragTarget has become invisible in the meantime.
+
+2006-07-25 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/TabSet.java
+ (equals): New method override for 1.5,
+ (hashCode): Likewise,
+ (toString): Added spaces to match reference implementation.
+
+2006-07-24 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/IntrospectionException.java,
+ * javax/management/MBeanAttributeInfo.java:
+ New files.
+ * javax/management/MBeanNotificationInfo.java:
+ Documentation cleanups.
+
+2006-07-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/TabSet.java
+ (TabSet): Check for null argument,
+ (getTab): Throw IllegalArgumentException for index out of bounds,
+ (getTabIndexAfter): Changed test to '<=',
+ and updated API docs all over,
+ * javax/swing/text/TabStop.java: Updated API docs.
+
+2006-07-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/TabStop.java
+ (toString): Don't use 'left ' prefix, and added space between tab
+ location and '(w/leader)' suffix.
+
+2006-07-24 Francis Kung <fkung@redhat.com>
+
+ * javax/swing/JComboBox.java
+ (DefaultKeySelectionManager): Implemented.
+ (createDefaultKeySelectionManager): Implemented.
+ (getKeySelectionManager): Implemented.
+ (processKeyEvent): Removed duplicate code.
+ * javax/swing/JPopupMenu.java
+ (selectionModel): Changed visibility.
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (KeyHandler.keyPressed): Added navigation keys.
+ (configureEditor): Add key listener.
+ (installListeners): Install focus listener to combo box.
+ (isNavigationKey): Added enter, escape, and tab.
+ (selectPreviousPossibleValue): Added out of bounds check.
+ (unconfigureEditor): Remove key listener.
+ * javax/swing/plaf/metal/MetalComboBoxButton.java
+ (paintComponent): Highlight combo box when in focus.
+
+2006-07-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SwingUtilities.java
+ (isLeftMouseButton): Fixed condition.
+ * java/awt/LightweightDispatcher.java
+ (handleMouseEvent): Dispatch MOUSE_ENTERED even when mouse
+ is dragged.
+
+2006-07-24 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (setPaint): Fixed scaleX and scaleY.
+
+2006-07-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (handleInsert): Repaint the whole table for variable row
+ height tables and an optimized region otherwise.
+ (handleDelete): Likewise.
+ (handleUpdate): Likewise.
+
+2006-07-24 Mario Torre <neugens@limasoftware.net>
+
+ * gnu/java/awt/peer/gtk/GtkToolkit.java (createDragGestureRecognizer):
+ now explicity registerListeners on GtkMouseDragGestureRecognizer
+ instance.
+ * gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
+ (unregisterListeners): new method, overrided from base class
+ to rise visibility (from protected to public).
+ (registerListeners): Likewise.
+ (GtkMouseDragGestureRecognizer): fixed potential threading issue:
+ removed call to registerListeners from the constructor.
+
+2006-07-23 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac: Check for moc and moc-qt4.
+
+2006-07-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/Kernel.java: API doc updates.
+
+2006-07-22 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java: Optimize pixel swap code a
+ bit more.
+
+2006-07-22 Mark Wielaard <mark@klomp.org>
+
+ * java/lang/Iterable.java: Import all of java.util.
+ * lib/mkcollections.pl.in (javautilclasses): Add Iterable.
+ * lib/Makefile.am: Only search for .java files in COLLECTIONS_PREFIX.
+
+2006-07-22 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * doc/vmintegration.texinfo:
+ Document getType(String).
+ * gnu/java/lang/management/MemoryPoolMXBeanImpl.java,
+ * java/lang/management/MemoryPoolMXBean.java:
+ (getType()): Implemented.
+ * vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
+ (getType(String)): Implemented.
+
+2006-07-22 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * doc/vmintegration.texinfo:
+ Move end of itemization block.
+
+2006-07-22 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java:
+ (initComponentDefaults): Added new properties, added comments.
+
+2006-07-22 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * doc/vmintegration.texinfo:
+ Mention callback methods.
+ * gnu/java/lang/management/MemoryMXBeanImpl.java:
+ (fireNotification(String,String,long,long,long,long,long)):
+ Made package-private.
+ (fireThresholdExceededNotification(String,long,long,long,
+ long,long)): Likewise.
+ (fireCollectionThresholdExceededNotification(String,long,
+ long,long,long,long)): Likewise.
+ * java/lang/management/MemoryMXBean.java:
+ Document notifications.
+
+2006-07-22 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/MemoryMXBeanImpl.java:
+ (fireNotification(String,String,long,long,long,long,long)):
+ Implemented.
+ (fireThresholdExceededNotification(String,long,long,long,
+ long,long)): Likewise.
+ (fireCollectionThresholdExceededNotification(String,long,
+ long,long,long,long)): Likewise.
+ * java/lang/management/MemoryNotificationInfo.java:
+ Use composite type from MemoryMXBeanImpl.
+ * javax/management/openmbean/CompositeData.java:
+ Correct documentation.
+ * javax/management/openmbean/CompositeDataSupport.java,
+ * javax/management/openmbean/InvalidKeyException.java:
+ New files.
+
+2006-07-22 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/util/IntegerUtil.java: New file.
+
+2006-07-22 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/28100
+ * gnu/javax/crypto/cipher/TripleDES.java: Updated documentation.
+ (KEY_SIZE): Likewise.
+ (adjustParity(int,byte[],int): New method.
+ (adjustParity(byte[],int): Call above method with 3 as 1st argument.
+ (isParityAdjusted(int,byte[],int)): New method.
+ (isParityAdjusted): Call above method with 3 as 1st argument.
+ (keySizes): Add 8 and 16 as other valid key sizes.
+ (makeKey): Amended to cater for 1, 2 and 3 independent DES keys.
+
+2006-07-22 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java (CairoSurface): Rearrange
+ code for the pixel swap routine to be more efficient.
+
+2006-07-20 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java:
+ Removed unused fields.
+ (GtkMouseDragGestureRecognizer): Removed initializations.
+
+2006-07-20 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
+ (GtkMouseDragGestureRecognizer): New constructor.
+ (GtkMouseDragGestureRecognizer): New constructor.
+ (GtkMouseDragGestureRecognizer): New constructor.
+ (mouseClicked): Removed FIXME.
+ (mousePressed): Implemented.
+ (mouseReleased): Implemented.
+ (mouseEntered): Implemented.
+ (mouseDragged): Implemented to check mouse point and trigger origin.
+ (mouseMoved): Removed FIXME.
+ (getDropActionFromEvent): New helper function used to convert mouse event
+ modifiers to a drop action.
+ * java/awt/dnd/DragSource.java
+ (getDragThreshold): Changed to return some arbitrary value for testing
+ purposes.
+
+2006-07-20 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (findTarget): Also consider components that have their eventMask
+ set, for compatibility with stonage AWT. Optimized check
+ for MouseListener.
+ (handleMouseEvent): Likewise.
+
+2006-07-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (tableChanged): Split out handling of the event into multiple
+ subroutines.
+ (handleCompleteChange): New method. Clear the selection and
+ check the lead/anchor indices.
+ (handleInsert): New method. Check the lead/anchor indices.
+ Optimized repainting.
+ (handleDelete): New method. Check the lead/anchor indices.
+ Optimized repainting.
+ (handleUpdate): New method. Optimized repainting.
+ (checkSelection): New helper method.
+ (setSelectionModel): Update lead/anchor indices.
+
+2006-07-20 Lillian Angel <langel@redhat.com>
+
+ PR 28440
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+ (dispose): Reset all fields.
+
+2006-07-20 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XToolkit.java
+ (createImage(InputStream)): Only copy image to Pixmap if
+ it's actually opaque. Transparent images are left as
+ BufferedImage and composited later onto the screen.
+ * gnu/java/awt/peer/x/XGraphics.java
+ (XGraphics): Fetch some parameters for image rendering.
+ (drawImage): Added special handling of transparent images.
+ (getRGB): New helper method.
+ (setRGB): New helper method.
+
+2006-07-20 Roman Kennke <kennke@aicas.com>
+
+ * gnu/javax/imageio/IIOInputStream.java: New class. Wraps
+ ImageInputStreams as normal InputStreams.
+ * gnu/javax/imageio/gif/GIFStream.java:
+ Moved to gnu/javax/imageio/IIOInputStream.java.
+ * gnu/javax/imageio/gif/GIFImageReader.java
+ (readImage): Use IIOInputStream.
+ * gnu/javax/imageio/gif/GIFImageReaderSpi.java
+ (canDecodeInput): Use IIOInputStream.
+ * gnu/javax/imageio/png/PNGException.java: Make subclass
+ of IOException.
+ * gnu/javax/imageio/png/PNGImageReader.java: New class.
+ Implements the ImageIO ImageReader for PNG.
+ * gnu/javax/imageio/png/PNGImageReaderSpi.java: New class.
+ Implements the ImageIO ImageReaderSpi for PNG.
+ * javax/imageio/spi/IIORegistry.java:
+ (IIORegistry): Add PNGImageReaderSpi.
+
+2006-07-20 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/ComponentSampleModel.java
+ (getPixel): Added argument check,
+ (getSample): Modified exception message.
+
+2006-07-20 David Gilbert <david.gilbert@object-refinery.com>
+
+ PR Classpath/28422
+ * java/awt/image/ConvolveOp.java
+ (filter(Raster, WritableRaster)): Reimplemented,
+ (fillEdge): New private method.
+
+2006-07-19 Keith Seitz <keiths@redhat.com>
+
+ * include/jvmti.h (JVMTI_VERSION_1_0): Define.
+ (JVMTI_VERSION): Define.
+
+2006-07-19 Roman Kennke <kennke@aicas.com>
+
+ * resource/gnu/regexp/MessagesBundle.properties,
+ * resource/gnu/regexp/MessagesBundle_fr.properties,
+ * resource/gnu/regexp/MessagesBundle_it.properties:
+ Moved to resource/gnu/java/util/regex.
+ * resource/gnu/java/util/regex/MessagesBundle.properties,
+ * resource/gnu/java/util/regex/MessagesBundle_fr.properties,
+ * resource/gnu/java/util/regex/MessagesBundle_it.properties:
+ New files.
+ * gnu/java/util/regex/RE.java
+ Use new resource bundle location.
+
+2006-07-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildren): Refactored. The paintChildrenOptimized method
+ has been moved back in here. Added locking of the tree and
+ only check for completely obscured child components
+ when not optimized drawing enabled. Use Graphics.create() to
+ protect from irreversible changes.
+ (isCompletelyObscured): New helper method.
+ (paintComponent): Also use Graphics.create() for Graphics2D,
+ to protect from irreverible changes.
+ (clipAndTranslateGraphics): Refactored to use more efficient
+ iterative (vs recursive) approach.
+ * javax/swing/RepaintManager.java
+ (getOffscreenBuffer): Create image from root component.
+
+2006-07-19 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XGraphics.java
+ (translate): Don't set the clip on the X server.
+ (clipRect): Use setXClip() to set the clip on the X server.
+ (hitClip): More efficient and correct implementation.
+ (setClip): Use setXClip() to set the clip on the X server.
+ (setClip(Shape)): Use setXClip() to set the clip on the X server.
+ (copyArea): Translate and clip the source rectangle correctly.
+ (dispose): Only flush when object is not yet disposed.
+ (clone): Use setXClip() to set the clip on the X server.
+
+2006-07-19 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/imageio/png/PNGChunk.java,
+ * gnu/javax/imageio/png/PNGData.java,
+ * gnu/javax/imageio/png/PNGDecoder.java,
+ * gnu/javax/imageio/png/PNGEncoder.java,
+ * gnu/javax/imageio/png/PNGException.java,
+ * gnu/javax/imageio/png/PNGFile.java,
+ * gnu/javax/imageio/png/PNGFilter.java,
+ * gnu/javax/imageio/png/PNGGamma.java,
+ * gnu/javax/imageio/png/PNGHeader.java,
+ * gnu/javax/imageio/png/PNGICCProfile.java,
+ * gnu/javax/imageio/png/PNGPalette.java,
+ * gnu/javax/imageio/png/PNGPhys.java,
+ * gnu/javax/imageio/png/PNGTime.java:
+ New files.
+
+2006-07-19 Sven de Marothy <sven@physto.se>
+
+ * java/net/Inet6Address.java:
+ (getScopedId, getScopedInterface): New methods.
+
+2006-07-19 Lillian Angel <langel@redhat.com>
+
+ * examples/gnu/classpath/examples/awt/Demo.java
+ (DragDropWindow): Fixed typo in Label text.
+ * gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
+ (GtkDragSourceContextPeer): Removed unneeded initialization for field.
+ (startDrag): Initialized context field.
+ (transferablesFlavorsChanged): Removed FIXME. Nothing is done in this
+ function.
+ (dragEnter): New function.
+ (dragExit): Likewise.
+ (dragDropEnd): Likewise.
+ (dragMouseMoved): Likewise.
+ (dragOver): Likewise.
+ (dragActionChanged): Likewise.
+
+2006-07-19 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/26302
+ * resource/java/security/classpath.security: Updated copyright year.
+ (auth.login.defaultCallbackHandler): New property; set to our default
+ callback handler. This is needed by the LoginContext when no callback
+ handler was specified.
+ * javax/security/auth/login/LoginContext.java: Updated copyright year.
+ (LoginContext(4)): Assign passed parameters to local fields before invoking
+ lookup method.
+
+2006-07-19 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XGraphics.java
+ (drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver)):
+ Fixed ordering of parameters.
+
+2006-07-18 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/MemoryMXBeanImpl.java:
+ (MemoryMXBeanImpl()): Implemented.
+ (ListenerData): New private class.
+ (addNotificationListener(NotificationListener,
+ NotificationFilter, Object)): Implemented.
+ (getNotificationInfo()): Likewise.
+ (removeNotificationListener(NotificationListener)):
+ Likewise.
+ (removeNotificationListener(NotificationListener,
+ NotificationFilter, Object)): Likewise.
+
+2006-07-18 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XFontPeer.java
+ (encodeFont): Be more flexible with font sizes.
+ (validSize): New helper method.
+ * gnu/java/awt/peer/x/XGraphics.java
+ (drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver)):
+ Implemented.
+ (drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)):
+ Implemented.
+ * gnu/java/awt/peer/x/XImage.java
+ (properties): New field.
+ (getProperty): Implemented.
+ * resource/gnu/java/awt/peer/x/fonts.properties:
+ Added copyright header. Fixed font size field.
+
+2006-07-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java
+ (createDataBuffer): New method override,
+ * java/awt/image/ByteLookupTable.java
+ (ByteLookupTable(int, byte[][])): Create new array to hold references,
+ (ByteLookuptable(int, byte[])): Check for null array,
+ * java/awt/image/ComponentSampleModel.java
+ (createDataBuffer): Removed unnecessary braces,
+ (getSample): Check (x, y) is within bounds,
+ * java/awt/image/ShortLookupTable.java
+ (ShortLookupTable(int, short[][])): Create new array to hold references,
+ (ShortLookupTable(int, short[])): Check for null array,
+ (getTable): Added API docs,
+ (lookupPixel): Source reformatting.
+
+2006-07-18 Tania Bento <tbento@redhat.com>
+
+ * java/awt/GridLayout.java
+ (setHgap): Illegal Argument Exception should not be thrown if
+ hgap < 0.
+ (setVgap): Illegal Argument Exception should not be thrown if
+ vgap < 0.
+ (toString): Opening square braket ([) should appear before hgap
+ value, not the name of the class.
+
+2006-07-18 Roman Kennke <kennke@aicas.com>
+
+ * lib/copy-vmresources.sh.in: Reverted.
+ * gnu/java/awt/peer/x/fonts.properties: Moved to resource/
+ * resource/gnu/java/awt/peer/x/fonts.properties: New file.
+
+2006-07-18 Roman Kennke <kennke@aicas.com>
+
+ * lib/copy-vmresources.sh.in: Include properties from X peers.
+
+2006-07-18 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/27205
+ * tools/gnu/classpath/tools/jarsigner/SFHelper.java (writeDSA): Check
+ certificate validity.
+ (getIssuerName): New method.
+ (getSubjectName): Likewise.
+ (getNotAfterDate): Likewise.
+ (getNotBeforeDate): Likewise.
+ * resource/gnu/classpath/tools/jarsigner/messages.properties: Added
+ messages for newly added messages in SFHelper.
+
+2006-07-18 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XDialogPeer.java: New class.
+ * gnu/java/awt/peer/x/XEventPump.java
+ (handleEvent): Cast to XWindowPeer rather than XFramePeer.
+ * gnu/java/awt/peer/x/XFramePeer.java
+ Made a subclass of XWindowPeer, rather than SwingFramePeer.
+ * gnu/java/awt/peer/x/XGraphics.java
+ Made subclass of Graphics rather than Graphics2D. Removed
+ all Graphics2D specific method stubs.
+ (setColor): Map colors using the X color map that is
+ stored in XToolkit.
+ * gnu/java/awt/peer/x/XToolkit.java
+ (colorMap): New field.
+ (getLocalGraphicsEnvironment): Return new XGraphicsEnvironment
+ instance.
+ (createDialog): Implemented.
+ (createImage(ImageProducer)): Implemented.
+ (createImage(InputStream)): Use createImage(ImageProducer)
+ to convert the BufferedImage to an XImage.
+ * gnu/java/awt/peer/x/XWindowPeer.java
+ (XWindowPeer): Removed debug output.
+
+2006-07-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BufferedImageOp.java: API docs added,
+ * java/awt/image/RasterOp.java: Likewise.
+
+2006-07-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Graphics2D.java: API docs updated.
+
+2006-07-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/WritableRaster.java: Added API docs and reformatted
+ source code.
+
+2006-07-18 Sven de Marothy <sven@physto.se>
+
+ * java/net/Inet6Address.java:
+ Add 1.5 serialized fields.
+ (getByAddress): New methods.
+ (readObject, writeObject): New methods.
+ (equals): Reimplement.
+
+2006-07-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/Raster.java: Added API docs and reformatted source
+ code.
+
+2006-07-18 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java: Remove unneeded
+ imports.
+ * gnu/java/awt/peer/gtk/CairoSurface.java: Likewise.
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java: Likewise.
+ * gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java: Likewise.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkButtonPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkClipboardNotifier.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkContainerPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkDialogPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkFramePeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkImage.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkImageConsumer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkMenuItemPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkPanelPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkScrollbarPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java: Likewise.
+
+2006-07-17 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * javax/swing/text/html/HTMLEditorKit.java: Rearrange import statements
+ to make it compile again under jikes. Note added.
+
+2006-07-17 Lillian Angel <langel@redhat.com>
+
+ * examples/gnu/classpath/examples/awt/Demo.java
+ (Demo): Added new window for DnD demo.
+ (DragDropWindow): New class.
+ * gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java:
+ Added new fields and declarations for native functions.
+ (GtkDragSourceContextPeer): Implemented.
+ (getComponentPeer): New function.
+ (startDrag): Partially implemented.
+ (getCursor): Implemented.
+ (setCursor): Implemented.
+ * include/GtkDragSourceContextPeer.h: New file.
+ * include/Makefile.am: Added new header file.
+ * java/awt/Component.java
+ (addNotify): Added call to the dropTarget's addNotify.
+ * java/awt/dnd/DragSource.java
+ (startDrag): Fixed code to use shared instances of peer and
+ context.
+ (getDragThreshold): Added stub.
+ * java/awt/dnd/DropTarget.java
+ (DropTarget): Implemented fully.
+ (addNotify): Added code to get the peer of the parent that is
+ not lightweight.
+ * java/awt/dnd/DropTargetDragEvent.java
+ (getTransferable): Added stub.
+ * native/jni/gtk-peer/GtkDragSourceContextPeer.c: New file.
+ * native/jni/gtk-peer/Makefile.am: Added new c file.
+ * gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java:
+ Changed to extend GtkGenericPeer.
+ (GtkDropTargetContextPeer): New constructor.
+ * gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java:
+ Changed to extend GtkGenericPeer.
+ (GtkDropTargetContextPeer): New constructor.
+
+2006-07-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/SinglePixelPackedSampleModel.java
+ (createSubsetSampleModel): Added argument check and API docs.
+
+2006-07-17 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XGraphics.java
+ (copyArea): Implemented.
+
+2006-07-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/SinglePixelPackedSampleModel.java
+ (getSampleSize): Return copy of array,
+ (getOffset): Added API docs,
+ (getScanlineStride): Likewise,
+ (hashCode): Implemented.
+
+2006-07-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MultiPixelPackedSampleModel.java
+ (getOffset): Updated API docs and source reformatting,
+ (getBitOffset): Source reformatting only,
+ (getDataElements): Likewise,
+ (getPixel): Likewise,
+ (getPixels): Removed method override,
+ (setDataElements): Reimplemented.
+
+2006-07-17 Gary Benson <gbenson@redhat.com>
+
+ * resource/META-INF/services/.cvsignore: New file.
+ * lib/.cvsignore: Updated.
+
+2006-07-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonListener.java
+ (propertyChange): Only do the text layout caching as long
+ as the noGraphics2D property isn't set.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (PropertyChangeHandler.propertyChange): Only do the text layout
+ caching as long as the noGraphics2D property isn't set.
+
+2006-07-17 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/XGraphicsEnvironment.java
+ (XGraphicsEnvironment): Make constructor public so that it
+ can be called via Class.forName().newInstance().
+ * gnu/java/awt/peer/x/XImage.java
+ (XImage): Fetch GraphicsEnvironment via
+ GraphicsEnvironment.getLocalGraphicsEnvironment() rather
+ than the XToolkit method, to avoid double instantiation
+ of the XGraphicsEnvironment.
+ * gnu/java/awt/peer/x/XToolkit.java
+ (env): Removed field.
+ (getLocalGraphicsEnvironment): Removed impl. This method
+ should not be called since we set the graphicsenv property
+ in the constructor.
+
+2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/UUID.java:
+ (compareTo(Object)): Call compareTo(UUID).
+ (compareTo(UUID)): Implemented.
+
+2006-07-16 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/StrictMath.java (cbrt): Added '@since'.
+
+2006-07-16 Carsten Neumann <cn-develop@gmx.net>
+
+ * java/lang/StrictMath.java (cbrt): New method.
+ (getLowDWord): New helper method.
+ (getHighDWord): Likewise.
+ (buildDouble): Likewise.
+ (CBRT_B1): New field.
+ (CBRT_B2): Likewise.
+ (CBRT_C): Likewise.
+ (CBRT_D): Likewise.
+ (CBRT_E): Likewise.
+ (CBRT_F): Likewise.
+ (CBRT_G): Likewise.
+
+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 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 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
+ (setDelay): Throw IllegalArgumentException for negative delay,
+ (setInitialDelay): Likewise,
+ * javax/swing/ToolTipManager.java
+ (setInitialDelay): Document IllegalArgumentException,
+ (setDismissDelay): Likewise,
+ (setReshowDelay): Likewise.
+
+2006-07-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/MemoryUsage.java:
+ (from(javax.management.openmbean.CompositeData)):
+ Implemented.
+ * java/lang/management/ThreadInfo.java:
+ Changed to use open types throughout for the state.
+ (ThreadInfo(long,String,String,long,long,String,
+ long,String,long,long,boolean,StackTraceElement[])):
+ New constructor.
+ (checkAttribute(javax.management.openmbean.CompositeType,
+ String, javax.management.openmbean.OpenType)): New method.
+ (from(javax.management.openmbean.CompositeData)):
+ Implemented.
+ (getLockName()): Fixed to use new variable.
+ (getLockOwnerId()): Likewise.
+ (getLockOwnerName()): Likewise.
+ (getThreadId()): Likewise.
+ (getThreadName()): Likewise.
+ (getThreadState()): Likewise.
+ (toString()): Refactored to use new variables.
+ * javax/management/openmbean/ArrayType.java:
+ New file.
+ * javax/management/openmbean/CompositeType.java:
+ Variables should be transient, not volatile.
+ * javax/management/openmbean/OpenDataException.java:
+ (serialVersionUID): Added.
+ * javax/management/openmbean/SimpleType.java:
+ New file.
+ * javax/management/openmbean/TabularType.java
+ Variables should be transient, not volatile.
+
+2006-07-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/.cvsignore: Updated for new tools.
+
+2006-07-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/openmbean/CompositeData.java,
+ * javax/management/openmbean/CompositeType.java,
+ * javax/management/openmbean/OpenDataException.java,
+ * javax/management/openmbean/OpenType.java,
+ * javax/management/openmbean/TabularData.java,
+ * javax/management/openmbean/TabularType.java,
+ * javax/management/openmbean/package.html:
+ New files.
+
+2006-07-09 Mark Wielaard <mark@klomp.org>
+
+ * gnu/javax/print/ipp/IppRequest.java: Remove double assignment.
+ * gnu/java/rmi/server/UnicastServerRef.java: Likewise.
+ * gnu/java/rmi/server/ActivatableServerRef.java: Likewise.
+
+2006-07-08 Anthony Green <green@redhat.com>
+
+ * gnu/javax/sound/sampled/WAV/WAVReader.java,
+ resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader:
+ New files.
+
+2006-07-09 Mario Torre <neugens@limasoftware.net>
+
+ * native/jni/gconf-peer/GConfNativePeer.c:
+ Fixed indentation to be more compliant to the GNU coding
+ guidelines.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset):
+ Added explicit test for errors in the GConf backend.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
+ Added explicit test for errors in the GConf backend.
+ Fixed Segmentation Fault when non valid key names are given as input.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string):
+ likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists):
+ Added explicit test for errors in the GConf backend.
+ * gnu/java/util/prefs/gconf/GConfNativePeer.java:
+ Added javadoc comments for all native methods.
+ (nodeExist): removed test to check for valid absolute path name
+ for nodes.
+ (startWatchingNode): likewise.
+ (stopWatchingNode): likewise.
+ (setString): likewise, plus fixed javadoc comments.
+ (unset): likekwise.
+ (getKey): likewise.
+ (getKeys): likewise, also fixed javadoc comments.
+ (getChildrenNodes): likewise.
+ * gnu/java/util/prefs/GConfBasedPreferences.java:
+ changed DEFAULT_USER_ROOT to /apps/classpath.
+ (constructor): Test to check for a valid absolute path for nodes
+ is now in the contructor for that node, instead of being on
+ each method of the backend.
+ (getGConfKey): removed empty new line.
+
+2006-07-08 Mark Wielaard <mark@klomp.org>
+
+ * .classpath: Add gnu/java/awt/peer/x/ to excludes.
+
+2006-07-08 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/FlowView.java (FlowStrategy.layoutRow):
+ Handle the forced break in the same way as exceeding the
+ available row space.
+ * javax/swing/text/html/HRuleView.java: Rewritten.
+ * javax/swing/text/html/HTMLDocument.java
+ (HTMLReader.addSpecialElement):Reserve two characters for
+ the special elements.
+ * examples/gnu/classpath/examples/swing/HtmlDemo.java
+ (text): Extended the HTML example to parse.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (setHorizontalAlignment): Check for illegal argument,
+ (setVerticalAlignment): Likewise.
+
+2006-07-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/TableView.java
+ (getStyleSheet): New method. (RowView.getStyleSheet):
+ New method.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (setRolloverIcon): Call setRolloverEnabled(true),
+ (setRolloverSelectedIcon): Likewise.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/border/TitledBorder.java
+ (setTitlePosition): Added message to exception,
+ (setTitleJustification): Likewise.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (createDefaultTheme): Corrected API docs,
+ (initComponentDefaults): Added entry for 'TitledBorder.border',
+ (getCurrentTheme): Initialise theme if it is null.
+
+2006-07-07 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (isValid): Return false when component has no peer,
+ don't query the showing state.
+
+2006-07-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/FlowView.java (FlowStrategy.layoutRow):
+ Advance the offset also in the case of the enforced break.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java
+ (MAXIMUM_SIZE): Removed field,
+ (MINIMUM_SIZE): Likewise,
+ (PREFERRED_SIZE): Likewise,
+ (getMaximumSize): Return new instance every time,
+ (getMinimumSize): Likewise,
+ (getPreferredSize): Likewise.
+
+2006-07-07 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (findTarget): Avoid array copying in
+ Container.getComponents().
+
+2006-07-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildrenWithOverlap): Avoid array copying in
+ Container.getComponents().
+ (paintChildrenOptimized): Avoid array copying in
+ Container.getComponents().
+ (fireAncestorEvent): Avoid array copying in
+ Container.getComponents().
+ (findOverlapFreeParent): Avoid array copying in
+ Container.getComponents().
+
+2006-07-07 Matt Wringe <mwringe@redhat.com>
+
+ * javax/crypto/spec/PBEKeySpec.java: Updated copyright year.
+ (passwordValid): New field.
+ (setPassword): New method.
+ (setSalt): Likewise.
+ (setIterationCount): Likewise.
+ (setKeyLength): Likewise.
+ (PBEKeySpec(char[])): Use new setter methods.
+ (PBEKeySpec(char[], byte[], int)): Likewise.
+ (PBEKeySpec(char[], byte[], int, int)): Likewise.
+ (clearPassword): Set passwordValid to false.
+ (getPassword): Check that clearPassword() was not called earlier.
+ Return a clone of the password.
+ (getSalt): Return a clone of the salt if it was not null.
+
+2006-07-07 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (isValid): Always return false when component is
+ not showing.
+ (setFont): Always set font, even when setting
+ the same or equal font again.
+
+2006-07-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (CheckBoxMenuItemIcon): Implement UIResource,
+ (FileChooserDetailViewIcon): Likewise,
+ (FileChooserHomeFolderIcon): Likewise,
+ (FileChooserListViewIcon): Likewise,
+ (FileChooserNewFolderIcon): Likewise,
+ (FileChooserUpFolderIcon): Removed redundant 'implements',
+ (RadioButtonMenuItemIcon): Implement UIResource,
+ (HorizontalSliderThumbIcon): Likewise,
+ (InternalFrameCloseIcon): Likewise,
+ (InternalFrameDefaultMenuIcon): Likewise,
+ (InternalFrameAltMaximizeIcon): Likewise,
+ (InternalFrameMaximizeIcon): Likewise,
+ (InternalFrameMinimizeIcon): Likewise,
+ (VerticalSliderThumbIcon): Likewise,
+ (TreeHardDriveIcon): Likewise,
+ (TreeFloppyDriveIcon): Likewise,
+ (TreeComputerIcon): Likewise,
+ (horizontalSliderThumbIcon): New field,
+ (verticalSliderThumbIcon): New field,
+ (getHorizontalSliderThumbIcon): Cache icon,
+ (getVerticalSliderThumbIcon): Likewise.
+
+2006-07-06 Mark Wielaard <mark@klomp.org>
+
+ * lib/Makefile.am (CLEANFILES): Add Makefile.deps.
+ (DISTCLEANFILES): Add standard.omit.
+ (clean-local): Remove Makefile.deps, only remove dirs.
+
+2006-07-06 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (setFont): Only invalidate when component is valid.
+ * java/awt/Container.java
+ (setLayout): Only invalidate when component is valid.
+
+2006-07-06 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java:
+ New class not fully implemented.
+ * gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java:
+ New class not fully implemented.
+ * gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java:
+ New class not fully implemented.
+ * gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java:
+ New class not fully implemented.
+ * nu/java/awt/peer/gtk/GtkToolkit.java:
+ Fixed Imports.
+ (createDragSourceContextPeer): Implemented.
+ (createDragGestureRecognizer): New function to override
+ java.awt.Toolkit.createDragGestureRecognizer.
+ * java/awt/dnd/DragSource.java
+ (NoDragGestureRecognizer): Removed inner class.
+ (createDragGestureRecognizer): Re-Implemented to
+ call Toolkit's createDragGestureRecognizer.
+ (createDefaultDragGestureRecognizer): Re-Implemented to
+ call Toolkit's createDragGestureRecognizer.
+ * java/awt/dnd/DropTarget.java
+ (addNotify): Added check to determine type of peer and call
+ addDropTarget.
+ (removeNotify): Added call to removeDropTarget.
+
+2006-07-06 Tom Tromey <tromey@redhat.com>
+
+ * gnu/java/util/prefs/EventDispatcher.java (dispatch): Notify
+ 'queue'.
+ (run): Wait on queue, not 'this'.
+
+2006-07-06 Lillian Angel <langel@redhat.com>
+
+ * java/awt/dnd/DragSource.java
+ (startDrag): Implemented. Added comments describing
+ what the function should do. Removed FIXME.
+
+2006-07-06 Tania Bento <tbento@redhat.com>
+
+ * gnu/java/awt/Canvas.java
+ Added new private variable 'next_canvas_number'.
+ (generateName): Added.
+ (getUniqueLong): Added.
+
+2006-07-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/CharacterAttributeTranslator.java
+ (getColor): Made public.
+ * javax/swing/text/html/StyleSheet.java (stringToColor):
+ Use CharacterAttributeTranslator.getColor(String)
+
+2006-07-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLEditorKit.java:
+ (HTMLFactory.createElement): Update reference to the html table view.
+ * javax/swing/text/html/HTMLTableView.java: Removed (renamed).
+ * javax/swing/text/html/TableView.java: New file.
+
+2006-07-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLEditorKit.java:
+ (HTMLFactory.createElement): Uncomment
+ code for BRView and HRuleView.
+ * javax/swing/text/html/BRView.java,
+ javax/swing/text/html/HRuleView.java: New files.
+
+2006-07-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS: Updated.
+ * doc/vmintegration.texinfo: Likewise.
+ * examples/gnu/classpath/examples/management/TestGarbageCollector.java,
+ * examples/gnu/classpath/examples/management/TestMemoryManager.java,
+ * gnu/java/lang/management/GarbageCollectorMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryManagerMXBeanImpl.java,
+ * java/lang/management/GarbageCollectorMXBean.java:
+ New files.
+ * java/lang/management/ManagementFactory.java:
+ (getGarbageCollectorMXBeans()): Implemented.
+ (getMemoryManagerMXBeans()): Likewise.
+ * vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
+ * vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java:
+ New files.
+ * vm/reference/java/lang/management/VMManagementFactory.java:
+ (getMemoryManagerNames()): Added.
+ (getGarbageCollectorNames()): Added.
+
+2006-07-05 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/plugin/Makefile.am (nativeexeclib_LTLIBRARIES): Rename
+ from lib_LTLIBRARIES.
+ (install-plugin): Depend on nativeexeclib_LTLIBRARIES.
+
+2006-07-05 Lillian Angel <langel@redhat.com>
+
+ * java/awt/dnd/DragGestureEvent.java:
+ Added new fields.
+ (DragGestureEvent): Initialized new fields, added to check and
+ added documentation.
+ (getSourceAsDragGestureRecognizer): Added documentation and
+ changed to use getSource.
+ (getComponent): Added documentation and fixed to return the proper
+ value.
+ (getDragSource): Likewise.
+ (getDragOrigin): Added documentation.
+ (iterator): Implemented and added documentation.
+ (toArray): Likewise.
+ (toArray): Likewise.
+ (getDragAction): Likewise.
+ (getTriggerEvent): Likewise.
+ (startDrag): Likewise.
+ * java/awt/dnd/DragGestureRecognizer.java
+ (resetRecognizer): Added FIXME.
+ * java/awt/dnd/DragSource.java:
+ Added new field.
+ (DragSource): Set ds to be null if headless.
+ (getDefaultDragSource): Added documentation and implemented.
+ (isDragImageSupported): Marked as unimplemented.
+ (startDrag): Likewise.
+ (createDragSourceContext): Implemented.
+ (NoDragGestureRecognizer): Formatted inner class.
+ * java/awt/dnd/DropTarget.java
+ (stop): Marked as unimplemented.
+ (actionPerformed): Likewise.
+ (addDropTargetListener): Added code to throw exception.
+ (removeDropTargetListener): Added check, removed FIXME.
+ (dragEnter): Implemented.
+ (dragOver): Implemented.
+ (dropActionChanged): Implemented.
+ (dragExit): Implemented.
+ (drop): Implemented.
+ (addNotify): Implemented.
+ (removeNotify): Implemented.
+ (createDropTargetContext): Implemented.
+ (createDropTargetAutoScroller): Implemented.
+ (initializeAutoscrolling): Implemented.
+ (updateAutoscroll): Implemented.
+ (clearAutoscroll): Implemented.
+ * java/awt/dnd/DropTargetContext.java
+ (dropComplete): Implemented.
+ (acceptDrag): Implemented.
+ (rejectDrag): Implemented.
+ (acceptDrop): Implemented.
+ (rejectDrop): Implemented.
+ (getCurrentDataFlavors): Implemented.
+ (getTransferable): Partially implemented.
+ * java/awt/dnd/DropTargetDragEvent.java
+ (getDropAction): Uncommented correct code.
+ * java/awt/dnd/DropTargetDropEvent.java
+ (dropComplete) :Implemented.
+ * java/awt/dnd/InvalidDnDOperationException.java
+ (InvalidDnDOperationException): Added call to super.
+
+2006-07-05 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java:
+ (paint): Removed getBounds() call, changed center point
+ calculation.
+
+2006-07-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/InputMap.java
+ (inputMap): Don't initialize yet,
+ (InputMap): Removed TODO,
+ (get): Check for null inputMap,
+ (put): Return immediately for null keyStroke, check for null inputMap
+ and initialize if necessary,
+ (remove): Check for null inputMap,
+ (size): Likewise,
+ (clear): Likewise,
+ (keys): Likewise,
+ (allKeys): Likewise,
+ (writeObject): Removed,
+ (readObject): Removed.
+
+2006-07-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/classpath/examples/swing/TabbedPaneDemo.java
+ (createContent): Use different labels for buttons.
+
+2006-07-04 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS: Updated.
+ * doc/vmintegration.texinfo: Likewise.
+ * examples/gnu/classpath/examples/management/TestMemoryPool.java,
+ * gnu/java/lang/management/MemoryPoolMXBeanImpl.java:
+ New files.
+ * java/lang/management/ManagementFactory.java:
+ (getMemoryPoolMXBeans()): Implemented.
+ * vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
+ * vm/reference/java/lang/management/VMManagementFactory.java:
+ New files.
+
+2006-07-04 Lillian Angel <langel@redhat.com>
+
+ * java/awt/dnd/DragSourceContext.java:
+ Removed FIXMEs from fields.
+ (DragSourceContext): Added code to initialize cursor and sourceActions.
+ (getDragSource): Added documentation.
+ (getComponent): Likewise.
+ (getTrigger): Likewise.
+ (getSourceActions): Added documentation and implemented.
+ (setCursor): Implemented. Added documentation.
+ (getCursor): Implemented. Added documentation.
+ (dragEnter): Added code to notify DragSource's listeners.
+ (dragOver): Likewise.
+ (dragExit): Likewise.
+ (dropActionChanged): Likewise.
+ (dragDropEnd): Likewise.
+ (dragMouseMoved): Implemented.
+ (getTransferable): Added API documentation.
+ (updateCurrentCursor): Added API documentation and partially implemented.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java (KeyHandler): Implemented.
+
+2006-07-04 Lillian Angel <langel@redhat.com>
+
+ * java/awt/dnd/DragSourceContext.java
+ (DragSourceContext): Implemented fully. Fixed API docs.
+ (transferablesFlavorsChanged): Implemented.
+ (dragEnter): Implemented.
+ (dragOver): Implemented.
+ (dragExit): Implemented.
+ (dropActionChanged): Implemented.
+ (dragDropEnd): Implemented.
+
+2006-07-04 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java:
+ Fixed name of constant.
+ (getIconWidth): Changed name of constant returned.
+ (getIconHeight): Likewise.
+ (paint): Likewise.
+ (createSeparator): Marked as unimplemented.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (focusGained): Marked as unimplemented.
+ (focusLost): Marked as unimplemented.
+ (mouseEntered): Likewise.
+ (mouseMoved): Likewise.
+ (uninstallDefaults): Likewise.
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (mouseClicked): Changed comment.
+ (mouseEntered): Likewise.
+ (mouseExited): Likewise.
+ (mouseMoved): Likewise.
+ (setOrientation): Implemented.
+ (ToolBarFocusListener): Marked as unimplemented.
+ (focusGained): Marked as unimplemented.
+ (focusLost): Marked as unimplemented.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28061
+ * javax/swing/plaf/basic/BasicTreeUI.java (isLocationInExpandControl):
+ Mind the effect of the root visibility on the position of the control.
+ Quess icon width 18. (paintVerticalPartOfLeg): Do no paint the
+ vertical line over first level nodes.
+
+2006-07-04 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ (installKeyboardActions): Implemented to call super. Nothing else
+ needs to be done here.
+ (setupPostTimer): Marked as unimplemented.
+ (uninstallKeyboardActions): Implemented to call super. Nothing else
+ needs to be done here.
+ (mouseMoved): Removed TODO. Nothing to be done here.
+ (ChangeHandler): Implemented.
+ (menuDragMouseExited): Removed TODO. Nothing to be done here.
+ (menuDragMouseReleased): Removed TODO. Nothing to be done here.
+ (menuKeyReleased): Removed TODO. Nothing to be done here.
+ (menuKeyTyped): Marked as unimplemented.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28061
+ * gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
+ (getDefaults): Set hash color to black.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Set hash color to grey blue.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (instellDefaults): Set hash color.
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (TreeControlIcon.paint): Rewritten.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28061
+ * javax/swing/plaf/basic/BasicTreeUI.java (MouseHandler.mousePressed):
+ Always cancel the current editing session before doing anything else,
+ return immediately if this fails.
+ (TreeHomeAction): Ensure that the lead selection path is visible after
+ the action is performed. TreeIncrementAction: Likewise. TreeToggleAction:
+ Likewise. TreeTraverseAction: Likewise.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28061
+ * javax/swing/plaf/basic/BasicTreeUI.java (MouseHandler.mousePressed):
+ Returned back the code to handle the start of the click-pause-click
+ editing initiation, explained about this code.
+ (TreeStartEditingAction): New inner class.
+ (stopEditingInCompleteEditing): Explained about this field.
+ (completeEditing(boolean, boolean, boolean): Only return early
+ if there is no current editing session.
+ (createDefaultActions): Install TreeStartEditingAction and
+ TreeCancelEditingAction.
+
+2006-07-04 Mario Torre <neugens@limasoftware.net>
+
+ * configure.ac: Added new option --enable-default-preferences-peer
+ to pass user specified default preference backend.
+ If the GConf peer is built, GConf become the default backend.
+ * resource/META-INF/services/java.util.prefs.PreferencesFactory.in:
+ new file.
+ * lib/Makefile.am: excludes files terminating in 'in' from
+ the metafiles list.
+ * lib/copy-vmresources.sh.in: excludes files terminating in 'in'
+ from copy into META-INF.
+ * java/util/prefs/Preferences.java: added two new import
+ classes gnu.classpath.ServiceFactory and java.util.Iterator.
+ (getFactory): Now try to check for
+ a system defined default preference backend before to fall back on
+ FileBasedPreference.
+
+2006-07-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28061
+ * javax/swing/JTree.java (COLLAPSED): Initialise to Boolean.FALSE.
+ (EXPANDED): Initialise to Boolean.TRUE.
+ * javax/swing/plaf/basic/BasicTreeUI.java (completeUIInstall):
+ First configure layout cache and then set the assigned value
+ as row mapper. Set the root visibility property.
+ (toggleExpandState): Obtains expansion state from the layout cache.
+
+2006-07-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/MemoryPoolMXBean.java:
+ New file.
+
+2006-07-03 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/RSACipherImpl.java: Source formatting.
+
+2006-07-03 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/sasl/anonymous/AnonymousClient.java: Source formatting.
+ * gnu/javax/crypto/sasl/anonymous/AnonymousServer.java: Likewise.
+ * gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/CramMD5Client.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/CramMD5Server.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/CramMD5Util.java: Likewise.
+ * gnu/javax/crypto/sasl/crammd5/PasswordFile.java: Likewise.
+ * gnu/javax/crypto/sasl/plain/PasswordFile.java: Likewise.
+ * gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java: Likewise.
+ * gnu/javax/crypto/sasl/plain/PlainClient.java: Likewise.
+ * gnu/javax/crypto/sasl/plain/PlainRegistry.java: Likewise.
+ * gnu/javax/crypto/sasl/plain/PlainServer.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/CALG.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/ClientStore.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/IALG.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/KDF.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/PasswordFile.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SecurityContext.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/ServerStore.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRP.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPClient.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPRegistry.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPServer.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/StoreEntry.java: Likewise.
+ * gnu/javax/crypto/sasl/AuthInfo.java: Likewise.
+ * gnu/javax/crypto/sasl/AuthInfoProviderFactory.java: Likewise.
+ * gnu/javax/crypto/sasl/ClientFactory.java: Likewise.
+ * gnu/javax/crypto/sasl/ClientMechanism.java: Likewise.
+ * gnu/javax/crypto/sasl/ConfidentialityException.java: Likewise.
+ * gnu/javax/crypto/sasl/IAuthInfoProvider.java: Likewise.
+ * gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java: Likewise.
+ * gnu/javax/crypto/sasl/IllegalMechanismStateException.java: Likewise.
+ * gnu/javax/crypto/sasl/InputBuffer.java: Likewise.
+ * gnu/javax/crypto/sasl/IntegrityException.java: Likewise.
+ * gnu/javax/crypto/sasl/NoSuchMechanismException.java: Likewise.
+ * gnu/javax/crypto/sasl/NoSuchUserException.java: Likewise.
+ * gnu/javax/crypto/sasl/OutputBuffer.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslEncodingException.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslInputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslOutputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslUtil.java: Likewise.
+ * gnu/javax/crypto/sasl/ServerFactory.java: Likewise.
+ * gnu/javax/crypto/sasl/ServerMechanism.java: Likewise.
+ * gnu/javax/crypto/sasl/UserAlreadyExistsException.java: Likewise.
+
+2006-07-02 Anthony Green <green@redhat.com>
+
+ * gnu/javax/sound/midi/file/MidiFileWriter.java (writeTrack): Make
+ sure that every track written ends with an End Of Track meta
+ message.
+
+2006-07-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/MemoryUsage.java:
+ (toString()): Fix missing MB for maximum memory usage.
+
+2006-07-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS:
+ Updated to include VMCompilationMXBeanImpl.
+ * doc/vmintegration.texinfo:
+ Likewise, along with update to VMMemoryMXBeanImpl
+ as below.
+ * examples/gnu/classpath/examples/management/TestCompilation.java,
+ * gnu/java/lang/management/CompilationMXBeanImpl.java,
+ * java/lang/management/CompilationMXBeanImpl.java:
+ New files.
+ * java/lang/management/ManagementFactory.java:
+ (getCompilationMXBean()): Implemented.
+ * vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java:
+ New file.
+ * vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java:
+ (getHeapMemoryUsage()): Added default implementation.
+
+2006-07-02 Anthony Green <green@redhat.com>
+
+ * NEWS: Mention MIDI file reader/writer providers.
+
+2006-07-02 Anthony Green <green@redhat.com>
+
+ * resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter,
+ gnu/javax/sound/midi/file/MidiFileWriter.java,
+ gnu/javax/sound/midi/file/MidiDataOutputStream.java: New files.
+
+2006-07-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS:
+ Updated to include VMMemoryMXBeanImpl.
+ * doc/vmintegration.texinfo: Likewise.
+ * examples/gnu/classpath/examples/management/TestMemory.java:
+ New file.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java:
+ Remove redundant import.
+ * gnu/java/lang/management/MemoryMXBeanImpl.java:
+ New file.
+ * gnu/java/lang/management/ThreadMXBeanImpl.java:
+ Remove redundant import.
+ * java/lang/management/ManagementFactory.java:
+ (getMemoryMXBean()): Implemented.
+ * java/lang/management/MemoryMXBean.java,
+ * java/lang/management/MemoryUsage.java:
+ New files.
+ * java/lang/management/ThreadInfo.java:
+ (toString()): Updated documentation.
+ * vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java:
+ New file.
+
+2006-07-01 Anthony Green <green@redhat.com>
+
+ * resource/META-INF/services/javax.sound.midi.spi.MidiFileReader,
+ gnu/javax/sound/midi/file/MidiFileReader.java,
+ gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java,
+ gnu/javax/sound/midi/file/MidiDataInputStream.java: New files.
+
+2006-07-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/prng/ARCFour.java: Source formatting.
+ * gnu/javax/crypto/prng/CSPRNG.java: Likewise.
+ * gnu/javax/crypto/prng/Fortuna.java: Likewise.
+ * gnu/javax/crypto/prng/ICMGenerator.java: Likewise.
+ * gnu/javax/crypto/prng/PBKDF2.java: Likewise.
+ * gnu/javax/crypto/prng/PRNGFactory.java: Likewise.
+ * gnu/javax/crypto/prng/UMacGenerator.java: Likewise.
+
+2006-07-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/pad/BasePad.java: Source formatting.
+ * gnu/javax/crypto/pad/IPad.java: Likewise.
+ * gnu/javax/crypto/pad/PadFactory.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS1_V1_5.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS7.java: Likewise.
+ * gnu/javax/crypto/pad/SSL3.java: Likewise.
+ * gnu/javax/crypto/pad/TBC.java: Likewise.
+ * gnu/javax/crypto/pad/TLS1.java: Likewise.
+ * gnu/javax/crypto/pad/WrongPaddingException.java: Likewise.
+
+2006-07-01 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/SysexMessage.java (setMessage): Fix sysex
+ status byte test.
+ (setMessage): Fix it again, in a different setMessage method.
+
+2006-07-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/mode/BaseMode.java: Source formatting.
+ * gnu/javax/crypto/mode/CBC.java: Likewise.
+ * gnu/javax/crypto/mode/CFB.java: Likewise.
+ * gnu/javax/crypto/mode/CTR.java: Likewise.
+ * gnu/javax/crypto/mode/EAX.java: Likewise.
+ * gnu/javax/crypto/mode/ECB.java: Likewise.
+ * gnu/javax/crypto/mode/IAuthenticatedMode.java: Likewise.
+ * gnu/javax/crypto/mode/ICM.java: Likewise.
+ * gnu/javax/crypto/mode/IMode.java: Likewise.
+ * gnu/javax/crypto/mode/ModeFactory.java: Likewise.
+ * gnu/javax/crypto/mode/OFB.java: Likewise.
+
+2006-07-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/mac/BaseMac.java: Source formatting.
+ * gnu/javax/crypto/mac/HMac.java: Likewise.
+ * gnu/javax/crypto/mac/HMacFactory.java: Likewise.
+ * gnu/javax/crypto/mac/IMac.java: Likewise.
+ * gnu/javax/crypto/mac/MacFactory.java: Likewise.
+ * gnu/javax/crypto/mac/MacInputStream.java: Likewise.
+ * gnu/javax/crypto/mac/MacOutputStream.java: Likewise.
+ * gnu/javax/crypto/mac/OMAC.java: Likewise.
+ * gnu/javax/crypto/mac/TMMH16.java: Likewise.
+ * gnu/javax/crypto/mac/UHash32.java: Likewise.
+ * gnu/javax/crypto/mac/UMac32.java: Likewise.
+
+2006-07-01 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/Track.java (vector, eventSet): Initialize.
+
+2006-07-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/keyring/AuthenticatedEntry.java: Source formatting.
+ * gnu/javax/crypto/keyring/BaseKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/BinaryDataEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/CertificateEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/CertPathEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/CompressedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/EncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/Entry.java: Likewise.
+ * gnu/javax/crypto/keyring/EnvelopeEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPrivateKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPublicKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/IKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/IPrivateKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/IPublicKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/MalformedKeyringException.java: Likewise.
+ * gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/MeteredInputStream.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordProtectedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PrimitiveEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PrivateKeyEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/Properties.java: Likewise.
+ * gnu/javax/crypto/keyring/PublicKeyEntry.java: Likewise.
+
+2006-07-01 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractCellEditor.java: Source code formatting,
+ * javax/swing/AbstractSpinnerModel.java: Likewise,
+ * javax/swing/Box.java: Likewise,
+ * javax/swing/BoxLayout.java: Likewise,
+ * javax/swing/DefaultListModel.java: Likewise,
+ * javax/swing/GrayFilter.java: Likewise,
+ * javax/swing/LookAndFeel.java: Likewise,
+ * javax/swing/ProgressMonitor.java: Likewise,
+ * javax/swing/ProgressMonitorInputStream.java: Likewise,
+ * javax/swing/ScrollPaneLayout.java: Likewise,
+ * javax/swing/SpringLayout.java: Likewise,
+ * javax/swing/event/EventListenerList.java: Likewise,
+ * javax/swing/event/MenuEvent.java: Likewise,
+ * javax/swing/event/TreeExpansionListener.java: Likewise.
+
+2006-07-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS:
+ Mention threading bean and getState().
+ * doc/vmintegration.texinfo:
+ Update documentation for threading bean and new
+ method of VMThread.
+
+2006-07-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * examples/gnu/classpath/examples/management/TestClassLoading.java,
+ * examples/gnu/classpath/examples/management/TestOS.java,
+ * examples/gnu/classpath/examples/management/TestRuntime.java,
+ * examples/gnu/classpath/examples/management/TestThread.java:
+ New files.
+
+2006-07-01 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/ThreadGroup.java
+ (getThreadFromId, getThreadFromIdImpl): New methods.
+
+2006-07-01 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/Thread.java:
+ Make thread IDs start from 1 in a more efficient way.
+
+2006-07-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/Thread.java:
+ Make thread IDs start from 1.
+
+2006-07-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/BeanImpl.java:
+ New superclass for all bean implementations.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java:
+ Extend BeanImpl and call permission code there.
+ * gnu/java/lang/management/OperatingSystemMXBeanImpl.java:
+ Extend BeanImpl.
+ * gnu/java/lang/management/RuntimeMXBeanImpl.java:
+ Extend BeanImpl and call permission code there.
+ * gnu/java/lang/management/ThreadMXBeanImpl.java:
+ New file.
+ * java/lang/management/ManagementFactory.java:
+ (getThreadMXBean()): Implemented.
+ * java/lang/management/ThreadInfo.java:
+ (ThreadInfo(Thread,int)): Replaced...
+ (ThreadInfo(Thread,long,long,Object,Thread,long,long,
+ boolean, boolean, StackTraceElement[])): with this.
+ (getBlockedCount()): Refactored to use local variables.
+ (getBlockedTime()): Likewise.
+ (getLockName()): Likewise.
+ (getLockOwnerId()): Likewise.
+ (getLockOwnerName()): Likewise.
+ (getStackTrace()): Likewise.
+ (getWaitedCount()): Likewise.
+ (getWaitedTime()): Likewise.
+ (isInNative()): Likewise.
+ (isSuspended()): Likewise.
+ (toString()): Changed to use new local variables.
+ * java/lang/management/ThreadMXBean.java:
+ (getThreadInfo(long, int)): Corrected documentation.
+ (getThreadInfo(long[], int)): Likewise.
+ * vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java:
+ New file.
+ * vm/reference/java/lang/management/VMThreadInfo.java:
+ Removed.
+
+2006-07-01 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java: Source formatting.
+ * gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java: Likewise.
+ * gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java: Likewise.
+ * gnu/javax/crypto/key/dh/DiffieHellmanSender.java: Likewise.
+ * gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java: Likewise.
+ * gnu/javax/crypto/key/dh/ElGamalReceiver.java: Likewise.
+ * gnu/javax/crypto/key/dh/ElGamalSender.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHKey.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHPublicKey.java: Likewise.
+ * gnu/javax/crypto/key/dh/RFC2631.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6Host.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6SaslClient.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6SaslServer.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6TLSClient.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6TLSServer.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRP6User.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPAlgorithm.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPKey.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPPrivateKey.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPPublicKey.java: Likewise.
+ * gnu/javax/crypto/key/BaseKeyAgreementParty.java: Likewise.
+ * gnu/javax/crypto/key/GnuSecretKey.java: Likewise.
+ * gnu/javax/crypto/key/IKeyAgreementParty.java: Likewise.
+ * gnu/javax/crypto/key/IncomingMessage.java: Likewise.
+ * gnu/javax/crypto/key/KeyAgreementException.java: Likewise.
+ * gnu/javax/crypto/key/KeyAgreementFactory.java: Likewise.
+ * gnu/javax/crypto/key/OutgoingMessage.java: Likewise.
+
+2006-07-01 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ (transform): Make field protected.
+ (getDestinationRaster): Provide default implementation for
+ previously abstract method.
+
+2006-06-30 Tania Bento <tbento@redhat.com>
+
+ * java/awt/TextArea.java
+ (TextArea(String, int, int, int)): No longer throws
+ IllegalArgumentException if rows, columns, or scrollbarVisibility
+ values are invalid.
+ (TextArea(String, int, int, int)): If rows or columns are < 0,
+ they get set to 0. If scrollbarVisibility is < 0 or > 4, it
+ gets set to the default value of 0 (SCROLLBARS_BOTH).
+ (appendText): Added case when peer = null.
+ (insertText): Added case when peer == null.
+ (replaceText): Added case when peer == null.
+ * java/awt/TextComponent.java
+ (TextComponent(String)): If text == null, set it to "".
+
+2006-06-30 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+ (create): Added synchronized block around groupMap.get calls.
+ (setCheckboxGroup): Likewise.
+
+2006-06-30 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+ (create): Changed to be non-synchronized.
+ (setLabel): Likewise.
+ (setCheckboxGroup): Likewise.
+ (addToGroupMap): Likewise. Added synchronized block around
+ code.
+ (dispose): Changed to be non-synchronized.
+
+2006-06-30 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java:
+ Changed all return values of native functions to void.
+ (create): Changed function to be synchronized. Removed
+ call to put value in groupMap, this is now done from
+ the native code.
+ (setState): Changed function to be synchronized.
+ (setLabel): Changed function to be synchronized.
+ (setCheckboxGroup): Changed function to be synchronized. Removed
+ call to put value in groupMap, this is now done from
+ the native code.
+ (postItemEvent): Changed function to be synchronized.
+ (addToGroupMap): New function. Called by native code to add
+ new value to the group.
+ (dispose): Changed function to be synchronized.
+ * include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h: Updated
+ all functions.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+ (cp_gtk_checkbox_init_jni): Added code to link to
+ java function.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createRadioButton):
+ Changed return value to void. Added call
+ to java function to set pointer in groupMap.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_addtoGroup): Likewise. Also,
+ changed check to an assert. Also, removed call to set/del pointer.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_removeFromGroup):
+ Likewise. Also, added check to determine if native_group should be
+ set to NULL.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_switchToGroup): Likewise.
+
+2006-06-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/ClasspathToolkit.java,
+ * gnu/java/awt/peer/x/XToolkit.java,
+ * gnu/java/awt/peer/qt/QtToolkit.java,
+ * gnu/java/awt/peer/gtk/GtkToolkit.java,
+ Remove ClasspathTextLayoutPeer.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java,
+ * gnu/java/awt/peer/ClasspathTextLayoutPeer:
+ Files removed.
+
+2006-06-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java:
+ (drawGlyphVector): Don't draw empty vectors.
+
+2006-06-30 Lillian Angel <langel@redhat.com>
+ Tom Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java: Removed class.
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java:
+ Added current_group, groupMap fields. Added definitions for
+ new native functions.
+ (create): Removed FIXME. Added code to create the check button or
+ radio button when appropriate. Updated groupMap to contain
+ pointer to the newly created group.
+ (setCheckboxGroup): Added code to handle all cases. Removing
+ a button from a group, adding a button to a group, or changing the
+ group of a button.
+ (dispose): Changed to call super.
+ * include/Makefile.am: Removed reference to
+ gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h.
+ * include/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h: Removed file.
+ * include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h: Added definitions
+ for new functions.
+ * native/jni/gtk-peer/Makefile.am: Removed reference to
+ gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c:
+ Removed file.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_combobox_get_widget):
+ Renamed to checkbox_get_widget.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals):
+ Changed to use checkbox_get_widget.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup):
+ Removed.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont):
+ Changed to use checkbox_get_widget.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel):
+ Likewise.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createCheckButton):
+ New function. Creates checkbutton without a group.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createRadioButton):
+ Creates a radio button in a group, using groupPointer. If groupPointer
+ is 0, then a new group is created.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_addToGroup): Adds the
+ check button to a group, using groupPointer. A radio button is created
+ in its place. If groupPointer is 0, then a new group is created.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_removeFromGroup): The
+ radio button is removed from the group. A check button is created in
+ its place.
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_switchToGroup): The
+ radio button is moved to a new group.
+
+2006-06-30 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac: Move standard.omit creation after dirs are created.
+ Cat standard.omit.in from srcdir. Make exclude regex more explicit.
+ * lib/Makefile.am (EXTRA_DIST): Add standard.omit.in.
+ (clean-local): Remove standard.omit.
+ * lib/gen-classlist.sh.in: Use omit file in build dir.
+ * lib/standard.omit.in: Make exclude regex more explicit.
+
+2006-06-30 Roman Kennke <kennke@aicas.com>
+
+ * lib/Makefile.am: Added Escher dir/jar to classpath when
+ requested.
+ * configure.ac: Moved handling of standard.omit to a place
+ where it actually gets executed.
+
+2006-06-30 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/TextComponent.java: Reformatted source code,
+ * java/awt/TextField.java: Likewise.
+
+2006-06-29 Jeroen Frijters <jeroen@sumatra.nl>
+
+ * java/lang/Thread.java:
+ (getState()): Handle case of no VMThread
+ correctly.
+
+2006-06-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/Thread.java,
+ * java/lang/VMThread.java:
+ Reverted patch from 2006-06-28.
+
+2006-06-29 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/x/GLGraphics.java,
+ * gnu/java/awt/peer/x/ImageConverter.java,
+ * gnu/java/awt/peer/x/KeyboardMapping.java,
+ * gnu/java/awt/peer/x/XEventPump.java,
+ * gnu/java/awt/peer/x/XFontPeer.java,
+ * gnu/java/awt/peer/x/XFontPeer2.java,
+ * gnu/java/awt/peer/x/XFramePeer.java,
+ * gnu/java/awt/peer/x/XGraphics.java,
+ * gnu/java/awt/peer/x/XGraphics2D.java,
+ * gnu/java/awt/peer/x/XGraphicsConfiguration.java,
+ * gnu/java/awt/peer/x/XGraphicsDevice.java,
+ * gnu/java/awt/peer/x/XGraphicsEnvironment.java,
+ * gnu/java/awt/peer/x/XImage.java,
+ * gnu/java/awt/peer/x/XLightweightPeer.java,
+ * gnu/java/awt/peer/x/XToolkit.java,
+ * gnu/java/awt/peer/x/XWindowPeer.java,
+ * gnu/java/awt/peer/x/fonts.properties: New files.
+ * lib/standard.omit: Removed.
+ * lib/standard.omit.in: Added.
+ * configure.ac: Added configure option --with-escher. Added some
+ configury for omitting gnu.java.awt.peer.x package when
+ this option is not specified.
+
+2006-06-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (JComponent()): Initialize the locale here, not the default locale,
+ (getDefaultLocale): If null, return Locale.getDefault(),
+ (setDefaultLocale): Added API docs.
+
+2006-06-29 Tania Bento <tbento@redhat.com>
+
+ * java/awt/Container.java
+ (applyComponentOrientation): Implemented method.
+
+2006-06-29 Gary Benson <gbenson@redhat.com>
+
+ * java/io/File.java (listRoots): Merge security checks from libgcj.
+
+2006-06-29 Gary Benson <gbenson@redhat.com>
+
+ * java/io/FilePermission.java (implies): Work when path is "/".
+
+2006-06-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/Thread.java:
+ (Thread(ThreadGroup,Runnable,String,long)): Update
+ state.
+ (Thread(VMThread,String,int,boolean)): Likewise.
+ (join(long,int)): Likewise.
+ (resume()): Likewise.
+ (sleep(long,int)): Likewise.
+ (start()): Likewise.
+ (stop()): Likewise.
+ (suspend()): Likewise.
+ (die()): Likewise.
+ (getState()): Return either state or use VMThread.
+ * java/lang/VMThread.java:
+ (getState()): Added default implementation to return
+ thread.state
+
+2006-06-28 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java: Swap the data from the
+ GdkPixbuf correctly on big endian systems. Fix a typo in the little
+ endian swapping code.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkImage_getPixels): Swap the pixeldata
+ without alpha information correctly on big endian systems.
+
+2006-06-28 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/net/local/LocalSocket.java
+ (setSoTimeout): Don't throw exception and ignore request.
+ (getSoTimeout): Don't throw exception and always return 0.
+
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (getRegisteredKeyStrokes): Implemented.
+
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (verifyInputWhenFocusTarget): Initialise to true.
+
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/beans/VetoableChangeSupport.java
+ (addVetoableChangeListener(VetoableChangeListener)): Do nothing for
+ null listener,
+ (addVetoableChangeListener(String, VetoableChangeListener)): Do nothing
+ for null property name and/or listener,
+ * javax/swing/JComponent.java
+ (getListeners): Handle VetoableChangeListener.class as a special case,
+ (getVetoableChangeListeners): Fetch these from the
+ vetoableChangeSupport object.
+
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (componentPopupMenu): New field,
+ (inheritsPopupMenu): New field,
+ (getInheritsPopupMenu): Implemented,
+ (setInheritsPopupMenu): Likewise,
+ (getComponentPopupMenu): Likewise,
+ (setComponentPopupMenu): Likewise,
+ * javax/swing/JLabel.java
+ (JLabel(String, Icon, int)): Set inheritsPopupMenu to true.
+
+2006-06-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/key/dh/GnuDHPublicKey.java (str): New field.
+ (toString): New method.
+ * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java (str): New field.
+ (toString): New method.
+ * gnu/javax/crypto/key/dh/GnuDHKey.java (str): New field.
+ (toString): New method.
+ * gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java (encodePrivateKey):
+ Handle case when Q is null.
+ (decodePrivateKey): Likewise.
+ * gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java (encodePublicKey):
+ Likewise.
+ (decodePublicKey): Likewise.
+ * gnu/javax/crypto/jce/GnuCrypto.java (run): Added AlgorithmParameters
+ aliases for all block ciphers.
+ * gnu/javax/crypto/jce/DiffieHellmanImpl.java (result): Changed to byte[].
+ (engineDoPhase): Compute fully the shared secret.
+ (checkState): New method.
+ (reset): Likewise.
+ (engineGenerateSecret()): Reset key-agreement before returning.
+ (engineGenerateSecret(byte[],int)): Check for short-buffer.
+ Reset key-agreement before returning.
+ (engineGenerateSecret(String)): Reset key-agreement before returning.
+ (engineInit(Key,SecureRandom)): Call reset() before returning.
+ * gnu/javax/crypto/jce/params/BlockCipherParameters.java (log): New field.
+ (engineInit): Replace printing to System.out with conditional logging.
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java (engineInitHandler):
+ When the key-size is not specified, attempt best effort to find a suitable
+ value among those advertised by the cipher before setting it to the length
+ of provided key material.
+
+2006-06-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/table/DefaultTableColumnModel.java
+ (changeEvent): Don't initialize yet, removed FIXME,
+ (fireColumnModelChanged): Initialize changeEvent if necessary.
+
+2006-06-27 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/Thread.java:
+ (getAllStackTraces()): Implemented.
+ (getStackTrace()): Likewise.
+
+2006-06-27 Tania Bento <tbento@redhat.com>
+
+ * java/awt/Component.java
+ (setComponentOrientation): NPE should not be thrown.
+
+2006-06-27 Tom Tromey <tromey@redhat.com>
+
+ * configure.ac: Create gjar, gnative2ascii, gserialver.
+ * tools/gappletviewer.in: Quote $@.
+ * tools/gkeytool.in: Likewise.
+ * tools/gjarsigner.in: Likewise.
+ * tools/gjar.in: New file.
+ * tools/gnative2ascii.in: Likewise.
+ * tools/gserialver.in: Likewise.
+ * tools/Makefile.am (bin_PROGRAMS): Added gjar, gnative2ascii,
+ gserialver.
+ (bin_SCRIPTS): Likewise.
+
+2006-06-27 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/ThreadMXBean.java:
+ (getThreadInfo(long[])): Corrected return type.
+ (getThreadInfo(long[], int)): Likewise.
+
+2006-06-27 Mark Wielaard <mark@klomp.org>
+
+ * java/awt/datatransfer/Clipboard.java (addFlavorListener): Do
+ nothing when listener is null.
+ (removeFlavorListener): Likewise.
+
+ * java/awt/datatransfer/DataFlavor.java
+ (getRepresentationClassFromMime): Renamed to
+ getRepresentationClassFromMimeThrows.
+ (isRepresentationClassInputStream): Use Class.isAssignableFrom().
+ (isRepresentationClassSerializable): Likewise.
+ (isFlavorJavaFileListType): Likewise and check primary and
+ subtype.
+ (getParameter): Parameters are separated by semi-colons.
+ (DataFlavor(Class,String,String)): Do some sanity checks.
+ (DataFlavor(String,String,ClassLoader)): Call
+ getRepresentationClassFromMimeThrows.
+ (DataFlavor(String)): Likewise.
+ (equals(DataFlavor)): Special case primary type text and charset
+ parameter.
+
+2006-06-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Component.java
+ (setName): Fire required PropertyChangeEvent,
+ * java/awt/Label.java
+ (getText): Removed redundant brackets,
+ (generateName): New method (override),
+ (nextLabelNumber): New field,
+ (getUniqueLong): New method.
+
+2006-06-27 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/swing/SwingComponentPeer.java
+ (createImage): Delegate this to the parent.
+ (handleEvent): Only handle PAINT/UPDATE events when the
+ component is actually showing.
+ (hide): Repaint the parent after hiding a component.
+ (prepareImage): Have only one return point.
+ (setVisible): Delegate to show() and hide().
+ (createVolatileImage): Added null check to avoid NPE.
+
+2006-06-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Label.java: Reformatted source code.
+
+2006-06-27 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/image/BufferedImage.java
+ (getSource): Use a fixed DirectColorModel to deliver the
+ RGB pixels to the ImageConsumer.
+
+2006-06-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Point.java
+ (setLocation(double, double)): Round to nearest integer coordinates.
+
+2006-06-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Component.java
+ (minSizeSet): New field,
+ (maxSize): Likewise,
+ (maxSizeSet): Likewise,
+ (isMaximumSizeSet): Implemented,
+ (isMinimumSizeSet): Likewise,
+ (isPreferredSizeSet): Likewise,
+ (setMaximumSize): Likewise,
+ (setMinimumSize): Likewise,
+ (setPreferredSize): Likewise.
+
+2006-06-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/imageio/spi/IIORegistry.java
+ (IIORegistry): Added BMP codec.
+
+2006-06-27 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/JComponent.java
+ (firePropertyChange(String,char,char)): New override method.
+
+2006-06-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/Thread.java:
+ (getState()): New method.
+ * java/lang/management/ClassLoadingMXBean.java:
+ Corrected class documentation.
+ * java/lang/management/ManagementFactory.java:
+ Added new temporary marked stub to get thread bean.
+ * java/lang/management/OperatingSystemMXBean.java:
+ Corrected class documentation.
+ * java/lang/management/RuntimeMXBean.java:
+ Corrected class documentation.
+ * java/lang/management/ThreadInfo.java,
+ * java/lang/management/ThreadMXBean.java:
+ New classes.
+ * vm/reference/java/lang/VMThread.java:
+ (getState()): New method.
+ * vm/reference/java/lang/management/VMThreadInfo.java:
+ New VM class.
+
+2006-06-26 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/imageio/gif/GIFFile.java
+ * gnu/javax/imageio/gif/GIFImageReader.java
+ * gnu/javax/imageio/gif/GIFImageSpi.java
+ * gnu/javax/imageio/gif/GIFStream.java
+ New files.
+ * javax/imageio/spi/IIORegistry.java: Load new GIF decoder plugin.
+
+2006-06-26 Tania Bento <tbento@redhat.com>
+
+ * java/awt/List.java
+ (List): A list should have at least 4 visible rows.
+ (replaceItem): Should throw an ArrayIndexOutOfBoundsException,
+ not an IllegalArgumentException.
+ (makeVisible): Should not throw an IllegalArgumentException if
+ the specified index is out of range.
+
+2006-06-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JList.java
+ (getNextMatch): Reimplemented to perform a circular search for the
+ matching item.
+
+2006-06-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JList.java
+ (init): Set default value for visibleRowCount to 8,
+ (setVisibleRowCount): Fire PropertyChangeEvent when value changes.
+
+2006-06-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JList.java
+ (valueIsAdjusting): Removed,
+ (init): Removed initialization of valueIsAdjusting field,
+ (getValueIsAdjusting): Fetch value from selection model,
+ (setValueIsAdjusting): Store value in selection model.
+
+2006-06-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicListUI.java
+ (installKeyboardActions): Rewritten to fit with the
+ ActionMap/InputMap architecture.
+ (uninstallKeyboardActions): Implemented.
+ (ListAction): Made private. Added TODO for splitting
+ up this bulk Action.
+ (ListAction.ListAction): New constructor. This one
+ takes a cmd parameter to be installed as actionCommand.
+
+2006-06-26 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/key/rsa/RSAKeyPairRawCodec.java: Remove RCS Revision.
+ * gnu/javax/crypto/assembly/DeflateTransformer.java: Likewise.
+
+2006-06-26 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java: Source formatting.
+ * gnu/javax/crypto/jce/GnuSasl.java: Likewise.
+ * gnu/javax/crypto/jce/GnuCrypto.java: Likewise.
+ * gnu/javax/crypto/jce/DiffieHellmanImpl.java: Likewise.
+ * gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java: Likewise.
+ * gnu/javax/crypto/jce/spec/TMMHParameterSpec.java: Likewise.
+ * gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java: Likewise.
+ * gnu/javax/crypto/jce/sig/DHKeyFactory.java: Likewise.
+ * gnu/javax/crypto/jce/prng/UMacRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/ICMRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/FortunaImpl.java: Likewise.
+ * gnu/javax/crypto/jce/prng/CSPRNGSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/params/DERWriter.java: Likewise.
+ * gnu/javax/crypto/jce/params/DERReader.java: Likewise.
+ * gnu/javax/crypto/jce/params/DEREncodingException.java: Likewise.
+ * gnu/javax/crypto/jce/params/BlockCipherParameters.java: Likewise.
+ * gnu/javax/crypto/jce/mac/UMac32Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/UHash32Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/TMMH16Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacTwofishImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacSquareImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacSerpentImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacKhazadImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacDESImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacCast5Impl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacAnubisImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/MacAdapter.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacTigerSpi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacSHA512Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacSHA384Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacSHA256Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacSHA160Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacMD5Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacMD4Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacMD2Spi.java: Likewise.
+ * gnu/javax/crypto/jce/mac/HMacHavalSpi.java: Likewise.
+ * gnu/javax/crypto/jce/keyring/GnuKeyring.java: Likewise.
+ * gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/TwofishSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/TripleDESSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/SquareSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/SerpentSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/RijndaelSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/PBES2.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/NullCipherSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/KhazadSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/DESSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/Cast5Spi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/BlowfishSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/ARCFourSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/AnubisSpi.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/AESSpi.java: Likewise.
+
+2006-06-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JList.java
+ (setLayoutOrientation): Check for valid argument.
+
+2006-06-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (firePropertyChange(String,int,int)): New method. Overrides
+ Component method and makes it public.
+ (firePropertyChange(String,boolean,boolean)): Likewise.
+
+2006-06-25 Vivek Lakshmanan <vivekl@redhat.com>
+
+ * gnu/java/security/.cvsignore: New File.
+ * gnu/java/security/Configuration.java.in: New File.
+ * gnu/java/security/Properties.java: Change import from
+ gnu.classpath.Configuration to gnu.java.security.Configuration.
+ * gnu/java/security/hash/Whirlpool.java: Likewise.
+ * gnu/java/security/jce/sig/EncodedKeyFactory.java: Likewise.
+ * gnu/java/security/jce/sig/SignatureAdapter.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/dss/DSSPrivateKey.java: Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairX509Codec.java: Likewise.
+ * gnu/java/security/pkcs/PKCS7SignedData.java: Likewise.
+ * gnu/java/security/pkcs/SignerInfo.java: Likewise.
+ * gnu/java/security/provider/PKIXCertPathValidatorImpl.java: Likewise.
+ * gnu/java/security/sig/rsa/EMSA_PSS.java: Likewise.
+ * gnu/java/security/sig/rsa/RSAPSSSignature.java: Likewise.
+ * gnu/java/security/util/Base64.java: Likewise.
+ * gnu/java/security/x509/X509CRL.java: Likewise.
+ * gnu/java/security/x509/X509CRLEntry.java: Likewise.
+ * gnu/java/security/x509/ext/Extension.java: Likewise.
+ * gnu/javax/crypto/cipher/Anubis.java: Likewise.
+ * gnu/javax/crypto/cipher/BaseCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/Khazad.java: Likewise.
+ * gnu/javax/crypto/cipher/Rijndael.java: Likewise.
+ * gnu/javax/crypto/cipher/Twofish.java: Likewise.
+ * gnu/javax/crypto/jce/keyring/GnuKeyring.java: Likewise.
+ * gnu/javax/crypto/jce/prng/ICMRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/UMacRandomSpi.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/keyring/Entry.java: Likewise.
+ * gnu/javax/crypto/keyring/EnvelopeEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPrivateKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPublicKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/mac/OMAC.java: Likewise.
+ * gnu/javax/crypto/pad/BasePad.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS1_V1_5.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS7.java: Likewise.
+ * gnu/javax/crypto/pad/TBC.java: Likewise.
+ * gnu/javax/crypto/prng/CSPRNG.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslInputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslOutputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPClient.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPServer.java: Likewise.
+ * gnu/javax/security/auth/login/ConfigFileParser.java: Likewise.
+ * gnu/javax/security/auth/login/ConfigFileTokenizer.java: Likewise.
+ * gnu/javax/security/auth/login/GnuConfiguration.java
+ (getAppConfigurationEntry): Change reference to
+ gnu.classpath.Configuration.DEBUG to gnu.java.security.Configuration.DEBUG.
+ (getConfigFromUserHome): Likewise.
+ (getInputStreamFromURL): Likewise.
+ (getUserHome): Likewise.
+ (init): Likewise.
+ (processSecurityProperties): Likewise.
+ (processSystemProperty): Likewise.
+ (processUserHome): Likewise.
+ * configure.ac: Add gnu/java/security/Configuration.java to AC_CONFIG_FILES list.
+ * lib/Makefile.am: Remove gnu/java/security/Configuration.java when required.
+
+
+2006-06-25 Carsten Neumann <cn-develop@gmx.net>
+
+ * javax/swing/text/DefaultCaret.java (isActive): New method.
+
+2006-06-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java,
+ * java/lang/management/ClassLoadingMXBean.java:
+ (getTotalLoadedClassCount()): Corrected return type.
+ (getUnloadedClassCount()): Likewise.
+ * vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java:
+ (getUnloadedClassCount()): Likewise.
+
+2006-06-25 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/cipher/WeakKeyException.java: Source formatting.
+ * gnu/javax/crypto/cipher/Twofish.java: Likewise.
+ * gnu/javax/crypto/cipher/TripleDES.java: Likewise.
+ * gnu/javax/crypto/cipher/Square.java: Likewise.
+ * gnu/javax/crypto/cipher/Serpent.java: Likewise.
+ * gnu/javax/crypto/cipher/Rijndael.java: Likewise.
+ * gnu/javax/crypto/cipher/NullCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/Khazad.java: Likewise.
+ * gnu/javax/crypto/cipher/IBlockCipherSpi.java: Likewise.
+ * gnu/javax/crypto/cipher/IBlockCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/DES.java: Likewise.
+ * gnu/javax/crypto/cipher/CipherFactory.java: Likewise.
+ * gnu/javax/crypto/cipher/Cast5.java: Likewise.
+ * gnu/javax/crypto/cipher/Blowfish.java: Likewise.
+ * gnu/javax/crypto/cipher/BaseCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/Anubis.java: Likewise.
+
+2006-06-25 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/assembly/TransformerException.java: Source formatting.
+ * gnu/javax/crypto/assembly/Transformer.java: Likewise.
+ * gnu/javax/crypto/assembly/Stage.java: Likewise.
+ * gnu/javax/crypto/assembly/PaddingTransformer.java: Likewise.
+ * gnu/javax/crypto/assembly/Operation.java: Likewise.
+ * gnu/javax/crypto/assembly/ModeStage.java: Likewise.
+ * gnu/javax/crypto/assembly/LoopbackTransformer.java: Likewise.
+ * gnu/javax/crypto/assembly/Direction.java: Likewise.
+ * gnu/javax/crypto/assembly/DeflateTransformer.java: Likewise.
+ * gnu/javax/crypto/assembly/CascadeTransformer.java: Likewise.
+ * gnu/javax/crypto/assembly/CascadeStage.java: Likewise.
+ * gnu/javax/crypto/assembly/Cascade.java: Likewise.
+ * gnu/javax/crypto/assembly/Assembly.java: Likewise.
+
+2006-06-24 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS,
+ * doc/vmintegration.texinfo:
+ Updated with information on new VM interface.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java,
+ * java/lang/management/ClassLoadingMXBean.java:
+ New files implementing the class loading bean.
+ * java/lang/management/ManagementFactory.java:
+ (getClassLoadingMXBean()): Implemented.
+ * vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java:
+ New VM interface file.
+
+2006-06-24 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/RuntimeMXBeanImpl.java:
+ (isBootClassPathSupported()): Use SystemProperties
+ rather than System.getProperty.
+
+2006-06-24 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/Properties.java: Source formatting.
+ * gnu/java/security/Registry.java: Likewise.
+
+2006-06-24 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/util/Util.java: Source formatting.
+ * gnu/java/security/util/SimpleList.java: Likewise.
+ * gnu/java/security/util/Sequence.java: Likewise.
+ * gnu/java/security/util/PRNG.java: Likewise.
+ * gnu/java/security/util/ExpirableObject.java: Likewise.
+ * gnu/java/security/util/Base64.java: Likewise.
+ * gnu/java/security/sig/SignatureFactory.java: Likewise.
+ * gnu/java/security/sig/ISignatureCodec.java: Likewise.
+ * gnu/java/security/sig/ISignature.java: Likewise.
+ * gnu/java/security/sig/BaseSignature.java: Likewise.
+ * gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java: Likewise.
+ * gnu/java/security/sig/rsa/RSAPSSSignature.java: Likewise.
+ * gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java: Likewise.
+ * gnu/java/security/sig/rsa/RSA.java: Likewise.
+ * gnu/java/security/sig/rsa/EMSA_PSS.java: Likewise.
+ * gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java: Likewise.
+ * gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java: Likewise.
+ * gnu/java/security/sig/dss/DSSSignatureRawCodec.java: Likewise.
+ * gnu/java/security/sig/dss/DSSSignature.java: Likewise.
+ * gnu/java/security/provider/X509CertificateFactory.java: Likewise.
+ * gnu/java/security/provider/PKIXCertPathValidatorImpl.java: Likewise.
+ * gnu/java/security/provider/Gnu.java: Likewise.
+ * gnu/java/security/prng/RandomEventListener.java: Likewise.
+ * gnu/java/security/prng/RandomEvent.java: Likewise.
+ * gnu/java/security/prng/PRNGFactory.java: Likewise.
+ * gnu/java/security/prng/MDGenerator.java: Likewise.
+ * gnu/java/security/prng/LimitReachedException.java: Likewise.
+ * gnu/java/security/prng/IRandom.java: Likewise.
+ * gnu/java/security/prng/EntropySource.java: Likewise.
+ * gnu/java/security/prng/BasePRNG.java: Likewise.
+
+2006-06-23 Francis Kung <fkung@redhat.com>
+
+ * examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java
+ (Harness.actionPerformed): Process additional options.
+ (J2dBenchmarkWrapper): Defer init call until after options are processed.
+ (J2dBenchmarkWrapper.setAlias): New method.
+ (J2dBenchmarkWrapper.setComposite): New method.
+ (J2dBenchmarkWrapper.setFill): New method.
+ (J2dBenchmarkWrapper.setRotation): New method.
+ (J2dBenchmarkWrapper.setShear): New method.
+ (J2dBenchmarkWrapper.setStroke): New method.
+ (J2dBenchmarkWrapper.setTranslation): New method.
+ (run): Add additional options to GUI.
+ * examples/gnu/classpath/examples/java2d/J2dBenchmark.java:
+ Added protected fields for various options.
+ (GraphicsTest.runSet_noClipping): Reset graphics settings between tests.
+ (GraphicsTest.runSet_withClipping): Reset graphics settings between tests.
+ (GraphicsTest.runSet_zeroClipping): Reset graphics settings between tests.
+ (getNextColor): Renamed to setRandom.
+ (init): Load additional image for texturing if needed.
+ (loadBufferedImage): New method.
+ (main): Accept additional command-line switches.
+ (prepareGraphics): New method.
+ (resetGraphics): New method.
+ (runTestSuite): Accept additional image-processing options.
+ (setRandom): Renamed from getNextColor; generate various random options
+ (test_drawArc): Rename getNextColor to setRandom.
+ (test_drawCubic): Likewise.
+ (test_drawEllipse): Likewise.
+ (test_drawGeneralPath): Likewise.
+ (test_drawImage): Likewise.
+ (test_drawLine): Likewise.
+ (test_drawQuadCurve): Likewise.
+ (test_drawRectangle): Likewise.
+ (test_drawRoundRectangle): Likewise.
+ (test_drawTransparentImage): Likewise.
+ (test_fillArc): Rename getNextColor to setRandom.
+ (test_fillEllipse): Likewise.
+ (test_fillGeneralPath): Likewise.
+ (test_fillRectangle): Likewise.
+ (test_fillRoundRectangle): Likewise.
+ (TestRecorder.getAverage): Round the average time.
+
+2006-06-23 Tom Tromey <tromey@redhat.com>
+
+ * java/util/logging/LoggingMXBean.java: New file.
+ * java/util/logging/LogManager.java (LOGGING_MXBEAN_NAME): New field.
+ (loggingBean): New field.
+ (getLoggingMXBean): New method.
+
+2006-06-23 Tania Bento <tbento@redhat.com>
+
+ * java/awt/TextField.java
+ (TextField): Default number of columns should be 0, not 1.
+ (TextField): Check if number of columns given as argument
+ is valid (>= 0) and set the number of columns accordingly.
+ (TextField): Check if the string passed is null. If it is,
+ set columns to 0, else columns is set to the length of
+ the string.
+
+2006-06-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (InternalFramePropertyChangeListener.propertyChange):
+ Don't call getPropertyName() repeatedly. Added null checks
+ to avoid NPEs. Call closeFrame() if the closed property
+ changes.
+
+2006-06-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JInternalFrame.java
+ (maxTransition): Removed.
+ (JInternalFrame): Set maxium=false. Initialize desktopIcon here.
+ Don't initialize storedBounds here.
+ (dipose): Rewritten to correctly dispose the JInternalFrame.
+ (getDesktopIcon): Don't initialize desktopIcon here.
+ (getLayer): Delegate to JLayeredPane.getLayer().
+ (getNormalBounds): Return bounds when storedBounds == null,
+ otherwise storedBounds.
+ (hide): Don't change selection. Also hide the desktopIcon.
+ (moveToBack): Call getParent() only once.
+ (moveToFront): Call getParent() only once.
+ (pack): Call validate() to make sure that the layout is
+ propagated to the children.
+ (setClosed): Fire InternalFrameEvent first, before the
+ PropertyVetoEvent.
+ (setJMenuBar): Fire PropertyChangeEvent for this property.
+ (setLayer): Delegate to JLayeredPane.
+ (setLayeredPane): Check for null and throw IllegalArgumenException.
+ (setMaximum): Remove handling of maxTransition and normalBounds.
+ Should probably be done in the UI.
+ (setNormalBounds): Store Rectangle object directly, not a copy.
+ (setRootPane): Go into rootPaneCheckingEnabled mode so that
+ adding the RootPane doesn't add it to the contentPane.
+ Fire PropertyChangeEvent.
+ (setSelected): Added condition for when this property must not
+ be changed.
+ (show): Don't ask the DesktopPane to select the frame. Moved
+ code around to fire InternalFrameEvent before actually calling
+ super.show(). Also make the desktopIcon visible.
+ (setTitle): Fire PropertyChangeEvent unconditionally.
+
+2006-06-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLayeredPane.java
+ (getPosition): Moved code around to avoid unnecessary method calls.
+ (setPosition): Delegate to setLayer().
+ (insertIndexForLayer(int,int)): Delegate to new private helper method.
+ (insertIndexForLayer(Component,int,int)): New helper method
+ to support the use of setComponentZOrder() which doesn't remove
+ the component and thus the insertIndexForLayer must ignore
+ the component to be moved to get the index right.
+ (setLayer): Added check to prevent unnecessary execution of
+ method body. Changed to update the component order here.
+ Added repaint() to make sure that the update becomes visible.
+ (addImpl): Call setLayer() only when a constraint has been specified.
+ Validate and repaint the JLayeredPane.
+
+2006-06-23 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Container.java
+ (getComponentZOrder): Use ncomponents instead of
+ component.length so that we don't consider the empty space
+ after the last component.
+
+2006-06-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (vetoableChangeSupport): New field.
+ (removeVetoableChangeListener): Rewritten to use
+ vetoableChangeSupport.
+ (addVetoableChangeListener): Rewritten to use
+ vetoableChangeSupport.
+ (fireVetoableChange): Rewritten to use
+ vetoableChangeSupport.
+ (addPropertyChangeListener): Removed. This is handled in
+ Component already.
+ (firePropertyChange(String,boolean,boolean)): Likewise.
+ (firePropertyChange(String,char,char)): Likewise.
+ (firePropertyChange(String,int,int)): Likewise.
+ (revalidate): Don't do anything when the commponent has no
+ parent.
+
+2006-06-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java: Updated API docs.
+
+2006-06-22 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/Insets.java: Updated copyright year.
+ (toString): Changed string, removed a line from the
+ documentation.
+
+2006-06-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/AbstractDocument.java
+ (AbstractDocument): Set the i18n document property.
+ (removeImpl): Added checks for correct boundaries.
+
+2006-06-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/PlainDocument.java
+ (rootElement): Changed type to Element.
+ (tabSize): Removed field. This is stored in the document properties
+ instead.
+ (PlainDocument): Set tabSize property. Init rootElement without
+ cast.
+ (insertUpdate): Rewritten. The previous implementation did not
+ handle some corner cases properly and was a mess.
+ (removeUpdate): Cast rootElement to BranchElement.
+
+2006-06-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicLabelUI.java
+ (installKeyboardActions): Implemented,
+ (uninstallKeyboardActions): Implemented,
+ (propertyChange): Add handling for 'displayedMnemonic' and 'labelFor'
+ properties.
+
+2006-06-22 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/JMenu.java:
+ (removeAll): Added check for popupMenu not being null.
+
+2006-06-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (getText): Updated API docs,
+ (setText): Corrected the check for an unchanged value, and the update
+ of the displayedMnemonicIndex.
+
+2006-06-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (setDisplayedMnemonic(int)): Fire property change event AFTER updating
+ field,
+ (setDisplayedMnemonicIndex): Modified argument checking to handle case
+ where label text is null.
+
+2006-06-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (setDisplayedMnemonic): Updated API docs,
+ (getDisplayedMnemonic): Removed unnecessary type-cast,
+ (setDisplayedMnemonicIndex): Removed unnecessary validation,
+ (getDisplayedMnemonicIndex): Updated API docs.
+
+2006-06-21 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultListSelectionModel.java
+ (getSelectionMode): Updated API docs,
+ (setAnchorSelectionIndex): Added ListSelectionEvent generation,
+ (addSelectionInterval): If mode is SINGLE_SELECTION, just call
+ setSelectionInterval(),
+ (setSelectionInterval): Reimplemented SINGLE_SELECTION and
+ SINGLE_INTERVAL_SELECTION cases.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/AbstractDocument.java
+ (BranchElement.numChildren): New field.
+ (BranchElement.BranchElement): Initialize children array with
+ one element (that's the least number of elements that makes sense).
+ Initialize numChildren.
+ (BranchElement.children): Use numChildren as boundary.
+ (BranchElement.getElement): Use numChildren as boundary.
+ (BranchElement.getElementCount): Use numChildren as boundary.
+ (BranchElement.getElementIndex): Use numChildren as boundary.
+ (BranchElement.getEndOffset): Use numChildren as boundary.
+ (BranchElement.getStartOffset): Use numChildren as boundary.
+ (BranchElement.positionToElement): Use numChildren as boundary.
+ (BranchElement.replace): Handle the children array more efficiently
+ by growing in blocks > 1, and reusing space from removed elements.
+ (LeafElement.startDelta): Removed.
+ (LeafElement.endDelta): Removed.
+ (LeafElement.LeafElement): Removed handling of deltas.
+ (LeafElement.getEndOffset): Likewise.
+ (LeafElement.getStartOffset): Likewise.
+ * javax/swing/text/JTextComponent.java
+ (setDocument): Added locking of the old document to avoid dangling
+ notification beeing delivered while the document is beeing
+ disconnected.
+ (getScrollableTracksViewportWidth): Fixed condition.
+ * javax/swing/text/PlainDocument.java
+ (createDefaultRoot): Create elements without AttributeSet.
+ * javax/swing/text/rtf/RTFParser.java
+ (parseFile): Handle slightly incorrect RTF gracefully.
+ * javax/swing/text/rtf/RTFScanner.java
+ (lastToken): New field.
+ (readTokenImpl): New method.
+ (peekToken): New method.
+ (readToken): Changed to call readTokenImpl or return the lastToken
+ if there's one present.
+
+2006-06-21 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JMenu.java
+ (remove): An IllegalArgumentException should be thrown if
+ either index < 0 or if index > 0 and there are no menu
+ components. Also, a check was added that ensures there are
+ menu components before removing the desired the component.
+
+2006-06-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/text/DefaultCaret.java
+ (install): Added check to prevent NPE.
+ (propertyChange): Added checks to prevent NPEs.
+
+2006-06-21 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JMenu.java
+ Changed instantiation of popupMenu to null.
+ (JMenu): Instantiated popupMenu to new JPopupMenu.
+ (JMenu): Instantiated popupMenu to new JPopupMenu.
+ (add): Changed popupMenu to getPopupMenu().
+ (add): Changed popupMenu to getPopupMenu().
+ (add): Changed popupMenu to getPopupMenu().
+ (add): Changed popupMenu to getPopupMenu().
+ (remove): Changed popupMenu to getPopupMenu().
+ (remove): Changed popupMenu to getPopupMenu().
+ (insert): Changed popupMenu to getPopupMenu().
+ (setSelectedHelper): Changed popupMenu to getPopupMenu().
+ (isPopupMenuVisible): Changed popupMenu to getPopupMenu().
+ (setPopupMenuVisible): Changed popupMenu to getPopupMenu().
+ (getMenuComponentCount): Changed popupMenu to getPopupMenu().
+ (getMenuComponents): Changed popupMenu to getPopupMenu().
+ (getPopupMenu): Check first if popupMenu is null and if so,
+ instantiate it to a new JPopupMenu and set the invoker.
+ * javax/swing/plaf/basic/BasicPopupMenuUI.java
+ (popupMenuWillBecomeVisible): Component Listener should only
+ be added to the root container if the root container is not
+ null. This avoids a null pointer exception.
+
+2006-06-21 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JMenu.java
+ (JMenu): Delay should be set to 200, not default of 0.
+ (JMenu): Delay should be set to 200, not default of 0.
+ (JMenu): Delay should be set to 200, not default of 0.
+ (JMenu): Delay should be set to 200, not default of 0.
+ (remove): Added check that index >= 0 before removing
+ the component.
+ (getItem): Return null if item count equals 0.
+ (isTearOff): Should throw new error and not return false.
+ (getMenuComponent): Return null if popupMenu is null or
+ if there are no menu components.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/font/FontRenderContext.java:
+ (equals): Added special conditions for affineTransform beeing
+ null.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/UIManager.java
+ (MultiplexUIDefaults.clear): Removed method. The fallback UIDefaults
+ must not be cleared.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalUtils.java
+ (paintHorizontalGradient): Use paintHorizontalGradient2D when
+ Graphics2D is available. Use fillRect instead of drawLine, this
+ is much faster.
+ (paintVerticalGradient): Use paintHorizontalGradient2D when
+ Graphics2D is available. Use fillRect instead of drawLine, this
+ is much faster.
+ (paintHorizontalGradient2D): New method. Paints gradient
+ using Graphics2D functions.
+ (paintVerticalGradient2D): New method. Paints gradient
+ using Graphics2D functions.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonListener.java
+ (propertyChange): Create a TextLayout and store it in the button
+ when the 'text' property changes.
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (paintText): Call BasicGraphicsUtils utility method for
+ drawing strings, instead of Graphics.drawString().
+ * javax/swing/plaf/basic/BasicGraphicsUtils.java
+ (CACHE_TEXT_LAYOUT): New constant field. Used as a key for storing
+ cached text layouts as client properties in JComponents.
+ (drawString(JComponent,Graphics,String,int,int)): New helper method.
+ (drawStringUnderlineCharAt): New helper method.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (PropertyChangeHandler.propertyChange): Update cached text layout
+ when 'text' property changes. Use equals() instead of == for
+ string comparison.
+ (paintText): Use new BasicGraphicsUtils methods for painting
+ the cached text layout.
+ (installListeners): Call super.installListeners() and remove
+ the unneeded listener installs.
+ (uninstallListeners): Call super.uninstallListeners() and remove
+ the unneeded listener uninstalls.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (PropertyChangeHandler.propertyChange): Handle document listener
+ update here.
+ (background): Removed unneeded fields.
+ (inactiveBackground): Remove unneeded fields.
+ (installUI): Install the document listener. Slightly changed
+ order of operations. Don't trigger modelChanged().
+ (installDefaults): Only install properties when the
+ current properties are null or instances of UIResource.
+ (installListeners): Removed unnecessary listener installs.
+ (installDocumentListeners): Removed unneeded method.
+ (uninstallListeners): Removed unnecessary listener uninstalls.
+ (modelChanged): Removed call to installDocumentListeners().
+ * javax/swing/plaf/basic/BasicTextFieldUI.java
+ (propertyChange): Update the colors by fetching them from
+ SharedUIDefaults. Fixed conditions.
+ * javax/swing/plaf/basic/SharedUIDefaults.java
+ (getColor): New method.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeSequence.java
+ (SizeSequence): Initialize array with correct number of entries.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JSplitPane.java
+ (setDividerLocation): Substract divider size when computing
+ the absolute size.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildrenWithOverlap): Determine opaque property by
+ calling the corresponding Component method, without requiring
+ a JComponent.
+ (paintChildrenOptimized): Removed old unneeded code.
+ (paintImmediately): Use JComponent's convertRectangleToAncestor()
+ method instead of SwingUtilities.convertRectangle(). This is
+ more efficient.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ (init): Call setText() instead of setting the property directly,
+ so that listeners (especially in the UI) get notified.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/UIManager.java
+ (MultiplexUIDefaults): New inner class.
+ (currentUIDefaults): Changed type to be MultiplexUIDefaults.
+ (userUIDefaults): Changed name to be lookAndFeelDefaults.
+ (<cinit>): Call setLookAndFeel(String) instead of trying to load
+ directly. Print stacktrace if something goes wrong.
+ (get): Delegate call to currentUIDefaults.
+ (getDefaults): If currentUIDefaults is null, then lazily instantiate
+ it.
+ (getUI): Delegate call to currentUIDefaults.
+ (put): Delegate call to currentUIDefaults.
+ (setLookAndFeel): Initialize currentUIDefaults with
+ MultiplexUIDefaults. Set lookAndFeelDefaults.
+ (setLookAndFeel): Use current thread's context classloader for
+ loading the L&F.
+
+2006-06-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/GapContent.java
+ (GapContentPosition.GapContentPosition): Replace
+ Collections.binarySearch with call to local search() to make
+ sure we find the first object that equals the searched object.
+ (setPositionsInRange): Likewise.
+ (adjustPositionsInRange): Likewise.
+ (search): New helper method.
+
+2006-06-21 Gary Benson <gbenson@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Add security check.
+ * gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
+ * gnu/java/awt/java2d/AbstractGraphics2D.java: Likewise.
+
+2006-06-20 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/plugin/Makefile.am (libgcjwebplugin_la_CXXFLAGS): Define
+ APPLETVIEWER_EXECUTABLE to gappletviewer.
+
+2006-06-20 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/28095:
+ * java/net/URL.java (URL): Throw MalformedURLException if a
+ RuntimeException is caught. Chain exceptions.
+
+2006-06-20 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+ (create): Added check to prevent Seg Fault. Should not
+ set the label if it is null.
+ * gnu/java/awt/peer/gtk/GtkLabelPeer.java
+ (setText): Changed to be a non-native function. Calls
+ setNativeText if the String parameter is non-null.
+ (setNativeText): Replaces old native setText function.
+ * include/gnu_java_awt_peer_gtk_GtkLabelPeer.h: Regenerated.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText): Removed.
+ Replaced by Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeText.
+ (Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeText): Replaced
+ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText.
+
+2006-06-20 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/text/JTextComponent.java
+ (AccessibleJTextComponent): Rewrote all javadocs
+ for this inner class.
+
+2006-06-20 Francis Kung <fkung@redhat.com>
+
+ * examples/gnu/classpath/examples/java2d/J2dBenchmark.java:
+ Changed many members to be protected.
+ (J2dBenchmark): moved to init() instead.
+ (init): New method.
+ (main): Call init() after creating object
+ (testComplete): New method.
+ (test_drawArc): Use maxTests varialbe instead of constant.
+ (test_drawCubicCurve): Likewise.
+ (test_drawEllipse): Likewise.
+ (test_drawGeneralPath): Likewise.
+ (test_drawImage): Likewise.
+ (test_drawLine): Likewise.
+ (test_drawQuadCurve): Likewise.
+ (test_drawRectangle): Likewise.
+ (test_drawRoundRectangle): Likewise.
+ (test_drawTransparentImage): Likewise.
+ (test_fillArc): Likewise.
+ (test_fillEllipse): Likewise.
+ (test_fillGeneralPath): Likewise.
+ (test_fillRectangle): Likewise.
+ (test_fillRoundRectangle): Likewise.
+ (GraphicsTest.runSetNoClipping): Added runCount parameter.
+ (GraphicsTest.runSetWithClipping): Likewise.
+ (GraphicsTest.runSetZeroClipping): Likewise.
+ (GraphicsTest.run): Added checks for more option flags.
+ * examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java:
+ New file.
+
+2006-06-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/GapContent.java
+ (GapContentPosition.mark): New field.
+ (GapContentPosition.index): Removed.
+ (GapContentPosition.GapContentPosition): Changed to take the
+ real offset as parameter. Added handling of reference counter.
+ Try to cleanup before creating new instances.
+ (getOffset): Delegate to the Mark method with same name.
+ (Mark): New class, encapsulating a mark.
+ (positionMarks): Removed field.
+ (numMarks): Removed field.
+ (marks): New field.
+ (queueOfDeath): New field.
+ (GapContent): Removed init of old fields, added init of new fields.
+ (createPosition): Added check for validity of arguments.
+ Create GapContentPosition directly with offset.
+ (shiftEnd): Pass end of buffer directly to adjustPositionsInRange.
+ (shiftGap): Pass end of buffer directly to adjustPositionsInRange.
+ (shiftGapStartDown): Call resetMarksAtZero().
+ (shiftGapEndUp): Call resetMarksAtZero().
+ (replace): Don't call resetMarksAtZero().
+ (setPositionInRange): Replaced by simpler algorithm, similar to
+ adjustPositionsInRange.
+ (adjustPositionsInRange): Adapted to use of Mark objects.
+ (resetMarksAtZero): Reset all marks that point to zero instead
+ of only the first one.
+ (dumpMarks): Adjusted to dump Mark objects.
+ (insertMark): Removed.
+ (garbageCollect): New method. Cleans up the marks list.
+ (binarySearch): Removed.
+
+2006-06-20 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Added call to updateColor because
+ Cairo seems to lose the current color.
+
+2006-06-20 Gary Benson <gbenson@redhat.com>
+
+ * java/awt/Toolkit.java: Add security check.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java: Likewise.
+ * gnu/java/awt/peer/qt/QtToolkit.java: Likewise.
+
+2006-06-20 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/key/dss/DSSKey.java: Source formatting.
+ * gnu/java/security/key/dss/DSSKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairRawCodec.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairX509Codec.java: Likewise.
+ * gnu/java/security/key/dss/DSSPrivateKey.java: Likewise.
+ * gnu/java/security/key/dss/DSSPublicKey.java: Likewise.
+ * gnu/java/security/key/dss/FIPS186.java: Likewise.
+ * gnu/java/security/key/rsa/GnuRSAKey.java: Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPublicKey.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairRawCodec.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairX509Codec.java: Likewise.
+ * gnu/java/security/key/IKeyPairCodec.java: Likewise.
+ * gnu/java/security/key/IKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/KeyPairCodecFactory.java: Likewise.
+ * gnu/java/security/key/KeyPairGeneratorFactory.java: Likewise.
+
+2006-06-19 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Should always use getRGB to get the pixels.
+ getData returns an incorrect array of pixels.
+
+2006-06-19 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/jce/hash/HavalSpi.java: Source formatting.
+ * gnu/java/security/jce/hash/MD2Spi.java: Likewise.
+ * gnu/java/security/jce/hash/MD4Spi.java: Likewise.
+ * gnu/java/security/jce/hash/MD5Spi.java: Likewise.
+ * gnu/java/security/jce/hash/MessageDigestAdapter.java: Likewise.
+ * gnu/java/security/jce/hash/RipeMD128Spi.java: Likewise.
+ * gnu/java/security/jce/hash/RipeMD160Spi.java: Likewise.
+ * gnu/java/security/jce/hash/Sha160Spi.java: Likewise.
+ * gnu/java/security/jce/hash/Sha256Spi.java: Likewise.
+ * gnu/java/security/jce/hash/Sha384Spi.java: Likewise.
+ * gnu/java/security/jce/hash/Sha512Spi.java: Likewise.
+ * gnu/java/security/jce/hash/TigerSpi.java: Likewise.
+ * gnu/java/security/jce/hash/WhirlpoolSpi.java: Likewise.
+ * gnu/java/security/jce/prng/HavalRandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/MD2RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/MD4RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/MD5RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/RipeMD128RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/RipeMD160RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/SecureRandomAdapter.java: Likewise.
+ * gnu/java/security/jce/prng/Sha160RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/Sha256RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/Sha384RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/Sha512RandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/TigerRandomSpi.java: Likewise.
+ * gnu/java/security/jce/prng/WhirlpoolRandomSpi.java: Likewise.
+ * gnu/java/security/jce/sig/DSSKeyFactory.java: Likewise.
+ * gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java: Likewise.
+ * gnu/java/security/jce/sig/DSSParameters.java: Likewise.
+ * gnu/java/security/jce/sig/DSSRawSignatureSpi.java: Likewise.
+ * gnu/java/security/jce/sig/EncodedKeyFactory.java: Likewise.
+ * gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java: Likewise.
+ * gnu/java/security/jce/sig/RSAKeyFactory.java: Likewise.
+ * gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java: Likewise.
+ * gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java: Likewise.
+ * gnu/java/security/jce/sig/SignatureAdapter.java: Likewise.
+
+2006-06-19 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * NEWS: Updated (delayed) for security tools and tools.texinfo.
+
+2006-06-19 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (drawImage): Clip volatile image correctly.
+ (drawVolatileImage): Added arguments for clipping.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (drawVolatileImage): Added arguments for clipping. Clip image
+ correctly.
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h: Regenerated.
+
+2006-06-19 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28035
+ * java/rmi/server/UID.java (constructor): Synchronized
+ the whole constructor on the UID class.
+
+2006-06-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/RepaintManager.java
+ (addInvalidComponent): Only add component that are displayable,
+ that have displayable parents and that have a validateRoot.
+ Also, don't validate components that have a CellRendererPane
+ ancestor.
+
+2006-06-19 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/IconUIResource.java
+ (IconUIResource): Throw IllegalArgumentException for null icon.
+
+2006-06-18 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 28035
+ * java/rmi/server/UID.java (constructor): First increment
+ uidCounter, and then use the value.
+
+2006-06-18 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * java/awt/GridBagLayout.java (AdjustForGravity): Implement.
+ * java/awt/GridBagConstraints.java: Indent.
+
+2006-06-18 Tom Tromey <tromey@redhat.com>
+
+ * native/jni/gconf-peer/.cvsignore: New file.
+
+2006-06-18 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/Parser.java (handleLongOption):
+ Also handle short options.
+
+2006-06-18 Jim Huang <jserv@kaffe.org>
+
+ PR classpath/28076:
+ * native/jni/gconf-peer/Makefile.am (libgconfpeer_la_LIBADD):
+ Fixed typo.
+
+2006-06-19 Mark Wielaard <mark@klomp.org>
+
+ * include/Makefile.am: gnu_java_util_prefs_gconf_%.h should depend
+ on gnu/java/util/prefs/gconf/%.class.
+ * Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class: Fix
+ chache typo, should be cache.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys):
+ Declare tmp early.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes):
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir):
+ Don't return a value for void function.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir)
+ Likewise.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists):
+ Mark clazz as unused. Return JNI_FALSE, not NULL for jboolean
+ function.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class):
+ Mark clazz ad unused.
+
+2006-06-18 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/hash/Whirlpool.java: Source formatting.
+ * gnu/java/security/hash/Tiger.java: Likewise.
+ * gnu/java/security/hash/Sha512.java: Likewise.
+ * gnu/java/security/hash/Sha384.java: Likewise.
+ * gnu/java/security/hash/Sha256.java: Likewise.
+ * gnu/java/security/hash/Sha160.java: Likewise.
+ * gnu/java/security/hash/RipeMD160.java: Likewise.
+ * gnu/java/security/hash/RipeMD128.java: Likewise.
+ * gnu/java/security/hash/MD5.java: Likewise.
+ * gnu/java/security/hash/MD4.java: Likewise.
+ * gnu/java/security/hash/MD2.java: Likewise.
+ * gnu/java/security/hash/IMessageDigest.java: Likewise.
+ * gnu/java/security/hash/Haval.java: Likewise.
+ * gnu/java/security/hash/HashFactory.java: Likewise.
+ * gnu/java/security/hash/BaseHash.java: Likewise.
+
+2006-06-18 Sven de Marothy <sven@physto.se>
+
+ * java/awt/event/KeyEvent.java:
+ (VK_WINDOWS, VK_CONTEXT_MENU, VK_BEGIN): Add new keysym fields.
+ * natve/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c:
+ Implement WINDOWS, ALT_GR and CONTEXT_MENU keysyms.
+
+2006-06-18 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/util/Prime2.java: Removed.
+ * gnu/java/security/key/dss/FIPS186.java: Remove unused imports.
+ (generateParameters): Use isProbablePrime() in BigInteger instead of Prime2.
+ * gnu/java/security/key/rsa/RSAKeyPairGenerator.java: Remove unused imports.
+ (generate): Use isProbablePrime() in BigInteger instead of Prime2.
+ * gnu/javax/crypto/key/dh/RFC2631.java: Remove unused imports.
+ (generateParameters): Use isProbablePrime() in BigInteger instead of Prime2.
+ * gnu/javax/crypto/key/srp6/SRPAlgorithm.java: Remove unused imports.
+ (checkParams): Use isProbablePrime() in BigInteger instead of Prime2.
+ * gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java: Remove unused imports.
+ (generateParameters): Use isProbablePrime() in BigInteger instead of Prime2.
+ * gnu/javax/net/ssl/provider/KeyPool.java: Remove unused imports.
+ (generateRSAKeyPair): Use isProbablePrime() in BigInteger instead of Prime2.
+
+2006-06-18 Sven de Marothy <sven@physto.se>
+
+ * java/awt/GridBagLayout.java (AdjustForGravity): Implement.
+ * java/awt/font/TextMeasurer.java: Fix copyright date,
+ remove commented-out code.
+
+2006-06-18 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (FreetypeGlyphVector, clone): Implement cloning.
+ (getGlyphLogicalBounds): Bounds should be offset to the glyph position.
+ * java/awt/font/TextMeasurer.java: Implement.
+ * java/awt/font/LineBreakMeasurer.java:
+ Reimplement to use TextMeasurer.
+ * java/awt/font/TextLayout.java
+ New constructors.
+ (getBlackboxBounds, getLogicalHighlightShape): Reimplement.
+ (getText, getFont): New private static methods.
+ (setCharIndices): New method.
+ * java/text/AttributedString.java
+ (AttributedString): Fix constructor to stop at end point.
+
+2006-06-12 Mario torre <neugens at limasoftware.net>
+
+ * gnu/java/util/prefs/GConfBasedPreferences.java: new class.
+ * gnu/java/util/prefs/GConfBasedFactory.java: new class.
+ * gnu/java/util/prefs/gconf/GConfNativePeer.java: new class.
+ * gnu_java_util_prefs_gconf_GConfNativePeer.h: generated
+ header file.
+ * classpath/native/jni/gconf-peer/GConfNativePeer.c: new C file.
+ * configure.ac: update to introduce new files. Added options
+ to build gconf native peer used by the GConf preference backend.
+ * include/Makefile.am: update to introduce new files.
+ * native/jni/Makefile.am update to introduce new files.
+ * scripts/check_jni_methods.sh: added three new ignored file
+ from check.
+ * native/jni/gconf-peer/Makefile.am: new Makefile needed to
+ build gconf-peer shared library.
+
+2006-06-17 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java:
+ Use Integer.valueOf() instead of new Integer().
+ * gnu/java/security/jce/sig/EncodedKeyFactory.java: Likewise.
+ * gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java: Likewise.
+ * gnu/java/security/util/Sequence.java: Likewise.
+ * gnu/java/security/x509/ext/GeneralNames.java: Likewise.
+ * gnu/java/security/x509/X509Certificate.java: Likewise.
+ * gnu/javax/crypto/assembly/ModeStage.java: Likewise.
+ * gnu/javax/crypto/cipher/Anubis.java: Likewise.
+ * gnu/javax/crypto/cipher/Blowfish.java: Likewise.
+ * gnu/javax/crypto/cipher/Cast5.java: Likewise.
+ * gnu/javax/crypto/cipher/DES.java: Likewise.
+ * gnu/javax/crypto/cipher/Khazad.java: Likewise.
+ * gnu/javax/crypto/cipher/NullCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/Rijndael.java: Likewise.
+ * gnu/javax/crypto/cipher/Serpent.java: Likewise.
+ * gnu/javax/crypto/cipher/Square.java: Likewise.
+ * gnu/javax/crypto/cipher/TripleDES.java: Likewise.
+ * gnu/javax/crypto/cipher/Twofish.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java: Likewise.
+ * gnu/javax/crypto/jce/cipher/PBES2.java: Likewise.
+ * gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java: Likewise.
+ * gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java: Likewise.
+ * gnu/javax/crypto/jce/prng/ICMRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/UMacRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java: Likewise.
+ * gnu/javax/crypto/keyring/AuthenticatedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/EncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordProtectedEntry.java: Likewise.
+ * gnu/javax/crypto/mac/UHash32.java: Likewise.
+ * gnu/javax/crypto/mac/UMac32.java: Likewise.
+ * gnu/javax/crypto/mode/BaseMode.java: Likewise.
+ * gnu/javax/crypto/mode/EAX.java: Likewise.
+ * gnu/javax/crypto/prng/ICMGenerator.java: Likewise.
+ * gnu/javax/crypto/prng/UMacGenerator.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/KDF.java: Likewise.
+ * gnu/javax/security/auth/callback/ConsoleCallbackHandler.java: Likewise.
+ * java/security/cert/X509CertSelector.java: Likewise.
+
+2006-06-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/DynamicMBean.java:
+ (setAttribute): Fixed to return void.
+ * javax/management/MBeanFeatureInfo.java:
+ New file.
+
+2006-06-17 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ On behalf of Vivek Lakshmanan <vivekl@redhat.com>
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java
+ (engineInit(int, Key, SecureRandom)): Seperate common initialization logic
+ into engineInitHandler and reuse the code in
+ engineInit(int, Key, AlgorithmSpec, SecureRandom).
+ (engineInitHandler): New method.
+ (engineInit(int, Key, AlgorithmParameterSpec, SecureRandom)): When param is
+ null, use random or default information when possible.
+
+2006-06-16 Francis Kung <fkung@redhat.com>
+
+ * examples/gnu/classpath/examples/swing/Demo.java:
+ (mkButtonBar): Rename FillRect to JNIOverhead.
+ (mkMenuBar): Rename FillRect to JNIOverhead.
+ * examples/gnu/classpath/examples/swing/FillRect.java: Removed.
+ * examples/gnu/classpath/examples/java2d/J2dBenchmark.java: New file.
+ * examples/gnu/classpath/examples/java2d/JNIOverhead.java:
+ Moved from old FillRect.
+
+2006-06-16 Tom Tromey <tromey@redhat.com>
+
+ * tools/.cvsignore: Added new tool names.
+
+2006-06-16 Tom Tromey <tromey@redhat.com>
+
+ * vm/reference/sun/reflect/misc/ReflectUtil.java: Moved...
+ * vm/reference/sun/misc/ReflectUtil.java: ...from here.
+
+2006-06-16 Keith Seitz <keiths@redhat.com>
+
+ * gnu/classpath/jdwp/event/EventManager.java (getDefault): Redo
+ instantiation so that EventManager is created when getDefault
+ is first called.
+ * gnu/classpath/jdwp/Jdwp.java (Thread): Force creation
+ of EventManager.
+
+2006-06-16 Keith Seitz <keiths@redhat.com>
+
+ * gnu/classpath/jdwp/Jdwp.java (_initLock): New field.
+ (_initCount): New field.
+ (Jdwp): Don't set isDebugging until fully initialized.
+ (subcomponentInitialized): New method.
+ (run): Wait for PacketProcessor and JdwpConnection to
+ startup, then set isDebugging, and then let this thread
+ die.
+ * gnu/classpath/jdwp/transport/JdwpConnection.java
+ (run): Add synchronization notification.
+ * gnu/classpath/jdwp/processor/PacketProcessor.java
+ (run): Likewise.
+
+2006-06-16 Tom Tromey <tromey@redhat.com>
+
+ * NEWS: Updated for JSR 166.
+ * vm/reference/sun/reflect/Reflection.java (verifyMemberAccess):
+ Removed.
+ (getCallerClass): Now static.
+ * vm/reference/sun/reflect/misc/ReflectUtil.java: New file.
+
+2006-06-16 Kyle Galloway <kgallowa@redhat.com>
+
+ * gnu/classpath/jdwp/event/ExceptionEvent:
+ Added Object instance to javadoc in constructor
+ * gnu/classpath/jdwp/event/MethodEntryEvent:
+ Ditto.
+ * gnu/classpath/jdwp/event/MethodExitEvent:
+ Ditto,
+ * gnu/classpath/jdwp/event/SingleStepEvent:
+ Ditto.
+
+2006-06-16 Tom Tromey <tromey@redhat.com>
+
+ * external/jsr166: Removed files from cvs trunk.
+
+2006-06-16 Lillian Angel <langel@redhat.com>
+
+ * java/awt/FileDialog.java
+ (FileDialog): Added @since tag to API docs.
+ (FileDialog): Likewise.
+ (FileDialog): Likewise.
+ * java/awt/Font.java:
+ Added @since tag to TYPE1_FONT field docs.
+ * javax/swing/plaf/basic/BasicScrollBarUI.java:
+ (isThumbRollover): Likewise.
+ (setThumbRollover): Likewise.
+ (getSupportsAbsolutePositioning): Likewise.
+ * javax/swing/plaf/basic/BasicSliderUI.java:
+ (isDragging): Likewise.
+
+2006-06-16 Lillian Angel <langel@redhat.com>
+
+ * java/awt/FileDialog.java
+ (FileDialog): Implemented.
+ (FileDialog): Implemented.
+ (FileDialog): Implemented.
+ * java/awt/Font.java:
+ Added TYPE1_FONT constant field.
+
+2006-06-16 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/TextLayout.java:
+ Removed unneeded imports.
+ * javax/swing/plaf/basic/BasicScrollBarUI.java:
+ Added new thumbRollover field.
+ (mouseMoved): Added code to set thumbRollover field.
+ (isThumbRollover): New function.
+ (setThumbRollover): New function.
+ (getSupportsAbsolutePositioning): Implemented. This
+ needs to be changed once the feature has been
+ implemented.
+ * javax/swing/plaf/basic/BasicSliderUI.java:
+ Added new dragging field.
+ (mouseDragged): Initialized dragging field.
+ (isDragging): New function.
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (focusGained): Marked as not implemented.
+ (focusLost): Likewise.
+
+2006-06-16 Kyle Galloway <kgallowa@redhat.com>
+
+ * gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java:
+ Added check for null ThreadId to avoid null pointer
+ exception.
+
+2006-06-16 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultComboBoxModel.java
+ (removeElementAt): Set new selected item by calling setSelectedItem().
+
+2006-06-16 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultButtonModel.java
+ (setSelected): Use 'this', not null, for the item in the ItemEvent.
+
+2006-06-16 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/event/ListDataEvent.java: updated API docs, plus
+ (ListDataEvent): Handle case where index0 > index1,
+ (toString): Implemented.
+
+2006-06-16 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/metal/MetalMenuBarUI.java:
+ (update): Added subexpression to if-statement.
+
+2006-06-16 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java:
+ (installDefaults): Removed unneccessary code.
+ (paint): Removed complex if-cascade, revert to default icon if
+ icon property is not set.
+ (getPreferredSize): New method.
+
+2006-06-16 Roman Kennke <kennke@aicas.com>
+
+ PR 28027
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Don't use setClip() but instead clipRect() to
+ intersect the current clip with a new one.
+
+2006-06-15 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac: Rename appletviewer to gappletviewer, jarsigner to
+ gjarsigner and keytool to gkeytool.
+ * doc/tools.texinfo: Add note about tool exectable names.
+ * tools/Makefile.am: Rename appletviewer to gappletviewer,
+ jarsigner to gjarsigner and keytool to gkeytool.
+ * tools/appletviewer.in: Rename ...
+ * tools/gappletviewer.in: New file.
+ * tools/jarsigner.in: Rename ...
+ * tools/gjarsigner.in: New file.
+ * tools/keytool.in: Rename ...
+ * tools/gkeytool.in: New file.
+ * tools/toolwrapper.c: Simplify TOOLS_ZIP macro.
+
+2006-06-15 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/AttributeList.java:
+ Add serialization UID.
+ * javax/management/DynamicMBean.java:
+ New file.
+ * javax/management/JMRuntimeException.java:
+ Add serialization UID and correct name
+ of serialized field.
+ * javax/management/MBeanInfo.java: New file.
+
+2006-06-15 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/AttributeList.java,
+ * javax/management/JMRuntimeException.java,
+ * javax/management/RuntimeOperationsException.java:
+ New files.
+
+2006-06-15 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/TextLayout.java:
+ DEFAULT_CARET_POLICY changed to be public static final.
+
+2006-06-15 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/plaf/metal/MetalScrollButton.java
+ (MetalScrollButton): Should set 'focusable' to false.
+
+2006-06-15 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java
+ (BasicArrowButton): Should set 'focusable' to false.
+ (BasicArrowButton): Should set 'focusable' to false.
+
+2006-06-15 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (getGraphicsConfiguration): Return default screen device.
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java (component):
+ New field.
+ (GtkVolatileImage): Record initiating component.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (getDeviceConfiguration): Return configuration of image component.
+
+2006-06-15 Mark Wielaard <mark@klomp.org>
+
+ * java/awt/geom/GeneralPath.java (closePath): Return if path already
+ closed.
+
+2006-06-15 Mark Wielaard <mark@klomp.org>
+
+ * java/awt/BasicStroke.java (createStrokedShape): Call getPathIterator
+ with null argument.
+
+2006-06-15 Kyle Galloway <kgallowa@redhat.com>
+
+ * gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
+ (matches): Added explicit brackets to return statement.
+
+2006-06-15 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JRadioButtonMenuItem.java
+ (JRadioButtonMenuItem): Should set 'focusable' to false.
+
+2006-06-15 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JCheckBoxMenuItem.java
+ (JCheckBoxMenuItem): Should set 'focusable' to false.
+
+2006-06-15 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/AbstractButton.java:
+ (AbstractButton): 'Focusable' should be set to true and not false.
+
+2006-06-15 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/ManagementFactory.java:
+ Add private constructor to prevent instance creation.
+ * java/lang/management/ManagementPermission.java:
+ Make final.
+
+2006-06-15 Francis Kung <fkung@redhat.com>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java:
+ (BasicArrowButton): move client property for not triggering out
+ of consturctor
+ * javax/swing/plaf/basic/BasicComboBoxUI.java:
+ (configureArrowButton): set client property for not triggering
+ (installUI): set client property for not triggering
+ * javax/swing/plaf/basic/BasicLookAndFeel.java:
+ (PopupHelper.mousePressed): check client property for triggering
+
+2006-06-15 Roman Kennke <kennke@aicas.com>
+
+ PR 28037
+ * javax/swing/RepaintManager.java
+ (blitBuffer): Substract coordinates the other way around.
+
+2006-06-15 Roman Kennke <kennke@aicas.com>
+
+ PR 28027
+ * javax/swing/JComponent.java
+ (paintImmediately2): Only paint component without double buffering
+ when all of it's parents have also double buffering disabled.
+ (isPaintingDoubleBuffered): New helper method.
+
+2006-06-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (draw(Shape)): Pass null transform to getPathIterator(),
+ (getClip): Likewise,
+ * gnu/java/print/PostscriptGraphics2D.java
+ (drawStringShape): Pass null transform to getPathIterator(),
+ (writeShape): Likewise,
+ * java/awt/Shape.java: Small updates to API docs.
+
+2006-06-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (getAccessibleChildrenCount): Implemented.
+ (getAccessibleChild): Implemented.
+ (isNavigationKey): Implemented.
+ (KeyHandler.keyPressed): Implemented.
+
+2006-06-14 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/ManagementPermission.java:
+ Added serialization UID.
+ * javax/management/Attribute.java: Likewise.
+ * javax/management/MBeanException.java,
+ * javax/management/ReflectionException.java:
+ Added serialization UID and changed to extend
+ javax.management.JMException.
+
+2006-06-14 Lillian Angel <langel@redhat.com>
+
+ * java/awt/Component.java
+ (ignoreOldMouseEvents): Made static.
+ (translateEvent): Made static.
+ * java/awt/TextComponent.java
+ (ignoreOldMouseEvents): Made static.
+
+2006-06-14 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java (drawLine): Lock and
+ call super.
+ (drawRect): Likewise.
+ (fillRect): Likewise.
+
+2006-06-14 Lillian Angel <langel@redhat.com>
+
+ * java/awt/Component.java
+ (ignoreOldMouseEvents): New helper function.
+ (translateEvent): Changed to be non-static and use new helper.
+ * java/awt/TextComponent.java
+ (ignoreOldMouseEvents): New helper function.
+
+2006-06-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/RepaintManager.java
+ (MERGE_REGIONS): New constant flag.
+ (commitBuffer): Exclude the merging of regions by default. This
+ was causing painting artifacts in some applications, especially
+ when different areas of the GUI are updated synchronously.
+
+2006-06-14 Roman Kennke <kennke@aicas.com>
+
+ * examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java:
+ New file. This is a benchmark for AWT 1.1 style graphics operations.
+ * examples/gnu/classpath/examples/awt/palme.gif: New file.
+ * examples/gnu/classpath/examples/awt/aicas.gif: New file.
+
+2006-06-14 Tom Tromey <tromey@redhat.com>
+
+ * java/io/File.java (getParent): Javadoc fix.
+
+2006-06-14 Tom Tromey <tromey@redhat.com>
+
+ * gnu/java/net/loader/JarURLLoader.java (initialize): Skip our own
+ jar.
+ * gnu/java/net/IndexListParser.java (IndexListParser): Call clearAll
+ when index entry does not exist.
+
+2006-06-14 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Set focusable to false, not true.
+
+2006-06-14 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JMenuItem.java
+ (init): Changed horizontalAlignment from JButton.LEFT to JButton.LEADING.
+
+2006-06-14 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JCheckBoxMenuItem.java
+ (JCheckBoxMenuItem): Added check to set the selected state.
+
+2006-06-14 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (cairoDrawLine): New native method.
+ (cairoDrawRect): New native method.
+ (cairoFillRect): New native method.
+ (drawLine): Use special native method.
+ (drawRect): Use special native method.
+ (fillRect): Use special native method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (cairoDrawLine): New native method.
+ (cairoDrawRect): New native method.
+ (cairoFillRect): New native method.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Regenerated.
+
+2006-06-14 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkImage_getPixels): Return when array
+ cannot be allocated.
+
+2006-06-14 Tom Tromey <tromey@redhat.com>
+
+ PR java/28024:
+ * m4/acinclude.m4 (REGEN_WITH_JAY): Use backquote, not $(...).
+ * configure.ac (QT_INCLUDE_DIR): Use backquote, not $(...).
+
+2006-06-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (isRepainting): New flag.
+ (paintImmediately2): Set isRepainting flag.
+ (getRoot): Removed obsolete method.
+ (paintDoubleBuffered): Differenciate between paint calls from
+ RepaintManager and from AWT refresh. Call
+ RepaintManager.commitBuffer with this and local coordinates.
+ (findOpaqueParent): Stop searching at heavyweight component. These
+ are always opaque.
+ (paintChildrenOptimized): Don't paint heavyweight children. These
+ should care for themselves.
+ (paintChildrenWithOverlap): Don't paint heavyweight children. These
+ should care for themselves.
+ * javax/swing/RepaintManager.java
+ (getOffscreenBuffer): Associate offscreen buffer with toplevel
+ windows only.
+ (getVolatileOffscreenBuffer): Associate offscreen buffer with
+ toplevel windows only.
+ (getRoot): Removed obsolete method.
+ (commitBuffer): Blit buffer on nearest heavyweight.
+ (blitBuffer): New helper method.
+ (getHeavyweightParent): New helper method.
+ (commitRemainingBuffers): Call blitBuffer instead of commitBuffer.
+ * javax/swing/SwingUtilities.java
+ (convertRectangleToAncestor): New helper method.
+
+2006-06-14 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/security/auth/login/ConfigFileTokenizer.java: Fixed a typo.
+ Condition all trace/debug code based on Configuration.DEBUG.
+ Use logger instead of STDOUT and ot STDERR.
+
+2006-06-13 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc
+ (NP_Initialize): Removed code to create whitelist file.
+ (GCJ_New): Added code to create whitelist file.
+ (plugin_user_trusts_documentbase): Fixed error message.
+
+2006-06-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (HorizontalSliderThumbIcon.gradientMask): Modified by 1 pixel to
+ prevent overwriting border,
+ (VerticalSliderThumbIcon.gradientMask): Likewise.
+
+2006-06-13 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/AttributeNotFoundException.java,
+ * javax/management/InvalidAttributeValueException.java,
+ * javax/management/JMException.java,
+ * javax/management/MBeanException.java,
+ * javax/management/OperationsException.java,
+ * javax/management/ReflectionException.java:
+ New files.
+
+2006-06-13 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (dispatchEvent): Handle events even when consumed (this might be
+ picked up later in the dispatching chain).
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (PopupHelper.mousePressed): Don't consume event. Only close popup
+ when target component isn't flagged as DONT_CANCEL_POPUP.
+ (DONT_CANCEL_POPUP): New package private constant for flagging
+ special components that don't trigger popup closing.
+ * javax/swing/plaf/basic/BasicArrowButton.java
+ (BasicArrowButton): Set client property for not triggering closing
+ of popups.
+
+2006-06-13 Lillian Angel <langel@redhat.com>
+
+ * java/awt/image/PixelGrabber.java
+ (PixelGrabber): Added to API documentation.
+
+2006-06-13 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
+ (ExceptionOnlyFilter): Allow null refId.
+
+ * gnu/classpath/jdwp/event/BreakpointEvent.java: Added _instance for
+ compatibility with filters.
+ (getParameter): Modified to allow access to above.
+
+2006-06-13 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (create): Use stride in ints.
+
+2006-06-13 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/ClassUnloadEvent.java: New file.
+
+2006-06-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (calculateThumbSize): Removed unnecessary code,
+ (calculateThumbLocation): Shift position by one,
+ (calculateTickRect): Shift position by one when ticks are displayed,
+ (calculateLabelRect): Calculate rect differently according to whether
+ or not the labels are visible,
+ (paintTrack): Shift track down one pixel.
+
+2006-06-13 Lillian Angel <langel@redhat.com>
+
+ * java/awt/image/PixelGrabber.java
+ (PixelGrabber): Removed check to throw exception. JDK does
+ not do this.
+ (startGrabbing): Removed line to print stacktrace.
+
+2006-06-13 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java (drawImage): Don't
+ allocate unused AffineTransform. Add comment about conversion to
+ BufferedImage.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java (drawImage):
+ Recognize identity transform as "easy". Always convert to
+ BufferedImage before calling super.
+
+2006-06-13 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (getGraphics): Translate child graphics correctly.
+ (dispatchEvent): Only dispatch event if it hasn't been consumed
+ yet by the global dispatcher.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ Added some API docs.
+ (PopupHelper.mousePressed): Consume the event after closing
+ opened menus.
+
+2006-06-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicCheckBoxUI.java: Source code formatting
+ changes only,
+ * javax/swing/plaf/basic/BasicComboBoxUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicComboPopup.java: Likewise,
+ * javax/swing/plaf/basic/BasicFileChooserUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise,
+ * javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicScrollBarUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicSliderUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTableUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTextUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicToolBarUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTreeUI.java: Likewise.
+
+2006-06-12 Sven de Marothy <sven@physto.se>
+
+ * java/awt/font/LineBreakMeasurer.java): Implement.
+
+2006-06-12 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/SingleStepEvent.java: New file.
+
+2006-06-12 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/MethodEntryEvent.java: New file.
+
+ * gnu/classpath/jdwp/event/MethodExitEvent.java: New file.
+
+2006-06-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintDoubleBuffered): Correctly translate and clip the Graphics
+ instance.
+ (clipAndTranslateGraphics): New helper method.
+
+2006-06-12 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (copy): Use getClip() to copy the clip. Make copied transform
+ null when original transform is null. Set clip here.
+ (setTransform): Correctly update the clip.
+ (setTransformImpl): New method. Updates the actual transform for
+ Cairo.
+ (transform): Correctly update the clip.
+ (translate): Correctly update the clip.
+ (clip): Handle null clip and argument correctly.
+ (clipRect): Avoid creating new Rectangle objects.
+ (getClip): Get the correct copy of the clip.
+ (setClip): Correctly handle null argument.
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ (CairoSurfaceGraphics): Don't set the clip here. The clip can either
+ be null or whatever has been set in copy().
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (drawImage): Add translation to the image coordinates.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (VolatileImageGraphics): Don't set clip here. The clip can either
+ be null or whatever has been set in copy().
+
+2006-06-12 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
+ (forCaught): Removed unused/unnecessary method.
+ (forUncaught): Likewise.
+ (matches): Implement.
+
+2006-06-12 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/ExceptionEvent.java: New file.
+
+2006-06-12 Keith Seitz <keiths@redhat.com>
+
+ From Kyle Galloway <kgallowa@redhat.com>:
+ * gnu/classpath/jdwp/event/Event.java: Added constants for
+ type.
+ (getParameter): Changed parameter type from Class to int.
+ * gnu/classpath/jdwp/event/BreakpointEvent.java (getParameter):
+ Changed from Class type to constants.
+ * gnu/classpath/jdwp/event/ClassPrepareEventEvent.java (getParameter):
+ Likewise.
+ * gnu/classpath/jdwp/event/ThreadEndEvent.java (getParameter):
+ Likewise.
+ * gnu/classpath/jdwp/event/ThreadStartEvent.java (getParameter):
+ Likewise.
+ * gnu/classpath/jdwp/event/VmDeathEvent.java (getParameter):
+ Likewise.
+ * gnu/classpath/jdwp/event/VmInitEvent.java (getParameter):
+ Likewise.
+ * gnu/classpath/jdwp/event/ClassMatchFilter.java (matches):
+ Likewise.
+ * gnu/classpath/jdwp/event/ClassOnlyFilter.java (matches):
+ Likewise.
+ * gnu/classpath/jdwp/event/InstanceOnlyFilter.java (matches):
+ Likewise.
+ * gnu/classpath/jdwp/event/ThreadOnlyFilter.java (matches):
+ Likewise.
+
+2006-06-12 Lillian Angel <langel@redhat.com>
+
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
+ (StandaloneAppletWindow): Changed title of standalone window.
+
+2006-06-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (layoutContainer): Added missing selectedComponent assignment.
+
+2006-06-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (layoutContainer): Added check to prevent exception.
+
+2006-06-12 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/Thread.java (uncaughtException): Javadoc fix.
+
+2006-06-12 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java (hasLock):
+ New static field.
+ (ONE): Likewise.
+ (lock): New method.
+ (unlock): Likewise.
+ (draw): Use lock() and unlock().
+ (fill): Likewise.
+ (drawRenderedImage): Likewise.
+ (drawImage): Likewise.
+ (drawGlyphVector): Likewise.
+
+2006-06-12 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawPixels): Include alpha in parameter list.
+ (cairoFill): Include alpha in parameter list.
+ (setComposite): Don't modify the color.
+ (draw(Shape))): Use fill when the current composite has an alpha
+ of != 1.0, so that the stroked shaped will be composited.
+ (fill(Shape)): Call cairoFill() with alpha.
+ (drawImage): Call drawPixels or drawSurface with alpha.
+ (drawGlyphVector): When composite alpha is != 1.0, render the
+ outline using fill() to enable compositing for text.
+ (drawRaster): Call drawPixels with alpha.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (nativeDrawSurface): Include alpha in parameter list.
+ (drawSurface): Include alpha in parameter list. Pass it to
+ nativeDrawSurface().
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h:
+ Regenerated.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (drawPixels): Handle possible alpha for compositing.
+ (cairoFill): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (nativeDrawSurface): Handle possible alpha for compositing.
+
+2006-06-12 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java (streamImage):
+ Notify data when completely done. Wait for worker thread to finish.
+ Rethrow any pending exceptions.
+ (exception): New field.
+ (run): Store pending exception.
+
+2006-06-12 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/ManagementPermission.java:
+ New file.
+
+2006-06-12 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * doc/tools.texinfo: Replaced original author with "The GNU Classpath Team".
+
+2006-06-12 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/security/auth/login/ConfigFileParser.java (validateClassName):
+ Use String.charAt().
+
+2006-06-11 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * doc/tools.texinfo
+ (Applet Tools): New chapter.
+ (appletviewer Tool): New section.
+ (gcjwebplugin): New section.
+
+2006-06-11 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java (streamImage):
+ Takes GdkPixbufWriter.
+ (GdkPixbufWriter): Implements Runnable.
+ (write(IIOMetadata,IIOImage,ImageWriteParam)): Start Thread for
+ data processing.
+ (DATADONE): New static final field.
+ (data): New field.
+ (write(byte[])): New method.
+ (run): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
+ (Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initStaticState):
+ Get dataOutputWriteID from writeClass.
+ (stream_save_request): Change stream field to writer.
+ (save_to_stream): Remove FIXME, call writer.
+ (Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_streamImage):
+ Store writer.
+
+2006-06-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * NEWS:
+ Mention new VM interface and use of properties.
+ * doc/vmintegration.texinfo:
+ Update with new gnu.java.lang.management section.
+ * gnu/java/lang/management/RuntimeMXBeanImpl.java:
+ New file.
+ * java/lang/management/ManagementFactory.java:
+ (getRuntimeMXBean()): Implemented.
+ * vm/reference/gnu/java/lang/management/RuntimeMXBeanImpl.java:
+ New VM interface file.
+
+2006-06-11 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/26065
+ * gnu/javax/security/auth/login/GnuConfiguration.java: Condition all trace/
+ debug code based on Configuration.DEBUG.
+ Use logger instead of STDOUT and ot STDERR.
+ * gnu/javax/security/auth/login/ConfigFileParser.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslOutputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/SaslInputStream.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPServer.java: Likewise.
+ * gnu/javax/crypto/sasl/srp/SRPClient.java: Likewise.
+ * gnu/javax/crypto/prng/CSPRNG.java: Likewise.
+ * gnu/javax/crypto/pad/TBC.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS7.java: Likewise.
+ * gnu/javax/crypto/pad/PKCS1_V1_5.java: Likewise.
+ * gnu/javax/crypto/pad/BasePad.java: Likewise.
+ * gnu/javax/crypto/mac/OMAC.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPublicKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/GnuPrivateKeyring.java: Likewise.
+ * gnu/javax/crypto/keyring/EnvelopeEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/Entry.java: Likewise.
+ * gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java: Likewise.
+ * gnu/javax/crypto/jce/prng/UMacRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/prng/ICMRandomSpi.java: Likewise.
+ * gnu/javax/crypto/jce/keyring/GnuKeyring.java: Likewise.
+ * gnu/javax/crypto/cipher/Twofish.java: Likewise.
+ * gnu/javax/crypto/cipher/Khazad.java: Likewise.
+ * gnu/javax/crypto/cipher/Rijndael.java: Likewise.
+ * gnu/javax/crypto/cipher/BaseCipher.java: Likewise.
+ * gnu/javax/crypto/cipher/Anubis.java: Likewise.
+ * gnu/java/security/Properties.java: Likewise.
+ * gnu/java/security/x509/X509CRLEntry.java: Likewise.
+ * gnu/java/security/x509/X509CRL.java: Likewise.
+ * gnu/java/security/x509/ext/Extension.java: Likewise.
+ * gnu/java/security/util/Prime2.java: Likewise.
+ * gnu/java/security/util/Base64.java: Likewise.
+ * gnu/java/security/sig/rsa/RSAPSSSignature.java: Likewise.
+ * gnu/java/security/sig/rsa/EMSA_PSS.java: Likewise.
+ * gnu/java/security/provider/PKIXCertPathValidatorImpl.java: Likewise.
+ * gnu/java/security/pkcs/SignerInfo.java: Likewise.
+ * gnu/java/security/pkcs/PKCS7SignedData.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairX509Codec.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/rsa/RSAKeyPairGenerator.java: Likewise.
+ * gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Likewise.
+ * gnu/java/security/key/dss/DSSPrivateKey.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java: Likewise.
+ * gnu/java/security/key/dss/DSSKeyPairGenerator.java: Likewise.
+ * gnu/java/security/jce/sig/SignatureAdapter.java: Likewise.
+ * gnu/java/security/jce/sig/EncodedKeyFactory.java: Likewise.
+ * gnu/java/security/hash/Whirlpool.java: Likewise.
+
+2006-06-11 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
+ (Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs):
+ Remove unused variable glyph_index.
+
+2006-06-11 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java (drawImage):
+ Don't recurse, return false if not an BufferedImage and no image
+ source available.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java (draw): Add
+ end_gdk_drawing() to finally block.
+ (fill): Likewise.
+ (drawRenderedImage): Likewise.
+ (drawImage): Likewise.
+ (drawGlyphVector): Likewise.
+
+2006-06-11 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * doc/tools.texinfo: Added text for new -cacert command.
+ Re-structured sections.
+ * resource/gnu/classpath/tools/keytool/messages.properties: Added messages
+ for -cacert command.
+ * tools/gnu/classpath/tools/keytool/Main.java (CACERT_CMD): New constant.
+ (_CACERT): Likewise.
+ (shutdownThread): New field.
+ (Main): Install shutdown thread.
+ (main): Uninstall shutdown thread.
+ (start): Handle new -cacert command.
+ (getParser): Likewise.
+ (teardown): Increased visibility.
+ (ShutdownHook): New inner class.
+ * tools/gnu/classpath/tools/keytool/CACertCmd.java: New file.
+
+2006-06-11 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (setupGlyphMetrics): New method. Add glyphmetrics caching.
+ (getOutline): Operate on the shape directly.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getGlyphMetrics,putGlyphMetrics): Add GlyphMetrics caching.
+ * include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
+ (getGlyph renamed getGlyphs)
+ * java/awt/geom/AffineTransform.java
+ (getTranslateInstance): Set fields directly.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
+ (getGlyphs): Get all glyph codes at once.
+
+2006-06-11 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ PR Classpath/27853
+ * gnu/javax/crypto/RSACipherImpl.java (engineDoFinal): Was short by 1 byte.
+
+2006-06-11 Sven de Marothy <sven@physto.se>
+
+ * java/awt/font/TextLayout.java
+ (getLogicalHighlightShape): Add check.
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (getLogicalBounds, getGlyphPositions): Cache bounds, positions.
+
+2006-06-11 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/security/auth/login/ConfigFileParser.java (validateClassName):
+ Check that every component of 'cn' starts with a valid Java identifier char.
+
+2006-06-10 Tom Tromey <tromey@redhat.com>
+
+ * java/io/File.java (pathSeparator): Typo fix.
+
+2006-06-10 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/cairographics2d.h (cp_gtk_get_cairo_t):
+ Removed.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ Mark all unused parameters.
+ (cp_gtk_get_cairo_t): Removed.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix):
+ Don't mix declerations and statements.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c:
+ Mark all unused parameters.
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface):
+ Get cairographics2d pointer directly.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout):
+ Use jlong to pass pointer.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c:
+ Mark all unused parameters.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_GdkTextLayout.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_GtkVolatileImage.h: Regenerated.
+ * include/java_io_VMFile.h: Regenerated.
+
+2006-06-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (VolatileImageGraphics(VolatileImageGraphics)): Use clipRect()
+ instead of setClip(), so that an already present clip is intersected
+ and not resetted.
+
+2006-06-10 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java (GdkFontLineMetrics):
+ Call getSize() to avoid accessor method.
+
+2006-06-10 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/text/html/HTMLDocument.java (addSpecialElement):
+ Qualify ElementSpec.
+
+2006-06-10 Mark Wielaard <mark@klomp.org>
+
+ * lib/.cvsignore: Add sun.
+ * lib/Makefile.am (dist-hook): Likewise.
+
+2006-06-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ * native/jni/gtk-peer/cairographics2d.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c:
+ Changed method signatures and calls to pass native pointers directly
+ into the JNI code, in order to avoid costly lookups on each
+ JNI call.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h,
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h,
+ * include/gnu_java_awt_peer_gtk_GtkVolatileImage.h:
+ Regenerated
+
+2006-06-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27973
+ * javax/swing/text/DefaultStyledDocument.java
+ (ElementBuffer.insertContentTag):
+ Do not recreate leaves and do not remove elements here.
+
+2006-06-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLDocument.java
+ (HTMLReader.HiddenAction): Implemented.
+
+2006-06-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/RepaintManager.java
+ (getVolatileOffscreenBuffer): Store the created buffer.
+ * javax/swing/JComponent.java
+ (paintDoubleBuffered): Try to use a volatile offscreen buffer
+ for better performance.
+
+2006-06-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (VolatileImageGraphics(VolatileImageGraphics)): Initialize native
+ context correctly.
+ (getRealBounds): Overridden to return the correct bounds.
+
+2006-06-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalButtonUI.java
+ (update): Fixed to paint the gradient under the correct conditions.
+ (updateWidthGradient): Removed.
+ (isToolbarButton): New helper method.
+ (isDrawingGradient): New helper method.
+
+2006-06-09 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTabbedPane.java
+ (setSelectedIndex): Don't change the visibility of the components,
+ this is done by the UI class.
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (TabbedPaneLayout.layoutContainer): Change visibility of component
+ here, depending on the selected index. Only do this if the new
+ selected component is not null. Some programs seem to expect
+ this.
+ (visibleComponent): New field.
+ (getVisibleComponent): Changed to return visibleComponent field.
+ (setVisibleComponent): Changed to set the visibility of
+ the old and new visible component.
+
+2006-06-09 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildrenOptimized): Paint component with a new Graphics
+ object to protect the other painting code from modifications
+ done in that object, and avoid cleanup ops on possibly dispose()ed
+ Graphics object.
+
+2006-06-09 Sven de Marothy <sven@physto.se>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface):
+ Use GTK locks while disposing (Xlib) surface.
+
+2006-06-09 Tom Tromey <tromey@redhat.com>
+
+ * lib/Makefile.am (install-data-local): Copy 'sun' files.
+ (uninstall-local): Delete 'sun' directory.
+ (glibj.zip): Include 'sun' classes.
+ (clean-local): Delete 'sun' directory.
+ * lib/gen-classlist.sh.in: Search 'sun' subdirectories.
+
+2006-06-09 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ (drawImage): Fixed scaling.
+ (fillShape): Removed offset handling.
+ (fillShapeImpl): Limit scanlining to device bounds.
+ (getSegments): Removed offset handling.
+ * gnu/java/awt/java2d/PolyEdge.java
+ (toString): Include isClip flag in output.
+
+2006-06-08 Sven de Marothy <sven@physto.se>
+
+ * java/awt/font/TextLayout.java
+ (getOutline): Allow null transform.
+
+2006-06-08 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawString): Use TextLayout instead of GlyphVector.
+
+2006-06-08 Sven de Marothy <sven@physto.se>
+
+ * java/text/Bidi.java: Treat WS as neutral for rules N1 & N2.
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ New constructor for bidirectionality.
+ (getGlyphMetrics): Return whitespace glyphs.
+ (getLogicalBounds): Offset rectangles to correct positions.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getBaselineFor): Default to ROMAN_BASELINE.
+ (GdkFontLineMetrics): Guess some values for underline and
+ strikethrough.
+ (layoutGlyphVector): Use bidirectionality.
+ * java/awt/font/TextLayout.java: Implement, mostly.
+
+2006-06-09 Anthony Green <green@redhat.com>
+
+ PR classpath/27888:
+ * javax/swing/text/GapContent.java (binarySearch): Use unsigned shift.
+ * java/util/Collections.java (binarySearch): Use unsigned shift.
+ * java/util/Arrays.java (binarySearch): Use unsigned shift.
+
+2006-06-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/.cvsignore: Added .deps.
+
+2006-06-09 Kazuya Ujihara <ujihara@aurora.dti.ne.jp>
+
+ PR classpath/27966:
+ * gnu/javax/security/auth/login/ConfigFileParser.java
+ (validateClassName): Quote '.' in regexp.
+
+2006-06-09 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/23863:
+ * native/fdlibm/dtoa.c (_dtoa): Free contents of _Jv_reent when
+ finished.
+ * native/fdlibm/mprec.c: New version from newlib. Commented out
+ some includes. Added <assert.h>.
+ (_reent, _Bigint): New defines.
+ (_REENT_CHECK_MP, _REENT_MP_FREELIST, _REENT_MP_P5S): Likewise.
+ (__ULong, __Long): New types.
+ (_calloc_r): New function.
+ (Balloc): Dynamically add new _freelist entries as needed.
+ * native/fdlibm/mprec.h (struct _Jv_Bigint): Don't use
+ MAX_BIGNUMS to size _x[].
+ (struct _Jv_reent): _freelist now a _Jv_Bigint**. Removed
+ _allocation_map, num. Added _max_k.
+
+2006-06-09 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawGlyphVector): Added fallback for non-FreetypeGlyphVector
+ implementations.
+
+2006-06-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BufferedImage.java
+ (BufferedImage(int, int, int)): Added API docs,
+ (getProperty(String)): Return correct value for undefined properties,
+ (getPropertyNames()): Added comments and removed FIXME.
+
+2006-06-09 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc (PLUGIN_ERROR_THREE): New macro.
+ (NP_Initialize): Use PLUGIN_ERROR_THREE in place of g_strconcat.
+
+2006-06-09 Francis Kung <fkung@redhat.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxRenderer.java:
+ (getPreferredSize): Return correct height for null or empty
+ items.
+
+2006-06-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/datatransfer/DataFlavor.java
+ (readExternal): Mark as stub,
+ (writeExternal): Likewise,
+ * java/awt/dnd/DropTargetContext.java
+ (dropComplete): Mark as stub,
+ (acceptDrag): Likewise,
+ (rejectDrag): Likewise,
+ (acceptDrop): Likewise,
+ (rejectDrop): Likewise,
+ (getCurrentDataFlavors): Likewise,
+ (getTransferable): Likewise,
+ * java/awt/dnd/DropTargetDropEvent.java
+ (dropComplete): Mark as stub.
+
+2006-06-09 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
+ (constructor): Do not lowercase the values.
+ * javax/swing/text/html/HTMLDocument.java
+ (HTMLReader.addSpecialElement): Implemented.
+ * examples/gnu/classpath/examples/swing/HtmlDemo.java: New file.
+
+2006-06-09 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ On behalf of Matthew Wringe <mwringe@redhat.com>
+ * gnu/java/security/Registry.java (ISO10126_PAD): New constant.
+ * gnu/javax/crypto/pad/ISO10126.java: New class.
+ * gnu/javax/crypto/pad/PadFactory.java (names): New field.
+ (getInstance): Added support for ISO-10126 scheme.
+ (getNames): Likewise.
+ Cache result for speed.
+
+2006-06-09 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/pad/BasePad.java (selfTest): Re-factored to allow more
+ flexible self-test by sub-classes.
+ (test1BlockSize): New method.
+
+2006-06-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Corrected 'ScrollBar.focusInputMap' entry,
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (installKeyboardActions): Implemented,
+ (uninstallKeyboardActions): Implemented,
+ (getInputMap): New method,
+ (getActionMap): New method,
+ (createActionMap): New method,
+ (installUI): Call installKeyboardActions(),
+ (uninstallUI): Call uninstallKeyboardActions().
+
+2006-06-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (getActionMap): Use correct key to store action map.
+
+2006-06-09 Jeroen Frijters <jeroen@frijters.net>
+
+ * gnu/java/awt/font/opentype/truetype/VirtualMachine.java
+ (executeInstruction): Added NOT support.
+
+2006-06-09 Jeroen Frijters <jeroen@frijters.net>
+
+ * sun/reflect/annotation/AnnotationInvocationHandler.java:
+ New file.
+
+2006-06-08 Tom Tromey <tromey@redhat.com>
+
+ * java/text/Bidi.java (resolveNeutralTypes): Set j'th slot
+ of 'types'.
+
+2006-06-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/management/RuntimeMXBean.java:
+ New file.
+
+2006-06-08 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc:
+ (NP_Shutdown): Freed whitelist_filename.
+
+2006-06-08 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/Makefile.am:
+ Removed DATA_DIRECTORY.
+ * native/plugin/gcjwebplugin.cc:
+ Added new global fields for whitelist_file
+ and data_directory. Removed WHITELIST_FILE.
+ (NP_Initialize): Initialized new fields. Also,
+ Changed to use new fields.
+ (NP_Shutdown): Freed data_directory.
+ (GCJ_New): Changed to use new fields.
+ (plugin_ask_user_about_documentbase): Likewise.
+
+2006-06-08 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/Makefile.am:
+ Changed DATA_DIRECTORY to be ~/.gcjwebplugin.
+ * native/plugin/gcjwebplugin.cc:
+ Changed all instances of PLUGIN_DATA_DIRECTORY
+ to DATA_DIRECTORY.
+
+2006-06-08 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (handleMouseEvent): Replaced calls to AWTUtilities.convertPoint()
+ with convertPointToChild(). This is more efficient and avoids
+ problems with getLocationOnScreen().
+ (findTarget): Check for component beeing showing() early.
+ Simplified AWTUtilities.convertPoint() to a simple substraction
+ operation.
+ (convertPointToChild): New helper method.
+
+2006-06-08 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc (SECURITY_DESCRIPTION): Update
+ message.
+
+2006-06-08 Tom Fitzsimmons <fitzsim@redhat.com>
+ Lillian Angel <langel@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc
+ (NP_Shutdown): Added code to free plugin mutex and whitelist file.
+ Also, reset initialized field.
+
+2006-06-08 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicProgressBarUI.java
+ (paintString): Fixed to paint string at the correct location.
+
+2006-06-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (createDefaultActions): Added new actions.
+ (TreePageAction.TreePageAction): Set action name.
+ (TreePageAction.actionPerformed): Implemented.
+ (TreePageAction.isEnabled): Implemented.
+ (TreeToggleAction.TreePageAction): Set action name.
+ (TreeToggleAction.actionPerformed): Implemented.
+ (TreeToggleAction.isEnabled): Implemented.
+ (TreeTraverseAction.TreeTraverseAction): Set action name.
+ (TreeTraverseAction.actionPerformed): Use action name as command.
+ (TreeTraverseAction.isEnabled): Implemented.
+
+2006-06-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installKeyboardActions): Rewritten to correctly install the UI
+ input and action maps.
+ (getActionMap): New helper method.
+ (createDefaultActionMap): New helper method.
+ (TreeHomeAction.TreeHomeAction()): Implemented.
+ (TreeHomeAction.actionPerformed): Implemented.
+ (TreeHomeAction.isEnabled): Implemented.
+ (TreeIncrementAction.TreeIncrementAction()): Implemented.
+ (TreeIncrementAction.actionPerformed): Use action name as command.
+ (TreeIncrementAction.isEnabled): Implemented.
+
+2006-06-08 Mark Wielaard <mark@klomp.org>
+
+ PR 27917
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData): Ref pixbuf
+ and unref loader.
+
+2006-06-08 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+ (attrs): Removed unused static.
+
+2006-06-08 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (getInputMap): New method,
+ (getActionMap): New method,
+ (createActionMap): New method,
+ (installKeyboardActions): Implemented,
+ (uninstallKeyboardActions): Implemented.
+
+2006-06-08 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/border/MatteBorder.java:
+ (MatteBorder(int,int,int,int,Icon)): Removed if-statement and exception
+ throwing.
+ (paintBorder): Added if-statement to abort painting early.
+
+2006-06-08 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR27864.
+ * gnu/xml/dom/DomIterator.java:
+ (successor): Changed expression.
+
+2006-06-08 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (defaultLayout): Do kerning.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
+ (getKerning): Correct class name, removed unused variable.
+
+2006-06-07 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/qt/QtToolkit.java (initToolkit): Load
+ libqtpeer.so unconditionally.
+
+2006-06-07 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/InputMismatchException.java:
+ Documented.
+
+2005-04-20 Tom Tromey <tromey@redhat.com>
+
+ * java/util/InputMismatchException.java: New file.
+
+2006-06-07 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jawt/Makefile.am (AM_LDFLAGS): Add XTEST_LIBS.
+
+2006-06-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (completeUIUninstall): Implemented.
+ (uninstallUI): Moved some bits to completeUIUninstall(). Complete
+ editing before uninstalling anything.
+ (isToggleEvent): Implemented.
+ (selectPathForEvent): Make use of isToggleEvent().
+ (ComponentHandler.componentMoved): Implemented.
+ (ComponentHandler.startTimer): Implemented.
+ (ComponentHandler.getScrollPane): Implemented.
+ (ComponentHandler.actionPerformed): Implemented.
+
+2006-06-07 Francis Kung <fkung@redhat.com>
+
+ * javax/swing/JMenuBar.java:
+ (getSubElements): Do not return null values.
+
+2006-06-07 Roman Kennke <kennke@aicas.com>
+
+ PR 27902
+ * gnu/regexp/BacktrackStack.java
+ * gnu/regexp/CharIndexed.java
+ * gnu/regexp/CharIndexedCharArray.java
+ * gnu/regexp/CharIndexedCharSequence.java
+ * gnu/regexp/CharIndexedInputStream.java
+ * gnu/regexp/CharIndexedString.java
+ * gnu/regexp/CharIndexedStringBuffer.java
+ * gnu/regexp/RE.java
+ * gnu/regexp/REException.java
+ * gnu/regexp/REFilterInputStream.java
+ * gnu/regexp/REMatch.java
+ * gnu/regexp/REMatchEnumeration.java
+ * gnu/regexp/RESyntax.java
+ * gnu/regexp/REToken.java
+ * gnu/regexp/RETokenAny.java
+ * gnu/regexp/RETokenBackRef.java
+ * gnu/regexp/RETokenChar.java
+ * gnu/regexp/RETokenEnd.java
+ * gnu/regexp/RETokenEndOfPreviousMatch.java
+ * gnu/regexp/RETokenEndSub.java
+ * gnu/regexp/RETokenIndependent.java
+ * gnu/regexp/RETokenLookAhead.java
+ * gnu/regexp/RETokenLookBehind.java
+ * gnu/regexp/RETokenNamedProperty.java
+ * gnu/regexp/RETokenOneOf.java
+ * gnu/regexp/RETokenPOSIX.java
+ * gnu/regexp/RETokenRange.java
+ * gnu/regexp/RETokenRepeated.java
+ * gnu/regexp/RETokenStart.java
+ * gnu/regexp/RETokenWordBoundary.java
+ * gnu/regexp/UncheckedRE.java
+ * gnu/java/util/regex/BacktrackStack.java
+ * gnu/java/util/regex/CharIndexed.java
+ * gnu/java/util/regex/CharIndexedCharArray.java
+ * gnu/java/util/regex/CharIndexedCharSequence.java
+ * gnu/java/util/regex/CharIndexedInputStream.java
+ * gnu/java/util/regex/CharIndexedString.java
+ * gnu/java/util/regex/CharIndexedStringBuffer.java
+ * gnu/java/util/regex/RE.java
+ * gnu/java/util/regex/REException.java
+ * gnu/java/util/regex/REFilterInputStream.java
+ * gnu/java/util/regex/REMatch.java
+ * gnu/java/util/regex/REMatchEnumeration.java
+ * gnu/java/util/regex/RESyntax.java
+ * gnu/java/util/regex/REToken.java
+ * gnu/java/util/regex/RETokenAny.java
+ * gnu/java/util/regex/RETokenBackRef.java
+ * gnu/java/util/regex/RETokenChar.java
+ * gnu/java/util/regex/RETokenEnd.java
+ * gnu/java/util/regex/RETokenEndOfPreviousMatch.java
+ * gnu/java/util/regex/RETokenEndSub.java
+ * gnu/java/util/regex/RETokenIndependent.java
+ * gnu/java/util/regex/RETokenLookAhead.java
+ * gnu/java/util/regex/RETokenLookBehind.java
+ * gnu/java/util/regex/RETokenNamedProperty.java
+ * gnu/java/util/regex/RETokenOneOf.java
+ * gnu/java/util/regex/RETokenPOSIX.java
+ * gnu/java/util/regex/RETokenRange.java
+ * gnu/java/util/regex/RETokenRepeated.java
+ * gnu/java/util/regex/RETokenStart.java
+ * gnu/java/util/regex/RETokenWordBoundary.java
+ * gnu/java/util/regex/UncheckedRE.java
+ Moved gnu.regexp classes to gnu.java.util.regex package.
+ * java/util/regex/Matcher.java
+ * java/util/regex/Pattern.java
+ Adjusted import statements for new package name for gnu regexp.
+
+2006-06-07 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27905:
+ * gnu/java/nio/charset/Provider.java (loadExtended): Now synchronized.
+ Added missing charsets.
+ (charsetForName): Don't check 'extendedLoaded'.
+
+2006-06-07 Roman Kennke <kennke@aicas.com>
+
+ PR 27833
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (clip(Shape)): Implemented correctly, so that the current shape
+ gets intersected by the parameter shape.
+
+2006-06-07 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/math/BigDecimal.java:
+ (compareTo(Object)): Make this call the other
+ one.
+ (compareTo(BigDecimal)): Recreated.
+
+2006-06-07 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (getTabBounds): If this method is called with a tab index
+ that is not in the rects array, we need to re-layout the container
+ so it is created.
+
+2006-06-07 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ (FreetypeGlyphVector): Removed assignment. Caused compilation error.
+ * java/lang/String.java
+ (codePointCount): Fixed check to match API. Shouldn't throw exception
+ if end == count. end is 1 more than the endIndex, so end == count is
+ possible.
+
+2006-06-07 Gary Benson <gbenson@redhat.com>
+
+ PR 24895
+ * native/jni/java-io/java_io_VMFile.c
+ (Java_java_io_VMFile_toCanonicalForm): New method.
+ * configure.ac: Added checks for lstat and readlink.
+ * include/java_io_VMFile.h: Added new method.
+ * vm/reference/java/io/VMFile.java: Use new method.
+ * gnu/java/io/PlatformHelper.java (toCanonicalForm): Removed.
+ * NEWS: Documented the above.
+ * java/io/File.java: Javadoc fix.
+
+2006-06-07 Roman Kennke <kennke@aicas.com>
+
+ PR 27920
+ * javax/swing/JTree.java
+ (JTree()): Initialize with default model.
+ (JTree(TreeModel)): Clear expanded state hashtable. Added comment
+ on the updateUI() / setModel() order.
+ (setModel): Correctly (un-)setup the listeners. Clear the expanded
+ paths.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (BasicTreeUI()): Initialize listeners in installListeners().
+ (setModel): Complete editing on model change. Correctly resetup
+ the listeners. Update the layout cache accordingly.
+ (setShowRootHandles): Complete editing and update layout. Do not
+ call back into the JTree, this could cause cycles.
+ (prepareForUIInstall): Implemented. Moved some init code from
+ installUI() to this method.
+ (completeUIInstall): Implemented. Moved some init code from
+ installUI() to this method.
+ (createDefaultCellEditor): Check for type of renderer, and install
+ with null renderer when not DefaultTreeCellRenderer.
+ (updateLayoutCacheExpandedNodes): Added null check for tree root
+ to avoid NPE.
+ (updateRenderer): Call updateEditor().
+ (installListeners): Initialize the listeners here. Added some null
+ checks to avoid NPEs.
+ (installUI): Moved some init code to prepareForUIInstall() and
+ completeUIInstall().
+ (completeEditing): Return immediately if editing component is null
+ or if the setting is to not stop editing on complete editing.
+ (checkForClickInExpandControl): Call handleExpandControlClick()
+ instead of toggleExpandState() directly.
+ (isLocationInExpandControl): Rewritten to correctly determine the
+ expand click location.
+ (MouseHandler.mousePressed): Rewritten to make better use of the
+ instance methods of BasicTreeUI to handle the click.
+ (PropertyHandler.propertyChange): Handle model and cell renderer
+ updates.
+ * javax/swing/tree/DefaultTreeCellEditor.java
+ (DefaultTreeCellEditor): Removed initialization of the icon. This
+ is done so that the constructor can deal with null renderer as the
+ RI does. Maybe this needs more fixing.
+ * javax/swing/tree/TreePath.java
+ (isDescendant): Fixed this method. The previous version did too
+ much and compared the wrong things, which lead to a ClassCastException
+ in equals().
+ * javax/swing/tree/VariableHeightLayoutCache.java
+ (update): Do nothing when model is null.
+ (setModel): Clear the tables and update the layout. Added null
+ check to prevent NPE.
+
+2006-06-07 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkGlyphVector: Removed file.
+
+2006-06-07 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+ * include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
+ New files.
+
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getGlyphVector): Removed native method.
+ (createGlyphVector, getStringBounds): Use new GV class.
+
+ * include/Makefile.am
+ * native/jni/gtk-peer/Makefile.am
+ Add new files.
+
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+ (getGlyphVector): Removed native method.
+
+2006-06-07 Chris Burdess <dog@gnu.org>
+
+ * gnu/classpath/debug/TeeInputStream.java,
+ gnu/classpath/debug/TeeOutputStream.java,
+ gnu/classpath/debug/TeeReader.java,
+ gnu/classpath/debug/TeeWriter.java: New classes for debugging streams.
+ * gnu/xml/stream/XMLParser.java: Use tee streams for debugging. Don't
+ read more characters than absolutely necessary in tryRead method.
+
+2006-06-07 Robert Schuster <robertschuster@fsfe.org>
+
+ * examples/gnu/classpath/examples/swing/Demo.java:
+ (mkMenuBar): Put look and feel radio buttons into
+ appropriate button group.
+
+2006-06-07 Chris Burdess <dog@gnu.org>
+
+ * gnu/xml/stream/SAXParser.java,
+ gnu/xml/stream/XMLParser.java: Add command line options for setting
+ parsing parameters (for simpler debugging).
+ * gnu/xml/transform/TransformerImpl.java: Try to ensure that I/O error
+ closing output stream is propagated to application.
+
+2006-06-06 Mark Wielaard <mark@klomp.org>
+
+ PR 27917
+ * gnu/java/awt/peer/gtk/CairoSurface.java (finalize): Call dispose.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java: Override dispose to
+ call disposeSurface.
+ (disposeSurface): New native method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_disposeNative): Free
+ pattern_pixels.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_drawSurface): Call
+ cairo_pattern_destroy.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface):
+ New function to destroy the surface.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h: Likewise.
+
+2006-06-06 Mark Wielaard <mark@klomp.org>
+
+ * include/jni.h (JDK1_1InitArgs): Mark pointer-to-function types
+ with JNICALL.
+
+2006-06-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalSplitPaneDivider.java
+ (paint): If has focus, paint special background color,
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (FocusHandler.focusGained): Implemented,
+ (FocusHandler.focusLost): Implemented.
+
+2006-06-06 Tom Tromey <tromey@redhat.com>
+
+ * javax/swing/text/StyleContext.java (registerStaticAttributeKey):
+ Javadoc fix.
+ (writeAttributeSet): Implemented.
+
+2006-06-06 Tom Tromey <tromey@redhat.com>
+
+ * javax/swing/text/html/HTMLDocument.java (SpecialAction.start):
+ Implement.
+ (SpecialAction.end): Removed.
+ (IsindexAction.end): Likewise.
+
+2006-06-06 Tom Tromey <tromey@redhat.com>
+
+ * include/jni.h (JDK1_1InitArgs): New struct.
+ (JDK1_1AttachArgs): Likewise.
+
+2006-06-06 Tom Tromey <tromey@redhat.com>
+
+ * java/security/UnresolvedPermission.java (getUnresolvedType): New
+ method.
+ (getUnresolvedName): New method.
+ (getUnresolvedActions): New method.
+ (getUnresolvedCerts): New method.
+
+2006-06-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/CharacterAttributeTranslator.java
+ (getColor): Removed debugging code.
+
+2006-06-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/CharacterAttributeTranslator.java
+ (getColor): Added support for "rgb(red, green, blue)" notation.
+ (translateTag): Use Boolean.TRUE, not new Boolean().
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ PR 27651
+ * javax/swing/JTree.java
+ (JTree(TreeModel)): Call updateUI() before setModel().
+ (setModel): Don't call updateUI here.
+
+2006-06-06 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc:
+ Fixed failure message and commenting.
+ (NP_Initialize): Added more comments.
+
+2006-06-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JSplitPane.java
+ (AccessibleJSplitPane): API doc fixes,
+ (setDividerLocation): Likewise,
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Additions to SplitPane.ancestorInputMap,
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (getInputMap): New method,
+ (getActionMap): New method,
+ (createActionMap): New method,
+ (installKeyboardActions): Implemented,
+ (uninstallKeyboardActions): Implemented.
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ PR 27523
+ * javax/swing/MenuSelectionManager.java
+ (processKeyEvent): Added check to avoid
+ ArrayIndexOutOfBoundsException.
+
+2006-06-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/htmlAttributeSet.java
+ (getAttributeNames): Rewritten
+
+2006-06-06 Chris Burdess <dog@gnu.org>
+
+ * gnu/xml/transform/TransformerImpl.java: Check type of created
+ document (more cases).
+
+2006-06-06 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/htmlAttributeSet.java
+ (clone): New method. (copyAttributes): New method.
+ (getResolveParent): Comment fix. (getAttribute):
+ Rewritten. (addAttribute): Rewritten.
+ * gnu/javax/swing/text/html/SmallHtmlAttributeSet.java:
+ New file.
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ PR 27522
+ * javax/swing/JMenuBar.java
+ (processKeyBindingHelper): Added null check to prevent NPE.
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (ShowSystemMenuAction): New class.
+ (installKeyboardActions): Implemented.
+ (uninstallKeyboardActions): Implemented.
+ * javax/swing/plaf/metal/MetalInternalFrameUI.java
+ (installKeyboardActions): Overridden to remove showSystemMenu action.
+
+2006-06-06 Chris Burdess <dog@gnu.org>
+
+ * gnu/xml/transform/TransformerImpl.java: Check type of created
+ document.
+
+2006-06-06 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
+ (getScreenDevices): Added explicit cast.
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (installKeyboardActions): Use shared input map. Correctly
+ install the input/action maps in the component's input/action
+ map hierarchies.
+ (getActionMap): New helper method for fetching an ActionMap from
+ the UIManager or creating a default one if there is none supplied
+ by the UIManager.
+ (createActionMap): Add the TransferHandler's actions here. Made
+ method private.
+ (getInputMap): Leave out unnecessary method parameter. Load
+ shared input map.
+ * javax/swing/plaf/basic/SharedUIDefaults.java: New file.
+
+2006-06-06 Robert Schuster <robertschuster@fsfe.org>
+
+ * configure.ac: Added missing [ to expression.
+
+2006-06-06 Robert Schuster <robertschuster@fsfe.org>
+
+ * configure.ac: Added missing { to expression.
+
+2006-06-06 Robert Schuster <robertschuster@fsfe.org>
+
+ * include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h: Regenerated.
+ * include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h: New file.
+ * include/Makefile.am: Added
+ gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.
+ * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:
+ (GdkGraphicsConfiguration): Rewritten.
+ (getColorModel): Rewritten.
+ (getColorModel(int)): Rewritten.
+ (getBounds): Rewritten.
+ (createCompatibleVolatileImage): Implemented.
+ * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java: Added static
+ initializer.
+ (getDefaultScreenDevice): Rewritten.
+ (nativeGetDefaultScreenDevice): New method.
+ (getScreenDevices): Rewritten.
+ (nativeGetScreenDevices): New method.
+ (nativeInitState): New method.
+ * gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java: Entirely
+ rewritten.
+ (X11DisplayMode): New inner class.
+ * native/jni/gtk-peer/Makefile.am: Added gdkdisplay.h and
+ gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
+ * native/jni/gtk-peer/gdkdisplay.h: New file.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c:
+ (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState):
+ New function.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState):
+ New function.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment
+ _nativeGetScreenDevices):
+ New function.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment
+ _nativeGetDefaultScreenDevice):
+ New function.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c:
+ New file.
+ * configure.ac: Added check for Xrandr library.
+
+2006-06-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (getMaximumSize): Don't return null. Fixed calculation of
+ table height.
+ (getMinimumSize): Don't return null. Fixed calculation of
+ table height.
+ (getPreferredSize): Fixed calculation of with and height. Added
+ API docs.
+ (getHeight): New helper method.
+
+2006-06-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComponent.java
+ (getInputMap(int)): Throw IllegalArgumentException for unknown
+ condition argument, and added API docs,
+ (getInputMap()): Added API docs.
+
+2006-06-06 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/BufferedImage.java: Added fourth 8 to bits4 field.
+
+2006-06-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTable.java
+ (AccessibleJTableHeaderCell.header): New field,
+ (AccessibleJTableHeaderCell.columnIndex): Likewise,
+ (AccessibleJTableHeaderCell.AccessibleJTableHeaderCell()): Initialise,
+ (AccessibleJTableHeaderCell.getColumnHeaderRenderer): New method,
+ (AccessibleJTableHeaderCell.getAccessibleContext): Implemented,
+ (AccessibleJTableHeaderCell.getAccessibleRole): Implemented,
+ (AccessibleJTable.getAccessibleChild(int)): Overridden,
+ (AccessibleJTable.getAccessibleAt): Reimplemented.
+
+2006-06-05 Sven de Marothy <sven@physto.se>
+
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (initFromVolatile): New method.
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ Reimplement.
+ * include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+ (copyArea, drawVolatileImage): New methods.
+
+2006-06-05 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JFrame.java
+ (frameInit): Set background color and fixed layout parameters.
+
+2006-06-05 Tom Tromey <tromey@redhat.com>
+
+ * NEWS: Mention VMURLConnection.
+
+2006-06-05 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/gcjwebplugin.cc:
+ Added new field to keep track of initialization.
+ (plugin_start_appletviewer): Fixed to return an error value, if
+ an error was encountered when loading the appletviewer.
+ (GCJ_NEW): Added call to plugin_failed if the loading of the appletviewer
+ has failed.
+ (plugin_failed): New helper function. Shows a warning if the appletviewer
+ has not been installed.
+ (NP_Initialize): Added code to make sure this function is only called
+ once.
+
+2006-06-05 Lillian Angel <langel@redhat.com>
+
+ * native/plugin/Makefile.am:
+ Fixed to use a set plugin directory in the .mozilla directory.
+ All applet logs are now stored here, instead of /tmp.
+ * native/plugin/gcjwebplugin.cc:
+ Added new fields for security warning.
+ (GCJ_NEW): Added code to generate a security warning for all pages
+ that spawn an appletviewer. This warning asks the user if they trust
+ the applet and if they would like to add it to a 'whitelist'. This
+ whitelist keeps track of all the addresses the user would like
+ to trust indefinitely.
+ (plugin_user_trusts_documentbase): New helper function.
+ (plugin_add_documentbase_to_whitelist): New helper function.
+ (plugin_ask_user_about_documentbase): New helper function.
+ (plugin_in_pipe_callback): Fixed check to determine if channel_error
+ has been set.
+ (plugin_start_appletviewer): Likewise.
+ (plugin_create_applet_tag): Reset all fields to null after they have been
+ freed.
+ (plugin_send_message_to_appletviewer): Fixed all error checks to determine
+ if channel_error has been set.
+ (plugin_stop_appletviewer): Likewise.
+ (NP_Initialize): Likewise. Also, added code to determine if directory and file
+ should be created.
+
+2006-06-05 Francis Kung <fkung@redhat.com>
+
+ PR 27507
+ * gnu/java/awt/peer/gtk/GtkImage.java
+ (getSource): Added check to determine if in
+ errorLoading state.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java
+ (createImage): Added check to prevent NPE.
+
+2006-06-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLEditorKit.java (HTMLFactory.create):
+ Create the ImageView, when applicable.
+ * gnu/javax/swing/text/html/CombinedAttributes.java,
+ javax/swing/text/html/ImageView.java: New files.
+
+2006-06-05 Roman Kennke <kennke@aicas.com>
+
+ PR 27834
+ * javax/swing/text/GapContent.java
+ (setPositionsInRange): Compare with startIndex and endIndex
+ rather than start and end.
+ (dumpMarks): Only dump real marks.
+
+2006-06-05 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (ComponentGraphics): Use 0,0 as clip origin.
+
+2006-06-04 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/Formattable.java,
+ * java/util/FormattableFlags.java,
+ * java/util/Formatter.java:
+ Documented.
+
+2006-03-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/Formatter.java:
+ Make the class final.
+
+2005-09-26 Tom Tromey <tromey@redhat.com>
+
+ * java/util/Formatter.java (format): Set fmtLocale.
+ (applyLocalization): New method.
+ (basicIntegralConversion): Likewise.
+ (hexOrOctalConversion): Use it.
+ (decimalConversion): New method.
+ (format): Use decimalConversion, dateTimeConversion.
+ (genericFormat): Upper-case earlier. Justify correctly.
+ (singleDateTimeConversion): New method.
+ (dateTimeConversion): Likewise.
+
+2005-09-25 Tom Tromey <tromey@redhat.com>
+
+ * java/util/Formatter.java (lineSeparator): Use SystemProperties.
+
+2005-09-24 Tom Tromey <tromey@redhat.com>
+
+ * java/util/FormattableFlags.java (PLUS, SPACE, ZERO, COMMA,
+ PAREN): New constants.
+ * java/util/Formattable.java: New file.
+ * java/util/Formatter.java: New file.
+
+2005-08-13 Tom Tromey <tromey@redhat.com>
+
+ * java/util/FormattableFlags.java: New file.
+
+2006-06-04 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (createVolatileImage): Pass peer to VolatileImage constructor.
+ * java/awt/Component.java
+ (createVolatileImage): Call peer method directly.
+
+2006-06-04 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/DuplicateFormatFlagsException.java,
+ * java/util/FormatFlagsConversionMismatchException.java,
+ * java/util/FormatterClosedException.java,
+ * java/util/IllegalFormatCodePointException.java,
+ * java/util/IllegalFormatConversionException.java,
+ * java/util/IllegalFormatException.java,
+ * java/util/IllegalFormatFlagsException.java,
+ * java/util/IllegalFormatPrecisionException.java,
+ * java/util/IllegalFormatWidthException.java,
+ * java/util/MissingFormatArgumentException.java,
+ * java/util/MissingFormatWidthException.java,
+ * java/util/UnknownFormatConversionException.java,
+ * java/util/UnknownFormatFlagsException.java:
+ Documented.
+
+2005-08-13 Tom Tromey <tromey@redhat.com>
+
+ * java/util/UnknownFormatConversionException.java
+ (serialVersionUID): New field.
+ (s): Renamed from 'conv' for serialization.
+ * java/util/MissingFormatWidthException.java (serialVersionUID):
+ New field.
+ (s): Renamed from 'width' for serialization.
+ * java/util/MissingFormatArgumentException.java
+ (serialVersionUID): New field.
+ (s): Renamed from 'spec' for serialization.
+ * java/util/IllegalFormatWidthException.java (serialVersionUID):
+ New field.
+ (w): Renamed from 'width' for serialization.
+ * java/util/IllegalFormatPrecisionException.java
+ (serialVersionUID): New field.
+ (p): Renamed from 'precision' for serialization.
+ * java/util/IllegalFormatFlagsException.java (serialVersionUID):
+ New field.
+ * java/util/IllegalFormatConversionException.java
+ (serialVersionUID): New field.
+ (c): Renamed from 'conv' for serialization.
+ (arg): Renamed from 'argClass' for serialization.
+ * java/util/IllegalFormatCodePointException.java
+ (serialVersionUID): New field.
+ (c): Renamed from 'codepoint' for serialization.
+ * java/util/FormatFlagsConversionMismatchException.java
+ (serialVersionUID): New field.
+ (f): Renamed from 'flags' for serialization.
+ (c): Renamed from 'conversion' for serialization.
+ * java/util/DuplicateFormatFlagsException.java (serialVersionUID):
+ New field.
+ * java/util/IllegalFormatException.java (serialVersionUID): New
+ field.
+ * java/util/FormatterClosedException.java (serialVersionUID): New
+ field.
+
+2005-04-20 Tom Tromey <tromey@redhat.com>
+
+ * java/util/DuplicateFormatFlagsException.java: New file.
+ * java/util/FormatFlagsConversionMismatchException.java: New file.
+ * java/util/FormatterClosedException.java: New file.
+ * java/util/IllegalFormatCodePointException.java: New file.
+ * java/util/IllegalFormatConversionException.java: New file.
+ * java/util/UnknownFormatFlagsException.java: New file.
+ * java/util/UnknownFormatConversionException.java: New file.
+ * java/util/MissingFormatWidthException.java: New file.
+ * java/util/MissingFormatArgumentException.java: New file.
+ * java/util/IllegalFormatWidthException.java: New file.
+ * java/util/IllegalFormatPrecisionException.java: New file.
+ * java/util/IllegalFormatFlagsException.java: New file.
+ * java/util/IllegalFormatException.java: New file.
+
+2006-06-04 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (getFlippedBuffer): New method.
+ (getGtkImage): Renamed method.
+ * gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ Renamed getSharedImage to getGtkImage.
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (getFlippedBuffer): New method
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ Avoid window casts.
+
+2006-03-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/System.java:
+ (nanoTime()): Documented.
+
+2006-03-20 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/System.java:
+ (nanoTime()): Implemented.
+
+2006-03-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (precision): Fixed overflow problem with large numbers.
+ (longValueExact): New method.
+ (intValueExact): Likewise.
+ (byteValueExact): Likewise.
+ (shortValueExact): Likewise.
+
+2006-03-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (remainder(BigDecimal)): New method.
+ (divideAndRemainder(BigDecimal)): Likewise.
+ (divideToIntegralValue(BigDecimal)): Likewise.
+ (floor): New implementation method.
+
+2006-02-28 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (divide(BigDecimal, int, RoundingMode)): New method.
+ (divide(BigDecimal, RoundingMode)): Likewise.
+ (divide(BigDecimal, int, int)): Removed incorrect throwing of exception
+ when the new scale is < 0.
+ (setScale(int, RoundingMode)): New method.
+ (ulp): Likewise.
+
+2006-02-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java: Replaced occurences of BigInteger.valueOf
+ with BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN where appropriate.
+ (add(BigDecimal, MathContext)): New method.
+ (subtract(BigDecimal, MathContext)): Likewise.
+ (precision): Fixed to correctly handle BigIntegers with more than 19
+ digits.
+ (pow(int, MathContext)): New method.
+
+2006-02-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java: Added @throws clause to constructors.
+ (mathContext): Removed this unneeded field.
+ (BigDecimal(int, MathContext)): New constructor.
+ (BigDecimal(BigInteger, int, MathContext)): Likewise.
+ (multiply(BigDecimal, MathContext)): New method.
+ (negate(MathContext)): Likewise.
+ (plus(MathContext)): Likewise.
+ (numDigitsInLong): Fixed to properly handle negatives.
+
+2006-02-24 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (BigDecimal(long, MathContext)): New constructor.
+ (BigDecimal(BigInteger, MathContext)): Likewise.
+ (BigDecimal(String, MathContext)): Likewise.
+ (BigDecimal(double, MathContext)): Likewise.
+ (round): Fixed a typo where the precision field was used instead of a
+ call to the precision method, and also store the new precision in the
+ returned BigDecimal.
+ (abs(MathContext)): New method.
+
+2006-02-24 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java
+ (toBigInteger): Fixed problem where this method couldn't handle
+ negative values for scale.
+ (toBigIntegerExact): New method.
+ (stripTrailingZeros): Likewise.
+
+2006-02-23 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (toString): Fixed a problem where the negative sign was being displayed
+ twice in the exponent.
+ (toEngineeringString): New method.
+ (toPlainString): Likewise.
+ (pow): Likewise.
+
+2006-02-23 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (toString): Rewrote this method to behave as specified. Added API
+ comments to explain behaviour.
+ (scaleByPowerOfTen): New method.
+
+2006-02-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (BigDecimal(char[], int, int, MathContext)): New constructor.
+ (BigDecimal(char[], MathContext)): Likewise.
+ (BigDecimal(char[])): Likewise.
+ (BigDecimal(char[], int, int)): Likewise.
+ (BigDecimal(String)): Fixed handling of exponent and scale.
+
+2006-02-21 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/BigDecimal.java:
+ (mathContext): New field.
+ (precision): Likewise.
+ (BigDecimal(int)): New constructor.
+ (BigDecimal(long)): Likewise.
+ (BigDecimal(BigInteger)): Added API docs.
+ (BigDecimal(BigInteger, int)): Removed incorrect NumberFormatException
+ and added API docs.
+ (plus): New method.
+ (round): Likewise.
+ (precision): Likewise.
+ (valueOf): Likewise.
+ (numDigitsInLong): New implementation method.
+
+2006-02-21 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/math/MathContext.java: New class.
+
+2006-06-04 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c:
+ (drawVolatile): Add casts.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c:
+ (getOutline): Add casts.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c:
+ Comment out unused prototype.
+ (getPixels): Add appropriate cast and comment out unused variable.
+
+2006-06-04 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/sasl/SaslUtil.java: Remove unused import.
+ * gnu/javax/crypto/sasl/srp/SRPRegistry.java (PASSWORD_DB): Fix javadoc @link.
+ * gnu/javax/crypto/sasl/srp/PasswordFile.java: Removed unused import.
+ * gnu/javax/crypto/prng/CSPRNG.java (FILE_SOURCES): Fix javadoc @see.
+ (getSystemInstance): Fix javadoc @link.
+ (counter): Increased visibility.
+ * gnu/javax/crypto/pad/TLS1.java: Remove unused import.
+ * gnu/javax/crypto/pad/IPad.java: Fix javadoc @link.
+ * gnu/javax/crypto/pad/PKCS1_V1_5.java (PKCS1_V1_5): Likewise.
+ * gnu/javax/crypto/pad/PKCS7.java (PKCS7): Likewise.
+ * gnu/javax/crypto/pad/TBC.java (TBC): Likewise.
+ * gnu/javax/crypto/mode/CTR.java: Remove unused import.
+ * gnu/javax/crypto/mode/BaseMode.java (defaultBlockSize): Fix javadoc @see.
+ * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java (getEncoded): Fix javadoc @see.
+ * gnu/javax/crypto/jce/spec/TMMHParameterSpec.java: Fix javadoc @link.
+ * gnu/javax/crypto/keyring/AuthenticatedEntry.java: Remove unused imports.
+ * gnu/javax/crypto/keyring/CertificateEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/CertPathEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/EncryptedEntry.java: Likewise.
+ * gnu/javax/crypto/keyring/PublicKeyEntry.java: Likewise.
+ * gnu/javax/crypto/mac/OMAC.java: Likewise.
+ * gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java: Likewise.
+ * gnu/javax/crypto/jce/mac/OMacImpl.java: Likewise.
+ * gnu/javax/crypto/jce/prng/CSPRNGSpi.java: Likewise.
+ * gnu/javax/crypto/cipher/IBlockCipherSpi.java: Fix javadoc @link.
+ * gnu/javax/crypto/jce/cipher/CipherAdapter.java (CipherAdapter): Likewise.
+ * gnu/javax/crypto/cipher/BaseCipher.java: Remove unused import.
+ * gnu/javax/crypto/assembly/Cascade.java: Fix javadoc @link.
+ * gnu/javax/crypto/assembly/Direction.java: Likewise.
+ * gnu/javax/crypto/assembly/Transformer.java: Likewise.
+
+2006-06-04 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/PolicyFile.java: Updated copyright year.
+ (logger): Increased visibility.
+ * gnu/java/security/x509/Util.java: Updated copyright year.
+ (hexDump): Fix javadoc @link.
+ * gnu/java/security/x509/ext/GeneralNames.java: Updated copyright year.
+ Removed unused import.
+ * gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java: Fix javadoc @link.
+ * gnu/java/security/sig/ISignature.java (SOURCE_OF_RANDOMNESS): Likewise.
+ * gnu/java/security/util/ExpirableObject.java: Likewise.
+ (destroy): Likewise.
+ * gnu/java/security/util/SimpleList.java (SimpleList): Likewise.
+ * gnu/java/security/provider/PKIXCertPathValidatorImpl.java:
+ Updated copyright year.
+ (checkCRL): Fix javadoc @param.
+
+2006-06-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/lang/annotation/IncompleteAnnotationException.java:
+ Documented.
+
+2004-08-07 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/annotation/IncompleteAnnotationException.java: New
+ file.
+
+2006-06-02 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (cairoPreserveClip, cairoResetClip): New methods.
+ (setClip, clip): Reimplement.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+ (cairoPreserveClip, cairoResetClip): New methods.
+
+2006-06-02 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ * include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+ New files.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (drawImage): Overloads for VolatileImage drawing.
+ (drawVolatile): New method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ (drawVolatile): New method.
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ Unstub implementation.
+ * include/Makefile.am
+ * native/jni/gtk-peer/Makefile.am
+ Add new files.
+ * native/jni/gtk-peer/gtkpeer.h
+ New prototype.
+
+2006-06-03 Roman Kennke <kennke@aicas.com>
+
+ PR 27418
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (damageRange): Added null check to avoid NPE.
+
+2006-06-03 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/PlainView.java
+ (updateDamage): Check for valid longestLine and initialize if
+ necessary.
+
+2006-06-03 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c: Use C
+ comments, not C++.
+
+2006-06-02 Sven de Marothy <sven@physto.se>
+
+ PR 27879
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (copyArea): Implement.
+ (copyAreaImpl, getRealBounds): New methods.
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (copyAreaImpl, getRealBounds): Implement.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (nativeCopyArea): Reimplement.
+
+2006-06-02 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.ac: Add -lX11 and -lXtst to XTEST_LIBS.
+ (XTEST_LIBS): New, substitute.
+ * native/jni/gtk-peer/Makefile.am (AM_LDFLAGS): Add XTEST_LIBS.
+
+2006-06-02 Roman Kennke <kennke@aicas.com>
+
+ PR 26738
+ * javax/swing/text/PlainView.java
+ (updateDamage): Rewritten for correct repainting and revalidating.
+ (findLongestLine): New helper method.
+ (getLineLength): New helper method.
+
+2006-06-02 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (nativeCopyArea): Change stride parameter to use # of ints.
+ (setPixels): Add checks.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (ComponentGraphics): Set background, clip.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (Cairographics2D): Don't set clip.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ Add flush.
+
+2006-06-02 Lillian Angel <langel@redhat.com>
+
+ PR 24458
+ * java/awt/DefaultKeyboardFocusManager.java
+ (dispatchEvent): Fixed to getFocusOwner, if that fails it tries
+ to get the focused window.
+
+2006-06-01 Miriam Schuster <schmir11@web.de>
+
+ * Makefile.am: Add fallback if "mozilla-plugin" is not available.
+ Fallbacks used: "firefox-plugin" and "xulrunner-plugin".
+
+2006-06-02 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (columnSelectionChanged): Don't return when there's only one
+ column (might still need repainting). Correctly calculate
+ repaint rectangle.
+ (valueChanged): Use return value of SwingUtilities.computeUnion
+ as dirty region.
+
+2006-06-01 Keith Seitz <keiths@redhat.com>
+
+ From Martin Platter <motse@complang.tuwien.ac.at>:
+ * gnu/classpath/jdwp/processor/EventRequestCommandSet.java
+ (executeSet): Fix buffer underflow reading reference ID.
+ * gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
+ (executeParent): Fix NPE if ThreadGroup is top-level ThreadGroup.
+ * gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
+ (executeSuperclass): Handle case of Object with ID zero.
+
+2006-06-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/StorePasswdCmd.java: Fixed typo.
+ * tools/gnu/classpath/tools/keytool/CertReqCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/DeleteCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/ExportCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/GenKeyCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/KeyCloneCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/ListCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/SelfCertCmd.java: Likewise.
+
+2006-06-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/Command.java (shutdownThread): New field.
+ (Command): Add the shutdown hook.
+ (doCommand): Remove the shutdown hook.
+ (ShutdownHook): New class.
+
+2006-06-02 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/jarsigner.in: Use @VM_BINARY@.
+ * tools/keytool.in: Likewise.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java:
+ (setColor): Update the cairo paint.
+
+2006-06-01 Mark Wielaard <mark@klomp.org>
+
+ * java/util/logging/LogManager.java (createInstance): Always add
+ original exception on warning.
+
+2006-06-01 Lillian Angel <langel@redhat.com>
+
+ * tools/gnu/classpath/tools/appletviewer/AppletTag.java
+ (prependCodebase): Fixed check. No dirname was ever considered to
+ be a file, so every applet fell into the if-statement causing a lot
+ of classloading problems with the applets.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ Patch submitted by Boris Dusek.
+ * native/jni/qt-peer/qtmenupeer.cpp
+ Fix segfault
+
+2006-06-01 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (AccessibleJTableCell.getAccessibleRow): Added comment explaining
+ why the behaviour is like it is.
+ (AccessibleJTableCell.getAccessibleStateSet): Implemented.
+ (AccessibleJTableHeader): New inner class.
+ (AccessibleJTableHeaderCell): New inner class.
+ (AccessibleJTable.lastSelectedRow): New field.
+ (AccessibleJTable.lastSelectedColumn): New field.
+ (AccessibleJTable.caption): New field.
+ (AccessibleJTable.summary): New field.
+ (AccessibleJTable.rowDescriptions): New field.
+ (AccessibleJTable.columnDescriptions): New field.
+ (AccessibleJTable): Initialize lastSelectedRow and lastSelectedColumn.
+ (AccessibleJTable.getAccessibleSelection(int)): Implemented.
+ (AccessibleJTable.isAccessibleChildSelected): Implemented.
+ (AccessibleJTable.addAccessibleSelection): Implemented.
+ (AccessibleJTable.removeAccessibleSelection): Implemented.
+ (AccessibleJTable.clearAccessibleSelection): Implemented.
+ (AccessibleJTable.selectAllAccessibleSelection): Implemented.
+ (AccessibleJTable.valueChange): Implemented.
+ (AccessibleJTable.tableRowsInserted): Implemented.
+ (AccessibleJTable.tableRowsDeleted): Implemented.
+ (AccessibleJTable.handleRowChange): New helper method.
+ (AccessibleJTable.columnAdded): Implemented.
+ (AccessibleJTable.columnMarginChanged): Implemented.
+ (AccessibleJTable.columnMoved): Implemented.
+ (AccessibleJTable.columnRemoved): Implemented.
+ (AccessibleJTable.columnSelectionChanged): Implemented.
+ (AccessibleJTable.handleColumnChange): New helper method.
+ (AccessibleJTable.editingCanceled): Implemented.
+ (AccessibleJTable.editingStopped): Implemented.
+ (AccessibleJTable.getAccessibleRow): Implemented.
+ (AccessibleJTable.getAccessibleColumn): Implemented.
+ (AccessibleJTable.getAccessibleIndex): Implemented.
+ (AccessibleJTable.getAccessibleCaption): Implemented.
+ (AccessibleJTable.setAccessibleCaption): Implemented.
+ (AccessibleJTable.getAccessibleSummary): Implemented.
+ (AccessibleJTable.setAccessibleSummary): Implemented.
+ (AccessibleJTable.getAccessibleRowCount): Implemented.
+ (AccessibleJTable.getAccessibleColumnCount): Implemented.
+ (AccessibleJTable.getAccessibleAt): Implemented.
+ (AccessibleJTable.getAccessibleRowExtentAt): Implemented.
+ (AccessibleJTable.getAccessibleColumnExtentAt): Implemented.
+ (AccessibleJTable.getAccessibleRowHeader): Implemented.
+ (AccessibleJTable.setAccessibleRowHeader): Implemented.
+ (AccessibleJTable.getAccessibleColumnHeader): Implemented.
+ (AccessibleJTable.setAccessibleColumnHeader): Implemented.
+ (AccessibleJTable.getAccessibleRowDescription): Implemented.
+ (AccessibleJTable.setAccessibleRowDescription): Implemented.
+ (AccessibleJTable.getAccessibleColumnDescription): Implemented.
+ (AccessibleJTable.setAccessibleColumnDescription): Implemented.
+ (AccessibleJTable.isAccessibleSelected): Implemented.
+ (AccessibleJTable.isAccessibleRowSelected): Implemented.
+ (AccessibleJTable.isAccessibleColumnSelected): Implemented.
+ (AccessibleJTable.getSelectedAccessibleRows): Implemented.
+ (AccessibleJTable.getSelectedAccessibleColumns): Implemented.
+ (getAccessibleContext): Register listeners for the accessibility
+ class on the JTable.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java:
+ (setPaint): Scale +1 pixel larger.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ PR 27854
+ * gnu/java/awt/Buffers.java (getData): Reimplement.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (getElem, setElem): Call native methods.
+
+2006-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/ImageViewIconFactory.java: New file.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Check for zero size.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java:
+ (setFont): Declare new native method.
+ (GdkTextLayout): Read some attributes.
+ * include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (setFont): New native method.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (updateBufferedImage): Fix some errors.
+
+2006-06-01 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java: Minor source code style
+ fixes,
+ * javax/swing/plaf/basic/BasicDirectoryModel.java: Likewise,
+ * javax/swing/plaf/basic/BasicFileChooserUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicIconFactory.java: Likewise,
+ * javax/swing/plaf/basic/BasicListUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicRootPaneUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicSpinnerUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise,
+ * javax/swing/plaf/basic/BasicTextAreaUI.java: Likewise.
+
+2006-06-01 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComboBox.java: Minor source code formatting fixes,
+ * javax/swing/JEditorPane.java: Likewise,
+ * javax/swing/JFormattedTextField.java: Likewise,
+ * javax/swing/JLayeredPane.java: Likewise,
+ * javax/swing/JScrollPane.java: Likewise,
+ * javax/swing/JSlider.java: Likewise,
+ * javax/swing/JSpinner.java: Likewise,
+ * javax/swing/JTree.java: Likewise,
+ * javax/swing/JViewport.java: Likewise,
+ * javax/swing/UIDefaults.java: Likewise,
+ * javax/swing/UIManager.java: Likewise.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (BufferedImageGraphics): Cache surfaces.
+ (updateBufferedImage): Copy directly for certain color models.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Reimplement.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (setPixels): Don't swap, correct size.
+
+2006-05-31 Anthony Green <green@redhat.com>
+
+ PR 27828
+ * java/net/InetSocketAddress.java: Defer getting the host
+ name until somebody calls InetSocketAddress.getHostName().
+ Fix "represenation" typo.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (updateBufferedImage): Simplify.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (getPixels): Don't swap.
+
+2006-06-01 Sven de Marothy <sven@physto.se>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (setGradient): Reimplement.
+
+2006-06-01 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/cairographics2d.h: Rename/prefix function
+ CairoGraphics2D_getCairoT to cp_gtk_get_cairo_t correctly.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_drawSurface): Rename function
+ CairoGraphics2D_getCairoT to cp_gtk_get_cairo_t.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout):
+ Likewise.
+
+2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/table/JTableHeader.java
+ (getColumnHeaderRenderer): New method,
+ (getAccessibleColumnHeaderRenderer): Delegate part to new
+ getColumnHeaderRenderer() method,
+ (getLocale): Implemented.
+
+2006-05-31 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (cp_gtk_grab_current_drawable): Rename
+ cp_java_awt_peer_gtk_ComponentGraphics_grab_current_drawable to
+ cp_gtk_grab_current_drawable, remove static declaration.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState): Renamed above
+ function.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c:
+ Remove prototype of
+ cp_java_awt_peer_gtk_ComponentGraphics_grab_current_drawable.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_getPixbuf): Rename
+ function.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_copyPixbuf): Likewise.
+ * native/jni/gtk-peer/gtkpeer.h: Add prototype for
+ cp_gtk_grab_current_drawable here.
+
+2006-05-31 Sven de Marothy <sven@physto.se>
+
+ Should fix PR 27835
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (updateBufferedImage): Keep within image bounds.
+
+2006-05-31 Thomas Fitzsimmons <fitzsim@redhat.com>
+ Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.ac: Check for libXrender when the GTK peers are
+ enabled, and set HAVE_XRENDER accordingly. Add -lXrender to
+ X_EXTRA_LIBS.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender)
+ [HAVE_XRENDER]: Call XRenderQueryExtension conditionally.
+
+2006-05-31 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicProgressBarUI.java
+ (paintString): Implemented to paint the string vertically.
+
+2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTable.java
+ (AccessibleJTable.AccessibleJTable()): Check for null editor,
+ (AccessibleJTable.getAccessibleRole()): Overridden to return correct
+ value,
+ (AccessibleJTable.getAccessibleTable()): Likewise,
+ (getAccessibleContext): Create new context if required.
+
+2006-05-31 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTabbedPane.java
+ (AccessibleJTabbedPane.stateChanged): Implemented.
+ (Page.getAccessibleStateSet): Implemented.
+ (Page.getAccessibleIndexInParent): Implemented.
+ (getAccessibleContext): Add AccessibleJTabbedPane object
+ as ChangeListener to the JTabbedPane.
+
+2006-05-31 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JMenuItem.java
+ (getAccessibleContext): Register accessible object as ChangeListener
+ to the JMenuItem.
+ (AccessibleJMenuItem.armed): New field.
+ (AccessibleJMenuItem.focusOwner): New field.
+ (AccessibleJMenuItem.pressed): New field.
+ (AccessibleJMenuItem.selected): New field.
+ (stateChanged): Implemented.
+
+2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/ListSelectionModel.java: Added API docs all over.
+
+2006-05-31 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/swing/FillRect.java
+ (paintComponent): Optionally paint lines rather than rectangles.
+ (createContent): Added option to test line painting.
+
+2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/event/EventListenerList.java
+ (getListenerList): Updated API docs.
+
+2006-05-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Clip scaled image to dest rectangle.
+
+2006-05-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoSurface.java:
+ (CairoSurface): Convert pixels properly.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ Remove commented-out lines.
+
+2006-05-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (drawImage): Use Toolkit to convert to BufferedImage.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (CairoSurface(GtkImage)): New Constructor.
+ (getBufferedImage): New method.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ Don't fill background - FIXME.
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java:
+ Remove unused methods.
+ * gnu/java/awt/peer/gtk/GtkImage.java:
+ (pixbuflock): New field. Methods change to use this lock.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java
+ (createImage): Use Cairo-backed surfaces via GtkImage instead of
+ GtkPixbufDecoder.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (setPixels): Correct length in bytes.
+
+2006-05-30 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java (static): Call
+ System.loadLibrary unconditionally.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java: Likewise.
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java: Likewise.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java: Likewise.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java: Likewise.
+
+2006-05-30 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative):
+ Mark unused parameters, remove unused variables.
+
+2006-05-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (copyArea): Implemented.
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c:
+ (copyAreaNative): New method.
+
+2006-05-30 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_getPixels): Define i only
+ for non big endian systems.
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_setPixels): Likewise.
+
+2006-05-30 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/TexturePaintContext.java: New file.
+ * java/awt/TexturePaint.java
+ (createContext): Implemented.
+
+2006-05-30 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/table/DefaultTableMode.java: Initialize dataVector
+ field early.
+
+2006-05-30 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/Container.java:
+ (removeAll): Reimplemented, added note.
+
+2006-05-30 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/Container.java:
+ (removeAll): Implemented different removal mechanism, added note.
+
+2006-05-30 Lillian Angel <langel@redhat.com>
+
+ PR 27785
+ * java/awt/Component.java:
+ (translateEvent): Added handling to translate WindowEvents
+ * java/awt/Window.java:
+ Removed unneeded imports.
+
+2006-05-30 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Add
+ cairographics2d.h.
+
+2006-05-30 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkImage.java: Fix constructor javadoc.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (clearRect): Do not reuse the fg field, call updateColor.
+ (drawRaster): Likewise.
+ (setColor): Call updateColor.
+ (updateColor): New method.
+
+2006-05-30 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/classpath/jcl.h (JLONG_TO_PTR): New macro.
+ (PTR_TO_JLONG): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (getPointer): Use new conversion macros.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_init): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_newCairoContext):
+ Likewise.
+ (setNativeObject): Likewise.
+ (getNativeObject): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (cp_java_awt_peer_gtk_ComponentGraphics_grab_current_drawable):
+ Mark static.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState):
+ Correctly cast XID and pointer values.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_getPixbuf):
+ Mark unused variables.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_copyPixbuf):
+ Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout):
+ Remove unused cairographics2d struct.
+ (_moveTo, _lineTo, _quadTo, _curveTo): Mark arguments const.
+ (Java_gnu_java_awt_peer_gtk_GtkImage_initFromBuffer):
+ Use new conversion macros.
+ * native/jni/midi-dssi/dssi_data.h: Move conversion macros to jcl.h.
+
+2006-05-30 Mark Wielaard <mark@klomp.org>
+
+ * include/Makefile.am (gnu_java_nio_VMChannel.h): Added.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (copy): Do not reuse the fd field.
+ (setColor): Do not set the color if the parameter
+ matches fd field.
+ (translate(double, double): Rewritten to use
+ AffineTransform.translate.
+
+2006-05-30 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
+ * include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
+ New files.
+ * include/Makefile.am
+ * native/jni/gtk-peer/Makefile.am
+ Add new files.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (getSharedGtkImage): New method.
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ Fix copyArea.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ Support a non-xrender context.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ Plug memory leak.
+ * gnu/java/awt/peer/gtk/GtkImage.java
+ * include/gnu_java_awt_peer_gtk_GtkImage.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (initFromBuffer): New method.
+ * native/jni/gtk-peer/gtkpeer.h:
+ Remove declarations of previouslyremoved methods.
+
+2006-05-29 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * tools/Makefile.am [FOUND_CACAO] (LIBJVM): Define to -ljvm.
+
+2006-05-29 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_init): Mark unused
+ arguments.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_setPixels): Declare size
+ early. Remove unused return statement in void function.
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_newCairoContext): Declare
+ ptr early.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender): Mark
+ unused arguments.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState): Likewise.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing):
+ Likewise.
+ (Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing):
+ Likewise.
+
+2006-05-29 Sven de Marothy <sven@physto.se>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (setPixels): Remove superfluous return statement.
+
+2006-05-29 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ * gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+ * include/gnu_java_awt_peer_gtk_CairoSurface.h
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ * native/jni/gtk-peer/cairographics2d.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ New files.
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
+ Removed
+
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (releasePeerGraphicsResource): Moved to Font peer class.
+
+ * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
+ (createGraphics): Use new context classes.
+
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java:
+ Use native BufferedImages where possible.
+
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java
+ * include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ Move GdkGraphics2D.drawGdkTextLayout to the GdkTextLayout class,
+ renamed to cairoDrawGdkTextLayout.
+
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java
+ (getGraphics): Use ComponentGraphics context.
+ (createImage): Use native BufferedImage.
+
+ * gnu/java/awt/peer/gtk/GtkImage.java:
+ * include/gnu_java_awt_peer_gtk_GtkImage.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ Remove pixmap support. (GtkImage(int, int) constructor, getGraphics)
+ Remove drawing methods.
+
+ * gnu/java/awt/print/JavaPrinterGraphics.java:
+ Use CairoSurface instead of GtkImage.
+
+ * include/Makefile.am
+ * native/jni/gtk-peer/Makefile.am
+ Update for new files.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+ Remove superfluous GtkImage code for GdkPixmaps.
+
+ * native/jni/gtk-peer/gtkpeer.h
+ Remove graphics2d structure.
+
+2006-05-29 Mark Wielaard <mark@klomp.org>
+
+ * java/io/ObjectStreamConstants.java: Removed double declaration
+ of SC_ENUM.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (copying constructor):
+ Do not reuse fg in the constructor.
+
+2006-05-29 Carsten Neumann <cn-develop@gmx.net>
+
+ * java/io/ObjectStreamConstants.java: Added API docs.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (setColor):
+ Take no action if this color is already set.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (translate):
+ Rewritten.
+ * examples/gnu/classpath/examples/swing/FillRect.java (paintComponent):
+ Optionally paint with translation. (createContent): Added option
+ to test painting with translation
+
+2006-05-29 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (FileHandler): Set the instance field
+ pattern to the default value when null.
+ Pass field pattern, and not parameter with same name to createFileStream.
+
+2006-05-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/OperatingSystemMXBeanImpl.java:
+ New class implementing the OS bean.
+ * gnu/java/lang/management/package.html:
+ New file to document the gnu.java.lang.management package.
+ * java/lang/management/ManagementFactory.java:
+ New class to provide access to the OS bean.
+ * java/lang/management/OperatingSystemMXBean.java:
+ New interface.
+ * java/lang/management/package.html:
+ New file to document the java.lang.management package.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java (GKR): New constant.
+ (JKS): Likewise.
+ (LIB): Likewise.
+ (SECURITY): Likewise.
+ (CACERTS): Likewise.
+ (CACERTS_GKR): Likewise.
+ (gkrCaCertsPathName): New field.
+ (jksCaCertsPathName): Likewise.
+ (selfSignedCertificate): Likewise.
+ (start): Initialize trusted certificate key stores if -trustcacerts is
+ specified.
+ (ensureReplyIsOurs): Initialize selfSignedCertificate.
+ (orderChain): Implemented.
+ (findTrustAndUpdate): Check a cacerts.gkr (GKR) and a cacert (JKS) trusted
+ certificate key stores if -trustcacerts option is specified.
+ (findTrustInCACerts): Removed.
+ (getCertPathParameters): New method.
+ (validate): New method.
+ * resource/gnu/classpath/tools/keytool/messages.properties: Added message.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (PROPERTY_PREFIX): New constant.
+ (PATTERN_KEY): Likewise.
+ (DEFAULT_PATTERN): Likewise.
+ (LIMIT_KEY): Likewise.
+ (DEFAULT_LIMIT): Likewise.
+ (COUNT_KEY): Likewise.
+ (DEFAULT_COUNT): Likewise.
+ (APPEND_KEY): Likewise.
+ (DEFAULT_APPEND): Likewise.
+ (FileHandler()): Use pattern value as set in logging.properties.
+ Use constants defined above.
+ (FileHandler(1)): Use constants defined above.
+ (FileHandler(2)): Likewise.
+ (FileHandler(3)): Likewise.
+ (FileHandler(4)): Likewise.
+ (createFileStream): Likewise.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java: Reverted previous patch.
+ * java/util/logging/LogManager.java: Likewise.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (PATTERN_KEY): New constant.
+ (DEFAULT_PATTERN): Likewise.
+ (FileHandler()): Use configured pattern property if any; otherwise use a
+ default value as per RI documentation.
+ * java/util/logging/LogManager.java (getStringProperty): New method.
+
+2006-05-27 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * NEWS: Announce libjawtgnu.so-to-libjawt.so rename.
+
+2006-05-27 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac (FOUND_CACAO): New automake conditional.
+ Add --enable-tool-wrappers.
+ * NEWS: Introduce the --enable-tool-wrappers option.
+ * tools/Makefile.am[CREATE_WRAPPERS]: Build wrapper binaries.
+ * tools/appletviewer.c: Remove file. Make tool-indepedent and
+ rename ...
+ * tools/toolwrapper.c: New file.
+
+2006-05-27 Dalibor Topic <robilad@kaffe.org>
+
+ * java/awt/Graphics2D.java: Use full class name for
+ PrinterJob in javadoc.
+
+2006-05-27 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/qt-peer/eventmethods.h (callVoidMethod): Silence warning.
+ (callMouseMethod): Likewise.
+
+2006-05-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * native/jni/java-net/java_net_VMURLConnection.c:
+ Fix function declarations to specify unused parameters.
+ * scripts/check_jni_methods.sh:
+ Remove copies of the same function using uniq.
+
+2006-05-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * vm/reference/java/net/VMURLConnection.java:
+ Make package-private and final.
+
+2006-05-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/swing/TableDemo.java
+ (TModed): Added editor for the icons column.
+ (createContent): Increase the row height by 2 px.
+
+2006-05-26 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27685:
+ * java/math/BigInteger.java (modPow): Correctly handle negative
+ exponent.
+
+2006-05-26 Tom Tromey <tromey@redhat.com>
+
+ * configure.ac: Check for magic.h and -lmagic.
+ * vm/reference/java/net/VMURLConnection.java: New file.
+ * include/java_net_VMURLConnection.h: New file.
+ * include/Makefile.am (H_FILES): Add VMURLConnection.h.
+ ($(top_srcdir)/include/java_net_VMURLConnection.h): New target.
+ * native/jni/java-net/Makefile.am (libjavanet_la_SOURCES):
+ Mention new file.
+ (libjavanet_la_LIBADD): Add $(LIBMAGIC).
+ * native/jni/java-net/java_net_VMURLConnection.c: New file.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * tools/Makefile.am (installcheck-binSCRIPTS): Do nothing.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jawt/Makefile.am (nativeexeclib_LTLIBRARIES): Rename
+ libjawtgnu.la libjawt.la.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove
+ gtkcairopeer.h.
+
+2006-05-25 Lillian Angel <langel@redhat.com>
+
+ PR 26174
+ * java/awt/Window.java
+ (Window): Moved code to helper.
+ (addWindowFocusListener): New function. Handles focus
+ listener code. Added code to handle focus lost/gained
+ from the window.
+
+2006-05-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * configure.ac:
+ Make pkg-config check for GTK+ >= 2.8.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (flush): Remove debugging printfs.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (schedule_flush): New function.
+ (end_drawing_operation): Call schedule_flush.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * examples/gnu/classpath/examples/swing/Demo.java: Add FillRect
+ paint performance demo.
+ * examples/gnu/classpath/examples/swing/FillRect.java: New file.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * INSTALL: Bump GTK requirement to 2.8 or higher. Do not mention
+ Cairo version requirement. Do not mention --enable-gtk-cairo
+ configure option.
+ * NEWS: Add entry for GdkGraphics2D.
+ * configure.ac: Remove --enable-gtk-cairo and explicit checks for
+ Cairo library and headers.
+ * .externalToolBuilders/Configure.launch: Remove
+ --enable-gtk-cairo from configure line.
+ * gnu/classpath/Configuration.java.in (GTK_CAIRO_ENABLED): Remove
+ field.
+ * gnu/java/awt/BitwiseXORComposite.java: Fix javadoc typo.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c : Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Remove.
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Remove
+ Unlocked method variants. Remove GTK_CAIRO_ENABLED and
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java: Remove instanceof
+ Graphics2D check. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+ (realize): Remove method.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (isRealized): Remove method.
+ (realize): Implement as a native method. Remove useGraphics2D
+ references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkImage.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Replace
+ GdkGraphics references with GdkGraphics2D references.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * include/Makefile.am (GTKPEER_H_FILES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.h.
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics.h: Remove.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Likewise.
+ * native/jawt/Makefile.am (AM_LDFLAGS): Remove CAIRO_LIBS.
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.c. Include
+ gnu_java_awt_peer_gtk_GdkGraphics2D.c unconditionally.
+ (AM_LDFLAGS): Remove CAIRO_LIBS.
+ (AM_CFLAGS): Remove CAIRO_CFLAGS.
+ * native/jni/gtk-peer/gtkcairopeer.h: Remove. Move declarations
+ to ...
+ * native/jni/gtk-peer/gtkpeer.h: Add Graphics2D declarations.
+
+2006-05-25 Lillian Angel <langel@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked):
+ Added check to prevent assertion error. If widget->window is null, then
+ use the parent widget's window to set the cursor on.
+
+2006-05-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java (TreeCancelEditingAction):
+ Implemented.
+
+2006-05-24 Lillian Angel <langel@redhat.com>
+
+ * tools/gnu/classpath/tools/appletviewer/AppletTag.java
+ (prependCodeBase): Added check to determine if the documentbase
+ points to a directory or a file.
+
+2006-05-24 Sven de Marothy <sven@physto.se>
+
+ * java/awt/dnd/DragGestureRecognizer.java
+ (resetRecognizer): Implement.
+ (fireDragGestureRecognized): Implement.
+
+2006-05-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java: Marked stub methods and
+ fixed source code formatting.
+
+2006-05-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JTable.java (valueChanged): If is editing, stop editing.
+
+2006-05-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ Reported by Antony Balkisson.
+ * javax/swing/JTable.java (selectAll): Return without action
+ if the table is empty.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/swing/TableDemo.java:
+ (SliderCell): New inner class. (setCustomEditors,
+ setInformativeHeaders): New fields. (createContent):
+ Rewritten.
+ * javax/swing/DefaultCellEditor.java
+ (JComboBoxDelegate.shouldSelectCell): New method.
+ * javax/swing/JTable.java (editCellAt): Call shouldSelectCell.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (MouseInputHandler.mouseClicked): Start editing on a single
+ click if the cell editor is not a default cell editor.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/naming/CompositeName.java,
+ javax/swing/naming/CompoundName.java:
+ Documented.
+
+2006-05-23 Archie Cobbs <archie@dellroad.org>
+
+ * vm/reference/java/lang/VMClassLoader.java: fix static initializer
+ ordering problem.
+
+2006-05-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/tree/AbstractLayoutCache.java: Coding style fixes,
+ * javax/swing/tree/DefaultMutableTreeNode.java: Likewise,
+ * javax/swing/tree/DefaultTreeCellRenderer.java: Likewise,
+ * javax/swing/tree/DefaultTreeModel.java: Likewise,
+ * javax/swing/tree/DefaultTreeSelectionModel.java: Likewise,
+ * javax/swing/tree/ExpandVetoException.java: Likewise,
+ * javax/swing/tree/FixedHeightLayoutCache.java: Likewise,
+ * javax/swing/tree/RowMapper.java: Likewise,
+ * javax/swing/tree/TreeNode.java: Likewise,
+ * javax/swing/tree/TreeSelectionModel.java: Likewise,
+ * javax/swing/tree/VariableHeightLayoutCache.java: Likewise.
+
+2006-05-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/tree/DefaultTreeCellRenderer.java
+ (DefaultTreeCellRenderer): Changed key for
+ setBackgroundNonSelectionColor(),
+ plus API docs all over.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27680
+ * javax/swing/JTable.java (booleanInvertingEditor): New field.
+ (defaultEditorsByColumnClass, defaultRenderersByColumnClass):
+ Initialise in constructor. (columnMoved): Cancel editing.
+ (createDefaultEditors): Rewritten. (editCellAt):
+ Just invert the value if this is a boolean cell.
+ (initialiseLocalVars): Do not initialise renderer and editor tables.
+ (setUI): Create editors and renderers here.
+
+2006-05-23 Robert Schuster <robertschuster@fsfe.org>
+
+ * examples/gnu/classpath/examples/awt/Demo.java:
+ (MainWindow.MainWindow): Added ResolutionWindow and FullscreenWindow
+ instance as subframe.
+ (ResolutionWindow): New inner class.
+ (FullscreenWindow): New inner class.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27680
+ * javax/swing/JTable.java (BooleanCellRenderer, IconCellRenderer):
+ Set horizontal alignment to centered.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/accessibility/AccessibleContext.java
+ (getAccessibleComponent): Fixed typo in docs,
+ * javax/swing/JLabel.java:
+ (AccessibleJLabel.getAccessibleName): Check for explicit
+ accessibleName,
+ * javax/swing/JTableHeader.java
+ (AccessibleJTableHeaderEntry.columnIndex): New field,
+ (AccessibleJTableHeaderEntry.parent): New field,
+ (AccessibleJTableHeaderEntry.table): New field,
+ (AccessibleJTableHeaderEntry.AccessibleJTableHeaderEntry()):
+ Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleColumnHeaderRenderer): New
+ utility method,
+ (AccessibleJTableHeaderEntry.addFocusListener): Implemented,
+ (AccessibleJTableHeaderEntry.addPropertyChangeListener): Implemented,
+ (AccessibleJTableHeaderEntry.contains): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleAction): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleAt): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleChild): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleChildrenCount): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleComponent): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleContext): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleDescription): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleIndexInParent): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleName): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleRole): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleSelection): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleStateSet): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleText): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleValue): Implemented,
+ (AccessibleJTableHeaderEntry.getBackground): Implemented,
+ (AccessibleJTableHeaderEntry.getBounds): Implemented,
+ (AccessibleJTableHeaderEntry.getCursor): Implemented,
+ (AccessibleJTableHeaderEntry.getFont): Implemented,
+ (AccessibleJTableHeaderEntry.getFontMetrics): Implemented,
+ (AccessibleJTableHeaderEntry.getForeground): Implemented,
+ (AccessibleJTableHeaderEntry.getLocation): Implemented,
+ (AccessibleJTableHeaderEntry.getLocationOnScreen): Implemented,
+ (AccessibleJTableHeaderEntry.getSize): Implemented,
+ (AccessibleJTableHeaderEntry.isEnabled): Implemented,
+ (AccessibleJTableHeaderEntry.isFocusTraversable): Implemented,
+ (AccessibleJTableHeaderEntry.isShowing): Implemented,
+ (AccessibleJTableHeaderEntry.isVisible): Implemented,
+ (AccessibleJTableHeaderEntry.removeFocusListener): Implemented,
+ (AccessibleJTableHeaderEntry.removePropertyChangeListener):
+ Implemented,
+ (AccessibleJTableHeaderEntry.requestFocus): Implemented,
+ (AccessibleJTableHeaderEntry.setAccessibleDescription): Implemented,
+ (AccessibleJTableHeaderEntry.setAccessibleName): Implemented,
+ (AccessibleJTableHeaderEntry.setBackground): Implemented,
+ (AccessibleJTableHeaderEntry.setBounds): Implemented,
+ (AccessibleJTableHeaderEntry.setCursor): Implemented,
+ (AccessibleJTableHeaderEntry.setEnabled): Implemented,
+ (AccessibleJTableHeaderEntry.setFont): Implemented,
+ (AccessibleJTableHeaderEntry.setForeground): Implemented,
+ (AccessibleJTableHeaderEntry.setLocation): Implemented,
+ (AccessibleJTableHeaderEntry.setSize): Implemented,
+ (AccessibleJTableHeaderEntry.setVisible): Implemented,
+ (AccessibleJTableHeader.getAccessibleRole): Implemented,
+ (AccessibleJTableHeader.getAccessibleChildrenCount): Implemented,
+ (AccessibleJTableHeader.getAccessibleChild): Implemented,
+ (AccessibleJTableHeader.getAccessibleAt): Implemented.
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * NEWS: Updated.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getAccessibleName): New method (override),
+ (setLabelFor): Fire 'labelFor' property change event before other
+ events.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getAccessibleRole): New method (override).
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * resource/gnu/classpath/tools/serialver/messages.properties: New
+ file.
+ * tools/gnu/classpath/tools/serialver/Messages.java: New file.
+ * tools/gnu/classpath/tools/serialver/SerialVer.java (classes): New
+ field.
+ (classpath): Likewise.
+ (run): New method.
+ (main): Use it.
+ (addFileURL): New method.
+ (getClassLoader): Likewise.
+ (printMessage): Likewise.
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/serialver/SerialVer.java: New file.
+
+2006-05-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JTable.java (doLayout): In the column
+ resize mode, only repaing the changed part of the table.
+ (getLeftResizingBoundary): New method.
+
+2006-05-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/spi/InitialContextFactory.java,
+ javax/naming/spi/InitialContextFactoryBuilder.java,
+ javax/naming/spi/NamingManager.java,
+ javax/naming/spi/ObjectFactory.java,
+ javax/naming/spi/ResolveResult.java,
+ javax/naming/spi/Resolver.java,
+ javax/naming/spi/StateFactory.java: Documented.
+
+2006-05-21 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27688:
+ * tools/gnu/classpath/tools/jar/Extractor.java (allItems): Now
+ a WorkSet.
+ (initSet): Removed.
+ (shouldExtract): Removed.
+ (run): Updated.
+ * tools/gnu/classpath/tools/jar/WorkSet.java: New file.
+ * tools/gnu/classpath/tools/jar/Lister.java (readUntilEnd): New
+ method.
+ (listJar): Use it.
+ (allItems): New field.
+ (run): Initialize it.
+ (listJar): Use it.
+
+2006-05-22 Sven de Marothy <sven@physto.se>
+
+ * java/nio/CharBuffer.java
+ (wrap): Fix bounds checking.
+
+2004-08-26 Tom Tromey <tromey@redhat.com>
+
+ * java/io/OutputStream.java
+ (OutputStream): Implements Closeable, Flushable.
+
+2006-04-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/io/ObjectOutputStream.java:
+ (writeObject(Object)): Added enum support.
+ (writeClassDescriptor(ObjectStreamClass)): Likewise.
+ * java/io/ObjectStreamClass.java:
+ (isEnum()): New package-private method.
+ (setFlags(Class)): Added enum support.
+ * java/io/ObjectStreamConstants.java:
+ (SC_ENUM): Added.
+
+2006-03-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/io/ObjectInputStream.java:
+ (parseContent(byte)): Added enum support.
+ * java/io/ObjectStreamConstants.java:
+ (TC_ENUM): Added.
+ (TC_MAX): Changed to new maximum, TC_ENUM.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (instantiateChild(String)): Implemented.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (add(Object)): Add further documentation.
+ (isEmpty()): Documented.
+ (propertyChange(PropertyChangeEvent)): Implemented.
+ (remove(Object)): Documented.
+ (remove(Object,boolean)): Documented and implemented.
+ (vetoableChange(PropertyChangeEvent)): Marked as
+ implemented (only subclasses appear to need this).
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (add(Object)): Implement support for the child being
+ a BeanContextChild.
+ (avoidingGui()): Implemented.
+ (dontUseGui()): Likewise.
+ (needsGui()): Likewise.
+ (okToUseGui()): Likewise.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Context.java,
+ javax/naming/ContextNotEmptyException.java,
+ javax/naming/Reference.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/MinimalHTMLWriter.java
+ (writeComponent, writeImage): Declare that the method
+ may throw the IOException.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 26972
+ * javax/naming/InitialContext.java (colon_list): Changed type to
+ hashset. (use_properties): New field. (init(Hashtable)): Rewritten.
+ (merge): Rewritten.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/InitialContext.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/NameParser.java,
+ javax/naming/NamingEnumeration.java,
+ javax/naming/PartialResultException.java,
+ javax/naming/SizeLimitExceededException.java,
+ javax/naming/spi/ObjectFactory.java,
+ javax/naming/spi/ObjectFactoryBuilder.java: Documented.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/net/loader/JarURLLoader.java:
+ Use Map.Entry instead of LinkedHashMap.Entry
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Context.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Referenceable.java: Documented.
+ * javax/naming/spi/NamingManager.java: Documented.
+
+2006-05-21 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * doc/tools.texinfo: Replaced references to MessageBundle.properties
+ to messages.properties.
+ * resource/gnu/classpath/tools/jarsigner/MessageBundle.properties:
+ Renamed to messages.properties.
+ * resource/gnu/classpath/tools/keytool/MessageBundle.properties:
+ Likewise.
+ * resource/gnu/classpath/tools/jarsigner/messages.properties:
+ Renamed from MessageBundle.properties.
+ Added copyright notice.
+ * resource/gnu/classpath/tools/keytool/messages.properties:
+ Likewise.
+ * tools/gnu/classpath/tools/jarsigner/Messages.java
+ (BUNDLE_NAME): Use messages instead of MessageBundle properties file.
+ (getFormattedString): Fixed a spelling mistake.
+ * tools/gnu/classpath/tools/keytool/Messages.java: Likewise.
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/font/opentype/NameDecoder.java
+ Made class public.
+ (getName): Use getShort instead of getChar(), fix PS name.
+ (decodeName): New method.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getSubFamilyName): Implement.
+ (getPostScriptName): Use the NameDecoder class instead.
+ (parsePSName): Removed.
+ (getName): Added
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getTrueTypeTable): New native method.
+ (getPostScriptName): Reimplement.
+ (parsePSName): New method.
+ (getNumGlyphs): Implement.
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: New native method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+ (Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable):
+ New function. File is now explicitly dependent on FT2.
+
+2006-05-20 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/native2ascii/Messages.java: New file.
+ * resource/gnu/classpath/tools/native2ascii/messages.properties: New
+ file.
+ * tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
+ (HandleFile): New class.
+ (input, output, encoding, reversed): New fields.
+ (createParser): New method.
+ (run): Likewise.
+ (main): Use 'run'.
+ * tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
+ (notifyFile): Throws OptionException.
+
+2006-05-20 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/native2ascii/Native2ASCII.java: New file,
+ from cp-tools.
+
+2006-05-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c:
+ (JCL_print_buffer): Fix to work with -Werror on 64-bit
+ platforms.
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * java/awt/Font.java (getNumGlyphs): Call correct peer method.
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/print/JavaPrinterJob.java
+ (print): Use PostScriptGraphics2D.
+ * gnu/java/awt/print/PostScriptGraphics2D.java: New file.
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/text/html/MinimalHTMLWriter.java: New file
+
+2006-05-20 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/java/security/OID.java: Updated copyright year.
+ (OID): Removed unused Javadoc param tag.
+ * gnu/java/security/prng/PRNGFactory.java: Removed unused import.
+ * gnu/java/security/hash/MD4.java: Fixed a Javadoc link.
+
+2006-05-20 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/jce/keyring/GnuKeyring.java (engineAliases):
+ Formatting.
+ Added trace/debug statements.
+ (engineSetCertificateEntry): Ensure alias is not already used for a Key
+ Entry. Also ensure that any previous entry for this alias is removed
+ before a new one is added.
+ (engineGetKey): Do not trace/log passwords.
+ Trace key's class name only.
+ (engineSetKeyEntry): Ensure alias is not alredy used for a Trusted
+ Certificate Entry. Also ensure that previous entry for this alias is
+ removed before a new one is added.
+ (engineLoad): Do not trace/log passwords.
+ (engineStore): Likewise.
+ (engineSize): Use size of enumeration instead of collection size.
+
+2006-05-20 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/javax/crypto/keyring/PrivateKeyEntry.java: Formatting.
+ (toString): New method.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java (decrypt):
+ Do not trace/log passwords.
+ Set masked to false before decoding envelope.
+ Do not set payload to null.
+ (encrypt): Set masked to true.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java (verify):
+ Do not trace/log passwords.
+ Set masked to false before decoding envelope.
+ Do not set payload to null.
+ Added trace/debug statements.
+ (authenticate): Do not trace/log passwords.
+ Set masked to true.
+ Added trace/debug statements.
+ (getMac): Added trace/debug statements.
+ * gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java
+ (remove(String)): Changed the signature to return a boolean.
+ (toString): New method.
+ * gnu/javax/crypto/keyring/GnuPublicKeyring.java (containsCertificate):
+ Formatting
+ (getCertificate): Likewise.
+ (putCertificate): Likewise.
+ (load): Likewise.
+ Do not trace/log passwords.
+ (store): Likewise.
+ * gnu/javax/crypto/keyring/GnuPrivateKeyring.java (getPrivateKey):
+ Do not trace/log passwords.
+ Added more trace/logging statements.
+ (putPrivateKey): Do not trace/log passwords.
+ Trace only key's class name.
+ Formatting.
+ (containsPublicKey): Formatting.
+ (getPublicKey): Likewise.
+ Trace only key's class name.
+ (putPublicKey): Trace only key's class name.
+ (containsCertPath): Formatting.
+ (getCertPath): Likewise.
+ (putCertPath): Likewise.
+ (load): Do not trace/log passwords.
+ Formatting.
+ (store): Likewise.
+ * gnu/javax/crypto/keyring/EnvelopeEntry.java (log): New field.
+ (add): Do not set payload to null.
+ Added trace/debug statements.
+ (containsAlias): Added trace/debug statements.
+ (get): Likewise.
+ (remove(Entry)): Likewise.
+ (remove(String)): Likewise.
+ Changed the signature to return a boolean.
+ Do not set payload to null unless really removed.
+ (toString): New method.
+ (decodeEnvelope): Clear entries before proceeding.
+ (makeAliasList): Added trace/debug statements.
+ Ensure only non-null aliases and alias-lists are added.
+ * gnu/javax/crypto/keyring/Entry.java (log): New field.
+ (TYPES): New constant.
+ (toString): New method.
+ (defaultDecode): Add trace/debug statement.
+
+2006-05-20 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/ListCmd.java (rfc):
+ Increased visibility.
+ (setup): Do not trace/log passwords.
+ (parsed): Was not setting correct (rfc) field; fixed.
+ (print1Chain): Formatting.
+ * tools/gnu/classpath/tools/keytool/DeleteCmd.java (setup):
+ Do not trace/log passwords.
+ * tools/gnu/classpath/tools/keytool/ExportCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/GenKeyCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/KeyCloneCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/StorePasswdCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java (setup): Likewise.
+ (orderChain): Added FIXME.
+ * tools/gnu/classpath/tools/keytool/CertReqCmd.java (setup):
+ Do not trace/log passwords.
+ Removed commented out code.
+ * tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/SelfCertCmd.java (setup): Likewise.
+ * tools/gnu/classpath/tools/keytool/Command.java (doCommand): Formatting.
+ (setKeystoreURLParam): Likewise.
+ (setKeystorePasswordParam): Do not trace/log passwords.
+ (saveKeyStore): Likewise.
+
+2006-05-19 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ Added class docs.
+ (pixel): Removed obsolete field.
+ (draw(Shape)): Removed commented out code.
+ (drawImage): Formatting.
+ (drawString): Added optimization hook.
+ (setPaint): Removed rawSetForeground().
+ (getFontRenderContext): Return context with correct transform.
+ (drawGlyphVector): Draw complete outline in one go.
+ (copyArea): Added optimization hook.
+ (clearRect): Added optimization hook.
+ (drawImage): Added optimization hook.
+ (fillShape): (Temporarily) Set antialiasing off by default for
+ font rendering. Adjust the shape by some bits to improve rendering.
+ Pass clip bounds to the render methods.
+ (drawPixel): Removed.
+ (rawSetPixel): Removed.
+ (rawSetForeground): Removed.
+ (rawDrawLine): Default impl calls standard pipeline.
+ (rawDrawString): New method, calls standard pipeline for rendering.
+ (rawClearRect): New method, calls standard pipeline for rendering.
+ (rawFillRect): New method, calls standard pipeline for rendering.
+ (rawDrawImage): New method, calls standard pipeline for rendering.
+ (rawCopyArea): New method.
+ (copyAreaImpl): New method.
+ (rawFillShape): Renamed to fillShapeImpl(). Small optimization
+ for rendering.
+ (fillShapeAntialias): Fixed AA rendering.
+ (fillScanlineAA): Fixed AA rendering.
+ (getSegments): Take offset into account.
+
+2006-05-19 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/text/AbstractWriter.java
+ (getText): Fix parameters (start, length) not (start, end).
+
+2006-05-19 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27444:
+ * gnu/java/net/loader/URLLoader.java (getClassPath): Documented.
+ Changed return type.
+ * java/net/URLClassLoader.java (urlloaders): Removed.
+ (addURLImpl): Updated.
+ * gnu/java/net/loader/JarURLLoader.java (initialized): New field.
+ (indexSet): Likewise.
+ (classPath): Changed type.
+ (JarURLLoader): New constructor.
+ (initialize): New method.
+ (getResource): Use index set if it exists.
+ (getClassPath): Updated.
+ * gnu/java/net/IndexListParser.java (IndexListParser): Avoid NPE.
+ (prefixes): New field.
+ (headers): Removed.
+ (IndexListParser): Fill in prefixes.
+ (clearAll): Clear prefixes.
+ (getHeaders): Changed return type.
+
+2006-05-19 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java
+ (MouseInputHandler.mouseExitted): No nothing there.
+ (MouseInputHandler.endDragging): Move column to the
+ first/last position if released outside the horizontal
+ table range.
+
+2006-05-19 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/GlyphVector.java
+ (getGlyphCharIndex): Implemented.
+ (getGlyphCharIndices): Implemented.
+ (getGlyphOutline): Implemented.
+ (getGlyphVisualBounds): Implemented.
+ (getGlyphVisualBounds): Implemented.
+ (getPixelBounds): Implemented.
+ (getLayoutFlags): Implemented.
+
+2006-05-19 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/LightweightDispatcher.java: Added field dragButton and
+ documentation for it.
+ (handleMouseEvent): Rewritten MOUSE_PRESSED case in switch-statement,
+ added subexpression to if-clause in MOUSE_RELEASED case.
+
+2006-05-19 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/metal/MetalButtonUI.java:
+ (update): Removed some subexpression from if-clause and call
+ updateWithGradient.
+ (updateWithGradient): New method.
+
+2006-05-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (findOverlapFreeParent): Implemented algorithm for finding
+ overlapping in component hierarchy.
+
+2006-05-19 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/Thread.java
+ (contextClassLoaderIsSystemClassLoader): New field.
+ (Thread(ThreadGroup,Runnable)): Call createAnonymousThreadName.
+ (Thread(VMThread,String,int,boolean)): Call createAnonymousThreadName
+ and set contextClassLoaderIsSystemClassLoader.
+ (Thread(ThreadGroup,Runnable,String,long)):
+ Set contextClassLoaderIsSystemClassLoader.
+ (createAnonymousThreadName): New method.
+ (getContextClassLoader): Check contextClassLoaderIsSystemClassLoader
+ and fixed security check.
+ (setContextClassLoader): Clear contextClassLoaderIsSystemClassLoader.
+
+2006-05-19 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java:
+ (createNonRolloverBorder): Rewritten.
+ (createRolloverBorder): Rewritten.
+ (setToNonRolloverBorder): Store old border instance in hashtable.
+ (setToRolloverBorder): Store old border instance in hashtable, use
+ AbstractButton instead of JButton in statements.
+ (setBorderToNormal): Rewritten.
+ * javax/swing/plaf/metal/MetalLookAndFeel.java:
+ (initComponentDefaults): Added values for ToolBar.rolloverBorder and
+ ToolBar.nonrolloverBorder.
+
+2006-05-18 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/stream/ImageInputStreamImpl.java: Complete.
+ * javax/imageio/stream/MemoryCacheImageInputStream.java: Likewise.
+
+2006-05-18 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/GlyphMetrics.java
+ (getLSB): Implemented.
+ (getRSB): Implemented.
+
+2006-05-18 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/GraphicAttribute.java:
+ Documented entire class.
+ (GraphicAttribute): Added check for alignment.
+ (getBounds): Implemented.
+ (getJustificationInfo): Implemented.
+
+2006-05-18 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/LightweightDispatcher.java:
+ (handleMouseEvent): Added note, added subexpression to if-statement.
+
+2006-05-18 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java:
+ (navigateFocusedComp): Marked as stub.
+ (createRolloverBorder): Create a different Border instance, added note.
+ * javax/swing/plaf/metal/MetalBorders.java:
+ (ButtonBorder): Added documentation.
+ (ButtonBorder.paintDefaultButtonBorder): Added else-block.
+ (ButtonBorder.paintOceanButtonBorder): Added else-block, added
+ subexpression into if-else cascade, added note.
+
+2006-05-18 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/ShapeGraphicAttribute.java:
+ Documented entire class.
+ (ShapeGraphicAttribute): Initialized bounds field.
+ (draw): Implemented.
+ (equals): Implemented.
+ (getAdvance): Implemented.
+ (getAscent): Implemented.
+ (getBounds): Implemented.
+ (getDescent): Implemented.
+ (hashCode): Implemented.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/CellRendererPane.java
+ (CellRendererPane): Set CellRendererPane to invisible.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics.java
+ (clipRect): Removed old intersection statement.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics.java
+ (clipRect): Don't use Rectangle.intersection() to avoid creating
+ 2 unnecessary Rectangle instances and fix a clipping problem.
+ (computeIntersection): New helper method, adapted from SwingUtilities.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (isCompletelyDirty): Removed.
+ (paint): Don't mark children as clean, this is no longer necessary.
+ (findOverlapFreeParent): Don't stop at Viewports, this breaks
+ painting when something overlaps the viewport (like a popup/menu).
+ * javax/swing/RepaintManager.java
+ (currentRepaintManagers): Made package private to avoid accessor
+ methods.
+ (dirtyComponents): Made private.
+ (dirtyComponentsWork): Made private.
+ (markCompletelyDirty): Fixed bounds of dirtyrect to be
+ component-local not parent-local. Do not set flag in JComponent.
+ (markCompletelyClean): Don't set JComponent flag.
+ (isCompletelyDirty): Rewritten to return true when the complete
+ component is marked dirty.
+ (paintDirtyRegions): Improved parent-merging so that the merged-in
+ components don't get painted too. 'Outsourced' the compilation
+ of the repaint root components.
+ (compileRepaintRoots): New helper method.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ PR 26368
+ * javax/swing/text/GapContent.java
+ (GapContentPosition(int)): Use adapted binarySearch method to
+ allow for having a greater array than number of entries.
+ (numMarks): New field, holds the end of the marks list.
+ (GapContent): Initialize positionMarks with size of 10 instead of 0.
+ (shiftGapStartDown): Adjusted for new setPositionsInRange signature.
+ (shiftGapEndUp): Adjusted for new setPositionsInRange signature.
+ (setPositionsInRange): Changed signature to narrow the purpose and
+ special cases inside. Reimplemented to crunch together equal marks.
+ (adjustPositionsInRange): Added assertion to make sure we do
+ not accidentally change the order of the mark. Added some debug
+ output for a special case of which I don't know if it even exists.
+ (resetMarksAtZero): Made impl simpler.
+ (dumpMarks): New debug helper method.
+ (insertMark): Grow array in bigger chunks to avoid excessive copying.
+ (binarySearch): New method. An adaption of Arrays.binarySearch()
+ that allows for an maxIndex parameter.
+
+2006-05-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/KeyboardManager.java
+ (topLevelLookup): Use WeakHashMap to avoid memory leak.
+
+2006-05-18 Jeroen Frijters <jeroen@frijters.net>
+
+ * gnu/java/net/loader/JarURLLoader.java
+ (JarURLLoader): Use a slightly more efficient URL constructor.
+
+2006-05-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/java/awt/print/JavaPrinterGraphics.java
+ (drawImage(Image, int, int, Color, ImageObserver)): Fix endless loop,
+ (drawImage(Image, int, int, ImageObserver)): Likewise,
+ (drawImage(Image, int, int, int, int, Color, ImageObserver)): Likewise,
+ (drawImage(Image, int, int, int, int, ImageObserver)): Likewise,
+ (drawImage(Image, int, int, int, int, int, int, int, int, Color,
+ ImageObserver)): Likewise,
+ (drawImage(Image, int, int, int, int, int, int, int, int,
+ ImageObserver)): Likewise.
+
+2006-05-17 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/jar/Indexer.java (indexJarFile): Use a
+ LinkedHashSet.
+
+2006-05-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/border/AbstractBorder.java: Source code formatting fixes,
+ * javax/swing/border/BevelBorder.java: Likewise,
+ * javax/swing/border/CompoundBorder.java: Likewise,
+ * javax/swing/border/TitledBorder.java: Likewise.
+
+2006-05-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/table/AbstractTableModel.java: Formatting fixes,
+ * javax/swing/table/DefaultTableModel.java: Likewise,
+ * javax/swing/table/TableCellEditor.java: Likewise,
+ * javax/swing/table/TableCellRenderer.java: Likewise.
+
+2006-05-17 Lillian Angel <langel@redhat.com>
+
+ * java/awt/font/ImageGraphicAttribute.java:
+ Documented entire class.
+ (ImageGraphicAttribute): Changed to call this.
+ (ImageGraphicAttribute): Implemented.
+ (draw): Implemented.
+ (equals): Implemented.
+ (getAdvance): Implemented.
+ (getAscent): Implemented.
+ (getBounds): Implemented.
+ (getDescent): Implemented.
+ (hashCode): Implemented.
+ * javax/swing/text/html/HTMLDocument.java
+ (create): Removed. Sufficent enough for
+ super to be called.
+ (insert): Likewise.
+ (insertUpdate): Likewise.
+ (processHTMLFrameHyperlinkEvent): Marked as stub.
+ (start): Removed FIXME.
+ (end): Likewise.
+ (start): Called super.
+ (end): Called super.
+ (getElement): removed unneeded code.
+ (setParagraphAttribute): Removed. Sufficent enough
+ for super to be called.
+ (fireChangedUpdate): Likewise.
+ (fireUndoableEditUpdate): Likewise.
+
+2006-05-17 Lillian Angel <langel@redhat.com>
+
+ * java/awt/TexturePaint.java:
+ Added documentation for class and all functions.
+ (getTransparency): Implemented.
+
+2006-05-17 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (findTarget): Translate point to child components.
+
+2006-05-17 Roman Kennke <kennke@aicas.com>
+
+ PR 26368
+ * javax/swing/text/GapContent.java
+ (GapContentPosition): Do no more implement Comparable.
+ (GapContentPosition.mark): Removed field.
+ (GapContentPosition.index): New field to hold the index into
+ the positions array.
+ (GapContentPosition(int)): Rewritten to use the new indirection
+ to the positions array.
+ (GapContentPosition.compareTo): Removed.
+ (GapContentPosition.getOffset): Synchronized. Fetch mark from
+ positionMarks array.
+ (WeakPositionComparator): Removed obsolete class.
+ (positions): Changed type to WeakHashMap.
+ (positionMarks): New field, holds the marks of the positions.
+ (GapContent): Initialize new fields.
+ (createPosition): Rewritten to use the new indirection
+ to the positions array.
+ (getPositionsInRange): Rewritten to use the new indirection
+ to the positions array.
+ (setPositionsInRange): Rewritten to use the new indirection
+ to the positions array.
+ (adjustPositionsInRange): Rewritten to use the new indirection
+ to the positions array.
+ (insertMark): New helper method.
+ (clearPositionReferences): Removed obsolete methods.
+
+2006-05-17 Lillian Angel <langel@redhat.com>
+
+ * java/awt/GraphicsConfiguration.java
+ (getImageCapabilities): Implemented.
+ (getBufferCapabilities): Implemented.
+
+2006-05-17 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (focusGained): Implemented.
+ (focusLost): Implemented.
+ (paint): Added code to paint the focus.
+ * javax/swing/plaf/metal/MetalSliderUI.java
+ (paintThumb): Added code to set the thumbColor.
+ (paintFocus): Implemented properly.
+
+2006-05-17 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27383
+ * javax/naming/spi/NamingManager.java (getURLContext):
+ Always search for the factory class in all possible places
+ and use VMStackWalker.
+ (forName): New method.
+
+2006-05-17 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (handleMouseEvent): Fixed search algorithm for finding the
+ mouse event target.
+ (findTarget): Fixed search algorithm for finding the
+ mouse event target.
+
+2006-05-17 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/spi/NamingManager.java: Documented.
+
+2006-05-17 Mark Wielaard <mark@klomp.org>
+
+ * THANKYOU: Add Trevor Linton <tlinton@xmission.com>.
+ * gnu/javax/imageio/jpeg/DCT.java: Cleanup Todo copyright.
+ * gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java: Likewise.
+ * gnu/javax/imageio/jpeg/ZigZag.java: Likewise.
+
+2006-05-17 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR 26947.
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java: Updated copyright
+ year.
+ (BorderListener.mouseClicked): Detect double-clicks in title pane,
+ copied code from
+ BasicInternalFrameTitlePaneUI.MaximizeAction.actionPerformed().
+
+2006-05-17 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR 27626.
+ * java/awt/LightweightDispatcher.java:
+ (handleMouseEvent): Moved assignment into switch-block, added notes.
+
+2006-05-16 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/text/StyleContext.java:
+ Changed staticAttributeKeys to be a Hashtable.
+ (getStaticAttribute): Implemented.
+ (getStaticAttributeKey): Implemented.
+ (readAttributeSet): Implemented.
+ (writeAttributeSet): Added FIXME. Not sure how
+ to implement this.
+ (readAttributes): Implemented.
+ (writeAttributes): Implemented.
+ (registerStaticAttibuteKey): Fixed to add key to
+ the hash table.
+
+2006-05-16 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultButtonModel.java
+ (setGroup): Removed event notification.
+
+2006-05-16 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (installKeyboardActions): Implemented.
+ (uninstallKeyboardActions): Implemented.
+ * javax/swing/plaf/basic/BasicComboPopup.java
+ (uninstallKeyboardActions): Removed FIXME. Nothing
+ to be done here.
+ (installKeyboardActions): Likewise.
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (uninstallKeyboardActions): Implemented.
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Added field for hashColor.
+ Marked stub methods.
+ (getHashColor): Implemented to use field.
+ (setHashColor): Likewise.
+ (getRowX): Implemented.
+ (NodeDimensions.getRowX): Changed to use BasicTreeUI.getRowX.
+
+2006-05-16 Roman Kennke <kennke@aicas.com>
+
+ PR 26521
+ * javax/swing/JTable.java
+ (rowHeights): New field.
+ (initializeLocalVars): Call setRowHeigt instead of rowHeight=,
+ in order to initialize rowHeights correctly.
+ (tableChanged): Nullify rowHeights when model changes. Only
+ create default columns from model when corresponding property
+ is set. Sync table model with rowHeights as appropriate.
+ (valueChanged): Call repaint with the correct rectangle.
+ (rowAtPoint): Handle rowHeights.
+ (getCellRect): Mostly rewritten. Check for boundaries
+ of model and return (0,0,0,0) or (0,0,width,height) when outside.
+ Handle component orientation. Round correctly.
+ (getRowHeight(int)): Implemented for variable row height.
+ (setRowHeight(int,int)): Implemented for variable row height.
+ (setRowHeight(int)): Nullify rowHeights.
+ (setModel): Notify tableChanged().
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (installDefaults): Create rendererPane in installUI.
+ (installUI): Create and install rendererPane.
+ (uninstallUI): Uninstall rendererPane and nullify rendererPane
+ and table.
+ (paint): Correctly handle rowMargin.
+
+2006-05-16 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27563:
+ * java/text/NumberFormat.java (getIntegerInstance): Use
+ "integerFormat", not "numberFormat".
+
+2006-05-16 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JPopupMenu.java
+ (addMenuKeyListener): Implemented.
+ (removeMenuKeyListener): Implemented.
+ (getMenuKeyListeners): Implemented.
+ * javax/swing/ProgressMonitor.java:
+ Added new protected field.
+ (getAccessibleContext): Implemented.
+
+2006-05-16 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JFileChooser.java:
+ Added new private field.
+ (setDragEnabled): Implemented.
+ (getDragEnabled): Implemented.
+
+2006-05-16 Lillian Angel <langel@redhat.com>
+
+ * java/awt/Window.java
+ (applyResourceBundle): Implemented.
+
+2006-05-16 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultButtonModel.java
+ (setSelected): If new SELECTED state is false, clear ARMED and PRESSED
+ states also.
+
+2006-05-16 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JList.java (getSelectedValues):
+ Ask the value for the indexed array element.
+
+2006-05-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (valueChanged): Also repaint when table has only 1 row. Fixed
+ repaint rectangle to span the entire changed rows.
+
+2006-05-16 Roman Kennke <kennke@aicas.com>
+
+ PR 24031
+ * javax/swing/JOptionPane.java
+ (startModal): Rewritten. The events are now dispatched, even
+ when the event dispatch thread gets blocked by the call
+ to this method. Also, mouse events get intercepted outside the
+ internal frame.
+
+2006-05-16 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (BorderListener.mouseDragged):Do not set cursor
+ if the frame is being dragged.
+
+2006-05-16 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (BorderListener): Rewritten. (InternalFrameBorder):
+ Made package private.
+ (InternalFrameBorder.offset):
+ Renamed to cornerSize, made package private.
+ (bSize): Made package private.
+
+2006-05-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JMenu.java
+ (AccessibleJMenu.getAccessibleChildrenCount): Implemented.
+ (AccessibleJMenu.getAccessibleChild): Implemented.
+ (AccessibleJMenu.getAccessibleSelection): Implemented.
+ (AccessibleJMenu.getAccessibleSelection(int)): Implemented.
+ (AccessibleJMenu.isAccessibleChildSelected): Implemented.
+ (AccessibleJMenu.getAccessibleRole): Documented.
+ (AccessibleJMenu.getAccessibleSelectionCount): Implemented.
+ (AccessibleJMenu.addAccessibleSelection): Implemented.
+ (AccessibleJMenu.removeAccessibleSelection): Implemented.
+ (AccessibleJMenu.clearAccessibleSelection): Implemented.
+ (AccessibleJMenu.selectAllAccessibleSelection): Implemented.
+ (createPath): New helper method.
+
+2006-05-15 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLClassLoader.java: Moved inner classes to
+ gnu.java.net.loader.
+ (factoryCache): Changed type.
+ (URL_LOADER_PREFIX): New constant.
+ (URLClassLoader): Updated for new factoryCache.
+ (addURLImpl): Use reflection to search for a loader.
+ (findClass): Use getClass method on URLLoader.
+ (getURLStreamHandler): Removed.
+ * gnu/java/net/loader/URLLoader.java: New file, extracted
+ from URLClassLoader.
+ * gnu/java/net/loader/Resource.java: Likewise.
+ * gnu/java/net/loader/FileResource.java: Likewise.
+ * gnu/java/net/loader/FileURLLoaderjava: Likewise.
+ * gnu/java/net/loader/JarURLLoader.java: Likewise.
+ * gnu/java/net/loader/JarURLResource.java: Likewise.
+ * gnu/java/net/loader/RemoteURLLoader.java: Likewise.
+ * gnu/java/net/loader/RemoteResource.java: Likewise.
+ * gnu/java/net/loader/ULRStreamHandlerCache.java: New file.
+
+2006-05-15 Sven de Marothy <sven@physto.se>
+
+ * native/target/generic/target_generic_network.h:
+ Add a pair of parenthesis.
+
2006-05-15 Mark Wielaard <mark@klomp.org>
- * configure.ac (VERSION): Set to 0.91.
+ * java/awt/Graphics2D.java: Remove PrinterJob import.
+
+2006-05-15 Mark Wielaard <mark@klomp.org>
+
+ * doc/www.gnu.org/announce/20060515.wml: New file.
+ * doc/www.gnu.org/newsitems.txt: Add 0.91 release announcement.
+ * doc/www.gnu.org/downloads/downloads.wml: Add 0.91.
+
+2006-05-15 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * NEWS: Announce inclusion of gcjwebplugin.
+ Announce inclusion of appletviewer.
+ * INSTALL: Note gcjwebplugin dependencies.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/RepaintManager.java (paintDirtyRegions):
+ Break loop as soon as the component repaint is merged
+ with some parent. (ComponentComparator): Removed.
+ (comparator): Removed.
+
+2006-05-15 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/border/TitledBorder.java
+ (paintBorderWithTitle): Fixed indentation.
+
+2006-05-15 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/border/TitledBorder.java
+ (layoutBorderWithTitle): Fetch border using getBorder() instead
+ of using the border field directly. Allows for the use of
+ an UI supplied border in the case when a null border was set.
+ Fixed component orientation.
+ (paintBorderWithTitle): Fetch border using getBorder() instead
+ of using the border field directly. Allows for the use of
+ an UI supplied border in the case when a null border was set.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/RepaintManager.java (paintDirtyRegions): Rewritten.
+ (contains): New method.
+
+2006-05-15 Tom Tromey <tromey@redhat.com>
+
+ * resource/gnu/classpath/tools/jar/messages.properties: Fixed
+ argument indices.
+ * resource/gnu/classpath/tools/getopt/Messages.properties: Fixed
+ argument indices.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JComponent.java (findOverlapParent): Stop loop at
+ JViewport's.
+ * javax/swing/RepaintManager.java (addDirtyRegion): Always add the given
+ region. (paintDirtyRegions): Rewritten.
+
+2006-05-15 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/jar/Main.java (setArchiveFile): Use
+ MessageFormat.
+ * tools/gnu/classpath/tools/jar/Indexer.java (indexJarFile): Use
+ MessageFormat.
+ * tools/gnu/classpath/tools/jar/Extractor.java: Externalized strings.
+ (run): Use MessageFormat.
+ * resource/gnu/classpath/tools/jar/messages.properties: New file.
+ * tools/gnu/classpath/tools/jar/Creator.java: Externalized strings.
+ (writeFile): Use MessageFormat.
+
+2006-05-15 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/awt/Toolkit.java (getDefaultToolkit): Use Class.forName()
+ instead of directly calling the class loader.
+
+2006-05-15 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/Option.java (getDescription):
+ Removed old comment.
+ * tools/gnu/classpath/tools/getopt/ClasspathToolParser.java:
+ Externalized strings.
+ (getVersionString): Use MessageFormat.
+ * tools/gnu/classpath/tools/getopt/Messages.java: New file.
+ * resource/gnu/classpath/tools/getopt/Messages.properties: New file.
+ * tools/gnu/classpath/tools/getopt/Parser.java: Externalized strings.
+ (getArgument): Use a MessageFormat.
+ (handleLongOption): Likewise.
+ (parse): Likewise.
+
+2006-05-15 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR 27197.
+ * javax/swing/text/FieldView.java:
+ (paint): Calculate intersection between clip and allocation area and
+ set that as new clip.
+
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/text/JTextComponent.java: Marked stub methods.
+
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTable.java: Marked stub methods.
+
+2006-05-15 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/jarsigner/Main.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (KEYTOOL_TOOL): New constant.
+ (cmdLineParser): Changed type to ToolParser.
+ (fileAndAlias): new field.
+ (main): Don't catch OptionException.
+ (processArgs): Removed validation checks; now handled by ToolParser.
+ (getParser): Removed.
+ (ToolParserCallback): New inner class.
+ (ToolParser): Likewise.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JTable.java (TableTextArea.scrollRectToVisible):
+ Removed.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/DefaultDesktopManager.java (endDraggingFrame,
+ endResizingFrame): Do not repaint, unless in the outline mode.
+
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTabbedPane.java
+ (AccessibleJTabbedPane.getAccessibleRole): Implemented,
+ (AccessibleJTabbedPane.getAccessibleChildrenCount): Implemented,
+ (AccessibleJTabbedPane.getAccessibleSelection()): Implemented,
+ (AccessibleJTabbedPane.getAccessibleAt): Implemented,
+ (AccessibleJTabbedPane.getAccessibleSelectionCount): Implemented,
+ (AccessibleJTabbedPane.getAccessibleSelection(int)): Implemented,
+ (AccessibleJTabbedPane.isAccessibleChildSelected): Implemented,
+ (AccessibleJTabbedPane.addAccessibleSelection): Implemented,
+ (AccessibleJTabbedPane.removeAccessibleSelection): Implemented,
+ (AccessibleJTabbedPane.clearAccessibleSelection): Implemented,
+ (AccessibleJTabbedPane.selectAllAccessibleSelection): Implemented,
+ (Page.getAccessibleName): Implemented.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/DefaultDesktopManager.java (setBoundsForFrame):
+ Do not repaint nor revalidate here.
+
+2006-05-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/RepaintManager.java (addDirtyRegion):
+ If there is a lightweight parent, recursively add the corresponding
+ region of the parent instead.
+
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Graphics2D.java: Added some API doc comments.
2006-05-15 Mark Wielaard <mark@klomp.org>
* NEWS: Add release date and VMClassLoader.getBootPackages()
changes.
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JTabbedPane.java
+ (paramString): Reimplemented,
+ (getAccessibleContext): Added API docs.
+
+2006-05-15 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JFileChooser.java
+ (paramString): Reimplemented,
+ (getAccessibleContext): Updated API docs,
+ (AccessibleJFileChooser): Added API docs.
+
+2006-05-14 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/jar/Updater.java (run): No longer throws
+ OptionException.
+ * tools/gnu/classpath/tools/jar/Creator.java (run): No longer throws
+ OptionException.
+ * tools/gnu/classpath/tools/jar/Action.java (run): No longer throws
+ OptionException.
+ * tools/gnu/classpath/tools/jar/Indexer.java (run): Removed. Moved
+ validation to JarParser.
+ * tools/gnu/classpath/tools/jar/Main.java (JarParser): New class.
+ (run): Moved validation to JarParser. Don't throw OptionException.
+ (initializeParser): Create a JarParser.
+ (main): Don't catch OptionException.
+ * tools/gnu/classpath/tools/getopt/Parser.java (printHelp): No longer
+ public.
+ (validate): New method.
+ (parse): Call it. Print '-help' in error message when long-only.
+
+2006-05-14 Tom Tromey <tromey@redhat.com>
+
+ * gnu/java/awt/print/JavaPrinterJob.java (setPrintable): Fixed
+ assignment.
+
+2006-05-15 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/print/JavaPrinterGraphics.java:
+ Sweeping changes I can't be bothered to document in detail.
+ * gnu/java/awt/print/JavaPrinterJob.java
+ (getPageAttributes): New method.
+ (setPageable,cancel,isCancelled): Implement.
+
2006-05-15 Christian Thalinger <twisti@complang.tuwien.ac.at>
* README: Added CACAO to list of VMs.
+2006-05-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JCheckBoxMenuItem.java
+ (requestFocus): Fixed typo in API docs,
+ (paramString): Just call super.paramString(),
+ (getAccessibleContext): Added API docs,
+ (AccessibleJCheckBoxMenuItem): Likewise.
+
+2006-05-14 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/jar/Indexer.java
+ (writeCommandLineEntries): Simplify insertion.
+ * tools/gnu/classpath/tools/jar/Main.java (run): Don't allow both
+ -m and -M.
+
+2006-05-14 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27514:
+ * gnu/java/net/IndexListParser.java (JAR_INDEX_FILE): Renamed. Now
+ constant.
+ (JAR_INDEX_VERSION_KEY): Likewise.
+ (IndexListParser): Updated.
+ (getVersionInfo): Likewise.
+ * tools/gnu/classpath/tools/jar/Indexer.java: New file.
+ * tools/gnu/classpath/tools/jar/Action.java (run): Now throws
+ OptionException.
+ * tools/gnu/classpath/tools/jar/Main.java (initializeParser): Handle
+ -i.
+ (ModeOption): New constructor.
+ (parsed): Updated. Use setArchiveFile.
+ (setArchiveFile): New method.
+ (run): Handle no-argument case.
+ (main): Emit --help message on option error.
+ * tools/gnu/classpath/tools/jar/Updater.java (inputJar): New field.
+ (createManifest): New method.
+ (run): Updated. Throws OptionException. Correctly copy zip entry.
+ * tools/gnu/classpath/tools/jar/Creator.java (createManifest): New
+ method.
+ (writeManifest): Removed.
+ (outputStream): Now a JarOutputStream.
+ (writeCommandLineEntries): Changed parameters. Updated callers.
+ (run): Throws OptionException.
+ * java/util/jar/JarOutputStream.java (putNextEntry): Typo fix.
+ * java/util/jar/Manifest.java (read): Typo fix.
+
+2006-05-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JMenuItem.java
+ (paramString): Fixed class name in API doc comment.
+
+2006-05-14 Tom Tromey <tromey@redhat.com>
+
+ * native/plugin/.cvsignore: Updated.
+
2006-05-14 Mark Wielaard <mark@klomp.org>
* native/jni/java-net/javanet.c (_javanet_accept): Don't use C++
comments.
-2006-05-14 Chris Burdess <dog@gnu.org>
-
- * gnu/xml/dom/DomNode.java: Permit comments and PIs in doctype
- nodes to be preserved during cloneNode.
-
2006-05-14 Mark Wielaard <mark@klomp.org>
PR 27459
* native/jni/java-net/javanet.c (_javanet_accept): Reset the
inherited timeout on socket.
-2006-05-14 Lillian Angel <langel@redhat.com>
+2006-05-14 Raif S. Naffah <raif@swiftdsl.com.au>
- * java/util/SimpleTimeZone.java: Reverted patch.
- (SimpleTimeZone): Throw exception if startMonth ==
- endMonth.
- (SimpleTimeZone): Likewise.
- (checkRule): Rewritten to properly check all values (more
- efficently).
- This code is now more stable, at least less buggy than before.
- Fixed API documentation.
- (setStartRule): Moved checkRule call to end.
- (setStartRule): Likewise.
- (setEndRule): Likewise.
- (setEndRule): Likewise.
+ * tools/gnu/classpath/tools/jarsigner/Main.java (main): Formatting.
-2006-05-14 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+2006-05-14 Raif S. Naffah <raif@swiftdsl.com.au>
- * javax/swing/tree/DefaultTreeSelectionModel.java (leadRow):
- Initialise to -1.
+ * resource/gnu/classpath/tools/keytool/MessageBundle.properties:
+ Added help text.
+ * tools/gnu/classpath/tools/keytool/keytool.txt: Removed
+ * tools/gnu/classpath/tools/keytool/StorePasswdCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/SelfCertCmd.java: Likewise.
+ (setup): Mark (Eclipse) strings that need not be externalised.
+ (start): Likewise.
+ * tools/gnu/classpath/tools/keytool/PrintCertCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/Main.java: Amended to use getopt
+ command line option parsing.
+ * tools/gnu/classpath/tools/keytool/ListCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (setup): set 'all' local field.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/KeyCloneCmd.java: Likewise.
+ (setNewKeyPassword): Fixed comments.
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (getParser): New method.
+ (findTrustInCACerts): Mark (Eclipse) strings that need not be
+ externalised.
+ * tools/gnu/classpath/tools/keytool/GenKeyCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (setup): Mark (Eclipse) strings that need not be externalised.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java: Likewise.
+ * tools/gnu/classpath/tools/keytool/DeleteCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/CertReqCmd.java: Likewise.
+ (ATTRIBUTES_OPT): New constant.
+ * tools/gnu/classpath/tools/keytool/ExportCmd.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (processArgs): Removed.
+ (setup): Mark (Eclipse) strings that need not be externalised.
+ (start): Likewise.
+ Reduced logging level.
+ (getParser): New method.
+ * tools/gnu/classpath/tools/keytool/Command.java
+ (processArgs): Made it concrete.
+ (getParser): New abstract method.
+ * tools/Makefile.am (KEYTOOL_HELPS): Removed.
+
+2006-05-13 Casey Marshall <csm@gnu.org>
+
+ Patch by Michael Barker <mike@middlesoft.co.uk>.
+ * gnu/java/nio/PipeImpl.java: Retrofitted to use VMChannel.
+ * gnu/java/nio/SelectorImpl.java (register): Added condition for
+ gnu.java.nio.SocketChannelSelectionKeyImpl.
+ * gnu/java/nio/SocketChannelSelectionKeyImpl.java: new file.
+ * gnu/java/nio/channels/FileChannelImpl.java: retrofitted to use
+ VMChannel.
+ * include/gnu_java_nio_VMChannel.h: new file.
+ * java/nio/FileChannel.java (read,write): changed to call abstract
+ method.
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c: new file.
+ * native/jni/java-nio/Makefile.am (libjavanio_SOURCES): add
+ `gnu_java_nio_VMChannel.c.'
+ * vm/reference/gnu/java/nio/VMChannel.java: new file.
2006-05-14 Robert Schuster <robertschuster@fsfe.org>
- PR classpath/27595
* javax/swing/text/AbstractDocument.java:
(insertString): Flipped if-expression and its blocks.
(remove): Dito.
@@ -76,38 +9897,658 @@
* java/nio/ByteBufferImpl.java (compact): Always set position.
+2006-05-13 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/print/JavaPrinterGraphics.java
+ (spoolPostScript): Use a faster writer.
+
+2006-05-13 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/print/JavaPrinterGraphics.java
+ (colorTripleHex): Reimplement better.
+
+2006-05-13 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/text/html/HTMLDocument.java
+ (CharacterAction.start): Translate tag to StyleAttribute.
+ (pushCharacterStyle): Push copy of attributes onto stack.
+ * gnu/javax/swing/text/html/CharacterAttributeTranslator.java:
+ New file
+
+2006-05-13 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/print/ipp/IppRequest.java (send): Set a timeout.
+ * java/awt/print/PrinterJob.java
+ (getPrinterJob): Return a JavaPrinterJob
+ (setPrintService,getPrintService): Implement.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c:
+ (getPixels): Gtk_threads_enter required.
+ * gnu/java/awt/print/JavaPrinterGraphics.java
+ * gnu/java/awt/print/JavaPrinterJob.java
+ * gnu/java/awt/print/SpooledDocumet.java:
+ New files.
+
+2006-05-13 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/text/TextAction.java:
+ (HorizontalMovementAction): New inner class.
+ (VerticalMovementAction): New inner class.
+ * javax/swing/text/DefaultEditorKit.java: Added assigning instances of
+ new inner classes to array 'defaultActions'.
+ (SelectionBeginWordAction): New inner class.
+ (SelectionEndWordAction): New inner class.
+ (BeginWordAction): New inner class.
+ (EndWordAction): New inner class.
+ (PreviousWordAction.actionPerformed): Rewritten.
+ (SelectLineAction): New inner class.
+ (SelectWordAction): New inner class.
+ (SelectionDownAction): Rewritten.
+ (SelectionUpAction): Rewritten.
+ (DownAction): Rewritten.
+ (UpAction): Rewritten.
+ (SelectionForwardAction): Rewritten.
+ (SelectionBackwardAction): Rewritten.
+ (ForwardAction): Rewritten.
+ (BackwardAction): Rewritten.
+ (BeginAction): New inner class.
+ (EndAction): New inner class.
+ (DefaultKeyTypedAction.actionPerformed): Use int variant of
+ Character.isISOControl.
+
+2006-05-13 Robert Schuster <robertschuster@fsfe.org>
+
+ * examples/gnu/classpath/examples/swing/NavigationFilterDemo.java:
+ (WordFilter.getNextVisualPositionFrom): Added statement to check
+ for variable pt not being null.
+
+2006-05-13 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/text/Utilities.java:
+ (getNextWord): Fixed grammar in exception message.
+ (getPreviousWord): Changed expression in first if-clause, added sub-
+ expression to if-clause in while-loop.
+ (getWordStart): Changed expression in if-clause.
+ getNextVisualPositionFrom): Added package-private helper method.
+
+2006-05-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/tree/DefaultTreeSelectionModel.java (leadRow):
+ Initialise to -1.
+
+2006-05-13 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * resource/gnu/classpath/tools/jarsigner/MessageBundle.properties:
+ Added help text.
+ * tools/Makefile.am (JARSIGNER_HELPS): Removed.
+ * tools/gnu/classpath/tools/jarsigner/jarsigner.txt: Removed.
+ * tools/gnu/classpath/tools/jarsigner/Main.java:
+ Increased visibility of fields used by parser anonymous classes.
+ (HELP_PATH): Removed.
+ (cmdLineParser): New field.
+ (main): Handle JVM exit status.
+ Handle command line parsing exceptions.
+ (processArgs): Use getopt command line parser.
+ (getParser): New method.
+ (setupCommonParams): Removed checks now handled by processArgs().
+ (setupSigningParams): Likewise.
+ * tools/gnu/classpath/tools/jarsigner/JarSigner.java (start):
+ Reuse an existing message-bundle constant.
+
+2006-05-12 Tom Tromey <tromey@redhat.com>
+
+ * gnu/java/net/protocol/jar/Connection.java (getHeaderField):
+ Explicitly specify class for synchronization.
+
+2006-05-12 Tom Tromey <tromey@redhat.com>
+
+ * java/util/logging/Logger.java (resetLogger): Fixed typo.
+
+2006-05-12 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/net/protocol/http/HTTPConnection.java (get): Add timeout parameter.
+ * gnu/java/net/protocol/http/HTTPURLConnection.java
+ (setConnectTimeout): New method.
+ (getConnection): Add timeout parameter.
+ * java/net/URLConnection.java
+ (getConnectTimeout, setConnectTimeout): Implement.
+ * native/target/generic/target_generic_network.h:
+ Set correct socket parameters SO_SNDTIMEO and SO_RCVTIMEO.
+
+2006-05-12 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/print/CupsServer.java
+ (CupsServer): Make the Cups host configurable.
+ * java/lang/System.java: Document the system property.
+
+2006-05-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/border/TitledBorder.java
+ (paintBorder): Rewritten for simplicity and correctness.
+ (layoutBorderWithTitle): New helper method.
+ (paintBorderWithTitle): New helper method.
+ (getBorderInsets): Rewritten.
+ (getMinimumSize): Rewritten.
+ (getRealJustification): Removed.
+ (getMeasurements): Removed.
+ (Measurements): Removed.
+
+2006-05-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicPanelUI.java
+ (sharedUI): New field,
+ (createUI): Return a shared instance rather than a new instance,
+ (installUI): Reformatted and added API docs,
+ (installDefaults): Install border if one is defined,
+ (uninstallDefaults): Uninstall border.
+
+2006-05-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JProgressBar.java: Updated API docs all over.
+
+2006-05-11 Lillian Angel <langel@redhat.com>
+
+ * java/awt/ContainerOrderFocusTraversalPolicy.java
+ (getComponentAfter): Should not throw exception if
+ the ancestor is null. Added a check for this.
+ Also, changed to use new helper function, we should
+ iterate through all the components at least once.
+ (getNextAvailableComponent): New helper function.
+ (getPrevAvailableComponent): New helper function.
+ (getComponentBefore): Should not throw exception if
+ the ancestor is null. Added a check for this.
+ Also, changed to use new helper function, we should
+ iterate through all the components at least once.
+ (getFirstComponent): Changed check to manually check
+ fields. Calling accept() casts the object to a Component,
+ so different values may be returned.
+ (getLastComponent): Likewise.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java: Clean up formatting/style,
+ * javax/swing/plaf/metal/MetalButtonUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalCheckBoxUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalComboBoxButton.java: Likewise,
+ * javax/swing/plaf/metal/MetalComboBoxIcon.java: Likewise,
+ * javax/swing/plaf/metal/MetalFileChooserUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalIconFactory.java: Likewise,
+ * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java: Likewise,
+ * javax/swing/plaf/metal/MetalLookAndFeel.java: Likewise,
+ * javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalRootPaneUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalScrollBarUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalSeparatorUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalSliderUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalSplitPaneDivider.java: Likewise,
+ * javax/swing/plaf/metal/MetalTabbedPaneUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalToolTipUI.java: Likewise,
+ * javax/swing/plaf/metal/MetalUtils.java: Likewise.
+
+2006-05-11 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/text/DefaultCaret.java: Made field 'textComponent'
+ package-private, added field 'active'.
+ (PropertyChangeHandler.propertyChange): Added variable 'name', added
+ cases to update field 'active'.
+ (mouseDragged): Added documentation, added if-clause to update
+ selection or caret position.
+ (mouseClicked): Added early return when text component is disabled.
+ (focusGained): Moved statements into an if-clause.
+ (focusLost): Added subexpression to if-clause.
+ (install): Preset value of 'active'.
+ (paint): Added subexpression to if-clause.
+ (isVisible): Extended return expression.
+ * javax/swing/text/JTextComponent.java:
+ (copy): Copy only if component is enabled.
+ (cut): Cut only if component is enabled and editable.
+ (paste): Dito.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/multi/MultiComboBoxUI.java: Minor formatting change,
+ * javax/swing/plaf/multi/MultiFileChooserUI.java: Likewise,
+ * javax/swing/plaf/multi/MultiListUI.java: Likewise,
+ * javax/swing/plaf/multi/MultiLookAndFeel.java: Likewise,
+ * javax/swing/plaf/multi/MultiOptionPaneUI.java: Likewise,
+ * javax/swing/plaf/multi/MultiSplitPaneUI.java: Likewise,
+ * javax/swing/plaf/multi/MultiTabbedPaneUI.java: Likewise.
+
+2006-05-11 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/font/GNUGlyphVector.java
+ (GNUGlyphVector): Don't apply the font renderer context's
+ transform.
+
2006-05-11 Mark Wielaard <mark@klomp.org>
* java/util/logging/Logger.java (global): Initialize inside static
PrivilegedAction.
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JFrame.java
+ (EXIT_ON_CLOSE): Added note to API docs,
+ (close_action): Renamed closeAction,
+ (JFrame()): Change title to "",
+ (JFrame(String)): Added API docs,
+ (getAccessibleContext): Likewise,
+ (getDefaultCloseOperation): Updated for renamed field, added API docs,
+ (processWindowEvent): Updated for renamed field,
+ (setDefaultCloseOperation): Likewise, and updated API docs.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JFrame.java
+ (paramString): Reimplemented,
+ * javax/swing/SwingUtilities.java
+ (convertWindowConstantToString): New method.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/WindowConstants.java: Updated API docs.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicToggleButtonUI.java: Updated API docs,
+ (createUI): Removed 'final' qualifier for parameter,
+ (paint): Reformatted.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicCheckBoxUI.java: Added API docs plus,
+ (createUI): Removed 'final' qualifier on method argument.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicCheckBoxUI.java
+ (getDefaultIcon): Removed this redundant method.
+
+2006-05-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Pass component size to paintFocus().
+
+2006-05-11 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/Component.java:
+ (dispatchEventImpl): Added comment.
+
+2006-05-11 Mark Wielaard <mark@klomp.org>
+
+ * tools/gnu/classpath/tools/appletviewer/Main.java (main): Cast
+ Option constructor null argument to String.
+
2006-05-11 Mark Wielaard <mark@klomp.org>
* java/awt/geom/GeneralPath.java (WIND_EVEN_ODD, WIND_NON_ZERO):
Fully qualify PathIterator constants
+2006-05-11 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/awt/Component.java:
+ (dispatchEventImpl): Added subexpression to if-clause.
+
+2006-05-11 Mark Wielaard <mark@klomp.org>
+
+ * java/util/Collections.java (UnmodifiableMapEntry): Qualify
+ Map.Entry.
+
+2006-05-10 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/TransferHandler.java: Marked stub methods.
+
2006-05-10 Roman Kennke <kennke@aicas.com>
- PR classpath/27481
+ PR 27481
* javax/swing/plaf/basic/BasicInternalFrameUI.java
(installDefaults): Set background of content pane to null, if
no custom color has been installed by the application yet.
+2006-05-10 Sven de Marothy <sven@physto.se>
+
+ * java/awt/print/PrinterJob.java:
+ (lookupPrintServices): Un-comment-out.
+
2006-05-10 Roman Kennke <kennke@aicas.com>
- PR classpath/27481
* javax/swing/JRootPane.java
(createContentPane): Don't set background to null.
+2006-05-11 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/getopt/OptionGroup.java
+ (FILLER): New constant.
+ (formatText(PrintStream,String,int)): New method.
+ (formatText(PrintStream,String,int,Locale)): Likewise.
+ (printHelp): Use formatText method.
+ * tools/gnu/classpath/tools/getopt/Parser.java
+ (MAX_LINE_LENGTH): New constant.
+ (formatText(PrintStream,String)): New method.
+ (formatText(PrintStream,String,Locale)): Likewise.
+ (printHelp): New method.
+ (printHelp(PrintStream)): Increased visibility to protected.
+ Use formatText method.
+
+2006-05-10 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalRadioButtonUI.java
+ (installDefaults): Use getPropertyPrefix() to allow subclasses to
+ modify the lookup key.
+
+2006-05-10 Lillian Angel <langel@redhat.com>
+
+ * java/util/SimpleTimeZone.java: Reverted patch.
+ (SimpleTimeZone): Throw exception if startMonth ==
+ endMonth.
+ (SimpleTimeZone): Likewise.
+ (checkRule): Rewritten to properly check all values (more
+ efficently).
+ This code is now more stable, at least less buggy than before.
+ Fixed API documentation.
+ (setStartRule): Moved checkRule call to end.
+ (setStartRule): Likewise.
+ (setEndRule): Likewise.
+ (setEndRule): Likewise.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/swing/SwingComponent.java:
+ Some API comment fixlets.
+ * gnu/java/awt/peer/swing/SwingComponentPeer.java:
+ (createImage): Create a BufferedImage, not a Toolkit image.
+ (paint): Removed bogus API comment.
+ (prepareImage): Added checks to avoid NPE.
+ * gnu/java/awt/peer/swing/SwingContainerPeer.java:
+ (getInsets): Added check to avoid NPE.
+ (handleMouseEvent): Added check to avoid NPE.
+ * gnu/java/awt/peer/swing/SwingFramePeer.java:
+ Some API comment fixlets.
+ * gnu/java/awt/peer/swing/SwingMenuBarPeer.java:
+ Some API comment fixlets.
+ * gnu/java/awt/peer/swing/SwingTextFieldPeer.java:
+ Changed start_pos name to startPos.
+ * gnu/java/awt/peer/swing/SwingWindowPeer.java:
+ Some API comment fixlets.
+
+2006-05-10 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/BasicStroke.java
+ (equals): Fixed typo in HTML tag for API doc comment.
+
+2006-05-10 Gary Benson <gbenson@redhat.com>
+
+ * java/lang/ThreadGroup.java (parent): Make package-private.
+ * java/lang/SecurityManager.java (checkAccess(Thread)):
+ Reference ThreadGroup.parent directly to avoid extra checks.
+ * java/lang/SecurityManager.java (checkAccess(ThreadGroup)):
+ Likewise.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ Reported by Ingo Proetel (proetel@aicas.com)
+ * java/awt/EventDispatchThread.java
+ (DEFAULT_PRIORITY): New constant field.
+ (EventDispatchThread()): Added gnu.awt.dispatchthread.priority
+ system property for adjusting the priority of the event
+ dispatch thread.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ Reported by Ingo Proetel (proetel@aicas.com)
+ * java/awt/image/ColorModel.java
+ (S_RGB_MODEL): New constant field.
+ (getRGBDefault): Return constant SRGBColorModel.
+ (SRGBColorModel): Specialized color model for sRGB.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/ColorPaintContext.java
+ (getRaster): Create Raster with (0,0) as source location.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AlphaCompositeContext.java
+ (compose): Don't premultiply alpha to alpha itself.
+
+2006-05-10 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ (drawImage(Image,AffineTransform,ImageObserver)): Implemented.
+ (drawImageImpl(Image,AffineTransform,ImageObserver,Rectangle)):
+ New method.
+ (drawImage(BufferedImage,BufferedImageOp,int,int)): Implemented.
+ (drawRenderedImage(RenderedImage,AffineTransform)): Implemented.
+ (drawRenderedImageImpl(RenderedImage,AffineTransform,Rectangle)):
+ New method.
+ (drawRenderableImage(RenderableImage,AffineTransform)): Implemented.
+ (drawRenderableImageImpl(RenderableImage,AffineTransform,Rectangle)):
+ New method.
+ (scale): Inverse transform by doing 1/scale instead of -scale.
+ (drawImage(Image,int,int,ImageObserver)): Implemented.
+ (drawImage(Image,int,int,int,int,ImageObserver)): Implemented.
+ (drawImage(Image,int,int,Color,ImageObserver)): Implemented.
+ (drawImage(Image,int,int,int,int,Color,ImageObserver)): Implemented.
+ (drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver)):
+ Implemented.
+ (drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)):
+ Implemented.
+ (fillScanline): Work on translated destination raster for
+ correct compositin.
+ (init): Fetch the clip after the destination raster is initialized.
+ * gnu/java/awt/java2d/ImagePaint.java: New file.
+ * gnu/java/awt/java2d/RasterGraphics
+ (drawImage): Removed.
+
+2006-05-09 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties:
+ Clarify option descriptions.
+ * tools/gnu/classpath/tools/appletviewer/Main.java: Use all
+ uppercase for metasyntactic variables.
+
2006-05-09 Robert Schuster <robertschuster@fsfe.org>
- PR classpath/24216
+ Fixed PR24216.
* javax/swing/text/AbstractDocument.java:
(insertString): Added more documentation, added argument check.
(remove): Added more documentation.
(removeImpl): Added argument check.
(replace): Added more documentation, added argument check.
+2006-05-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/.cvsignore: Added appletviewer.
+
+2006-05-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/Parser.java (printHelp): Skip
+ empty groups.
+
+2006-05-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/OptionGroup.java (printHelp):
+ Special case for '-J'. Use space instead of '='.
+ * tools/gnu/classpath/tools/getopt/Parser.java (setHeader): Added
+ comment.
+
+2006-05-09 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac: Add --disable-plugin and --with-vm options. Check
+ for plugin support headers and libraries.
+ * native/Makefile.am: Recurse into plugin directory.
+ * native/plugin/.cvsignore: New file.
+ * native/plugin/Makefile.am: New file.
+ * native/plugin/gcjwebplugin.cc: New file.
+ * tools/Makefile.am: Install appletviewer wrapper script.
+ * tools/appletviewer.in: Replace VM location heuristic with
+ VM_BINARY configure substitution.
+
+2006-05-09 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/OptionGroup.java (printHelp): Added
+ an initial pass to look for short options. Added 'longOnly' option.
+ * tools/gnu/classpath/tools/appletviewer/Main.java (main): Removed -J
+ option.
+ * tools/gnu/classpath/tools/getopt/Parser.java (parsed): Put stadnard
+ options into final group. Added -J.
+ (add): Insert new groups before final group.
+ (printHelp): Updated.
+
+2006-05-09 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27518
+ * tools/gnu/classpath/tools/giop/GRMIC.java (main),
+ tools/gnu/classpath/tools/rmi/RMIC.java (main):
+ Expect -classpath option.
+ * tools/gnu/classpath/tools/rmi/RMIC.txt,
+ tools/gnu/classpath/tools/giop/GRMIC.txt: Documenting
+ -classpath option.
+ tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
+ (classLoader): New field. (loadClass, setClassPath):
+ New methods.
+
+2006-05-09 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/RasterGraphics.java
+ (RasterGraphics): Call init() and super().
+ (drawImage): Temporary drawImage impl until AbstractGraphics2D has
+ this.
+
+2006-05-09 Gary Benson <gbenson@redhat.com>
+
+ * java/lang/Thread.java (Thread): Always perform threadgroup
+ access checks on thread creation.
+
+2006-05-09 Chris Burdess <dog@gnu.org>
+
+ * gnu/xml/dom/DomNode.java: Permit comments and PIs in doctype nodes to
+ be preserved during cloneNode.
+
+2006-05-09 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27517
+ * tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java (compile):
+ Do not demand all thrown exceptions to be an instance of RemoteException.
+
+2006-05-09 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties:
+ Use hash-style comments.
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties:
+ Likewise.
+
+2006-05-09 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (paramString): Added more attribute details,
+ * javax/swing/SwingUtilities.java
+ (convertHorizontalAlignmentCodeToString): New method,
+ (convertVerticalAlignmentCodeToString): New method.
+
+2006-05-08 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/jar/Updater.java (run): Updated.
+ * tools/gnu/classpath/tools/jar/Main.java: Use javadoc for fields.
+ * tools/gnu/classpath/tools/jar/Lister.java (listJar): Use
+ ZipInputStream.
+ (run): Updated.
+ * tools/gnu/classpath/tools/jar/Extractor.java (run): Use System.err
+ for verbose.
+ (run): Use ZipInputStream.
+ (initSet): New method.
+ (shouldExtract): Likewise.
+ (run): Use new methods.
+ * tools/gnu/classpath/tools/jar/Creator.java
+ (writeCommandLineEntries): New overload.
+ (writeFile): Use System.err for verbose.
+ (writeManifest): New method.
+ (writtenItems): New field.
+ (writeFile): Update it.
+ (writeCommandLineEntries): Return void. Call writeManifest.
+ (addEntries): Don't add extra '/'.
+ * NEWS: Mention jar.
+
+2006-05-08 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/net/IndexListParser.java: New class.
+ * java/net/URLClassLoader.java
+ (JarURLLoader): Fixed code to use new class.
+
+2006-05-08 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComboBox.java
+ (AccessibleJComboBox.getAccessibleChildrenCount): Implemented.
+ (AccessibleJComboBox.getAccessibleChild): Implemented.
+ (AccessibleJComboBox.getAccessibleSelection()): Implemented.
+ (AccessibleJComboBox.getAccessibleSelection(int)): Implemented.
+ (AccessibleJComboBox.isAccessibleChildSelected): Implemented.
+ (AccessibleJComboBox.getAccessibleAction): Implemented.
+ (AccessibleJComboBox.getAccessibleActionDescription): Implemented.
+ (AccessibleJComboBox.getAccessibleActionCount): Implemented.
+ (AccessibleJComboBox.doAccessibleAction): Implemented.
+ (AccessibleJComboBox.getAccessibleSelectionCount): Implemented.
+ (AccessibleJComboBox.addAccessibleSelection): Implemented.
+ (AccessibleJComboBox.removeAccessibleSelection): Implemented.
+ (AccessibleJComboBox.clearAccessibleSelection): Implemented.
+ (AccessibleJComboBox.selectAllAccessibleSelection): Implemented.
+
+2006-05-08 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac: Add support for building appletviewer.
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle.properties:
+ New file.
+ * resource/gnu/classpath/tools/appletviewer/MessagesBundle_de.properties:
+ New file.
+ * tools/appletviewer.c: New file.
+ * tools/appletviewer.in: New file.
+ * tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/AppletTag.java: New file.
+ * tools/gnu/classpath/tools/appletviewer/AppletWarning.java: New
+ file.
+ * tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java: New
+ file.
+ * tools/gnu/classpath/tools/appletviewer/ErrorApplet.java: New
+ file.
+ * tools/gnu/classpath/tools/appletviewer/Main.java: New file.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java:
+ New file.
+ * tools/gnu/classpath/tools/appletviewer/TagParser.java: New
+ file.
+
+2006-05-08 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/getopt/ClasspathToolParser.java: New file.
+ * tools/gnu/classpath/tools/jar/Action.java: New file.
+ * tools/gnu/classpath/tools/jar/Creator.java: New file.
+ * tools/gnu/classpath/tools/jar/Entry.java: New file.
+ * tools/gnu/classpath/tools/jar/Extractor.java: New file.
+ * tools/gnu/classpath/tools/jar/Lister.java: New file.
+ * tools/gnu/classpath/tools/jar/Main.java: New file.
+ * tools/gnu/classpath/tools/jar/Updater.java: New file.
+ * tools/gnu/classpath/tools/getopt/Option.java: New file.
+ * tools/gnu/classpath/tools/getopt/OptionException.java: New file.
+ * tools/gnu/classpath/tools/getopt/OptionGroup.java: New file.
+ * tools/gnu/classpath/tools/getopt/Parser.java: New file.
+ * tools/gnu/classpath/tools/getopt/FileArgumentCallback.java: New
+ file.
+
2006-05-08 Lillian Angel <langel@redhat.com>
* java/net/URLClassLoader.java
@@ -116,7 +10557,25 @@
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27481
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ (fill): Removed commented out code.
+ (fillShape): Also determine the outline of the clip and feed
+ it into the rendering method. Use new helper method for
+ converting the shapes into lists of segments.
+ (getUserBounds): Removed obsolete method.
+ (rawFillShape): Respect the clip when rendering shapes.
+ (fillShapeAntialias): Adjusted signature for new clipped rendering.
+ However, the implementation can't clip still.
+ (getSegments): New helper method for converting a shape into
+ a list of segments.
+ (clipShape): Removed obsolete method.
+ * gnu/java/awt/java2d/PolyEdge.java
+ (isClip): New field.
+ (PolyEdge): Added isField argument to constructor.
+
+2006-05-08 Roman Kennke <kennke@aicas.com>
+
+ PR 27481
* javax/swing/JRootPane.java
(createContentPane): Set background of the content pane to null,
so that the content pane inherits its background from the
@@ -124,7 +10583,7 @@
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27480
+ PR 27480
* javax/swing/ButtonGroup.java
(add): Check if new button is selected and if so, deselect other
buttons in the group.
@@ -138,27 +10597,27 @@
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27461
+ PR 27461
* javax/swing/ImageIcon.java
(ImageIcon(URL)): Set description to URL.toString().
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27482
+ PR 27482
* javax/swing/JTable.java
(IconCellRenderer.getTableCellRendererComponent): Set icon to
null when cell value is null.
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27484
+ PR 27484
* javax/swing/DefaultDesktopManager.java
(closeFrame): Don't perform default close action on the frame
to prevent endless loop.
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27485
+ PR 27485
* javax/swing/table/DefaultTableModel.java
(addExtraRows): New helper method.
(checkSize): New helper method.
@@ -169,10 +10628,19 @@
2006-05-08 Roman Kennke <kennke@aicas.com>
- PR classpath/27486
+ PR 27486
* javax/swing/JTable.java
(setValueAt): Allow setting values even when table is editable.
+2006-05-08 Tom Tromey <tromey@redhat.com>
+
+ * java/text/SimpleDateFormat.java (compileFormat): Added missing
+ space to error message.
+
+2006-05-08 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java: Fixed comment typos.
+
2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/27435:
@@ -183,19 +10651,13 @@
Fixed PR27343
* java/util/Calendar.java (setTimeZone): Force recalculation.
-
+
2006-05-07 Sven de Marothy <sven@physto.se>
Fixed PR27463
* javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
(propertyChange): Handle FRAME_ICON_PROPERTY property.
-
-2006-05-06 Sven de Marothy <sven@physto.se>
-
- Fixed PR27454
- * gnu/java/awt/peer/gtk/GtkImage: (drawPixels,drawPixelsScaled):
- Check for zero image sizes.
-
+
2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/27311:
@@ -205,16 +10667,34 @@
(formatInternal(double,StringFormatBuffer,FieldPosition)):
Don't calculate the exponent when the number is 0 or less.
Also, use log10 instead of log now it's available.
+
+2006-05-07 Raif S. Naffah <raif@swiftdsl.com.au>
-2006-05-07 Sven de Marothy <sven@physto.se>
+ * gnu/javax/crypto/keyring/PrimitiveEntry.java (PrimitiveEntry):
+ Use instance's field creationDate not the constructor's argument.
+ * gnu/javax/crypto/keyring/PasswordEncryptedEntry.java:
+ Removed unused imports.
+ Sorted imports.
+ (log): New field.
+ (decrypt): Added trace/debug/timing statements.
+ (encrypt): Likewise.
+ Use PRNG instead of instantiating every time a new SecureRandom.
+ * gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java:
+ Removed unused imports.
+ Sorted imports.
+ (log): New field.
+ (verify): Added trace/debug/timing statements.
+ (authenticate): Likewise.
+ Use PRNG instead of instantiating every time a new SecureRandom.
- Fixed PR27455
- * gnu/java/awt/peer/GLightweightPeer.java (mouseEntered): Remove.
- * java/awt/Component.java (processMouseEvent):
- Do lightweight cursor handling.
- * javax/swing/plaf/basic/BasicTableHeaderUI.java
- (endResizing,mouseMoved): Save and reset original cursor, not the
- default one.
+2006-05-07 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * gnu/classpath/debug/Simple1LineFormatter.java (DAT_FORMAT): Removed.
+ (THREAD_FORMAT): Likewise.
+ (dateFormat): Added field.
+ (threadFormat): Added field.
+ (format): Initialize instance fields if null.
+ Use StringBuilder instead of StringBuffer.
2006-05-07 Roman Kennke <kennke@aicas.com>
@@ -245,6 +10725,66 @@
(compose): Fixed loops, conditions and logic to make compositing
work correctly.
+2006-05-07 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/ColorPaintContext.java
+ (ColorPaintContext): Fixed filling of the raster.
+
+2006-05-07 Sven de Marothy <sven@physto.se>
+
+ Fixed PR27455
+ * gnu/java/awt/peer/GLightweightPeer.java (mouseEntered): Remove.
+ * java/awt/Component.java (processMouseEvent):
+ Do lightweight cursor handling.
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java
+ (endResizing,mouseMoved): Save and reset original cursor, not the
+ default one.
+
+2006-05-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27298
+ * javax/swing/plaf/basic/BasicTreeUI.java (NodeDimensionsHandler.
+ getNodeDimensions): Mind the size of the node icon. (getRowX):
+ use totalChildIndent. (TreeExpansionHandler): Set maximal height
+ to zero on events. (nullIcon): New field. (getCurrentControlIcon):
+ Return nullIcon if there is no other icon. (getNodeIcon): New method.
+ (installDefaults): assign totalChildIndent. (installUI): Call
+ updateExpandedDescendants. (paintHorizontalPartOfLeg): Rewritten.
+ (paintRow): Rewritten. (updateRenderer): Do not set the renderer for
+ the tree.
+
+2006-05-06 Sven de Marothy <sven@physto.se>
+
+ Fixed PR27454
+ * gnu/java/awt/peer/gtk/GtkImage: (drawPixels,drawPixelsScaled):
+ Check for zero image sizes.
+
+2006-05-06 Olivier Jolly <olivier.jolly@pcedev.com>
+
+ Fixed PR27362
+ * java/util/Calendar.java (clear(int)): Forced internal state
+ completion before performing a field clearing.
+
+2006-05-06 Olivier Jolly <olivier.jolly@pcedev.com>
+
+ * java/util/Collections.java(UnmodifiableMap.UnmodifiableEntrySet.
+ UnmodifiableMapEntry): New Map.Entry implementation which is immutable.
+ (UnmodifiableMap.UnmodifiableEntrySet.iterator,
+ UnmodifiableMap.UnmodifiableEntrySet.toArray,
+ UnmodifiableMap.UnmodifiableEntrySet.toArray(Object[])): Used
+ UnmodifiableMapEntry as part of their return value.
+
+2006-05-06 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/keytool.sh.in: Removed (renamed to keytool.in).
+ * tools/jarsigner.in: Removed (renamed to jarsigner.in).
+ * tools/Makefile.am: Include jarsigner and keytool classes in tools.zip.
+ Generate jarsigner and keytool scripts.
+ * tools/keytool.in: New file (renamed from keytool.sh.in).
+ * tools/jarsigner.in: New file (renamed from jarsigner.sh.in).
+ * tools/.cvsignore: Replaced *.sh with *
+ * configure.ac: Replaced tools/*.sh with tools/*.
+
2006-05-05 Roman Kennke <kennke@aicas.com>
* java/awt/image/ColorModel.java
@@ -261,6 +10801,58 @@
* javax/swing/JTable.java
(tableChanged): Sync selection model with table model changes.
+2006-05-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early
+ if there are no visible nodes to paint.
+
+2006-05-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JOptionPane.java: API doc updates.
+
+2006-05-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JToolBar.java
+ (paramString): Reimplemented.
+
+2006-05-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JScrollBar.java
+ (paramString): Reimplemented.
+
+2006-05-04 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27375:
+ * java/util/zip/ZipFile.java (entries): Now a LinkedHashMap.
+ (readEntries): Updated.
+ (getEntries): Likewise.
+ (getEntry): Likewise.
+ (getInputStream): Likewise.
+
+2006-05-04 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/javax/imageio/jpeg/DCT.java,
+ gnu/javax/imageio/jpeg/HuffmanTable.java,
+ gnu/javax/imageio/jpeg/JPEGComponent.java,
+ gnu/javax/imageio/jpeg/JPEGDecoder.java,
+ gnu/javax/imageio/jpeg/JPEGException.java,
+ gnu/javax/imageio/jpeg/JPEGFrame.java,
+ gnu/javax/imageio/jpeg/JPEGImageInputStream.java,
+ gnu/javax/imageio/jpeg/JPEGImageReader.java,
+ gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java,
+ gnu/javax/imageio/jpeg/JPEGMarker.java,
+ gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java,
+ gnu/javax/imageio/jpeg/JPEGScan.java,
+ gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java,
+ gnu/javax/imageio/jpeg/ZigZag.java: New files.
+
+2006-05-04 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JLabel.java
+ (JLabel): Pass in an empty string for the text parameter.
+ (JLabel): Likewise.
+ (JLabel): Likewise.
+
2006-05-04 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicButtonListener.java
@@ -276,18 +10868,17 @@
* javax/swing/JLabel.java
(AccessibleJLabel.getSelectedText): Return null instead of "".
(AccessibleJLabel.getSelectionStart): Added comment why
- return -1 is correct here.
+ return -1 is correct here.
(AccessibleJLabel.getSelectionEnd): Added comment why
- return -1 is correct here.
- (AccessibleJLabel.getCharacterAttribute): Added comment about
- what to do here.
+ return -1 is correct here.
+ (AccessibleJLabel.getCharacterAttribute): Added comment about what
+ to do here.
(AccessibleJLabel.getCharCount): Added comment about what
- to do here.
- (AccessibleJLabel.getCharacterBounds): Tagged as not
- implemented.
+ to do here.
+ (AccessibleJLabel.getCharacterBounds): Tagged as not implemented.
(AccessibleJLabel.getIndexAtPoint): Tagged as not implemented.
(paramString): Return super.paramString() here, this provides
- a more meaningful output.
+ a more meaningful output.
2006-05-04 Roman Kennke <kennke@aicas.com>
@@ -299,49 +10890,41 @@
* javax/swing/AbstractButton.java
(addImpl): New method. Installs an OverlayLayout if no
other layout has been installed before.
- (setLayout): New method. Detect if a client app installs a
- custom layout.
-
+ (setLayout): New method. Detect if a client app installs a custom
+ layout.
+
2006-05-04 Roman Kennke <kennke@aicas.com>
- * javax/swing/table/DefaultTableCellModel.java
+ * javax/swing/table/DefaultTableCellRenderer.java
(noFocusBorder): Fixed width of empty border to 1.
(getTableCellRendererComponent): Don't change the colors for
focuses cells. Fixed border for focused cells.
-
+
2006-05-04 Roman Kennke <kennke@aicas.com>
* javax/swing/JTable.java
- (moveToCellBeingEdited): Adjust bounding box
- of editing component to exactly cover the grid.
+ (moveToCellBeingEdited): Adjust bounding box of editing component
+ to exactly cover the grid.
* javax/swing/plaf/basic/BasicTableUI.java
- (paint): Paint grid to the bottom and right of
- the cells instead of left and top. Adjust bounding
- box of cells accordingly.
+ (paint): Paint grid to the bottom and right of the cells instead
+ of left and top. Adjust bounding box of cells accordingly.
* javax/swing/plaf/metal/MetalLookAndFeel.java
- (initComponentDefaults): Fixed color of JTable
- selection border.
+ (initComponentDefaults): Fixed color of JTable selection border.
* javax/swing/plaf/metal/OceanTheme.java
- (addCustomEntriesToTable): Fixed color of JTable
- selection border.
+ (addCustomEntriesToTable): Fixed color of JTable selection border.
2006-05-04 Raif S. Naffah <raif@swiftdsl.com.au>
* tools/gnu/classpath/tools/keytool/ExportCmd.java (setup):
Use _alias instead of alias.
-2006-05-04 Lillian Angel <langel@redhat.com>
-
- * javax/swing/JLabel.java
- (JLabel): Pass in an empty string for the text parameter.
- (JLabel): Likewise.
- (JLabel): Likewise.
+2006-05-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
-2006-05-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+ * configure.ac:
+ Set version to 0.92-pre.
+ * NEWS:
+ Add space for 0.92 entries.
- * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early
- if there are no visible nodes to paint.
-
2006-05-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
* include/Makefile.am:
@@ -1586,7 +12169,7 @@
2006-04-21 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/border/AbstractBorder.java: API doc updates,
- * javax/swing/border/BevelBorder.java: Likewise,
+ * javax/swing/border/BevelBorder.java: Likewise,
* javax/swing/border/CompoundBorder.java: Likewise,
* javax/swing/border/EtchedBorder.java: Likewise,
* javax/swing/border/LineBorder.java: Likewise,
@@ -1944,7 +12527,8 @@
2006-04-18 Robert Schuster <robertschuster@fsfe.org>
- * javax/swing/plaf/basic/BasicTextUI.java: Implemented.
+ * javax/swing/plaf/basic/BasicTextUI.java:
+ (getNextVisualPositionFrom): Implemented.
2006-04-18 David Gilbert <david.gilbert@object-refinery.com>
@@ -5726,21 +16310,6 @@
* vm/reference/gnu/classpath/Unsafe.java:
New class to handle low-level facilities for concurrency.
-2006-03-19 Michael Barker <mike@middlesoft.co.uk>
-
- * vm/reference/gnu/java/nio/VMChannel.java: Added, supports setting
- non-blocking and scatter-gather io operations.
- * gnu/java/nio/PipeImpl.java: Retrofitted to use VMChannel
- * gnu/java/nio/SelectorImpl.java
- (register) Added condition for gnu.java.nio.SocketChannelSelectionKeyImpl
- * gnu/java/nio/SocketChannelSelectionKeyImpl.java Added.
- * gnu/java/nio/channels/FileChannelImpl.java: Retrofitted to use VMChannel
- * java/nio/FileChannel.java
- (read (ByteBuffer)) Changed to call abstract method.
- (write (ByteBuffer)) Changed to call abstract method.
- * include/gnu_java_nio_VMChannel.h: Added.
- * native/jni/java-nio/gnu_java_nio_VMChannel.c: Added.
-
2006-03-19 Mark Wielaard <mark@klomp.org>
* include/Makefile.am: Rename PlainDatagramSocketImpl to
@@ -12092,7 +22661,7 @@
(AccessibleJComponent.changeSupport): Changed to be a
java.beans.PropertyChangeSupport rather than
SwingPropertyChangeSupport.
- (AccessibleJComponent.AccesibleJComponent()): Change initialization
+ (AccessibleJComponent.AccessibleJComponent()): Change initialization
of above field.
(changeSupport): Removed unneeded field.
(removePropertyChangeListener): Removed unneeded methods.
@@ -16016,8 +26585,3 @@
* java/net/InetAddress.java (getAllByName): use LOCALHOST if
localhost is null or is an empty string. Trim hostname before
lookup.
-
-
-Local Variables:
-coding: iso-latin-1-unix
-End:
diff --git a/libjava/classpath/INSTALL b/libjava/classpath/INSTALL
index 96059a50a6b..dae909effde 100644
--- a/libjava/classpath/INSTALL
+++ b/libjava/classpath/INSTALL
@@ -46,19 +46,24 @@ Suggested Software
are required unless --disable-gtk-peer is used as an argument to
configure.
- - GTK+ 2.4.x (or higher)
+ - GTK+ 2.8.x (or higher)
- gdk-pixbuf
- XTest Extension (libXtst) for GdkRobot support in java.awt.
- For building the Cairo GdkGraphics2D backend you need at least
- Cairo 0.5.0.
+ For building gcjwebplugin you'll need the Mozilla plugin
+ support headers and libraries.
For building the Qt AWT peer JNI native libraries you have to
specify --enable-qt-peer and need the following library:
- Qt 4.0.1
+ For building the X AWT peers see information below
+ (Building and running with the X AWT peers). You will need
+ the Escher 0.2.3 library:
+ http://escher.sourceforge.net
+
Please note that at the moment most operating systems do not
ship Qt4 by default. We recommend using GNU Classpath' Qt4
support only for its developers and bug reporters. See
@@ -113,17 +118,22 @@ gives a complete list.
--enable-java compile Java source default=yes
--enable-jni compile JNI source default=yes
--enable-gtk-peer compile GTK native peers default=yes
- --enable-gtk-cairo compile cairo based Graphics2D default=no
--enable-qt-peer compile Qt4 native peers default=no
--enable-default-toolkit
fully qualified class name of default AWT toolkit
default=no
--enable-xmlj compile native libxml/xslt library default=no
--enable-load-library enable to use JNI native methods default=yes
+ --enable-local-sockets enable build of local Unix sockets
--with-jikes to compile the class library using jikes
the default is to use gcj
--with-glibj define what to install (zip|flat|both|none)
default=zip
+ --with-escher=/path/to/escher
+ enable build of the X/Escher peers, with
+ the escher library at /path/to/escher, either
+ in the form of a JAR file, or a directory
+ containing the .class files of Escher.
--enable-Werror whether to compile C code with -Werror which turns
any compiler warning into a compilation failure
default=no
@@ -165,6 +175,25 @@ More information about the VMs that use GNU Classpath can be found in the
README file.
------------------------------------------------------------------
+Building and running with the X AWT peers
+------------------------------------------------------------------
+
+In order build the X peers you need the Escher library version 0.2.3
+from http://escher.sourceforge.net . Unpack (and optionally build) the
+Escher library following the instructions in the downloaded
+package. Enable the build of the X peers by passing
+--with-escher=/path/to/escher to ./configure where /path/to/escher
+either points to a directory structure or JAR file containing the
+Escher classes. For Unix systems it is preferable to also build local
+socket support by passing --enable-local-sockets, which accelerates
+the network communication to the X server significantly.
+
+In this release you have to enable the X peers at runtime by
+setting the system property awt.toolkit=gnu.java.awt.peer.x.XToolkit
+by passing -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit to the java
+command when running an application.
+
+------------------------------------------------------------------
Misc. Notes
------------------------------------------------------------------
Compilation is accomplished using a compiler's @file syntax. For our
diff --git a/libjava/classpath/Makefile.in b/libjava/classpath/Makefile.in
index 21f6a3fead4..b8fbd3d4a4d 100644
--- a/libjava/classpath/Makefile.in
+++ b/libjava/classpath/Makefile.in
@@ -38,8 +38,10 @@ host_triplet = @host@
target_triplet = @target@
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure \
- $(top_srcdir)/gnu/classpath/Configuration.java.in AUTHORS \
- COPYING ChangeLog INSTALL NEWS TODO compile config.guess \
+ $(top_srcdir)/gnu/classpath/Configuration.java.in \
+ $(top_srcdir)/gnu/java/security/Configuration.java.in \
+ $(top_srcdir)/resource/META-INF/services/java.util.prefs.PreferencesFactory.in \
+ AUTHORS COPYING ChangeLog INSTALL NEWS TODO config.guess \
config.sub depcomp install-sh ltcf-c.sh ltcf-cxx.sh \
ltcf-gcj.sh ltconfig ltmain.sh missing mkinstalldirs
subdir = .
@@ -57,7 +59,9 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
-CONFIG_CLEAN_FILES = gnu/classpath/Configuration.java
+CONFIG_CLEAN_FILES = gnu/classpath/Configuration.java \
+ gnu/java/security/Configuration.java \
+ resource/META-INF/services/java.util.prefs.PreferencesFactory
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -109,6 +113,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -129,6 +135,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -159,6 +166,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -209,6 +220,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -229,6 +241,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -341,6 +355,10 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
gnu/classpath/Configuration.java: $(top_builddir)/config.status $(top_srcdir)/gnu/classpath/Configuration.java.in
cd $(top_builddir) && $(SHELL) ./config.status $@
+gnu/java/security/Configuration.java: $(top_builddir)/config.status $(top_srcdir)/gnu/java/security/Configuration.java.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+resource/META-INF/services/java.util.prefs.PreferencesFactory: $(top_builddir)/config.status $(top_srcdir)/resource/META-INF/services/java.util.prefs.PreferencesFactory.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
@@ -487,7 +505,7 @@ distclean-tags:
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
- $(mkdir_p) $(distdir)/../.. $(distdir)/examples $(distdir)/gnu/classpath $(distdir)/lib $(distdir)/m4 $(distdir)/scripts $(distdir)/tools
+ $(mkdir_p) $(distdir)/../.. $(distdir)/examples $(distdir)/gnu/classpath $(distdir)/gnu/java/security $(distdir)/lib $(distdir)/m4 $(distdir)/resource/META-INF/services $(distdir)/scripts $(distdir)/tools
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
diff --git a/libjava/classpath/NEWS b/libjava/classpath/NEWS
index d4f9e5a86ef..a787833e587 100644
--- a/libjava/classpath/NEWS
+++ b/libjava/classpath/NEWS
@@ -1,3 +1,101 @@
+New in release 0.92 (Aug 9, 2006)
+
+* libjawtgnu.so has been renamed libjawt.so for binary compatibility.
+ libjawt.so should be installed in a VM-specific directory rather
+ than directly in /usr/lib. Proprietary VMs put their libjawt.so
+ implementations in VM-specific directories but search /usr/lib first.
+ If GNU Classpath's libjawt.so is installed in /usr/lib it will create
+ problems for people who use a proprietary VM to run AWT Native
+ Interface applications.
+* The GdkGraphics2D backend has been made the default. There is no
+ longer an explicit dependency on Cairo, the --enable-gtk-cairo
+ configure option is gone, and GTK 2.8 or higher is now required to
+ build the GTK peers.
+* A Mozilla plugin, 'gcjwebplugin', is now included. It introduces a
+ dependency on the Mozilla plugin support headers and libraries.
+* New java implementations of png and gif imageio readers and writers.
+* A tools.texinfo document has been created and now includes
+ documentation about:
+ * appletviewer
+ * gcjwebplugin
+ * jarsigner
+ * keytool
+* Several new tools are now included:
+ * appletviewer
+ * jar
+ * native2ascii
+ * serialver
+ * keytool
+ * jarsigner
+ A new configure option --enable-tool-wrappers causes wrapper
+ binaries to be built for VMs that support the JNI Invocation API.
+* javax.sound.midi providers have been added to read and
+ write standard MIDI files.
+* A javax.sound.sampled .au and .wav file readers have been added.
+* New Java Virtual Machine Tool Interface header, jvmti.h.
+* AWT peers for X Windows based on Escher (a pure java X protocol
+ implementation) have been added. So far it supports AWT 1.1 style
+ Graphics, image loading via ImageIO (PNG, GIF and BMP images in this
+ release), top level components as well as mouse and keyboard input.
+ It is capable of running many Swing applications. Graphics2D and
+ AWT widgets are not yet supported with this peer set.
+* GConf based util.peers backend (see the --enable-gconf-peer and
+ --enable-default-preferences-peer configure options).
+* Support for batch importing trusted certificates for use with ssl
+ connections (see script/import-cacerts.sh).
+* NIO scatter-gather channel support.
+
+Runtime interface changes:
+
+* A new class, VMURLConnection, is used to implement
+ URLConnection.guessContentTypeFromStream. The reference
+ implementation uses libmagic (and falls back to doing nothing if
+ libmagic is not available).
+* The method gnu.java.io.PlatformHelper.toCanonicalForm() has been
+ replaced with a JNI implementation of VMFile.toCanonicalForm() for
+ GNU/Posix systems.
+* A new class, VMRuntimeMXBeanImpl, is used to implement
+ the low-level support of the runtime management bean.
+ VMs should use it to supply the input arguments and start
+ time of the VM. In addition, one of sun.boot.class.path
+ or java.boot.class.path should be defined by the VM to
+ support the optional boot class path access functionality.
+* The Unsafe class was moved back to the place expected by the JSR 166
+ reference implementation. We've also added a couple other new VM
+ classes to support the JSR 166 code -- sun.reflect.Reflection and
+ sun.reflect.misc.ReflectUtil.
+* Another new class, VMClassLoadingMXBeanImpl, is used to implement
+ the low-level support of the class loading management bean.
+ VMs need to supply it with information about how many classes
+ are currently loaded, how many have been unloaded and whether
+ verbose class loading output is on or off. Provision should also
+ be made for the latter to be toggled at runtime.
+* VMThreadMXBeanImpl is used to implement the low-level support
+ of the thread management bean. Providing this interface requires
+ providing a fair amount of information about threads, including
+ optional time and contention monitoring, and instances of the
+ new ThreadInfo class in java.lang.management. getState() has also
+ been added to the VMThread interface; this is required by the bean
+ as well as java.lang.Thread.
+* VMMemoryMXBeanImpl is used to implement the low-level support
+ of the memory management bean. Providing this interface requires
+ providing information about the levels of heap and non-heap memory,
+ and the number of objects eligible for garbage collection.
+* VMCompilationMXBeanImpl is used to allow for optional compilation
+ time support for Just-In-Time compilers.
+* VMMemoryPoolMXBeanImpl is used to implement the low-level support
+ of the memory pool beans. Providing this interface requires
+ providing memory usage statistics for each supported bean.
+* VMManagementFactory provides the names of the memory pools,
+ memory managers and garbage collectors maintained by the virtual
+ machine. These are used to create the beans by the ManagementFactory.
+* VMMemoryManagerMXBeanImpl and VMGarbageCollectorMXBeanImpl provide
+ low-level support for memory managers (including the specific subclass
+ of garbage collecting memory managers). The interfaces for these
+ require no more than enumerating the number of collections and the
+ time spent (for garbage collectors) and a relationship to the memory
+ pools (for all), along with a validity check.
+
New in release 0.91 (May 15, 2006)
* Experimental activation (java.rmi.activation) support, including RMI
diff --git a/libjava/classpath/README b/libjava/classpath/README
index 132fbe531ed..d2e38a5db11 100644
--- a/libjava/classpath/README
+++ b/libjava/classpath/README
@@ -1,21 +1,21 @@
-GNU Classpath README - Last updated: May 15, 2006
+GNU Classpath README - Last updated: August 6, 2006 (for release 0.92)
GNU Classpath, Essential Libraries for Java is a project to create a
free software implementation of the core class libraries for the java
programming language.
-Additionally GNU Classpath includes a sub-project called GNU Classpath
-Tools whose goal is to provide a number of free replacements for
-standard Java development tools like javadoc, javap, javah, and
-others. And a sub-project called GNU Inetlib, an extension library to
-provide extra network protocol support (ftp, finger, gopher) for GNU
-Classpath, but it can also standalone to ease adding http, imap, pop3
-and smtp client support to applictions. These subprojects are normally
-released independent from the core libraries.
+Additionally, GNU Classpath includes a sub-project called GNU Classpath
+Tools whose goal is to provide a number of free replacements for standard
+Java development tools like javadoc, javap, and others. A sub-project
+called GNU Inetlib, can be used as an extension library to provide extra
+network protocol support (ftp, finger, gopher) for GNU Classpath. It can
+also be used as a standalone to ease adding http, imap, pop3 and smtp
+client support to applictions. These subprojects are normally released
+independently from the core libraries.
This is a development snapshot release only and is not for general
-purpose use. GNU Classpath needs to be combine with a proper
-development environments to be useable for end users. Eventually,
+purpose use. GNU Classpath needs to be combined with a proper
+development environment to be useable for end users. Eventually,
these essential libraries for java will work with as many free
compilers and runtimes as possible.
@@ -31,24 +31,22 @@ with this GNU Classpath releases include
* CACAO (http://www.cacaojvm.org/)
* JamVM (http://jamvm.sourceforge.net/)
- * Jikes RVM (http://www.ibm.com/developerworks/oss/jikesrvm/)
- * Kissme (http://kissme.sourceforge.net/)
+ * Jikes RVM (http://jikesrvm.sourceforge.net/)
In general the latest releases of the above VMs will work out of the box
with the latest GNU Classpath release (and in most cases directly with the
development sources from CVS).
Besides combining GNU Classpath with the runtimes and compilers above
-you might want to add support for encryption libraries as provided by
-GNU Crypto (http://www.gnu.org/software/gnu-crypto/).
-And for additional extension libraries (mail, xml, activation, infobus,
-servlet) check out GNU ClasspathX (http://www.gnu.org/software/classpathx).
+you might want to add support for additional extension libraries (mail,
+activation, infobus, servlet) check out the GNU ClasspathX project
+(http://www.gnu.org/software/classpathx/).
Some tools come with their own customized version of GNU Classpath.
-Please check if there is a customised version available for the tool you
-use before trying the bare bones GNU Classpath release. We are working with
+Please check if there is a customized version available for the tool you
+use before trying the bare bones GNU Classpath release. We are working with
the tool creators to keep the differences between the core classes as small
-as possible. Please tell us if you make GNU Classpath work with a new tool.
+as possible. Please tell us if you make GNU Classpath work with a new tool.
Active projects which use modified versions of the Classpath libraries
some of which synchronizes with the Classpath CVS head every couple of weeks:
@@ -57,9 +55,9 @@ some of which synchronizes with the Classpath CVS head every couple of weeks:
* JC (http://jcvm.sourceforge.net/)
* JNode (http://jnode.sourceforge.net/)
* MysaifuVM (http://www2s.biglobe.ne.jp/~dat/java/project/jvm/)
- * SableVM (http://www.sablevm.org)
+ * SableVM (http://www.sablevm.org/)
-See for a more complete list of GNU Classpath based projects the
+For a more complete list of GNU Classpath based projects, see the
GNU Classpath website: http://www.gnu.org/software/classpath/stories.html
See the file INSTALL for details on installing GNU Classpath.
@@ -69,23 +67,25 @@ See the file HACKING for working on (non-released) CVS development versions.
Homepage: http://www.gnu.org/software/classpath/
+Bugs should be reported via bugzilla, available from the GNU Classpath
+website: http://www.gnu.org/software/classpath/bugs.html
+
General Mailing List: classpath@gnu.org
- --> Bugs and patches can be reported via Savannah if you have a browser
- or via this address otherwise.
--> To subscribe send email to classpath-request@gnu.org with a
subject and body of "subscribe". To unsubscribe do the same,
only with a body and subject of "unsubscribe". This is a
smartlist managed mailing list.
-CVS Commit, Bugs and Patches List: commit-classpath@gnu.org
- --> To subscribe send email to commit-classpath-request@gnu.org with a
+Patches Mailing List: classpath-patches@gnu.org
+ --> Proposed patches should be sent to the GNU Classpath patches list
+ --> To subscribe send email to classpath-patches-request@gnu.org with a
subject and body of "subscribe". To unsubscribe do the same,
only with a body and subject of "unsubscribe". This is a
smartlist managed mailing list.
Anonymous CVS:
- --> export CVS_RSH="ssh"
- --> cvs -z3 -d:ext:anoncvs@savannah.gnu.org:/cvsroot/classpath co classpath
+ --> "cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/classpath
+ co classpath"
--> More detailed instructions available on the Savannah project website.
http://savannah.gnu.org/projects/classpath/
diff --git a/libjava/classpath/THANKYOU b/libjava/classpath/THANKYOU
index d191d7c0574..cb93e25b197 100644
--- a/libjava/classpath/THANKYOU
+++ b/libjava/classpath/THANKYOU
@@ -27,6 +27,7 @@ Steven Hugg (hugg@pobox.com)
jockey@aromasoft.com
Isaac Jones (ijones@cis.ohio-state.edu)
Oskar Liljeblad (osk@hem.passagen.se)
+Trevor Linton (tlinton@xmission.com)
Casey Marshall (rsdio@metastatic.org)
Steve Mayer (SMayer@dynamicsoft.com)
Matt Mucklo (mmucklo@jumpsmart.com)
diff --git a/libjava/classpath/aclocal.m4 b/libjava/classpath/aclocal.m4
index c6085b3d893..1d0405b6d45 100644
--- a/libjava/classpath/aclocal.m4
+++ b/libjava/classpath/aclocal.m4
@@ -468,6 +468,27 @@ AC_DEFUN([AM_PROG_INSTALL_SH],
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
+# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
@@ -873,8 +894,6 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
-m4_include([../../config/depstand.m4])
-m4_include([../../config/lead-dot.m4])
m4_include([../../libtool.m4])
m4_include([m4/acattribute.m4])
m4_include([m4/accross.m4])
diff --git a/libjava/classpath/autogen.sh b/libjava/classpath/autogen.sh
index babfa4e5d83..9919d15b4b5 100755
--- a/libjava/classpath/autogen.sh
+++ b/libjava/classpath/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/libjava/classpath/config.guess b/libjava/classpath/config.guess
index 52c01be4c86..c085f4f51a2 100755
--- a/libjava/classpath/config.guess
+++ b/libjava/classpath/config.guess
@@ -1,9 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
-timestamp='2005-11-11'
+timestamp='2006-05-13'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -106,7 +107,7 @@ set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
@@ -206,6 +207,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
macppc:MirBSD:*:*)
echo powerppc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
@@ -764,7 +768,14 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -780,7 +791,10 @@ EOF
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
x86:Interix*:[345]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T:Interix*:[345]*)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
@@ -851,7 +865,11 @@ EOF
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
mips64:Linux:*:*)
@@ -870,7 +888,11 @@ EOF
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
@@ -919,6 +941,9 @@ EOF
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
@@ -964,7 +989,7 @@ EOF
LIBC=gnulibc1
# endif
#else
- #ifdef __INTEL_COMPILER
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
@@ -974,7 +999,11 @@ EOF
LIBC=dietlibc
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
@@ -1263,6 +1292,9 @@ EOF
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
diff --git a/libjava/classpath/config.sub b/libjava/classpath/config.sub
index eb6b3eb89ce..4d936e23942 100755
--- a/libjava/classpath/config.sub
+++ b/libjava/classpath/config.sub
@@ -1,9 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
-timestamp='2005-12-06'
+timestamp='2006-05-13'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -119,8 +120,9 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -247,7 +249,8 @@ case $basic_machine in
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -267,16 +270,17 @@ case $basic_machine in
| mn10200 | mn10300 \
| mt \
| msp430 \
+ | nios | nios2 \
| ns16k | ns32k \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
@@ -284,9 +288,6 @@ case $basic_machine in
| z8k)
basic_machine=$basic_machine-unknown
;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
@@ -294,10 +295,10 @@ case $basic_machine in
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
- ms1)
- basic_machine=mt-unknown
- ;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
@@ -327,7 +328,7 @@ case $basic_machine in
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
+ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
@@ -349,17 +350,18 @@ case $basic_machine in
| mmix-* \
| mt-* \
| msp430-* \
+ | nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
@@ -370,8 +372,6 @@ case $basic_machine in
| ymp-* \
| z8k-*)
;;
- m32c-*)
- ;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
@@ -708,7 +708,7 @@ case $basic_machine in
os=-msdos
;;
ms1-*)
- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
@@ -817,6 +817,12 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
@@ -873,6 +879,10 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -1115,7 +1125,7 @@ case $basic_machine in
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@@ -1188,21 +1198,23 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
+ | -skyos* | -haiku* | -rdos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1354,6 +1366,9 @@ else
# system, and we'll never get to this point.
case $basic_machine in
+ spu-*)
+ os=-elf
+ ;;
*-acorn)
os=-riscix1.2
;;
@@ -1363,9 +1378,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index cded54990b0..c8f930f8651 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for GNU Classpath 0.92-pre.
+# Generated by GNU Autoconf 2.59 for GNU Classpath 0.92.
#
# Report bugs to <classpath@gnu.org>.
#
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='GNU Classpath'
PACKAGE_TARNAME='classpath'
-PACKAGE_VERSION='0.92-pre'
-PACKAGE_STRING='GNU Classpath 0.92-pre'
+PACKAGE_VERSION='0.92'
+PACKAGE_STRING='GNU Classpath 0.92'
PACKAGE_BUGREPORT='classpath@gnu.org'
ac_unique_file="java/lang/System.java"
@@ -312,7 +312,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os LIBVERSION CLASSPATH_MODULE CLASSPATH_CONVENIENCE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CREATE_COLLECTIONS_TRUE CREATE_COLLECTIONS_FALSE CREATE_JNI_LIBRARIES_TRUE CREATE_JNI_LIBRARIES_FALSE CREATE_CORE_JNI_LIBRARIES_TRUE CREATE_CORE_JNI_LIBRARIES_FALSE default_toolkit CREATE_XMLJ_LIBRARY_TRUE CREATE_XMLJ_LIBRARY_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CREATE_ALSA_LIBRARIES_TRUE CREATE_ALSA_LIBRARIES_FALSE CREATE_DSSI_LIBRARIES_TRUE CREATE_DSSI_LIBRARIES_FALSE CREATE_GTK_PEER_LIBRARIES_TRUE CREATE_GTK_PEER_LIBRARIES_FALSE CREATE_QT_PEER_LIBRARIES_TRUE CREATE_QT_PEER_LIBRARIES_FALSE CREATE_PLUGIN_TRUE CREATE_PLUGIN_FALSE nativeexeclibdir glibjdir VM_BINARY FOUND_CACAO_TRUE FOUND_CACAO_FALSE CREATE_JNI_HEADERS_TRUE CREATE_JNI_HEADERS_FALSE CREATE_WRAPPERS_TRUE CREATE_WRAPPERS_FALSE LN_S CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE RANLIB ac_ct_RANLIB LIBTOOL CXXCPP PERL COLLECTIONS_PREFIX LIBMAGIC LIBICONV LTLIBICONV WARNING_CFLAGS STRICT_WARNING_CFLAGS ERROR_CFLAGS PKG_CONFIG XML_CFLAGS XML_LIBS XSLT_CFLAGS XSLT_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GTK_CFLAGS GTK_LIBS FREETYPE2_CFLAGS FREETYPE2_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS XTEST_LIBS QT_CFLAGS QT_LIBS MOC MOZILLA_CFLAGS MOZILLA_LIBS GLIB_CFLAGS GLIB_LIBS PLUGIN_DIR USER_JAVAH USER_SPECIFIED_JAVAH_TRUE USER_SPECIFIED_JAVAH_FALSE CLASSPATH_INCLUDES GCJ JIKES JIKESENCODING JIKESWARNINGS KJC GCJX ECJ FOUND_GCJ_TRUE FOUND_GCJ_FALSE FOUND_JIKES_TRUE FOUND_JIKES_FALSE FOUND_ECJ_TRUE FOUND_ECJ_FALSE FOUND_KJC_TRUE FOUND_KJC_FALSE FOUND_GCJX_TRUE FOUND_GCJX_FALSE USER_CLASSLIB USER_SPECIFIED_CLASSLIB_TRUE USER_SPECIFIED_CLASSLIB_FALSE vm_classes MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBDEBUG INIT_LOAD_LIBRARY JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION REMOVE MKDIR CP DATE FIND ZIP FASTJAR INSTALL_GLIBJ_ZIP_TRUE INSTALL_GLIBJ_ZIP_FALSE INSTALL_CLASS_FILES_TRUE INSTALL_CLASS_FILES_FALSE BUILD_CLASS_FILES_TRUE BUILD_CLASS_FILES_FALSE EXAMPLESDIR GJDOC CREATE_API_DOCS_TRUE CREATE_API_DOCS_FALSE JAY JAY_SKELETON REGEN_PARSERS_TRUE REGEN_PARSERS_FALSE USE_PREBUILT_GLIBJ_ZIP_TRUE USE_PREBUILT_GLIBJ_ZIP_FALSE PATH_TO_GLIBJ_ZIP ENABLE_LOCAL_SOCKETS_TRUE ENABLE_LOCAL_SOCKETS_FALSE LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os LIBVERSION CLASSPATH_MODULE CLASSPATH_CONVENIENCE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CREATE_COLLECTIONS_TRUE CREATE_COLLECTIONS_FALSE CREATE_JNI_LIBRARIES_TRUE CREATE_JNI_LIBRARIES_FALSE CREATE_CORE_JNI_LIBRARIES_TRUE CREATE_CORE_JNI_LIBRARIES_FALSE CREATE_GCONF_PEER_LIBRARIES_TRUE CREATE_GCONF_PEER_LIBRARIES_FALSE default_toolkit CREATE_XMLJ_LIBRARY_TRUE CREATE_XMLJ_LIBRARY_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CREATE_ALSA_LIBRARIES_TRUE CREATE_ALSA_LIBRARIES_FALSE CREATE_DSSI_LIBRARIES_TRUE CREATE_DSSI_LIBRARIES_FALSE CREATE_GTK_PEER_LIBRARIES_TRUE CREATE_GTK_PEER_LIBRARIES_FALSE CREATE_QT_PEER_LIBRARIES_TRUE CREATE_QT_PEER_LIBRARIES_FALSE CREATE_PLUGIN_TRUE CREATE_PLUGIN_FALSE nativeexeclibdir glibjdir VM_BINARY FOUND_CACAO_TRUE FOUND_CACAO_FALSE CREATE_JNI_HEADERS_TRUE CREATE_JNI_HEADERS_FALSE CREATE_WRAPPERS_TRUE CREATE_WRAPPERS_FALSE LN_S CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE RANLIB ac_ct_RANLIB LIBTOOL CXXCPP PERL COLLECTIONS_PREFIX LIBMAGIC LIBICONV LTLIBICONV WARNING_CFLAGS STRICT_WARNING_CFLAGS ERROR_CFLAGS PKG_CONFIG XML_CFLAGS XML_LIBS XSLT_CFLAGS XSLT_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GTK_CFLAGS GTK_LIBS FREETYPE2_CFLAGS FREETYPE2_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS XTEST_LIBS GCONF_CFLAGS GCONF_LIBS GDK_CFLAGS GDK_LIBS QT_CFLAGS QT_LIBS MOC MOZILLA_CFLAGS MOZILLA_LIBS GLIB_CFLAGS GLIB_LIBS PLUGIN_DIR USER_JAVAH USER_SPECIFIED_JAVAH_TRUE USER_SPECIFIED_JAVAH_FALSE CLASSPATH_INCLUDES GCJ JIKES JIKESENCODING JIKESWARNINGS KJC GCJX ECJ FOUND_GCJ_TRUE FOUND_GCJ_FALSE FOUND_JIKES_TRUE FOUND_JIKES_FALSE FOUND_ECJ_TRUE FOUND_ECJ_FALSE FOUND_KJC_TRUE FOUND_KJC_FALSE FOUND_GCJX_TRUE FOUND_GCJX_FALSE USER_CLASSLIB USER_SPECIFIED_CLASSLIB_TRUE USER_SPECIFIED_CLASSLIB_FALSE vm_classes MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBDEBUG INIT_LOAD_LIBRARY JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION REMOVE MKDIR CP DATE FIND ZIP FASTJAR INSTALL_GLIBJ_ZIP_TRUE INSTALL_GLIBJ_ZIP_FALSE INSTALL_CLASS_FILES_TRUE INSTALL_CLASS_FILES_FALSE BUILD_CLASS_FILES_TRUE BUILD_CLASS_FILES_FALSE EXAMPLESDIR GJDOC CREATE_API_DOCS_TRUE CREATE_API_DOCS_FALSE JAY JAY_SKELETON REGEN_PARSERS_TRUE REGEN_PARSERS_FALSE USE_PREBUILT_GLIBJ_ZIP_TRUE USE_PREBUILT_GLIBJ_ZIP_FALSE PATH_TO_GLIBJ_ZIP USE_ESCHER_TRUE USE_ESCHER_FALSE PATH_TO_ESCHER ENABLE_LOCAL_SOCKETS_TRUE ENABLE_LOCAL_SOCKETS_FALSE DEFAULT_PREFS_PEER LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -793,7 +793,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures GNU Classpath 0.92-pre to adapt to many kinds of systems.
+\`configure' configures GNU Classpath 0.92 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -864,7 +864,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of GNU Classpath 0.92-pre:";;
+ short | recursive ) echo "Configuration of GNU Classpath 0.92:";;
esac
cat <<\_ACEOF
@@ -874,6 +874,12 @@ Optional Features:
--enable-collections create collections.jar default=no
--enable-jni compile JNI source default=yes
--enable-core-jni compile JNI sources for core default=yes
+ --enable-default-preferences-peer
+ fully qualified class name of default Preferences
+ API Backend
+ --disable-gconf-peer compile GConf native peers (disabled by
+ --disable-jni) default=yes
+
--enable-Werror whether to compile C code with -Werror which turns
any compiler warning into a compilation failure
default=no
@@ -888,7 +894,6 @@ Optional Features:
default=yes
--disable-gtk-peer compile GTK native peers (disabled by --disable-jni)
default=yes
-
--enable-qt-peer compile Qt4 native peers (disabled by --disable-jni)
default=no
--disable-plugin compile gcjwebplugin (disabled by --disable-plugin)
@@ -944,6 +949,7 @@ Optional Packages:
path to the jay executable
--with-glibj-zip=ABS.PATH
use prebuilt glibj.zip class library
+ --with-escher=ABS.PATH specify path to escher dir or JAR for X peers
Some influential environment variables:
CC C compiler command
@@ -1056,7 +1062,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-GNU Classpath configure 0.92-pre
+GNU Classpath configure 0.92
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1070,7 +1076,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by GNU Classpath $as_me 0.92-pre, which was
+It was created by GNU Classpath $as_me 0.92, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1818,7 +1824,7 @@ fi
# Define the identity of the package.
PACKAGE='classpath'
- VERSION='0.92-pre'
+ VERSION='0.92'
cat >>confdefs.h <<_ACEOF
@@ -2100,6 +2106,46 @@ else
fi
+# Check whether --enable-default-preferences-peer or --disable-default-preferences-peer was given.
+if test "${enable_default_preferences_peer+set}" = set; then
+ enableval="$enable_default_preferences_peer"
+
+fi;
+DEFAULT_PREFS_PEER=$enable_default_preferences_peer
+if test "$DEFAULT_PREFS_PEER" = ""; then
+ DEFAULT_PREFS_PEER=gnu.java.util.prefs.FileBasedFactory
+fi
+
+# Check whether --enable-gconf-peer or --disable-gconf-peer was given.
+if test "${enable_gconf_peer+set}" = set; then
+ enableval="$enable_gconf_peer"
+ case "${enableval}" in
+ yes) COMPILE_GCONF_PEER=yes ;;
+ no) COMPILE_GCONF_PEER=no ;;
+ *) COMPILE_GCONF_PEER=yes ;;
+ esac
+else
+ COMPILE_GCONF_PEER=yes
+fi;
+
+
+if test "x${COMPILE_GCONF_PEER}" = xyes; then
+ CREATE_GCONF_PEER_LIBRARIES_TRUE=
+ CREATE_GCONF_PEER_LIBRARIES_FALSE='#'
+else
+ CREATE_GCONF_PEER_LIBRARIES_TRUE='#'
+ CREATE_GCONF_PEER_LIBRARIES_FALSE=
+fi
+
+
+# Check whether --enable-gconf-peers or --disable-gconf-peers was given.
+if test "${enable_gconf_peers+set}" = set; then
+ enableval="$enable_gconf_peers"
+ { { echo "$as_me:$LINENO: error: No --enable-gconf-peers (or --disable-gconf-peers) option; you want --enable-gconf-peer" >&5
+echo "$as_me: error: No --enable-gconf-peers (or --disable-gconf-peers) option; you want --enable-gconf-peer" >&2;}
+ { (exit 1); exit 1; }; }
+fi;
+
# Check whether --enable-Werror or --disable-Werror was given.
if test "${enable_Werror+set}" = set; then
enableval="$enable_Werror"
@@ -5666,7 +5712,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5669 "configure"' > conftest.$ac_ext
+ echo '#line 5715 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -10007,7 +10053,7 @@ ac_x_header_dirs='
/usr/openwin/share/include'
if test "$ac_x_includes" = no; then
- # Guess where to find include files, by looking for Intrinsic.h.
+ # Guess where to find include files, by looking for Xlib.h.
# First, try using that file with no special directory specified.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -10015,7 +10061,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@@ -10042,7 +10088,7 @@ else
sed 's/^/| /' conftest.$ac_ext >&5
for ac_dir in $ac_x_header_dirs; do
- if test -r "$ac_dir/X11/Intrinsic.h"; then
+ if test -r "$ac_dir/X11/Xlib.h"; then
ac_x_includes=$ac_dir
break
fi
@@ -10063,11 +10109,11 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
int
main ()
{
-XtMalloc (0)
+XrmInitialize ()
;
return 0;
}
@@ -11831,6 +11877,213 @@ fi
fi
+ if test "x${COMPILE_GCONF_PEER}" = xyes; then
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for gconf-2.0 >= 2.11.2" >&5
+echo $ECHO_N "checking for gconf-2.0 >= 2.11.2... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "gconf-2.0 >= 2.11.2" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking GCONF_CFLAGS" >&5
+echo $ECHO_N "checking GCONF_CFLAGS... $ECHO_C" >&6
+ GCONF_CFLAGS=`$PKG_CONFIG --cflags "gconf-2.0 >= 2.11.2"`
+ echo "$as_me:$LINENO: result: $GCONF_CFLAGS" >&5
+echo "${ECHO_T}$GCONF_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking GCONF_LIBS" >&5
+echo $ECHO_N "checking GCONF_LIBS... $ECHO_C" >&6
+ GCONF_LIBS=`$PKG_CONFIG --libs "gconf-2.0 >= 2.11.2"`
+ echo "$as_me:$LINENO: result: $GCONF_LIBS" >&5
+echo "${ECHO_T}$GCONF_LIBS" >&6
+ else
+ GCONF_CFLAGS=""
+ GCONF_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ GCONF_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gconf-2.0 >= 2.11.2"`
+ echo $GCONF_PKG_ERRORS
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ :
+ else
+ { { echo "$as_me:$LINENO: error: Library requirements (gconf-2.0 >= 2.11.2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (gconf-2.0 >= 2.11.2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+
+
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for gdk-2.0 >= 2.8" >&5
+echo $ECHO_N "checking for gdk-2.0 >= 2.8... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "gdk-2.0 >= 2.8" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking GDK_CFLAGS" >&5
+echo $ECHO_N "checking GDK_CFLAGS... $ECHO_C" >&6
+ GDK_CFLAGS=`$PKG_CONFIG --cflags "gdk-2.0 >= 2.8"`
+ echo "$as_me:$LINENO: result: $GDK_CFLAGS" >&5
+echo "${ECHO_T}$GDK_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking GDK_LIBS" >&5
+echo $ECHO_N "checking GDK_LIBS... $ECHO_C" >&6
+ GDK_LIBS=`$PKG_CONFIG --libs "gdk-2.0 >= 2.8"`
+ echo "$as_me:$LINENO: result: $GDK_LIBS" >&5
+echo "${ECHO_T}$GDK_LIBS" >&6
+ else
+ GDK_CFLAGS=""
+ GDK_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ GDK_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gdk-2.0 >= 2.8"`
+ echo $GDK_PKG_ERRORS
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ :
+ else
+ { { echo "$as_me:$LINENO: error: Library requirements (gdk-2.0 >= 2.8) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (gdk-2.0 >= 2.8) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+
+
+ USE_GCONF_PREFS_PEER=$enable_default_preferences_peer
+ if test "$USE_GCONF_PREFS_PEER" = ""; then
+ DEFAULT_PREFS_PEER=gnu.java.util.prefs.GConfBasedFactory
+ fi
+ fi
+
if test "x${COMPILE_QT_PEER}" = xyes; then
succeeded=no
@@ -12015,6 +12268,41 @@ else
echo "${ECHO_T}no" >&6
fi
+ # Extract the first word of "moc-qt4", so it can be a program name with args.
+set dummy moc-qt4; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MOC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$MOC"; then
+ ac_cv_prog_MOC="$MOC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_MOC="moc-qt4"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+MOC=$ac_cv_prog_MOC
+if test -n "$MOC"; then
+ echo "$as_me:$LINENO: result: $MOC" >&5
+echo "${ECHO_T}$MOC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
fi
if test "x$HAVE_QT4" = "xno"; then
{ echo "$as_me:$LINENO: Looking for QT_CFLAGS and QT_LIBS without pkg-config" >&5
@@ -12388,6 +12676,104 @@ echo "${ECHO_T}$MOZILLA_LIBS" >&6
fi
fi
+ if test "x${MOZILLA_FOUND}" = xno; then
+
+ succeeded=no
+
+ if test -z "$PKG_CONFIG"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+ echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ fi
+
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment variable"
+ echo "*** to the full path to pkg-config."
+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+ else
+ PKG_CONFIG_MIN_VERSION=0.9.0
+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+ echo "$as_me:$LINENO: checking for mozilla-firefox-plugin" >&5
+echo $ECHO_N "checking for mozilla-firefox-plugin... $ECHO_C" >&6
+
+ if $PKG_CONFIG --exists "mozilla-firefox-plugin" ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ succeeded=yes
+
+ echo "$as_me:$LINENO: checking MOZILLA_CFLAGS" >&5
+echo $ECHO_N "checking MOZILLA_CFLAGS... $ECHO_C" >&6
+ MOZILLA_CFLAGS=`$PKG_CONFIG --cflags "mozilla-firefox-plugin"`
+ echo "$as_me:$LINENO: result: $MOZILLA_CFLAGS" >&5
+echo "${ECHO_T}$MOZILLA_CFLAGS" >&6
+
+ echo "$as_me:$LINENO: checking MOZILLA_LIBS" >&5
+echo $ECHO_N "checking MOZILLA_LIBS... $ECHO_C" >&6
+ MOZILLA_LIBS=`$PKG_CONFIG --libs "mozilla-firefox-plugin"`
+ echo "$as_me:$LINENO: result: $MOZILLA_LIBS" >&5
+echo "${ECHO_T}$MOZILLA_LIBS" >&6
+ else
+ MOZILLA_CFLAGS=""
+ MOZILLA_LIBS=""
+ ## If we have a custom action on failure, don't print errors, but
+ ## do set a variable so people can do so.
+ MOZILLA_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "mozilla-firefox-plugin"`
+
+ fi
+
+
+
+ else
+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
+ fi
+ fi
+
+ if test $succeeded = yes; then
+ MOZILLA_FOUND=yes
+ else
+ MOZILLA_FOUND=no
+ fi
+
+ fi
succeeded=no
@@ -18128,6 +18514,41 @@ fi
+# Check whether --with-escher or --without-escher was given.
+if test "${with_escher+set}" = set; then
+ withval="$with_escher"
+
+fi;
+case "$with_escher" in
+"")
+ use_escher=false
+ ;;
+"no")
+ use_escher=false
+ ;;
+"yes")
+ { { echo "$as_me:$LINENO: error: Please suply an absolute path to Escher library" >&5
+echo "$as_me: error: Please suply an absolute path to Escher library" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+*)
+ use_escher=true
+ PATH_TO_ESCHER=$with_escher
+ ;;
+esac;
+
+
+
+if test x$use_escher = xtrue; then
+ USE_ESCHER_TRUE=
+ USE_ESCHER_FALSE='#'
+else
+ USE_ESCHER_TRUE='#'
+ USE_ESCHER_FALSE=
+fi
+
+
+
# Check whether --enable-local-sockets or --disable-local-sockets was given.
if test "${enable_local_sockets+set}" = set; then
enableval="$enable_local_sockets"
@@ -18410,7 +18831,27 @@ fi
- ac_config_files="$ac_config_files Makefile doc/Makefile doc/api/Makefile external/Makefile external/sax/Makefile external/w3c_dom/Makefile external/relaxngDatatype/Makefile gnu/classpath/Configuration.java include/Makefile native/Makefile native/fdlibm/Makefile native/jawt/Makefile native/jni/Makefile native/jni/classpath/Makefile native/jni/java-io/Makefile native/jni/java-lang/Makefile native/jni/java-net/Makefile native/jni/java-nio/Makefile native/jni/java-util/Makefile native/jni/gtk-peer/Makefile native/jni/qt-peer/Makefile native/jni/xmlj/Makefile native/jni/midi-alsa/Makefile native/jni/midi-dssi/Makefile native/plugin/Makefile native/target/Makefile native/target/Linux/Makefile native/target/generic/Makefile resource/Makefile scripts/Makefile scripts/classpath.spec lib/Makefile lib/gen-classlist.sh lib/copy-vmresources.sh tools/Makefile examples/Makefile examples/Makefile.jawt"
+
+ ac_config_files="$ac_config_files Makefile doc/Makefile doc/api/Makefile external/Makefile external/sax/Makefile external/w3c_dom/Makefile external/relaxngDatatype/Makefile gnu/classpath/Configuration.java gnu/java/security/Configuration.java include/Makefile native/Makefile native/fdlibm/Makefile native/jawt/Makefile native/jni/Makefile native/jni/classpath/Makefile native/jni/java-io/Makefile native/jni/java-lang/Makefile native/jni/java-net/Makefile native/jni/java-nio/Makefile native/jni/java-util/Makefile native/jni/gtk-peer/Makefile native/jni/gconf-peer/Makefile native/jni/qt-peer/Makefile native/jni/xmlj/Makefile native/jni/midi-alsa/Makefile native/jni/midi-dssi/Makefile native/plugin/Makefile native/target/Makefile native/target/Linux/Makefile native/target/generic/Makefile resource/Makefile resource/META-INF/services/java.util.prefs.PreferencesFactory scripts/Makefile scripts/classpath.spec lib/Makefile lib/gen-classlist.sh lib/copy-vmresources.sh tools/Makefile examples/Makefile examples/Makefile.jawt examples/Makefile.java2d"
+
+
+if test "x${COMPILE_WRAPPERS}" = xno
+then
+ ac_config_files="$ac_config_files tools/gappletviewer tools/gjarsigner tools/gkeytool tools/gjar tools/gnative2ascii tools/gserialver"
+
+ ac_config_commands="$ac_config_commands gappletviewer"
+
+ ac_config_commands="$ac_config_commands gjarsigner"
+
+ ac_config_commands="$ac_config_commands gkeytool"
+
+ ac_config_commands="$ac_config_commands gjar"
+
+ ac_config_commands="$ac_config_commands gnative2ascii"
+
+ ac_config_commands="$ac_config_commands gserialver"
+
+fi
if test "x${COMPILE_WRAPPERS}" = xno
@@ -18541,6 +18982,13 @@ echo "$as_me: error: conditional \"CREATE_CORE_JNI_LIBRARIES\" was never defined
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${CREATE_GCONF_PEER_LIBRARIES_TRUE}" && test -z "${CREATE_GCONF_PEER_LIBRARIES_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"CREATE_GCONF_PEER_LIBRARIES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CREATE_GCONF_PEER_LIBRARIES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${CREATE_XMLJ_LIBRARY_TRUE}" && test -z "${CREATE_XMLJ_LIBRARY_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"CREATE_XMLJ_LIBRARY\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -18751,6 +19199,13 @@ echo "$as_me: error: conditional \"USE_PREBUILT_GLIBJ_ZIP\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${USE_ESCHER_TRUE}" && test -z "${USE_ESCHER_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"USE_ESCHER\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"USE_ESCHER\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${ENABLE_LOCAL_SOCKETS_TRUE}" && test -z "${ENABLE_LOCAL_SOCKETS_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"ENABLE_LOCAL_SOCKETS\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -19029,7 +19484,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by GNU Classpath $as_me 0.92-pre, which was
+This file was extended by GNU Classpath $as_me 0.92, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -19095,7 +19550,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-GNU Classpath config.status 0.92-pre
+GNU Classpath config.status 0.92
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -19232,6 +19687,7 @@ do
"external/w3c_dom/Makefile" ) CONFIG_FILES="$CONFIG_FILES external/w3c_dom/Makefile" ;;
"external/relaxngDatatype/Makefile" ) CONFIG_FILES="$CONFIG_FILES external/relaxngDatatype/Makefile" ;;
"gnu/classpath/Configuration.java" ) CONFIG_FILES="$CONFIG_FILES gnu/classpath/Configuration.java" ;;
+ "gnu/java/security/Configuration.java" ) CONFIG_FILES="$CONFIG_FILES gnu/java/security/Configuration.java" ;;
"include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
"native/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/Makefile" ;;
"native/fdlibm/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/fdlibm/Makefile" ;;
@@ -19244,6 +19700,7 @@ do
"native/jni/java-nio/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/java-nio/Makefile" ;;
"native/jni/java-util/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/java-util/Makefile" ;;
"native/jni/gtk-peer/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/gtk-peer/Makefile" ;;
+ "native/jni/gconf-peer/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/gconf-peer/Makefile" ;;
"native/jni/qt-peer/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/qt-peer/Makefile" ;;
"native/jni/xmlj/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/xmlj/Makefile" ;;
"native/jni/midi-alsa/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/midi-alsa/Makefile" ;;
@@ -19253,6 +19710,7 @@ do
"native/target/Linux/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/target/Linux/Makefile" ;;
"native/target/generic/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/target/generic/Makefile" ;;
"resource/Makefile" ) CONFIG_FILES="$CONFIG_FILES resource/Makefile" ;;
+ "resource/META-INF/services/java.util.prefs.PreferencesFactory" ) CONFIG_FILES="$CONFIG_FILES resource/META-INF/services/java.util.prefs.PreferencesFactory" ;;
"scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
"scripts/classpath.spec" ) CONFIG_FILES="$CONFIG_FILES scripts/classpath.spec" ;;
"lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
@@ -19261,6 +19719,13 @@ do
"tools/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
"examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
"examples/Makefile.jawt" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile.jawt" ;;
+ "examples/Makefile.java2d" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile.java2d" ;;
+ "tools/gappletviewer" ) CONFIG_FILES="$CONFIG_FILES tools/gappletviewer" ;;
+ "tools/gjarsigner" ) CONFIG_FILES="$CONFIG_FILES tools/gjarsigner" ;;
+ "tools/gkeytool" ) CONFIG_FILES="$CONFIG_FILES tools/gkeytool" ;;
+ "tools/gjar" ) CONFIG_FILES="$CONFIG_FILES tools/gjar" ;;
+ "tools/gnative2ascii" ) CONFIG_FILES="$CONFIG_FILES tools/gnative2ascii" ;;
+ "tools/gserialver" ) CONFIG_FILES="$CONFIG_FILES tools/gserialver" ;;
"tools/appletviewer" ) CONFIG_FILES="$CONFIG_FILES tools/appletviewer" ;;
"tools/jarsigner" ) CONFIG_FILES="$CONFIG_FILES tools/jarsigner" ;;
"tools/keytool" ) CONFIG_FILES="$CONFIG_FILES tools/keytool" ;;
@@ -19268,6 +19733,12 @@ do
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"mkcollections.pl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS mkcollections.pl" ;;
"$ac_stdint_h" ) CONFIG_COMMANDS="$CONFIG_COMMANDS $ac_stdint_h" ;;
+ "gappletviewer" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gappletviewer" ;;
+ "gjarsigner" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gjarsigner" ;;
+ "gkeytool" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gkeytool" ;;
+ "gjar" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gjar" ;;
+ "gnative2ascii" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gnative2ascii" ;;
+ "gserialver" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gserialver" ;;
"appletviewer" ) CONFIG_COMMANDS="$CONFIG_COMMANDS appletviewer" ;;
"jarsigner" ) CONFIG_COMMANDS="$CONFIG_COMMANDS jarsigner" ;;
"keytool" ) CONFIG_COMMANDS="$CONFIG_COMMANDS keytool" ;;
@@ -19403,6 +19874,8 @@ s,@CREATE_JNI_LIBRARIES_TRUE@,$CREATE_JNI_LIBRARIES_TRUE,;t t
s,@CREATE_JNI_LIBRARIES_FALSE@,$CREATE_JNI_LIBRARIES_FALSE,;t t
s,@CREATE_CORE_JNI_LIBRARIES_TRUE@,$CREATE_CORE_JNI_LIBRARIES_TRUE,;t t
s,@CREATE_CORE_JNI_LIBRARIES_FALSE@,$CREATE_CORE_JNI_LIBRARIES_FALSE,;t t
+s,@CREATE_GCONF_PEER_LIBRARIES_TRUE@,$CREATE_GCONF_PEER_LIBRARIES_TRUE,;t t
+s,@CREATE_GCONF_PEER_LIBRARIES_FALSE@,$CREATE_GCONF_PEER_LIBRARIES_FALSE,;t t
s,@default_toolkit@,$default_toolkit,;t t
s,@CREATE_XMLJ_LIBRARY_TRUE@,$CREATE_XMLJ_LIBRARY_TRUE,;t t
s,@CREATE_XMLJ_LIBRARY_FALSE@,$CREATE_XMLJ_LIBRARY_FALSE,;t t
@@ -19478,6 +19951,10 @@ s,@FREETYPE2_LIBS@,$FREETYPE2_LIBS,;t t
s,@PANGOFT2_CFLAGS@,$PANGOFT2_CFLAGS,;t t
s,@PANGOFT2_LIBS@,$PANGOFT2_LIBS,;t t
s,@XTEST_LIBS@,$XTEST_LIBS,;t t
+s,@GCONF_CFLAGS@,$GCONF_CFLAGS,;t t
+s,@GCONF_LIBS@,$GCONF_LIBS,;t t
+s,@GDK_CFLAGS@,$GDK_CFLAGS,;t t
+s,@GDK_LIBS@,$GDK_LIBS,;t t
s,@QT_CFLAGS@,$QT_CFLAGS,;t t
s,@QT_LIBS@,$QT_LIBS,;t t
s,@MOC@,$MOC,;t t
@@ -19541,8 +20018,12 @@ s,@REGEN_PARSERS_FALSE@,$REGEN_PARSERS_FALSE,;t t
s,@USE_PREBUILT_GLIBJ_ZIP_TRUE@,$USE_PREBUILT_GLIBJ_ZIP_TRUE,;t t
s,@USE_PREBUILT_GLIBJ_ZIP_FALSE@,$USE_PREBUILT_GLIBJ_ZIP_FALSE,;t t
s,@PATH_TO_GLIBJ_ZIP@,$PATH_TO_GLIBJ_ZIP,;t t
+s,@USE_ESCHER_TRUE@,$USE_ESCHER_TRUE,;t t
+s,@USE_ESCHER_FALSE@,$USE_ESCHER_FALSE,;t t
+s,@PATH_TO_ESCHER@,$PATH_TO_ESCHER,;t t
s,@ENABLE_LOCAL_SOCKETS_TRUE@,$ENABLE_LOCAL_SOCKETS_TRUE,;t t
s,@ENABLE_LOCAL_SOCKETS_FALSE@,$ENABLE_LOCAL_SOCKETS_FALSE,;t t
+s,@DEFAULT_PREFS_PEER@,$DEFAULT_PREFS_PEER,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
@@ -20843,6 +21324,12 @@ echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
mv $ac_stdint $ac_stdint_h
fi
;;
+ gappletviewer ) chmod 755 tools/gappletviewer ;;
+ gjarsigner ) chmod 755 tools/gjarsigner ;;
+ gkeytool ) chmod 755 tools/gkeytool ;;
+ gjar ) chmod 755 tools/gjar ;;
+ gnative2ascii ) chmod 755 tools/gnative2ascii ;;
+ gserialver ) chmod 755 tools/gserialver ;;
appletviewer ) chmod 755 tools/appletviewer ;;
jarsigner ) chmod 755 tools/jarsigner ;;
keytool ) chmod 755 tools/keytool ;;
@@ -20881,3 +21368,10 @@ if test "$no_create" != yes; then
$ac_cs_success || { (exit 1); exit 1; }
fi
+
+# Create standard.omit based on decisions we just made.
+cat ${srcdir}/lib/standard.omit.in > lib/standard.omit
+if test x$use_escher != xtrue; then
+ echo gnu/java/awt/peer/x/.*java$ >> lib/standard.omit
+fi
+
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index bd3ba21998e..800c4520ed5 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -6,7 +6,7 @@ dnl -----------------------------------------------------------
dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl
-AC_INIT([GNU Classpath],[0.92-pre],[classpath@gnu.org],[classpath])
+AC_INIT([GNU Classpath],[0.92],[classpath@gnu.org],[classpath])
AC_CONFIG_SRCDIR(java/lang/System.java)
AC_CANONICAL_TARGET
@@ -82,6 +82,36 @@ AC_ARG_ENABLE([core-jni],
[COMPILE_CORE_JNI=yes])
AM_CONDITIONAL(CREATE_CORE_JNI_LIBRARIES, test "x${COMPILE_CORE_JNI}" = xyes)
+dnl -----------------------------------------------------------
+dnl Default Preference Backend
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE(default-preferences-peer,
+ AS_HELP_STRING([--enable-default-preferences-peer],
+ [fully qualified class name of default Preferences API Backend]))
+DEFAULT_PREFS_PEER=$enable_default_preferences_peer
+if test "$DEFAULT_PREFS_PEER" = ""; then
+ DEFAULT_PREFS_PEER=gnu.java.util.prefs.FileBasedFactory
+fi
+dnl AC_SUBST(DEFAULT_PREFS_PEER)
+
+dnl -----------------------------------------------------------
+dnl GConf native peer (enabled by default)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([gconf-peer],
+ [AS_HELP_STRING(--disable-gconf-peer,compile GConf native peers (disabled by --disable-jni) [default=yes])],
+ [case "${enableval}" in
+ yes) COMPILE_GCONF_PEER=yes ;;
+ no) COMPILE_GCONF_PEER=no ;;
+ *) COMPILE_GCONF_PEER=yes ;;
+ esac],
+ [COMPILE_GCONF_PEER=yes])
+AM_CONDITIONAL(CREATE_GCONF_PEER_LIBRARIES, test "x${COMPILE_GCONF_PEER}" = xyes)
+
+dnl -----------------------------------------------------------
+dnl GTK native peer error checking
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([gconf-peers],,AC_MSG_ERROR([No --enable-gconf-peers (or --disable-gconf-peers) option; you want --enable-gconf-peer]))
+
dnl ------------------------------------------------------------
dnl Whether to compile with -Werror or not (disabled by default)
dnl ------------------------------------------------------------
@@ -432,6 +462,24 @@ if test "x${COMPILE_JNI}" = xyes; then
AC_SUBST(XTEST_LIBS)
fi
+ dnl gconf-peer
+ if test "x${COMPILE_GCONF_PEER}" = xyes; then
+ PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.11.2)
+ AC_SUBST(GCONF_CFLAGS)
+ AC_SUBST(GCONF_LIBS)
+ dnl we also need gdk for locking
+ PKG_CHECK_MODULES(GDK, gdk-2.0 >= 2.8)
+ AC_SUBST(GDK_CFLAGS)
+ AC_SUBST(GDK_LIBS)
+ dnl check if the config value was given form the command line,
+ dnl if not, overwrite the default if we have the gconf backend
+ dnl compiled in
+ USE_GCONF_PREFS_PEER=$enable_default_preferences_peer
+ if test "$USE_GCONF_PREFS_PEER" = ""; then
+ DEFAULT_PREFS_PEER=gnu.java.util.prefs.GConfBasedFactory
+ fi
+ fi
+
dnl Check for AWT related Qt4
if test "x${COMPILE_QT_PEER}" = xyes; then
PKG_CHECK_MODULES(QT, QtCore QtGui >= 4.1.0, HAVE_QT4="yes", HAVE_QT4="no")
@@ -446,6 +494,7 @@ if test "x${COMPILE_JNI}" = xyes; then
QT_CFLAGS="$QT_CFLAGS -I$EXTRA_QT_INCLUDE_DIR",
AC_MSG_WARN([QWidget not found])))
AC_CHECK_PROG(MOC, [moc], [moc])
+ AC_CHECK_PROG(MOC, [moc-qt4], [moc-qt4])
fi
if test "x$HAVE_QT4" = "xno"; then
AC_MSG_NOTICE([Looking for QT_CFLAGS and QT_LIBS without pkg-config])
@@ -490,6 +539,9 @@ if test "x${COMPILE_JNI}" = xyes; then
if test "x${MOZILLA_FOUND}" = xno; then
PKG_CHECK_MODULES(MOZILLA, xulrunner-plugin, [MOZILLA_FOUND=yes], [MOZILLA_FOUND=no])
fi
+ if test "x${MOZILLA_FOUND}" = xno; then
+ PKG_CHECK_MODULES(MOZILLA, mozilla-firefox-plugin, [MOZILLA_FOUND=yes], [MOZILLA_FOUND=no])
+ fi
PKG_CHECK_MODULES(GLIB, glib-2.0)
AC_SUBST(MOZILLA_CFLAGS)
@@ -671,6 +723,30 @@ esac;
AM_CONDITIONAL(USE_PREBUILT_GLIBJ_ZIP, test x$use_glibj_zip = xtrue)
AC_SUBST(PATH_TO_GLIBJ_ZIP)
+dnl -----------------------------------------------------------
+dnl Build with Escher based X peers.
+dnl -----------------------------------------------------------
+AC_ARG_WITH([escher],
+ AS_HELP_STRING([--with-escher=ABS.PATH],
+ [specify path to escher dir or JAR for X peers]))
+case "$with_escher" in
+"")
+ use_escher=false
+ ;;
+"no")
+ use_escher=false
+ ;;
+"yes")
+ AC_MSG_ERROR([Please suply an absolute path to Escher library])
+ ;;
+*)
+ use_escher=true
+ PATH_TO_ESCHER=$with_escher
+ ;;
+esac;
+
+AM_CONDITIONAL(USE_ESCHER, test x$use_escher = xtrue)
+AC_SUBST(PATH_TO_ESCHER)
dnl -----------------------------------------------------------
dnl Check if local socket support should be included.
@@ -695,6 +771,10 @@ then
fi
AM_CONDITIONAL(ENABLE_LOCAL_SOCKETS, test "x$ENABLE_LOCAL_SOCKETS" = "xyes")
+dnl -----------------------------------------------------------
+dnl Add the default preference peer
+dnl -----------------------------------------------------------
+AC_SUBST(DEFAULT_PREFS_PEER)
dnl -----------------------------------------------------------
dnl output files
@@ -707,6 +787,7 @@ external/sax/Makefile
external/w3c_dom/Makefile
external/relaxngDatatype/Makefile
gnu/classpath/Configuration.java
+gnu/java/security/Configuration.java
include/Makefile
native/Makefile
native/fdlibm/Makefile
@@ -719,6 +800,7 @@ native/jni/java-net/Makefile
native/jni/java-nio/Makefile
native/jni/java-util/Makefile
native/jni/gtk-peer/Makefile
+native/jni/gconf-peer/Makefile
native/jni/qt-peer/Makefile
native/jni/xmlj/Makefile
native/jni/midi-alsa/Makefile
@@ -728,6 +810,7 @@ native/target/Makefile
native/target/Linux/Makefile
native/target/generic/Makefile
resource/Makefile
+resource/META-INF/services/java.util.prefs.PreferencesFactory
scripts/Makefile
scripts/classpath.spec
lib/Makefile
@@ -735,7 +818,25 @@ 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
+AC_CONFIG_FILES([tools/gappletviewer
+tools/gjarsigner
+tools/gkeytool
+tools/gjar
+tools/gnative2ascii
+tools/gserialver])
+AC_CONFIG_COMMANDS([gappletviewer],[chmod 755 tools/gappletviewer])
+AC_CONFIG_COMMANDS([gjarsigner],[chmod 755 tools/gjarsigner])
+AC_CONFIG_COMMANDS([gkeytool],[chmod 755 tools/gkeytool])
+AC_CONFIG_COMMANDS([gjar],[chmod 755 tools/gjar])
+AC_CONFIG_COMMANDS([gnative2ascii],[chmod 755 tools/gnative2ascii])
+AC_CONFIG_COMMANDS([gserialver],[chmod 755 tools/gserialver])
+fi
+
if test "x${COMPILE_WRAPPERS}" = xno
then
@@ -750,3 +851,10 @@ fi
AC_CONFIG_COMMANDS([gen-classlist],[chmod 755 lib/gen-classlist.sh])
AC_CONFIG_COMMANDS([copy-vmresources],[chmod 755 lib/copy-vmresources.sh])
AC_OUTPUT
+
+# Create standard.omit based on decisions we just made.
+cat ${srcdir}/lib/standard.omit.in > lib/standard.omit
+if test x$use_escher != xtrue; then
+ echo gnu/java/awt/peer/x/.*java$ >> lib/standard.omit
+fi
+
diff --git a/libjava/classpath/doc/Makefile.in b/libjava/classpath/doc/Makefile.in
index 0a17afee1c1..d0fc71edbb3 100644
--- a/libjava/classpath/doc/Makefile.in
+++ b/libjava/classpath/doc/Makefile.in
@@ -93,6 +93,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -113,6 +115,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -143,6 +146,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -193,6 +200,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -213,6 +221,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/doc/api/Makefile.in b/libjava/classpath/doc/api/Makefile.in
index ad4956ce93c..09162650b13 100644
--- a/libjava/classpath/doc/api/Makefile.in
+++ b/libjava/classpath/doc/api/Makefile.in
@@ -86,6 +86,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -106,6 +108,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -136,6 +139,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -186,6 +193,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -206,6 +214,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/doc/tools.texinfo b/libjava/classpath/doc/tools.texinfo
index 53eadfaae56..28252cdc809 100644
--- a/libjava/classpath/doc/tools.texinfo
+++ b/libjava/classpath/doc/tools.texinfo
@@ -5,7 +5,7 @@
@settitle GNU Classpath Tools Guide
@c %**end of header
-@setchapternewpage off
+@setchapternewpage on
@ifinfo
This file documents the Tools included in a standard distribution of the GNU
@@ -23,7 +23,7 @@ Copyright (C) 2006 Free Software Foundation, Inc.
@titlepage
@title GNU Classpath Tools Guide
-@author Raif S. Naffah
+@author The GNU Classpath Team
@page
@vskip 0pt plus 1filll
@@ -37,8 +37,10 @@ Permission is granted to copy and distribute translations of this manual into an
@end titlepage
+@contents
+
@ifinfo
-@node Top, Security Tools, (dir), (dir)
+@node Top, Applet Tools, (dir), (dir)
@top GNU Classpath Tools Guide
This document contains important information you need to know in order to use
@@ -51,17 +53,64 @@ Software Development Kit (SDK).
@end ifinfo
@menu
+* Applet Tools:: Work with applets
* Security Tools:: Work securely with Java applications
* I18N Issues:: How to add support for non-English languages
@detailmenu
--- The Detailed Node Listing ---
+Applet Tools
+
+* appletviewer Tool:: Load applets
+* gcjwebplugin:: Load applets in a web browser
+
Security Tools
* jarsigner Tool:: Sign and verify .JAR files
* keytool Tool:: Manage private keys and public certificates
+jarsigner Tool
+
+* Common jarsigner Options:: Options used when signing or verifying a file
+* Signing Options:: Options only used when signing a .JAR file
+* Verification Options:: Options only used when verifying a .JAR file
+
+keytool Tool
+
+* Getting Help:: How to get help with keytool commands
+* Common keytool Options:: Options used in more than one command
+* Distinguished Names:: X.500 Distinguished Names used in certificates
+* Add/Update Commands:: Commands for adding data to a Key Store
+* Export Commands:: Commands for exporting data from a Key Store
+* Display Commands:: Commands for displaying data in a Key Store
+* Management Commands:: Commands for managing a Key Store
+
+Add/Update Commands
+
+* Command -genkey:: Generate private key and self-signed certificate
+* Command -import:: Import certificates and certificate replies
+* Command -selfcert:: Generate self-signed certificate
+* Command -cacert:: Import a CA Trusted Certificate
+* Command -identitydb:: Import JDK-1 style identities
+
+Export Commands
+
+* Command -certreq:: Generate Certificate Signing Requests (CSR)
+* Command -export:: Export a certificate in a Key Store
+
+Display Commands
+
+* Command -list:: Display information about one or all Aliases
+* Command -printcert:: Print a certificate or a certificate fingerprint
+
+Management Commands
+
+* Command -keyclone:: Clone a Key Entry in a Key Store
+* Command -storepasswd:: Change the password protecting a Key Store
+* Command -keypasswd:: Change the password protecting a Key Entry
+* Command -delete:: Remove an entry in a Key Store
+
I18N Issues
* Language Resources:: Where resources are located
@@ -72,11 +121,161 @@ I18N Issues
@comment ----------------------------------------------------------------------
-@node Security Tools, I18N Issues, Top, Top
+@node Applet Tools, Security Tools, Top, Top
+@comment node-name, next, previous, up
+@chapter Applet Tools
+
+Two Applet Tools are available with GNU Classpath: @b{appletviewer}
+and @b{gcjwebplugin}.
+
+To avoid conflicts with other implementations, the appletviewer
+executable is called ``gappletviewer''.
+
+@menu
+* appletviewer Tool:: Load applets
+* gcjwebplugin:: Load applets in a web browser
+@end menu
+
+If while using these tools you think you found a bug, then please report it at @uref{http://www.gnu.org/software/classpath/bugs.html,classpath-bugs}.
+
+@comment ----------------------------------------------------------------------
+
+@node appletviewer Tool, gcjwebplugin, Applet Tools, Applet Tools
+@comment node-name, next, previous, up
+@section The @code{appletviewer} Tool
+
+@table @b
+
+@item SYNOPSIS
+@code{appletviewer [OPTION]... URL...}@*
+@code{appletviewer [OPTION]... -code CODE}@*
+@code{appletviewer [OPTION]... -plugin INPUT,OUTPUT}
+
+@item DESCRIPTION
+The @code{appletviewer} tool loads and runs an applet.
+
+Use the first form to test applets specified by tag. The URL should
+resolve to an HTML document from which the @code{appletviewer} will
+extract applet tags. The APPLET, EMBED and OBJECT tags are supported.
+If a given document contains multiple applet tags, all the applets
+will be loaded, with each applet appearing in its own window.
+Likewise, when multiple URLs are specified, each applet tag instance
+is given its own window. If a given document contains no recognized
+tags the @code{appletviewer} does nothing.
+
+@example
+@code{appletviewer http://www.gnu.org/software/classpath/}
+@end example
+
+Use the second form to test an applet in development. This form
+allows applet tag attributes to be supplied on the command line. Only
+one applet may be specified using the @code{-code} option. The
+@code{-code} option overrides the URL form -- any URLs specified will
+be ignored.
+
+@example
+@code{appletviewer -code Test.class -param datafile,data.txt}
+@end example
+
+@code{gcjwebplugin} uses the third form to communicate with the
+@code{appletviewer} through named pipes.
+
+@item URL OPTIONS
+@table @b
+@item -debug
+This option is not yet implemented but is provided for compatibility.
+
+@item -encoding CHARSET
+Use this option to specify an alternate character encoding for the
+specified HTML page.
+
+@end table
+
+@item APPLET TAG OPTIONS
+@table @b
+@item -code CODE
+Use the @code{-code} option to specify the value of the applet tag
+CODE attribute.
+
+@item -codebase CODEBASE
+Use the @code{-codebase} option to specify the value of the applet tag
+CODEBASE attribute.
+
+@item -archive ARCHIVE
+Use the @code{-archive} option to specify the value of the applet tag
+ARCHIVE attribute.
+
+@item -width WIDTH
+Use the @code{-width} option to specify the value of the applet tag
+WIDTH attribute.
+
+@item -height HEIGHT
+Use the @code{-height} option to specify the value of the applet tag
+HEIGHT attribute.
+
+@item -param NAME,VALUE
+Use the @code{-param} option to specify values for the NAME and VALUE
+attributes of an applet PARAM tag.
+
+@end table
+
+@item PLUGIN OPTION
+@table @b
+@item -plugin INPUT,OUTPUT
+@code{gcjwebplugin} uses the @code{-plugin} option to specify the
+named pipe the @code{appletviewer} should use for receiving commands
+(INPUT) and the one it should use for sending commands to
+@code{gcjwebplugin} (OUTPUT).
+
+@end table
+
+@item DEBUGGING OPTION
+@table @b
+@item -verbose
+Use the @code{-verbose} option to have the @code{appletviewer} print
+debugging messages.
+
+@end table
+
+@item STANDARD OPTIONS
+@table @b
+@item -help
+Use the @code{-help} option to have the @code{appletviewer} print a
+usage message, then exit.
+
+@item -version
+Use the @code{-version} option to have the @code{appletviewer} print
+its version, then exit.
+
+@item -JOPTION
+Use the @code{-J} option to pass OPTION to the virtual machine that
+will run the @code{appletviewer}. Unlike other options, there must
+not be a space between the -J and OPTION.
+
+@end table
+@end table
+
+@comment ----------------------------------------------------------------------
+
+@node gcjwebplugin, , appletviewer Tool, Applet Tools
+@comment node-name, next, previous, up
+@section The @code{gcjwebplugin} Tool
+
+@code{gcjwebplugin} is a plugin that adds applet support to web
+browsers. Currently @code{gcjwebplugin} only supports Mozilla-based
+browsers (e.g., Firefox, Galeon, Mozilla).
+
+@comment ----------------------------------------------------------------------
+
+@node Security Tools, I18N Issues, Applet Tools, Top
@comment node-name, next, previous, up
@chapter Security Tools
-Two Security Tools are available with GNU Classpath: @b{jarsugner} and @b{keytool}.
+Two Security Tools are available with GNU Classpath: @b{jarsigner} and @b{keytool}.
+
+To avoid conflicts with other implementations, the jarsigner
+executable is called ``gjarsigner'' and the keytool executable is
+called ``gkeytool''.
@menu
* jarsigner Tool:: Sign and verify .JAR files
@@ -91,22 +290,59 @@ If while using these tools you think you found a bug, then please report it at @
@comment node-name, next, previous, up
@section The @code{jarsigner} Tool
-@table @b
+The @b{jarsigner} tool is invoked from the command line, in one of two forms, as follows:
-@item SYNOPSIS
-@code{jarsigner [OPTION]... FILE ALIAS}@*
+@example
+@code{jarsigner [OPTION]... FILE ALIAS}
@code{jarsigner -verify [OPTION]... FILE}
+@end example
-@item DESCRIPTION
-When the first form is used, the tool signs the designated JAR file.
-
-The second form, on the other hand, is used to verify a previously signed JAR file.
+When the first form is used, the tool signs the designated JAR file. The second form, on the other hand, is used to verify a previously signed JAR file.
@code{FILE} is the .JAR file to process; i.e. to sign if the first syntax form is used, or to verify if the second syntax form is used instead.
-@code{ALIAS} must be a known @i{Alias} of a @i{Key Entry} in the designated key store. The private key material associated with this @i{Alias} is then used for signing the designated .JAR file.
+@code{ALIAS} must be a known @i{Alias} of a @i{Key Entry} in the designated @i{Key Store}. The private key material associated with this @i{Alias} is then used for signing the designated .JAR file.
+
+@menu
+* Common jarsigner Options:: Options used when signing or verifying a file
+* Signing Options:: Options only used when signing a .JAR file
+* Verification Options:: Options only used when verifying a .JAR file
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Common jarsigner Options, Signing Options, jarsigner Tool, jarsigner Tool
+@comment node-name, next, previous, up
+@subsection Common options
+
+The following options may be used when the tool is used for either signing, or verifying, a .JAR file.
+
+@table @b
+@item -verbose
+Use this option to force the tool to generate more verbose messages, during its processing.
+
+@item -internalsf
+When present, the tool will include --which otherwise it does not-- the @code{.SF} file in the @code{.DSA} generated file.
+
+@item -sectionsonly
+When present, the tool will include in the @code{.SF} generated file --which otherwise it does not-- a header containing a hash of the whole manifest file. When that header is included, the tool can quickly check, during verification, if the hash (in the header) matches or not the manifest file.
+
+@item -provider PROVIDER_CLASS_NAME
+A fully qualified class name of a @i{Security Provider} to add to the current list of @i{Security Providers} already installed in the JVM in-use. If a provider class is specified with this option, and was successfully added to the runtime --i.e. it was not already installed-- then the tool will attempt to remove this @i{Security Provider} before exiting.
+
+@item -help
+Prints a help text similar to this one.
+
+@end table
+
+@comment ----------------------------------------------------------------------
+
+@node Signing Options, Verification Options, Common jarsigner Options, jarsigner Tool
+@comment node-name, next, previous, up
+@subsection Signing options
+
+The following options may be specified when using the tool for signing purposes.
-@item SIGNING OPTIONS
@table @b
@item -keystore URL
Use this option to specify the location of the key store to use. The default value is a file URL referencing the file named @file{.keystore} located in the path returned by the call to @code{java.lang.System#getProperty(String)} using @code{user.home} as argument.
@@ -129,12 +365,19 @@ Use this option to designate a literal that will be used to construct file names
If this option is missing, the first eight characters of the @code{ALIAS} argument will be used. When this is the case, any character in @code{ALIAS} that is outside the permissible range of characters will be replaced by an underscore.
-@item -signedjar FILE_NAME
+@item -signedjar FILE
Use this option to specify the file name of the signed JAR. If this option is omitted, then the signed JAR will be named the same as @code{FILE}; i.e. the input JAR file will be replaced with the signed copy.
@end table
-@item VERIFICATION OPTIONS
+@comment ----------------------------------------------------------------------
+
+@node Verification Options, , Signing Options, jarsigner Tool
+@comment node-name, next, previous, up
+@subsection Verification options
+
+The following options may be specified when using the tool for verification purposes.
+
@table @b
@item -verify
Use this option to indicate that the tool is to be used for verification purposes.
@@ -144,44 +387,37 @@ This option is used in conjunction with the @code{-verbose} option. When present
@end table
-@item COMMON OPTIONS
-@table @b
-@item -verbose
-Use this option to force the tool to generate more verbose messages, during its processing.
+@comment ----------------------------------------------------------------------
-@item -internalsf
-When present, the tool will include --which otherwise it does not-- the @code{.SF} file in the @code{.DSA} generated file.
+@node keytool Tool, , jarsigner Tool, Security Tools
+@comment node-name, next, previous, up
+@section The @code{keytool} Tool
-@item -sectionsonly
-When present, the tool will include in the @code{.SF} generated file --which otherwise it does not-- a header containing a hash of the whole manifest file. When that header is included, the tool can quickly check, during verification, if the hash (in the header) matches or not the manifest file.
+Cryptographic credentials, in a Java environment, are usually stored in a @i{Key Store}. The Java SDK specifies a @i{Key Store} as a persistent container of two types of objects: @i{Key Entries} and @i{Trusted Certificates}. The security tool @b{keytool} is a Java-based application for managing those types of objects.
-@item -provider PROVIDER_CLASS_NAME
-A fully qualified class name of a @i{Security Provider} to add to the current list of @i{Security Providers} already installed in the JVM in-use. If a provider class is specified with this option, and was successfully added to the runtime --i.e. it was not already installed-- then the tool will attempt to remove this @i{Security Provider} before exiting.
+A @i{Key Entry} represents the private key part of a key-pair used in Public-Key Cryptography, and a signed X.509 certificate which authenticates the public key part for a known entity; i.e. the owner of the key-pair. The X.509 certificate itself contains the public key part of the key-pair.
-@item -help
-Prints a help text similar to this one.
+A @i{Trusted Certificate} is a signed X.509 certificate issued by a trusted entity. The @i{Trust} in this context is relative to the User of the @b{keytool}. In other words, the existence of a @i{Trusted Certificate} in the @i{Key Store} processed by a @b{keytool} command implies that the User trusts the @i{Issuer} of that @i{Trusted Certificate} to also sign, and hence authenticates, other @i{Subjects} the tool may process.
-@end table
-@end table
+@i{Trusted Certificates} are important because they allow the tool to mechanically construct @i{Chains of Trust} starting from one of the @i{Trusted Certificates} in a @i{Key Store} and ending with a certificate whose @i{Issuer} is potentially unknown. A valid chain is an ordered list, starting with a @i{Trusted Certificate} (also called the @i{anchor}), ending with the target certificate, and satisfying the condition that the @i{Subject} of certificate @code{#i} is the @i{Issuer} of certificate @code{#i + 1}.
-@comment ----------------------------------------------------------------------
+The @b{keytool} is invoked from the command line as follows:
-@node keytool Tool, , jarsigner Tool, Security Tools
-@comment node-name, next, previous, up
-@section The @code{keytool} Tool
-
-@table @b
-@item SYNOPSIS
+@example
@code{keytool [COMMAND]...}
+@end example
-@item DESCRIPTION
-A Java-based tool for managing both @i{Key Entries} as well as @i{Trusted Certificates}.
+Multiple @code{COMMAND}s may be specified at once, each complete with its own options. @b{keytool} will parse all the arguments, before processing, and executing, each @code{COMMAND}. If an exception occurs while executing one @code{COMMAND} @b{keytool} will abort. Note however that because the implementation of the tool uses code to parse command line options that also supports GNU-style options, you have to separate each command group with a double-hyphen; e.g
-Multiple @code{COMMAND}s may be specified at once, each complete with its own options. @b{keytool} will parse all the arguments, before processing, and executing, each @code{COMMAND}. If an exception occurs while executing one @code{COMMAND} @b{keytool} will abort.
+@example
+@code{keytool -list -- -printcert -alias mykey}
+@end example
-A @code{COMMAND} can be one of the followings:
+Here is a summary of the commands supported by the tool:
-@table @b
+@enumerate
+@item Add/Update commands
+@itemize @bullet
@item -genkey [OPTION]@dots{}
Generate a new @i{Key Entry}, eventually creating a new key store.
@@ -191,22 +427,34 @@ Add, to a key store, @i{Key Entries} (private keys and certificate chains authen
@item -selfcert [OPTION]@dots{}
Generate a new self-signed @i{Trusted Certificate}.
+@item -cacert [OPTION]@dots{}
+Import a CA @i{Trusted Certificate}.
+
@item -identitydb [OPTION]@dots{}
@b{NOT IMPLEMENTED YET}.@*
Import a JDK 1.1 style Identity Database.
+@end itemize
+@item Export commands
+@itemize @bullet
@item -certreq [OPTION]@dots{}
Issue a @i{Certificate Signing Request} (CSR) which can be then sent to a @i{Certification Authority} (CA) to issue a certificate signed (by the CA) and authenticating the @i{Subject} of the request.
@item -export [OPTION]@dots{}
Export a certificate from a key store.
+@end itemize
+@item Display commands
+@itemize @bullet
@item -list [OPTION]@dots{}
Print one or all certificates in a key store to @code{STDOUT}.
@item -printcert [OPTION]@dots{}
Print a human-readable form of a certificate, in a designated file, to @code{STDOUT}.
+@end itemize
+@item Management commands
+@itemize @bullet
@item -keyclone [OPTION]@dots{}
Clone a @i{Key Entry} in a key store.
@@ -218,13 +466,48 @@ Change the password protecting a @i{Key Entry} in a key store.
@item -delete [OPTION]@dots{}
Delete a @i{Key Entry} or a @i{Trusted Certificate} from a key store.
+@end itemize
-@item -help
-Prints a help text similar to this one.
+@end enumerate
-@end table
+@menu
+* Getting Help:: How to get help with keytool commands
+* Common keytool Options:: Options used in more than one command
+* Distinguished Names:: X.500 Distinguished Names used in certificates
+* Add/Update Commands:: Commands for adding data to a Key Store
+* Export Commands:: Commands for exporting data from a Key Store
+* Display Commands:: Commands for displaying data in a Key Store
+* Management Commands:: Commands for managing a Key Store
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Getting Help, Common keytool Options, keytool Tool, keytool Tool
+@comment node-name, next, previous, up
+@subsection Getting help
+
+To get a general help text about the tool, use the @code{-help} option; e.g.
+
+@example
+@code{keytool -help}
+@end example
+
+To get more specific help text about one of the tool's command use the @code{-help} option for that command; e.g.
+
+@example
+@code{keytool -genkey -help}
+@end example
+
+In both instances, the tool will print a help text and then will exit the running JVM.
+
+It is worth noting here that the help messages printed by the tool are I18N-ready. This means that if/when the contents of the tool's @i{Message Bundle} properties file are available in languages other than English, you may see those messages in that language.
+
+@comment ----------------------------------------------------------------------
+
+@node Common keytool Options, Distinguished Names, Getting Help, keytool Tool
+@comment node-name, next, previous, up
+@subsection Common options
-@item OPTIONS COMMON TO MORE THAN ONE COMMAND
The following @code{OPTION}s are used in more than one @code{COMMAND}. They are described here to reduce redundancy.
@table @b
@@ -263,7 +546,7 @@ If a URL was specified, but was found to be malformed --e.g. missing protocol el
A fully qualified class name of a @i{Security Provider} to add to the current list of @i{Security Providers} already installed in the JVM in-use. If a provider class is specified with this option, and was successfully added to the runtime --i.e. it was not already installed-- then the tool will attempt to removed this @i{Security Provider} before exiting.
@anchor{file}
-@item -file FILE_NAME
+@item -file FILE
Use this option to designate a file to use with a command. When specified with this option, the value is expected to be the fully qualified path of a file accessible by the File System. Depending on the command, the file may be used as input or as output. When this option is omitted from the command line, @code{STDIN} will be used instead, as the source of input, and @code{STDOUT} will be used instead as the output destination.
@anchor{verbose}
@@ -272,8 +555,13 @@ Unless specified otherwise, use this option to enable more verbose output.
@end table
+@comment ----------------------------------------------------------------------
+
+@node Distinguished Names, Add/Update Commands, Common keytool Options, keytool Tool
+@comment node-name, next, previous, up
+@subsection X.500 Distinguished Names
+
@anchor{dn}
-@item X.500 DISTINGUISHED NAME
A @i{Distinguished Name} (or DN) MUST be supplied with some of the @code{COMMAND}s using a @code{-dname} option. The syntax of a valid value for this option MUST follow RFC-2253 specifications. Namely the following components (with their accepted meaning) will be recognized. Note that the component name is case-insensitive:
@ftable @var
@@ -299,8 +587,27 @@ CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
@*
If the @i{Distinguished Name} is required, and no valid default value can be used, the tool will prompt you to enter the information through the console.
-@item -genkey COMMAND
-Generate a new key-pair (both private and public keys), and save these credentials in the key store as a @i{Key Entry}, associated with the designated (if was specified in the @code{-alias} option) or default (if the @code{-alias} option is omitted) @i{Alias}.
+@comment ----------------------------------------------------------------------
+
+@node Add/Update Commands, Export Commands, Distinguished Names, keytool Tool
+@comment node-name, next, previous, up
+@subsection Add/Update commands
+
+@menu
+* Command -genkey:: Generate private key and self-signed certificate
+* Command -import:: Import certificates and certificate replies
+* Command -selfcert:: Generate self-signed certificate
+* Command -cacert:: Import a CA Trusted Certificate
+* Command -identitydb:: Import JDK-1 style identities
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Command -genkey, Command -import, Add/Update Commands, Add/Update Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-genkey} command
+
+Use this command to generate a new key-pair (both private and public keys), and save these credentials in the key store as a @i{Key Entry}, associated with the designated (if was specified with the @code{-alias} option) or default (if the @code{-alias} option is omitted) @i{Alias}.
The private key material will be protected with a user-defined password (see @code{-keypass} option). The public key on the other hand will be part of a self-signed X.509 certificate, which will form a 1-element chain and will be saved in the key store.
@@ -347,8 +654,13 @@ For more details @pxref{verbose}.
@end table
-@item -import COMMAND
-Read an X.509 certificate, or a PKCS#7 @i{Certificate Reply} from a designated input source and incorporate the certificates into the key store.
+@comment ----------------------------------------------------------------------
+
+@node Command -import, Command -selfcert, Command -genkey, Add/Update Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-import} command
+
+Use this command to read an X.509 certificate, or a PKCS#7 @i{Certificate Reply} from a designated input source and incorporate the certificates into the key store.
If the @i{Alias} does not already exist in the key store, the tool treats the certificate read from the input source as a new @i{Trusted Certificate}. It then attempts to discover a chain-of-trust, starting from that certificate and ending at another @i{Trusted Certificate}, already stored in the key store. If the @code{-trustcacerts} option is present, an additional key store, of type @code{JKS} named @file{cacerts}, and assumed to be present in @file{$@{JAVA_HOME@}/lib/security} will also be consulted if found --@code{$@{JAVA_HOME@}} refers to the location of an installed @i{Java Runtime Environment} (JRE). If no chain-of-trust can be established, and unless the @code{-noprompt} option has been specified, the certificate is printed to @code{STDOUT} and the user is prompted for a confirmation.
@@ -358,8 +670,8 @@ If @i{Alias} exists in the key store, the tool will treat the certificate(s) rea
@item -alias ALIAS
For more details @pxref{alias,, ALIAS}.
-@item -file FILE_NAME
-For more details @pxref{file,, FILE_NAME}.
+@item -file FILE
+For more details @pxref{file,, FILE}.
@item -keypass PASSWORD
Use this option to specify the password which the tool will use to protect the @i{Key Entry} associated with the designated @i{Alias}, when replacing this @i{Alias}' chain of certificates with that found in the certificate reply.
@@ -389,8 +701,13 @@ For more details @pxref{verbose}.
@end table
-@item -selfcert COMMAND
-Generate a self-signed X.509 version 1 certificate. The newly generated certificate will form a chain of one element which will replace the previous chain associated with the designated @i{Alias} (if @code{-alias} option was specified), or the default @i{Alias} (if @code{-alias} option was omitted).
+@comment ----------------------------------------------------------------------
+
+@node Command -selfcert, Command -cacert, Command -import, Add/Update Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-selfcert} command
+
+Use this command to generate a self-signed X.509 version 1 certificate. The newly generated certificate will form a chain of one element which will replace the previous chain associated with the designated @i{Alias} (if @code{-alias} option was specified), or the default @i{Alias} (if @code{-alias} option was omitted).
@table @b
@item -alias ALIAS
@@ -429,14 +746,50 @@ For more details @pxref{verbose}.
@end table
-@item -identitydb COMMAND
+@comment ----------------------------------------------------------------------
+
+@node Command -cacert, Command -identitydb, Command -selfcert, Add/Update Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-cacert} command
+
+Use this command to import, a CA certificate and add it to the key store as a @i{Trusted Certificate}. The @i{Alias} for this new entry will be constructed from the FILE's base-name after replacing hyphens and dots with underscores.
+
+This command is useful when used in a script that recursively visits a directory of CA certificates to populate a @code{cacerts.gkr} @i{Key Store} of trusted certificates which can then be used commands that specify the @code{-trustcacerts} option.
+
+@table @b
+@item -file FILE
+For more details @pxref{file,, FILE}.
+
+@item -storetype STORE_TYPE
+For more details @pxref{storetype,, STORE_TYPE}.
+
+@item -keystore URL
+For more details @pxref{keystore,, URL}.
+
+@item -storepass PASSWORD
+For more details @pxref{storepass,, PASSWORD}.
+
+@item -provider PROVIDER_CLASS_NAME
+For more details @pxref{provider,, PROVIDER_CLASS_NAME}.
+
+@item -v
+For more details @pxref{verbose}.
+
+@end table
+
+@comment ----------------------------------------------------------------------
+
+@node Command -identitydb, , Command -cacert, Add/Update Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-identitydb} command
+
@b{NOT IMPLEMENTED YET}.
-Import a JDK 1.1 style Identity Database.
+Use this command to import a JDK 1.1 style Identity Database.
@table @b
-@item -file FILE_NAME
-For more details @pxref{file,, FILE_NAME}.
+@item -file FILE
+For more details @pxref{file,, FILE}.
@item -storetype STORE_TYPE
For more details @pxref{storetype,, STORE_TYPE}.
@@ -455,8 +808,24 @@ For more details @pxref{verbose}.
@end table
-@item -certreq COMMAND
-Generate a PKCS#10 @i{Certificate Signing Request} (CSR) and writes it to a designated output destination. The contents of the destination should look something like the following:
+@comment ----------------------------------------------------------------------
+
+@node Export Commands, Display Commands, Add/Update Commands, keytool Tool
+@comment node-name, next, previous, up
+@subsection Export commands
+
+@menu
+* Command -certreq:: Generate Certificate Signing Requests (CSR)
+* Command -export:: Export a certificate in a Key Store
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Command -certreq, Command -export, Export Commands, Export Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-certreq} command
+
+Use this command to generate a PKCS#10 @i{Certificate Signing Request} (CSR) and write it to a designated output destination. The contents of the destination should look something like the following:
@example
-----BEGIN NEW CERTIFICATE REQUEST-----
@@ -476,8 +845,8 @@ For more details @pxref{alias,, ALIAS}.
@item -sigalg ALGORITHM
The canonical name of the digital signature algorithm to use for signing the certificate. If this option is omitted, a default value will be chosen based on the type of the private key associated with the designated @i{Alias}. If the private key is a @code{DSA} one, the value for the signature algorithm will be @code{SHA1withDSA}. If on the other hand the private key is an @code{RSA} one, then the tool will use @code{MD5withRSA} as the signature algorithm.
-@item -file FILE_NAME
-For more details @pxref{file,, FILE_NAME}.
+@item -file FILE
+For more details @pxref{file,, FILE}.
@item -keypass PASSWORD
Use this option to specify the password which the tool will use to unlock the @i{Key Entry} associated with the designated @i{Alias}.
@@ -504,16 +873,20 @@ Use this option to force the tool to encode a @code{NULL} DER value in the CSR a
@end table
-@item -export COMMAND
-Export a certificate stored in the key store to a designated output destination, either in binary format (if the @code{-v} option is specified), or in RFC-1421 compliant encoding (if the @code{-rfc} option is specified
-instead).
+@comment ----------------------------------------------------------------------
+
+@node Command -export, , Command -certreq, Export Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-export} command
+
+Use this command to export a certificate stored in a key store to a designated output destination, either in binary format (if the @code{-v} option is specified), or in RFC-1421 compliant encoding (if the @code{-rfc} option is specified instead).
@table @b
@item -alias ALIAS
For more details @pxref{alias,, ALIAS}.
-@item -file FILE_NAME
-For more details @pxref{file,, FILE_NAME}.
+@item -file FILE
+For more details @pxref{file,, FILE}.
@item -storetype STORE_TYPE
For more details @pxref{storetype,, STORE_TYPE}.
@@ -535,8 +908,24 @@ Output the certificate in binary DER encoding. This is the default output format
@end table
-@item -list COMMAND
-Print one or all of the key store entries to @code{STDOUT}. Usually this command will only print a @i{fingerprint} of the certificate, unless either the @code{-rfc} or the @code{-v} option is specified.
+@comment ----------------------------------------------------------------------
+
+@node Display Commands, Management Commands, Export Commands, keytool Tool
+@comment node-name, next, previous, up
+@subsection Display commands
+
+@menu
+* Command -list:: Display information about one or all Aliases
+* Command -printcert:: Print a certificate or a certificate fingerprint
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Command -list, Command -printcert, Display Commands, Display Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-list} command
+
+Use this command to print one or all of a key store entries to @code{STDOUT}. Usually this command will only print a @i{fingerprint} of the certificate, unless either the @code{-rfc} or the @code{-v} option is specified.
@table @b
@item -alias ALIAS
@@ -564,20 +953,43 @@ Output the certificate in human-readable format. If both this option and the @co
@end table
-@item -printcert COMMAND
-Read a certificate from a designated input source and print it to @code{STDOUT} in a human-readable form.
+@comment ----------------------------------------------------------------------
+
+@node Command -printcert, , Command -list, Display Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-printcert} command
+
+Use this command to read a certificate from a designated input source and print it to @code{STDOUT} in a human-readable form.
@table @b
-@item -file FILE_NAME
-For more details @pxref{file,, FILE_NAME}.
+@item -file FILE
+For more details @pxref{file,, FILE}.
@item -v
For more details @pxref{verbose}.
@end table
-@item -keyclone COMMAND
-Clone an existing @i{Key Entry} and store it under a new (different) @i{Alias} protecting, its private key material with possibly a new password.
+@comment ----------------------------------------------------------------------
+
+@node Management Commands, , Display Commands, keytool Tool
+@comment node-name, next, previous, up
+@subsection Management commands
+
+@menu
+* Command -keyclone:: Clone a Key Entry in a Key Store
+* Command -storepasswd:: Change the password protecting a Key Store
+* Command -keypasswd:: Change the password protecting a Key Entry
+* Command -delete:: Remove an entry in a Key Store
+@end menu
+
+@comment ----------------------------------------------------------------------
+
+@node Command -keyclone, Command -storepasswd, Management Commands, Management Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-keyclone} command
+
+Use this command to clone an existing @i{Key Entry} and store it under a new (different) @i{Alias} protecting, its private key material with possibly a new password.
@table @b
@item -alias ALIAS
@@ -611,8 +1023,13 @@ For more details @pxref{verbose}.
@end table
-@item -storepasswd COMMAND
-Change the password protecting a key store.
+@comment ----------------------------------------------------------------------
+
+@node Command -storepasswd, Command -keypasswd, Command -keyclone, Management Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-storepasswd} command
+
+Use this command to change the password protecting a key store.
@table @b
@item -new PASSWORD
@@ -635,14 +1052,18 @@ For more details @pxref{verbose}.
@end table
-@item -keypasswd COMMAND
-Change the password protecting the private key material of a designated @i{Key Entry}.
+@comment ----------------------------------------------------------------------
+
+@node Command -keypasswd, Command -delete, Command -storepasswd, Management Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-keypasswd} command
+
+Use this command to change the password protecting the private key material of a designated @i{Key Entry}.
@table @b
@item -alias ALIAS
For more details @pxref{alias,, ALIAS}.
-@item -keypass PASSWORD
Use this option to specify the password which the tool will use to unlock the @i{Key Entry} associated with the designated @i{Alias}.
If this option is omitted, the tool will first attempt to unlock the @i{Key Entry} using the same password protecting the key store. If this fails, you will then be prompted to provide a password.
@@ -667,8 +1088,13 @@ For more details @pxref{verbose}.
@end table
-@item -delete COMMAND
-Delete a designated key store entry.
+@comment ----------------------------------------------------------------------
+
+@node Command -delete, , Command -keypasswd, Management Commands
+@comment node-name, next, previous, up
+@subsubsection @code{-delete} command
+
+Use this command to delete a designated key store entry.
@table @b
@item -alias ALIAS
@@ -690,7 +1116,6 @@ For more details @pxref{provider,, PROVIDER_CLASS_NAME}.
For more details @pxref{verbose}.
@end table
-@end table
@comment ----------------------------------------------------------------------
@@ -709,7 +1134,7 @@ Some tools --@pxref{Security Tools}-- allow using other than the English languag
@node Language Resources, Message Formats, I18N Issues, I18N Issues
@comment node-name, next, previous, up
-@section Language-Specific Resources
+@section Language-specific resources
The Tools use Java @code{ResourceBundle}s to store messages, and message templates they use at runtime to generate the message text itself, depending on the locale in use at the time.
@@ -721,7 +1146,7 @@ Command.23=A correct key password MUST be provided
When the tool needs to signal a mandatory but missing key password, it would reference the property named @code{Command.23} and the message "@kbd{A correct key password MUST be provided}" will be used instead. This indirect referencing of "resources" permits replacing, as late as possible, the English strings with strings in other languages, provided of course @i{Resource Bundles} in those languages are provided.
-For the GNU Classpath Tools described in this Guide, the @i{Resource Bundles} are files named @file{MessageBundle[_ll[_CC[_VV]]].properties} where:
+For the GNU Classpath Tools described in this Guide, the @i{Resource Bundles} are files named @file{messages[_ll[_CC[_VV]]].properties} where:
@ftable @var
@item ll
@@ -746,24 +1171,24 @@ The location of the @i{Resource Bundles} for the GNU Classpath Tools is specific
The collection of @i{Resource Bundles} in a location act as an inverted tree with a parent-child relationship. For example suppose in the @file{gnu/classpath/tools/keytool} there are 3 message bundles named:
@enumerate
-@item @code{MessageBundle.properties}
-@item @code{MessageBundle_fr.properties}
-@item @code{MessageBundle_fr_FR.properties}
+@item @code{messages.properties}
+@item @code{messages_fr.properties}
+@item @code{messages_fr_FR.properties}
@end enumerate
-In the above example, bundle #1 will act as the parent of bundle #2, which in turn will act as the parent for bundle #3. This ordering is used by the Java runtime to choose which file to load based on the set Locale. For example if the Locale is @code{fr_CH}, @code{MessageBundle_fr.properties} will be used because (a) @code{MessageBundle_fr_CH.properties} does not exist, but (b) @code{MessageBundle_fr.properties} is the parent for the required bundle, and it exists. As another example, suppose the Locale was set to @code{en_AU}; then the tool will end up using @code{MessageBundle.properties} because (a) @code{MessageBundle_en_AU.properties} does not exist, (b) @code{MessageBundle_en.properties} which is the parent for the required bundle does not exist, but (c) @code{MessageBundle.properties} exists and is the root of the hierarchy.
+In the above example, bundle #1 will act as the parent of bundle #2, which in turn will act as the parent for bundle #3. This ordering is used by the Java runtime to choose which file to load based on the set Locale. For example if the Locale is @code{fr_CH}, @code{messages_fr.properties} will be used because (a) @code{messages_fr_CH.properties} does not exist, but (b) @code{messages_fr.properties} is the parent for the required bundle, and it exists. As another example, suppose the Locale was set to @code{en_AU}; then the tool will end up using @code{messages.properties} because (a) @code{messages_en_AU.properties} does not exist, (b) @code{messages_en.properties} which is the parent for the required bundle does not exist, but (c) @code{messages.properties} exists and is the root of the hierarchy.
-You can see from the examples above that @file{MessageBundle.properties} is the safety net that the Java runtime falls back to when failing to find a specific bunlde and its parent(s). This file is always provided with the Tool. In time, more localized versions will be included to cater for other languages.
+You can see from the examples above that @file{messages.properties} is the safety net that the Java runtime falls back to when failing to find a specific bunlde and its parent(s). This file is always provided with the Tool. In time, more localized versions will be included to cater for other languages.
-In the meantime, if you are willing to contribute localized versions of these resources, grab the @file{MessageBundle.properties} for a specific tool; translate it; save it with the appropriate language and region suffix and mail it to @code{classpath@@gnu.org}.
+In the meantime, if you are willing to contribute localized versions of these resources, grab the @file{messages.properties} for a specific tool; translate it; save it with the appropriate language and region suffix and mail it to @code{classpath@@gnu.org}.
@comment ----------------------------------------------------------------------
@node Message Formats, , Language Resources, I18N Issues
@comment node-name, next, previous, up
-@section Message Formats
+@section Message formats
-If you open any of the @file{MessageBundle.properties} described in the previous section, you may see properties that look like so:
+If you open any of the @file{messages.properties} described in the previous section, you may see properties that look like so:
@example
Command.67=Issuer: @{0@}
@@ -774,7 +1199,7 @@ Command.70=\ \ \ \ \ until: @{0,date,full@} - @{0,time,full@}
These are @i{Message Formats} used by the tools to customize a text string that will then be used either as a prompt for User input or as output.
-If you are translating a @file{MessageBundle.properties} be careful not to alter text between curly braces.
+If you are translating a @file{messages.properties} be careful not to alter text between curly braces.
@comment ----------------------------------------------------------------------
diff --git a/libjava/classpath/doc/vmintegration.texinfo b/libjava/classpath/doc/vmintegration.texinfo
index a784e6fadfa..e7f85d088b5 100644
--- a/libjava/classpath/doc/vmintegration.texinfo
+++ b/libjava/classpath/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
@@ -202,6 +203,8 @@ implementation.
* gnu.java.nio::
* java.lang.reflect::
* gnu.java.lang::
+* gnu.java.lang.management::
+* java.lang.management::
* Classpath Callbacks::
@end menu
@@ -704,6 +707,9 @@ to allow the setting to flow down to the native thread.
@item @code{nativeStop(Throwable)} -- The VM should stop the thread abnormally
and throw the specified exception. This is clearly deprecated, due to the
ambiguous state an abruptly-stopped thread may leave.
+@item @code{getState()} -- Returns the VM's impression of the current state
+of the thread. The applicable states are supplied by the @code{State}
+enumeration in @code{java.lang.Thread}.
@end itemize
@item Mandatory Class Methods
@itemize @bullet
@@ -1206,7 +1212,7 @@ which the VM uses to generate a new non-primitive array of a
particular class and size. The default implementation simply passes
the job down to the standard JNI function, @code{NewObjectArray}.
-@node gnu.java.lang, Classpath Callbacks, java.lang.reflect, Classpath Hooks
+@node gnu.java.lang, gnu.java.lang.management, java.lang.reflect, Classpath Hooks
@section @code{gnu.java.lang}
@code{gnu.java.lang} provides VM interfaces for the GNU
@@ -1258,7 +1264,384 @@ method calls the @code{VMInstrumentationImpl.redefineClasses} native method
which must be implemented by the VM. The implementation should call the
@code{InstrumentationImpl.callTransformers} method.
-@node Classpath Callbacks, , gnu.java.lang, Classpath Hooks
+@node gnu.java.lang.management, java.lang.management, gnu.java.lang, Classpath Hooks
+@section @code{gnu.java.lang.management}
+
+@code{gnu.java.lang.management} provides the VM interfaces for the GNU
+implementations of the management beans.
+
+@menu
+* gnu.java.lang.management.VMRuntimeMXBeanImpl::
+* gnu.java.lang.management.VMClassLoadingMXBeanImpl::
+* gnu.java.lang.management.VMThreadMXBeanImpl::
+* gnu.java.lang.management.VMMemoryMXBeanImpl::
+* gnu.java.lang.management.VMCompilationMXBeanImpl::
+* gnu.java.lang.management.VMMemoryPoolMXBeanImpl::
+* gnu.java.lang.management.VMMemoryManagerMXBeanImpl::
+* gnu.java.lang.management.VMGarbageCollectorMXBeanImpl::
+@end menu
+
+@node gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMRuntimeMXBeanImpl}
+
+The @code{gnu.java.lang.management.RuntimeMXBeanImpl} provides an
+implementation of the @code{java.lang.management.RuntimeMXBean} interface,
+and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMRuntimeMXBeanImpl}. This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean. The VM
+methods are generally representative of information that is only
+available from the virtual machine, such as the command-line arguments
+it was given at startup.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(getInputArguments())} -- The VM should supply
+a @code{String} array containing each of the command-line
+arguments, excluding those that are directed at the
+@code{main()} method. The reference implementation expects
+this to be a native method.
+@item @code{(getName())} -- The VM developer should choose
+an appropriate name for the virtual machine. This name can
+be instance-specific e.g. it can include things like the
+process identifier or host name of the machine, which only
+apply to the current running instance. Thus, the intention is
+that this name refers to the entity that the other information
+refers to, rather than the VM in general. The reference
+implementation supplies a default concatenation of the VM
+name and version.
+@item @code{(getStartTime())} -- This should return the number
+of milliseconds at which the virtual machine was started.
+The uptime property of the bean is provided relative to this
+value. Again, the reference implementation also expects
+this method to be native.
+@end itemize
+
+The virtual machine also needs to provide either the
+@code{sun.boot.class.path} or @code{java.boot.class.path}
+property in order to support the optional boot class path
+retrieval functionality.
+
+@node gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}
+
+The @code{gnu.java.lang.management.ClassLoadingMXBeanImpl} provides an
+implementation of the @code{java.lang.management.ClassLoadingMXBean} interface,
+and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}. This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean. Implementing
+this bean requires the VM to monitor when classes are loaded and unloaded,
+and provide the option of verbose class loading output.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(getLoadedClassCount())} -- This should return
+the number of classes that are currently loaded by the VM.
+@item @code{(getUnloadedClassCount())} -- This should return
+the number of classes that have been loaded by the VM, but
+have since been unloaded.
+@item @code{(isVerbose())} -- This should return @code{true}
+or @code{false}, depending on whether verbose class loading
+output is turned or not, respectively.
+@item @code{(setVerbose(boolean))} -- This should allow the
+verbose class loading output to be turned on and off.
+@end itemize
+
+@node gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMThreadMXBeanImpl}
+
+The @code{gnu.java.lang.management.ThreadMXBeanImpl} provides an
+implementation of the @code{java.lang.management.ThreadMXBean} interface,
+and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMThreadMXBeanImpl}. This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean. Implementing
+this bean requires the VM to monitor thread-related statistics such as
+how often the blocked and waiting states have been entered, as well as
+additional optional support for time and contention monitoring.
+
+Optional support is determined by the following properties:
+
+@itemize @bullet
+@item @code{gnu.java.lang.management.CurrentThreadTimeSupport} --
+This property should be present if the VM supports monitoring the
+time used by the current thread. If time monitoring for all threads
+is supported, this need not be provided.
+@item @code{gnu.java.lang.management.ThreadTimeSupport} --
+This property should be present if the VM supports monitoring the
+time used by all threads.
+@item @code{gnu.java.lang.management.ThreadContentionSupport} --
+This property should be present if the VM supports thread contention
+monitoring.
+@end itemize
+
+In addition, the property
+@code{gnu.java.lang.management.ThreadTimeInitallyEnabled} may be
+set to the @code{String} value, @code{"true"}, if time monitoring
+is enabled at startup.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(findMonitorDeadlockedThreads())} -- This should return
+an array of thread identifiers which match threads involved in
+deadlock cycles (where each thread is waiting to obtain a lock
+held by one of the others). This is specified as a native method
+in the reference implementation.
+@item @code{(getAllThreads())} -- This should return an array of
+all live threads and set the @code{filled} variable to the number
+found. A default implementation is provided.
+@item @code{(getAllThreadIds())} -- This should return an array of
+all live thread identifiers. An implementation is provided against
+@code{getAllThreads()} by default.
+@item @code{(getCurrentThreadCpuTime())} -- This should return the
+approximate number of nanoseconds of CPU time the current thread
+has used. This is an optional native method, which is used by VMs
+supporting time monitoring.
+@item @code{(getCurrentThreadUserTime())} -- This should return the
+approximate number of nanoseconds of user time the current thread
+has used. This is an optional native method, which is used by VMs
+supporting time monitoring.
+@item @code{(getDaemonThreadCount())} -- This should return the number
+of live daemon threads. A default implementation is provided, based
+on @code{getAllThreads()}.
+@item @code{(getPeakThreadCount())} -- The VM should maintain a record
+of the peak number of live threads, and return it when this method is
+called. This is specified as a native method in the reference
+implementation.
+@item @code{(resetPeakThreadCount())} -- This should reset the record
+of the peak number of live threads to the current number of live
+threads. This is specified as a native method in the reference
+implementation.
+@item @code{(getThreadCount())} -- This should return the number of
+live threads. A default implementation is provided, based on
+@code{getAllThreads()}.
+@item @code{(getThreadCpuTime(long))} -- This should return the
+approximate number of nanoseconds of CPU time the specified thread
+has used. This is an optional native method, which is used by VMs
+supporting time monitoring.
+@item @code{(getThreadUserTime(long))} -- This should return the
+approximate number of nanoseconds of CPU time the specified thread
+has used. This is an optional native method, which is used by VMs
+supporting time monitoring.
+@item @code{(getThreadInfoForId(long, int))} -- This return an instance
+of @code{java.lang.management.ThreadInfo} for the specified thread.
+The class includes a private constructor which VMs should use to initialise
+it with the appropriate values for the thread. The second argument
+given here specifies the depth of the stack trace supplied on construction
+of the instance. Special values are 0 (return an empty array) and
+@code{Integer.MAX_VALUE} (return the maximum depth possible). This
+is specified as a native method in the reference implementation.
+@item @code{(getTotalStartedThreadCount())} -- This should return the
+total number of threads that have been started by the VM, including ones
+that have died. This is specified as a native method in the reference
+implementation.
+@end itemize
+
+@node gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMMemoryMXBeanImpl}
+
+The @code{gnu.java.lang.management.MemoryMXBeanImpl} provides an
+implementation of the @code{java.lang.management.MemoryMXBean} interface,
+and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMMemoryMXBeanImpl}. This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean. Implementing
+this bean requires the VM to monitor the levels of heap and non-heap
+memory, and provide the number of objects which are eligible for garbage
+collection.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(getHeapMemoryUsage())} -- This should return
+an instance of @code{java.lang.management.MemoryUsage} with
+values pertaining to the heap. A default implementation is
+provided, based on @code{java.lang.Runtime}'s methods.
+@item @code{(getNonHeapMemoryUsage())} -- This should return
+an instance of @code{java.lang.management.MemoryUsage} with
+values pertaining to non-heap memory.
+@item @code{(getObjectPendingFinalizationCount())} -- Returns
+the number of objects which are no longer referenced, and which
+will thus be garbage collected on the next run of the garbage
+collector.
+@item @code{(isVerbose())} -- This should return @code{true}
+or @code{false}, depending on whether verbose memory management
+output is turned or not, respectively.
+@item @code{(setVerbose(boolean))} -- This should allow the
+verbose memory management output to be turned on and off.
+@end itemize
+
+@node gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMCompilationMXBeanImpl}
+
+The @code{gnu.java.lang.management.CompilationMXBeanImpl} provides an
+implementation of the optional @code{java.lang.management.CompilationMXBean}
+interface, and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMCompilationMXBeanImpl}. This provides a
+single method for returning the number of milliseconds the virtual
+machine's Just-In-Time (JIT) compiler has spent compiling. Even if
+a JIT compiler is available and an instance of the bean supplied, this
+method is still optional.
+
+Optional support is determined by the following properties:
+
+@itemize @bullet
+@item @code{gnu.java.lang.compiler.name} -- This property should
+specify the name of the JIT compiler. Classpath also uses this,
+within @code{java.lang.management.ManagementFactory}, to determine
+whether a bean should be created. If this property is set to a
+non-null value, a bean will be created and its @code{getName()}
+method will return this value.
+@item @code{gnu.java.lang.management.CompilationTimeSupport} --
+This property should be present if the VM supports monitoring the
+time spent compiling.
+@end itemize
+
+Time support is implemented by the following method:
+
+@itemize @bullet
+@item @code{(getTotalCompilationTime())} -- This should return the
+number of milliseconds the JIT compiler has spent compiling.
+@end itemize
+
+@node gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}
+
+The @code{gnu.java.lang.management.MemoryPoolMXBeanImpl} provides an
+implementation of the optional @code{java.lang.management.MemoryPoolMXBean}
+interface, and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}. Providing
+this interface requires implementing a number of methods for each supported
+pool. These return statistics on memory usage, and, optionally, allows
+monitoring of when memory usage exceedes a preset threshold.
+
+Optional support is determined by the following properties:
+
+@itemize @bullet
+@item @code{gnu.java.lang.management.CollectionUsageThresholdSupport} --
+This property should be present if the VM supports setting a collection
+usage threshold and monitoring when it is matched or exceeded. Collection
+usage thresholds are related to the remaining memory usage following a
+garbage collection cycle.
+@item @code{gnu.java.lang.management.UsageThresholdSupport} --
+This property should be present if the VM supports setting a
+usage threshold and monitoring when it is matched or exceeded.
+@end itemize
+
+The methods are as follows (all take a pool name as their
+first parameter):
+
+@itemize @bullet
+@item @code{(getCollectionUsage(String))} -- Returns a
+@code{java.lang.management.MemoryUsage} object, containing the
+memory usage statistics following a garbage collection cycle
+for the specified pool. This may also return @code{null} if
+the pool isn't an appropriate pool for this particular task.
+@item @code{(getCollectionUsageThreshold(String))} -- Returns
+the pool's collection usage threshold, if supported.
+@item @code{(getCollectionUsageThresholdCount(String))} -- Returns
+the number of times the specified pool has matched or exceeded
+its collection usage threshold, if supported.
+@item @code{(getMemoryManagerNames(String))} -- Returns a list
+of names of memory managers which manage the specified pool.
+@item @code{(getPeakUsage(String))} -- Returns a
+@code{java.lang.management.MemoryUsage} object for the peak
+usage level of the specified pool.
+@item @code{(getType(String))} -- Returns a string containing
+either @code{"HEAP"} or @code{"NON_HEAP"} which indicates the type of
+memory used by the specified pool.
+@item @code{(getUsage(String))} -- Returns a
+@code{java.lang.management.MemoryUsage} object for the current
+usage level of the specified pool.
+@item @code{(getUsageThreshold(String))} -- Returns
+the pool's usage threshold, if supported.
+@item @code{(getUsageThresholdCount(String))} -- Returns
+the number of times the specified pool has matched or exceeded
+its usage threshold, if supported.
+@item @code{(isValid(String))} -- Returns true if the pool
+is still in use by the virtual machine.
+@item @code{(resetPeakUsage(String))} -- Resets the peak usage
+levels to the current usage levels for the specified pool.
+@item @code{(setCollectionUsageThreshold(String, long))} -- Sets
+the pool's collection usage threshold, if supported.
+@item @code{(setUsageThreshold(String, long))} -- Sets
+the pool's usage threshold, if supported.
+@end itemize
+
+@node gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
+
+The @code{gnu.java.lang.management.MemoryManagerMXBeanImpl} provides an
+implementation of the optional @code{java.lang.management.MemoryManagerMXBean}
+interface, and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}. Providing
+this interface requires implementing two methods (each takes the name
+of the manager as the first argument):
+
+@itemize @bullet
+@item @code{(getMemoryPoolNames(String))} -- Returns a list of the
+memory pools that the manager maintains. A default implementation
+which scans the results of @code{getMemoryManagerNames()} for each
+pool is provided.
+@item @code{(isValid(String))} -- Returns true if the specified
+manager is still valid i.e. it is still in use by the virtual machine.
+@end itemize
+
+@node gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}
+
+The @code{gnu.java.lang.management.GarbageCollectorMXBeanImpl} provides an
+implementation of the optional @code{java.lang.management.GarbageCollectorMXBean}
+interface, and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}. Providing
+this interface requires implementing two methods (each takes the name
+of the garbage collector as the first argument):
+
+@itemize @bullet
+@item @code{(getCollectionCount(String))} -- Returns the number of
+times the specified garbage collector has run.
+@item @code{(getCollectionTime(String))} -- Returns the accumulated
+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 @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
+@section @code{java.lang.management}
+
+@code{gnu.java.lang.management} provides the VM interfaces for the GNU
+implementations of the management beans.
+
+@menu
+* java.lang.management.VMManagementFactory::
+@end menu
+
+@node java.lang.management.VMManagementFactory,,,java.lang.management
+@subsection @code{java.lang.management.VMManagementFactory}
+
+This VM interface provides the names of the memory pools, memory managers
+and garbage collectors for use by the @code{java.lang.management.ManagementFactory}
+in creating lists of appropriate beans for these types of managed object.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(getMemoryPoolNames())} -- Returns a list of the names
+of the current memory pools in use by the virtual machine.
+@item @code{(getMemoryManagerNames())} -- Returns a list of the names
+of the current memory managers in use by the virtual machine. This
+should not include those that are also garbage collectors.
+@item @code{(getGarbageCollectorNames())} -- Returns a list of the names
+of the current garbage collectors in use by the virtual machine.
+@end itemize
+
+@node Classpath Callbacks, , java.lang.management, Classpath Hooks
Some of the classes you implement for the VM will need to call back to
package-private methods in Classpath:
@@ -1269,6 +1652,26 @@ the group.
@item @code{java.lang.ThreadGroup.removeThread(Thread)}
Call this method from @code{Thread} when a @code{Thread} is stopped or destroyed.
+
+@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireThresholdExceededNotification(String, long, long, long, long)}
+If the monitoring of memory usage thresholds is supported, this method
+should be called when the normal usage of a memory pool crosses the
+threshold, in order to emit a notification. Another notification
+should not be emitted until there is an intermittent period where the
+usage is again below the threshold. The parameters are the memory
+pool name, the usage levels (init, used, committed and max) and the
+number of times the threshold has been crossed.
+
+@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireCollectionThresholdExceededNotification(String, long, long, long, long)}
+If the monitoring of memory usage thresholds is supported, this method
+should be called when the usage of a memory pool after a garbage
+collection cycle crosses the threshold, in order to emit a
+notification. Another notification should not be emitted until there
+is an intermittent period where the usage is again below the
+threshold. The parameters are the memory pool name, the usage levels
+(init, used, committed and max) and the number of times the threshold
+has been crossed.
+
@end itemize
@node VM Hooks, JNI Implementation, Classpath Hooks, Top
@@ -1369,7 +1772,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
@@ -1412,8 +1815,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/libjava/classpath/examples/Makefile.am b/libjava/classpath/examples/Makefile.am
index 71909e8d64d..84e3ebe0fc9 100644
--- a/libjava/classpath/examples/Makefile.am
+++ b/libjava/classpath/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/libjava/classpath/examples/Makefile.in b/libjava/classpath/examples/Makefile.in
index d8336a98bf3..47742688983 100644
--- a/libjava/classpath/examples/Makefile.in
+++ b/libjava/classpath/examples/Makefile.in
@@ -39,7 +39,7 @@ host_triplet = @host@
target_triplet = @target@
subdir = examples
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/Makefile.jawt.in
+ $(srcdir)/Makefile.java2d.in $(srcdir)/Makefile.jawt.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
@@ -52,7 +52,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
-CONFIG_CLEAN_FILES = Makefile.jawt
+CONFIG_CLEAN_FILES = Makefile.jawt Makefile.java2d
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -95,6 +95,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -115,6 +117,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -145,6 +148,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -195,6 +202,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -215,6 +223,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -290,8 +300,9 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
# 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
@@ -306,7 +317,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
@@ -315,7 +326,7 @@ example_DATA = $(EXAMPLE_ZIP) README
exampledir = $(pkgdatadir)/examples
# Make sure everything is included in the distribution.
-EXTRA_DIST = README Makefile.jawt.in
+EXTRA_DIST = README Makefile.jawt.in Makefile.java2d.in
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -351,6 +362,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
Makefile.jawt: $(top_builddir)/config.status $(srcdir)/Makefile.jawt.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Makefile.java2d: $(top_builddir)/config.status $(srcdir)/Makefile.java2d.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
mostlyclean-libtool:
-rm -f *.lo
@@ -524,7 +537,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`; \
@@ -534,7 +549,9 @@ 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
dist-hook:
srcdir_cnt=`echo $(srcdir) | wc -c`; \
for file in $(ALL_EXAMPLE_FILES); do \
diff --git a/libjava/classpath/examples/Makefile.java2d.in b/libjava/classpath/examples/Makefile.java2d.in
new file mode 100644
index 00000000000..dac22068c4d
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/examples/README b/libjava/classpath/examples/README
index 727677363c6..f7bf599624a 100644
--- a/libjava/classpath/examples/README
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
index c41ebe237ea..652ee53ccee 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
index 42fb7a574a7..2ac03a895ed 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
index f111d0eac93..ccf792da875 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
index 4d5eee74b4b..6ad13a9bbc7 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java b/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java
new file mode 100644
index 00000000000..ed18fd4c2ee
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/awt/AicasGraphicsBenchmark.java
@@ -0,0 +1,1018 @@
+/* AnimationApplet.java -- An example of an old-style AWT applet
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.awt;
+
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.Panel;
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class AicasGraphicsBenchmark extends Panel
+{
+ /**
+ * Default number of test-iterations.
+ */
+ private static final int DEFAULT_TEST_SIZE = 1000;
+
+ /**
+ * Default screen size.
+ */
+ private static final int DEFAULT_SCREEN_WIDTH = 320;
+ private static final int DEFAULT_SCREEN_HEIGHT = 240;
+
+ /**
+ * AWT tests.
+ */
+ private static final int AWTTEST_LINES = 1 << 0;
+ private static final int AWTTEST_RECT = 1 << 1;
+ private static final int AWTTEST_POLYLINE = 1 << 2;
+ private static final int AWTTEST_POLYGON = 1 << 3;
+ private static final int AWTTEST_ARC = 1 << 4;
+ private static final int AWTTEST_OVAL = 1 << 5;
+ private static final int AWTTEST_ROUNDRECT = 1 << 6;
+ private static final int AWTTEST_STRING = 1 << 7;
+ private static final int AWTTEST_TRANSPARENTIMAGE = 1 << 8;
+ private static final int AWTTEST_IMAGE = 1 << 9;
+
+ private static final int AWTTEST_NONE = 0;
+ private static final int AWTTEST_ALL = AWTTEST_LINES
+ | AWTTEST_RECT
+ | AWTTEST_POLYLINE
+ | AWTTEST_POLYGON
+ | AWTTEST_ARC
+ | AWTTEST_OVAL
+ | AWTTEST_ROUNDRECT
+ | AWTTEST_STRING
+ | AWTTEST_TRANSPARENTIMAGE
+ | AWTTEST_IMAGE
+ ;
+
+ int iterations = 1;
+ private int screenWidth = DEFAULT_SCREEN_WIDTH;
+ private int screenHeight = DEFAULT_SCREEN_HEIGHT;
+ boolean doubleBufferFlag = true;
+ private int awtTests = AWTTEST_ALL;
+
+ private Label testLabel;
+
+ private String testContext = "";
+
+ Logger logger = Logger.getLogger("AicasGraphicsBenchmark");
+
+ private Image pngTestImage;
+ private Image gifTestImage;
+
+ private TestSet testSetMap = new TestSet();
+
+ public AicasGraphicsBenchmark()
+ {
+ pngTestImage = loadImage("aicas.png");
+ gifTestImage = loadImage("palme.gif");
+
+ setLayout(new BorderLayout());
+ testLabel = new Label();
+ add(testLabel,BorderLayout.NORTH);
+ add(new GraphicsTest(),BorderLayout.CENTER);
+ }
+
+ void setTestContext(String testName)
+ {
+ logger.logp(Level.INFO, "AicasGraphicsBenchmark", "recordTest",
+ "--- Starting new test context: " + testName);
+ testContext = testName;
+ testLabel.setText(testName);
+ }
+
+ private void recordTest(String testName, long time)
+ {
+ logger.logp(Level.INFO, "AicasGraphicsBenchmark", "recordTest",
+ testContext + ": " + testName + " duration (ms): " + time);
+ TestRecorder recorder = testSetMap.getTest(testName);
+ if (recorder == null)
+ {
+ recorder = new TestRecorder(testName);
+ testSetMap.putTest(testName,recorder);
+ }
+ recorder.addRun(time);
+ }
+
+ void printReport()
+ {
+ for (Iterator i = testSetMap.testIterator(); i.hasNext(); )
+ {
+ TestRecorder recorder = testSetMap.getTest((String)i.next());
+ System.out.println("TEST " + recorder.getTestName() + ": average "
+ + recorder.getAverage() + "ms ["
+ + recorder.getMinTime() + "-" + recorder.getMaxTime()
+ + "]");
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ int awtTests;
+ int i;
+ boolean endOfOptionsFlag;
+ AicasGraphicsBenchmark speed= new AicasGraphicsBenchmark();
+
+ // Parse arguments.
+ i = 0;
+ endOfOptionsFlag = false;
+ awtTests = AWTTEST_NONE;
+ while (i < args.length)
+ {
+ if (!endOfOptionsFlag)
+ {
+ if (args[i].equals("--help") || args[i].equals("-help")
+ || args[i].equals("-h"))
+ {
+ System.out.println("Usage: AicasGraphicsBenchmark [<options>] [<test> ...]");
+ System.out.println("");
+ System.out.println("Options: -i|--iterations=<n|-1> - number of iterations (-1 is infinite)");
+ System.out.println(" -w|--width=<n> - screen width; default "+DEFAULT_SCREEN_WIDTH);
+ System.out.println(" -h|--height=<n> - screen height; default "+DEFAULT_SCREEN_HEIGHT);
+ System.out.println(" -n|--noDoubleBuffer - disable double-buffering test");
+ System.out.println("");
+ System.out.println("Tests: line");
+ System.out.println(" rect");
+ System.out.println(" polyline");
+ System.out.println(" polygon");
+ System.out.println(" arc");
+ System.out.println(" oval");
+ System.out.println(" roundrect");
+ System.out.println(" string");
+ System.out.println(" transparentimage");
+ System.out.println(" image");
+ System.exit(1);
+ }
+ else if ((args[i].startsWith("-i=")
+ || args[i].startsWith("--iterations=")))
+ {
+ speed.iterations =
+ Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-i") || args[i].equals("--iterations")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.iterations = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].startsWith("-w=")
+ || args[i].startsWith("--width=")))
+ {
+ speed.screenWidth =
+ Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-w") || args[i].equals("--width")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.screenWidth = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].startsWith("-h=")
+ || args[i].startsWith("--height=")))
+ {
+ speed.screenHeight =
+ Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i+=1;
+ continue;
+ }
+ else if ((args[i].equals("-h") || args[i].equals("--height")))
+ {
+ if ((i+1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.screenHeight = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].equals("-n")
+ || args[i].equals("--noDoubleBuffer")))
+ {
+ speed.doubleBufferFlag = false;
+ i += 1;
+ continue;
+ }
+ else if (args[i].equals("--"))
+ {
+ endOfOptionsFlag = true;
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("-"))
+ {
+ System.err.println("ERROR: Unknown option '" + args[i] + "'!");
+ System.exit(2);
+ }
+ }
+ StringTokenizer tokenizer = new StringTokenizer(args[i], " +,");
+ while (tokenizer.hasMoreTokens())
+ {
+ String s = tokenizer.nextToken().toLowerCase();
+ if (s.equals("line"))
+ awtTests |= AWTTEST_LINES;
+ else if (s.equals("rect"))
+ awtTests |= AWTTEST_RECT;
+ else if (s.equals("polyline"))
+ awtTests |= AWTTEST_POLYLINE;
+ else if (s.equals("polygon"))
+ awtTests |= AWTTEST_POLYGON;
+ else if (s.equals("arc"))
+ awtTests |= AWTTEST_ARC;
+ else if (s.equals("oval"))
+ awtTests |= AWTTEST_OVAL;
+ else if (s.equals("roundrect"))
+ awtTests |= AWTTEST_ROUNDRECT;
+ else if (s.equals("string"))
+ awtTests |= AWTTEST_STRING;
+ else if (s.equals("transparentimage"))
+ awtTests |= AWTTEST_TRANSPARENTIMAGE;
+ else if (s.equals("image"))
+ awtTests |= AWTTEST_IMAGE;
+ else
+ {
+ System.err.println("Unknown AWT test '" + s + "'!");
+ System.exit(2);
+ }
+ }
+ i += 1;
+ }
+ if (awtTests != AWTTEST_NONE)
+ speed.awtTests = awtTests;
+
+ // Create graphics.
+ final Frame frame = new Frame("AicasGraphicsBenchmark");
+
+ frame.addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ frame.setVisible(false);
+ System.exit(0);
+ }
+ });
+
+ frame.add(speed,BorderLayout.CENTER);
+ frame.setSize(speed.screenWidth,speed.screenHeight);
+ frame.setVisible(true);
+
+ // Insets are correctly set only after the native peer was created.
+ Insets insets = frame.getInsets();
+ // The internal size of the frame should be 320x240.
+ frame.setSize(320 + insets.right + insets.left,
+ 240 + insets.top + insets.bottom);
+ }
+
+ private Image loadImage(String imageName)
+ {
+ Image result = null;
+ logger.logp(Level.INFO, "AicasGraphicsBenchmark", "loadImage",
+ "Loading image: " + imageName);
+ URL url = getClass().getResource(imageName);
+ if (url != null)
+ {
+ result = Toolkit.getDefaultToolkit().getImage(url);
+ prepareImage(result, this);
+ }
+ else
+ {
+ logger.logp(Level.WARNING, "AicasGraphicsBenchmark", "loadImage",
+ "Could not locate image resource in class path: "
+ + imageName);
+ }
+ return result;
+ }
+
+ /**
+ * Executes the test methods.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ void runTestSet(Graphics g, Dimension size)
+ {
+ if ((awtTests & AWTTEST_LINES) != 0)
+ test_drawLine(g, size);
+ if ((awtTests & AWTTEST_RECT) != 0)
+ test_drawRect(g, size);
+ if ((awtTests & AWTTEST_RECT) != 0)
+ test_fillRect(g, size);
+ if ((awtTests & AWTTEST_POLYLINE) != 0)
+ test_drawPolyline(g, size);
+ if ((awtTests & AWTTEST_POLYGON) != 0)
+ test_drawPolygon(g, size);
+ if ((awtTests & AWTTEST_POLYGON) != 0)
+ test_fillPolygon(g,size);
+ if ((awtTests & AWTTEST_ARC) != 0)
+ test_drawArc(g,size);
+ if ((awtTests & AWTTEST_ARC) != 0)
+ test_fillArc(g,size);
+ if ((awtTests & AWTTEST_OVAL) != 0)
+ test_drawOval(g, size);
+ if ((awtTests & AWTTEST_OVAL) != 0)
+ test_fillOval(g, size);
+ if ((awtTests & AWTTEST_ROUNDRECT) != 0)
+ test_fillRoundRect(g, size);
+ if ((awtTests & AWTTEST_STRING) != 0)
+ test_drawString(g, size);
+ if ((awtTests & AWTTEST_TRANSPARENTIMAGE) != 0)
+ test_drawTransparentImage(g,size);
+ if ((awtTests & AWTTEST_IMAGE) != 0)
+ test_drawImage(g,size);
+ }
+
+ /**
+ * Gets a new random Color.
+ *
+ * @returna new random Color
+ */
+ private Color getNextColor()
+ {
+ return new Color((int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1);
+ }
+
+ /**
+ * Draws random lines within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawLine(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x1 = (int) (Math.random() * (size.width-minSize));
+ int y1 = (int) (Math.random() * (size.height-minSize));
+ int x2 = (int) (Math.random() * (size.width-minSize));
+ int y2 = (int) (Math.random() * (size.height-minSize));
+ g.drawLine(x1, y1, x2, y2);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawLine " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random rectangles within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawRect(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x1 = (int) (Math.random() * (size.width-minSize));
+ int y1 = (int) (Math.random() * (size.height-minSize));
+ int x2 = (int) (Math.random() * (size.width-minSize));
+ int y2 = (int) (Math.random() * (size.height-minSize));
+ g.drawRect(x1, y1, x2, y2);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawRect " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random rectangles within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillRect(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x1 = (int) (Math.random() * (size.width-minSize));
+ int y1 = (int) (Math.random() * (size.height-minSize));
+ int x2 = (int) (Math.random() * (size.width-minSize));
+ int y2 = (int) (Math.random() * (size.height-minSize));
+ g.fillRect(x1, y1, x2, y2);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("fillRect " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random polylines within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawPolyline(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int points = (int)(Math.random() * 6) + 3;
+ int[] x_coords = new int[points];
+ int[] y_coords = new int[points];
+ for (int j = 0; j < points; j+=1)
+ {
+ x_coords[j] = (int)(Math.random() * (size.width));
+ y_coords[j] = (int)(Math.random() * (size.height));
+ }
+ g.drawPolyline(x_coords,y_coords, points);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawPolyline " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random polygons within the given dimensions.
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawPolygon(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int points = (int) (Math.random() * 6) + 3;
+ int[] xcoords = new int[points];
+ int[] ycoords = new int[points];
+ for(int j = 0; j < points; j+=1)
+ {
+ xcoords[j] = (int) (Math.random() * (size.width));
+ ycoords[j] = (int) (Math.random() * (size.height));
+ }
+ g.drawPolygon(xcoords, ycoords, points);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawPolygon " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random filled polygons within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillPolygon(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int points = (int) (Math.random() * 6) + 3;
+ int[] xcoords = new int[points];
+ int[] ycoords = new int[points];
+ for (int j = 0; j < points; j+=1)
+ {
+ xcoords[j] = (int) (Math.random() * (size.width));
+ ycoords[j] = (int) (Math.random() * (size.height));
+ }
+ g.fillPolygon(xcoords, ycoords, points);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("fillPolygon " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random arcs within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawArc(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int startAngle = (int) (Math.random() * 360);
+ int arcAngle = (int) (Math.random() * 360 - startAngle);
+ g.drawArc(x, y, width, height, startAngle, arcAngle);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("drawArc " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random filled arcs within the given dimensions.
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillArc(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int)(Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int)(Math.random() * (size.height - y - minSize) + minSize);
+ int startAngle = (int)(Math.random() * 360);
+ int arcAngle = (int)(Math.random() * 360);
+ g.fillArc(x, y, width, height, startAngle, arcAngle);
+
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("fillArc " + maxTests + " times", (endTime - startTime));
+ }
+
+ /**
+ * Draws random ovals within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawOval(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int)(Math.random() * (size.width - minSize + 1));
+ int y = (int)(Math.random() * (size.height - minSize + 1));
+ int width = (int)(Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int)(Math.random() * (size.height - y - minSize) + minSize);
+ g.drawOval(x, y, Math.min(width, height), Math.min(width, height));
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("drawOval " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random filled ovals within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillOval(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ g.fillOval(x, y, width,height);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("fillOval " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random filled rounded rectangles within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillRoundRect(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i=0; i < maxTests; i+=1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int arcWidth = (int) (Math.random() * (width - 1) + 1);
+ int arcHeight = (int) (Math.random() * (height - 1) + 5);
+ g.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("fillRoundRect " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random images within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawImage(Graphics g, Dimension size)
+ {
+ if (gifTestImage == null)
+ {
+ logger.logp(Level.WARNING, "AicasGraphicsBenchmark", "runTestSet",
+ "Skipping 'test_drawImage' due to missing resource.");
+ return;
+ }
+
+ int maxTests = DEFAULT_TEST_SIZE / 2;
+ if(maxTests == 0)
+ maxTests = 1;
+ int imageWidth = gifTestImage.getWidth(this);
+ int imageHeight = gifTestImage.getHeight(this);
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - imageWidth + 1));
+ int y = (int) (Math.random() * (size.height - imageHeight + 1));
+ g.drawImage(gifTestImage, x, y, this);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawImage " + maxTests + " times", (endTime-startTime));
+ }
+
+ /**
+ * Draws random transparent images within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawTransparentImage(Graphics g, Dimension size)
+ {
+ if (pngTestImage == null)
+ {
+ logger.logp(Level.WARNING, "AicasGraphicsBenchmark", "runTestSet",
+ "Skipping 'test_drawTransparentImage' due to missing resource.");
+ return;
+ }
+
+
+ int maxTests = DEFAULT_TEST_SIZE / 5;
+ if(maxTests == 0)
+ maxTests = 1;
+ int imageWidth = pngTestImage.getWidth(this);
+ int imageHeight = pngTestImage.getHeight(this);
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ int x = (int) (Math.random() * (size.width - imageWidth + 1));
+ int y = (int) (Math.random() * (size.height - imageHeight + 1));
+ g.drawImage(pngTestImage, x, y, this);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw transparent image " + maxTests + " times",
+ (endTime-startTime));
+ }
+
+ /**
+ * Draws random strings within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawString(Graphics g, Dimension size)
+ {
+ int maxTests = DEFAULT_TEST_SIZE;
+ String testString = "HelloWorld";
+ int stringWidth = g.getFontMetrics().stringWidth(testString);
+ int stringHeight = g.getFontMetrics().getHeight();
+
+ long startTime = System.currentTimeMillis();
+ for(int i = 0; i < maxTests; i += 1)
+ {
+ g.setColor(getNextColor());
+ g.drawString(testString, (int) (Math.random() * (size.width - stringWidth + 1)),(int)(Math.random() * (size.height - stringHeight + 1)) + stringHeight);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawString " + maxTests + " times", (endTime-startTime));
+ }
+
+ private class GraphicsTest extends Canvas implements Runnable
+ {
+ Thread paintThread;
+ boolean done = false;
+ boolean doPaint = false;
+ boolean withClipping = false;
+
+ public GraphicsTest()
+ {
+ paintThread = new Thread(this);
+ paintThread.start();
+ }
+
+ public void run()
+ {
+ int runCount = 0;
+ while (!done)
+ {
+ runCount++;
+
+ try
+ {
+ synchronized (this)
+ {
+ while (!doPaint)
+ {
+ try
+ {
+ wait(200);
+ }
+ catch (InterruptedException exception)
+ {
+ return;
+ }
+ }
+ }
+
+ if (iterations != 0)
+ System.out.println("--- run...(" + runCount + "/" + iterations
+ + ") ------------------------------------------------------");
+
+ Graphics g = getGraphics();
+ Dimension size = getSize();
+ logger.logp(Level.INFO, "AicasGraphicsBenchmark.GraphicsTest", "run",
+ "Start testing non-double-buffered drawing");
+ runSet_noClipping(g,size);
+ runSet_zeroClipping(g, size);
+ runSet_withClipping(g, size);
+ g.dispose();
+
+ if (doubleBufferFlag)
+ {
+ logger.logp(Level.INFO, "AicasGraphicsBenchmark.GraphicsTest",
+ "run", "Start testing double-buffered drawing");
+ Graphics canvas = getGraphics();
+ Image doublebuffer = createImage(size.width,size.height);
+ g = doublebuffer.getGraphics();
+ runSet_noClipping(g,size);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+
+ g = doublebuffer.getGraphics();
+ runSet_withClipping(g, size);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+
+ g = doublebuffer.getGraphics();
+ runSet_zeroClipping(g, size);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+ canvas.dispose();
+ }
+
+ printReport();
+
+ if (iterations != 0)
+ {
+ if (iterations != -1)
+ iterations--;
+ }
+ else
+ {
+ System.out.println("--- done --------------------------------------------------------");
+ synchronized (this)
+ {
+ doPaint = false;
+ }
+ done = true;
+ }
+ }
+ catch (Error error)
+ {
+ System.err.println("Error: " + error);
+ System.exit(129);
+ }
+ }
+ System.exit(0);
+ }
+
+ private void runSet_zeroClipping(Graphics g, Dimension size)
+ {
+ int clipped_width;
+ int clipped_height;
+ int clipped_x;
+ int clipped_y;
+
+ clipped_width = 0;
+ clipped_height = 0;
+ clipped_x = (size.width) / 2;
+ clipped_y = (size.height) / 2;
+ g.setClip(0, 0, size.width, size.height);
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, size.width, size.height);
+ g.setColor(Color.WHITE);
+ g.drawRect(0, 0, size.width - 1, size.height - 1);
+ g.fillRect(clipped_x - 1, clipped_y - 1, clipped_width + 2, clipped_height + 2);
+
+ g.clipRect(clipped_x, clipped_y, clipped_width, clipped_height);
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, size.width, size.height);
+
+ setTestContext("clipping to zero");
+
+ runTestSet(g, size);
+ }
+
+ private void runSet_withClipping(Graphics g, Dimension size)
+ {
+ int clipped_width = 2 * size.width / 3;
+ int clipped_height = 2 * size.height / 3;
+ int clipped_x = (size.width - clipped_width) / 2;
+ int clipped_y = (size.height - clipped_height) / 2;
+
+ g.setClip(0,0,size.width,size.height);
+
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, size.width, size.height);
+ g.setColor(Color.GREEN);
+ g.drawRect(0, 0, size.width - 1, size.height - 1);
+ g.setColor(Color.WHITE);
+ g.fillRect(clipped_x - 1, clipped_y - 1, clipped_width + 2, clipped_height + 2);
+
+ g.clipRect(clipped_x, clipped_y, clipped_width, clipped_height);
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, size.width, size.height);
+
+ setTestContext("with clipping");
+
+ runTestSet(g, size);
+ }
+
+ public void runSet_noClipping(Graphics g, Dimension size)
+ {
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, size.width, size.height);
+
+ setTestContext("without clipping");
+
+ runTestSet(g, size);
+ }
+
+ public void paint(Graphics g)
+ {
+ synchronized(this)
+ {
+ doPaint=true;
+ notify();
+ }
+ }
+ }
+}
+
+class TestContext
+{
+}
+
+class TestSet
+{
+ private Map testsMap = new TreeMap();
+
+ public void putTest(String testName, TestRecorder recoder)
+ {
+ testsMap.put(testName,recoder);
+ }
+
+ public TestRecorder getTest(String testName)
+ {
+ return (TestRecorder)testsMap.get(testName);
+ }
+
+ public Iterator testIterator()
+ {
+ return testsMap.keySet().iterator();
+ }
+}
+
+class TestRecorder
+{
+ String test;
+ long totalTime = 0;
+ long minTime = Long.MAX_VALUE;
+ long maxTime = Long.MIN_VALUE;
+ int runCount = 0;
+
+ /**
+ * @return Returns the maxTime.
+ */
+ public final long getMaxTime()
+ {
+ return maxTime;
+ }
+
+ /**
+ * @return Returns the minTime.
+ */
+ public final long getMinTime()
+ {
+ return minTime;
+ }
+
+ /**
+ * @return Returns the test name.
+ */
+ public final String getTestName()
+ {
+ return test;
+ }
+
+ public final double getAverage()
+ {
+ return ((double)totalTime) / ((double)runCount);
+ }
+
+ public TestRecorder(String testName)
+ {
+ test = testName;
+ }
+
+ public void addRun(long time)
+ {
+ totalTime += time;
+ if(minTime > time)
+ minTime = time;
+ if(maxTime < time)
+ maxTime = time;
+ runCount += 1;
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java
index 64594e47b10..bd5e755cbb5 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/awt/Demo.java
@@ -20,11 +20,70 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
package gnu.classpath.examples.awt;
-import java.awt.*;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxGroup;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.DisplayMode;
+import java.awt.FileDialog;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Label;
import java.awt.List;
-import java.awt.event.*;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.MenuShortcut;
+import java.awt.Panel;
+import java.awt.ScrollPane;
+import java.awt.TextField;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.net.URL;
-import java.util.*;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
class Demo
{
@@ -154,6 +213,9 @@ class Demo
addSubWindow ("RandomTests", new TestWindow (this));
addSubWindow ("RoundRect", new RoundRectWindow ());
addSubWindow ("Animation", new AnimationWindow ());
+ addSubWindow ("Resolution", new ResolutionWindow ());
+ addSubWindow ("Fullscreen", new FullscreenWindow ());
+ addSubWindow ("Drag n' Drop", new DragDropWindow ());
Panel sp = new Panel();
PrettyPanel p = new PrettyPanel();
@@ -744,6 +806,234 @@ class Demo
t.beep();
}
}
+
+ static class ResolutionWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Change Screen Resolution");
+ final List list = new List();
+ DisplayMode[] modes = gd.getDisplayModes();
+
+ for (int i=0;i<modes.length;i++ )
+ list.add(modes[i].getWidth() + "x"
+ + modes[i].getHeight()
+ + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
+ ? "x" + modes[i].getBitDepth() + "bpp"
+ : "")
+ + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN)
+ ? "@" + modes[i].getRefreshRate() + "Hz"
+ : ""));
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ int i = list.getSelectedIndex();
+ gd.setDisplayMode(gd.getDisplayModes()[i]);
+ }
+ };
+
+ Button b = new Button("Switch");
+ Button c = new Button("Close");
+
+ list.addActionListener(al);
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(list);
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
+
+ static class DragDropWindow
+ extends SubFrame
+ implements ActionListener, DropTargetListener
+ {
+ DragLabel source = new DragLabel("Drag and drop me to the following Button",
+ Label.CENTER);
+
+ Button target = new Button();
+
+ public void init()
+ {
+ source.setForeground(Color.red);
+ add(source, BorderLayout.NORTH);
+
+ target.addActionListener(this);
+ add(target, BorderLayout.SOUTH);
+
+ new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this);
+
+ setSize(205, 100);
+
+ pack();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Button b = (Button) e.getSource();
+ b.setLabel("");
+ }
+
+ public void dragEnter(DropTargetDragEvent e)
+ {
+ }
+
+ public void dragExit(DropTargetEvent e)
+ {
+ }
+
+ public void dragOver(DropTargetDragEvent e)
+ {
+ }
+
+ public void drop(DropTargetDropEvent e)
+ {
+ try
+ {
+ Transferable t = e.getTransferable();
+
+ if (e.isDataFlavorSupported(DataFlavor.stringFlavor))
+ {
+ e.acceptDrop(e.getDropAction());
+
+ String s;
+ s = (String) t.getTransferData(DataFlavor.stringFlavor);
+
+ target.setLabel(s);
+
+ e.dropComplete(true);
+ }
+ else
+ e.rejectDrop();
+ }
+ catch (java.io.IOException e2)
+ {
+ }
+ catch (UnsupportedFlavorException e2)
+ {
+ }
+ }
+
+ public void dropActionChanged(DropTargetDragEvent e)
+ {
+ }
+
+ class DragLabel
+ extends Label
+ implements DragGestureListener, DragSourceListener
+ {
+ private DragSource ds = DragSource.getDefaultDragSource();
+
+ public DragLabel(String s, int alignment)
+ {
+ super(s, alignment);
+ int action = DnDConstants.ACTION_COPY_OR_MOVE;
+ ds.createDefaultDragGestureRecognizer(this, action, this);
+ }
+
+ public void dragGestureRecognized(DragGestureEvent e)
+ {
+ try
+ {
+ Transferable t = new StringSelection(getText());
+ e.startDrag(DragSource.DefaultCopyNoDrop, t, this);
+ }
+ catch (InvalidDnDOperationException e2)
+ {
+ System.out.println(e2);
+ }
+ }
+
+ public void dragDropEnd(DragSourceDropEvent e)
+ {
+ if (e.getDropSuccess() == false)
+ return;
+
+ int action = e.getDropAction();
+ if ((action & DnDConstants.ACTION_MOVE) != 0)
+ setText("");
+ }
+
+ public void dragEnter(DragSourceDragEvent e)
+ {
+ DragSourceContext ctx = e.getDragSourceContext();
+
+ int action = e.getDropAction();
+ if ((action & DnDConstants.ACTION_COPY) != 0)
+ ctx.setCursor(DragSource.DefaultCopyDrop);
+ else
+ ctx.setCursor(DragSource.DefaultCopyNoDrop);
+ }
+
+ public void dragExit(DragSourceEvent e)
+ {
+ }
+
+ public void dragOver(DragSourceDragEvent e)
+ {
+ }
+
+ public void dropActionChanged(DragSourceDragEvent e)
+ {
+ }
+ }
+ }
+
+ static class FullscreenWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Fullscreen Exclusive Mode");
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ if (gd.getFullScreenWindow() == FullscreenWindow.this)
+ gd.setFullScreenWindow(null);
+ else
+ gd.setFullScreenWindow(FullscreenWindow.this);
+ }
+ };
+
+ Button b = new Button("Toggle Fullscreen");
+ Button c = new Button("Close");
+
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ gd.setFullScreenWindow(null);
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
static class RoundRectWindow extends SubFrame
{
diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java
new file mode 100644
index 00000000000..118ae2463b8
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java
@@ -0,0 +1,1571 @@
+/* J2dBenchmark.java -- Benchmarking utility for java2d,
+ based on the Aicas AWT benchmarker
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath examples.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA. */
+
+package gnu.classpath.examples.java2d;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.MediaTracker;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.TexturePaint;
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.QuadCurve2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class J2dBenchmark
+ extends Panel
+{
+ /**
+ * Default number of test-iterations.
+ */
+ protected static final int DEFAULT_TEST_SIZE = 1000;
+
+ /**
+ * Default screen size.
+ */
+ protected static final int DEFAULT_SCREEN_WIDTH = 320;
+
+ protected static final int DEFAULT_SCREEN_HEIGHT = 240;
+
+ /**
+ * Java2D tests.
+ */
+ protected static final int J2DTEST_ARC = 1 << 0;
+
+ protected static final int J2DTEST_CUBICCURVE = 1 << 1;
+
+ protected static final int J2DTEST_ELLIPSE = 1 << 2;
+
+ protected static final int J2DTEST_GENERALPATH = 1 << 3;
+
+ protected static final int J2DTEST_LINE = 1 << 4;
+
+ protected static final int J2DTEST_QUADCURVE = 1 << 5;
+
+ protected static final int J2DTEST_RECTANGLE = 1 << 6;
+
+ protected static final int J2DTEST_ROUNDRECTANGLE = 1 << 7;
+
+ protected static final int J2DTEST_IMAGE = 1 << 8;
+
+ protected static final int J2DTEST_NONE = 0;
+
+ /*
+ private static final int J2DTEST_ALL = J2DTEST_ARC | J2DTEST_CUBICCURVE
+ | J2DTEST_ELLIPSE
+ | J2DTEST_GENERALPATH | J2DTEST_LINE
+ | J2DTEST_QUADCURVE
+ | J2DTEST_RECTANGLE
+ | J2DTEST_ROUNDRECTANGLE
+ | J2DTEST_IMAGE;
+ */
+ private static final int J2DTEST_ALL = J2DTEST_ARC | J2DTEST_CUBICCURVE
+ | J2DTEST_ELLIPSE
+ | J2DTEST_LINE
+ | J2DTEST_QUADCURVE
+ | J2DTEST_RECTANGLE
+ | J2DTEST_ROUNDRECTANGLE
+ | J2DTEST_IMAGE;
+
+ int iterations = 1;
+
+ protected int screenWidth = DEFAULT_SCREEN_WIDTH;
+
+ protected int screenHeight = DEFAULT_SCREEN_HEIGHT;
+
+ protected boolean noClippingFlag = true;
+
+ protected boolean withClippingFlag = true;
+
+ protected boolean zeroClippingFlag = true;
+
+ protected boolean singleBufferFlag = true;
+
+ protected boolean doubleBufferFlag = true;
+
+ protected boolean gradientFlag = false;
+
+ protected String texture = null;
+
+ protected boolean strokeFlag = false;
+
+ protected float composite = 1;
+
+ protected int xtranslate = 0;
+
+ protected int ytranslate = 0;
+
+ protected double xshear = 0;
+
+ protected double yshear = 0;
+
+ protected double rotate = 0;
+
+ protected boolean antialiasFlag = false;
+
+ protected AffineTransform affineTransform = null;
+
+ protected int awtTests = J2DTEST_ALL;
+
+ protected int testSize = DEFAULT_TEST_SIZE;
+
+ private Label testLabel;
+
+ private String testContext = "";
+
+ Logger logger = Logger.getLogger("J2dGraphicsBenchmark");
+
+ private Image pngTestImage;
+
+ private Image gifTestImage;
+
+ protected BufferedImage textureImage;
+
+ protected TestSet testSetMap = new TestSet();
+
+ public String init()
+ {
+ boolean loadError = false;
+ pngTestImage = loadImage("aicas.png");
+ gifTestImage = loadImage("palme.gif");
+
+ if (texture != null)
+ {
+ textureImage = loadBufferedImage(texture);
+
+ if (textureImage == null)
+ {
+ logger.logp(Level.WARNING, "J2dGraphicsBenchmark", "init",
+ "Unable to load texture - defaulting "
+ + "to solid colours");
+ texture = null;
+ loadError = true;
+ }
+ }
+
+ setLayout(new BorderLayout());
+ testLabel = new Label();
+ add(testLabel, BorderLayout.NORTH);
+ add(new GraphicsTest(), BorderLayout.CENTER);
+
+ if (loadError)
+ return "Unable to load image";
+ else
+ return null;
+ }
+
+ void setTestContext(String testName)
+ {
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark", "recordTest",
+ "--- Starting new test context: " + testName);
+ testContext = testName;
+ testLabel.setText(testName);
+ }
+
+ private void recordTest(String testName, long time)
+ {
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark", "recordTest",
+ testContext + ": " + testName + " duration (ms): " + time);
+ TestRecorder recorder = testSetMap.getTest(testName);
+ if (recorder == null)
+ {
+ recorder = new TestRecorder(testName);
+ testSetMap.putTest(testName, recorder);
+ }
+ recorder.addRun(time);
+ }
+
+ void printReport()
+ {
+ for (Iterator i = testSetMap.testIterator(); i.hasNext();)
+ {
+ TestRecorder recorder = testSetMap.getTest((String) i.next());
+ System.out.println("TEST " + recorder.getTestName() + ": average "
+ + recorder.getAverage() + "ms ["
+ + recorder.getMinTime() + "-"
+ + recorder.getMaxTime() + "]");
+ }
+ }
+
+ void testComplete()
+ {
+ System.exit(0);
+ }
+
+ public static void main(String[] args)
+ {
+ int awtTests;
+ int i;
+ boolean endOfOptionsFlag;
+ J2dBenchmark speed = new J2dBenchmark();
+
+ // Parse arguments.
+ i = 0;
+ endOfOptionsFlag = false;
+ awtTests = J2DTEST_NONE;
+ while (i < args.length)
+ {
+ if (! endOfOptionsFlag)
+ {
+ if (args[i].equals("--help") || args[i].equals("-help")
+ || args[i].equals("-h"))
+ {
+ System.out.println("Usage: J2dBenchmark [<options>] [<test> ...]");
+ System.out.println("");
+ System.out.println("Options: -i|--iterations=<n|-1> - number of iterations (-1 is infinite; default "
+ + speed.iterations + ")");
+ System.out.println(" -w|--width=<n> - screen width; default "
+ + DEFAULT_SCREEN_WIDTH);
+ System.out.println(" -h|--height=<n> - screen height; default "
+ + DEFAULT_SCREEN_HEIGHT);
+ System.out.println(" -d|--noDoubleBuffer - disable double-buffering test");
+ System.out.println(" -s|--testsize=<n> - size of each test; default "
+ + DEFAULT_TEST_SIZE);
+ System.out.println(" -c|--noClipping - disable clipping test");
+ System.out.println(" -z|--noZeroClipping - disable clipping to zero test");
+ System.out.println("");
+ System.out.println("Additional options:");
+ System.out.println(" --with-gradients - enable gradients (not compatible with --texture)");
+ System.out.println(" --with-stroking - enable random stroking");
+ System.out.println(" --texture=<file> - enable texturing with this file (not compatible with --with-gradients)");
+ System.out.println(" --composite=<n|-1> - set alpha composite level; -1 for random; default 1.0 (no transparency)");
+ System.out.println(" --anti-alias=<on|off> - set anti-aliasing hint (not all implementations respect this); default off");
+ System.out.println(" --x-translate=<n> - set x-axis translation; default 0");
+ System.out.println(" --y-translate=<n> - set y-axis translation; default 0");
+ System.out.println(" --x-shear=<n> - set x-axis shear; default 0");
+ System.out.println(" --y-shear=<n> - set y-axis shear; default 0");
+ System.out.println(" --rotate=<n|-1> - set rotation (radians); -1 for random; default: 0 (none)");
+ System.out.println("");
+ System.out.println("Tests: arc");
+ System.out.println(" cubiccurve");
+ System.out.println(" ellipse");
+ // System.out.println(" generalpath");
+ System.out.println(" line");
+ System.out.println(" quadcurve");
+ System.out.println(" rectangle");
+ System.out.println(" roundrectangle");
+ System.out.println(" image");
+ System.exit(1);
+ }
+ else if ((args[i].startsWith("-i=") || args[i].startsWith("--iterations=")))
+ {
+ speed.iterations = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-i") || args[i].equals("--iterations")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.iterations = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].startsWith("-w=") || args[i].startsWith("--width=")))
+ {
+ speed.screenWidth = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-w") || args[i].equals("--width")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.screenWidth = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].startsWith("-h=") || args[i].startsWith("--height=")))
+ {
+ speed.screenHeight = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-h") || args[i].equals("--height")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.screenHeight = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].equals("-d") || args[i].equals("--noDoubleBuffer")))
+ {
+ speed.doubleBufferFlag = false;
+ i += 1;
+ continue;
+ }
+ else if ((args[i].startsWith("-s=") || args[i].startsWith("--testsize=")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.testSize = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-s") || args[i].equals("--testsize")))
+ {
+ if ((i + 1) >= args.length)
+ {
+ System.err.println("ERROR: No argument given for option '"
+ + args[i] + "'!");
+ System.exit(2);
+ }
+ speed.testSize = Integer.parseInt(args[i + 1]);
+ i += 2;
+ continue;
+ }
+ else if ((args[i].equals("-c") || args[i].equals("--noClipping")))
+ {
+ speed.noClippingFlag = false;
+ i += 1;
+ continue;
+ }
+ else if ((args[i].equals("-z") || args[i].equals("--noZeroClipping")))
+ {
+ speed.zeroClippingFlag = false;
+ i += 1;
+ continue;
+ }
+ else if (args[i].equals("--with-gradients"))
+ {
+ speed.gradientFlag = true;
+ i += 1;
+ continue;
+ }
+ else if (args[i].equals("--with-stroking"))
+ {
+ speed.strokeFlag = true;
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--texture="))
+ {
+ speed.texture = args[i].substring(args[i].indexOf('=') + 1);
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--composite="))
+ {
+ speed.composite = Float.parseFloat(args[i].substring(args[i].indexOf('=') + 1));
+ if (speed.composite != - 1
+ && (speed.composite < 0 || speed.composite > 1))
+ {
+ System.err.println("ERROR: Invalid value for composite (must be between 0 and 1, or -1 for random)");
+ System.exit(2);
+ }
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--anti-alias="))
+ {
+ speed.antialiasFlag = (args[i].substring(args[i].indexOf('=') + 1).equals("on"));
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--x-translate="))
+ {
+ speed.xtranslate = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--y-translate="))
+ {
+ speed.ytranslate = Integer.parseInt(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--x-shear="))
+ {
+ speed.xshear = Double.parseDouble(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--y-shear="))
+ {
+ speed.yshear = Double.parseDouble(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("--rotate="))
+ {
+ speed.rotate = Double.parseDouble(args[i].substring(args[i].indexOf('=') + 1));
+ i += 1;
+ continue;
+ }
+
+ else if (args[i].equals("--"))
+ {
+ endOfOptionsFlag = true;
+ i += 1;
+ continue;
+ }
+ else if (args[i].startsWith("-"))
+ {
+ System.err.println("ERROR: Unknown option '" + args[i] + "'!");
+ System.exit(2);
+ }
+ }
+ StringTokenizer tokenizer = new StringTokenizer(args[i], " +,");
+ while (tokenizer.hasMoreTokens())
+ {
+ String s = tokenizer.nextToken().toLowerCase();
+ if (s.equals("arc"))
+ awtTests |= J2DTEST_ARC;
+ else if (s.equals("cubiccurve"))
+ awtTests |= J2DTEST_CUBICCURVE;
+ else if (s.equals("ellipse"))
+ awtTests |= J2DTEST_ELLIPSE;
+ else if (s.equals("generalpath"))
+ awtTests |= J2DTEST_GENERALPATH;
+ else if (s.equals("line"))
+ awtTests |= J2DTEST_LINE;
+ else if (s.equals("quadcurve"))
+ awtTests |= J2DTEST_QUADCURVE;
+ else if (s.equals("rectangle"))
+ awtTests |= J2DTEST_RECTANGLE;
+ else if (s.equals("roundrectangle"))
+ awtTests |= J2DTEST_ROUNDRECTANGLE;
+ else if (s.equals("image"))
+ awtTests |= J2DTEST_IMAGE;
+ else
+ {
+ System.err.println("Unknown AWT test '" + s + "'!");
+ System.exit(2);
+ }
+ }
+ i += 1;
+ }
+ if (awtTests != J2DTEST_NONE)
+ speed.awtTests = awtTests;
+
+ // Create graphics.
+ speed.init();
+ final Frame frame = new Frame("J2dGraphicsBenchmark");
+
+ frame.addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ frame.setVisible(false);
+ System.exit(0);
+ }
+ });
+
+ frame.add(speed, BorderLayout.CENTER);
+ frame.setSize(speed.screenWidth, speed.screenHeight);
+ frame.setVisible(true);
+
+ // Insets are correctly set only after the native peer was created.
+ Insets insets = frame.getInsets();
+ // The internal size of the frame should be 320x240.
+ frame.setSize(320 + insets.right + insets.left, 240 + insets.top
+ + insets.bottom);
+ }
+
+ private Image loadImage(String imageName)
+ {
+ Image result = null;
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark", "loadImage",
+ "Loading image: " + imageName);
+ URL url = getClass().getResource(imageName);
+ if (url != null)
+ {
+ result = Toolkit.getDefaultToolkit().getImage(url);
+ prepareImage(result, this);
+ }
+ else
+ {
+ logger.logp(Level.WARNING, "J2dGraphicsBenchmark", "loadImage",
+ "Could not locate image resource in class path: "
+ + imageName);
+ }
+ return result;
+ }
+
+ private BufferedImage loadBufferedImage(String imageName)
+ {
+ BufferedImage result = null;
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark", "loadImage",
+ "Loading image: " + imageName);
+
+ // Try to load image out of classpath before trying an absolute filename
+ URL url = getClass().getResource(imageName);
+ Image img;
+ if (url != null)
+ img = Toolkit.getDefaultToolkit().getImage(url);
+ else
+ img = Toolkit.getDefaultToolkit().getImage(imageName);
+
+ if (img != null)
+ {
+ // Wait for image to load
+ try
+ {
+ MediaTracker tracker = new MediaTracker(this);
+ tracker.addImage(img, 1);
+ tracker.waitForAll();
+
+ prepareImage(img, this);
+ result = new BufferedImage(img.getWidth(this), img.getHeight(this),
+ BufferedImage.TYPE_INT_RGB);
+ result.createGraphics().drawImage(img, 0, 0, this);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ if (result == null)
+ {
+ logger.logp(Level.WARNING, "J2dGraphicsBenchmark", "loadBufferedImage",
+ "Could not locate image resource in class path: "
+ + imageName);
+ }
+ return result;
+ }
+
+ /**
+ * Executes the test methods.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ void runTestSet(Graphics2D g, Dimension size)
+ {
+ // Any user-specified options (ie set transforms, rendering hints)
+ prepareGraphics((Graphics2D) g);
+
+ if ((awtTests & J2DTEST_ARC) != 0)
+ {
+ test_drawArc(g, size);
+ test_fillArc(g, size);
+ }
+
+ if ((awtTests & J2DTEST_CUBICCURVE) != 0)
+ {
+ test_drawCubicCurve(g, size);
+ }
+
+ if ((awtTests & J2DTEST_ELLIPSE) != 0)
+ {
+ test_drawEllipse(g, size);
+ test_fillEllipse(g, size);
+ }
+
+ if ((awtTests & J2DTEST_GENERALPATH) != 0)
+ {
+ // Current implementation doesn't work
+ test_drawGeneralPath(g, size);
+ test_fillGeneralPath(g, size);
+ }
+
+ if ((awtTests & J2DTEST_LINE) != 0)
+ {
+ test_drawLine(g, size);
+ }
+
+ if ((awtTests & J2DTEST_QUADCURVE) != 0)
+ {
+ test_drawQuadCurve(g, size);
+ }
+
+ if ((awtTests & J2DTEST_RECTANGLE) != 0)
+ {
+ test_drawRectangle(g, size);
+ test_fillRectangle(g, size);
+ }
+
+ if ((awtTests & J2DTEST_ROUNDRECTANGLE) != 0)
+ {
+ test_drawRoundRectangle(g, size);
+ test_fillRoundRectangle(g, size);
+ }
+
+ if ((awtTests & J2DTEST_IMAGE) != 0)
+ {
+ test_drawImage(g, size);
+ test_drawTransparentImage(g, size);
+ }
+ }
+
+ /**
+ * Reset all graphics settings to the standard, default values
+ *
+ * @param g the object to apply settings to
+ */
+ private void resetGraphics(Graphics2D g)
+ {
+ g.setTransform(new AffineTransform());
+ g.setStroke(new BasicStroke());
+ g.setComposite(AlphaComposite.SrcOut);
+ }
+
+ /**
+ * Sets initial user graphics options
+ *
+ * @param g the object to apply settings to
+ */
+ private void prepareGraphics(Graphics2D g)
+ {
+ // Transforms
+ if (affineTransform != null)
+ g.setTransform(affineTransform);
+
+ else if (xtranslate != 0 || ytranslate != 0 || xshear != 0 || yshear != 0)
+ {
+ g.translate(xtranslate, ytranslate);
+ g.shear(xshear, yshear);
+ }
+
+ if (rotate > 0)
+ g.rotate(rotate * Math.PI, screenWidth / 2, screenHeight / 2);
+
+ // Composite (transparency)
+ if (composite > 0)
+ {
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+ composite));
+ }
+
+ // Textures
+ if (texture != null)
+ g.setPaint(new TexturePaint(textureImage,
+ new Rectangle(0, 0, textureImage.getWidth(),
+ textureImage.getHeight())));
+
+ // Anti-alias setting
+ if (antialiasFlag)
+ g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON));
+ else
+ g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_OFF));
+ }
+
+ /**
+ * Gets new random settings
+ *
+ * @param g the object to set parameters for
+ * @param size the screen size
+ */
+ private void setRandom(Graphics2D g, Dimension size)
+ {
+ // Set colour / paint
+ if (gradientFlag)
+ {
+ Color c1 = new Color((int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1);
+
+ Color c2 = new Color((int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1);
+
+ g.setPaint(new GradientPaint(0, 0, c1, screenWidth / 5,
+ screenHeight / 5, c2, true));
+ }
+
+ else if (texture == null)
+ g.setPaint(new Color((int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1,
+ (int) (Math.random() * 254) + 1));
+
+ // Set stroke width and options
+ if (strokeFlag)
+ {
+ int cap = (int) (Math.random() * 3 + 1);
+ if (cap == 1)
+ cap = BasicStroke.CAP_SQUARE;
+ else if (cap == 2)
+ cap = BasicStroke.CAP_BUTT;
+ else
+ cap = BasicStroke.CAP_ROUND;
+
+ int join = (int) (Math.random() * 3 + 1);
+ if (join == 1)
+ join = BasicStroke.JOIN_MITER;
+ else if (join == 2)
+ join = BasicStroke.JOIN_BEVEL;
+ else
+ join = BasicStroke.JOIN_ROUND;
+
+ float[] dashes = { 10, 10 };
+ g.setStroke(new BasicStroke((int) (Math.random() * 10), cap, join, 10f,
+ dashes, 0));
+ }
+
+ // Composite / transparency
+ if (composite == - 1)
+ {
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+ (float) Math.random()));
+ }
+
+ // Transformations
+ if (rotate == - 1)
+ g.rotate(Math.random() * Math.PI * 2);
+ }
+
+ /**
+ * Draws random arcs within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawArc(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int startAngle = (int) (Math.random() * 360);
+ int arcAngle = (int) (Math.random() * 360 - startAngle);
+
+ Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle,
+ Arc2D.OPEN);
+ g.draw(arc);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("draw(Arc2D.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random filled arcs within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillArc(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int startAngle = (int) (Math.random() * 360);
+ int arcAngle = (int) (Math.random() * 360);
+
+ Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle,
+ Arc2D.OPEN);
+ g.fill(arc);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("fill(Arc2D.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random cubic curves within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawCubicCurve(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int xc1 = (int) (Math.random() * (size.width - minSize));
+ int yc1 = (int) (Math.random() * (size.height - minSize));
+ int xc2 = (int) (Math.random() * (size.width - minSize));
+ int yc2 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+
+ CubicCurve2D curve = new CubicCurve2D.Double(x1, y1, xc1, yc1, xc2,
+ yc2, x2, y2);
+ g.draw(curve);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(CubicCurve2D.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random ellipses within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawEllipse(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+ Ellipse2D ellipse = new Ellipse2D.Double(x1, y1, x2, y2);
+ g.draw(ellipse);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(Ellipse.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random ellipses within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillEllipse(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+ Ellipse2D ellipse = new Ellipse2D.Double(x1, y1, x2, y2);
+ g.fill(ellipse);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("fill(Ellipse.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ // TODO: fix the GeneralPath methods.
+ /**
+ * Draws random polygons within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawGeneralPath(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ long startTime = System.currentTimeMillis();
+
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int points = (int) (Math.random() * 6) + 2;
+ GeneralPath shape = new GeneralPath();
+ shape.moveTo((float) Math.random() * (size.width),
+ (float) Math.random() * (size.height));
+ for (int j = 0; j < points; j += 1)
+ {
+ shape.lineTo((float) (Math.random() * (size.width)),
+ (float) (Math.random() * (size.height)));
+ }
+ g.draw(shape);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(GeneralPath) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random filled polygons within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillGeneralPath(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ long startTime = System.currentTimeMillis();
+
+ GeneralPath shape = new GeneralPath();
+ shape.moveTo((float) Math.random() * (size.width), (float) Math.random()
+ * (size.height));
+
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int points = (int) (Math.random() * 6) + 2;
+ for (int j = 0; j < points; j += 1)
+ {
+ shape.lineTo((float) (Math.random() * (size.width)),
+ (float) (Math.random() * (size.height)));
+ }
+ g.fill(shape);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("fill(GeneralPath) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random lines within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawLine(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+ Line2D line = new Line2D.Double(x1, y1, x2, y2);
+ g.draw(line);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(Line2D.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random quadratic curves within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawQuadCurve(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int xc = (int) (Math.random() * (size.width - minSize));
+ int yc = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+
+ QuadCurve2D curve = new QuadCurve2D.Double(x1, y1, xc, yc, x2, y2);
+ g.draw(curve);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(QuadCurve2D.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random rectangles within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawRectangle(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+ Rectangle2D rect = new Rectangle2D.Double(x1, y1, x2, y2);
+ g.draw(rect);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw(Rectangle.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random rectangles within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillRectangle(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize = 10;
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x1 = (int) (Math.random() * (size.width - minSize));
+ int y1 = (int) (Math.random() * (size.height - minSize));
+ int x2 = (int) (Math.random() * (size.width - minSize));
+ int y2 = (int) (Math.random() * (size.height - minSize));
+ Rectangle2D rect = new Rectangle2D.Double(x1, y1, x2, y2);
+ g.fill(rect);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("fill(Rectangle.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random rounded rectangles within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawRoundRectangle(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int arcWidth = (int) (Math.random() * (width - 1) + 1);
+ int arcHeight = (int) (Math.random() * (height - 1) + 5);
+ RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width,
+ height, arcWidth,
+ arcHeight);
+ g.draw(rect);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("draw(RoundRectangle.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random filled rounded rectangles within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_fillRoundRectangle(Graphics2D g, Dimension size)
+ {
+ int maxTests = testSize;
+ int minSize;
+ long startTime;
+ long endTime;
+ minSize = 10;
+ startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - minSize + 1));
+ int y = (int) (Math.random() * (size.height - minSize + 1));
+ int width = (int) (Math.random() * (size.width - x - minSize) + minSize);
+ int height = (int) (Math.random() * (size.height - y - minSize) + minSize);
+ int arcWidth = (int) (Math.random() * (width - 1) + 1);
+ int arcHeight = (int) (Math.random() * (height - 1) + 5);
+ RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width,
+ height, arcWidth,
+ arcHeight);
+ g.fill(rect);
+ }
+ endTime = System.currentTimeMillis();
+ recordTest("fill(RoundRectangle.Double) " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ /**
+ * Draws random images within the given dimensions.
+ *
+ * @param g The Graphics2D object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawImage(Graphics2D g, Dimension size)
+ {
+ if (gifTestImage == null)
+ {
+ logger.logp(Level.WARNING, "J2dGraphicsBenchmark", "runTestSet",
+ "Skipping 'test_drawImage' due to missing resource.");
+ return;
+ }
+
+ int maxTests = testSize / 2;
+ if (maxTests == 0)
+ maxTests = 1;
+ int imageWidth = gifTestImage.getWidth(this);
+ int imageHeight = gifTestImage.getHeight(this);
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - imageWidth + 1));
+ int y = (int) (Math.random() * (size.height - imageHeight + 1));
+ g.drawImage(gifTestImage, x, y, this);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("drawImage " + maxTests + " times", (endTime - startTime));
+ }
+
+ /**
+ * Draws random transparent images within the given dimensions.
+ *
+ * @param g The Graphics object that is used to paint.
+ * @param size The size of the canvas.
+ */
+ private void test_drawTransparentImage(Graphics2D g, Dimension size)
+ {
+ if (pngTestImage == null)
+ {
+ logger.logp(Level.WARNING, "AicasGraphicsBenchmark", "runTestSet",
+ "Skipping 'drawTransparentImage' due to missing resource.");
+ return;
+ }
+
+ int maxTests = testSize / 5;
+ if (maxTests == 0)
+ maxTests = 1;
+ int imageWidth = pngTestImage.getWidth(this);
+ int imageHeight = pngTestImage.getHeight(this);
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < maxTests; i += 1)
+ {
+ setRandom(g, size);
+ int x = (int) (Math.random() * (size.width - imageWidth + 1));
+ int y = (int) (Math.random() * (size.height - imageHeight + 1));
+ g.drawImage(pngTestImage, x, y, this);
+ }
+ long endTime = System.currentTimeMillis();
+ recordTest("draw transparent image " + maxTests + " times",
+ (endTime - startTime));
+ }
+
+ private class GraphicsTest
+ extends Canvas
+ implements Runnable
+ {
+ Thread paintThread;
+
+ boolean done = false;
+
+ boolean doPaint = false;
+
+ boolean withClipping = false;
+
+ public GraphicsTest()
+ {
+ paintThread = new Thread(this);
+ paintThread.start();
+ }
+
+ public void run()
+ {
+ int runCount = 0;
+ while (! done)
+ {
+ runCount++;
+
+ try
+ {
+ synchronized (this)
+ {
+ while (! doPaint)
+ {
+ try
+ {
+ wait(200);
+ }
+ catch (InterruptedException exception)
+ {
+ return;
+ }
+ }
+ }
+
+ // if (iterations != 0)
+ // System.out.println("--- run...("
+ // + runCount
+ // + "/"
+ // + iterations
+ // + ") ------------------------------------------------------");
+
+ Graphics g = getGraphics();
+ Dimension size = getSize();
+
+ if (singleBufferFlag)
+ {
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark.GraphicsTest",
+ "run",
+ "Start testing non-double-buffered drawing");
+
+ if (noClippingFlag)
+ runSet_noClipping((Graphics2D) g, size, runCount);
+
+ if (withClippingFlag)
+ runSet_withClipping((Graphics2D) g, size, runCount);
+
+ if (zeroClippingFlag)
+ runSet_zeroClipping((Graphics2D) g, size, runCount);
+
+ g.dispose();
+ }
+
+ if (doubleBufferFlag)
+ {
+ logger.logp(Level.INFO, "J2dGraphicsBenchmark.GraphicsTest",
+ "run", "Start testing double-buffered drawing");
+ Graphics canvas = getGraphics();
+ Image doublebuffer = createImage(size.width, size.height);
+
+ if (noClippingFlag)
+ {
+ g = doublebuffer.getGraphics();
+ runSet_noClipping((Graphics2D) g, size,
+ "double buffering", runCount);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+ }
+
+ if (withClippingFlag)
+ {
+ g = doublebuffer.getGraphics();
+ runSet_withClipping((Graphics2D) g, size,
+ "double buffering", runCount);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+ }
+
+ if (zeroClippingFlag)
+ {
+ g = doublebuffer.getGraphics();
+ runSet_zeroClipping((Graphics2D) g, size,
+ "double buffering", runCount);
+ g.dispose();
+ canvas.drawImage(doublebuffer, 0, 0, this);
+ canvas.dispose();
+ }
+ }
+
+ printReport();
+
+ if (iterations != 1)
+ {
+ if (iterations != - 1)
+ iterations--;
+ }
+ else
+ {
+ // System.out.println("--- done
+ // --------------------------------------------------------");
+ synchronized (this)
+ {
+ doPaint = false;
+ }
+ done = true;
+ }
+ }
+ catch (Error error)
+ {
+ System.err.println("Error: " + error);
+ System.exit(129);
+ }
+ }
+ testComplete();
+ }
+
+ private void runSet_zeroClipping(Graphics2D g, Dimension size, int runCount)
+ {
+ runSet_zeroClipping(g, size, "", runCount);
+ }
+
+ private void runSet_zeroClipping(Graphics2D g, Dimension size,
+ String context, int runCount)
+ {
+ int clipped_width;
+ int clipped_height;
+ int clipped_x;
+ int clipped_y;
+
+ clipped_width = 0;
+ clipped_height = 0;
+ clipped_x = (size.width) / 2;
+ clipped_y = (size.height) / 2;
+
+ // Reset any transforms from past tests
+ resetGraphics(g);
+
+ Rectangle fullWindow = new Rectangle(0, 0, size.width, size.height);
+ g.setClip(fullWindow);
+ g.setPaint(Color.BLACK);
+ g.fill(fullWindow);
+
+ Rectangle windowBorder = new Rectangle(0, 0, size.width - 1,
+ size.width - 1);
+ g.setPaint(Color.WHITE);
+ g.draw(windowBorder);
+
+ Rectangle innerBorder = new Rectangle(clipped_x - 1, clipped_y - 1,
+ clipped_width + 2,
+ clipped_height + 2);
+ g.fill(innerBorder);
+
+ Rectangle innerBox = new Rectangle(clipped_x, clipped_y, clipped_width,
+ clipped_height);
+ g.clip(innerBox);
+ g.setPaint(Color.BLACK);
+ g.fill(fullWindow);
+
+ if (context.equals(""))
+ setTestContext("(" + runCount + ") clipping to zero");
+ else
+ setTestContext("(" + runCount + ") clipping to zero (" + context + ")");
+
+ runTestSet(g, size);
+ }
+
+ private void runSet_withClipping(Graphics2D g, Dimension size, int runCount)
+ {
+ runSet_withClipping(g, size, "", runCount);
+ }
+
+ private void runSet_withClipping(Graphics2D g, Dimension size,
+ String context, int runCount)
+ {
+ int clipped_width = 2 * size.width / 3;
+ int clipped_height = 2 * size.height / 3;
+ int clipped_x = (size.width - clipped_width) / 2;
+ int clipped_y = (size.height - clipped_height) / 2;
+
+ // Reset any transforms from past tests
+ resetGraphics(g);
+
+ Rectangle fullWindow = new Rectangle(0, 0, size.width, size.height);
+ g.setClip(fullWindow);
+
+ g.setPaint(Color.BLACK);
+ g.fill(fullWindow);
+
+ Rectangle windowBorder = new Rectangle(0, 0, size.width - 1,
+ size.height - 1);
+ g.setPaint(Color.GREEN);
+ g.draw(windowBorder);
+
+ Rectangle innerBorder = new Rectangle(clipped_x - 1, clipped_y - 1,
+ clipped_width + 2,
+ clipped_height + 2);
+ g.setPaint(Color.WHITE);
+ g.fill(innerBorder);
+
+ Rectangle innerBox = new Rectangle(clipped_x, clipped_y, clipped_width,
+ clipped_height);
+ g.clip(innerBox);
+
+ g.setPaint(Color.BLACK);
+ g.fill(fullWindow);
+
+ if (context.equals(""))
+ setTestContext("(" + runCount + ") with clipping ");
+ else
+ setTestContext("(" + runCount + ") with clipping (" + context + ")");
+
+ runTestSet(g, size);
+ }
+
+ private void runSet_noClipping(Graphics2D g, Dimension size, int runCount)
+ {
+ runSet_noClipping(g, size, "", runCount);
+ }
+
+ private void runSet_noClipping(Graphics2D g, Dimension size,
+ String context, int runCount)
+ {
+ // Reset any transforms from past tests
+ resetGraphics(g);
+
+ Rectangle fullWindow = new Rectangle(0, 0, size.width, size.height);
+ g.setPaint(Color.BLACK);
+ g.fill(fullWindow);
+
+ if (context.equals(""))
+ setTestContext("(" + runCount + ") without clipping");
+ else
+ setTestContext("(" + runCount + ") without clipping (" + context + ")");
+
+ runTestSet(g, size);
+ }
+
+ public void paint(Graphics g)
+ {
+ synchronized (this)
+ {
+ doPaint = true;
+ notify();
+ }
+ }
+ }
+}
+
+class TestContext
+{
+}
+
+class TestSet
+{
+ private Map testsMap = new TreeMap();
+
+ public void putTest(String testName, TestRecorder recoder)
+ {
+ testsMap.put(testName, recoder);
+ }
+
+ public TestRecorder getTest(String testName)
+ {
+ return (TestRecorder) testsMap.get(testName);
+ }
+
+ public Iterator testIterator()
+ {
+ return testsMap.keySet().iterator();
+ }
+}
+
+class TestRecorder
+{
+ String test;
+
+ long totalTime = 0;
+
+ long minTime = Long.MAX_VALUE;
+
+ long maxTime = Long.MIN_VALUE;
+
+ int runCount = 0;
+
+ /**
+ * @return Returns the maxTime.
+ */
+ public final long getMaxTime()
+ {
+ return maxTime;
+ }
+
+ /**
+ * @return Returns the minTime.
+ */
+ public final long getMinTime()
+ {
+ return minTime;
+ }
+
+ /**
+ * @return Returns the test name.
+ */
+ public final String getTestName()
+ {
+ return test;
+ }
+
+ public final long getAverage()
+ {
+ return (totalTime / runCount);
+ }
+
+ public TestRecorder(String testName)
+ {
+ test = testName;
+ }
+
+ public void addRun(long time)
+ {
+ totalTime += time;
+ if (minTime > time)
+ minTime = time;
+ if (maxTime < time)
+ maxTime = time;
+ runCount += 1;
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java
new file mode 100644
index 00000000000..bb583cbdcd2
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmarkGUI.java
@@ -0,0 +1,891 @@
+/* J2dBenchmarkGUI.java -- GUI for java2d benchmarker
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+package gnu.classpath.examples.java2d;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.border.BevelBorder;
+
+/**
+ * Extends the J2dBenchmark to provide a GUI for selecting options and tests.
+ */
+public class J2dBenchmarkGUI
+ implements ActionListener
+{
+
+ JLabel errorLabel;
+
+ JCheckBox noClipping;
+
+ JCheckBox withClipping;
+
+ JCheckBox zeroClipping;
+
+ JCheckBox singleBuffer;
+
+ JCheckBox doubleBuffer;
+
+ public J2dBenchmarkGUI()
+ {
+ super();
+ }
+
+ public static void main(String[] args)
+ {
+ new J2dBenchmarkGUI().run();
+ }
+
+ /**
+ * Sets up the initial GUI
+ */
+ public void run()
+ {
+ // Store all elements in a hashtable so that they can be passed into the
+ // harness easily.
+ Hashtable elements = new Hashtable();
+
+ // Set up frame
+ final JFrame frame = new JFrame("Java2D benchmark");
+ errorLabel = new JLabel(" ");
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
+ Container content = frame.getContentPane();
+
+ // Display options for dimensions, iterations, test size, etc
+ JPanel options = new JPanel(new GridLayout(0, 2));
+
+ options.add(new JLabel("Height: "));
+ JTextField heightField = new JTextField(Integer.toString(J2dBenchmark.DEFAULT_SCREEN_HEIGHT));
+ heightField.setColumns(5);
+ options.add(heightField);
+ elements.put("height", heightField);
+
+ options.add(new JLabel("Width: "));
+ JTextField widthField = new JTextField(Integer.toString(J2dBenchmark.DEFAULT_SCREEN_WIDTH));
+ widthField.setColumns(5);
+ options.add(widthField);
+ elements.put("width", widthField);
+
+ options.add(new JLabel("Iterations: "));
+ JTextField iterField = new JTextField("1");
+ iterField.setColumns(5);
+ options.add(iterField);
+ elements.put("iterations", iterField);
+
+ options.add(new JLabel("Test size: "));
+ JTextField testSizeField = new JTextField(Integer.toString(J2dBenchmark.DEFAULT_TEST_SIZE));
+ testSizeField.setColumns(5);
+ options.add(testSizeField);
+ elements.put("size", testSizeField);
+
+ options.add(new JLabel("Test without clipping: "));
+ noClipping = new JCheckBox("", true);
+ noClipping.addActionListener(this);
+ options.add(noClipping);
+ elements.put("noclip", noClipping);
+
+ options.add(new JLabel("Test with clipping: "));
+ withClipping = new JCheckBox("", true);
+ withClipping.addActionListener(this);
+ options.add(withClipping);
+ elements.put("withclip", withClipping);
+
+ options.add(new JLabel("Test with clipping to zero: "));
+ zeroClipping = new JCheckBox("", true);
+ zeroClipping.addActionListener(this);
+ options.add(zeroClipping);
+ elements.put("zeroclip", zeroClipping);
+
+ options.add(new JLabel("Run single-buffer test: "));
+ singleBuffer = new JCheckBox("", true);
+ singleBuffer.addActionListener(this);
+ options.add(singleBuffer);
+ elements.put("singlebuffer", singleBuffer);
+
+ options.add(new JLabel("Run double-buffer test: "));
+ doubleBuffer = new JCheckBox("", true);
+ doubleBuffer.addActionListener(this);
+ options.add(doubleBuffer);
+ elements.put("doublebuffer", doubleBuffer);
+
+ // Allow user to select tests to run
+ JPanel tests = new JPanel();
+ tests.setLayout(new BoxLayout(tests, BoxLayout.PAGE_AXIS));
+ tests.setBorder(new BevelBorder(BevelBorder.RAISED));
+ tests.add(new JLabel("Shapes to test:"));
+
+ JCheckBox test_arcDraw = new JCheckBox("Arc", true);
+ tests.add(test_arcDraw);
+ elements.put("test_arcDraw", test_arcDraw);
+
+ JCheckBox test_ccurveDraw = new JCheckBox("Cubic Curve", true);
+ tests.add(test_ccurveDraw);
+ elements.put("test_ccurveDraw", test_ccurveDraw);
+
+ JCheckBox test_ellipseDraw = new JCheckBox("Ellipse", true);
+ tests.add(test_ellipseDraw);
+ elements.put("test_ellipseDraw", test_ellipseDraw);
+
+ /*
+ JCheckBox test_pathDraw = new JCheckBox("General Path", true);
+ tests.add(test_pathDraw);
+ elements.put("test_pathDraw", test_pathDraw);
+ */
+
+ JCheckBox test_lineDraw = new JCheckBox("Line", true);
+ tests.add(test_lineDraw);
+ elements.put("test_lineDraw", test_lineDraw);
+
+ JCheckBox test_qcurveDraw = new JCheckBox("Quadratic Curve", true);
+ tests.add(test_qcurveDraw);
+ elements.put("test_qcurveDraw", test_qcurveDraw);
+
+ JCheckBox test_rectDraw = new JCheckBox("Rectangle", true);
+ tests.add(test_rectDraw);
+ elements.put("test_rectDraw", test_rectDraw);
+
+ JCheckBox test_rrectDraw = new JCheckBox("Round Rectangle", true);
+ tests.add(test_rrectDraw);
+ elements.put("test_rrectDraw", test_rrectDraw);
+
+ JCheckBox test_image = new JCheckBox("Images", true);
+ tests.add(test_image);
+ elements.put("test_image", test_image);
+
+ // Additional image-processing options
+ JPanel extras = new JPanel();
+ extras.setBorder(new BevelBorder(BevelBorder.LOWERED));
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.insets = new Insets(5, 2, 15, 15);
+ extras.setLayout(layout);
+
+ // Filling (solid, gradient, or texture)
+ JPanel opt_Fill = new JPanel();
+ opt_Fill.setLayout(new BoxLayout(opt_Fill, BoxLayout.PAGE_AXIS));
+ JLabel opt_FillLabel = new JLabel("Filling:");
+ opt_FillLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
+ opt_Fill.add(opt_FillLabel);
+
+ ButtonGroup opt_FillGroup = new ButtonGroup();
+ JRadioButton opt_FillSolid = new JRadioButton("Solid colour", true);
+ opt_FillSolid.setActionCommand("solid");
+ opt_Fill.add(opt_FillSolid);
+ opt_FillGroup.add(opt_FillSolid);
+ JRadioButton opt_FillGradient = new JRadioButton("Gradient", false);
+ opt_FillGradient.setActionCommand("gradient");
+ opt_Fill.add(opt_FillGradient);
+ opt_FillGroup.add(opt_FillGradient);
+ JRadioButton opt_FillTexture = new JRadioButton("Texture", false);
+ opt_FillTexture.setActionCommand("texture");
+ opt_Fill.add(opt_FillTexture);
+ opt_FillGroup.add(opt_FillTexture);
+ JTextField opt_FillTextureFile = new JTextField("texture file");
+ opt_FillTextureFile.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ opt_Fill.add(opt_FillTextureFile);
+ elements.put("opt_FillGroup", opt_FillGroup);
+ elements.put("opt_FillTextureFile", opt_FillTextureFile);
+ layout.setConstraints(opt_Fill, gbc);
+ extras.add(opt_Fill);
+
+ // Stroke
+ JPanel opt_Stroke = new JPanel();
+ opt_Stroke.setLayout(new BoxLayout(opt_Stroke, BoxLayout.PAGE_AXIS));
+ JLabel opt_StrokeLabel = new JLabel("Stroke:");
+ opt_StrokeLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
+ opt_Stroke.add(opt_StrokeLabel);
+ JCheckBox opt_StrokeRandom = new JCheckBox("random", false);
+ elements.put("opt_StrokeRandom", opt_StrokeRandom);
+ opt_Stroke.add(opt_StrokeRandom);
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ layout.setConstraints(opt_Stroke, gbc);
+ extras.add(opt_Stroke);
+
+ // Anti-Alias
+ JPanel opt_Alias = new JPanel();
+ opt_Alias.setLayout(new BoxLayout(opt_Alias, BoxLayout.PAGE_AXIS));
+ JLabel opt_AliasLabel = new JLabel("Anti-Aliasing:");
+ opt_AliasLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
+ opt_Alias.add(opt_AliasLabel);
+ JCheckBox opt_AliasOn = new JCheckBox("on", false);
+ elements.put("opt_AliasOn", opt_AliasOn);
+ opt_Alias.add(opt_AliasOn);
+ gbc.gridwidth = 1;
+ layout.setConstraints(opt_Alias, gbc);
+ extras.add(opt_Alias);
+
+ // Alpha composite
+ JPanel opt_Composite = new JPanel();
+ opt_Composite.setLayout(new BoxLayout(opt_Composite, BoxLayout.PAGE_AXIS));
+ JLabel opt_CompositeLabel = new JLabel("Alpha Composite:");
+ opt_CompositeLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
+ opt_Composite.add(opt_CompositeLabel);
+ JTextField opt_CompositeValue = new JTextField("1.0");
+ opt_CompositeValue.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ elements.put("opt_CompositeValue", opt_CompositeValue);
+ opt_Composite.add(opt_CompositeValue);
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ layout.setConstraints(opt_Composite, gbc);
+ extras.add(opt_Composite);
+
+ // Transformations
+ // TODO: allow user-defined matrices for AffineTransform
+ // (backend already has hooks for it, need to create gui)
+ JLabel opt_TransformLabel = new JLabel("Transformations:");
+ opt_TransformLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
+ gbc.insets = new Insets(5, 2, 0, 15);
+ layout.setConstraints(opt_TransformLabel, gbc);
+ extras.add(opt_TransformLabel);
+
+ JPanel opt_Transform_Translate = new JPanel(new GridLayout(0, 2, 5, 5));
+ opt_Transform_Translate.add(new JLabel("x-axis translation "));
+ JTextField opt_TransformTranslateX = new JTextField("0");
+ opt_TransformTranslateX.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ opt_Transform_Translate.add(opt_TransformTranslateX);
+ elements.put("opt_TransformTranslateX", opt_TransformTranslateX);
+ opt_Transform_Translate.add(new JLabel("y-axis translation "));
+ JTextField opt_TransformTranslateY = new JTextField("0");
+ opt_TransformTranslateY.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ opt_Transform_Translate.add(opt_TransformTranslateY);
+ elements.put("opt_TransformTranslateY", opt_TransformTranslateY);
+ gbc.gridwidth = 1;
+ gbc.insets = new Insets(0, 2, 5, 15);
+ layout.setConstraints(opt_Transform_Translate, gbc);
+ extras.add(opt_Transform_Translate);
+
+ JPanel opt_Transform_Shear = new JPanel(new GridLayout(0, 2, 5, 5));
+ opt_Transform_Shear.add(new JLabel("x-axis shear "));
+ JTextField opt_TransformShearX = new JTextField("0");
+ opt_TransformShearX.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ opt_Transform_Shear.add(opt_TransformShearX);
+ elements.put("opt_TransformShearX", opt_TransformShearX);
+ opt_Transform_Shear.add(new JLabel("y-axis shear "));
+ JTextField opt_TransformShearY = new JTextField("0");
+ opt_Transform_Shear.add(opt_TransformShearY);
+ elements.put("opt_TransformShearY", opt_TransformShearY);
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ layout.setConstraints(opt_Transform_Shear, gbc);
+ extras.add(opt_Transform_Shear);
+
+ JPanel opt_Transform_Rotate = new JPanel(new GridLayout(0, 2, 5, 5));
+ opt_Transform_Rotate.add(new JLabel("rotation (radians) "));
+ JTextField opt_TransformRotate = new JTextField("0");
+ opt_Transform_Rotate.add(opt_TransformRotate);
+ elements.put("opt_TransformRotate", opt_TransformRotate);
+ layout.setConstraints(opt_Transform_Rotate, gbc);
+ extras.add(opt_Transform_Rotate);
+
+ // Final submit button
+ JPanel submit = new JPanel();
+ submit.setLayout(new BoxLayout(submit, BoxLayout.PAGE_AXIS));
+
+ JButton rectButton = new JButton("Run benchmark");
+ rectButton.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ submit.add(rectButton, BorderLayout.CENTER);
+
+ errorLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ errorLabel.setForeground(Color.RED);
+ submit.add(errorLabel);
+
+ rectButton.addActionListener(new Harness(elements, errorLabel));
+
+ // Lay it all out
+ JPanel body = new JPanel();
+ body.setLayout(new BoxLayout(body, BoxLayout.LINE_AXIS));
+ options.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ body.add(options);
+ body.add(Box.createHorizontalStrut(50));
+ tests.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
+ body.add(tests);
+
+ body.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ panel.add(body);
+ extras.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ panel.add(extras);
+ submit.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ panel.add(submit);
+
+ content.add(panel, BorderLayout.CENTER);
+
+ // Leave some breathing space in the frame
+ frame.pack();
+
+ frame.addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ frame.setVisible(false);
+ System.exit(0);
+ }
+ });
+
+ frame.show();
+ }
+
+ /**
+ * Handles user events on the options GUI, ensuring that user input is valid
+ */
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (! noClipping.isSelected() && ! withClipping.isSelected()
+ && ! zeroClipping.isSelected())
+ errorLabel.setText("You must select at least one clipping option");
+
+ else if (! singleBuffer.isSelected() && ! doubleBuffer.isSelected())
+ errorLabel.setText("You must select at least one buffering option");
+
+ else
+ errorLabel.setText(" ");
+ }
+
+ /**
+ * Parses GUI input and sets options in the benchmarker
+ */
+ private class Harness
+ implements ActionListener
+ {
+ Hashtable elements;
+
+ JLabel errorLabel;
+
+ /**
+ * Creates a new Harness object
+ *
+ * @param elements Hashtable containing the swing elements from the GUI
+ * @param errorLabel JLabel on which to display any error messages
+ */
+ public Harness(Hashtable elements, JLabel errorLabel)
+ {
+ super();
+
+ this.elements = elements;
+ this.errorLabel = errorLabel;
+ }
+
+ /**
+ * Handles user button-clicks, parsing the form, setting options, and
+ * starting the J2dBenchmark
+ *
+ * @param ae event that triggered this action
+ */
+ public void actionPerformed(ActionEvent ae)
+ {
+ try
+ {
+ // Create benchmarker object
+ final JFrame frame = new JFrame("Java2D benchmark");
+ J2dBenchmarkWrapper speed = new J2dBenchmarkWrapper(frame);
+
+ // Set options
+ speed.setDimensions(Integer.parseInt(((JTextField) elements.get("width")).getText()),
+ Integer.parseInt(((JTextField) elements.get("height")).getText()));
+
+ speed.setIterations(Integer.parseInt(((JTextField) elements.get("iterations")).getText()));
+ speed.setTestSize(Integer.parseInt(((JTextField) elements.get("size")).getText()));
+
+ speed.setClipping(((JCheckBox) elements.get("noclip")).isSelected(),
+ ((JCheckBox) elements.get("withclip")).isSelected(),
+ ((JCheckBox) elements.get("zeroclip")).isSelected());
+
+ speed.setBuffers(((JCheckBox) elements.get("singlebuffer")).isSelected(),
+ ((JCheckBox) elements.get("doublebuffer")).isSelected());
+
+ // Set additional processing options
+ speed.setFill(((ButtonGroup) elements.get("opt_FillGroup")).getSelection().getActionCommand(),
+ ((JTextField) elements.get("opt_FillTextureFile")).getText());
+
+ speed.setStroke(((JCheckBox) elements.get("opt_StrokeRandom")).isSelected());
+
+ speed.setAlias(((JCheckBox) elements.get("opt_AliasOn")).isSelected());
+
+ speed.setComposite(Float.parseFloat(((JTextField) elements.get("opt_CompositeValue")).getText()));
+
+ speed.setTranslation(Integer.parseInt(((JTextField) elements.get("opt_TransformTranslateX")).getText()),
+ Integer.parseInt(((JTextField) elements.get("opt_TransformTranslateY")).getText()));
+
+ speed.setRotation(Double.parseDouble(((JTextField) elements.get("opt_TransformRotate")).getText()));
+
+ speed.setShear(Double.parseDouble(((JTextField) elements.get("opt_TransformShearX")).getText()),
+ Double.parseDouble(((JTextField) elements.get("opt_TransformShearY")).getText()));
+
+ // Set tests
+ int testSuite = 0;
+ if (((JCheckBox) elements.get("test_arcDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_ARC;
+ if (((JCheckBox) elements.get("test_ccurveDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_CUBICCURVE;
+ if (((JCheckBox) elements.get("test_ellipseDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_ELLIPSE;
+ //if (((JCheckBox)elements.get("test_pathDraw")).isSelected())
+ // testSuite |= J2dBenchmarkWrapper.J2DTEST_GENERALPATH;
+ if (((JCheckBox) elements.get("test_lineDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_LINE;
+ if (((JCheckBox) elements.get("test_qcurveDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_QUADCURVE;
+ if (((JCheckBox) elements.get("test_rectDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_RECTANGLE;
+ if (((JCheckBox) elements.get("test_rrectDraw")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_ROUNDRECTANGLE;
+ if (((JCheckBox) elements.get("test_image")).isSelected())
+ testSuite |= J2dBenchmarkWrapper.J2DTEST_IMAGE;
+
+ if (testSuite != 0)
+ {
+ speed.setTests(testSuite);
+
+ String initResult = speed.init();
+
+ if (initResult == null)
+ {
+ // Create graphics.
+ frame.add(speed, BorderLayout.CENTER);
+ frame.setSize(
+ Integer.parseInt(((JTextField) elements.get("width")).getText()),
+ Integer.parseInt(((JTextField) elements.get("height")).getText()));
+ frame.setVisible(true);
+
+ // Insets are correctly set only after the native peer was
+ // created.
+ Insets insets = frame.getInsets();
+ frame.setSize(frame.getWidth() + insets.right + insets.left,
+ frame.getHeight() + insets.top + insets.bottom);
+
+ // Clear any old error messages
+ errorLabel.setText(" ");
+ }
+ else
+ errorLabel.setText(initResult);
+ }
+ else
+ errorLabel.setText("Please select at least one test.");
+ }
+ catch (NumberFormatException e)
+ {
+ errorLabel.setText("Please enter valid integers");
+ }
+ }
+ }
+
+ /**
+ * Wrapper for the J2dBenchmark, which outputs the results to a GUI
+ * instead of the command-line
+ */
+ private class J2dBenchmarkWrapper
+ extends J2dBenchmark
+ {
+ JFrame myFrame;
+
+ ResultsDisplay display;
+
+ /**
+ * Create new J2dBenchmarkWrapper object
+ *
+ * @param frame parent frame
+ */
+ public J2dBenchmarkWrapper(JFrame frame)
+ {
+ // Redirect log messages to the custom handler
+ logger.setUseParentHandlers(false);
+ display = new ResultsDisplay();
+ display.setLevel(Level.INFO);
+ logger.addHandler(display);
+
+ myFrame = frame;
+ }
+
+ /**
+ * Set dimensions of benchmarking canvas
+ *
+ * @param width width of canvas
+ * @param height height of canvas
+ */
+ public void setDimensions(int width, int height)
+ {
+ screenHeight = height;
+ screenWidth = width;
+ setSize(width, height);
+ }
+
+ /**
+ * Set number of iterations
+ *
+ * @param it number of iterations
+ */
+ public void setIterations(int it)
+ {
+ iterations = it;
+ }
+
+ /**
+ * Set size of each test
+ *
+ * @param size size of test
+ */
+ public void setTestSize(int size)
+ {
+ testSize = size;
+ }
+
+ /**
+ * Set clipping options
+ *
+ * @param no run test with no clipping
+ * @param with run test with clipping
+ * @param zero run test with clipping to zero
+ */
+ public void setClipping(boolean no, boolean with, boolean zero)
+ {
+ this.noClippingFlag = no;
+ this.withClippingFlag = with;
+ this.zeroClippingFlag = zero;
+ }
+
+ /**
+ * Set buffering options
+ *
+ * @param single run test without double-buffering
+ * @param doubleb run test with double-buffering
+ */
+ public void setBuffers(boolean single, boolean doubleb)
+ {
+ this.singleBufferFlag = single;
+ this.doubleBufferFlag = doubleb;
+ }
+
+ /**
+ * Set fill options
+ *
+ * @param type fill type: "solid", "gradient", or "texture"
+ * @param file filename to use if texturing
+ */
+ public void setFill(String type, String file)
+ {
+ if (type.equals("gradient"))
+ this.gradientFlag = true;
+ else if (type.equals("texture"))
+ {
+ this.texture = file;
+ }
+ }
+
+ /**
+ * Set stroke options
+ *
+ * @param stroke boolean flag to use random stroking or not
+ */
+ public void setStroke(boolean stroke)
+ {
+ this.strokeFlag = stroke;
+ }
+
+ /**
+ * Set anti-aliasing options
+ *
+ * @param alias boolean flag to use anti-aliasing or not
+ */
+ public void setAlias(boolean alias)
+ {
+ this.antialiasFlag = alias;
+ }
+
+ /**
+ * Set alpha composite
+ *
+ * @param alpha alpha composite
+ */
+ public void setComposite(float alpha)
+ {
+ this.composite = alpha;
+ }
+
+ /**
+ * Set translation values
+ *
+ * @param x x-axis translation
+ * @param y y-axis translation
+ */
+ public void setTranslation(int x, int y)
+ {
+ this.xtranslate = x;
+ this.ytranslate = y;
+ }
+
+ /**
+ * Set rotation
+ *
+ * @param theta angle to rotate by (radians)
+ */
+ public void setRotation(double theta)
+ {
+ this.rotate = theta;
+ }
+
+ /**
+ * Set shear values
+ *
+ * @param x x-axis shear value
+ * @param y-axis shear value
+ */
+ public void setShear(double x, double y)
+ {
+ this.xshear = x;
+ this.yshear = y;
+ }
+
+ /**
+ * Set tests to run
+ *
+ * @param tests bit-shifted list of tests (see J2dBenchmark constants)
+ */
+ public void setTests(int tests)
+ {
+ awtTests = tests;
+ }
+
+ /**
+ * Saves test report after each iteration
+ */
+ void printReport()
+ {
+ // Report test results to the GUI display
+ ArrayList results = new ArrayList();
+ for (Iterator i = testSetMap.testIterator(); i.hasNext();)
+ {
+ TestRecorder recorder = testSetMap.getTest((String) i.next());
+
+ results.add("TEST " + recorder.getTestName() + ": average "
+ + recorder.getAverage() + "ms [" + recorder.getMinTime()
+ + "-" + recorder.getMaxTime() + "]");
+ }
+
+ display.report(results);
+ }
+
+ /**
+ * Disables current frame and displays test results
+ */
+ void testComplete()
+ {
+ // Clear benchmarking canvas and display results instead
+ myFrame.setVisible(false);
+
+ display.show();
+ }
+ }
+
+ /**
+ * GUI to display results of benchmarking
+ */
+ private class ResultsDisplay
+ extends Handler
+ implements ActionListener
+ {
+ /**
+ * Allow user to select results from each iteration
+ */
+ JComboBox iterations;
+
+ /**
+ * Area to print results in
+ */
+ JTextArea results;
+
+ /**
+ * Allow user to view summary or full details of test report
+ */
+ JCheckBox details;
+
+ /**
+ * Store all test results
+ */
+ ArrayList testResults;
+
+ /**
+ * Store all test details
+ */
+ ArrayList testDetails;
+
+ /**
+ * Initialize variables
+ */
+ public ResultsDisplay()
+ {
+ testResults = new ArrayList();
+ testDetails = new ArrayList();
+ testDetails.add(new ArrayList());
+ }
+
+ /**
+ * Parse all results and display on a GUI
+ */
+ public void show()
+ {
+ // Set up panel
+ JFrame frame = new JFrame("Java2D benchmark results");
+ Container cp = frame.getContentPane();
+
+ // Non-editable text area for the results
+ results = new JTextArea();
+ results.setEditable(false);
+ results.setRows(15);
+ results.setColumns(60);
+
+ // Checkbox to optionally display details (ie log messages)
+ details = new JCheckBox("Details", false);
+ details.addActionListener(this);
+
+ // Combo box to allow selection of iteration number
+ iterations = new JComboBox();
+ iterations.addActionListener(this);
+ for (int i = 0; i < testResults.size(); i++)
+ iterations.addItem("Iteration #" + (i + 1));
+
+ // Lay it all out
+ JPanel topleft = new JPanel();
+ topleft.add(new JLabel("View results from: "));
+ topleft.add(iterations);
+ topleft.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ details.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
+ JPanel top = new JPanel();
+ top.setLayout(new BoxLayout(top, BoxLayout.LINE_AXIS));
+ top.add(topleft);
+ top.add(details);
+
+ cp.add(top, BorderLayout.NORTH);
+ cp.add(new JScrollPane(results), BorderLayout.SOUTH);
+
+ frame.pack();
+ frame.show();
+ }
+
+ /**
+ * This overrides the logger publish method, which accepts log messages and
+ * saves them for later display
+ *
+ * @param record information about the log event
+ */
+ public void publish(LogRecord record)
+ {
+ ((ArrayList) testDetails.get(testDetails.size() - 1)).add(record.getMessage());
+ }
+
+ /**
+ * Accepts a test summary report, generated after each iteration of a test
+ *
+ * @param results test results
+ */
+ public void report(ArrayList results)
+ {
+ testResults.add(results);
+ testDetails.add(new ArrayList());
+ }
+
+ /**
+ * Provided as part of the Handler interface; not used
+ */
+ public void flush()
+ {
+ }
+
+ /**
+ * Provided as part of the Handler interface; not used
+ */
+ public void close()
+ {
+ }
+
+ /**
+ * Handle user-generated events on the results GUI
+ */
+ public void actionPerformed(ActionEvent ev)
+ {
+ // Display information about the requested iteration
+ int iteration = iterations.getSelectedIndex();
+ String message = "";
+
+ // Display summary or details, as requested
+ Iterator it;
+ if (details.isSelected())
+ it = ((ArrayList) testDetails.get(iteration)).iterator();
+ else
+ it = ((ArrayList) testResults.get(iteration)).iterator();
+
+ // Parse the ArrayList's
+ while (it.hasNext())
+ {
+ message = message + ((String) it.next() + "\n");
+ }
+
+ // Output to screen
+ results.setText(message);
+ }
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java
new file mode 100644
index 00000000000..efa57d2a36f
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/JNIOverhead.java
@@ -0,0 +1,390 @@
+/* JNIOverhead.java - demonstrator for classpath/gcj fillrect performance issue
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.java2d;
+
+import gnu.classpath.examples.swing.DemoFactory;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+/**
+ * @author Norman Hendrich
+ */
+public class JNIOverhead
+ extends JPanel
+ implements ActionListener
+{
+
+ static JNIOverhead fillRectDemo;
+
+ LCDCanvas lcd;
+ Worker worker;
+ JLabel label;
+ JCheckBox translate;
+ JCheckBox lines;
+
+ int nx = 128;
+ int ny = 64;
+ int matrix[][], future[][];
+ int generation = 0;
+
+ // 20 msec, or 50 repaints per sec (theoretically)
+ int sleepMillis = 20;
+ long lastMillis = System.currentTimeMillis();
+
+ boolean enableRepaints = true;
+
+ /**
+ * If true, test translation.
+ */
+ boolean testTranslation = false;
+
+ /**
+ * If true, paint lines rather than rectangles
+ */
+ boolean paintLines;
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public JNIOverhead()
+ {
+ setSize(nx, ny);
+ createContent();
+ }
+
+ public void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ JPanel p = new JPanel(new BorderLayout());
+ lcd = new LCDCanvas();
+ label = new JLabel();
+ label.setText("not running");
+
+ translate = new JCheckBox("translate");
+ translate.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ testTranslation = translate.isSelected();
+ }
+ });
+
+ lines = new JCheckBox("lines");
+ lines.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ paintLines = lines.isSelected();
+ }
+ });
+
+ JPanel bottom = new JPanel();
+ bottom.add(lines);
+ bottom.add(translate);
+
+ p.add(lcd, BorderLayout.CENTER);
+ p.add(bottom, BorderLayout.SOUTH);
+ p.add(label, BorderLayout.NORTH);
+ add(p);
+ }
+
+ public void setSize(int _nx,int _ny )
+ {
+ nx = _nx;
+ ny = _ny;
+ matrix = new int[nx][ny];
+ future = new int[nx][ny];
+ }
+
+ public void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ public void setSleepMillis(int millis)
+ {
+ sleepMillis = millis;
+ }
+
+ public class LCDCanvas extends JPanel
+ {
+ private int sx, sy;
+ private Color activePixel = new Color(30, 30, 40);
+ private Color passivePixel = new Color(200, 180, 240);
+ private Color gridPixel = new Color(255, 240, 240);
+
+ public LCDCanvas()
+ {
+ super();
+ sx = 4 * nx;
+ sy = 4 * ny;
+ }
+
+ public void paintComponent(Graphics g)
+ {
+ // for buffered drawing - not used atm
+ // g.drawImage( buffer, 0, 0, null );
+ long t1 = System.currentTimeMillis();
+
+ g.setColor(gridPixel);
+ g.fillRect(0, 0, sx, sy);
+
+ Color pixelColor = null;
+
+ int dx, dy;
+
+ if (paintLines)
+ {
+ for (int ix = 0; ix < nx; ix++)
+ for (int iy = 0; iy < ny; iy++)
+ {
+ if (matrix[ix][iy] != 0)
+ pixelColor = activePixel;
+ else
+ pixelColor = passivePixel;
+
+ dx = 4 * ix;
+ dy = 4 * iy;
+ g.setColor(pixelColor);
+
+ if (testTranslation)
+ {
+ g.translate(dx, dy);
+ g.drawLine(0, 0, 5, 5);
+ g.translate(- dx, - dy);
+ }
+ else
+ g.drawLine(dx, dy, dx + 5, dy + 5);
+ }
+ }
+ else
+ for (int ix = 0; ix < nx; ix++)
+ {
+ for (int iy = 0; iy < ny; iy++)
+ {
+ if (matrix[ix][iy] != 0)
+ pixelColor = activePixel;
+ else
+ pixelColor = passivePixel;
+
+ dx = 4 * ix;
+ dy = 4 * iy;
+ g.setColor(pixelColor);
+
+ if (testTranslation)
+ {
+ g.translate(dx, dy);
+ g.fillRect(0, 0, 3, 3);
+ g.translate(- dx, - dy);
+ }
+ else
+ g.fillRect(dx, dy, 3, 3);
+ }
+ }
+
+ long t2 = System.currentTimeMillis();
+
+ label.setText("paintComponent took " + (t2 - t1) + " msec. " + "("
+ + (nx * ny + 1) + " "
+ + (paintLines ? "drawLine" : "fillRect") + " calls)");
+
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(sx,sy);
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return new Dimension(sx,sy);
+ }
+ }
+
+ public class Worker extends Thread
+ {
+ public void run()
+ {
+ boolean running = true;
+ while(running)
+ {
+ iteration();
+
+ if (enableRepaints)
+ display();
+
+ if (sleepMillis > 0)
+ {
+ try
+ {
+ Thread.sleep( sleepMillis );
+ }
+ catch(InterruptedException ie)
+ {
+ running = false;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * stupid animation algorithm: show binary representation of current
+ * iteration.
+ */
+ public void iteration()
+ {
+ generation++;
+
+ for (int i = 0; i < nx; i++)
+ {
+ long tmp1 = 1L << i;
+ for (int j = 0; j < ny; j++)
+ {
+ // count neighbors
+ long tmp2 = (1L << j);
+
+
+ long tmp3 = generation & tmp1 & tmp2;
+ if (tmp3 != 0)
+ matrix[i][j] = 1;
+ else
+ matrix[i][j] = 0;
+ }
+ }
+
+ if ((generation % 100) == 0)
+ {
+ long t = System.currentTimeMillis();
+ // System.out.println(
+ // " generation= " + generation +
+ // " iterations/sec= " + 100.0*1000/(t-lastMillis) );
+ lastMillis = t;
+ }
+ }
+
+ public void display()
+ {
+ lcd.repaint();
+ }
+
+ public static void usage()
+ {
+ System.out.println(
+ "Usage: <java> FillRect2 [-sleep <millis>] [-size <int>] [-nopaint]\n"
+ + "Example: jamvm FillRect2 -sleep 10 -size 100\n"
+ );
+ System.exit(0);
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ fillRectDemo = new JNIOverhead();
+ for (int i = 0; i < args.length; i++)
+ {
+ if ("-help".equals(args[i]))
+ {
+ usage();
+ }
+ if ("-sleep".equals(args[i]))
+ {
+ fillRectDemo.setSleepMillis( Integer.parseInt(args[i + 1]));
+ i++;
+ }
+ if ("-size".equals(args[i]))
+ {
+ int size = Integer.parseInt(args[i + 1]);
+ fillRectDemo.setSize(size, size);
+ i++;
+ }
+ if ("-nopaint".equals(args[i]))
+ {
+ fillRectDemo.enableRepaints = false;
+ }
+ }
+
+ SwingUtilities.invokeLater (new Runnable()
+ {
+ public void run()
+ {
+
+ fillRectDemo.initFrameContent();
+ JFrame frame = new JFrame("FillRect performance test");
+ frame.getContentPane().add(fillRectDemo);
+ frame.pack();
+ frame.show();
+ fillRectDemo.worker = fillRectDemo.new Worker();
+ fillRectDemo.worker.start();
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a SliderDemo.
+ *
+ * @return a DemoFactory that creates a SliderDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ fillRectDemo = new JNIOverhead();
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ fillRectDemo.worker = fillRectDemo.new Worker();
+ fillRectDemo.worker.start();
+ }
+ });
+ return fillRectDemo;
+ }
+ };
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/bench.c b/libjava/classpath/examples/gnu/classpath/examples/java2d/bench.c
new file mode 100644
index 00000000000..e5b45aa1c15
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/java2d/bench.h b/libjava/classpath/examples/gnu/classpath/examples/java2d/bench.h
new file mode 100644
index 00000000000..aebd50a6785
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java
new file mode 100644
index 00000000000..ad8234555e5
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java
@@ -0,0 +1,55 @@
+/* TestBeans.java -- Tests the dynamic interface of the beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.DynamicMBean;
+
+public class TestBeans
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ List beans = new ArrayList();
+ /* FIXME: When there's a server, this will be easier... :) */
+ beans.add(ManagementFactory.getOperatingSystemMXBean());
+ beans.add(ManagementFactory.getRuntimeMXBean());
+ beans.add(ManagementFactory.getThreadMXBean());
+ beans.add(ManagementFactory.getCompilationMXBean());
+ beans.add(ManagementFactory.getClassLoadingMXBean());
+ beans.add(ManagementFactory.getMemoryMXBean());
+ beans.addAll(ManagementFactory.getMemoryPoolMXBeans());
+ beans.addAll(ManagementFactory.getMemoryManagerMXBeans());
+ beans.addAll(ManagementFactory.getGarbageCollectorMXBeans());
+ Iterator it = beans.iterator();
+ while (it.hasNext())
+ {
+ DynamicMBean bean = (DynamicMBean) it.next();
+ if (bean != null)
+ System.out.println(bean.getMBeanInfo());
+ }
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java
new file mode 100644
index 00000000000..113a4f2582c
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java
@@ -0,0 +1,41 @@
+/* TestClassLoading.java -- Tests the class loading bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ClassLoadingMXBean;
+import java.lang.management.ManagementFactory;
+
+public class TestClassLoading
+{
+ public static void main(String[] args)
+ {
+ ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean();
+ System.out.println("Bean: " + bean);
+ System.out.println("Loaded classes: " + bean.getLoadedClassCount());
+ System.out.println("Unloaded classes: " + bean.getUnloadedClassCount());
+ System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount());
+ boolean verbosity = bean.isVerbose();
+ System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
+ System.out.println("Changing verbose setting...");
+ bean.setVerbose(!verbosity);
+ System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no"));
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java
new file mode 100644
index 00000000000..ea8f45f6d1e
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestCompilation.java
@@ -0,0 +1,48 @@
+/* TestCompilation.java -- Tests the compilation bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.CompilationMXBean;
+
+public class TestCompilation
+{
+
+ public static void main(String[] args)
+ {
+ CompilationMXBean bean = ManagementFactory.getCompilationMXBean();
+ if (bean == null)
+ {
+ System.out.println("The compilation bean is not supported by this VM.");
+ System.exit(-1);
+ }
+ System.out.println("Bean: " + bean);
+ System.out.println("JIT compiler name: " + bean.getName());
+ boolean timeMonitoring = bean.isCompilationTimeMonitoringSupported();
+ System.out.println("Compilation time monitoring supported: " + timeMonitoring);
+ if (timeMonitoring)
+ {
+ System.out.println("Compilation time: "
+ + bean.getTotalCompilationTime() + "ms");
+ }
+ }
+
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java
new file mode 100644
index 00000000000..5d6d56797c4
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestGarbageCollector.java
@@ -0,0 +1,53 @@
+/* TestGarbageCollector.java -- Tests the garbage collector beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestGarbageCollector
+{
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getGarbageCollectorMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Memory pool names: "
+ + Arrays.toString(bean.getMemoryPoolNames()));
+ System.out.println("Is valid: "
+ + (bean.isValid() ? "yes" : "no"));
+ System.out.println("Collection count: "
+ + bean.getCollectionCount());
+ System.out.println("Collection time: "
+ + bean.getCollectionTime() + "ms");
+ }
+ }
+}
+
+
+
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java
new file mode 100644
index 00000000000..ca25d62119b
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemory.java
@@ -0,0 +1,52 @@
+/* TestMemory.java -- Tests the memory bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.MemoryMXBean;
+import java.lang.management.ManagementFactory;
+
+public class TestMemory
+{
+ public static void main(String[] args)
+ {
+ MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
+ System.out.println("Bean: " + bean);
+ System.out.println("Heap memory usage: "
+ + bean.getHeapMemoryUsage());
+ System.out.println("Non-heap memory usage: "
+ + bean.getNonHeapMemoryUsage());
+ System.out.println("Objects pending finalization: "
+ + bean.getObjectPendingFinalizationCount());
+ System.out.println("Running garbage collector via bean...");
+ bean.gc();
+ System.out.println("Heap memory usage: "
+ + bean.getHeapMemoryUsage());
+ System.out.println("Non-heap memory usage: "
+ + bean.getNonHeapMemoryUsage());
+ System.out.println("Objects pending finalization: "
+ + bean.getObjectPendingFinalizationCount());
+ boolean verbosity = bean.isVerbose();
+ System.out.println("Verbose memory output: " + (verbosity ? "yes" : "no"));
+ System.out.println("Changing verbose setting...");
+ bean.setVerbose(!verbosity);
+ System.out.println("Verbose memory output: " + (bean.isVerbose() ? "yes" : "no"));
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java
new file mode 100644
index 00000000000..30a0c985b9f
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryManager.java
@@ -0,0 +1,49 @@
+/* TestMemoryManager.java -- Tests the memory manager beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryManagerMXBean;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestMemoryManager
+{
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getMemoryManagerMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Memory pool names: "
+ + Arrays.toString(bean.getMemoryPoolNames()));
+ System.out.println("Is valid: "
+ + (bean.isValid() ? "yes" : "no"));
+ }
+ }
+}
+
+
+
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java
new file mode 100644
index 00000000000..2476ed76fe0
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java
@@ -0,0 +1,93 @@
+/* TestMemoryPool.java -- Tests the memory pool beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryUsage;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestMemoryPool
+{
+
+ /**
+ * 1mb in bytes
+ */
+ private static final int MB = 1 << 20;
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Collection usage: " + bean.getCollectionUsage());
+ boolean collectionUsage = bean.isCollectionUsageThresholdSupported();
+ System.out.println("Collection usage threshold supported: "
+ + collectionUsage);
+ if (collectionUsage)
+ {
+ System.out.println("Collection usage threshold: "
+ + bean.getCollectionUsageThreshold());
+ System.out.println("Setting collection usage threshold to 1MB ("
+ + MB + " bytes)");
+ bean.setCollectionUsageThreshold(MB);
+ System.out.println("Collection usage threshold: "
+ + bean.getCollectionUsageThreshold());
+ System.out.println("Collection usage threshold count: "
+ + bean.getCollectionUsageThresholdCount());
+ System.out.println("Collection usage threshold exceeded: "
+ + (bean.isCollectionUsageThresholdExceeded()
+ ? "yes" : "no"));
+ }
+ System.out.println("Memory manager names: "
+ + Arrays.toString(bean.getMemoryManagerNames()));
+ System.out.println("Peak usage: " + bean.getPeakUsage());
+ System.out.println("Current usage: " + bean.getUsage());
+ System.out.println("Resetting peak usage...");
+ bean.resetPeakUsage();
+ System.out.println("Peak usage: " + bean.getPeakUsage());
+ System.out.println("Current usage: " + bean.getUsage());
+ boolean usage = bean.isUsageThresholdSupported();
+ System.out.println("Usage threshold supported: " + usage);
+ if (usage)
+ {
+ System.out.println("Usage threshold: "
+ + bean.getUsageThreshold());
+ System.out.println("Setting usage threshold to 1MB ("
+ + MB + " bytes)");
+ bean.setUsageThreshold(MB);
+ System.out.println("Usage threshold: "
+ + bean.getUsageThreshold());
+ System.out.println("Usage threshold count: "
+ + bean.getUsageThresholdCount());
+ System.out.println("Usage threshold exceeded: "
+ + (bean.isUsageThresholdExceeded()
+ ? "yes" : "no"));
+ }
+ System.out.println("Valid: " + (bean.isValid() ? "yes" : "no"));
+ }
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestOS.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestOS.java
new file mode 100644
index 00000000000..a13e514f8e1
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestOS.java
@@ -0,0 +1,37 @@
+/* TestOS.java -- Tests the OS bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+
+public class TestOS
+{
+ public static void main(String[] args)
+ {
+ OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
+ System.out.println("Bean: " + osBean);
+ System.out.println("OS Name: " + osBean.getName());
+ System.out.println("OS Version: " + osBean.getVersion());
+ System.out.println("Architecture: " + osBean.getArch());
+ System.out.println("Processors: " + osBean.getAvailableProcessors());
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestRuntime.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestRuntime.java
new file mode 100644
index 00000000000..2a629ca83c6
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestRuntime.java
@@ -0,0 +1,54 @@
+/* TestRuntime.java -- Tests the runtime bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
+import java.util.Date;
+
+public class TestRuntime
+{
+
+ public static void main(String[] args)
+ {
+ RuntimeMXBean vmBean = ManagementFactory.getRuntimeMXBean();
+ System.out.println("Bean: " + vmBean);
+ boolean bootClassPath = vmBean.isBootClassPathSupported();
+ System.out.println("Boot Class Path Supported: " + bootClassPath);
+ if (bootClassPath)
+ System.out.println("Boot Class Path: " + vmBean.getBootClassPath());
+ System.out.println("Class Path: " + vmBean.getClassPath());
+ System.out.println("Input Arguments: " + vmBean.getInputArguments());
+ System.out.println("Library Path: " + vmBean.getLibraryPath());
+ System.out.println("Management Spec. Version: " + vmBean.getManagementSpecVersion());
+ System.out.println("Name: " + vmBean.getName());
+ System.out.println("Spec Name: " + vmBean.getSpecName());
+ System.out.println("Spec Vendor: " + vmBean.getSpecVendor());
+ System.out.println("Spec Version: " + vmBean.getSpecVersion());
+ System.out.println("Start Time: " + new Date(vmBean.getStartTime()));
+ System.out.println("System Properties: " + vmBean.getSystemProperties());
+ System.out.println("Uptime: " + vmBean.getUptime() + "ms");
+ System.out.println("VM Name: " + vmBean.getVmName());
+ System.out.println("VM Vendor: " + vmBean.getVmVendor());
+ System.out.println("VM Version: " + vmBean.getVmVersion());
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java
new file mode 100644
index 00000000000..e49776ce227
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestThread.java
@@ -0,0 +1,118 @@
+/* TestThread.java -- Tests the thread bean.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+import java.util.Arrays;
+
+public class TestThread
+{
+
+ public static void main(String[] args)
+ {
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ System.out.println("Bean: " + bean);
+ System.out.println("Monitor deadlocked threads: " + bean.findMonitorDeadlockedThreads());
+ long[] ids = bean.getAllThreadIds();
+ System.out.println("Live thread ids: " + Arrays.toString(ids));
+ boolean currentTimeMonitoring = bean.isCurrentThreadCpuTimeSupported();
+ System.out.println("Current thread CPU time monitoring supported: " + currentTimeMonitoring);
+ if (currentTimeMonitoring)
+ {
+ boolean timeEnabled = bean.isThreadCpuTimeEnabled();
+ System.out.println("Is time monitoring enabled... " +
+ (timeEnabled ? "yes" : "no"));
+ if (!timeEnabled)
+ {
+ System.out.println("Enabling...");
+ bean.setThreadCpuTimeEnabled(true);
+ timeEnabled = bean.isThreadCpuTimeEnabled();
+ System.out.println("Should now be enabled... " +
+ (timeEnabled ? "yes" : "no"));
+ }
+ if (timeEnabled)
+ {
+ System.out.println("Current thread CPU time: "
+ + bean.getCurrentThreadCpuTime()
+ + "ns");
+ System.out.println("Current thread user time: "
+ + bean.getCurrentThreadUserTime()
+ + "ns");
+ }
+ }
+ System.out.println("Daemon thread count: " + bean.getDaemonThreadCount());
+ System.out.println("Peak thread count: " + bean.getPeakThreadCount());
+ System.out.println("Resetting...");
+ bean.resetPeakThreadCount();
+ System.out.println("Peak thread count: " + bean.getPeakThreadCount());
+ System.out.println("Thread count: " + bean.getThreadCount());
+ boolean timeMonitoring = bean.isThreadCpuTimeSupported();
+ System.out.println("Thread CPU time monitoring supported: " + timeMonitoring);
+ if (timeMonitoring)
+ {
+ for (int a = 0; a < ids.length; ++a)
+ {
+ System.out.println("Thread " + a
+ + " CPU time: "
+ + bean.getThreadCpuTime(ids[a]) + "ns");
+ System.out.println("Thread "
+ + a + " user time: "
+ + bean.getThreadUserTime(ids[a]) + "ns");
+ }
+ }
+ System.out.println("Current thread info: "
+ + bean.getThreadInfo(Thread.currentThread().getId()));
+ System.out.println("All thread info: " + Arrays.toString(bean.getThreadInfo(ids)));
+ System.out.println("Total started threads: " + bean.getTotalStartedThreadCount());
+ boolean contentionMonitoring = bean.isThreadContentionMonitoringSupported();
+ System.out.println("Thread contention monitoring supported: " + contentionMonitoring);
+ if (contentionMonitoring)
+ {
+ boolean contentionEnabled = bean.isThreadContentionMonitoringEnabled();
+ System.out.println("Thread contention monitoring shouldn't be enabled... " +
+ (contentionEnabled ? "but it is" : "true"));
+ if (!contentionEnabled)
+ {
+ System.out.println("Enabling...");
+ bean.setThreadContentionMonitoringEnabled(true);
+ contentionEnabled = bean.isThreadContentionMonitoringEnabled();
+ System.out.println("Should now be enabled... " +
+ (contentionEnabled ? "it is" : "nope"));
+ }
+ if (contentionEnabled)
+ {
+ ThreadInfo[] info = bean.getThreadInfo(ids);
+ for (int a = 0; a < info.length; ++a)
+ {
+ System.out.println("Blocked time for thread "
+ + info[a].getThreadId() + ": "
+ + info[a].getBlockedTime() + "ms");
+ System.out.println("Waited time for thread "
+ + info[a].getThreadId() + ": "
+ + info[a].getWaitedTime() + "ms");
+ }
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
index 0f0b3555ea0..19bc27c1de8 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
@@ -22,12 +22,15 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
package gnu.classpath.examples.swing;
+import gnu.classpath.examples.java2d.JNIOverhead;
+
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
+import javax.swing.plaf.basic.BasicLookAndFeel;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
@@ -156,7 +159,10 @@ public class Demo
examples.add(new JMenuItem(new PopupAction("NavigationFilter",
NavigationFilterDemo.createDemoFactory())));
-
+ examples.add(new JMenuItem(new PopupAction("JNI Overhead",
+ JNIOverhead.createDemoFactory())));
+
+
final JMenuItem vmMenu;
help.add(new JMenuItem("just play with the widgets"));
@@ -187,6 +193,10 @@ public class Demo
}
});
+ // Installs the BasicLookAndFeel.
+ UIManager.installLookAndFeel("(Basic Look And Feel)",
+ InstantiableBasicLookAndFeel.class.getName());
+
// Create L&F menu.
JMenu lafMenu = new JMenu("Look and Feel");
ButtonGroup lafGroup = new ButtonGroup();
@@ -200,6 +210,8 @@ public class Demo
boolean selected = laf.getClassName().equals(currentLaf);
lafItem.setSelected(selected);
lafMenu.add(lafItem);
+
+ lafGroup.add(lafItem);
}
// Create themes menu.
@@ -543,7 +555,10 @@ public class Demo
panel.add(new JButton(new PopupAction("Tree",
TreeDemo.createDemoFactory())));
panel.add(new JButton(new PopupAction("Theme Editor",
- MetalThemeEditor.createDemoFactory())));
+ MetalThemeEditor.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("JNI Overhead",
+ JNIOverhead.createDemoFactory())));
+
JButton exitDisposer = mkDisposerButton(frame);
panel.add(exitDisposer);
@@ -652,10 +667,45 @@ public class Demo
{
ex.printStackTrace();
}
+
SwingUtilities.updateComponentTreeUI(frame);
themesMenu.setEnabled(laf.getClassName()
.equals("javax.swing.plaf.metal.MetalLookAndFeel"));
}
+ }
+ /**
+ * An implementation of BasicLookAndFeel which can be instantiated.
+ *
+ * @author Robert Schuster (robertschuster@fsfe.org)
+ *
+ */
+ public static class InstantiableBasicLookAndFeel extends BasicLookAndFeel
+ {
+ public String getDescription()
+ {
+ return "An instantiable implementation of BasicLookAndFeel";
+ }
+
+ public String getID()
+ {
+ return "instantiableBasicLookAndFeel";
+ }
+
+ public String getName()
+ {
+ return "Instantiable Basic Look And Feel";
+ }
+
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
}
+
}
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java
new file mode 100644
index 00000000000..223ee07cd4a
--- /dev/null
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java
@@ -0,0 +1,298 @@
+/* HtmlDemo.java -- HTML viewer demo
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+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.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class HtmlDemo extends JPanel
+{
+
+ JTextPane html = new JTextPane();
+
+ 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()
+ {
+ super();
+ html.setContentType("text/html"); // not now.
+ createContent();
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel uses a BorderLayout(), and
+ * the BorderLayout.SOUTH area is empty, to allow callers to add controls to
+ * the bottom of the panel if they want to (a close button is added if this
+ * demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ JPanel center = new JPanel();
+ GridLayout layout = new GridLayout();
+ layout.setRows(2);
+ center.setLayout(layout);
+ center.add(new JScrollPane(text));
+ center.add(new JScrollPane(html));
+
+ buttons = new JPanel();
+
+ JButton parse = new JButton("parse");
+ parse.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ String t = text.getText();
+ System.out.println("HtmlDemo.java.createContent:Parsing started");
+ html.setText(t);
+ System.out.println("HtmlDemo.java.createContent:Parsing completed");
+ }
+ });
+
+ 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);
+ }
+
+ /**
+ * The executable method to display the editable table.
+ *
+ * @param args
+ * unused.
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ HtmlDemo demo = new HtmlDemo();
+
+ JButton exit = new JButton("exit");
+ exit.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ System.exit(0);
+ }
+ });
+
+ demo.buttons.add(exit);
+
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(demo);
+ frame.setSize(new Dimension(700, 480));
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a HtmlDemo.
+ *
+ * @return a DemoFactory that creates a HtmlDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new HtmlDemo();
+ }
+ };
+ }
+}
+
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java
index 6c1be74cc2e..5184e5ba0f6 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java
@@ -160,7 +160,7 @@ public class NavigationFilterDemo
pt = text.getCaret().getMagicCaretPosition();
// Calculate its position above.
- newpos = Utilities.getPositionAbove(text, pos, pt.x);
+ newpos = Utilities.getPositionAbove(text, pos, (pt != null) ? pt.x : 0);
// If we have a valid position, then calculate the next word start
// from there.
@@ -173,7 +173,7 @@ public class NavigationFilterDemo
pt = text.getCaret().getMagicCaretPosition();
// Calculate its position below.
- newpos = Utilities.getPositionBelow(text, pos, pt.x);
+ newpos = Utilities.getPositionBelow(text, pos, (pt != null) ? pt.x : 0);
// If we have a valid position, then calculate the next word start
// from there.
@@ -192,7 +192,6 @@ public class NavigationFilterDemo
else
return Utilities.getPreviousWord(text, newpos);
case SwingConstants.EAST:
- // Simply calculate the next word's start offset.
return Utilities.getNextWord(text, newpos);
default:
// Do whatever the super implementation did.
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
index 9d797d20317..527fe455e4b 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
@@ -66,17 +66,17 @@ public class TabbedPaneDemo
JPanel p = new JPanel();
p.setLayout(new GridLayout(2, 2));
JTabbedPane tabs1 = new JTabbedPane(SwingConstants.TOP);
- tabs1.add("Top Item 1", new JButton("Button"));
- tabs1.add("Top Item 2", new JButton("Button"));
+ tabs1.add("Top Item 1", new JButton("Content: Top Item 1"));
+ tabs1.add("Top Item 2", new JButton("Content: Top Item 2"));
JTabbedPane tabs2 = new JTabbedPane(SwingConstants.LEFT);
- tabs2.add("Left Item 1", new JButton("Button"));
- tabs2.add("Left Item 2", new JButton("Button"));
+ tabs2.add("Left Item 1", new JButton("Content: Left Item 1"));
+ tabs2.add("Left Item 2", new JButton("Content: Left Item 2"));
JTabbedPane tabs3 = new JTabbedPane(SwingConstants.BOTTOM);
- tabs3.add("Bottom Item 1", new JButton("Button"));
- tabs3.add("Bottom Item 2", new JButton("Button"));
+ tabs3.add("Bottom Item 1", new JButton("Content: Bottom Item 1"));
+ tabs3.add("Bottom Item 2", new JButton("Content: Bottom Item 2"));
JTabbedPane tabs4 = new JTabbedPane(SwingConstants.RIGHT);
- tabs4.add("Right Item 1", new JButton("Button"));
- tabs4.add("Right Item 2", new JButton("Button"));
+ tabs4.add("Right Item 1", new JButton("Content: Right Item 1"));
+ tabs4.add("Right Item 2", new JButton("Content: Right Item 2"));
p.add(tabs1);
p.add(tabs2);
p.add(tabs3);
diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java
index e661ee3adc6..d4a97b3ef45 100644
--- a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java
+++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java
@@ -39,19 +39,36 @@ exception statement from your version. */
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.text.DateFormat;
+import java.util.Date;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
+import javax.swing.JList;
import javax.swing.JPanel;
+import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
+import javax.swing.JSlider;
import javax.swing.JTable;
+import javax.swing.JTextField;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import javax.swing.plaf.metal.MetalIconFactory;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
/**
* Displays the editable table. The first column consists of check boxes.
@@ -78,12 +95,11 @@ public class TableDemo extends JPanel
{
/**
- * Return true if the cell is editable.
- * Icons are not editable, other cells are editable.
+ * All cells are editable in our table.
*/
public boolean isCellEditable(int row, int column)
{
- return column!=1;
+ return true;
}
/**
@@ -144,6 +160,77 @@ public class TableDemo extends JPanel
}
/**
+ * The scroll bar renderer.
+ */
+ class SliderCell
+ extends AbstractCellEditor
+ implements TableCellEditor, TableCellRenderer
+ {
+ /**
+ * The editor bar.
+ */
+ JSlider bar;
+
+ /**
+ * The renderer bar.
+ */
+ JSlider rendererBar;
+
+ /**
+ * The border around the bar, if required.
+ */
+ Border border = BorderFactory.createLineBorder(table.getGridColor());
+
+ SliderCell()
+ {
+ bar = new JSlider();
+ bar.setOrientation(JScrollBar.HORIZONTAL);
+ bar.setMinimum(0);
+ bar.setMaximum(rows);
+ bar.setBorder(border);
+
+ rendererBar = new JSlider();
+ rendererBar.setMinimum(0);
+ rendererBar.setMaximum(rows);
+ rendererBar.setEnabled(false);
+ }
+
+ /**
+ * Get the editor.
+ */
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row,
+ int column)
+ {
+ if (value instanceof Integer)
+ bar.setValue(((Integer) value).intValue());
+ return bar;
+ }
+
+ /**
+ * Get the renderer.
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ rendererBar.setValue(((Integer) value).intValue());
+ if (hasFocus)
+ rendererBar.setBorder(border);
+ else
+ rendererBar.setBorder(null);
+ return rendererBar;
+ }
+
+ public Object getCellEditorValue()
+ {
+ return new Integer(bar.getValue());
+ }
+
+ }
+
+ /**
* The table being displayed.
*/
JTable table = new JTable();
@@ -159,6 +246,25 @@ public class TableDemo extends JPanel
Object[][] values;
/**
+ * The icons that appear in the icon column.
+ */
+ Icon[] icons = new Icon[]
+ {
+ MetalIconFactory.getTreeComputerIcon(),
+ MetalIconFactory.getTreeHardDriveIcon(),
+ MetalIconFactory.getTreeFolderIcon(),
+ };
+
+ /**
+ * The choices in the combo boxes
+ */
+ String [] sides = new String[]
+ {
+ "north", "south", "east", "west"
+ };
+
+
+ /**
* Create the table demo with the given titel.
*/
public TableDemo()
@@ -178,29 +284,25 @@ public class TableDemo extends JPanel
setLayout(new BorderLayout());
values = new Object[rows][];
- // The icons that appear in the icon column.
- Icon[] icons = new Icon[]
- {
- MetalIconFactory.getTreeComputerIcon(),
- MetalIconFactory.getTreeHardDriveIcon(),
- MetalIconFactory.getTreeFolderIcon(),
- };
-
for (int i = 0; i < values.length; i++)
{
values[i] = new Object[cols];
- for (int j = 2; j < cols; j++)
+ for (int j = 3; j < cols; j++)
{
values[i][j] = "" + ((char) ('a' + j)) + i;
}
values [i][0] = i % 2 == 0? Boolean.TRUE : Boolean.FALSE;
- values [i][1] = icons [ i % icons.length ];
+ values [i][1] = icons [ i % icons.length ];
+ values [i][2] = sides [ i % sides.length ];
+ values [i][4] = new Integer(i);
}
table.setModel(model);
// Make the columns with gradually increasing width:
DefaultTableColumnModel cm = new DefaultTableColumnModel();
+ table.setColumnModel(cm);
+
for (int i = 0; i < cols; i++)
{
TableColumn column = new TableColumn(i);
@@ -215,8 +317,9 @@ public class TableDemo extends JPanel
cm.addColumn(column);
}
-
- table.setColumnModel(cm);
+
+ setCustomEditors();
+ setInformativeHeaders();
// Create the table, place it into scroll pane and place
// the pane into this frame.
@@ -226,6 +329,52 @@ public class TableDemo extends JPanel
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.getViewport().add(table);
add(scroll, BorderLayout.CENTER);
+
+ // Increase the row height to make the icons and sliders look better.
+ table.setRowHeight(table.getRowHeight()+2);
+ }
+
+ /**
+ * Set the more informative column headers for specific columns.
+ */
+ void setInformativeHeaders()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ cm.getColumn(0).setHeaderValue("check");
+ cm.getColumn(1).setHeaderValue("icon");
+ cm.getColumn(2).setHeaderValue("combo");
+ cm.getColumn(3).setHeaderValue("edit combo");
+ cm.getColumn(4).setHeaderValue("slider");
+ }
+
+ /**
+ * Set the custom editors for combo boxes. This method also sets one
+ * custom renderer.
+ */
+ void setCustomEditors()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ // Set combo-box based editor for icons (note that no custom
+ // renderer is needed for JComboBox to work with icons.
+ JComboBox combo0 = new JComboBox(icons);
+ cm.getColumn(1).setCellEditor(new DefaultCellEditor(combo0));
+
+ // Set the simple combo box editor for the third column:
+ JComboBox combo1 = new JComboBox(sides);
+ cm.getColumn(2).setCellEditor(new DefaultCellEditor(combo1));
+
+ // Set the editable combo box for the forth column:
+ JComboBox combo2 = new JComboBox(sides);
+ combo2.setEditable(true);
+ cm.getColumn(3).setCellEditor(new DefaultCellEditor(combo2));
+
+ SliderCell scrollView = new SliderCell();
+ cm.getColumn(4).setCellEditor(scrollView);
+ cm.getColumn(4).setCellRenderer(scrollView);
+
+ table.setColumnModel(cm);
}
/**
@@ -266,3 +415,4 @@ public class TableDemo extends JPanel
};
}
}
+
diff --git a/libjava/classpath/external/Makefile.in b/libjava/classpath/external/Makefile.in
index 23279c2ee95..308dd19217c 100644
--- a/libjava/classpath/external/Makefile.in
+++ b/libjava/classpath/external/Makefile.in
@@ -93,6 +93,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -113,6 +115,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -143,6 +146,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -193,6 +200,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -213,6 +221,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/external/relaxngDatatype/Makefile.in b/libjava/classpath/external/relaxngDatatype/Makefile.in
index cc063ac9b67..7db1816403c 100644
--- a/libjava/classpath/external/relaxngDatatype/Makefile.in
+++ b/libjava/classpath/external/relaxngDatatype/Makefile.in
@@ -84,6 +84,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -104,6 +106,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -134,6 +137,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -184,6 +191,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -204,6 +212,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/external/sax/Makefile.in b/libjava/classpath/external/sax/Makefile.in
index cd04e16ff07..af963340722 100644
--- a/libjava/classpath/external/sax/Makefile.in
+++ b/libjava/classpath/external/sax/Makefile.in
@@ -84,6 +84,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -104,6 +106,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -134,6 +137,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -184,6 +191,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -204,6 +212,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/external/w3c_dom/Makefile.in b/libjava/classpath/external/w3c_dom/Makefile.in
index 7e61f759dee..7a5537c5fd6 100644
--- a/libjava/classpath/external/w3c_dom/Makefile.in
+++ b/libjava/classpath/external/w3c_dom/Makefile.in
@@ -84,6 +84,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -104,6 +106,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -134,6 +137,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -184,6 +191,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -204,6 +212,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java b/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java
index cbdf46f259a..5b77fa03073 100644
--- a/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java b/libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java
index 0bdf22a1950..96573193a9e 100644
--- a/libjava/classpath/gnu/classpath/debug/Simple1LineFormatter.java
+++ b/libjava/classpath/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;
@@ -91,20 +92,27 @@ public class Simple1LineFormatter
extends Formatter
{
private static final String DAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSSS Z ";
- private static final DateFormat DAT_FORMAT = new SimpleDateFormat(DAT_PATTERN);
private static final String THREAD_PATTERN = " #########0;-#########0";
- private static final NumberFormat THREAD_FORMAT = new DecimalFormat(THREAD_PATTERN);
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;
// default 0-arguments constructor
public String format(LogRecord record)
{
- StringBuffer sb = new StringBuffer(180)
- .append(DAT_FORMAT.format(new Date(record.getMillis())))
- .append(THREAD_FORMAT.format(record.getThreadID()))
+ if (dateFormat == null)
+ dateFormat = new SimpleDateFormat(DAT_PATTERN);
+
+ if (threadFormat == null)
+ threadFormat = new DecimalFormat(THREAD_PATTERN);
+
+ StringBuilder sb = new StringBuilder(180)
+ .append(dateFormat.format(new Date(record.getMillis())))
+ .append(threadFormat.format(record.getThreadID()))
.append(" ");
String s = record.getSourceClassName();
if (s == null)
diff --git a/libjava/classpath/gnu/classpath/debug/SystemLogger.java b/libjava/classpath/gnu/classpath/debug/SystemLogger.java
index 94aa93f69da..502b488702b 100644
--- a/libjava/classpath/gnu/classpath/debug/SystemLogger.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/debug/TeeInputStream.java b/libjava/classpath/gnu/classpath/debug/TeeInputStream.java
new file mode 100644
index 00000000000..ef6b2ed3dc1
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/debug/TeeInputStream.java
@@ -0,0 +1,98 @@
+/* TeeInputStream.java
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under terms
+of your choice, provided that you also meet, for each linked independent
+module, the terms and conditions of the license of that module. An
+independent module is a module which is not derived from or based on
+this library. If you modify this library, you may extend this exception
+to your version of the library, but you are not obligated to do so. If
+you do not wish to do so, delete this exception statement from your
+version. */
+
+package gnu.classpath.debug;
+
+import java.io.*;
+
+/**
+ * An input stream that copies all its input to a byte sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeInputStream
+ extends InputStream
+{
+
+ private final InputStream in;
+ private final OutputStream out;
+
+ /**
+ * Constructs a tee input stream.
+ * @param in the underlying input stream
+ * @param out the output sink
+ */
+ public TeeInputStream(InputStream in, OutputStream out)
+ {
+ this.in = in;
+ this.out = out;
+ }
+
+ public int read()
+ throws IOException
+ {
+ int ret = in.read();
+ out.write(ret);
+ out.flush();
+ return ret;
+ }
+
+ public int read(byte[] b, int off, int len)
+ throws IOException
+ {
+ int ret = in.read(b, off, len);
+ if (ret != -1)
+ {
+ out.write(b, off, ret);
+ out.flush();
+ }
+ return ret;
+ }
+
+ public void close()
+ throws IOException
+ {
+ in.close();
+ out.close();
+ }
+
+ public final boolean markSupported()
+ {
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/debug/TeeOutputStream.java b/libjava/classpath/gnu/classpath/debug/TeeOutputStream.java
new file mode 100644
index 00000000000..cff60894a6c
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/debug/TeeOutputStream.java
@@ -0,0 +1,93 @@
+/* TeeOutputStream.java
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under terms
+of your choice, provided that you also meet, for each linked independent
+module, the terms and conditions of the license of that module. An
+independent module is a module which is not derived from or based on
+this library. If you modify this library, you may extend this exception
+to your version of the library, but you are not obligated to do so. If
+you do not wish to do so, delete this exception statement from your
+version. */
+
+package gnu.classpath.debug;
+
+import java.io.*;
+
+/**
+ * An output stream that copies all its output to an additional byte sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeOutputStream
+ extends OutputStream
+{
+
+ private final OutputStream out;
+ private final OutputStream sink;
+
+ /**
+ * Constructs a tee output stream.
+ * @param out the underlying output stream
+ * @param sink the output sink
+ */
+ public TeeOutputStream(OutputStream out, OutputStream sink)
+ {
+ this.out = out;
+ this.sink = sink;
+ }
+
+ public void write(int c)
+ throws IOException
+ {
+ out.write(c);
+ sink.write(c);
+ }
+
+ public void write(byte[] b, int off, int len)
+ throws IOException
+ {
+ out.write(b, off, len);
+ sink.write(b, off, len);
+ }
+
+ public void flush()
+ throws IOException
+ {
+ out.flush();
+ sink.flush();
+ }
+
+ public void close()
+ throws IOException
+ {
+ out.close();
+ sink.close();
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/debug/TeeReader.java b/libjava/classpath/gnu/classpath/debug/TeeReader.java
new file mode 100644
index 00000000000..8fa742e21a1
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/debug/TeeReader.java
@@ -0,0 +1,98 @@
+/* TeeReader.java
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under terms
+of your choice, provided that you also meet, for each linked independent
+module, the terms and conditions of the license of that module. An
+independent module is a module which is not derived from or based on
+this library. If you modify this library, you may extend this exception
+to your version of the library, but you are not obligated to do so. If
+you do not wish to do so, delete this exception statement from your
+version. */
+
+package gnu.classpath.debug;
+
+import java.io.*;
+
+/**
+ * A reader that copies all characters read to an output sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeReader
+ extends Reader
+{
+
+ private final Reader in;
+ private final Writer out;
+
+ /**
+ * Constructs a tee reader.
+ * @param in the input
+ * @param out the output sink
+ */
+ public TeeReader(Reader in, Writer out)
+ {
+ this.in = in;
+ this.out = out;
+ }
+
+ public int read()
+ throws IOException
+ {
+ int ret = in.read();
+ out.write(ret);
+ out.flush();
+ return ret;
+ }
+
+ public int read(char[] b, int off, int len)
+ throws IOException
+ {
+ int ret = in.read(b, off, len);
+ if (ret != -1)
+ {
+ out.write(b, off, ret);
+ out.flush();
+ }
+ return ret;
+ }
+
+ public void close()
+ throws IOException
+ {
+ in.close();
+ out.close();
+ }
+
+ public final boolean markSupported()
+ {
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/debug/TeeWriter.java b/libjava/classpath/gnu/classpath/debug/TeeWriter.java
new file mode 100644
index 00000000000..f226c21658a
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/debug/TeeWriter.java
@@ -0,0 +1,93 @@
+/* TeeWriter.java
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under terms
+of your choice, provided that you also meet, for each linked independent
+module, the terms and conditions of the license of that module. An
+independent module is a module which is not derived from or based on
+this library. If you modify this library, you may extend this exception
+to your version of the library, but you are not obligated to do so. If
+you do not wish to do so, delete this exception statement from your
+version. */
+
+package gnu.classpath.debug;
+
+import java.io.*;
+
+/**
+ * A writer that copies all its output to an additional character sink.
+ *
+ * @author Chris Burdess
+ */
+public class TeeWriter
+ extends Writer
+{
+
+ private final Writer out;
+ private final Writer sink;
+
+ /**
+ * Constructs a tee writer.
+ * @param out the underlying writer
+ * @param sink the output sink
+ */
+ public TeeWriter(Writer out, Writer sink)
+ {
+ this.out = out;
+ this.sink = sink;
+ }
+
+ public void write(int c)
+ throws IOException
+ {
+ out.write(c);
+ sink.write(c);
+ }
+
+ public void write(char[] b, int off, int len)
+ throws IOException
+ {
+ out.write(b, off, len);
+ sink.write(b, off, len);
+ }
+
+ public void flush()
+ throws IOException
+ {
+ out.flush();
+ sink.flush();
+ }
+
+ public void close()
+ throws IOException
+ {
+ out.close();
+ sink.close();
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/Jdwp.java b/libjava/classpath/gnu/classpath/jdwp/Jdwp.java
index 7141214ef26..e63a9a353dd 100644
--- a/libjava/classpath/gnu/classpath/jdwp/Jdwp.java
+++ b/libjava/classpath/gnu/classpath/jdwp/Jdwp.java
@@ -56,6 +56,9 @@ import java.util.HashMap;
/**
* Main interface from the virtual machine to the JDWP back-end.
*
+ * The thread created by this class is only used for initialization.
+ * Once it exits, the JDWP backend is fully initialized.
+ *
* @author Keith Seitz (keiths@redhat.com)
*/
public class Jdwp
@@ -65,7 +68,8 @@ public class Jdwp
private static Jdwp _instance = null;
/**
- * Are we debugging?
+ * Are we debugging? Only true if debugging
+ * *and* initialized.
*/
public static boolean isDebugging = false;
@@ -89,13 +93,16 @@ public class Jdwp
// A thread group for the JDWP threads
private ThreadGroup _group;
+ // Initialization synchronization
+ private Object _initLock = new Object ();
+ private int _initCount = 0;
+
/**
* constructor
*/
public Jdwp ()
{
_shutdown = false;
- isDebugging = true;
_instance = this;
}
@@ -271,17 +278,52 @@ public class Jdwp
}
}
+ /**
+ * Allows subcomponents to specify that they are
+ * initialized.
+ *
+ * Subcomponents include JdwpConnection and PacketProcessor.
+ */
+ public void subcomponentInitialized ()
+ {
+ synchronized (_initLock)
+ {
+ ++_initCount;
+ _initLock.notify ();
+ }
+ }
+
public void run ()
{
try
{
_doInitialization ();
+
+ /* We need a little internal synchronization here, so that
+ when this thread dies, the back-end will be fully initialized,
+ ready to start servicing the VM and debugger. */
+ synchronized (_initLock)
+ {
+ while (_initCount != 2)
+ _initLock.wait ();
+ }
+ _initLock = null;
}
catch (Throwable t)
{
System.out.println ("Exception in JDWP back-end: " + t);
System.exit (1);
}
+
+ /* Force creation of the EventManager. If the event manager
+ has not been created when isDebugging is set, it is possible
+ that the VM will call Jdwp.notify (which uses EventManager)
+ while the EventManager is being created (or at least this is
+ a problem with gcj/gij). */
+ EventManager.getDefault();
+
+ // Now we are finally ready and initialized
+ isDebugging = true;
}
// A helper function to process the configure string "-Xrunjdwp:..."
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java
index be429f4873a..abf280d6ec6 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java
@@ -62,18 +62,23 @@ public class BreakpointEvent
// Location where breakpoint occurred
private Location _location;
+
+ //object instance
+ private Object _instance;
/**
* Constructs a new BreakpointEvent
*
* @param thread thread in which event occurred
* @param loc location where breakpoint occurred
+ * @param instance object instance
*/
- public BreakpointEvent(Thread thread, Location loc)
+ public BreakpointEvent(Thread thread, Location loc, Object instance)
{
super(JdwpConstants.EventKind.BREAKPOINT);
_thread = thread;
_location = loc;
+ _instance = instance;
}
/**
@@ -83,12 +88,14 @@ public class BreakpointEvent
* @param type the type of parameter desired
* @returns the desired parameter or null
*/
- public Object getParameter(Class type)
+ public Object getParameter(int type)
{
- if (type == ThreadId.class)
+ if (type == EVENT_THREAD)
return _thread;
- else if (type == Location.class)
+ else if (type == EVENT_LOCATION)
return _location;
+ else if (type == EVENT_INSTANCE)
+ return _instance;
return null;
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java
index 22cede0c50a..5341daa42b5 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java
@@ -116,11 +116,11 @@ public class ClassPrepareEvent
* @param type the type of parameter desired
* @returns the desired parameter or <code>null</code>
*/
- public Object getParameter (Class type)
+ public Object getParameter (int type)
{
- if (type == ThreadId.class)
+ if (type == EVENT_THREAD)
return _thread;
- else if (type == ReferenceTypeId.class)
+ else if (type == EVENT_CLASS)
return _class;
return null;
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java
new file mode 100644
index 00000000000..4ba8bc80666
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java
@@ -0,0 +1,96 @@
+/* ClassUnloadEvent.java -- event generated when a class is unloaded
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a class unload in the target VM" -- JDWP 1.4.2
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class ClassUnloadEvent
+ extends Event
+{
+ //signature directly from VM
+ private String _signature;
+
+ /**
+ * Constructs a new <code>ClassUnloadEvent</code>
+ *
+ * @param signature the signature reported from the VM
+ */
+ public ClassUnloadEvent(String signature)
+ {
+ super(JdwpConstants.EventKind.CLASS_UNLOAD);
+ _signature = signature;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event. Class is the only
+ * valid type.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter(int type)
+ {
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ */
+ protected void _writeData(DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+
+ JdwpString.writeString(outStream, _signature);
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/Event.java b/libjava/classpath/gnu/classpath/jdwp/event/Event.java
index 14e5b78fc14..e91108a61a8 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/Event.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/Event.java
@@ -54,6 +54,41 @@ import java.io.IOException;
*/
public abstract class Event
{
+ /**
+ * The class of the object in which the event occurred
+ */
+ public static final int EVENT_CLASS = 1;
+
+ /**
+ * The thread where the event occurred
+ */
+ public static final int EVENT_THREAD = 2;
+
+ /**
+ * The location where an event occurred
+ */
+ public static final int EVENT_LOCATION = 3;
+
+ /**
+ * The instance of the class where the event occurred
+ */
+ public static final int EVENT_INSTANCE = 4;
+
+ /**
+ * The field acted on by an event
+ */
+ public static final int EVENT_FIELD = 5;
+
+ /**
+ * The class of the exception for ExceptionEvent
+ */
+ public static final int EVENT_EXCEPTION_CLASS = 6;
+
+ /**
+ * Whether this exception was caught (only valid for ExceptionEvents)
+ */
+ public static final int EVENT_EXCEPTION_CAUGHT = 7;
+
// The kind of event represented by this event
private byte _eventKind;
@@ -97,7 +132,7 @@ public abstract class Event
* @returns the parameter (not the ID) or <code>null</code> if none is
* is defined for this event
*/
- public abstract Object getParameter (Class type);
+ public abstract Object getParameter (int type);
/**
* Converts this event into to a JDWP packet
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java b/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
index eb0c3ddb7d2..54a7b08312d 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
@@ -1,5 +1,5 @@
/* EventManager.java -- event management and notification infrastructure
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -69,7 +69,7 @@ import java.util.Iterator;
public class EventManager
{
// Single instance
- private static EventManager _instance = new EventManager ();
+ private static EventManager _instance = null;
// maps event (EVENT_*) to lists of EventRequests
private Hashtable _requests = null;
@@ -79,8 +79,11 @@ public class EventManager
*
* @return the event manager
*/
- public static EventManager getDefault ()
+ public static EventManager getDefault()
{
+ if (_instance == null)
+ _instance = new EventManager();
+
return _instance;
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java
new file mode 100644
index 00000000000..1303c09be76
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java
@@ -0,0 +1,157 @@
+/* ExceptionEvent.java -- an event specifying an exception has been thrown
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that an exception has occurred along with where it
+ * occurred, and if and where it was caught.
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class ExceptionEvent
+ extends Event
+{
+ //object instance
+ private Object _instance;
+
+ // the exception thrown
+ private Throwable _exception;
+
+ // the thread in which the exception occurred
+ private Thread _thread;
+
+ // the location where the exception was thrown
+ private Location _location;
+
+ //the location where the exception was caught
+ private Location _catchLocation;
+
+ //the class where the exeption was thrown
+ private Class _klass;
+
+ /**
+ * Constructs a new <code>ExceptionEvent</code> where the exception was
+ * caught.
+ *
+ * @param exception the throwable object that generated the event
+ * @param thread the thread where the exception occurred
+ * @param location the location where the exception was thrown
+ * @param catchLocation the location where the exception was caught
+ * @param instance the instance that threw the exception
+ */
+ public ExceptionEvent(Throwable exception, Thread thread, Location location,
+ Location catchLocation, Class clazz, Object instance)
+ {
+ super(JdwpConstants.EventKind.EXCEPTION);
+ _exception = exception;
+ _thread = thread;
+ _location = location;
+ _catchLocation = catchLocation;
+ _klass = clazz;
+ _instance = instance;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event. Valid types are
+ * thread, location, and catchLocation.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or null
+ */
+ public Object getParameter(int type)
+ {
+ if (type == EVENT_THREAD)
+ return _thread;
+ else if (type == EVENT_LOCATION)
+ return _location;
+ else if (type == EVENT_INSTANCE)
+ return _instance;
+ else if (type == EVENT_CLASS)
+ return _klass;
+ else if (type == EVENT_EXCEPTION_CLASS)
+ return _exception.getClass();
+ else if (type == EVENT_EXCEPTION_CAUGHT)
+ if (_catchLocation.getMethod() != null)
+ return new Boolean(true);
+ else
+ return new Boolean(false);
+
+ return null;
+ }
+
+ /**
+ * Sets the catchLocation, used for exceptions that are caught in different
+ * stack frames from where they are thrown.
+ *
+ * @param catchLoc the location of the catch
+ */
+ public void setCatchLoc(Location catchLoc)
+ {
+ _catchLocation = catchLoc;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ * @throws IOException
+ */
+ protected void _writeData(DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+ ObjectId oid = idm.getObjectId(_exception);
+
+ tid.write(outStream);
+ _location.write(outStream);
+ oid.writeTagged(outStream);
+ _catchLocation.write(outStream);
+
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java
new file mode 100644
index 00000000000..40c0516c716
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java
@@ -0,0 +1,118 @@
+/* MethodEntryEvent.java -- an event specifying that a method has been invoked
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that that a method has been invoked
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class MethodEntryEvent
+ extends Event
+{
+ // The thread where the event occurred
+ private Thread _thread;
+
+ // the location where the event occurred
+ private Location _location;
+
+ //object instance
+ private Object _instance;
+
+ /**
+ * Constructs a new <code>MethodEntryEvent</code>
+ *
+ * @param thread the thread where the exception occurred
+ * @param location the location single stepped to
+ * @param instance instance from which the method was called
+ */
+ public MethodEntryEvent(Thread thread, Location location, Object instance)
+ {
+ super(JdwpConstants.EventKind.METHOD_ENTRY);
+ _thread = thread;
+ _location = location;
+ _instance = instance;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event. Valid types are
+ * thread and location
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or null
+ */
+ public Object getParameter(int type)
+ {
+ if (type == EVENT_THREAD)
+ return _thread;
+ else if (type == EVENT_LOCATION)
+ return _location;
+ else if (type == EVENT_INSTANCE)
+ return _instance;
+ else if (type == EVENT_CLASS)
+ return _instance.getClass();
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ * @throws IOException
+ */
+ protected void _writeData(DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+ tid.write(outStream);
+ _location.write(outStream);
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java
new file mode 100644
index 00000000000..ce03dd264e2
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java
@@ -0,0 +1,115 @@
+/* MethodExitEvent.java -- an event specifying that a method has returned
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Notification from the VM that that a method has returned
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class MethodExitEvent
+ extends Event
+{
+ // The thread where the event occurred
+ private Thread _thread;
+
+ // the location where the event occurred
+ private Location _location;
+
+ // object instance
+ private Object _instance;
+
+ /**
+ * Constructs a new <code>MethodExitEvent</code>
+ *
+ * @param thread the thread where the exception occurred
+ * @param location the location single stepped to
+ * @param instance the instance from which the method was called
+ */
+ public MethodExitEvent(Thread thread, Location location, Object instance)
+ {
+ super(JdwpConstants.EventKind.METHOD_EXIT);
+ _thread = thread;
+ _location = location;
+ _instance = instance;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event. Valid types are
+ * thread and location
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or null
+ */
+ public Object getParameter(int type)
+ {
+ if (type == EVENT_THREAD)
+ return _thread;
+ else if (type == EVENT_LOCATION)
+ return _location;
+ else if (type == EVENT_CLASS)
+ return _instance.getClass();
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ * @throws IOException
+ */
+ protected void _writeData(DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+ tid.write(outStream);
+ _location.write(outStream);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java
new file mode 100644
index 00000000000..cd69dd99d6b
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java
@@ -0,0 +1,121 @@
+/* SingleStepEvent.java -- an event specifying that a single step has
+ compleated
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+
+/**
+ * Notification from the VM that a single step has compleated including the
+ * thread and location stepped to
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class SingleStepEvent
+ extends Event
+{
+ // the thread where the event occurred
+ private Thread _thread;
+
+ // the location where the event occurred
+ private Location _location;
+
+ //object instance
+ private Object _instance;
+
+ /**
+ * Constructs a new <code>SingleStepEvent</code>
+ *
+ * @param thread the thread where the exception occurred
+ * @param location the location single stepped to
+ * @param instance the instance in which the single step occurred
+ */
+ public SingleStepEvent(Thread thread, Location location, Object instance)
+ {
+ super(JdwpConstants.EventKind.SINGLE_STEP);
+ _thread = thread;
+ _location = location;
+ _instance = instance;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event. Valid types are
+ * thread and location
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or null
+ */
+ public Object getParameter(int type)
+ {
+ if (type == EVENT_THREAD)
+ return _thread;
+ else if (type == EVENT_LOCATION)
+ return _location;
+ else if (type == EVENT_INSTANCE)
+ return _instance;
+ else if (type == EVENT_CLASS)
+ return _instance.getClass();
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ * @throws IOException
+ */
+ protected void _writeData(DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId(_thread);
+
+ tid.write(outStream);
+ _location.write(outStream);
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java
index 768b216de0c..c665428fb6a 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java
@@ -81,9 +81,9 @@ public class ThreadEndEvent
* @param type the type of parameter desired
* @returns the desired parameter or <code>null</code>
*/
- public Object getParameter (Class type)
+ public Object getParameter (int type)
{
- if (type == ThreadId.class)
+ if (type == EVENT_THREAD)
return _thread;
return null;
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java
index 2fa20791716..f9c507dfb16 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java
@@ -86,9 +86,9 @@ public class ThreadStartEvent
* @param type the type of parameter desired
* @returns the desired parameter or <code>null</code>
*/
- public Object getParameter (Class type)
+ public Object getParameter (int type)
{
- if (type == ThreadId.class)
+ if (type == EVENT_THREAD)
return _thread;
return null;
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java
index 160ef6acea1..a729bd47ec0 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java
@@ -67,7 +67,7 @@ public class VmDeathEvent
* @param type the type of parameter desired
* @returns the desired parameter or <code>null</code>
*/
- public Object getParameter (Class type)
+ public Object getParameter (int type)
{
return null;
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java
index dd228e935cf..1ed63b24799 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java
@@ -76,7 +76,7 @@ public class VmInitEvent
* @param type the type of parameter desired
* @returns the desired parameter or <code>null</code>
*/
- public Object getParameter (Class type)
+ public Object getParameter (int type)
{
return null;
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
index 62a3a74fe54..a8984316957 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
@@ -41,7 +41,6 @@ package gnu.classpath.jdwp.event.filters;
import gnu.classpath.jdwp.event.Event;
import gnu.classpath.jdwp.exception.InvalidStringException;
-import gnu.classpath.jdwp.id.ReferenceTypeId;
/**
* An event filter which includes events matching a
@@ -91,7 +90,7 @@ public class ClassMatchFilter
*/
public boolean matches (Event event)
{
- Object type = event.getParameter (ReferenceTypeId.class);
+ Object type = event.getParameter (Event.EVENT_CLASS);
if (type != null)
{
Class eventClass = (Class) type;
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
index e4bf06cf961..455cac6c04c 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
@@ -87,7 +87,7 @@ public class ClassOnlyFilter
*/
public boolean matches (Event event)
{
- Object type = event.getParameter (ReferenceTypeId.class);
+ Object type = event.getParameter (Event.EVENT_CLASS);
if (type != null)
{
try
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
index cf6c0704daf..8bb56ed78f7 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
@@ -1,5 +1,5 @@
-/* ExceptionOnlyFilter.java --
- Copyright (C) 2005 Free Software Foundation
+/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type
+ Copyright (C) 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -61,7 +61,7 @@ public class ExceptionOnlyFilter
/**
* Constructs a new ExceptionOnlyFilter
*
- * @param refId ID of the exception to report
+ * @param refId ID of the exception to report(null for all exceptions)
* @param caught Report caught exceptions
* @param uncaught Report uncaught exceptions
* @throws InvalidClassException if refid is invalid
@@ -70,8 +70,8 @@ public class ExceptionOnlyFilter
boolean uncaught)
throws InvalidClassException
{
- if (refId == null || refId.getReference().get () == null)
- throw new InvalidClassException (refId.getId ());
+ if (refId != null && refId.getReference().get() == null)
+ throw new InvalidClassException(refId.getId());
_refId = refId;
_caught = caught;
@@ -88,34 +88,36 @@ public class ExceptionOnlyFilter
return _refId;
}
- /**
- * Report caught exceptions?
- *
- * @return whether to report caught exceptions
- */
- public boolean forCaught ()
- {
- return _caught;
- }
-
- /**
- * Report uncaught exceptions?
- *
- * @return whether to report uncaught exceptions
- */
- public boolean forUncaught ()
- {
- return _uncaught;
- }
-
+
/**
* Does the given event match the filter?
- *
- * @param event the <code>Event</code> to scrutinize
+ *
+ * @param event the <code>Event</code> to scrutinize
*/
- public boolean matches (Event event)
+ public boolean matches(Event event)
{
- // FIXME
- throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented");
+ boolean classMatch = true;
+
+ // if not allowing all exceptions check if the exception matches
+ if (_refId != null)
+ {
+ try
+ {
+ Class klass
+ = (Class) event.getParameter(Event.EVENT_EXCEPTION_CLASS);
+ classMatch = klass == _refId.getType();
+ }
+ catch (InvalidClassException ex)
+ {
+ classMatch = false;
+ }
+ }
+
+ // check against the caught and uncaught options
+ Boolean caught
+ = (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT);
+
+ return classMatch && ((caught.booleanValue()) ? _caught : _uncaught);
}
+
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
index 130749b4b8a..bda5b27d6c1 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
@@ -89,7 +89,7 @@ public class InstanceOnlyFilter
*/
public boolean matches (Event event)
{
- Object eventInstance = event.getParameter (ObjectId.class);
+ Object eventInstance = event.getParameter (Event.EVENT_INSTANCE);
if (eventInstance != null)
{
Object myInstance = _instance.getReference().get ();
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
index 2c7a0f1359e..bc1eab883d3 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
@@ -65,7 +65,7 @@ public class ThreadOnlyFilter
public ThreadOnlyFilter (ThreadId tid)
throws InvalidThreadException
{
- if (tid.getReference().get () == null)
+ if (tid == null || tid.getReference().get () == null)
throw new InvalidThreadException (tid.getId ());
_tid = tid;
@@ -88,7 +88,7 @@ public class ThreadOnlyFilter
*/
public boolean matches (Event event)
{
- Object thread = event.getParameter (ThreadId.class);
+ Object thread = event.getParameter (Event.EVENT_THREAD);
if (thread != null)
{
Thread eventThread = (Thread) thread;
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
index f60da7b7021..a3a7ca05e59 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
@@ -106,8 +106,12 @@ public class ClassTypeCommandSet
Class clazz = refId.getType();
Class superClazz = clazz.getSuperclass();
- ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
- clazzId.write(os);
+ if (superClazz == null) {
+ os.writeLong(0L);
+ } else {
+ ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
+ clazzId.write(os);
+ }
}
private void executeSetValues(ByteBuffer bb, DataOutputStream os)
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
index e4b1b602ef5..59cfb94d39b 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
@@ -147,7 +147,7 @@ public class EventRequestCommandSet
if (id == 0)
refId = null;
else
- refId = idMan.readReferenceTypeId(bb);
+ refId = idMan.getReferenceType(id);
boolean caught = (bb.get() == 0) ? false : true;
boolean unCaught = (bb.get() == 0) ? false : true;
filter = new ExceptionOnlyFilter(refId, caught, unCaught);
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java b/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java
index 9e281f217f2..4df3f472875 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java
@@ -1,6 +1,6 @@
/* PacketProcessor.java -- a thread which processes command packets
from the debugger
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -137,6 +137,10 @@ public class PacketProcessor
*/
public Object run ()
{
+ // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+ // the PacketProcessor thread is ready.
+ Jdwp.getDefault().subcomponentInitialized ();
+
try
{
while (!_shutdown)
@@ -144,7 +148,7 @@ public class PacketProcessor
_processOnePacket ();
}
}
- catch (IOException ex)
+ catch (Exception ex)
{
ex.printStackTrace();
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
index ba36251f665..103199a2b6e 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
@@ -103,8 +103,12 @@ public class ThreadGroupReferenceCommandSet
ObjectId oid = idMan.readObjectId(bb);
ThreadGroup group = (ThreadGroup) oid.getObject();
ThreadGroup parent = group.getParent();
- ObjectId parentId = idMan.getObjectId(parent);
- parentId.write(os);
+ if (parent == null) {
+ os.writeLong(0L);
+ } else {
+ ObjectId parentId = idMan.getObjectId(parent);
+ parentId.write(os);
+ }
}
private void executeChildren(ByteBuffer bb, DataOutputStream os)
diff --git a/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java b/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java
index f008bbd00ca..82a2380bb7b 100644
--- a/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java
+++ b/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java
@@ -1,5 +1,5 @@
/* JdwpConnection.java -- A JDWP-speaking connection
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -165,6 +165,10 @@ public class JdwpConnection
*/
public void run ()
{
+ // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+ // the JdwpConnection thread is ready.
+ Jdwp.getDefault().subcomponentInitialized ();
+
while (!_shutdown)
{
try
diff --git a/libjava/classpath/gnu/classpath/jdwp/util/Location.java b/libjava/classpath/gnu/classpath/jdwp/util/Location.java
index 005b12c2bb2..89e81e563a1 100644
--- a/libjava/classpath/gnu/classpath/jdwp/util/Location.java
+++ b/libjava/classpath/gnu/classpath/jdwp/util/Location.java
@@ -94,18 +94,40 @@ public class Location
* @param os stream to write to
* @throws IOException when an error occurs writing to the stream
*/
- public void write(DataOutputStream os)
+ public void write(DataOutputStream os)
throws IOException
{
- VMIdManager idm = VMIdManager.getDefault();
- ClassReferenceTypeId crti = (ClassReferenceTypeId)
- idm.getReferenceTypeId(method.getDeclaringClass());
-
- crti.writeTagged(os);
- method.writeId(os);
- os.writeLong(index);
+ // check if this is an empty location
+ if (method != null)
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ClassReferenceTypeId crti =
+ (ClassReferenceTypeId)
+ idm.getReferenceTypeId(method.getDeclaringClass());
+
+ crti.writeTagged(os);
+ method.writeId(os);
+ os.writeLong(index);
+ }
+ else
+ {
+ os.writeByte(1);
+ os.writeLong((long) 0);
+ os.writeLong((long) 0);
+ os.writeLong((long) 0);
+ }
}
-
+
+ /**
+ * Sets up an empty location
+ *
+ * @return new Location (setup as empty)
+ */
+ public static Location getEmptyLocation()
+ {
+ return new Location(null, 0);
+ }
+
/**
* Gets the method of this location
*
diff --git a/libjava/classpath/gnu/java/awt/ClasspathToolkit.java b/libjava/classpath/gnu/java/awt/ClasspathToolkit.java
index 1ec5664dc3e..968cc3b1643 100644
--- a/libjava/classpath/gnu/java/awt/ClasspathToolkit.java
+++ b/libjava/classpath/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.
@@ -41,7 +41,6 @@ package gnu.java.awt;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.peer.ClasspathFontPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
-import gnu.java.awt.peer.ClasspathTextLayoutPeer;
import gnu.java.security.action.SetAccessibleAction;
import java.awt.AWTException;
@@ -53,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;
@@ -120,10 +120,6 @@ public abstract class ClasspathToolkit
*/
public abstract ClasspathFontPeer getClasspathFontPeer (String name, Map attrs);
- public abstract ClasspathTextLayoutPeer
- getClasspathTextLayoutPeer (AttributedString str, FontRenderContext frc);
-
-
/**
* Creates a {@link Font}, in a platform-specific manner.
*
@@ -193,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;
@@ -206,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/libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java b/libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
new file mode 100644
index 00000000000..1f0c3ad2da6
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
@@ -0,0 +1,172 @@
+/* GtkMouseDragGestureRecognizer.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.dnd;
+
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.MouseDragGestureRecognizer;
+import java.awt.event.MouseEvent;
+
+public class GtkMouseDragGestureRecognizer
+ extends MouseDragGestureRecognizer
+{
+
+ public GtkMouseDragGestureRecognizer (DragSource ds)
+ {
+ this(ds, null, 0, null);
+ }
+
+ public GtkMouseDragGestureRecognizer (DragSource ds, Component c)
+ {
+ this (ds, c, 0, null);
+ }
+
+ public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act)
+ {
+ this(ds, c, act, null);
+ }
+
+ public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act,
+ DragGestureListener dgl)
+ {
+ super(ds, c, act, dgl);
+ }
+
+ public void registerListeners ()
+ {
+ super.registerListeners();
+ }
+
+ public void unregisterListeners ()
+ {
+ super.unregisterListeners();
+ }
+
+ public void mouseClicked (MouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ public void mousePressed (MouseEvent e)
+ {
+ events.clear();
+ if (getDropActionFromEvent(e) != DnDConstants.ACTION_NONE)
+ appendEvent(e);
+ }
+
+ public void mouseReleased (MouseEvent e)
+ {
+ events.clear();
+ }
+
+ public void mouseEntered (MouseEvent e)
+ {
+ events.clear();
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ if (!events.isEmpty())
+ if (getDropActionFromEvent(e) == DnDConstants.ACTION_NONE)
+ events.clear();
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ if (!events.isEmpty())
+ {
+ int act = getDropActionFromEvent(e);
+
+ if (act == DnDConstants.ACTION_NONE)
+ return;
+
+ Point origin = ((MouseEvent) events.get(0)).getPoint();
+ Point current = e.getPoint();
+ int dx = Math.abs(origin.x - current.x);
+ int dy = Math.abs(origin.y - current.y);
+ int threshold = DragSource.getDragThreshold();
+
+ if (dx > threshold || dy > threshold)
+ fireDragGestureRecognized(act, origin);
+ else
+ appendEvent(e);
+ }
+ }
+
+ public void mouseMoved (MouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ private int getDropActionFromEvent(MouseEvent e)
+ {
+ int modEx = e.getModifiersEx();
+ int buttons = modEx & (MouseEvent.BUTTON1_DOWN_MASK
+ | MouseEvent.BUTTON2_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK);
+ if (!(buttons == MouseEvent.BUTTON1_DOWN_MASK ||
+ buttons == MouseEvent.BUTTON2_DOWN_MASK))
+ return DnDConstants.ACTION_NONE;
+
+ // Convert modifier to a drop action
+ int sourceActions = getSourceActions();
+ int mod = modEx
+ & (MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK);
+ switch (mod)
+ {
+ case MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK:
+ return DnDConstants.ACTION_LINK & sourceActions;
+ case MouseEvent.CTRL_DOWN_MASK:
+ return DnDConstants.ACTION_COPY & sourceActions;
+ case MouseEvent.SHIFT_DOWN_MASK:
+ return DnDConstants.ACTION_MOVE & sourceActions;
+ default:
+ if ((sourceActions & DnDConstants.ACTION_MOVE) != 0)
+ return DnDConstants.ACTION_MOVE & sourceActions;
+ else if ((sourceActions & DnDConstants.ACTION_COPY) != 0)
+ return DnDConstants.ACTION_COPY & sourceActions;
+ else if ((sourceActions & DnDConstants.ACTION_LINK) != 0)
+ return DnDConstants.ACTION_LINK & sourceActions;
+ }
+
+ return DnDConstants.ACTION_NONE & sourceActions;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
new file mode 100644
index 00000000000..4f922982273
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
@@ -0,0 +1,174 @@
+/* GtkDragSourceContextPeer.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
+
+public class GtkDragSourceContextPeer
+ extends GtkGenericPeer
+ implements DragSourceContextPeer
+{
+ private ComponentPeer peer;
+ private Cursor cursor;
+ private DragSourceContext context;
+
+ native void nativeStartDrag(Image i, int x, int y, int action, String target);
+ native void connectSignals(ComponentPeer comp);
+ native void create(ComponentPeer comp);
+ native void nativeSetCursor(int cursor);
+
+ public GtkDragSourceContextPeer(DragGestureEvent e)
+ {
+ super(e.getComponent());
+ Component comp = e.getComponent();
+ peer = getComponentPeer(comp);
+
+ create(peer);
+ connectSignals(peer);
+ cursor = comp.getCursor();
+ }
+
+ ComponentPeer getComponentPeer(Component c)
+ {
+ Component curr = c;
+ while (curr.getPeer() instanceof LightweightPeer)
+ curr = curr.getParent();
+
+ if (curr != null)
+ return curr.getPeer();
+ return null;
+ }
+
+ public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
+ throws InvalidDnDOperationException
+ {
+ this.context = context;
+
+ if (p == null)
+ p = new Point();
+
+ // FIXME: use proper DataFlavor, not "text/plain".
+ // Also, add check to determine if dragging.
+
+ setCursor(c);
+ nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
+ "text/plain");
+ }
+
+ public Cursor getCursor()
+ {
+ return cursor;
+ }
+
+ public void setCursor(Cursor c) throws InvalidDnDOperationException
+ {
+ if (c != null)
+ {
+ nativeSetCursor(c.getType());
+ cursor = c;
+ }
+ }
+
+ public void transferablesFlavorsChanged()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Called from native code.
+ */
+
+ public void dragEnter(int action, int modifiers)
+ {
+ context.dragEnter(new DragSourceDragEvent(context, action,
+ action
+ & context.getSourceActions(),
+ modifiers));
+ }
+
+ public void dragExit(int action, int x, int y)
+ {
+ context.dragExit(new DragSourceEvent(context, x, y));
+ }
+
+ public void dragDropEnd(int action, boolean success, int x, int y)
+ {
+ context.dragDropEnd(new DragSourceDropEvent(context, action, success, x, y));
+ }
+
+ public void dragMouseMoved(int action, int modifiers)
+ {
+ context.dragMouseMoved(new DragSourceDragEvent(context,
+ action,
+ action
+ & context.getSourceActions(),
+ modifiers));
+ }
+
+ public void dragOver(int action, int modifiers)
+ {
+ context.dragOver(new DragSourceDragEvent(context, action,
+ action
+ & context.getSourceActions(),
+ modifiers));
+ }
+
+ public void dragActionChanged(int newAction, int modifiers)
+ {
+ context.dropActionChanged(new DragSourceDragEvent(context,
+ newAction,
+ newAction
+ & context.getSourceActions(),
+ modifiers));
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java
new file mode 100644
index 00000000000..50cd95d41ad
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java
@@ -0,0 +1,125 @@
+/* GtkDropTargetContextPeer.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DropTargetContextPeer;
+
+public class GtkDropTargetContextPeer
+ extends GtkGenericPeer
+ implements DropTargetContextPeer
+{
+
+ public GtkDropTargetContextPeer()
+ {
+ super(null);
+ }
+
+ public void setTargetActions(int actions)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public int getTargetActions()
+ {
+ // FIXME: Not Implemented
+ return 0;
+ }
+
+ public DropTarget getDropTarget()
+ {
+ // FIXME: Not Implemented
+ return null;
+ }
+
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ // FIXME: Not Implemented
+ return null;
+ }
+
+ public Transferable getTransferable() throws InvalidDnDOperationException
+ {
+ // FIXME: Not Implemented
+ return null;
+ }
+
+ public boolean isTransferableJVMLocal()
+ {
+ // FIXME: Not Implemented
+ return false;
+ }
+
+ public void acceptDrag(int dragAction)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public void rejectDrag()
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public void acceptDrop(int dropAction)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public void rejectDrop()
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public void dropComplete(boolean success)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java
new file mode 100644
index 00000000000..88b75ad96ee
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java
@@ -0,0 +1,68 @@
+/* GtkDropTargetPeer.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.dnd.peer.gtk;
+
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.peer.DropTargetPeer;
+
+public class GtkDropTargetPeer
+ extends GtkGenericPeer
+ implements DropTargetPeer
+{
+
+ public GtkDropTargetPeer()
+ {
+ super(null);
+ }
+
+ public void addDropTarget(DropTarget target)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+ public void removeDropTarget(DropTarget target)
+ {
+ // FIXME: Not Implemented
+
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java b/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
index f057d8b237d..9d017240d60 100644
--- a/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
+++ b/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
@@ -39,6 +39,7 @@ package gnu.java.awt.java2d;
import java.awt.AWTError;
import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
@@ -72,6 +73,7 @@ import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
import java.awt.image.ImageObserver;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
@@ -144,7 +146,7 @@ public abstract class AbstractGraphics2D
/**
* The transformation for this Graphics2D instance
*/
- private AffineTransform transform;
+ protected AffineTransform transform;
/**
* The foreground.
@@ -539,6 +541,15 @@ public abstract class AbstractGraphics2D
*/
public void setComposite(Composite comp)
{
+ if (! (comp instanceof AlphaComposite))
+ {
+ // FIXME: this check is only required "if this Graphics2D
+ // context is drawing to a Component on the display screen".
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new AWTPermission("readDisplayPixels"));
+ }
+
composite = comp;
if (! (comp.equals(AlphaComposite.SrcOver)))
isOptimized = false;
@@ -2054,7 +2065,34 @@ public abstract class AbstractGraphics2D
*
* @return the destination raster
*/
- protected abstract WritableRaster getDestinationRaster();
+ protected WritableRaster getDestinationRaster()
+ {
+ // TODO: Ideally we would fetch the xdrawable's surface pixels for
+ // initialization of the raster.
+ Rectangle db = getDeviceBounds();
+ if (destinationRaster == null)
+ {
+ int[] bandMasks = new int[]{ 0xFF0000, 0xFF00, 0xFF };
+ destinationRaster = Raster.createPackedRaster(DataBuffer.TYPE_INT,
+ db.width, db.height,
+ bandMasks, null);
+ // Initialize raster with white.
+ int x0 = destinationRaster.getMinX();
+ int x1 = destinationRaster.getWidth() + x0;
+ int y0 = destinationRaster.getMinY();
+ int y1 = destinationRaster.getHeight() + y0;
+ int numBands = destinationRaster.getNumBands();
+ for (int y = y0; y < y1; y++)
+ {
+ for (int x = x0; x < x1; x++)
+ {
+ for (int b = 0; b < numBands; b++)
+ destinationRaster.setSample(x, y, b, 255);
+ }
+ }
+ }
+ return destinationRaster;
+ }
/**
* Notifies the backend that the raster has changed in the specified
diff --git a/libjava/classpath/gnu/java/awt/java2d/CubicSegment.java b/libjava/classpath/gnu/java/awt/java2d/CubicSegment.java
index 1e568f722e7..bf66be870c0 100644
--- a/libjava/classpath/gnu/java/awt/java2d/CubicSegment.java
+++ b/libjava/classpath/gnu/java/awt/java2d/CubicSegment.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.java.awt.java2d;
+import java.awt.geom.CubicCurve2D;
import java.awt.geom.Point2D;
/**
@@ -78,34 +79,89 @@ 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;
}
/**
- * Get the "top" and "bottom" segments of this segment.
- * First array element is p0 + normal, second is p0 - normal.
+ * Get the "top" and "bottom" segments of this segment. First array element is
+ * p0 + normal, second is p0 - normal.
*/
public Segment[] getDisplacedSegments(double radius)
{
+ // It is, apparently, impossible to derive a curve parallel to a bezier
+ // curve (unless it's a straight line), so we have no choice but to
+ // approximate the displaced segments. Similar to FlattenPathIterator.
+
+ Segment segmentTop = null;
+ Segment segmentBottom = null;
this.radius = radius;
- double x0 = P1.getX();
- double y0 = P1.getY();
- double x1 = cp1.getX();
- double y1 = cp1.getY();
- double x2 = cp2.getX();
- double y2 = cp2.getY();
- double x3 = P2.getX();
- double y3 = P2.getY();
- 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];
+ CubicCurve2D[] curves = new CubicCurve2D[10];
+ curves[0] = new CubicCurve2D.Double(P1.getX(), P1.getY(), cp1.getX(),
+ cp1.getY(), cp2.getX(), cp2.getY(),
+ P2.getX(), P2.getY());
+ int numCurves = 1;
+
+ // Hard-coded a recursion limit of 10 and flatness of 1... should we make
+ // this an option somewhere?
+ while (numCurves > 0)
+ {
+ // The curve is flat enough, or we've reached our recursion limit,
+ // so take the current start/end points and add it as a line segment
+ // to our final approximated curves
+ if (curves[numCurves - 1].getFlatnessSq() <= (radius / 3) || numCurves == 10)
+ {
+ Segment[] displaced = new LineSegment(
+ curves[numCurves - 1].getP1(),
+ curves[numCurves - 1].getP2()).getDisplacedSegments(radius);
+ if (segmentTop == null)
+ {
+ segmentTop = displaced[0];
+ segmentBottom = displaced[1];
+ }
+ else
+ {
+ segmentTop.add(displaced[0]);
+ segmentBottom.add(displaced[1]);
+ }
+ numCurves--;
+ }
+
+ // Otherwise, subdivide again and continue
+ else
+ {
+ CubicCurve2D left = new CubicCurve2D.Double();
+ CubicCurve2D right = new CubicCurve2D.Double();
+ curves[numCurves - 1].subdivide(left, right);
+ curves[numCurves - 1] = right;
+ curves[numCurves] = left;
+ curves[numCurves - 1] = right;
+ curves[numCurves] = left;
+ numCurves++;
+ }
+ }
+
+ return new Segment[] { segmentTop, segmentBottom };
}
-
+
public void reverse()
{
Point2D temp = P1;
@@ -116,12 +172,12 @@ public class CubicSegment extends Segment
cp2 = temp;
}
- public double[] first()
+ public double[] cp1()
{
return new double[]{cp1.getX(), cp1.getY()};
}
- public double[] last()
+ public double[] cp2()
{
return new double[]{cp2.getX(), cp2.getY()};
}
diff --git a/libjava/classpath/gnu/java/awt/java2d/LineSegment.java b/libjava/classpath/gnu/java/awt/java2d/LineSegment.java
index 9c0bcc7eae0..0395fd0af7b 100644
--- a/libjava/classpath/gnu/java/awt/java2d/LineSegment.java
+++ b/libjava/classpath/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;
}
/**
@@ -91,12 +106,12 @@ public class LineSegment extends Segment
P2 = p;
}
- public double[] first()
+ public double[] cp1()
{
return new double[]{P2.getX(), P2.getY()};
}
- public double[] last()
+ public double[] cp2()
{
return new double[]{P1.getX(), P1.getY()};
}
diff --git a/libjava/classpath/gnu/java/awt/java2d/QuadSegment.java b/libjava/classpath/gnu/java/awt/java2d/QuadSegment.java
index 9c15a8cfda0..5e15fe881d8 100644
--- a/libjava/classpath/gnu/java/awt/java2d/QuadSegment.java
+++ b/libjava/classpath/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;
}
/**
@@ -201,12 +217,12 @@ public class QuadSegment extends Segment
P2 = p;
}
- public double[] first()
+ public double[] cp1()
{
return new double[]{cp.getX(), cp.getY()};
}
- public double[] last()
+ public double[] cp2()
{
return new double[]{cp.getX(), cp.getY()};
}
diff --git a/libjava/classpath/gnu/java/awt/java2d/Segment.java b/libjava/classpath/gnu/java/awt/java2d/Segment.java
index 9a985f6967b..df1f67605d0 100644
--- a/libjava/classpath/gnu/java/awt/java2d/Segment.java
+++ b/libjava/classpath/gnu/java/awt/java2d/Segment.java
@@ -42,24 +42,38 @@ import java.awt.geom.Point2D;
public abstract class Segment implements Cloneable
{
- // segment type, PathIterator segment types are used.
+ // Start and end points of THIS segment
public Point2D P1;
public Point2D P2;
+
+ // Segments can be linked together internally as a linked list
+ public Segment first;
public Segment next;
public Segment last;
+
+ // Half the stroke width
protected double radius;
+ /**
+ * Create a new, empty segment
+ */
public Segment()
{
P1 = P2 = null;
+ first = this;
next = null;
last = this;
}
+ /**
+ * Add a segment to the polygon
+ * @param newsegment segment to add
+ */
public void add(Segment newsegment)
{
+ newsegment.first = first;
last.next = newsegment;
- last = last.next;
+ last = last.next.last;
}
/**
@@ -68,6 +82,7 @@ public abstract class Segment implements Cloneable
public void reverseAll()
{
reverse();
+ first = last;
Segment v = next;
Segment former = this;
next = null;
@@ -91,7 +106,7 @@ public abstract class Segment implements Cloneable
/**
* Get the normal vector to the slope of the line.
- * Returns: 0.5*width*(norm of derivative of the (x0,y0)-(x1,y1) vector)
+ * @return vector of length radius, normal to the (x0,y0)-(x1,y1) vector)
*/
protected double[] normal(double x0, double y0, double x1, double y1)
{
@@ -117,6 +132,9 @@ public abstract class Segment implements Cloneable
return new double[]{ dx, dy };
}
+ /**
+ * Reverse the current segment
+ */
public abstract void reverse();
/**
@@ -125,7 +143,16 @@ public abstract class Segment implements Cloneable
*/
public abstract Segment[] getDisplacedSegments(double radius);
- public abstract double[] first();
- public abstract double[] last();
+ /**
+ * Returns the coordinates of the first control point, or the start point
+ * for a line segment.
+ */
+ public abstract double[] cp1();
+
+ /**
+ * Returns the coordinates of the second control point, or the end point
+ * for a line segment.
+ */
+ public abstract double[] cp2();
}
diff --git a/libjava/classpath/gnu/java/awt/peer/ClasspathFontPeer.java b/libjava/classpath/gnu/java/awt/peer/ClasspathFontPeer.java
index 78ab3a9de21..dad7bb0b08f 100644
--- a/libjava/classpath/gnu/java/awt/peer/ClasspathFontPeer.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java b/libjava/classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java
deleted file mode 100644
index 70df2ef74ef..00000000000
--- a/libjava/classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ClasspathTextLayoutPeer.java
- Copyright (C) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 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;
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.font.TextHitInfo;
-import java.awt.font.TextLayout;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-
-/**
- * @author Graydon Hoare
- */
-
-public interface ClasspathTextLayoutPeer
-{
- TextHitInfo getStrongCaret (TextHitInfo hit1,
- TextHitInfo hit2);
-
- void draw (Graphics2D g2, float x, float y);
-
- byte getBaseline ();
-
- boolean isLeftToRight ();
- boolean isVertical ();
-
- float getAdvance ();
- float getAscent ();
- float getDescent ();
- float getLeading ();
-
- int getCharacterCount ();
- byte getCharacterLevel (int index);
-
- float[] getBaselineOffsets ();
- Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint);
- Rectangle2D getBounds ();
-
- float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds);
- Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds);
- Shape[] getCaretShapes (int offset, Rectangle2D bounds,
- TextLayout.CaretPolicy policy);
-
- Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
- Rectangle2D bounds);
- int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint,
- TextHitInfo secondEndpoint);
-
- TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy);
- TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy);
- TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds);
- TextHitInfo getVisualOtherHit (TextHitInfo hit);
-
- float getVisibleAdvance ();
- Shape getOutline (AffineTransform tx);
- Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
- TextHitInfo secondEndpoint,
- Rectangle2D bounds);
-
- TextLayout getJustifiedLayout (float justificationWidth);
- void handleJustify (float justificationWidth);
-
- Object clone ();
- int hashCode ();
- boolean equals (ClasspathTextLayoutPeer tl);
- String toString ();
-}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
index d9d300d9103..6a74eabc5d6 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -40,10 +40,8 @@ package gnu.java.awt.peer.gtk;
import java.awt.Color;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
-import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.font.GlyphVector;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
index 9f8f494eb41..b665f562e25 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
@@ -40,6 +40,7 @@ package gnu.java.awt.peer.gtk;
import gnu.java.awt.ClasspathToolkit;
+import java.awt.AWTPermission;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -52,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;
@@ -65,8 +66,8 @@ 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.Line2D;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
@@ -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
@@ -427,6 +445,46 @@ public abstract class CairoGraphics2D extends Graphics2D
*/
private native void cairoSurfaceSetFilter(long pointer, int filter);
+ /**
+ * Draws a line from (x1,y1) to (x2,y2).
+ *
+ * @param pointer the native pointer
+ *
+ * @param x1 the x coordinate of the starting point
+ * @param y1 the y coordinate of the starting point
+ * @param x2 the x coordinate of the end point
+ * @param y2 the y coordinate of the end point
+ */
+ private native void cairoDrawLine(long pointer, double x1, double y1,
+ double x2, double y2);
+
+ /**
+ * Draws a rectangle at starting point (x,y) and with the specified width
+ * and height.
+ *
+ * @param pointer the native pointer
+ * @param x the x coordinate of the upper left corner
+ * @param y the y coordinate of the upper left corner
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ */
+ private native void cairoDrawRect(long pointer, double x, double y, double w,
+ double h);
+
+ /**
+ * Fills a rectangle at starting point (x,y) and with the specified width
+ * and height.
+ *
+ * @param pointer the native pointer
+ * @param x the x coordinate of the upper left corner
+ * @param y the y coordinate of the upper left corner
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ */
+ private native void cairoFillRect(long pointer, double x, double y, double w,
+ double h);
+
+
///////////////////////// TRANSFORMS ///////////////////////////////////
/**
* Set the current transform
@@ -625,8 +683,8 @@ public abstract class CairoGraphics2D extends Graphics2D
int width = (int) tp.getAnchorRect().getWidth();
int height = (int) tp.getAnchorRect().getHeight();
- double scaleX = (width+1) / (double) img.getWidth();
- double scaleY = (height+1) / (double) img.getHeight();
+ double scaleX = width / (double) img.getWidth();
+ double scaleY = height / (double) img.getHeight();
AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
@@ -737,7 +795,7 @@ public abstract class CairoGraphics2D extends Graphics2D
else
{
GeneralPath p = new GeneralPath();
- PathIterator pi = clip.getPathIterator(new AffineTransform());
+ PathIterator pi = clip.getPathIterator(null);
p.append(pi, false);
return p;
}
@@ -847,6 +905,12 @@ public abstract class CairoGraphics2D extends Graphics2D
}
else
{
+ // FIXME: this check is only required "if this Graphics2D
+ // context is drawing to a Component on the display screen".
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new AWTPermission("readDisplayPixels"));
+
// FIXME: implement general Composite support
throw new java.lang.UnsupportedOperationException();
}
@@ -857,54 +921,79 @@ public abstract class CairoGraphics2D extends Graphics2D
public void draw(Shape s)
{
if ((stroke != null && ! (stroke instanceof BasicStroke))
- || (comp instanceof AlphaComposite
- && ((AlphaComposite) comp).getAlpha() != 1.0))
+ || (comp instanceof AlphaComposite && ((AlphaComposite) comp).getAlpha() != 1.0))
{
- // FIXME: This is a hack to work around BasicStrokes's current
- // limitations wrt cubic curves.
- // See CubicSegment.getDisplacedSegments().
- if (stroke instanceof BasicStroke)
- {
- PathIterator flatten = s.getPathIterator(new AffineTransform(),
- 1.0);
- GeneralPath p = new GeneralPath();
- p.append(flatten, false);
- s = p;
- }
- fill(stroke.createStrokedShape(s));
- return;
+ // Cairo doesn't support stroking with alpha, so we create the stroked
+ // shape and fill with alpha instead
+ fill(stroke.createStrokedShape(s));
+ 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);
}
/**
@@ -940,12 +1029,19 @@ public abstract class CairoGraphics2D extends Graphics2D
public void drawLine(int x1, int y1, int x2, int y2)
{
- draw(new Line2D.Double(x1, y1, x2, y2));
+ // The coordinates being pairwise identical means one wants
+ // to draw a single pixel. This is emulated by drawing
+ // a one pixel sized rectangle.
+ if (x1 == x2 && y1 == y2)
+ cairoFillRect(nativePointer, x1, y1, 1, 1);
+ else
+ cairoDrawLine(nativePointer, x1 + 0.5, y1 + 0.5, x2 + 0.5, y2 + 0.5);
}
public void drawRect(int x, int y, int width, int height)
{
- draw(new Rectangle(x, y, width, height));
+ cairoDrawRect(nativePointer, shifted(x, shiftDrawCalls),
+ shifted(y, shiftDrawCalls), width, height);
}
public void fillArc(int x, int y, int width, int height, int startAngle,
@@ -958,7 +1054,7 @@ public abstract class CairoGraphics2D extends Graphics2D
public void fillRect(int x, int y, int width, int height)
{
- fill(new Rectangle(x, y, width, height));
+ cairoFillRect(nativePointer, x, y, width, height);
}
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
@@ -1137,6 +1233,9 @@ public abstract class CairoGraphics2D extends Graphics2D
if (img == null)
return false;
+ if (xform == null)
+ xform = new AffineTransform();
+
// In this case, xform is an AffineTransform that transforms bounding
// box of the specified image from image space to user space. However
// when we pass this transform to cairo, cairo will use this transform
@@ -1160,6 +1259,7 @@ public abstract class CairoGraphics2D extends Graphics2D
// Note - this can get us in trouble when the gdk lock is re-acquired.
// for example by VolatileImage. See ComponentGraphics for how we work
// around this.
+
if( !(img instanceof BufferedImage) )
{
ImageProducer source = img.getSource();
@@ -1176,6 +1276,7 @@ public abstract class CairoGraphics2D extends Graphics2D
// If this BufferedImage has a BufferedImageGraphics object,
// use the cached CairoSurface that BIG is drawing onto
+
if( BufferedImageGraphics.bufferedImages.get( b ) != null )
db = (DataBuffer)BufferedImageGraphics.bufferedImages.get( b );
else
@@ -1190,6 +1291,7 @@ public abstract class CairoGraphics2D extends Graphics2D
if(db instanceof CairoSurface)
{
((CairoSurface)db).drawSurface(nativePointer, i2u, alpha);
+ updateColor();
return true;
}
@@ -1206,24 +1308,7 @@ public abstract class CairoGraphics2D extends Graphics2D
setPaint( oldPaint );
}
- int[] pixels;
-
- // Shortcut for easy color models.
- if( b.getColorModel().equals(rgb32) )
- {
- pixels = ((DataBufferInt)db).getData();
- for(int i = 0; i < pixels.length; i++)
- pixels[i] |= 0xFF000000;
- }
- else if( b.getColorModel().equals(argb32) )
- {
- pixels = ((DataBufferInt)db).getData();
- }
- else
- {
- pixels = b.getRGB(0, 0, width, height,
- null, 0, width);
- }
+ int[] pixels = b.getRGB(0, 0, width, height, null, 0, width);
drawPixels(nativePointer, pixels, width, height, width, i2u, alpha);
@@ -1249,7 +1334,9 @@ public abstract class CairoGraphics2D extends Graphics2D
public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
{
- Image filtered = op.filter(image, null);
+ Image filtered = image;
+ if (op != null)
+ filtered = op.filter(image, null);
drawImage(filtered, new AffineTransform(1f, 0f, 0f, 1f, x, y), null, null);
}
@@ -1317,7 +1404,7 @@ public abstract class CairoGraphics2D extends Graphics2D
else
{ cy = dy2; ch = dy1 - dy2; }
- setClip( cx, cy, cw, ch );
+ clipRect( cx, cy, cw, ch );
AffineTransform tx = new AffineTransform();
tx.translate( dx1 - sx1*scaleX, dy1 - sy1*scaleY );
@@ -1358,6 +1445,10 @@ public abstract class CairoGraphics2D extends Graphics2D
public void drawGlyphVector(GlyphVector gv, float x, float y)
{
double alpha = 1.0;
+
+ if( gv.getNumGlyphs() <= 0 )
+ return;
+
if (comp instanceof AlphaComposite)
alpha = ((AlphaComposite) comp).getAlpha();
if (gv instanceof FreetypeGlyphVector && alpha == 1.0)
@@ -1367,8 +1458,11 @@ public abstract class CairoGraphics2D extends Graphics2D
float[] positions = gv.getGlyphPositions (0, n, null);
setFont (gv.getFont ());
- cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
- x, y, n, codes, positions);
+ synchronized( this.font )
+ {
+ cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
+ x, y, n, codes, positions);
+ }
}
else
{
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
index 5ccd2e14eb9..78bc1e02db0 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
@@ -38,26 +38,16 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Graphics;
-import java.awt.Color;
-import java.awt.Image;
import java.awt.Point;
import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
-import java.io.File;
-import java.io.IOException;
+import java.nio.ByteOrder;
import java.util.Hashtable;
-import java.util.Vector;
-import java.io.ByteArrayOutputStream;
-import java.io.BufferedInputStream;
-import java.net.URL;
-import gnu.classpath.Pointer;
/**
* CairoSurface - wraps a Cairo surface.
@@ -79,10 +69,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);
/**
@@ -177,28 +167,45 @@ public class CairoSurface extends DataBuffer
height = image.height;
create(width, height, width);
-
+
if(surfacePointer == 0 || bufferPointer == 0)
throw new Error("Could not allocate bitmap.");
-
+
// Copy the pixel data from the GtkImage.
int[] data = image.getPixels();
// Swap ordering from GdkPixbuf to Cairo
- for(int i = 0; i < data.length; i++ )
+ if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
+ {
+ for (int i = 0; i < data.length; i++ )
+ {
+ // On a big endian system we get a RRGGBBAA data array.
+ int alpha = data[i] & 0xFF;
+ if( alpha == 0 ) // I do not know why we need this, but it works.
+ data[i] = 0;
+ else
+ {
+ // Cairo needs a ARGB32 native array.
+ data[i] = (data[i] >>> 8) | (alpha << 24);
+ }
+ }
+ }
+ else
{
- int alpha = (data[i] & 0xFF000000) >> 24;
- if( alpha == 0 ) // I do not know why we need this, but it works.
- data[i] = 0;
- else
+ for (int i = 0; i < data.length; i++ )
{
- int r = (((data[i] & 0x00FF0000) >> 16) );
- int g = (((data[i] & 0x0000FF00) >> 8) );
- int b = ((data[i] & 0x000000FF) );
- data[i] = (( alpha << 24 ) & 0xFF000000)
- | (( b << 16 ) & 0x00FF0000)
- | (( g << 8 ) & 0x0000FF00)
- | ( r & 0x000000FF);
+ // On a little endian system we get a AABBGGRR data array.
+ int alpha = data[i] & 0xFF000000;
+ if( alpha == 0 ) // I do not know why we need this, but it works.
+ data[i] = 0;
+ else
+ {
+ int b = (data[i] & 0xFF0000) >> 16;
+ int g = (data[i] & 0xFF00);
+ int r = (data[i] & 0xFF) << 16;
+ // Cairo needs a ARGB32 native array.
+ data[i] = alpha | r | g | b;
+ }
}
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
index 91f0b4981df..7bd136c3845 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
@@ -39,14 +39,9 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Graphics;
-import java.awt.Color;
import java.awt.GraphicsEnvironment;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.geom.Rectangle2D;
-import java.awt.image.*;
/**
* Implementation of Graphics2D on a Cairo surface.
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
index d1d3c280454..ffa78e9c904 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Color;
-import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
@@ -47,16 +46,14 @@ import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
-import java.awt.Point;
-import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
-import java.awt.image.ImagingOpException;
import java.awt.image.RenderedImage;
+import gnu.classpath.Pointer;
/**
* ComponentGraphics - context for drawing directly to a component,
@@ -66,6 +63,8 @@ import java.awt.image.RenderedImage;
*/
public class ComponentGraphics extends CairoGraphics2D
{
+ private static final boolean hasXRenderExtension = hasXRender();
+
private GtkComponentPeer component;
protected long cairo_t;
@@ -164,13 +163,27 @@ public class ComponentGraphics extends CairoGraphics2D
*/
public static native boolean hasXRender();
+ /**
+ * This is a utility method (used by GtkComponentPeer) for grabbing the
+ * image of a component.
+ */
+ private static native Pointer nativeGrab(GtkComponentPeer component);
private native void copyAreaNative(GtkComponentPeer component, int x, int y,
int width, int height, int dx, int dy);
private native void drawVolatile(GtkComponentPeer component,
long vimg, int x, int y,
- int width, int height);
+ int width, int height, int cx, int cy,
+ int cw, int ch);
+
+ /**
+ * Not really related (moveme?). Utility method used by GtkComponent.
+ */
+ public static GtkImage grab( GtkComponentPeer component )
+ {
+ return new GtkImage( nativeGrab( component ) );
+ }
/**
* Returns a Graphics2D object for a component, either an instance of this
@@ -178,7 +191,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();
@@ -285,21 +298,24 @@ public class ComponentGraphics extends CairoGraphics2D
if (img instanceof GtkVolatileImage)
{
GtkVolatileImage vimg = (GtkVolatileImage) img;
- int type = transform.getType();
- if (type == AffineTransform.TYPE_IDENTITY)
- {
- drawVolatile(component, vimg.nativePointer,
- x, y, vimg.width, vimg.height);
- return true;
- }
- else if (type == AffineTransform.TYPE_TRANSLATION)
- {
- x += transform.getTranslateX();
- y += transform.getTranslateY();
- drawVolatile(component, vimg.nativePointer,
- x, y, vimg.width, vimg.height);
- return true;
- }
+ int type = transform.getType();
+ if ((type == AffineTransform.TYPE_IDENTITY
+ || type == AffineTransform.TYPE_TRANSLATION)
+ && (clip == null || clip instanceof Rectangle2D))
+ {
+ Rectangle2D r = (Rectangle2D) clip;
+ if (r == null)
+ r = getRealBounds();
+ x += transform.getTranslateX();
+ y += transform.getTranslateY();
+ drawVolatile(component, vimg.nativePointer,
+ x, y, vimg.width, vimg.height,
+ (int) (r.getX() + transform.getTranslateX()),
+ (int) (r.getY() + transform.getTranslateY()),
+ (int) r.getWidth(),
+ (int) r.getHeight());
+ return true;
+ }
else
return super.drawImage(vimg.getSnapshot(), x, y, observer);
}
@@ -323,24 +339,28 @@ public class ComponentGraphics extends CairoGraphics2D
// If it is a GtkVolatileImage with an "easy" transform then
// draw directly. Always pass a BufferedImage to super to avoid
// deadlock (see Note in CairoGraphics.drawImage()).
- if (img instanceof GtkVolatileImage)
+ if (img instanceof GtkVolatileImage
+ && (clip == null || clip instanceof Rectangle2D))
{
GtkVolatileImage vimg = (GtkVolatileImage) img;
- int type = transform.getType();
- if (type == AffineTransform.TYPE_IDENTITY)
- {
- drawVolatile(component, vimg.nativePointer,
- x, y, width, height);
- return true;
- }
- else if (type == AffineTransform.TYPE_TRANSLATION)
- {
- x += transform.getTranslateX();
- y += transform.getTranslateY();
- drawVolatile(component, vimg.nativePointer,
- x, y, width, height);
- return true;
- }
+ int type = transform.getType();
+ if ((type == AffineTransform.TYPE_IDENTITY
+ || type == AffineTransform.TYPE_TRANSLATION)
+ && (clip == null || clip instanceof Rectangle2D))
+ {
+ Rectangle2D r = (Rectangle2D) clip;
+ if (r == null)
+ r = getRealBounds();
+ x += transform.getTranslateX();
+ y += transform.getTranslateY();
+ drawVolatile(component, vimg.nativePointer,
+ x, y, width, height,
+ (int) (r.getX() + transform.getTranslateX()),
+ (int) (r.getY() + transform.getTranslateY()),
+ (int) r.getWidth(),
+ (int) r.getHeight());
+ return true;
+ }
else
return super.drawImage(vimg.getSnapshot(), x, y,
width, height, observer);
@@ -359,5 +379,57 @@ public class ComponentGraphics extends CairoGraphics2D
return super.drawImage(bimg, x, y, width, height, observer);
}
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ lock();
+ try
+ {
+ super.drawLine(x1, y1, x2, y2);
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ public void drawRect(int x, int y, int width, int height)
+ {
+ lock();
+ try
+ {
+ super.drawRect(x, y, width, height);
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ public void fillRect(int x, int y, int width, int height)
+ {
+ lock();
+ try
+ {
+ super.fillRect(x, y, width, height);
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ public void setClip(Shape s)
+ {
+ lock();
+ try
+ {
+ super.setClip(s);
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
index 286fbeac060..2216d459a0e 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
@@ -39,17 +39,11 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
import java.awt.Image;
-import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBuffer;
import java.awt.image.RenderedImage;
import java.awt.image.ImageObserver;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java b/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
index 4978c6a4557..2c9d917934f 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
@@ -137,6 +137,35 @@ public class FreetypeGlyphVector extends GlyphVector
}
/**
+ * Cloning constructor
+ */
+ private FreetypeGlyphVector( FreetypeGlyphVector gv )
+ {
+ font = gv.font;
+ peer = gv.peer;
+ frc = gv.frc;
+ s = gv.s;
+ nGlyphs = gv.nGlyphs;
+ logicalBounds = gv.logicalBounds.getBounds2D();
+
+ if( gv.metricsCache != null )
+ {
+ metricsCache = new GlyphMetrics[ nGlyphs ];
+ System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs);
+ }
+
+ glyphCodes = new int[ nGlyphs ];
+ glyphPositions = new float[ nGlyphs ];
+ glyphTransforms = new AffineTransform[ nGlyphs ];
+ for(int i = 0; i < nGlyphs; i++ )
+ {
+ glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
+ glyphCodes[i] = gv.glyphCodes[ i ];
+ glyphPositions[i] = gv.glyphPositions[ i ];
+ }
+ }
+
+ /**
* Create the array of glyph codes.
*/
private void getGlyphs()
@@ -172,6 +201,12 @@ public class FreetypeGlyphVector extends GlyphVector
private native GeneralPath getGlyphOutlineNative(int glyphIndex);
+
+ public Object clone()
+ {
+ return new FreetypeGlyphVector( this );
+ }
+
/**
* Duh, compares two instances.
*/
@@ -260,8 +295,11 @@ public class FreetypeGlyphVector extends GlyphVector
if( gm == null )
return null;
Rectangle2D r = gm.getBounds2D();
- return new Rectangle2D.Double( r.getX() - gm.getLSB(), r.getY(),
- gm.getAdvanceX(), r.getHeight() );
+ Point2D p = getGlyphPosition( glyphIndex );
+ return new Rectangle2D.Double( p.getX() + r.getX() - gm.getLSB(),
+ p.getY() + r.getY(),
+ gm.getAdvanceX(),
+ r.getHeight() );
}
/*
@@ -385,8 +423,6 @@ public class FreetypeGlyphVector extends GlyphVector
for( int i = 1; i < nGlyphs; i++ )
{
Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
- Point2D p = getGlyphPosition( i );
- r2.setRect( p.getX(), p.getY(), r2.getWidth(), r2.getHeight() );
rect = rect.createUnion( r2 );
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
index f5ed8a71010..11635c3544e 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import gnu.classpath.Configuration;
import gnu.java.awt.peer.ClasspathFontPeer;
import gnu.java.awt.font.opentype.NameDecoder;
@@ -50,9 +49,7 @@ import java.awt.font.GlyphVector;
import java.awt.font.GlyphMetrics;
import java.awt.font.LineMetrics;
import java.awt.geom.Rectangle2D;
-import java.awt.geom.Point2D;
import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
index 035819d1c4b..e095c7dad4b 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
index cd047f26715..6d0a52b91be 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
@@ -38,13 +38,10 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import gnu.classpath.Configuration;
-
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.ImageConsumer;
-import java.awt.image.ImageProducer;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.io.DataInput;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java
deleted file mode 100644
index a8765222e0e..00000000000
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/* GdkTextLayout.java
- Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.awt.peer.gtk;
-
-import gnu.classpath.Configuration;
-import gnu.java.awt.peer.ClasspathTextLayoutPeer;
-
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphMetrics;
-import java.awt.font.GlyphVector;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextHitInfo;
-import java.awt.font.TextLayout;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Rectangle2D;
-import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
-import java.text.CharacterIterator;
-
-/**
- * This is an implementation of the text layout peer interface which
- * delegates all the hard work to pango.
- *
- * @author Graydon Hoare
- */
-
-public class GdkTextLayout
- implements ClasspathTextLayoutPeer
-{
- // native side, plumbing, etc.
- static
- {
- System.loadLibrary("gtkpeer");
-
- initStaticState ();
- }
- private native void setText(String str);
- private native void setFont(GdkFontPeer font);
- private native void getExtents(double[] inkExtents,
- double[] logExtents);
- private native void indexToPos(int idx, double[] pos);
-
- private native void initState ();
-
- private native void dispose ();
-
- private native void cairoDrawGdkTextLayout(long cg2d, float x, float y);
-
- static native void initStaticState();
-
- private final int native_state = GtkGenericPeer.getUniqueInteger ();
-
- protected void finalize ()
- {
- dispose ();
- }
-
- // we hold on to these to make sure we can render when presented
- // with non-GdkGraphics2D paint targets
- private AttributedString attributedString;
- private FontRenderContext fontRenderContext;
-
- public GdkTextLayout(AttributedString str, FontRenderContext frc)
- {
- initState();
- attributedString = str;
- fontRenderContext = frc;
- AttributedCharacterIterator aci = str.getIterator();
- char[] chars = new char[aci.getEndIndex() - aci.getBeginIndex()];
- for(int i = aci.getBeginIndex(); i < aci.getEndIndex(); i++)
- chars[i] = aci.setIndex(i);
- setText(new String(chars));
-
- Object fnt = aci.getAttribute(TextAttribute.FONT);
- if (fnt != null && fnt instanceof Font)
- setFont( (GdkFontPeer) ((Font)fnt).getPeer() );
- }
-
- protected class CharacterIteratorProxy
- implements CharacterIterator
- {
- public CharacterIterator target;
- public int begin;
- public int limit;
- public int index;
-
- public CharacterIteratorProxy (CharacterIterator ci)
- {
- target = ci;
- }
-
- public int getBeginIndex ()
- {
- return begin;
- }
-
- public int getEndIndex ()
- {
- return limit;
- }
-
- public int getIndex ()
- {
- return index;
- }
-
- public char setIndex (int idx)
- throws IllegalArgumentException
- {
- if (idx < begin || idx >= limit)
- throw new IllegalArgumentException ();
- char ch = target.setIndex (idx);
- index = idx;
- return ch;
- }
-
- public char first ()
- {
- int save = target.getIndex ();
- char ch = target.setIndex (begin);
- target.setIndex (save);
- return ch;
- }
-
- public char last ()
- {
- if (begin == limit)
- return this.first ();
-
- int save = target.getIndex ();
- char ch = target.setIndex (limit - 1);
- target.setIndex (save);
- return ch;
- }
-
- public char current ()
- {
- return target.current();
- }
-
- public char next ()
- {
- if (index >= limit - 1)
- return CharacterIterator.DONE;
- else
- {
- index++;
- return target.next();
- }
- }
-
- public char previous ()
- {
- if (index <= begin)
- return CharacterIterator.DONE;
- else
- {
- index--;
- return target.previous ();
- }
- }
-
- public Object clone ()
- {
- CharacterIteratorProxy cip = new CharacterIteratorProxy (this.target);
- cip.begin = this.begin;
- cip.limit = this.limit;
- cip.index = this.index;
- return cip;
- }
-
- }
-
-
- // public side
-
- public void draw (Graphics2D g2, float x, float y)
- {
- cairoDrawGdkTextLayout(((CairoGraphics2D) g2).nativePointer, x, y);
- }
-
- public TextHitInfo getStrongCaret (TextHitInfo hit1,
- TextHitInfo hit2)
- {
- throw new Error("not implemented");
- }
-
- public byte getBaseline ()
- {
- throw new Error("not implemented");
- }
-
- public boolean isLeftToRight ()
- {
- throw new Error("not implemented");
- }
-
- public boolean isVertical ()
- {
- throw new Error("not implemented");
- }
-
- public float getAdvance ()
- {
- throw new Error("not implemented");
- }
-
- public float getAscent ()
- {
- throw new Error("not implemented");
- }
-
- public float getDescent ()
- {
- throw new Error("not implemented");
- }
-
- public float getLeading ()
- {
- throw new Error("not implemented");
- }
-
- public int getCharacterCount ()
- {
- throw new Error("not implemented");
- }
-
- public byte getCharacterLevel (int index)
- {
- throw new Error("not implemented");
- }
-
- public float[] getBaselineOffsets ()
- {
- throw new Error("not implemented");
- }
-
- public Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint)
- {
- throw new Error("not implemented");
- }
-
- public Rectangle2D getBounds ()
- {
- double[] inkExtents = new double[4];
- double[] logExtents = new double[4];
- getExtents(inkExtents, logExtents);
- return new Rectangle2D.Double(logExtents[0], logExtents[1],
- logExtents[2], logExtents[3]);
- }
-
- public float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds)
- {
- throw new Error("not implemented");
- }
-
- public Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds)
- {
- throw new Error("not implemented");
- }
-
- public Shape[] getCaretShapes (int offset, Rectangle2D bounds,
- TextLayout.CaretPolicy policy)
- {
- throw new Error("not implemented");
- }
-
- public Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
- Rectangle2D bounds)
- {
- AffineTransform at = new AffineTransform();
- GeneralPath gp = new GeneralPath();
- double [] rect = new double[4];
- Rectangle2D tmp = new Rectangle2D.Double();
- for (int i = firstEndpoint; i <= secondEndpoint; ++i)
- {
- indexToPos(i, rect);
- tmp.setRect(rect[0], rect[1], rect[2], rect[3]);
- Rectangle2D.intersect(tmp, bounds, tmp);
- gp.append(tmp.getPathIterator(at), false);
- }
- return gp;
- }
-
- public int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint,
- TextHitInfo secondEndpoint)
- {
- throw new Error("not implemented");
- }
-
- public TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy)
- {
- throw new Error("not implemented");
- }
- public TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy)
- {
- throw new Error("not implemented");
- }
- public TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds)
- {
- throw new Error("not implemented");
- }
- public TextHitInfo getVisualOtherHit (TextHitInfo hit)
- {
- throw new Error("not implemented");
- }
-
- public float getVisibleAdvance ()
- {
- throw new Error("not implemented");
- }
-
- public native Shape getOutline (AffineTransform tx);
-
- public Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
- TextHitInfo secondEndpoint,
- Rectangle2D bounds)
- {
- throw new Error("not implemented");
- }
-
-
- public TextLayout getJustifiedLayout (float justificationWidth)
- {
- throw new Error("not implemented");
- }
-
- public void handleJustify (float justificationWidth)
- {
- throw new Error("not implemented");
- }
-
- public Object clone ()
- {
- throw new Error("not implemented");
- }
-
- public int hashCode ()
- {
- throw new Error("not implemented");
- }
-
- public boolean equals (ClasspathTextLayoutPeer tl)
- {
- throw new Error("not implemented");
- }
-
- public String toString ()
- {
- throw new Error("not implemented");
- }
-
-}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java
index 63d9cd48715..f18db7af9f1 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java
@@ -38,13 +38,8 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.AWTEvent;
import java.awt.Button;
-import java.awt.Component;
-import java.awt.Point;
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
import java.awt.peer.ButtonPeer;
// A composite widget. GtkButtons have transparent backgrounds. An
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
index edfc9ceee9c..30c39dedeac 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
@@ -53,8 +53,8 @@ public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
// Preferred size for a drawing widget is always what the user
// requested.
- public Dimension getPreferredSize ()
+ public Dimension preferredSize()
{
- return awtComponent.getSize ();
+ return awtComponent.getSize();
}
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
index 094aa3c0391..90d16c57282 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
@@ -40,20 +40,32 @@ package gnu.java.awt.peer.gtk;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
-import java.awt.peer.CheckboxPeer;
-
import java.awt.event.ItemEvent;
+import java.awt.peer.CheckboxPeer;
+import java.util.WeakHashMap;
+/**
+ * This class wraps either a GtkCheckButton or a GtkOptionButton
+ * depending on if this peer's owner belongs to a CheckboxGroup.
+ */
public class GtkCheckboxPeer extends GtkComponentPeer
implements CheckboxPeer
{
- // Group from last time it was set.
- public GtkCheckboxGroupPeer old_group;
+ // The CheckboxGroup to which this GtkCheckboxPeer's owner belongs.
+ public CheckboxGroup current_group;
// The current state of the GTK checkbox.
- private boolean currentState;
+ private boolean currentState;
+
+ // A map from CheckboxGroup to GSList* GTK option group pointer.
+ private static WeakHashMap groupMap = new WeakHashMap();
+
+ public native void createCheckButton ();
+ public native void createRadioButton (long groupPointer);
- public native void create (GtkCheckboxGroupPeer group);
- public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
+ public native void addToGroup (long groupPointer);
+ public native void removeFromGroup ();
+ public native void switchToGroup (long groupPointer);
+
public native void connectSignals ();
/**
@@ -68,17 +80,47 @@ public class GtkCheckboxPeer extends GtkComponentPeer
super (c);
}
- // FIXME: we must be able to switch between a checkbutton and a
- // radiobutton dynamically.
public void create ()
{
Checkbox checkbox = (Checkbox) awtComponent;
- CheckboxGroup g = checkbox.getCheckboxGroup ();
- old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
- create (old_group);
+ current_group = checkbox.getCheckboxGroup ();
+ if (current_group == null)
+ {
+ // Initially we're not part of a group so we're backed by a
+ // GtkCheckButton.
+ createCheckButton();
+ }
+ else
+ {
+ // Initially we're part of a group.
+
+ // See if this group is already stored in our map.
+ Long groupPointer = null;
+ synchronized (groupMap)
+ {
+ groupPointer = (Long) groupMap.get(current_group);
+ }
+
+ if (groupPointer == null)
+ {
+ // We don't know about this group. Create a new native
+ // group pointer for this group and store it in our map.
+ createRadioButton(0);
+ }
+ else
+ {
+ // We already know about this group. Pass the
+ // corresponding native group pointer value to the native
+ // create method.
+ createRadioButton(groupPointer.longValue());
+ }
+ }
currentState = checkbox.getState();
gtkToggleButtonSetActive(currentState);
- gtkButtonSetLabel (checkbox.getLabel ());
+
+ String label = checkbox.getLabel();
+ if (label != null)
+ gtkButtonSetLabel(label);
}
/**
@@ -87,7 +129,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
* event since events should only be posted for user initiated
* clicks on the GtkCheckButton.
*/
- synchronized public void setState (boolean state)
+ public synchronized void setState (boolean state)
{
if (currentState != state)
{
@@ -103,21 +145,87 @@ public class GtkCheckboxPeer extends GtkComponentPeer
public void setCheckboxGroup (CheckboxGroup group)
{
- GtkCheckboxGroupPeer gp
- = GtkCheckboxGroupPeer.getCheckboxGroupPeer (group);
- if (gp != old_group)
+ if (current_group == null && group != null)
{
- if (old_group != null)
- old_group.remove (this);
- nativeSetCheckboxGroup (gp);
- old_group = gp;
+ // This peer's owner is currently not in a group, and now
+ // we're adding it to a group. This means that the backing
+ // GtkWidget will change from a GtkCheckButton to a
+ // GtkRadioButton.
+
+ current_group = group;
+
+ // See if the new group is already stored in our map.
+ Long groupPointer = null;
+ synchronized (groupMap)
+ {
+ groupPointer = (Long) groupMap.get(current_group);
+ }
+
+ if (groupPointer == null)
+ {
+ // We don't know about this group. Create a new native
+ // group pointer for this group and store it in our map.
+ addToGroup(0);
+ }
+ else
+ {
+ // We already know about this group. Pass the
+ // corresponding native group pointer value to the native
+ // create method.
+ addToGroup(groupPointer.longValue());
+ }
+ }
+ else if (current_group != null && group == null)
+ {
+ // This peer's owner is currently in a group, and now we're
+ // removing it from a group. This means that the backing
+ // GtkWidget will change from a GtkRadioButton to a
+ // GtkCheckButton.
+ removeFromGroup();
+ current_group = null;
+ }
+ else if (current_group == null && group == null)
+ {
+ // This peer's owner is currently not in a group, and we're
+ // not adding it to a group, so simply return.
+ return;
+ }
+ else if (current_group != group)
+ {
+ // This peer's owner is currently in a group, and now we're
+ // putting it in another group. This means that we must
+ // remove the backing GtkRadioButton from one group and add it
+ // to the other group.
+
+ current_group = group;
+
+ // See if the new group is already stored in our map.
+ Long groupPointer = null;
+ synchronized (groupMap)
+ {
+ groupPointer = (Long) groupMap.get(current_group);
+ }
+
+ if (groupPointer == null)
+ {
+ // We don't know about this group. Create a new native
+ // group pointer for this group and store it in our map.
+ switchToGroup(0);
+ }
+ else
+ {
+ // We already know about this group. Pass the
+ // corresponding native group pointer value to the native
+ // create method.
+ switchToGroup(groupPointer.longValue());
+ }
}
}
// Override the superclass postItemEvent so that the peer doesn't
// need information that we have.
// called back by native side: item_toggled_cb
- synchronized public void postItemEvent(Object item, boolean state)
+ public synchronized void postItemEvent(Object item, boolean state)
{
// Only fire event is state actually changed.
if (currentState != state)
@@ -127,13 +235,20 @@ public class GtkCheckboxPeer extends GtkComponentPeer
state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
}
}
+
+ public void addToGroupMap(long groupPointer)
+ {
+ synchronized (groupMap)
+ {
+ groupMap.put(current_group, new Long (groupPointer));
+ }
+ }
public void dispose ()
{
- // Notify the group so that the native state can be cleaned up
- // appropriately.
- if (old_group != null)
- old_group.remove (this);
+ groupMap.clear();
+ current_group = null;
+ currentState = false;
super.dispose ();
}
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
index fdc7d50c5b5..61df796dc00 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java
@@ -1,5 +1,5 @@
/* GtkClipboardNotifier.java -- Helper for announcing GtkSelection changes.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.datatransfer.*;
-import java.util.*;
class GtkClipboardNotifier extends Thread
{
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 625855f0117..c11c45e2070 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -52,9 +52,12 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Insets;
import java.awt.ItemSelectable;
+import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
@@ -66,13 +69,13 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.PaintEvent;
import java.awt.event.TextEvent;
-import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
+import java.awt.peer.LightweightPeer;
import java.awt.peer.WindowPeer;
import java.util.Timer;
import java.util.TimerTask;
@@ -109,6 +112,9 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetRequestFocus ();
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
int keyCode, int keyLocation);
+ native boolean gtkWidgetHasFocus();
+ native boolean gtkWidgetCanFocus();
+
native void realize();
native void setNativeEventMask ();
@@ -365,7 +371,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public void print (Graphics g)
{
- throw new RuntimeException ();
+ g.drawImage( ComponentGraphics.grab( this ), 0, 0, null );
}
public void repaint (long tm, int x, int y, int width, int height)
@@ -414,8 +420,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public void requestFocus ()
{
- gtkWidgetRequestFocus();
- postFocusEvent(FocusEvent.FOCUS_GAINED, false);
+ assert false: "Call new requestFocus() method instead";
}
public void reshape (int x, int y, int width, int height)
@@ -628,6 +633,12 @@ public class GtkComponentPeer extends GtkGenericPeer
q.postEvent(keyEvent);
}
+ /**
+ * Referenced from native code.
+ *
+ * @param id
+ * @param temporary
+ */
protected void postFocusEvent (int id, boolean temporary)
{
q().postEvent (new FocusEvent (awtComponent, id, temporary));
@@ -647,8 +658,10 @@ public class GtkComponentPeer extends GtkGenericPeer
public GraphicsConfiguration getGraphicsConfiguration ()
{
- // FIXME: just a stub for now.
- return null;
+ // FIXME: The component might be showing on a non-default screen.
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice dev = env.getDefaultScreenDevice();
+ return dev.getDefaultConfiguration();
}
public void setEventMask (long mask)
@@ -661,10 +674,72 @@ public class GtkComponentPeer extends GtkGenericPeer
return false;
}
- public boolean requestFocus (Component source, boolean b1,
- boolean b2, long x)
+ public boolean requestFocus (Component request, boolean temporary,
+ boolean allowWindowFocus, long time)
{
- return false;
+ assert request == awtComponent || isLightweightDescendant(request);
+ boolean retval = false;
+ if (gtkWidgetHasFocus())
+ {
+ KeyboardFocusManager kfm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ Component currentFocus = kfm.getFocusOwner();
+ if (currentFocus == request)
+ // Nothing to do in this trivial case.
+ retval = true;
+ else
+ {
+ // Requested component is a lightweight descendant of this one
+ // or the actual heavyweight.
+ // Since this (native) component is already focused, we simply
+ // change the actual focus and be done.
+ postFocusEvent(FocusEvent.FOCUS_GAINED, temporary);
+ retval = true;
+ }
+ }
+ else
+ {
+ if (gtkWidgetCanFocus())
+ {
+ if (allowWindowFocus)
+ {
+ Window window = getWindowFor(request);
+ GtkWindowPeer wPeer = (GtkWindowPeer) window.getPeer();
+ if (! wPeer.gtkWindowHasFocus())
+ wPeer.requestWindowFocus();
+ }
+ // Store requested focus component so that the corresponding
+ // event is dispatched correctly.
+ gtkWidgetRequestFocus();
+ retval = true;
+ }
+ }
+ return retval;
+ }
+
+ private Window getWindowFor(Component c)
+ {
+ Component comp = c;
+ while (! (comp instanceof Window))
+ comp = comp.getParent();
+ return (Window) comp;
+ }
+
+ /**
+ * Returns <code>true</code> if the component is a direct (== no intermediate
+ * heavyweights) lightweight descendant of this peer's component.
+ *
+ * @param c the component to check
+ *
+ * @return <code>true</code> if the component is a direct (== no intermediate
+ * heavyweights) lightweight descendant of this peer's component
+ */
+ protected boolean isLightweightDescendant(Component c)
+ {
+ Component comp = c;
+ while (comp.getPeer() instanceof LightweightPeer)
+ comp = comp.getParent();
+ return comp == awtComponent;
}
public boolean isObscured ()
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java
index 06076e77f45..541de3d82a8 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java
@@ -42,10 +42,7 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
-import java.awt.Graphics;
import java.awt.Insets;
-import java.awt.Window;
-import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
public class GtkContainerPeer extends GtkComponentPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java
index 3254f566d17..13906544d27 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -1,5 +1,5 @@
/* GtkDialogPeer.java -- Implements DialogPeer with GTK
- Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,9 +39,6 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Dialog;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-import java.awt.event.PaintEvent;
import java.awt.peer.DialogPeer;
public class GtkDialogPeer extends GtkWindowPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java
index 6ec0b72982b..bb6f8b3bb3b 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -39,11 +39,9 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Frame;
-import java.awt.Graphics;
import java.awt.Image;
import java.awt.MenuBar;
import java.awt.Rectangle;
-import java.awt.event.PaintEvent;
import java.awt.peer.FramePeer;
import java.awt.peer.MenuBarPeer;
@@ -218,11 +216,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/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
index ef96518a1c0..0fd98bbd7b4 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
@@ -39,12 +39,10 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Graphics;
-import java.awt.Color;
import java.awt.Image;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.MemoryImageSource;
-import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.io.File;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java
index 299f01dcaa6..f1a74b8cc99 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java
@@ -1,5 +1,5 @@
/* GtkImageConsumer.java
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,16 +38,11 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Graphics;
-import java.awt.Image;
import java.awt.image.ColorModel;
-import java.awt.image.DirectColorModel;
import java.awt.image.ImageConsumer;
-import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.MemoryImageSource;
import java.util.Hashtable;
-import java.util.Vector;
/**
* Helper class to GtkImage. Sits and gathers pixels for a GtkImage and then
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkLabelPeer.java
index bbf4230b3ca..02db90d72bd 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkLabelPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkLabelPeer.java
@@ -56,7 +56,7 @@ public class GtkLabelPeer extends GtkComponentPeer
native void nativeSetAlignment (float alignment);
- public native void setText(String text);
+ public native void setNativeText(String text);
native void setNativeBounds (int x, int y, int width, int height);
// Because this is a composite widget, we need to retrieve the
@@ -69,6 +69,12 @@ public class GtkLabelPeer extends GtkComponentPeer
create (label.getText (), getGtkAlignment (label.getAlignment ()));
}
+ public void setText(String text)
+ {
+ if (text != null)
+ setNativeText(text);
+ }
+
public GtkLabelPeer (Label l)
{
super (l);
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
index d203b437f38..898f224f5e1 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
@@ -38,12 +38,9 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Font;
import java.awt.Menu;
import java.awt.MenuBar;
-import java.awt.MenuComponent;
import java.awt.peer.MenuBarPeer;
-import java.awt.peer.MenuPeer;
public class GtkMenuBarPeer extends GtkMenuComponentPeer
implements MenuBarPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
index 251bab233d7..ea523e953e7 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
@@ -38,13 +38,8 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Font;
-import java.awt.Menu;
-import java.awt.MenuBar;
-import java.awt.MenuComponent;
import java.awt.MenuItem;
import java.awt.peer.MenuItemPeer;
-import java.awt.peer.MenuPeer;
public class GtkMenuItemPeer extends GtkMenuComponentPeer
implements MenuItemPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
new file mode 100644
index 00000000000..02bf84d4e8e
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
@@ -0,0 +1,76 @@
+/* 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.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/libjava/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java
index 51fe2bc8e0c..e0053f763f5 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java
@@ -1,5 +1,5 @@
/* GtkPanelPeer.java -- Implements PanelPeer with GTK
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,6 @@ package gnu.java.awt.peer.gtk;
import java.awt.AWTEvent;
import java.awt.Panel;
import java.awt.event.MouseEvent;
-import java.awt.event.PaintEvent;
import java.awt.peer.PanelPeer;
public class GtkPanelPeer extends GtkContainerPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java
index 525a910bc1b..4d66a3f509d 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java
@@ -40,7 +40,6 @@ package gnu.java.awt.peer.gtk;
import java.awt.Component;
import java.awt.Event;
-import java.awt.MenuItem;
import java.awt.Point;
import java.awt.PopupMenu;
import java.awt.peer.PopupMenuPeer;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
index 9b31a7390e0..e4147d36c97 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Adjustable;
-import java.awt.EventQueue;
import java.awt.Scrollbar;
import java.awt.event.AdjustmentEvent;
import java.awt.peer.ScrollbarPeer;
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
index 163fc52f78a..6aa87fc2ecf 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -39,32 +39,83 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import gnu.classpath.Configuration;
import gnu.java.awt.EmbeddedWindow;
+import gnu.java.awt.dnd.GtkMouseDragGestureRecognizer;
+import gnu.java.awt.dnd.peer.gtk.GtkDragSourceContextPeer;
import gnu.java.awt.peer.ClasspathFontPeer;
-import gnu.java.awt.peer.ClasspathTextLayoutPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
-import java.awt.*;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.Rectangle;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.Window;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
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;
import java.awt.image.DirectColorModel;
-import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
-import java.awt.peer.*;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+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;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.WindowPeer;
import java.io.InputStream;
import java.net.URL;
-import java.text.AttributedString;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
@@ -310,6 +361,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)
{
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
return null;
}
@@ -528,12 +584,6 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
}
}
- public ClasspathTextLayoutPeer getClasspathTextLayoutPeer (AttributedString str,
- FontRenderContext frc)
- {
- return new GdkTextLayout(str, frc);
- }
-
protected EventQueue getSystemEventQueueImpl()
{
synchronized (GtkToolkit.class)
@@ -555,7 +605,26 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
{
- throw new Error("not implemented");
+ return new GtkDragSourceContextPeer(e);
+ }
+
+ public DragGestureRecognizer createDragGestureRecognizer(Class recognizer,
+ DragSource ds,
+ Component comp,
+ int actions,
+ DragGestureListener l)
+ {
+ if (recognizer.getName().equals("java.awt.dnd.MouseDragGestureRecognizer"))
+ {
+ GtkMouseDragGestureRecognizer gestureRecognizer
+ = new GtkMouseDragGestureRecognizer(ds, comp, actions, l);
+ gestureRecognizer.registerListeners();
+ return gestureRecognizer;
+ }
+ else
+ {
+ return null;
+ }
}
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
@@ -593,4 +662,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/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
index f38007f19d1..44e7b027b0b 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
@@ -50,6 +50,8 @@ public class GtkVolatileImage extends VolatileImage
int width, height;
private ImageCapabilities caps;
+ final GtkComponentPeer component;
+
/**
* Don't touch, accessed from native code.
*/
@@ -85,6 +87,7 @@ public class GtkVolatileImage extends VolatileImage
this.width = width;
this.height = height;
this.caps = caps;
+ this.component = component;
nativePointer = init( component, width, height );
}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
index d15beacb4db..866d9c8816a 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
@@ -38,13 +38,14 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
+import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ComponentEvent;
+import java.awt.event.FocusEvent;
import java.awt.event.PaintEvent;
import java.awt.event.WindowEvent;
import java.awt.peer.WindowPeer;
@@ -70,7 +71,8 @@ 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 boolean gtkWindowHasFocus();
native void realize ();
/** Returns the cached width of the AWT window component. */
@@ -275,10 +277,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)
@@ -299,7 +304,40 @@ public class GtkWindowPeer extends GtkContainerPeer
// TODO Auto-generated method stub
return false;
}
-
+
+ public boolean requestFocus (Component request, boolean temporary,
+ boolean allowWindowFocus, long time)
+ {
+ assert request == awtComponent || isLightweightDescendant(request);
+ boolean retval = false;
+ if (gtkWindowHasFocus())
+ {
+ KeyboardFocusManager kfm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ Component currentFocus = kfm.getFocusOwner();
+ if (currentFocus == request)
+ // Nothing to do in this trivial case.
+ retval = true;
+ else
+ {
+ // Requested component is a lightweight descendant of this one
+ // or the actual heavyweight.
+ // Since this (native) component is already focused, we simply
+ // change the actual focus and be done.
+ postFocusEvent(FocusEvent.FOCUS_GAINED, temporary);
+ retval = true;
+ }
+ }
+ else
+ {
+ if (allowWindowFocus)
+ {
+ retval = requestWindowFocus();
+ }
+ }
+ return retval;
+ }
+
public Graphics getGraphics ()
{
Graphics g = super.getGraphics ();
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
index fa84ea0c797..58496559320 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
@@ -38,25 +38,11 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Color;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.font.GlyphVector;
-import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferInt;
-import java.awt.image.ColorModel;
-import java.awt.image.DirectColorModel;
-import java.awt.image.RenderedImage;
import java.awt.image.ImageObserver;
-import java.util.WeakHashMap;
public class VolatileImageGraphics extends ComponentGraphics
{
@@ -83,7 +69,7 @@ public class VolatileImageGraphics extends ComponentGraphics
public GraphicsConfiguration getDeviceConfiguration()
{
- return null;
+ return owner.component.getGraphicsConfiguration();
}
public Graphics create()
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java
index 788e08ee12a..acac5e460a4 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java
@@ -1,5 +1,5 @@
/* QtCheckboxPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.Rectangle;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.event.ItemEvent;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java
index 7395a8e6c81..c5c839e321a 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java
@@ -1,5 +1,5 @@
/* QtComponentGraphics.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,7 @@ package gnu.java.awt.peer.qt;
import java.awt.Color;
import java.awt.GraphicsConfiguration;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Rectangle;
-import java.awt.Paint;
/**
* QtComponentPainter is a Graphics2D context for painting directly to AWT
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
index d5662a86169..4d7b58c4d87 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
@@ -1,5 +1,5 @@
/* QtComponentPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,6 @@ import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Component;
-import java.awt.Container;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java
index 3782d781597..ec04b0567d8 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java
@@ -1,5 +1,5 @@
/* QtContainerPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.Container;
import java.awt.Component;
import java.awt.Insets;
import java.awt.peer.ContainerPeer;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java
index 0da2e4ebc95..23e5c065396 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java
@@ -1,5 +1,5 @@
/* QtDialogPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.Dialog;
-import java.awt.MenuBar;
-import java.awt.Rectangle;
import java.awt.peer.DialogPeer;
public class QtDialogPeer extends QtWindowPeer implements DialogPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
index cac12b91a99..0f859b78e4f 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
@@ -1,5 +1,5 @@
/* QtEmbeddedWindowPeer.java -- embedded window peer
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.Component;
-import java.awt.peer.WindowPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
/**
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java
index e403239e9e9..2438fcc3282 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java
@@ -1,5 +1,5 @@
/* QtFontMetrics.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,6 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphVector;
-import java.awt.font.LineMetrics;
public class QtFontMetrics extends FontMetrics
{
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java
index ee88c7dd5d0..d847a805396 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java
@@ -1,5 +1,5 @@
/* QtFontPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import java.awt.font.LineMetrics;
import java.text.CharacterIterator;
import java.util.Locale;
import java.util.Map;
-import java.awt.peer.FontPeer;
import gnu.java.awt.peer.ClasspathFontPeer;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java
index f9b4f26729f..842cbbbf8ba 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java
@@ -1,5 +1,5 @@
/* QtGraphics.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
@@ -57,7 +58,6 @@ import java.awt.Stroke;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
-import java.awt.geom.PathIterator;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
@@ -605,8 +605,16 @@ public abstract class QtGraphics extends Graphics2D
composite = comp;
}
else
- throw new UnsupportedOperationException("We don't support custom"+
- " composites yet.");
+ {
+ // FIXME: this check is only required "if this Graphics2D
+ // context is drawing to a Component on the display screen".
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new AWTPermission("readDisplayPixels"));
+
+ throw new UnsupportedOperationException("We don't support custom"+
+ " composites yet.");
+ }
}
public Composite getComposite()
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
index 142b140cf14..15a01592277 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
@@ -1,5 +1,5 @@
/* QtGraphicsEnvironment.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,6 @@ import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import java.awt.HeadlessException;
import java.awt.image.BufferedImage;
import java.util.Locale;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java
index 90954643570..b6fbb1dca41 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java
@@ -1,5 +1,5 @@
/* QtImage.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import java.awt.Image;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.MemoryImageSource;
-import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.io.File;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java
index aec0671f8e0..7096c21e48d 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java
@@ -1,5 +1,5 @@
/* QtImageConsumer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,15 +37,10 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.Graphics;
-import java.awt.Image;
import java.awt.image.ColorModel;
-import java.awt.image.DirectColorModel;
import java.awt.image.ImageConsumer;
-import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.util.Hashtable;
-import java.util.Vector;
/**
* Helper class to QtImage. Sits and gathers pixels for a QtImage and then
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java
index 5a6f3189a7a..d49084af831 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java
@@ -1,5 +1,5 @@
/* QtImageDirectGraphics.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,29 +38,10 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.Color;
-import java.awt.GraphicsConfiguration;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Image;
-import java.awt.Paint;
-import java.awt.Rectangle;
-import java.util.Stack;
import java.awt.Shape;
-import java.awt.Stroke;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
-import java.awt.geom.PathIterator;
-import java.awt.geom.Arc2D;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Line2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.geom.RoundRectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
-import java.awt.image.RenderedImage;
-import java.awt.image.renderable.RenderableImage;
/**
* A QtImagePainter that does an update after every drawing op.
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java
index f8a7e51d398..1224d69150f 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java
@@ -1,5 +1,5 @@
/* QtImageGraphics.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,7 @@ package gnu.java.awt.peer.qt;
import java.awt.Color;
import java.awt.GraphicsConfiguration;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Image;
-import java.awt.Paint;
import java.awt.Rectangle;
import java.util.Stack;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java
index d8f0d1f8892..c91b37f3711 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java
@@ -1,5 +1,5 @@
/* QtMenuBarPeer.java -- Qt peer for a menu bar.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package gnu.java.awt.peer.qt;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.peer.MenuBarPeer;
-import java.util.Vector;
public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
{
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java
index 34753cb359b..7658ff078f1 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java
@@ -1,5 +1,5 @@
/* QtMenuItemPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.Menu;
import java.awt.MenuItem;
import java.awt.CheckboxMenuItem;
import java.awt.event.ActionEvent;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
index 81577cc6c52..b96c5c51045 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
@@ -1,5 +1,5 @@
/* QtPopupMenuPeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,12 +38,9 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.Component;
-import java.awt.Menu;
-import java.awt.MenuItem;
import java.awt.Point;
import java.awt.PopupMenu;
import java.awt.Event;
-import java.awt.event.ActionEvent;
import java.awt.peer.PopupMenuPeer;
public class QtPopupMenuPeer extends QtMenuPeer implements PopupMenuPeer
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
index 045cfdf3284..c67b55bf42f 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
@@ -1,5 +1,5 @@
/* QtScreenDeviceConfiguration.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,11 +37,9 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.DisplayMode;
import java.awt.ImageCapabilities;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsConfigTemplate;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java
index 02fa8fb22cb..c3731cbd5f2 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java
@@ -1,5 +1,5 @@
/* QtScrollPanePeer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
import java.awt.Adjustable;
-import java.awt.Dimension;
import java.awt.Insets;
import java.awt.ScrollPane;
import java.awt.peer.ScrollPanePeer;
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java
index 73652f8df90..5116769389e 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java
@@ -1,5 +1,5 @@
/* QtToolkit.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,19 +37,16 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import gnu.classpath.Configuration;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.peer.ClasspathFontPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
-import gnu.java.awt.peer.ClasspathTextLayoutPeer;
-import java.awt.AWTEvent;
+
import java.awt.AWTException;
import java.awt.Button;
import java.awt.Canvas;
import java.awt.Checkbox;
import java.awt.CheckboxMenuItem;
import java.awt.Choice;
-import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
@@ -68,18 +65,13 @@ import java.awt.TextField;
import java.awt.FileDialog;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import java.awt.HeadlessException;
import java.awt.PopupMenu;
import java.awt.PrintJob;
import java.awt.Scrollbar;
import java.awt.ScrollPane;
-import java.awt.Toolkit;
import java.awt.Window;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.DragSource;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.event.AWTEventListener;
import java.awt.image.ColorModel;
@@ -91,37 +83,29 @@ import java.awt.peer.ButtonPeer;
import java.awt.peer.FontPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.CanvasPeer;
-import java.awt.peer.FramePeer;
+import java.awt.peer.FramePeer;
import java.awt.peer.PopupMenuPeer;
import java.awt.peer.CheckboxMenuItemPeer;
import java.awt.peer.LabelPeer;
import java.awt.peer.RobotPeer;
import java.awt.peer.CheckboxPeer;
-import java.awt.peer.LightweightPeer;
import java.awt.peer.ScrollPanePeer;
-import java.awt.peer.ChoicePeer;
+import java.awt.peer.ChoicePeer;
import java.awt.peer.ListPeer;
import java.awt.peer.ScrollbarPeer;
-import java.awt.peer.ComponentPeer;
import java.awt.peer.MenuBarPeer;
import java.awt.peer.TextAreaPeer;
-import java.awt.peer.ContainerPeer;
-import java.awt.peer.MenuComponentPeer;
-import java.awt.peer.TextComponentPeer;
import java.awt.peer.DialogPeer;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.TextFieldPeer;
import java.awt.peer.FileDialogPeer;
import java.awt.peer.MenuPeer;
import java.awt.peer.WindowPeer;
-import java.awt.font.FontRenderContext;
import java.io.InputStream;
import java.net.URL;
-import java.text.AttributedString;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import javax.imageio.spi.IIORegistry;
import gnu.java.awt.ClasspathToolkit;
@@ -402,6 +386,11 @@ public class QtToolkit extends ClasspathToolkit
String jobtitle,
Properties props)
{
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
throw new RuntimeException("Not implemented");
}
@@ -445,12 +434,6 @@ public class QtToolkit extends ClasspathToolkit
return new QtFontPeer (name, attrs);
}
- public ClasspathTextLayoutPeer getClasspathTextLayoutPeer(AttributedString str,
- FontRenderContext frc)
- {
- return null;
- }
-
// FIXME
public Font createFont(int format, InputStream stream)
{
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java b/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java
index 0ec61deb3a6..c81bb2a098b 100644
--- a/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java
@@ -1,5 +1,5 @@
/* QtVolatileImage.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,15 +47,11 @@ import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.MemoryImageSource;
-import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
-import java.io.File;
-import java.io.IOException;
import java.util.Hashtable;
import java.util.WeakHashMap;
-import java.util.Vector;
/**
* QtVolatileImage - wraps a QImage
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
index f60c8e96c1d..96ccc00b8f0 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
@@ -48,8 +48,6 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
@@ -101,8 +99,8 @@ public class SwingComponentPeer
/**
* Creates a SwingComponentPeer instance. Subclasses are expected to call
* this constructor and thereafter call
- * {@link #init(Component, SwingComponent)} in order to setup the AWT and
- * Swing components properly.
+ * {@link #init(Component,SwingComponent)}
+ * in order to setup the AWT and Swing components properly.
*/
protected SwingComponentPeer()
{
@@ -167,12 +165,9 @@ public class SwingComponentPeer
*/
public Image createImage(int width, int height)
{
- GraphicsEnvironment graphicsEnv =
- GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice dev = graphicsEnv.getDefaultScreenDevice();
- GraphicsConfiguration conf = dev.getDefaultConfiguration();
- Image image = conf.createCompatibleImage(width, height);
- return image;
+ Component parent = awtComponent.getParent();
+ ComponentPeer parentPeer = parent.getPeer();
+ return parentPeer.createImage(width, height);
}
/**
@@ -336,21 +331,24 @@ public class SwingComponentPeer
{
case PaintEvent.UPDATE:
case PaintEvent.PAINT:
- Graphics g = getGraphics();
- Rectangle clip = ((PaintEvent)e).getUpdateRect();
- g.clipRect(clip.x, clip.y, clip.width, clip.height);
- //if (this instanceof LightweightPeer)
- // {
+ // This only will work when the component is showing.
+ if (awtComponent.isShowing())
+ {
+ Graphics g = getGraphics();
+ Rectangle clip = ((PaintEvent)e).getUpdateRect();
+ g.clipRect(clip.x, clip.y, clip.width, clip.height);
+ //if (this instanceof LightweightPeer)
+ // {
if (e.getID() == PaintEvent.UPDATE)
awtComponent.update(g);
else
awtComponent.paint(g);
- // }
- // We paint the 'heavyweights' at last, so that they appear on top of
- // everything else.
- peerPaint(g);
-
- g.dispose();
+ // }
+ // We paint the 'heavyweights' at last, so that they appear on top of
+ // everything else.
+ peerPaint(g);
+ g.dispose();
+ }
break;
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
@@ -384,6 +382,11 @@ public class SwingComponentPeer
{
if (swingComponent != null)
swingComponent.getJComponent().setVisible(false);
+
+ Component parent = awtComponent.getParent();
+ if (parent != null)
+ parent.repaint(awtComponent.getX(), awtComponent.getY(),
+ awtComponent.getWidth(), awtComponent.getHeight());
}
/**
@@ -470,17 +473,15 @@ public class SwingComponentPeer
public boolean prepareImage(Image img, int width, int height, ImageObserver ob)
{
Component parent = awtComponent.getParent();
- boolean res;
if(parent != null)
- {
- ComponentPeer parentPeer = parent.getPeer();
- res = parentPeer.prepareImage(img, width, height, ob);
- }
+ {
+ ComponentPeer parentPeer = parent.getPeer();
+ return parentPeer.prepareImage(img, width, height, ob);
+ }
else
- {
- res = Toolkit.getDefaultToolkit().prepareImage(img, width, height, ob);
- }
- return res;
+ {
+ return Toolkit.getDefaultToolkit().prepareImage(img, width, height, ob);
+ }
}
public void print(Graphics graphics)
@@ -662,8 +663,10 @@ public class SwingComponentPeer
*/
public void setVisible(boolean visible)
{
- if (swingComponent != null)
- swingComponent.getJComponent().setVisible(visible);
+ if (visible)
+ show();
+ else
+ hide();
}
/**
@@ -782,8 +785,13 @@ public class SwingComponentPeer
public VolatileImage createVolatileImage(int width, int height)
{
Component parent = awtComponent.getParent();
- ComponentPeer parentPeer = parent.getPeer();
- return parentPeer.createVolatileImage(width, height);
+ VolatileImage im = null;
+ if (parent != null)
+ {
+ ComponentPeer parentPeer = parent.getPeer();
+ im = parentPeer.createVolatileImage(width, height);
+ }
+ return im;
}
/**
diff --git a/libjava/classpath/gnu/java/awt/peer/x/GLGraphics.java b/libjava/classpath/gnu/java/awt/peer/x/GLGraphics.java
new file mode 100644
index 00000000000..c80c85c28f0
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/GLGraphics.java
@@ -0,0 +1,123 @@
+/* GLGraphics.java -- Graphics2D impl on top of GLX
+ 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.x;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.ColorModel;
+
+import gnu.java.awt.java2d.AbstractGraphics2D;
+import gnu.x11.extension.glx.GL;
+
+/**
+ * An implementation of Graphics2D on top of the GLX extension of X.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class GLGraphics extends AbstractGraphics2D
+{
+
+ /**
+ * The rendering context.
+ */
+ private GL gl;
+
+ /**
+ * Creates a new GLGraphics that paints on the specified GL context.
+ *
+ * @param g the GL context to paint to
+ */
+ GLGraphics(GL g)
+ {
+ gl = g;
+ }
+
+ public void setBackground(Color b)
+ {
+ super.setBackground(b);
+ gl.clear_color(b.getRed() / 255.F, b.getGreen() / 255.F,
+ b.getBlue() / 255.F, b.getAlpha() / 255.F);
+ }
+
+ public void clearRect(int x, int y, int w, int h)
+ {
+ // TODO: Maybe use fillRect().
+ gl.clear(GL.COLOR_BUFFER_BIT);
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ gl.begin(GL.LINES);
+ gl.vertex2i(x1, y1);
+ gl.vertex2i(x2, y2);
+ gl.end();
+ // TODO: Maybe do:
+ // gl.flush();
+ }
+
+ public void drawRect(int x, int y, int w, int h)
+ {
+ gl.polygon_mode(GL.FRONT_AND_BACK, GL.LINE);
+ gl.begin(GL.POLYGON);
+ gl.recti(x, y, x + w, y + h);
+ gl.end();
+ // TODO: Maybe do:
+ // gl.flush();
+ }
+
+ public void fillRect(int x, int y, int w, int h)
+ {
+ gl.polygon_mode(GL.FRONT_AND_BACK, GL.FILL);
+ gl.recti(x, y, x + w, y + h);
+ // TODO: Maybe do:
+ // gl.flush();
+ }
+
+ protected ColorModel getColorModel()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/ImageConverter.java b/libjava/classpath/gnu/java/awt/peer/x/ImageConverter.java
new file mode 100644
index 00000000000..6d32448eece
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/ImageConverter.java
@@ -0,0 +1,113 @@
+/* ImageConverter.java -- Convert arbitrary Image impl to XImage
+ 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.x;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageConsumer;
+import java.util.Hashtable;
+
+/**
+ * Convert a non-XImage to an XImage.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class ImageConverter implements ImageConsumer
+{
+
+ private XImage image;
+ private Graphics imageGraphics;
+
+ public void setDimensions(int width, int height)
+ {
+ image = new XImage(width, height);
+ }
+
+ public void setProperties(Hashtable props)
+ {
+ // Ignore for now.
+ }
+
+ public void setColorModel(ColorModel model)
+ {
+ // Ignore for now.
+ }
+
+ public void setHints(int flags)
+ {
+ // Ignore for now.
+ }
+
+ public void setPixels(int x, int y, int w, int h, ColorModel model,
+ byte[] pixels, int offset, int scansize)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void setPixels(int x, int y, int w, int h, ColorModel model,
+ int[] pixels, int offset, int scansize)
+ {
+ System.err.println("transferType: " + model.getTransferType());
+ System.err.println("colorModel: " + model);
+ if (imageGraphics == null)
+ imageGraphics = image.getGraphics();
+ int xend = x + w;
+ int yend = y + h;
+ for (int yy = y; yy < yend; yy++)
+ {
+ for (int xx = x; xx < xend; xx++)
+ {
+ int pixel = pixels[yy * scansize + xx + offset];
+ imageGraphics.setColor(new Color(model.getRGB(pixel)));
+ imageGraphics.fillRect(xx, yy, 1, 1);
+ }
+ }
+ }
+
+ public void imageComplete(int status)
+ {
+ // Nothing to do here.
+ }
+
+ XImage getXImage()
+ {
+ return image;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/KeyboardMapping.java b/libjava/classpath/gnu/java/awt/peer/x/KeyboardMapping.java
new file mode 100644
index 00000000000..8e0a31f5d36
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/KeyboardMapping.java
@@ -0,0 +1,415 @@
+/* KeyboardMapping.java -- Maps X keysyms to Java keyCode and keyChar
+ 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.x;
+
+import gnu.x11.Input;
+import gnu.x11.keysym.Latin1;
+import gnu.x11.keysym.Misc;
+
+import java.awt.event.KeyEvent;
+
+/**
+ * Defines the keyboard mapping from X keysyms to Java
+ * keycodes and keychars.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+final class KeyboardMapping
+{
+
+ /**
+ * Maps X keycodes to AWT keycodes.
+ *
+ * @param xInput the X input event
+ * @param xKeyCode the X keycode to map
+ * @param xMods the X modifiers
+ *
+ * @return the AWT keycode and keychar
+ */
+ static int mapToKeyCode(gnu.x11.Input xInput, int xKeyCode, int xMods)
+ {
+ int mapped = KeyEvent.VK_UNDEFINED;
+ int keysym = xInput.keycode_to_keysym(xKeyCode, xMods, true);
+
+ // Special keys.
+ if (keysym >= 255 << 8)
+ {
+ // FIXME: Add missing mappings.
+ switch (keysym)
+ {
+ case Misc.BACKSPACE:
+ mapped = KeyEvent.VK_BACK_SPACE;
+ break;
+ case Misc.TAB:
+ mapped = KeyEvent.VK_TAB;
+ break;
+ case Misc.CLEAR:
+ mapped = KeyEvent.VK_CLEAR;
+ break;
+ case Misc.RETURN:
+ mapped = KeyEvent.VK_ENTER;
+ break;
+ case Misc.PAUSE:
+ mapped = KeyEvent.VK_PAUSE;
+ break;
+ case Misc.SCROLL_LOCK:
+ mapped = KeyEvent.VK_SCROLL_LOCK;
+ break;
+ case Misc.ESCAPE:
+ mapped = KeyEvent.VK_ESCAPE;
+ break;
+ case Misc.HOME:
+ mapped = KeyEvent.VK_HOME;
+ break;
+ case Misc.LEFT:
+ mapped = KeyEvent.VK_LEFT;
+ break;
+ case Misc.UP:
+ mapped = KeyEvent.VK_UP;
+ break;
+ case Misc.RIGHT:
+ mapped = KeyEvent.VK_RIGHT;
+ break;
+ case Misc.DOWN:
+ mapped = KeyEvent.VK_DOWN;
+ break;
+ case Misc.PAGE_UP:
+ mapped = KeyEvent.VK_PAGE_UP;
+ break;
+ case Misc.PAGE_DOWN:
+ mapped = KeyEvent.VK_PAGE_DOWN;
+ break;
+ case Misc.END:
+ mapped = KeyEvent.VK_END;
+ break;
+ case Misc.BEGIN:
+ mapped = KeyEvent.VK_BEGIN;
+ break;
+ case Misc.INSERT:
+ mapped = KeyEvent.VK_INSERT;
+ break;
+ case Misc.UNDO:
+ mapped = KeyEvent.VK_UNDO;
+ break;
+ case Misc.FIND:
+ mapped = KeyEvent.VK_FIND;
+ break;
+ case Misc.CANCEL:
+ mapped = KeyEvent.VK_CANCEL;
+ break;
+ case Misc.HELP:
+ mapped = KeyEvent.VK_HELP;
+ break;
+ case Misc.MODE_SWITCH:
+ mapped = KeyEvent.VK_MODECHANGE;
+ break;
+ case Misc.NUM_LOCK:
+ mapped = KeyEvent.VK_NUM_LOCK;
+ break;
+ case Misc.KP_LEFT:
+ mapped = KeyEvent.VK_KP_LEFT;
+ break;
+ case Misc.KP_UP:
+ mapped = KeyEvent.VK_KP_UP;
+ break;
+ case Misc.KP_RIGHT:
+ mapped = KeyEvent.VK_KP_RIGHT;
+ break;
+ case Misc.KP_DOWN:
+ mapped = KeyEvent.VK_KP_DOWN;
+ break;
+ case Misc.F1:
+ mapped = KeyEvent.VK_F1;
+ break;
+ case Misc.F2:
+ mapped = KeyEvent.VK_F2;
+ break;
+ case Misc.F3:
+ mapped = KeyEvent.VK_F3;
+ break;
+ case Misc.F4:
+ mapped = KeyEvent.VK_F4;
+ break;
+ case Misc.F5:
+ mapped = KeyEvent.VK_F5;
+ break;
+ case Misc.F6:
+ mapped = KeyEvent.VK_F6;
+ break;
+ case Misc.F7:
+ mapped = KeyEvent.VK_F7;
+ break;
+ case Misc.F8:
+ mapped = KeyEvent.VK_F8;
+ break;
+ case Misc.F9:
+ mapped = KeyEvent.VK_F9;
+ break;
+ case Misc.F10:
+ mapped = KeyEvent.VK_F10;
+ break;
+ case Misc.F11:
+ mapped = KeyEvent.VK_F11;
+ break;
+ case Misc.F12:
+ mapped = KeyEvent.VK_F12;
+ break;
+ case Misc.F13:
+ mapped = KeyEvent.VK_F13;
+ break;
+ case Misc.F14:
+ mapped = KeyEvent.VK_F14;
+ break;
+ case Misc.F15:
+ mapped = KeyEvent.VK_F15;
+ break;
+ case Misc.F16:
+ mapped = KeyEvent.VK_F16;
+ break;
+ case Misc.F17:
+ mapped = KeyEvent.VK_F17;
+ break;
+ case Misc.F18:
+ mapped = KeyEvent.VK_F18;
+ break;
+ case Misc.F19:
+ mapped = KeyEvent.VK_F19;
+ break;
+ case Misc.F20:
+ mapped = KeyEvent.VK_F20;
+ break;
+ case Misc.F21:
+ mapped = KeyEvent.VK_F21;
+ break;
+ case Misc.F22:
+ mapped = KeyEvent.VK_F22;
+ break;
+ case Misc.F23:
+ mapped = KeyEvent.VK_F23;
+ break;
+ case Misc.F24:
+ mapped = KeyEvent.VK_F24;
+ break;
+ case Misc.SHIFT_L:
+ case Misc.SHIFT_R:
+ mapped = KeyEvent.VK_SHIFT;
+ break;
+ case Misc.CONTROL_L:
+ case Misc.CONTROL_R:
+ mapped = KeyEvent.VK_CONTROL;
+ break;
+ case Misc.CAPS_LOCK:
+ case Misc.SHIFT_LOCK:
+ mapped = KeyEvent.VK_CAPS_LOCK;
+ break;
+ case Misc.META_L:
+ case Misc.META_R:
+ mapped = KeyEvent.VK_META;
+ break;
+ case Misc.ALT_L:
+ case Misc.ALT_R:
+ mapped = KeyEvent.VK_ALT;
+ break;
+ case Misc.DELETE:
+ mapped = KeyEvent.VK_DELETE;
+ break;
+ default:
+ mapped = KeyEvent.VK_UNDEFINED;
+ }
+ }
+ // Map Latin1 characters.
+ else if (keysym < 256)
+ {
+ // TODO: Add missing mappings, if any.
+ // Lowercase characters are mapped to
+ // their corresponding upper case pendants.
+ if (keysym >= Latin1.A_SMALL && keysym <= Latin1.Z_SMALL)
+ mapped = keysym - 0x20;
+ // Uppercase characters are mapped 1:1.
+ else if (keysym >= Latin1.A && keysym <= Latin1.Z)
+ mapped = keysym;
+ // Digits are mapped 1:1.
+ else if (keysym >= Latin1.NUM_0 && keysym <= Latin1.NUM_9)
+ mapped = keysym;
+ else
+ {
+ switch (keysym)
+ {
+ case Latin1.SPACE:
+ mapped = KeyEvent.VK_SPACE;
+ break;
+ case Latin1.EXCLAM:
+ mapped = KeyEvent.VK_EXCLAMATION_MARK;
+ break;
+ case Latin1.QUOTE_DBL:
+ mapped = KeyEvent.VK_QUOTEDBL;
+ break;
+ case Latin1.NUMBER_SIGN:
+ mapped = KeyEvent.VK_NUMBER_SIGN;
+ break;
+ case Latin1.DOLLAR:
+ mapped = KeyEvent.VK_DOLLAR;
+ break;
+ case Latin1.AMPERSAND:
+ mapped = KeyEvent.VK_AMPERSAND;
+ break;
+ case Latin1.APOSTROPHE:
+ mapped = KeyEvent.VK_QUOTE;
+ break;
+ case Latin1.PAREN_LEFT:
+ mapped = KeyEvent.VK_LEFT_PARENTHESIS;
+ break;
+ case Latin1.PAREN_RIGHT:
+ mapped = KeyEvent.VK_RIGHT_PARENTHESIS;
+ break;
+ case Latin1.ASTERISK:
+ mapped = KeyEvent.VK_ASTERISK;
+ break;
+ case Latin1.PLUS:
+ mapped = KeyEvent.VK_PLUS;
+ break;
+ case Latin1.COMMA:
+ mapped = KeyEvent.VK_COMMA;
+ break;
+ case Latin1.MINUS:
+ mapped = KeyEvent.VK_MINUS;
+ break;
+ case Latin1.PERIOD:
+ mapped = KeyEvent.VK_PERIOD;
+ break;
+ case Latin1.SLASH:
+ mapped = KeyEvent.VK_SLASH;
+ break;
+ case Latin1.COLON:
+ mapped = KeyEvent.VK_COLON;
+ break;
+ case Latin1.SEMICOLON:
+ mapped = KeyEvent.VK_SEMICOLON;
+ break;
+ case Latin1.LESS:
+ mapped = KeyEvent.VK_LESS;
+ break;
+ case Latin1.EQUAL:
+ mapped = KeyEvent.VK_EQUALS;
+ break;
+ case Latin1.GREATER:
+ mapped = KeyEvent.VK_GREATER;
+ break;
+ case Latin1.AT:
+ mapped = KeyEvent.VK_AT;
+ break;
+ case Latin1.BRACKET_LEFT:
+ mapped = KeyEvent.VK_OPEN_BRACKET;
+ break;
+ case Latin1.BACKSLASH:
+ mapped = KeyEvent.VK_BACK_SLASH;
+ break;
+ case Latin1.BRACKET_RIGHT:
+ mapped = KeyEvent.VK_CLOSE_BRACKET;
+ break;
+ case Latin1.ASCII_CIRCUM:
+ mapped = KeyEvent.VK_CIRCUMFLEX;
+ break;
+ case Latin1.UNDERSCORE:
+ mapped = KeyEvent.VK_UNDERSCORE;
+ break;
+ case Latin1.GRAVE:
+ mapped = KeyEvent.VK_DEAD_GRAVE;
+ break;
+ case Latin1.BRACE_LEFT:
+ mapped = KeyEvent.VK_BRACELEFT;
+ break;
+ case Latin1.BRACE_RIGHT:
+ mapped = KeyEvent.VK_BRACERIGHT;
+ break;
+ case Latin1.ASCII_TILDE:
+ mapped = KeyEvent.VK_DEAD_TILDE;
+ break;
+ case Latin1.EXCLAM_DOWN:
+ mapped = KeyEvent.VK_INVERTED_EXCLAMATION_MARK;
+ break;
+ default:
+ mapped = KeyEvent.VK_UNDEFINED;
+ }
+ }
+ }
+ return mapped;
+ }
+
+ /**
+ * Maps X keycodes+modifiers to Java keychars.
+ *
+ * @param xInput The X Input to use for mapping
+ * @param xKeyCode the X keycode
+ * @param xMods the X key modifiers
+ *
+ * @return the Java keychar
+ */
+ static char mapToKeyChar(gnu.x11.Input xInput, int xKeyCode, int xMods)
+ {
+ char mapped = KeyEvent.CHAR_UNDEFINED;
+ char keysym = (char) xInput.keycode_to_keysym(xKeyCode, xMods, false);
+ // FIXME: Map other encodings properly.
+ if (keysym < 256) // Latin1.
+ {
+ mapped = keysym;
+ }
+ return mapped;
+ }
+
+ /**
+ * Maps X modifier masks to AWT modifier masks.
+ *
+ * @param xMods the X modifiers
+ *
+ * @return the AWT modifiers
+ */
+ static int mapModifiers(int xMods)
+ {
+ int mods = 0;
+
+ if ((xMods & Input.SHIFT_MASK) != 0)
+ mods |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK;
+ if ((xMods & Input.ALT_MASK) != 0)
+ mods |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK;
+ if ((xMods & Input.CONTROL_MASK) != 0)
+ mods |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK;
+
+ return mods;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/x/XDialogPeer.java
new file mode 100644
index 00000000000..45ad24d67e9
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XDialogPeer.java
@@ -0,0 +1,61 @@
+/* XDialogPeer.java -- The peer for AWT dialogs
+ 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.x;
+
+import java.awt.Dialog;
+import java.awt.peer.DialogPeer;
+
+public class XDialogPeer
+ extends XWindowPeer
+ implements DialogPeer
+{
+
+ XDialogPeer(Dialog target)
+ {
+ super(target);
+ }
+
+ public void setResizable(boolean resizeable)
+ {
+ }
+
+ public void setTitle(String title)
+ {
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XEventPump.java b/libjava/classpath/gnu/java/awt/peer/x/XEventPump.java
new file mode 100644
index 00000000000..870edf3796d
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XEventPump.java
@@ -0,0 +1,287 @@
+/* XEventPump.java -- Pumps events from X to AWT
+ 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.x;
+
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.ComponentEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.PaintEvent;
+import java.util.HashMap;
+
+import gnu.x11.Display;
+import gnu.x11.event.ButtonPress;
+import gnu.x11.event.ButtonRelease;
+import gnu.x11.event.ConfigureNotify;
+import gnu.x11.event.Event;
+import gnu.x11.event.Expose;
+import gnu.x11.event.Input;
+import gnu.x11.event.KeyPress;
+import gnu.x11.event.KeyRelease;
+import gnu.x11.event.MotionNotify;
+
+/**
+ * Fetches events from X, translates them to AWT events and pumps them up
+ * into the AWT event queue.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class XEventPump
+ implements Runnable
+{
+
+ /**
+ * The X Display from which we fetch and pump up events.
+ */
+ private Display display;
+
+ /**
+ * Maps X Windows to AWT Windows to be able to correctly determine the
+ * event targets.
+ */
+ private HashMap windows;
+
+ /**
+ * Indicates if we are currently inside a drag operation. This is
+ * set to the button ID when a button is pressed and to -1 (indicating
+ * that no drag is active) when the mouse is released.
+ */
+ private int drag;
+
+ /**
+ * Creates a new XEventPump for the specified X Display.
+ *
+ * @param d the X Display
+ */
+ XEventPump(Display d)
+ {
+ display = d;
+ windows = new HashMap();
+ drag = -1;
+ Thread t = new Thread(this);
+ t.start();
+ }
+
+ /**
+ * The main event pump loop. This basically fetches events from the
+ * X Display and pumps them into the system event queue.
+ */
+ public void run()
+ {
+ while (display.connected)
+ {
+ try
+ {
+ Event xEvent = display.next_event();
+ handleEvent(xEvent);
+ }
+ catch (ThreadDeath death)
+ {
+ // If someone wants to kill us, let them.
+ return;
+ }
+ catch (Throwable x)
+ {
+ System.err.println("Exception during event dispatch:");
+ x.printStackTrace(System.err);
+ }
+ }
+ }
+
+ /**
+ * Adds an X Window to AWT Window mapping. This is required so that the
+ * event pump can correctly determine the event targets.
+ *
+ * @param xWindow the X Window
+ * @param awtWindow the AWT Window
+ */
+ void registerWindow(gnu.x11.Window xWindow, Window awtWindow)
+ {
+ if (XToolkit.DEBUG)
+ System.err.println("registering window id: " + xWindow.id);
+ windows.put(new Integer(xWindow.id), awtWindow);
+ }
+
+ void unregisterWindow(gnu.x11.Window xWindow)
+ {
+ windows.remove(new Integer(xWindow.id));
+ }
+
+ private void handleEvent(Event xEvent)
+ {
+ Integer key = new Integer(xEvent.window_id());;
+ Window awtWindow = (Window) windows.get(key);
+
+ if (XToolkit.DEBUG)
+ System.err.println("fetched event: " + xEvent);
+ switch (xEvent.code())
+ {
+ case ButtonPress.CODE:
+ ButtonPress bp = (ButtonPress) xEvent;
+ // Create and post the mouse event.
+ int button = bp.detail();
+ drag = button;
+ MouseEvent mp = new MouseEvent(awtWindow, MouseEvent.MOUSE_PRESSED,
+ System.currentTimeMillis(), 0,
+ bp.event_x(), bp.event_y(),
+ 1, false, button);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mp);
+ break;
+ case ButtonRelease.CODE:
+ ButtonRelease br = (ButtonRelease) xEvent;
+ drag = -1;
+ MouseEvent mr = new MouseEvent(awtWindow, MouseEvent.MOUSE_RELEASED,
+ System.currentTimeMillis(), 0,
+ br.event_x(), br.event_y(),
+ 1, false, br.detail());
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mr);
+ break;
+ case MotionNotify.CODE:
+ MotionNotify mn = (MotionNotify) xEvent;
+ MouseEvent mm;
+ if (drag == -1)
+ {
+ mm = new MouseEvent(awtWindow, MouseEvent.MOUSE_MOVED,
+ System.currentTimeMillis(), 0,
+ mn.event_x(), mn.event_y(),
+ 1, false);
+ }
+ else
+ {
+ mm = new MouseEvent(awtWindow, MouseEvent.MOUSE_DRAGGED,
+ System.currentTimeMillis(), 0,
+ mn.event_x(), mn.event_y(),
+ 1, false);
+ }
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mm);
+ break;
+ case ConfigureNotify.CODE:
+ ConfigureNotify c = (ConfigureNotify) xEvent;
+ if (XToolkit.DEBUG)
+ System.err.println("resize request for window id: " + key);
+
+ // Detect and report size changes.
+ if (c.width() != awtWindow.getWidth()
+ || c.height() != awtWindow.getHeight())
+ {
+ if (XToolkit.DEBUG)
+ System.err.println("Setting size on AWT window: " + c.width()
+ + ", " + c.height() + ", " + awtWindow.getWidth()
+ + ", " + awtWindow.getHeight());
+ ((XWindowPeer) awtWindow.getPeer()).callback = true;
+ awtWindow.setSize(c.width(), c.height());
+ ((XWindowPeer) awtWindow.getPeer()).callback = false;
+ }
+ break;
+ case Expose.CODE:
+ Expose exp = (Expose) xEvent;
+ if (XToolkit.DEBUG)
+ System.err.println("expose request for window id: " + key);
+ Rectangle r = new Rectangle(exp.x(), exp.y(), exp.width(),
+ exp.height());
+ //System.err.println("expose paint: " + r);
+ // We need to clear the background of the exposed rectangle.
+ Graphics g = awtWindow.getGraphics();
+ g.clearRect(r.x, r.y, r.width, r.height);
+ g.dispose();
+ PaintEvent pev = new PaintEvent(awtWindow, PaintEvent.PAINT, r);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(pev);
+ break;
+ case KeyPress.CODE:
+ case KeyRelease.CODE:
+ handleKeyEvent(xEvent, awtWindow);
+ break;
+ default:
+ if (XToolkit.DEBUG)
+ System.err.println("Unhandled X event: " + xEvent);
+ }
+ }
+
+ /**
+ * Handles key events from X.
+ *
+ * @param xEvent the X event
+ * @param awtWindow the AWT window to which the event gets posted
+ */
+ private void handleKeyEvent(Event xEvent, Window awtWindow)
+ {
+ Input keyEvent = (Input) xEvent;
+ int xKeyCode = keyEvent.detail();
+ int xMods = keyEvent.state();
+ int keyCode = KeyboardMapping.mapToKeyCode(xEvent.display.input, xKeyCode,
+ xMods);
+ char keyChar = KeyboardMapping.mapToKeyChar(xEvent.display.input, xKeyCode,
+ xMods);
+ if (XToolkit.DEBUG)
+ System.err.println("XEventPump.handleKeyEvent: " + xKeyCode + ", "
+ + xMods + ": " + ((int) keyChar) + ", " + keyCode);
+ int awtMods = KeyboardMapping.mapModifiers(xMods);
+ long when = System.currentTimeMillis();
+ KeyEvent ke;
+ if (keyEvent.code() == KeyPress.CODE)
+ {
+ ke = new KeyEvent(awtWindow, KeyEvent.KEY_PRESSED, when,
+ awtMods, keyCode,
+ KeyEvent.CHAR_UNDEFINED);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke);
+ if (keyChar != KeyEvent.CHAR_UNDEFINED)
+ {
+ ke = new KeyEvent(awtWindow, KeyEvent.KEY_TYPED, when,
+ awtMods, KeyEvent.VK_UNDEFINED,
+ keyChar);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke);
+ }
+
+ }
+ else
+ {
+ ke = new KeyEvent(awtWindow, KeyEvent.KEY_RELEASED, when,
+ awtMods, keyCode,
+ KeyEvent.CHAR_UNDEFINED);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke);
+ }
+
+ }
+
+
+}
+
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XFontPeer.java b/libjava/classpath/gnu/java/awt/peer/x/XFontPeer.java
new file mode 100644
index 00000000000..fd293d8dd43
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XFontPeer.java
@@ -0,0 +1,766 @@
+/* XFontPeer.java -- The font peer for X
+ 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.x;
+
+import java.awt.AWTError;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.awt.font.TextAttribute;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.CharacterIterator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+
+import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.x11.Display;
+import gnu.x11.Fontable;
+
+/**
+ * The bridge from AWT to X fonts.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class XFontPeer
+ extends ClasspathFontPeer
+{
+
+ /**
+ * The font mapping as specified in the file fonts.properties.
+ */
+ private static Properties fontProperties;
+ static
+ {
+ fontProperties = new Properties();
+ InputStream in = XFontPeer.class.getResourceAsStream("fonts.properties");
+ try
+ {
+ fontProperties.load(in);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * The FontMetrics implementation for XFontPeer.
+ */
+ private class XFontMetrics
+ extends FontMetrics
+ {
+ /**
+ * The ascent of the font.
+ */
+ int ascent;
+
+ /**
+ * The descent of the font.
+ */
+ int descent;
+
+ /**
+ * The maximum of the character advances.
+ */
+ private int maxAdvance;
+
+ /**
+ * The internal leading.
+ */
+ int leading;
+
+ /**
+ * Cached string metrics. This caches string metrics locally so that the
+ * server doesn't have to be asked each time.
+ */
+ private HashMap metricsCache;
+
+ /**
+ * The widths of the characters indexed by the characters themselves.
+ */
+ private int[] charWidths;
+
+ /**
+ * Creates a new XFontMetrics for the specified font.
+ *
+ * @param font the font
+ */
+ protected XFontMetrics(Font font)
+ {
+ super(font);
+ metricsCache = new HashMap();
+ Fontable.FontReply info = getXFont().info();
+ ascent = info.font_ascent();
+ descent = info.font_descent();
+ maxAdvance = info.max_bounds().character_width();
+ leading = 0; // TODO: Not provided by X. Possible not needed.
+
+ if (info.min_byte1() == 0 && info.max_byte1() == 0)
+ readCharWidthsLinear(info);
+ else
+ readCharWidthsNonLinear(info);
+ }
+
+ /**
+ * Reads the character widths when specified in a linear fashion. That is
+ * when the min-byte1 and max-byte2 fields are both zero in the X protocol.
+ *
+ * @param info the font info reply
+ */
+ private void readCharWidthsLinear(Fontable.FontReply info)
+ {
+ int startIndex = info.min_char_or_byte2();
+ int endIndex = info.max_char_or_byte2();
+ charWidths = new int[endIndex + 1];
+ // All the characters before startIndex are zero width.
+ for (int i = 0; i < startIndex; i++)
+ {
+ charWidths[i] = 0;
+ }
+ // All the other character info is fetched from the font info.
+ int index = startIndex;
+ Iterator charInfos = info.char_infos().iterator();
+ while (charInfos.hasNext())
+ {
+ Fontable.FontReply.CharInfo charInfo =
+ (Fontable.FontReply.CharInfo) charInfos.next();
+ charWidths[index] = charInfo.character_width();
+ index++;
+ }
+ }
+
+ private void readCharWidthsNonLinear(Fontable.FontReply info)
+ {
+ // TODO: Implement.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Returns the ascent of the font.
+ *
+ * @return the ascent of the font
+ */
+ public int getAscent()
+ {
+ return ascent;
+ }
+
+ /**
+ * Returns the descent of the font.
+ *
+ * @return the descent of the font
+ */
+ public int getDescent()
+ {
+ return descent;
+ }
+
+ /**
+ * Returns the overall height of the font. This is the distance from
+ * baseline to baseline (usually ascent + descent + leading).
+ *
+ * @return the overall height of the font
+ */
+ public int getHeight()
+ {
+ return ascent + descent;
+ }
+
+ /**
+ * Returns the leading of the font.
+ *
+ * @return the leading of the font
+ */
+ public int getLeading()
+ {
+ return leading;
+ }
+
+ /**
+ * Returns the maximum advance for this font.
+ *
+ * @return the maximum advance for this font
+ */
+ public int getMaxAdvance()
+ {
+ return maxAdvance;
+ }
+
+ /**
+ * Determines the width of the specified character <code>c</code>.
+ *
+ * @param c the character
+ *
+ * @return the width of the character
+ */
+ public int charWidth(char c)
+ {
+ int width;
+ if (c > charWidths.length)
+ width = charWidths['?'];
+ else
+ width = charWidths[c];
+ return width;
+ }
+
+ /**
+ * Determines the overall width of the specified string.
+ *
+ * @param c the char buffer holding the string
+ * @param offset the starting offset of the string in the buffer
+ * @param length the number of characters in the string buffer
+ *
+ * @return the overall width of the specified string
+ */
+ public int charsWidth(char[] c, int offset, int length)
+ {
+ int width = 0;
+ if (c.length > 0 && length > 0)
+ {
+ String s = new String(c, offset, length);
+ width = stringWidth(s);
+ }
+ return width;
+ }
+
+ /**
+ * Determines the overall width of the specified string.
+ *
+ * @param s the string
+ *
+ * @return the overall width of the specified string
+ */
+ public int stringWidth(String s)
+ {
+ int width = 0;
+ if (s.length() > 0)
+ {
+ if (metricsCache.containsKey(s))
+ {
+ width = ((Integer) metricsCache.get(s)).intValue();
+ }
+ else
+ {
+ Fontable.TextExtentReply extents = getXFont().text_extent(s);
+ /*
+ System.err.println("string: '" + s + "' : ");
+ System.err.println("ascent: " + extents.getAscent());
+ System.err.println("descent: " + extents.getDescent());
+ System.err.println("overall ascent: " + extents.getOverallAscent());
+ System.err.println("overall descent: " + extents.getOverallDescent());
+ System.err.println("overall width: " + extents.getOverallWidth());
+ System.err.println("overall left: " + extents.getOverallLeft());
+ System.err.println("overall right: " + extents.getOverallRight());
+ */
+ width = extents.overall_width(); // + extents.overall_left();
+ //System.err.println("String: " + s + ", width: " + width);
+ metricsCache.put(s, new Integer(width));
+ }
+ }
+ //System.err.print("stringWidth: '" + s + "': ");
+ //System.err.println(width);
+ return width;
+ }
+ }
+
+ /**
+ * The LineMetrics implementation for the XFontPeer.
+ */
+ private class XLineMetrics
+ extends LineMetrics
+ {
+
+ /**
+ * Returns the ascent of the font.
+ *
+ * @return the ascent of the font
+ */
+ public float getAscent()
+ {
+ return fontMetrics.ascent;
+ }
+
+ public int getBaselineIndex()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException();
+ }
+
+ public float[] getBaselineOffsets()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the descent of the font.
+ *
+ * @return the descent of the font
+ */
+ public float getDescent()
+ {
+ return fontMetrics.descent;
+ }
+
+ /**
+ * Returns the overall height of the font. This is the distance from
+ * baseline to baseline (usually ascent + descent + leading).
+ *
+ * @return the overall height of the font
+ */
+ public float getHeight()
+ {
+ return fontMetrics.ascent + fontMetrics.descent;
+ }
+
+ /**
+ * Returns the leading of the font.
+ *
+ * @return the leading of the font
+ */
+ public float getLeading()
+ {
+ return fontMetrics.leading;
+ }
+
+ public int getNumChars()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException();
+ }
+
+ public float getStrikethroughOffset()
+ {
+ return 0.F; // TODO: Provided by X??
+ }
+
+ public float getStrikethroughThickness()
+ {
+ return 1.F; // TODO: Provided by X??
+ }
+
+ public float getUnderlineOffset()
+ {
+ return 0.F; // TODO: Provided by X??
+ }
+
+ public float getUnderlineThickness()
+ {
+ return 1.F; // TODO: Provided by X??
+ }
+
+ }
+
+ /**
+ * The X font.
+ */
+ private gnu.x11.Font xfont;
+
+ private String name;
+
+ private int style;
+
+ private int size;
+
+ /**
+ * The font metrics for this font.
+ */
+ XFontMetrics fontMetrics;
+
+ /**
+ * Creates a new XFontPeer for the specified font name, style and size.
+ *
+ * @param name the font name
+ * @param style the font style (bold / italic / normal)
+ * @param size the size of the font
+ */
+ public XFontPeer(String name, int style, int size)
+ {
+ super(name, style, size);
+ this.name = name;
+ this.style = style;
+ this.size = size;
+ }
+
+ /**
+ * Creates a new XFontPeer for the specified font name and style
+ * attributes.
+ *
+ * @param name the font name
+ * @param atts the font attributes
+ */
+ public XFontPeer(String name, Map atts)
+ {
+ super(name, atts);
+ String family = name;
+ if (family == null || family.equals(""))
+ family = (String) atts.get(TextAttribute.FAMILY);
+ if (family == null)
+ family = "SansSerif";
+
+ int size = 12;
+ Float sizeFl = (Float) atts.get(TextAttribute.SIZE);
+ if (sizeFl != null)
+ size = sizeFl.intValue();
+
+ int style = 0;
+ // Detect italic attribute.
+ Float posture = (Float) atts.get(TextAttribute.POSTURE);
+ if (posture != null && !posture.equals(TextAttribute.POSTURE_REGULAR))
+ style |= Font.ITALIC;
+
+ // Detect bold attribute.
+ Float weight = (Float) atts.get(TextAttribute.WEIGHT);
+ if (weight != null && weight.compareTo(TextAttribute.WEIGHT_REGULAR) > 0)
+ style |= Font.BOLD;
+
+ this.name = name;
+ this.style = style;
+ this.size = size;
+ }
+
+ /**
+ * Initializes the font peer with the specified attributes. This method is
+ * called from both constructors.
+ *
+ * @param name the font name
+ * @param style the font style
+ * @param size the font size
+ */
+ private void init(String name, int style, int size)
+ {
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice dev = env.getDefaultScreenDevice();
+ if (dev instanceof XGraphicsDevice)
+ {
+ Display display = ((XGraphicsDevice) dev).getDisplay();
+ String fontDescr = encodeFont(name, style, size);
+ if (XToolkit.DEBUG)
+ System.err.println("XLFD font description: " + fontDescr);
+ xfont = new gnu.x11.Font(display, fontDescr);
+ }
+ else
+ {
+ throw new AWTError("Local GraphicsEnvironment is not XWindowGraphicsEnvironment");
+ }
+ }
+
+ public boolean canDisplay(Font font, char c)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public int canDisplayUpTo(Font font, CharacterIterator i, int start, int limit)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public String getSubFamilyName(Font font, Locale locale)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public String getPostScriptName(Font font)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public int getNumGlyphs(Font font)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public int getMissingGlyphCode(Font font)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public byte getBaselineFor(Font font, char c)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public String getGlyphName(Font font, int glyphIndex)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public GlyphVector createGlyphVector(Font font, FontRenderContext frc,
+ CharacterIterator ci)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public GlyphVector createGlyphVector(Font font, FontRenderContext ctx,
+ int[] glyphCodes)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public GlyphVector layoutGlyphVector(Font font, FontRenderContext frc,
+ char[] chars, int start, int limit,
+ int flags)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @param font the font for which to fetch the font metrics
+ *
+ * @return the font metrics for the specified font
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ if (font.getPeer() != this)
+ throw new AWTError("The specified font has a different peer than this");
+
+ if (fontMetrics == null)
+ fontMetrics = new XFontMetrics(font);
+ return fontMetrics;
+ }
+
+ /**
+ * Frees the font in the X server.
+ */
+ protected void finalize()
+ {
+ if (xfont != null)
+ xfont.close();
+ }
+
+ public boolean hasUniformLineMetrics(Font font)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Returns the line metrics for this font and the specified string and
+ * font render context.
+ */
+ public LineMetrics getLineMetrics(Font font, CharacterIterator ci, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return new XLineMetrics();
+ }
+
+ public Rectangle2D getMaxCharBounds(Font font, FontRenderContext rc)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Rectangle2D getStringBounds(Font font, CharacterIterator ci,
+ int begin, int limit, FontRenderContext frc)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Encodes a font name + style + size specification into a X logical font
+ * description (XLFD) as described here:
+ *
+ * http://www.meretrx.com/e93/docs/xlfd.html
+ *
+ * This is implemented to look up the font description in the
+ * fonts.properties of this package.
+ *
+ * @param name the font name
+ * @param atts the text attributes
+ *
+ * @return the encoded font description
+ */
+ static String encodeFont(String name, Map atts)
+ {
+ String family = name;
+ if (family == null || family.equals(""))
+ family = (String) atts.get(TextAttribute.FAMILY);
+ if (family == null)
+ family = "SansSerif";
+
+ int size = 12;
+ Float sizeFl = (Float) atts.get(TextAttribute.SIZE);
+ if (sizeFl != null)
+ size = sizeFl.intValue();
+
+ int style = 0;
+ // Detect italic attribute.
+ Float posture = (Float) atts.get(TextAttribute.POSTURE);
+ if (posture != null && !posture.equals(TextAttribute.POSTURE_REGULAR))
+ style |= Font.ITALIC;
+
+ // Detect bold attribute.
+ Float weight = (Float) atts.get(TextAttribute.WEIGHT);
+ if (weight != null && weight.compareTo(TextAttribute.WEIGHT_REGULAR) > 0)
+ style |= Font.BOLD;
+
+ return encodeFont(name, style, size);
+ }
+
+ /**
+ * Encodes a font name + style + size specification into a X logical font
+ * description (XLFD) as described here:
+ *
+ * http://www.meretrx.com/e93/docs/xlfd.html
+ *
+ * This is implemented to look up the font description in the
+ * fonts.properties of this package.
+ *
+ * @param name the font name
+ * @param style the font style
+ * @param size the font size
+ *
+ * @return the encoded font description
+ */
+ static String encodeFont(String name, int style, int size)
+ {
+ StringBuilder key = new StringBuilder();
+ key.append(validName(name));
+ key.append('.');
+ switch (style)
+ {
+ case Font.BOLD:
+ key.append("bold");
+ break;
+ case Font.ITALIC:
+ key.append("italic");
+ break;
+ case (Font.BOLD | Font.ITALIC):
+ key.append("bolditalic");
+ break;
+ case Font.PLAIN:
+ default:
+ key.append("plain");
+
+ }
+
+ String protoType = fontProperties.getProperty(key.toString());
+ int s = validSize(size);
+ return protoType.replaceFirst("%d", String.valueOf(s * 10));
+ }
+
+ /**
+ * Checks the specified font name for a valid font name. If the font name
+ * is not known, then this returns 'sansserif' as fallback.
+ *
+ * @param name the font name to check
+ *
+ * @return a valid font name
+ */
+ static String validName(String name)
+ {
+ String retVal;
+ if (name.equalsIgnoreCase("sansserif")
+ || name.equalsIgnoreCase("serif")
+ || name.equalsIgnoreCase("monospaced")
+ || name.equalsIgnoreCase("dialog")
+ || name.equalsIgnoreCase("dialoginput"))
+ {
+ retVal = name.toLowerCase();
+ }
+ else
+ {
+ retVal = "sansserif";
+ }
+ return retVal;
+ }
+
+ /**
+ * Translates an arbitrary point size to a size that is typically available
+ * on an X server. These are the sizes 8, 10, 12, 14, 18 and 24.
+ *
+ * @param size the queried size
+ * @return the real available size
+ */
+ private static final int validSize(int size)
+ {
+ int val;
+ if (size <= 9)
+ val = 8;
+ else if (size <= 11)
+ val = 10;
+ else if (size <= 13)
+ val = 12;
+ else if (size <= 17)
+ val = 14;
+ else if (size <= 23)
+ val = 18;
+ else
+ val = 24;
+ return val;
+ }
+
+ /**
+ * Returns the X Font reference. This lazily loads the font when first
+ * requested.
+ *
+ * @return the X Font reference
+ */
+ gnu.x11.Font getXFont()
+ {
+ if (xfont == null)
+ {
+ init(name, style, size);
+ }
+ return xfont;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XFontPeer2.java b/libjava/classpath/gnu/java/awt/peer/x/XFontPeer2.java
new file mode 100644
index 00000000000..25371de1a41
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XFontPeer2.java
@@ -0,0 +1,335 @@
+/* XFontPeer2.java -- A Java based TTF font peer for X
+ 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.x;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.Locale;
+import java.util.Map;
+
+import gnu.java.awt.font.FontDelegate;
+import gnu.java.awt.font.FontFactory;
+import gnu.java.awt.peer.ClasspathFontPeer;
+
+public class XFontPeer2
+ extends ClasspathFontPeer
+{
+
+ private class XLineMetrics
+ extends LineMetrics
+ {
+
+ private Font font;
+// private CharacterIterator characterIterator;
+// private int begin;
+// private int limit;
+ private FontRenderContext fontRenderContext;
+ XLineMetrics(Font f, CharacterIterator ci, int b, int l,
+ FontRenderContext rc)
+ {
+ font = f;
+// characterIterator = ci;
+// begin = b;
+// limit = l;
+ fontRenderContext = rc;
+ }
+
+ public float getAscent()
+ {
+ return fontDelegate.getAscent(font.getSize(), fontRenderContext.getTransform(),
+ fontRenderContext.isAntiAliased(),
+ fontRenderContext.usesFractionalMetrics(), true);
+ }
+
+ public int getBaselineIndex()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public float[] getBaselineOffsets()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public float getDescent()
+ {
+ return (int) fontDelegate.getDescent(font.getSize(),
+ new AffineTransform(), false, false,
+ false);
+ }
+
+ public float getHeight()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public float getLeading()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public int getNumChars()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public float getStrikethroughOffset()
+ {
+ return 0.F;
+ }
+
+ public float getStrikethroughThickness()
+ {
+ return 0.F;
+ }
+
+ public float getUnderlineOffset()
+ {
+ return 0.F;
+ }
+
+ public float getUnderlineThickness()
+ {
+ return 0.F;
+ }
+
+ }
+
+ private class XFontMetrics
+ extends FontMetrics
+ {
+ XFontMetrics(Font f)
+ {
+ super(f);
+ }
+
+ public int getAscent()
+ {
+ return (int) fontDelegate.getAscent(getFont().getSize(),
+ new AffineTransform(), false, false,
+ false);
+ }
+
+ public int getDescent()
+ {
+ return (int) fontDelegate.getDescent(getFont().getSize(),
+ new AffineTransform(), false, false,
+ false);
+ }
+
+ public int getHeight()
+ {
+ GlyphVector gv = fontDelegate.createGlyphVector(getFont(),
+ new FontRenderContext(new AffineTransform(), false, false),
+ new StringCharacterIterator("m"));
+ Rectangle2D b = gv.getVisualBounds();
+ return (int) b.getHeight();
+ }
+
+ public int charWidth(char c)
+ {
+ Point2D advance = new Point2D.Double();
+ fontDelegate.getAdvance(c, getFont().getSize(), new AffineTransform(),
+ false, false, true, advance);
+ return (int) advance.getX();
+ }
+
+ public int charsWidth(char[] chars, int offs, int len)
+ {
+ return stringWidth(new String(chars, offs, len));
+ }
+
+ public int stringWidth(String s)
+ {
+ GlyphVector gv = fontDelegate.createGlyphVector(getFont(),
+ new FontRenderContext(new AffineTransform(), false, false),
+ new StringCharacterIterator(s));
+ Rectangle2D b = gv.getVisualBounds();
+ return (int) b.getWidth();
+ }
+ }
+
+ private FontDelegate fontDelegate;
+
+ XFontPeer2(String name, int style, int size)
+ {
+ super(name, style, size);
+ try
+ {
+ File fontfile = new File("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf");
+ FileInputStream in = new FileInputStream(fontfile);
+ FileChannel ch = in.getChannel();
+ ByteBuffer buffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
+ fontfile.length());
+ fontDelegate = FontFactory.createFonts(buffer)[0];
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ XFontPeer2(String name, Map atts)
+ {
+ super(name, atts);
+ try
+ {
+ File fontfile = new File("/usr/share/fonts/truetype/freefont/FreeSans.ttf");
+ FileInputStream in = new FileInputStream(fontfile);
+ FileChannel ch = in.getChannel();
+ ByteBuffer buffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
+ fontfile.length());
+ fontDelegate = FontFactory.createFonts(buffer)[0];
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public boolean canDisplay(Font font, char c)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public int canDisplayUpTo(Font font, CharacterIterator i, int start, int limit)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public String getSubFamilyName(Font font, Locale locale)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public String getPostScriptName(Font font)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public int getNumGlyphs(Font font)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public int getMissingGlyphCode(Font font)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public byte getBaselineFor(Font font, char c)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public String getGlyphName(Font font, int glyphIndex)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public GlyphVector createGlyphVector(Font font, FontRenderContext frc, CharacterIterator ci)
+ {
+ return fontDelegate.createGlyphVector(font, frc, ci);
+ }
+
+ public GlyphVector createGlyphVector(Font font, FontRenderContext ctx, int[] glyphCodes)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public GlyphVector layoutGlyphVector(Font font, FontRenderContext frc, char[] chars, int start, int limit, int flags)
+ {
+ StringCharacterIterator i = new StringCharacterIterator(new String(chars), start, limit, 0);
+ return fontDelegate.createGlyphVector(font, frc, i);
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new XFontMetrics(font);
+ }
+
+ public boolean hasUniformLineMetrics(Font font)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public LineMetrics getLineMetrics(Font font, CharacterIterator ci, int begin, int limit, FontRenderContext rc)
+ {
+ return new XLineMetrics(font, ci, begin, limit, rc);
+ }
+
+ public Rectangle2D getMaxCharBounds(Font font, FontRenderContext rc)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Rectangle2D getStringBounds(Font font, CharacterIterator ci, int begin, int limit, FontRenderContext frc)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XFramePeer.java b/libjava/classpath/gnu/java/awt/peer/x/XFramePeer.java
new file mode 100644
index 00000000000..439a2a7bbf1
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XFramePeer.java
@@ -0,0 +1,140 @@
+/* XFramePeer.java -- The X FramePeer implementation
+ 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.x;
+
+import java.awt.Component;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.MenuBar;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.PaintEvent;
+import java.awt.event.WindowEvent;
+import java.awt.peer.FramePeer;
+
+import gnu.java.awt.peer.swing.SwingFramePeer;
+import gnu.x11.Window;
+import gnu.x11.event.Event;
+
+public class XFramePeer
+ extends XWindowPeer
+ implements FramePeer
+{
+
+ XFramePeer(Frame f)
+ {
+ super(f);
+ }
+
+ public void setIconImage(Image image)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void setMenuBar(MenuBar mb)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void setResizable(boolean resizable)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void setTitle(String title)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public int getState()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void setState(int state)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void setMaximizedBounds(Rectangle r)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Check if this frame peer supports being restacked.
+ *
+ * @return true if this frame peer can be restacked,
+ * false otherwise
+ * @since 1.5
+ */
+ public boolean isRestackSupported()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Sets the bounds of this frame peer.
+ *
+ * @param x the new x co-ordinate
+ * @param y the new y co-ordinate
+ * @param width the new width
+ * @param height the new height
+ * @since 1.5
+ */
+ public void setBoundsPrivate(int x, int y, int width, int height)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XGraphics.java b/libjava/classpath/gnu/java/awt/peer/x/XGraphics.java
new file mode 100644
index 00000000000..134d7d3305e
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XGraphics.java
@@ -0,0 +1,792 @@
+/* XGraphics.java -- The Graphics implementation for X
+ 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.x;
+
+import gnu.x11.Colormap;
+import gnu.x11.Data;
+import gnu.x11.Display;
+import gnu.x11.Drawable;
+import gnu.x11.GC;
+import gnu.x11.Pixmap;
+import gnu.x11.Point;
+import gnu.x11.image.ZPixmap;
+
+import java.awt.AWTError;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.text.AttributedCharacterIterator;
+import java.util.HashMap;
+
+public class XGraphics
+ extends Graphics
+ implements Cloneable
+{
+
+ /**
+ * The X Drawable to draw on.
+ */
+ private Drawable xdrawable;
+
+ /**
+ * The X graphics context (GC).
+ */
+ private GC xgc;
+
+ /**
+ * The current translation.
+ */
+ private int translateX;
+ private int translateY;
+
+ /**
+ * The current clip. Possibly null.
+ */
+ private Rectangle clip;
+
+ /**
+ * The current font, possibly null.
+ */
+ private Font font;
+
+ /**
+ * The current foreground color, possibly null.
+ */
+ private Color foreground;
+
+ /**
+ * Indicates if this object has been disposed.
+ */
+ private boolean disposed = false;
+
+ // TODO: Workaround for limitation in current Escher.
+ private Pixmap.Format pixmapFormat;
+ private int imageByteOrder;
+ private int pixelByteCount;
+
+ /**
+ * Creates a new XGraphics on the specified X Drawable.
+ *
+ * @param d the X Drawable for which we create the Graphics
+ */
+ XGraphics(Drawable d)
+ {
+ xdrawable = d;
+ xgc = new GC(d);
+ translateX = 0;
+ translateY = 0;
+ clip = new Rectangle(0, 0, d.width, d.height);
+
+ Display display = xdrawable.display;
+ pixmapFormat = display.default_pixmap_format;
+ imageByteOrder = display.image_byte_order;
+ pixelByteCount = pixmapFormat.bits_per_pixel () / 8;
+ }
+
+ /**
+ * Creates an exact copy of this graphics context.
+ *
+ * @return an exact copy of this graphics context
+ */
+ public Graphics create()
+ {
+ XGraphics copy = (XGraphics) clone();
+ return copy;
+ }
+
+ /**
+ * Translates the origin by (x, y).
+ */
+ public void translate(int x, int y)
+ {
+ translateX += x;
+ translateY += y;
+ if (clip != null)
+ {
+ clip.x -= x;
+ clip.y -= y;
+ }
+ }
+
+ /**
+ * Returns the current foreground color, possibly <code>null</code>.
+ *
+ * @return the current foreground color, possibly <code>null</code>
+ */
+ public Color getColor()
+ {
+ return foreground;
+ }
+
+ /**
+ * Sets the current foreground color. A <code>null</code> value doesn't
+ * change the current setting.
+ *
+ * @param c the foreground color to set
+ */
+ public void setColor(Color c)
+ {
+ if (c != null)
+ {
+ XToolkit tk = (XToolkit) Toolkit.getDefaultToolkit();
+ HashMap colorMap = tk.colorMap;
+ gnu.x11.Color col = (gnu.x11.Color) colorMap.get(c);
+ if (col == null)
+ {
+ Colormap map = xdrawable.display.default_colormap;
+ col = map.alloc_color (c.getRed() * 256,
+ c.getGreen() * 256,
+ c.getBlue() * 256);
+ colorMap.put(c, col);
+ }
+ xgc.set_foreground(col);
+ foreground = c;
+ }
+ }
+
+ public void setPaintMode()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void setXORMode(Color color)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Returns the current font, possibly <code>null</code>.
+ *
+ * @return the current font, possibly <code>null</code>
+ */
+ public Font getFont()
+ {
+ return font;
+ }
+
+ /**
+ * Sets the font on the graphics context. A <code>null</code> value doesn't
+ * change the current setting.
+ *
+ * @param f the font to set
+ */
+ public void setFont(Font f)
+ {
+ if (f != null)
+ {
+ XFontPeer xFontPeer = (XFontPeer) f.getPeer();
+ xgc.set_font(xFontPeer.getXFont());
+ font = f;
+ }
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @param font the font for which we want the font metrics
+ *
+ * @return the font metrics for the specified font
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ if (font == null)
+ {
+ if (this.font == null)
+ setFont(new Font("Dialog", Font.PLAIN, 12));
+ font = this.font;
+ }
+ XFontPeer xFontPeer = (XFontPeer) font.getPeer();
+ return xFontPeer.getFontMetrics(font);
+ }
+
+ /**
+ * Returns the bounds of the current clip.
+ *
+ * @return the bounds of the current clip
+ */
+ public Rectangle getClipBounds()
+ {
+ return clip != null ? clip.getBounds() : null;
+ }
+
+ /**
+ * Clips the current clip with the specified clip.
+ */
+ public void clipRect(int x, int y, int width, int height)
+ {
+ if (clip == null)
+ {
+ clip = new Rectangle(x, y, width, height);
+ }
+ else
+ {
+ computeIntersection(x, y, width, height, clip);
+ }
+ // Update the X clip setting.
+ setXClip(clip.x, clip.y, clip.width, clip.height);
+ }
+
+ /**
+ * Returns <code>true</code> when the specified rectangle intersects with
+ * the current clip, <code>false</code> otherwise. This is overridden to
+ * avoid unnecessary creation of Rectangles via getBounds().
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ *
+ * @return <code>true</code> when the specified rectangle intersects with
+ * the current clip, <code>false</code> otherwise
+ */
+ public boolean hitClip(int x, int y, int w, int h)
+ {
+ boolean hit;
+ if (clip == null)
+ {
+ hit = true;
+ }
+ else
+ {
+ // It's easier to determine if the rectangle lies outside the clip,
+ // so we determine that and reverse the result (if it's not completely
+ // outside, it most likely hits the clip rectangle).
+ int x2 = x + w;
+ int y2 = y + h;
+ int clipX2 = clip.x + clip.width;
+ int clipY2 = clip.y + clip.height;
+ boolean outside = (x < clip.x && x2 < clip.x) // Left.
+ || (x > clipX2 && x2 > clipX2) // Right.
+ || (y < clip.y && y2 < clip.y) // Top.
+ || (y > clipY2 && y2 > clipY2); // Bottom.
+ hit = ! outside;
+ }
+ return hit;
+ }
+
+ public void setClip(int x, int y, int width, int height)
+ {
+ if (clip != null)
+ clip.setBounds(x, y, width, height);
+ else
+ clip = new Rectangle(x, y, width, height);
+ setXClip(clip.x, clip.y, clip.width, clip.height);
+ }
+
+ /**
+ * Sets the clip on the X server GC. The coordinates are not yet translated,
+ * this will be performed by the X server.
+ *
+ * @param x the clip, X coordinate
+ * @param y the clip, Y coordinate
+ * @param w the clip, width
+ * @param h the clip, height
+ */
+ private void setXClip(int x, int y, int w, int h)
+ {
+ gnu.x11.Rectangle[] clipRects = new gnu.x11.Rectangle[] {
+ new gnu.x11.Rectangle(x, y, w, h) };
+ xgc.set_clip_rectangles(translateX, translateY, clipRects, GC.YX_BANDED);
+ }
+
+ public Shape getClip()
+ {
+ // Return a copy here, so nobody can trash our clip.
+ return clip == null ? null : clip.getBounds();
+ }
+
+ /**
+ * Sets the current clip.
+ *
+ * @param c the clip to set
+ */
+ public void setClip(Shape c)
+ {
+ if (c != null)
+ {
+ Rectangle b;
+ if (c instanceof Rectangle)
+ {
+ b = (Rectangle) c;
+ }
+ else
+ {
+ b = c.getBounds();
+ }
+ clip.setBounds(b);
+ setXClip(b.x, b.y, b.width, b.height);
+ }
+ else
+ {
+ clip.setBounds(0, 0, xdrawable.width, xdrawable.height);
+ setXClip(0, 0, xdrawable.width, xdrawable.height);
+ }
+ }
+
+ public void copyArea(int x, int y, int width, int height, int dx, int dy)
+ {
+ // Clip and translate src rectangle.
+ int srcX = Math.min(Math.max(x, clip.x), clip.x + clip.width)
+ + translateX;
+ int srcY = Math.min(Math.max(y, clip.y), clip.y + clip.height)
+ + translateY;
+ int srcWidth = Math.min(Math.max(x + width, clip.x),
+ clip.x + clip.width) - x;
+ int srcHeight = Math.min(Math.max(y + height, clip.y),
+ clip.y + clip.height) - y;
+ xdrawable.copy_area(xdrawable, xgc, srcX, srcY, srcWidth, srcHeight,
+ srcX + dx, srcY + dy);
+ }
+
+ /**
+ * Draws a line from point (x1, y1) to point (x2, y2).
+ */
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ //System.err.println("drawLine: " + (x1 + translateX) + ", " + ( y1 + translateY) + ", " + (x2 + translateX) + ", " + (y2 + translateY) + " on: " + xdrawable);
+ xdrawable.line(xgc, x1 + translateX, y1 + translateY,
+ x2 + translateX, y2 + translateY);
+ }
+
+ /**
+ * Fills the specified rectangle.
+ */
+ public void fillRect(int x, int y, int width, int height)
+ {
+ xdrawable.rectangle(xgc, x + translateX, y + translateY,
+ width, height, true);
+ }
+
+ public void clearRect(int x, int y, int width, int height)
+ {
+ xgc.set_foreground(Color.WHITE.getRGB());
+ xdrawable.rectangle(xgc, x, y, width, height, true);
+ if (foreground != null)
+ xgc.set_foreground(foreground.getRGB());
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height, int arcWidth,
+ int arcHeight)
+ {
+ // Draw 4 lines.
+ int arcRadiusX = arcWidth / 2;
+ int arcRadiusY = arcHeight / 2;
+ drawLine(x + arcRadiusX, y, x + width - arcRadiusX, y);
+ drawLine(x, y + arcRadiusY, x, y + height - arcRadiusY);
+ drawLine(x + arcRadiusX, y + height, x + width - arcRadiusX, y + height);
+ drawLine(x + width, y + arcRadiusY, x + width, y + height - arcRadiusY);
+
+ // Draw the 4 arcs at the corners.
+ // Upper left.
+ drawArc(x, y, arcWidth, arcHeight, 90, 90);
+ // Lower left.
+ drawArc(x, y + height - arcHeight, arcWidth, arcHeight, 180, 90);
+ // Upper right.
+ drawArc(x + width - arcWidth, y, arcWidth, arcHeight, 0, 90);
+ // Lower right.
+ drawArc(x + width - arcWidth, y + height - arcHeight, arcWidth, arcHeight,
+ 270, 90);
+ }
+
+ public void fillRoundRect(int x, int y, int width, int height, int arcWidth,
+ int arcHeight)
+ {
+ // Fill the 3 rectangles that make up the inner area.
+ int arcRadiusX = arcWidth / 2;
+ int arcRadiusY = arcHeight / 2;
+ // Left.
+ fillRect(x, y + arcRadiusY, arcRadiusX, height - arcHeight);
+ // Middle.
+ fillRect(x + arcRadiusX, y, width - arcWidth, height);
+ // Right.
+ fillRect(x + width - arcRadiusX, y + arcRadiusY, arcRadiusX,
+ height - arcHeight);
+
+ // Fill the 4 arcs in the corners.
+ // Upper left.
+ fillArc(x, y, arcWidth, arcHeight, 90, 90);
+ // Lower left.
+ fillArc(x, y + height - arcHeight, arcWidth, arcHeight, 180, 90);
+ // Upper right.
+ fillArc(x + width - arcWidth, y, arcWidth, arcHeight, 0, 90);
+ // Lower right.
+ fillArc(x + width - arcWidth, y + height - arcHeight, arcWidth, arcHeight,
+ 270, 90);
+ }
+
+ public void drawOval(int x, int y, int width, int height)
+ {
+ xdrawable.arc(xgc, x, y, width, height, 0, 360 * 64, false);
+ }
+
+ public void fillOval(int x, int y, int width, int height)
+ {
+ xdrawable.arc(xgc, x, y, width, height, 0, 360 * 64, true);
+ }
+
+ public void drawArc(int x, int y, int width, int height, int arcStart,
+ int arcAngle)
+ {
+ xdrawable.arc(xgc, x, y, width, height, arcStart * 64, arcAngle * 64, false);
+ }
+
+ public void fillArc(int x, int y, int width, int height, int arcStart,
+ int arcAngle)
+ {
+ xdrawable.arc(xgc, x, y, width, height, arcStart * 64, arcAngle * 64, true);
+ }
+
+ public void drawPolyline(int[] xPoints, int[] yPoints, int npoints)
+ {
+ int numPoints = Math.min(xPoints.length, yPoints.length);
+ Point[] points = new Point[numPoints];
+ // FIXME: Improve Escher API to accept arrays to avoid creation
+ // of many Point objects.
+ for (int i = 0; i < numPoints; i++)
+ points[i] = new Point(xPoints[i], yPoints[i]);
+ xdrawable.poly_line(xgc, points, Drawable.ORIGIN);
+ }
+
+ public void drawPolygon(int[] xPoints, int[] yPoints, int npoints)
+ {
+ int numPoints = Math.min(xPoints.length, yPoints.length);
+ Point[] points = new Point[numPoints];
+ // FIXME: Improve Escher API to accept arrays to avoid creation
+ // of many Point objects.
+ for (int i = 0; i < numPoints; i++)
+ points[i] = new Point(xPoints[i], yPoints[i]);
+ xdrawable.poly_line(xgc, points, Drawable.ORIGIN);
+ }
+
+ public void fillPolygon(int[] xPoints, int[] yPoints, int npoints)
+ {
+ int numPoints = Math.min(xPoints.length, yPoints.length);
+ Point[] points = new Point[numPoints];
+ // FIXME: Improve Escher API to accept arrays to avoid creation
+ // of many Point objects.
+ for (int i = 0; i < numPoints; i++)
+ points[i] = new Point(xPoints[i], yPoints[i]);
+ xdrawable.fill_poly(xgc, points, Drawable.COMPLEX, Drawable.ORIGIN);
+ }
+
+ /**
+ * Draws the specified string at (x, y).
+ */
+ public void drawString(String string, int x, int y)
+ {
+ if (disposed)
+ throw new AWTError("XGraphics already disposed");
+
+ xdrawable.text(xgc, x + translateX, y + translateY, string);
+ }
+
+ public void drawString(AttributedCharacterIterator ci, int x, int y)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Draws the specified image on the drawable at position (x,y).
+ */
+ public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+ {
+ if (image instanceof XImage)
+ {
+ XImage xim = (XImage) image;
+ Pixmap pm = xim.pixmap;
+ xdrawable.copy_area(pm, xgc, 0, 0, pm.width, pm.height,
+ x + translateX, y + translateY);
+ }
+ else if (image instanceof BufferedImage
+ && ((BufferedImage) image).getTransparency() != Transparency.OPAQUE)
+ {
+ BufferedImage bi = (BufferedImage) image;
+ int width = bi.getWidth();
+ int height = bi.getHeight();
+ Data img = xdrawable.image(x + translateX, y + translateY,
+ width, height, 0xFFFFFFFF, 2);
+
+ // Compute line byte count.
+ int lineBitCount = width * pixmapFormat.bits_per_pixel ();
+ int rem = lineBitCount % pixmapFormat.scanline_pad ();
+ int linePadCount = lineBitCount / pixmapFormat.scanline_pad ()
+ + (rem == 0 ? 0 : 1);
+ int lineByteCount = linePadCount * pixmapFormat.scanline_pad () / 8;
+
+ // Composite source and destination pixel data.
+ int[] trgb = new int[3]; // The device rgb pixels.
+ for (int yy = 0; yy < height; yy++)
+ {
+ for (int xx = 0; xx < width; xx++)
+ {
+ getRGB(xx, yy, img, trgb, lineByteCount);
+ int srgb = bi.getRGB(xx, yy);
+ float alpha = ((srgb >> 24) & 0xff) / 256F;
+ float tAlpha = 1.F - alpha;
+ int red = (srgb >> 16) & 0xFF;
+ int green = (srgb >> 8) & 0xFF;
+ int blue = (srgb) & 0xFF;
+ trgb[0] = (int) (trgb[0] * tAlpha + red * alpha);
+ trgb[1] = (int) (trgb[1] * tAlpha + green * alpha);
+ trgb[2] = (int) (trgb[2] * tAlpha + blue * alpha);
+ setRGB(xx, yy, img, trgb, lineByteCount);
+ }
+ }
+
+ // Now we have the transparent image composited onto the target
+ // Image, now we only must copy it to the Drawable.
+ ZPixmap pm = new ZPixmap(xdrawable.display);
+ pm.width = width;
+ pm.height = height;
+ pm.init();
+ System.arraycopy(img.data, 32, pm.data, 0, img.data.length - 32);
+ xdrawable.put_image(xgc, pm, x + translateX, y + translateY);
+ }
+ else
+ {
+ // Pre-render the image into an XImage.
+ ImageProducer source = image.getSource();
+ ImageConverter conv = new ImageConverter();
+ source.startProduction(conv);
+ XImage xim = conv.getXImage();
+ Pixmap pm = xim.pixmap;
+ xdrawable.copy_area(pm, xgc, 0, 0, pm.width, pm.height,
+ x + translateX, y + translateY);
+ }
+ return true;
+ }
+
+ /**
+ * Helper method to work around limitation in the current Escher impl.
+ *
+ * @param x the x position
+ * @param y the y position
+ * @param img the image data
+ * @param rgb an 3-size array that holds the rgb values on method exit
+ */
+ private void getRGB(int x, int y, Data img, int[] rgb, int lineByteCount)
+ {
+ // TODO: Does this also work on non-RGB devices?
+ int i = y * lineByteCount + pixelByteCount * x;
+ if (imageByteOrder == gnu.x11.image.Image.LSB_FIRST)
+ {//if (i >= 5716-33) System.err.println("lbc: " + lineByteCount + ", " + pixelByteCount);
+ rgb[2] = img.data[32 + i];
+ rgb[1] = img.data[32 + i + 1];
+ rgb[0] = img.data[32 + i + 2];
+ }
+ else
+ { // MSB_FIRST
+ rgb[0] = img.data[32 + i];
+ rgb[1] = img.data[32 + i + 1];
+ rgb[2] = img.data[32 + i + 2];
+ }
+
+ }
+
+ /**
+ * Helper method to work around limitation in the current Escher impl.
+ *
+ * @param x the x position
+ * @param y the y position
+ * @param img the image data
+ * @param rgb an 3-size array that holds the rgb values on method exit
+ */
+ private void setRGB(int x, int y, Data img, int[] rgb, int lineByteCount)
+ {
+ // TODO: Does this also work on non-RGB devices?
+ int i = y * lineByteCount + pixelByteCount * x;
+ if (imageByteOrder == gnu.x11.image.Image.LSB_FIRST)
+ {
+ img.data[32 + i] = (byte) rgb[2];
+ img.data[32 + i + 1] = (byte) rgb[1];
+ img.data[32 + i + 2] = (byte) rgb[0];
+ }
+ else
+ { // MSB_FIRST
+ img.data[32 + i] = (byte) rgb[0];
+ img.data[32 + i + 1] = (byte) rgb[1];
+ img.data[32 + i + 2] = (byte) rgb[2];
+ }
+ }
+
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ ImageObserver observer)
+ {
+ return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null,
+ observer);
+ }
+
+ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2, Color bgcolor,
+ ImageObserver observer)
+ {
+
+ // FIXME: What to do with bgcolor?
+
+ // Scale the image.
+ int sw = image.getWidth(observer);
+ int sh = image.getHeight(observer);
+ double scaleX = Math.abs(dx2 - dx1) / (double) Math.abs(sx2 - sx1);
+ double scaleY = Math.abs(dy2 - dy1) / (double) Math.abs(sy2 - sy1);
+ Image scaled = image.getScaledInstance((int) (scaleX * sw),
+ (int) (scaleY * sh),
+ Image.SCALE_FAST);
+
+ // Scaled source coordinates.
+ int sx1s = (int) (scaleX * Math.min(sx1, sx2));
+ int sx2s = (int) (scaleX * Math.max(sx1, sx2));
+
+ // Temporarily clip to the target rectangle.
+ Rectangle old = clip;
+ clipRect(dx1, dy1, dx2 - dx1, dy2 - dy1);
+
+ // Draw scaled image.
+ boolean res = drawImage(scaled, dx1 - sx1s, dy1 - sx2s, observer);
+
+ // Reset clip.
+ setClip(old);
+
+ return res;
+ }
+
+ /**
+ * Frees any resources associated with this object.
+ */
+ public void dispose()
+ {
+ if (! disposed)
+ {
+ xgc.free();
+ xdrawable.display.flush();
+ disposed = true;
+ }
+ }
+
+ // Additional helper methods.
+
+ /**
+ * Creates and returns an exact copy of this XGraphics.
+ */
+ protected Object clone()
+ {
+ try
+ {
+ XGraphics copy = (XGraphics) super.clone();
+ copy.xgc = xgc.copy();
+ if (clip != null)
+ {
+ copy.clip = new Rectangle(clip);
+ copy.setXClip(clip.x, clip.y, clip.width, clip.height);
+ }
+ return copy;
+ }
+ catch (CloneNotSupportedException ex)
+ {
+ assert false;
+ }
+ return null;
+ }
+
+ /**
+ * Computes the intersection between two rectangles and stores the result
+ * int the second rectangle.
+ *
+ * This method has been copied from {@link javax.swing.SwingUtilities}.
+ *
+ * @param x the x coordinate of the rectangle #1
+ * @param y the y coordinate of the rectangle #1
+ * @param w the width of the rectangle #1
+ * @param h the height of the rectangle #1
+ * @param rect the rectangle #2 and output rectangle
+ */
+ private static void computeIntersection(int x, int y, int w, int h,
+ Rectangle rect)
+ {
+ int x2 = (int) rect.x;
+ int y2 = (int) rect.y;
+ int w2 = (int) rect.width;
+ int h2 = (int) rect.height;
+
+ int dx = (x > x2) ? x : x2;
+ int dy = (y > y2) ? y : y2;
+ int dw = (x + w < x2 + w2) ? (x + w - dx) : (x2 + w2 - dx);
+ int dh = (y + h < y2 + h2) ? (y + h - dy) : (y2 + h2 - dy);
+
+ if (dw >= 0 && dh >= 0)
+ rect.setBounds(dx, dy, dw, dh);
+ else
+ rect.setBounds(0, 0, 0, 0);
+ }
+
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XGraphics2D.java b/libjava/classpath/gnu/java/awt/peer/x/XGraphics2D.java
new file mode 100644
index 00000000000..5dc79ff5c2b
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XGraphics2D.java
@@ -0,0 +1,295 @@
+/* XGraphics2D.java -- A Java based Graphics2D impl for X
+ 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.x;
+
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.geom.AffineTransform;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+
+import gnu.java.awt.java2d.AbstractGraphics2D;
+import gnu.x11.Drawable;
+import gnu.x11.GC;
+import gnu.x11.image.ZPixmap;
+
+public class XGraphics2D
+ extends AbstractGraphics2D
+{
+
+ /**
+ * The X Drawable to draw on.
+ */
+ private Drawable xdrawable;
+
+ /**
+ * The X graphics context (GC).
+ */
+ private GC xgc;
+
+ /**
+ * Indicates if this graphics has already been disposed.
+ */
+ private boolean disposed;
+
+ XGraphics2D(Drawable d)
+ {
+ super();
+ xdrawable = d;
+ xgc = new GC(d);
+ init();
+ disposed = false;
+ //setClip(new Rectangle(0, 0, xdrawable.width, xdrawable.height));
+ }
+
+ /**
+ * Draws a pixel in the target coordinate space using the specified color.
+ *
+ * @param x the x coordinate
+ * @param y the y coordinate
+ */
+ protected void rawSetPixel(int x, int y)
+ {
+ xdrawable.point(xgc, x, y);
+ }
+
+// protected void rawFillPolygon(double[] xpoints, double[] ypoints, int npoints)
+// {
+// Point[] points = new Point[npoints];
+// for (int n = 0; n < npoints; n++)
+// {
+// points[n] = new Point((int) xpoints[n], (int) ypoints[n]);
+// }
+// xdrawable.fill_poly(xgc, points, Drawable.COMPLEX, Drawable.ORIGIN);
+// xdrawable.display.flush();
+// }
+
+ protected void rawDrawLine(int x0, int y0, int x1, int y1)
+ {
+ xdrawable.line(xgc, x0, y0, x1, y1);
+ }
+
+ protected void rawFillRect(int x, int y, int w, int h)
+ {
+ xdrawable.rectangle(xgc, x, y, w, h, true);
+ }
+
+ protected void rawSetForeground(java.awt.Color c)
+ {
+ if (c != null)
+ xgc.set_foreground(c.getRGB());
+ }
+
+ protected void rawSetForeground(int r, int g, int b)
+ {
+ xgc.set_foreground( r << 16 | g << 8 | b );
+ }
+
+ /**
+ * Returns the color model of this Graphics object.
+ *
+ * @return the color model of this Graphics object
+ */
+ protected ColorModel getColorModel()
+ {
+ return Toolkit.getDefaultToolkit().getColorModel();
+ }
+
+ /**
+ * Returns the color model of the target device.
+ *
+ * @return the color model of the target device
+ */
+ protected ColorModel getDestinationColorModel()
+ {
+ return Toolkit.getDefaultToolkit().getColorModel();
+ }
+
+ /**
+ * Returns the bounds of the target.
+ *
+ * @return the bounds of the target
+ */
+ protected Rectangle getDeviceBounds()
+ {
+ return new Rectangle(0, 0, xdrawable.width, xdrawable.height);
+ }
+
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ // FIXME: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void dispose()
+ {
+ if (!disposed)
+ {
+ xgc.free();
+ xdrawable.display.flush();
+ disposed = true;
+ }
+ }
+
+ public Graphics create()
+ {
+ // super.create() returns a copy created by clone(), so it should
+ // be a XGraphics2D.
+ XGraphics2D copy = (XGraphics2D) super.create();
+ copy.xgc = xgc.copy();
+ return copy;
+ }
+
+// /**
+// * Draws the specified image on the drawable at position (x,y).
+// */
+//
+// public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+// {
+// AffineTransform transform = getTransform();
+// int translateX = (int) transform.getTranslateX();
+// int translateY = (int) transform.getTranslateY();
+// if (image instanceof XImage)
+// {
+// XImage xim = (XImage) image;
+// Pixmap pm = xim.pixmap;
+// xdrawable.copy_area(pm, xgc, 0, 0, pm.width, pm.height,
+// x + translateX, y + translateY);
+// }
+// else if (image instanceof BufferedImage)
+// {
+// BufferedImage bufferedImage = (BufferedImage) image;
+// Raster raster = bufferedImage.getData();
+// int w = bufferedImage.getWidth();
+// int h = bufferedImage.getHeight();
+// // Push data to X server.
+// ZPixmap zPixmap = new ZPixmap(xdrawable.display, w, h,
+// xdrawable.display.default_pixmap_format);
+// System.err.println("data buffer length: " + zPixmap.data.length);
+// int[] pixel = new int[4];
+// for (int tx = 0; tx < w; tx++)
+// {
+// for (int ty = 0; ty < h; ty++)
+// {
+// pixel = raster.getPixel(tx, ty, pixel);
+//// System.err.print("r: " + pixel[0]);
+//// System.err.print(", g: " + pixel[1]);
+//// System.err.println(", b: " + pixel[2]);
+// zPixmap.set_red(tx, ty, pixel[0]);
+// zPixmap.set_green(tx, ty, pixel[1]);
+// zPixmap.set_blue(tx, ty, pixel[2]);
+// }
+// }
+// xdrawable.put_image(xgc, zPixmap, x, y);
+// }
+// else
+// {
+// throw new UnsupportedOperationException("Not yet implemented.");
+// }
+// return true;
+// }
+//
+ public void setClip(Shape c)
+ {
+ super.setClip(c);
+ if (c instanceof Rectangle)
+ {
+ Rectangle r = (Rectangle) c;
+ AffineTransform t = getTransform();
+ int translateX = (int) t.getTranslateX();
+ //System.err.println("translateX: " + translateX);
+ int translateY = (int) t.getTranslateY();
+ //System.err.println("translateY: " + translateY);
+ //System.err.println("clip: " + c);
+ gnu.x11.Rectangle clip = new gnu.x11.Rectangle(r.x, r.y, r.width,
+ r.height);
+ xgc.set_clip_rectangles(translateX, translateY,
+ new gnu.x11.Rectangle[]{clip}, GC.UN_SORTED);
+ }
+ }
+
+ /**
+ * Notifies the backend that the raster has changed in the specified
+ * rectangular area. The raster that is provided in this method is always
+ * the same as the one returned in {@link #getDestinationRaster}.
+ * Backends that reflect changes to this raster directly don't need to do
+ * anything here.
+ *
+ * @param raster the updated raster, identical to the raster returned
+ * by {@link #getDestinationRaster()}
+ * @param x the upper left corner of the updated region, X coordinate
+ * @param y the upper lef corner of the updated region, Y coordinate
+ * @param w the width of the updated region
+ * @param h the height of the updated region
+ */
+ protected void updateRaster(Raster raster, int x, int y, int w, int h)
+ {
+ if (w > 0 && h > 0)
+ {
+ ZPixmap zPixmap = new ZPixmap(xdrawable.display, w, h,
+ xdrawable.display.default_pixmap_format);
+ int[] pixel = null;
+ int x1 = x + w;
+ int y1 = y + h;
+ for (int tx = x; tx < x1; tx++)
+ {
+ for (int ty = y; ty < y1; ty++)
+ {
+ pixel = raster.getPixel(tx, ty, pixel);
+ //System.err.println("tx: " + tx + ", ty: " + ty + ", pixel: " + pixel[0] + ", " + pixel[1] + ", " + pixel[2]);
+// System.err.print("r: " + pixel[0]);
+// System.err.print(", g: " + pixel[1]);
+// System.err.println(", b: " + pixel[2]);
+ zPixmap.set_red(tx - x, ty - y, pixel[0]);
+ zPixmap.set_green(tx - x, ty - y, pixel[1]);
+ zPixmap.set_blue(tx - x, ty - y, pixel[2]);
+ }
+ }
+ xdrawable.put_image(xgc, zPixmap, x, y);
+ }
+ }
+
+
+ protected void init()
+ {
+ super.init();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XGraphicsConfiguration.java b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsConfiguration.java
new file mode 100644
index 00000000000..d6e66cbd202
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsConfiguration.java
@@ -0,0 +1,118 @@
+/* XGraphicsConfiguration.java -- GraphicsConfiguration for X
+ 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.x;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+
+public class XGraphicsConfiguration
+ extends GraphicsConfiguration
+{
+
+ XGraphicsDevice device;
+
+ XGraphicsConfiguration(XGraphicsDevice dev)
+ {
+ device = dev;
+ }
+
+ public GraphicsDevice getDevice()
+ {
+ return device;
+ }
+
+ public BufferedImage createCompatibleImage(int w, int h)
+ {
+ return new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int w, int h)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ int transparency)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public BufferedImage createCompatibleImage(int w, int h, int transparency)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public ColorModel getColorModel()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public ColorModel getColorModel(int transparency)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public AffineTransform getDefaultTransform()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public AffineTransform getNormalizingTransform()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Rectangle getBounds()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XGraphicsDevice.java b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsDevice.java
new file mode 100644
index 00000000000..6a020ec4e7a
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsDevice.java
@@ -0,0 +1,166 @@
+/* XGraphicsDevice.java -- GraphicsDevice for X
+ 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.x;
+
+import gnu.classpath.SystemProperties;
+import gnu.java.net.local.LocalSocket;
+import gnu.java.net.local.LocalSocketAddress;
+import gnu.x11.Connection;
+import gnu.x11.Display;
+
+import java.awt.AWTError;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.net.SocketException;
+
+/**
+ * This class represents an X Display. The actual connection is established
+ * lazily when it is first needed.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class XGraphicsDevice
+ extends GraphicsDevice
+{
+
+ private XGraphicsConfiguration defaultConfiguration;
+
+ /**
+ * The X display associated with the XGraphicsDevice. This is established
+ * when {@link #getDisplay} is first called.
+ */
+ private Display display;
+
+ /**
+ * The display name from which the display will be initialized.
+ */
+ private Display.Name displayName;
+
+ /**
+ * The event pump for this X Display.
+ */
+ private XEventPump eventPump;
+
+ /**
+ * Creates a new XGraphicsDevice.
+ */
+ XGraphicsDevice(Display.Name dn)
+ {
+ displayName = dn;
+ }
+
+ public int getType()
+ {
+ return TYPE_RASTER_SCREEN;
+ }
+
+ public String getIDstring()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public GraphicsConfiguration[] getConfigurations()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public GraphicsConfiguration getDefaultConfiguration()
+ {
+ if (defaultConfiguration == null)
+ defaultConfiguration = new XGraphicsConfiguration(this);
+ return defaultConfiguration;
+ }
+
+ /**
+ * Returns the X Display associated with this XGraphicsDevice.
+ * This establishes the connection to the X server on the first invocation.
+ *
+ * @return the X Display associated with this XGraphicsDevice
+ */
+ Display getDisplay()
+ {
+ if (display == null)
+ {
+ if (displayName.hostname.equals(""))
+ displayName.hostname = "localhost";
+ if (XToolkit.DEBUG)
+ System.err.println("connecting to : " + displayName);
+ // Try to connect via unix domain sockets when host == localhost.
+ if ((displayName.hostname.equals("localhost")
+ || displayName.hostname.equals(""))
+ && SystemProperties.getProperty("gnu.xawt.no_local_sockets") == null)
+ {
+ // TODO: Is this 100% ok?
+ String sockPath = "/tmp/.X11-unix/X" + displayName.display_no;
+ LocalSocketAddress addr = new LocalSocketAddress(sockPath);
+ try
+ {
+ if (XToolkit.DEBUG)
+ System.err.println("connecting to local socket: "
+ + sockPath);
+ LocalSocket socket = new LocalSocket(addr);
+ display = new Display(socket, "localhost",
+ displayName.display_no,
+ displayName.screen_no);
+ display.connection.send_mode = Connection.ASYNCHRONOUS;
+ if (XToolkit.DEBUG)
+ System.err.println("connected to local socket");
+ }
+ catch (SocketException ex)
+ {
+ AWTError err = new AWTError("could not connect to X server");
+ err.initCause(ex);
+ throw err;
+ }
+ }
+ else
+ {
+ display = new Display(displayName);
+ }
+ eventPump = new XEventPump(display);
+ }
+ return display;
+ }
+
+ XEventPump getEventPump()
+ {
+ return eventPump;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XGraphicsEnvironment.java b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsEnvironment.java
new file mode 100644
index 00000000000..65383a6cb0f
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XGraphicsEnvironment.java
@@ -0,0 +1,202 @@
+/* XGraphicsEnvironment.java -- Represents the X environment
+ 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.x;
+
+import gnu.java.awt.java2d.RasterGraphics;
+import gnu.x11.Display;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * Represents the X environment for AWT.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class XGraphicsEnvironment
+ extends GraphicsEnvironment
+{
+
+ /**
+ * The default graphics device. This is normally the local main X
+ * Display, but can be configured to be any X connection.
+ */
+ private XGraphicsDevice defaultDevice;
+
+ /**
+ * All configured devices.
+ */
+ private XGraphicsDevice[] devices;
+
+ /**
+ * Creates a new XGraphicsEnvironment. This loads the configuration if
+ * there is one present and initializes the XGraphicsDevices in the
+ * environment. If there is no configuration, then there is one
+ * default device initialized with the local main X device.
+ */
+ public XGraphicsEnvironment()
+ {
+ // Initiliaze the devices.
+ Properties props = new Properties();
+ File config = new File(System.getProperty("user.home"),
+ ".xawt.properties");
+
+ try
+ {
+ FileInputStream configIn = new FileInputStream(config);
+ props.load(configIn);
+ int dev = 1;
+ ArrayList deviceList = new ArrayList();
+ while (true)
+ {
+ String propName = "display." + dev;
+ String propValue = props.getProperty(propName);
+ if (propValue != null)
+ {
+ Display.Name displayName = new Display.Name(propValue);
+ XGraphicsDevice device = new XGraphicsDevice(displayName);
+ if (dev == 1)
+ defaultDevice = device;
+ deviceList.add(device);
+ dev++;
+ }
+ else
+ {
+ if (dev == 1)
+ {
+ defaultDevice = initDefaultDevice();
+ deviceList.add(defaultDevice);
+ }
+ break;
+ }
+ }
+ devices = (XGraphicsDevice[]) deviceList.toArray
+ (new XGraphicsDevice[deviceList.size()]);
+ }
+ catch (FileNotFoundException ex)
+ {
+ defaultDevice = initDefaultDevice();
+ devices = new XGraphicsDevice[]{ defaultDevice };
+ }
+ catch (IOException ex)
+ {
+ defaultDevice = initDefaultDevice();
+ devices = new XGraphicsDevice[]{ defaultDevice };
+ }
+
+ }
+
+ /**
+ * Helper method that initializes the default device in the case when there
+ * is no configuration for the default.
+ */
+ private XGraphicsDevice initDefaultDevice()
+ {
+ String display = System.getenv("DISPLAY");
+ if (display == null)
+ display = ":0.0";
+ Display.Name displayName = new Display.Name(display);
+ return new XGraphicsDevice(displayName);
+ }
+
+ /**
+ * Returns all configured screen devices.
+ *
+ * @return all configured screen devices
+ */
+ public GraphicsDevice[] getScreenDevices()
+ {
+ // We return a copy so that nobody can fiddle with our devices.
+ XGraphicsDevice[] copy = new XGraphicsDevice[devices.length];
+ System.arraycopy(devices, 0, copy, 0, devices.length);
+ return copy;
+ }
+
+ /**
+ * Returns the default screen device.
+ *
+ * @return the default screen device
+ */
+ public GraphicsDevice getDefaultScreenDevice()
+ {
+ return defaultDevice;
+ }
+
+ /**
+ * Returns a Graphics instance suitable for drawing on top of the
+ * BufferedImage.
+ *
+ * @param image the buffered image to create a graphics for
+ *
+ * @return a Graphics2D instance for drawing on the BufferedImage
+ */
+ public Graphics2D createGraphics(BufferedImage image)
+ {
+ return new RasterGraphics(image.getRaster(), image.getColorModel());
+ }
+
+ public Font[] getAllFonts()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public String[] getAvailableFontFamilyNames()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public String[] getAvailableFontFamilyNames(Locale l)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XImage.java b/libjava/classpath/gnu/java/awt/peer/x/XImage.java
new file mode 100644
index 00000000000..b9e993628f5
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XImage.java
@@ -0,0 +1,111 @@
+/* XImage.java -- Image impl for X Pixmaps
+ 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.x;
+
+import gnu.x11.Pixmap;
+
+import java.awt.Graphics;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.util.Hashtable;
+
+public class XImage
+ extends Image
+{
+
+ Pixmap pixmap;
+
+ private Hashtable properties;
+
+ XImage(int w, int h)
+ {
+ GraphicsEnvironment env =
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+ XGraphicsDevice dev = (XGraphicsDevice) env.getDefaultScreenDevice();
+ pixmap = new Pixmap(dev.getDisplay(), w, h);
+ }
+
+ public int getWidth(ImageObserver observer)
+ {
+ return pixmap.width;
+ }
+
+ public int getHeight(ImageObserver observer)
+ {
+ return pixmap.height;
+ }
+
+ public ImageProducer getSource()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Creates an XGraphics for drawing on this XImage.
+ *
+ * @return an XGraphics for drawing on this XImage
+ */
+ public Graphics getGraphics()
+ {
+ XGraphics g = new XGraphics(pixmap);
+ return g;
+ }
+
+ public Object getProperty(String name, ImageObserver observer)
+ {
+ Object val = null;
+ if (properties != null)
+ val = properties.get(val);
+ return val;
+ }
+
+ public void flush()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected void finalize()
+ {
+ pixmap.free();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XLightweightPeer.java b/libjava/classpath/gnu/java/awt/peer/x/XLightweightPeer.java
new file mode 100644
index 00000000000..2613d84d80c
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XLightweightPeer.java
@@ -0,0 +1,56 @@
+/* XLightweightPeer.java -- A lightweight peer for X
+ 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.x;
+
+import java.awt.Component;
+import java.awt.peer.LightweightPeer;
+
+import gnu.java.awt.peer.swing.SwingContainerPeer;
+
+public class XLightweightPeer
+ extends SwingContainerPeer
+ implements LightweightPeer
+{
+
+ XLightweightPeer(Component c)
+ {
+ super(c);
+ init(c, null);
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XToolkit.java b/libjava/classpath/gnu/java/awt/peer/x/XToolkit.java
new file mode 100644
index 00000000000..a286fd6f006
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XToolkit.java
@@ -0,0 +1,608 @@
+/* XToolkit.java -- The central AWT Toolkit for the X 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.x;
+
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.Transparency;
+import java.awt.Window;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.LightweightPeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.ScrollPanePeer;
+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.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+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;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.awt.peer.swing.SwingCanvasPeer;
+import gnu.java.awt.peer.swing.SwingLabelPeer;
+import gnu.java.awt.peer.swing.SwingPanelPeer;
+
+public class XToolkit
+ extends ClasspathToolkit
+{
+
+ /**
+ * Set to true to enable debug output.
+ */
+ static boolean DEBUG = false;
+
+ /**
+ * Maps AWT colors to X colors.
+ */
+ HashMap colorMap = new HashMap();
+
+ /**
+ * The system event queue.
+ */
+ private EventQueue eventQueue;
+
+ /**
+ * The default color model of this toolkit.
+ */
+ private ColorModel colorModel;
+
+ /**
+ * Maps image URLs to Image instances.
+ */
+ private HashMap imageCache = new HashMap();
+
+ /**
+ * The cached fonts.
+ */
+ private WeakHashMap fontCache = new WeakHashMap();
+
+ public XToolkit()
+ {
+ SystemProperties.setProperty("gnu.javax.swing.noGraphics2D", "true");
+ SystemProperties.setProperty("java.awt.graphicsenv",
+ "gnu.java.awt.peer.x.XGraphicsEnvironment");
+ }
+
+ public GraphicsEnvironment getLocalGraphicsEnvironment()
+ {
+ return new XGraphicsEnvironment();
+ }
+
+ /**
+ * Returns the font peer for a font with the specified name and attributes.
+ *
+ * @param name the font name
+ * @param attrs the font attributes
+ *
+ * @return the font peer for a font with the specified name and attributes
+ */
+ public ClasspathFontPeer getClasspathFontPeer(String name, Map attrs)
+ {
+ String canonical = XFontPeer.encodeFont(name, attrs);
+ ClasspathFontPeer font;
+ if (!fontCache.containsKey(canonical))
+ {
+ 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 = (ClasspathFontPeer) fontCache.get(canonical);
+ }
+ return font;
+ }
+
+ public Font createFont(int format, InputStream stream)
+ {
+ return null;
+ }
+
+ public RobotPeer createRobot(GraphicsDevice screen) throws AWTException
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected ButtonPeer createButton(Button target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected TextFieldPeer createTextField(TextField target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected LabelPeer createLabel(Label target)
+ {
+ return new SwingLabelPeer(target);
+ }
+
+ protected ListPeer createList(List target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected CheckboxPeer createCheckbox(Checkbox target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected ScrollbarPeer createScrollbar(Scrollbar target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected ScrollPanePeer createScrollPane(ScrollPane target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected TextAreaPeer createTextArea(TextArea target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected ChoicePeer createChoice(Choice target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected FramePeer createFrame(Frame target)
+ {
+ XFramePeer frame = new XFramePeer(target);
+ return frame;
+ }
+
+ protected CanvasPeer createCanvas(Canvas target)
+ {
+ return new SwingCanvasPeer(target);
+ }
+
+ protected PanelPeer createPanel(Panel target)
+ {
+ return new SwingPanelPeer(target);
+ }
+
+ protected WindowPeer createWindow(Window target)
+ {
+ return new XWindowPeer(target);
+ }
+
+ protected DialogPeer createDialog(Dialog target)
+ {
+ return new XDialogPeer(target);
+ }
+
+ protected MenuBarPeer createMenuBar(MenuBar target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected MenuPeer createMenu(Menu target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected PopupMenuPeer createPopupMenu(PopupMenu target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected MenuItemPeer createMenuItem(MenuItem target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected FileDialogPeer createFileDialog(FileDialog target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ protected FontPeer getFontPeer(String name, int style)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Dimension getScreenSize()
+ {
+ // FIXME: This is only a hack to get some apps working.
+ return new Dimension(1024, 768);
+ }
+
+ public int getScreenResolution()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Returns the color model used by this toolkit.
+ *
+ * @return the color model used by this toolkit
+ */
+ public ColorModel getColorModel()
+ {
+ // TODO: I assume 24 bit depth here, we can do this better.
+ if (colorModel == null)
+ colorModel = new DirectColorModel(24, 0xFF0000, 0xFF00, 0xFF);
+ return colorModel;
+ }
+
+ public String[] getFontList()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public FontMetrics getFontMetrics(Font name)
+ {
+ ClasspathFontPeer peer = (ClasspathFontPeer) name.getPeer();
+ return peer.getFontMetrics(name);
+ }
+
+ public void sync()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Returns an image that has its pixel data loaded from a file with the
+ * specified name. If that file doesn't exist, an empty or error image
+ * is returned instead.
+ *
+ * @param name the filename of the file that contains the pixel data
+ *
+ * @return the image
+ */
+ public Image getImage(String name)
+ {
+ Image image;
+ try
+ {
+ File file = new File(name);
+ image = getImage(file.toURL());
+ }
+ catch (MalformedURLException ex)
+ {
+ // TODO: Replace by a more meaningful error image instead.
+ image = null;
+ }
+ return image;
+ }
+
+ /**
+ * Returns an image that has its pixel data loaded from the specified URL.
+ * If the image cannot be loaded for some reason, an empty or error image
+ * is returned instead.
+ *
+ * @param url the URL to the image data
+ *
+ * @return the image
+ */
+ public Image getImage(URL url)
+ {
+ Image image;
+ if (imageCache.containsKey(url))
+ {
+ image = (Image) imageCache.get(url);
+ }
+ else
+ {
+ image = createImage(url);
+ imageCache.put(url, image);
+ }
+ return image;
+ }
+
+ /**
+ * Returns an image that has its pixel data loaded from a file with the
+ * specified name. If that file doesn't exist, an empty or error image
+ * is returned instead.
+ *
+ * @param filename the filename of the file that contains the pixel data
+ *
+ * @return the image
+ */
+ public Image createImage(String filename)
+ {
+ Image im;
+ try
+ {
+ File file = new File(filename);
+ URL url = file.toURL();
+ im = createImage(url);
+ }
+ catch (MalformedURLException ex)
+ {
+ im = createErrorImage();
+ }
+ return im;
+ }
+
+ /**
+ * Returns an image that has its pixel data loaded from the specified URL.
+ * If the image cannot be loaded for some reason, an empty or error image
+ * is returned instead.
+ *
+ * @param url the URL to the image data
+ *
+ * @return the image
+ */
+ public Image createImage(URL url)
+ {
+ Image image;
+ try
+ {
+ image = createImage(url.openStream());
+ }
+ catch (IOException ex)
+ {
+ image = createErrorImage();
+ }
+ return image;
+ }
+
+ /**
+ * Creates an image that is returned when calls to createImage() yields an
+ * error.
+ *
+ * @return an image that is returned when calls to createImage() yields an
+ * error
+ */
+ private Image createErrorImage()
+ {
+ // TODO: Create better error image.
+ return new XImage(1, 1);
+ }
+
+ public boolean prepareImage(Image image, int width, int height, ImageObserver observer)
+ {
+ // Images are loaded synchronously, so we don't bother and return true.
+ return true;
+ }
+
+ public int checkImage(Image image, int width, int height, ImageObserver observer)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ ImageConverter conv = new ImageConverter();
+ producer.startProduction(conv);
+ Image image = conv.getXImage();
+ return image;
+ }
+
+ public Image createImage(byte[] data, int offset, int len)
+ {
+ 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 the bufferedimage is opaque, then we can copy it over to an
+ // X Pixmap for faster drawing.
+ if (buffered != null && buffered.getTransparency() == Transparency.OPAQUE)
+ {
+ ImageProducer source = buffered.getSource();
+ image = createImage(source);
+ }
+ else if (buffered != null)
+ {
+ image = buffered;
+ }
+ else
+ {
+ image = createErrorImage();
+ }
+ return image;
+ }
+
+ public PrintJob getPrintJob(Frame frame, String title, Properties props)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void beep()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Clipboard getSystemClipboard()
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Returns the eventqueue used by the XLib peers.
+ *
+ * @return the eventqueue used by the XLib peers
+ */
+ protected EventQueue getSystemEventQueueImpl()
+ {
+ if (eventQueue == null)
+ eventQueue = new EventQueue();
+ return eventQueue;
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ /**
+ * Helper method to quickly fetch the default device (X Display).
+ *
+ * @return the default XGraphicsDevice
+ */
+ static XGraphicsDevice getDefaultDevice()
+ {
+ XGraphicsEnvironment env = (XGraphicsEnvironment)
+ XGraphicsEnvironment.getLocalGraphicsEnvironment();
+ return (XGraphicsDevice) env.getDefaultScreenDevice();
+ }
+
+ protected LightweightPeer createComponent(Component c)
+ {
+ return new XLightweightPeer(c);
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/x/XWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/x/XWindowPeer.java
new file mode 100644
index 00000000000..28cc5a5edf5
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/x/XWindowPeer.java
@@ -0,0 +1,255 @@
+/* XWindowPeer.java -- Window peer for X
+ 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.x;
+
+import java.awt.Component;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.PaintEvent;
+import java.awt.event.WindowEvent;
+
+import gnu.x11.Window;
+import gnu.x11.event.Event;
+
+import gnu.java.awt.peer.swing.SwingWindowPeer;
+
+public class XWindowPeer
+ extends SwingWindowPeer
+{
+
+ private static int standardSelect = Event.BUTTON_PRESS_MASK
+ | Event.BUTTON_RELEASE_MASK
+ | Event.POINTER_MOTION_MASK
+ //| Event.RESIZE_REDIRECT_MASK
+ | Event.EXPOSURE_MASK
+ //| Event.PROPERTY_CHANGE_MASK
+ | Event.STRUCTURE_NOTIFY_MASK
+ | Event.KEY_PRESS_MASK
+ | Event.KEY_RELEASE_MASK
+ ;
+
+ /**
+ * Indicates if we are in callback mode, that is when a property (like size)
+ * is changed in reponse to a request from the X server and doesn't need
+ * to be propagated back to the X server.
+ */
+ boolean callback = false;
+
+ /**
+ * The X window.
+ */
+ private Window xwindow;
+
+ XWindowPeer(java.awt.Window window)
+ {
+ super(window);
+ XGraphicsDevice dev = XToolkit.getDefaultDevice();
+
+ // TODO: Maybe initialize lazily in show().
+ // FIXME: Howto generate a Window without decorations?
+ int x = Math.max(window.getX(), 0);
+ int y = Math.max(window.getY(), 0);
+ int w = Math.max(window.getWidth(), 1);
+ int h = Math.max(window.getHeight(), 1);
+ xwindow = new Window(dev.getDisplay().default_root, x, y, w, h);
+ xwindow.create();
+ xwindow.select_input(standardSelect);
+ dev.getEventPump().registerWindow(xwindow, window);
+ }
+
+ public void toBack()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void toFront()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAlwaysOnTop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean requestWindowFocus()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Point getLocationOnScreen()
+ {
+ return new Point(xwindow.x, xwindow.y);
+ }
+
+ /**
+ * Returns a XGraphics suitable for drawing on this frame.
+ *
+ * @return a XGraphics suitable for drawing on this frame
+ */
+ public Graphics getGraphics()
+ {
+ return new XGraphics(xwindow);
+ }
+
+ public Image createImage(int w, int h)
+ {
+ return new XImage(w, h);
+ }
+
+ /**
+ * Makes the component visible. This is called by {@link Component#show()}.
+ *
+ * This is implemented to call setVisible(true) on the Swing component.
+ */
+ public void show()
+ {
+// // Prevent ResizeRedirect events.
+// //xwindow.select_input(noResizeRedirectSelect);
+// Window.Attributes atts = new Window.Attributes();
+// atts.set_override_redirect(true);
+// xwindow.change_attributes(atts);
+
+ // Prevent ResizeRedirect events.
+ //xwindow.select_input(Event.NO_EVENT_MASK);
+ //xwindow.select_input(noResizeRedirectSelect);
+
+ xwindow.map();
+ EventQueue eq = XToolkit.getDefaultToolkit().getSystemEventQueue();
+ java.awt.Window w = (java.awt.Window) super.awtComponent;
+ eq.postEvent(new WindowEvent(w, WindowEvent.WINDOW_OPENED));
+ eq.postEvent(new PaintEvent(w, PaintEvent.PAINT,
+ new Rectangle(0, 0, w.getWidth(),
+ w.getHeight())));
+
+// // Reset input selection.
+// atts.set_override_redirect(false);
+// xwindow.change_attributes(atts);
+ }
+
+ /**
+ * Makes the component invisible. This is called from
+ * {@link Component#hide()}.
+ *
+ * This is implemented to call setVisible(false) on the Swing component.
+ */
+ public void hide()
+ {
+ xwindow.unmap();
+ }
+
+ /**
+ * Notifies the peer that the bounds of this component have changed. This
+ * is called by {@link Component#reshape(int, int, int, int)}.
+ *
+ * This is implemented to call setBounds() on the Swing component.
+ *
+ * @param x the X coordinate of the upper left corner of the component
+ * @param y the Y coordinate of the upper left corner of the component
+ * @param width the width of the component
+ * @param height the height of the component
+ */
+ public void reshape(int x, int y, int width, int height)
+ {
+ // Prevent ResizeRedirect events.
+// //xwindow.select_input(noResizeRedirectSelect);
+// Window.Attributes atts = new Window.Attributes();
+// atts.set_override_redirect(true);
+// xwindow.change_attributes(atts);
+
+ // Need to substract insets because AWT size is including insets,
+ // and X size is excuding insets.
+ Insets i = insets();
+ xwindow.move_resize(x - i.left, y - i.right, width - i.left - i.right,
+ height - i.top - i.bottom);
+
+ // Reset input selection.
+// atts = new Window.Attributes();
+// atts.set_override_redirect(false);
+// xwindow.change_attributes(atts);
+ }
+
+ public Insets insets()
+ {
+ Insets i = new Insets(0, 0, 0, 0);
+// Window.GeometryReply g = xwindow.geometry();
+// int b = g.border_width();
+// Insets i = new Insets(b, b, b, b);
+// Window.WMSizeHints wmSize = xwindow.wm_normal_hints();
+// if (wmSize != null)
+// {
+// i.left = wmSize.x() - g.x();
+// i.right = wmSize.width() - g.width() - i.left ;
+// i.top = wmSize.y() - g.y();
+// i.bottom = wmSize.height() - g.height() - i.top;
+// }
+// System.err.println("insets: " + i);
+ return i;
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @return the font metrics for the specified font
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ XFontPeer fontPeer = (XFontPeer) font.getPeer();
+ return fontPeer.getFontMetrics(font);
+ }
+
+ /**
+ * Unregisters the window in the event pump when it is closed.
+ */
+ protected void finalize()
+ {
+ XGraphicsDevice dev = XToolkit.getDefaultDevice();
+ dev.getEventPump().unregisterWindow(xwindow);
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java b/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
index 2303f44b7de..e4cc8199a54 100644
--- a/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
+++ b/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
@@ -668,7 +668,7 @@ class PostScriptGraphics2D extends Graphics2D
saveAndInvertAxis();
// draw the shape s with an inverted Y axis.
- PathIterator pi = s.getPathIterator(new AffineTransform());
+ PathIterator pi = s.getPathIterator(null);
float[] coords = new float[6];
while (! pi.isDone())
@@ -872,7 +872,7 @@ class PostScriptGraphics2D extends Graphics2D
/** write a shape to the file */
private void writeShape(Shape s)
{
- PathIterator pi = s.getPathIterator(new AffineTransform());
+ PathIterator pi = s.getPathIterator(null);
float[] coords = new float[6];
while (! pi.isDone())
diff --git a/libjava/classpath/gnu/java/io/PlatformHelper.java b/libjava/classpath/gnu/java/io/PlatformHelper.java
index 79ce6e8f470..e54c56da935 100644
--- a/libjava/classpath/gnu/java/io/PlatformHelper.java
+++ b/libjava/classpath/gnu/java/io/PlatformHelper.java
@@ -1,5 +1,5 @@
/* PlatformHelper.java -- Isolate OS-specific IO helper methods and variables
- Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -97,98 +97,6 @@ public class PlatformHelper
}
/**
- * This routine canonicalizes input param "path" to formal path representation
- * for current platform, including interpreting ".." and "." .
- */
- public static final String toCanonicalForm(String path)
- {
- /*??
- if(path.indexOf('.') < 0 && path.indexOf("..") < 0)
- return path;
- */
- String tmppath = path.replace('/', separatorChar);
- StringBuffer canonpath;
-
- int i;
-
- if ((i = beginWithRootPathPrefix(tmppath)) == 0 )
- return path;
-
- /* The original
- "canonpath = new StringBuffer(tmppath.substring(0, i))"
- isn't very efficient because StringBuffer's
- ensureCapacity_unsynchronized will fail definitely each time
- and will enlarge buffer and copy contents. .
- */
- canonpath = new StringBuffer(INITIAL_MAX_PATH);
- canonpath.append(tmppath.substring(0, i));
- tmppath = tmppath.substring(i);
- // pathdepth==0 indicates there're only root path in the buffer
- int pathdepth = 0;
-
- StringTokenizer st = new StringTokenizer(tmppath, separator);
-
- // Traverse each element of the path, handling "." and ".."
- // Should handle "~" too?
- if (st.hasMoreTokens())
- do
- {
- String s = st.nextToken();
-
- // Handle "." or an empty element.
- if (s.equals(".") || s.equals(""))
- continue;
-
- // Handle ".." by deleting the last element from the path
- if (s.equals(".."))
- {
- if (pathdepth == 0)
- continue;
-
- // Strip of trailing separator
- canonpath.setLength(canonpath.length() - 1/*separator.length()*/);
- String tmpstr = canonpath.toString();
- int idx = tmpstr.lastIndexOf(separator);
-
- if ((idx == -1) || ((idx + 1/*separator.length()*/) > tmpstr.length()))
- //throw new IOException("Can't happen error");
- return path; // Shouldn't happen
-
- canonpath.setLength(idx + 1/*separator.length()*/);
- pathdepth--;
- continue;
- }
-
- canonpath.append(s);
- pathdepth++; //now it's more than root path
-
- if (st.hasMoreTokens())
- canonpath.append(separator);
- }
- while (st.hasMoreTokens());
-
- if (endWithSeparator(path))
- canonpath.append(separator);
-
- String tmpstr = canonpath.toString();
- //if (pathdepth > 0 && endWithSeparator(tmpstr) )
- // tmpstr = tmpstr.substring(0, tmpstr.length() - 1/*separator.length()*/);
-
- return tmpstr;
- }
-
- /**
- * This routine canonicalizes input param "path" to formal path representation
- * for current platform, and normalize all separators to "sepchar".
- */
- public static final String toCanonicalForm(String path, char sepchar)
- {
- String tmpstr = toCanonicalForm(path);
- tmpstr = tmpstr.replace(separatorChar, sepchar);
- return tmpstr;
- }
-
- /**
* This routine checks whether input param "path" ends with separator
*/
public static final boolean endWithSeparator(String path)
diff --git a/libjava/classpath/gnu/java/lang/management/BeanImpl.java b/libjava/classpath/gnu/java/lang/management/BeanImpl.java
new file mode 100644
index 00000000000..24572a25d5d
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/BeanImpl.java
@@ -0,0 +1,84 @@
+/* BeanImpl.java - A common superclass for bean implementations.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ManagementPermission;
+
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+
+/**
+ * A common superclass for bean implementations.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class BeanImpl
+ extends StandardMBean
+{
+
+ /**
+ * Constructs a new <code>BeanImpl</code>.
+ *
+ * @param iface the bean interface being implemented.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ protected BeanImpl(Class iface)
+ throws NotCompliantMBeanException
+ {
+ super(iface);
+ }
+
+ protected void checkMonitorPermissions()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new ManagementPermission("monitor"));
+ }
+
+ protected void checkControlPermissions()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new ManagementPermission("control"));
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
new file mode 100644
index 00000000000..92e68ae7678
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
@@ -0,0 +1,99 @@
+/* ClassLoadingMXBeanImpl.java - Implementation of a class loading bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ClassLoadingMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class ClassLoadingMXBeanImpl
+ extends BeanImpl
+ implements ClassLoadingMXBean
+{
+
+ /**
+ * Constructs a new <code>ClassLoadingMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public ClassLoadingMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(ClassLoadingMXBean.class);
+ }
+
+ public int getLoadedClassCount()
+ {
+ return VMClassLoadingMXBeanImpl.getLoadedClassCount();
+ }
+
+ public long getTotalLoadedClassCount()
+ {
+ return getLoadedClassCount() + getUnloadedClassCount();
+ }
+
+ public long getUnloadedClassCount()
+ {
+ return VMClassLoadingMXBeanImpl.getUnloadedClassCount();
+ }
+
+ public boolean isVerbose()
+ {
+ return VMClassLoadingMXBeanImpl.isVerbose();
+ }
+
+ public void setVerbose(boolean verbose)
+ {
+ checkControlPermissions();
+ VMClassLoadingMXBeanImpl.setVerbose(verbose);
+ }
+
+}
+
diff --git a/libjava/classpath/gnu/java/lang/management/CompilationMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/CompilationMXBeanImpl.java
new file mode 100644
index 00000000000..b3ad898b57c
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/CompilationMXBeanImpl.java
@@ -0,0 +1,105 @@
+/* CompilationMXBeanImpl.java - Implementation of a compilation bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import java.lang.management.CompilationMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about the JIT
+ * compiler of the virtual machine, if one exists.
+ * Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getCompilationMXBean()},
+ * if this is the case.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class CompilationMXBeanImpl
+ extends BeanImpl
+ implements CompilationMXBean
+{
+
+ /**
+ * Constant for compiler name.
+ */
+ private static final String COMPILER_NAME = "gnu.java.compiler.name";
+
+ /**
+ * Constant for compilation time support.
+ */
+ private static final String COMPILATION_TIME_SUPPORT =
+ "gnu.java.lang.management.CompilationTimeSupport";
+
+ /**
+ * Constructs a new <code>CompilationMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public CompilationMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(CompilationMXBean.class);
+ }
+
+ public String getName()
+ {
+ return SystemProperties.getProperty(COMPILER_NAME);
+ }
+
+ public boolean isCompilationTimeMonitoringSupported()
+ {
+ return SystemProperties.getProperty(COMPILATION_TIME_SUPPORT) != null;
+ }
+
+ public long getTotalCompilationTime()
+ {
+ if (isCompilationTimeMonitoringSupported())
+ return VMCompilationMXBeanImpl.getTotalCompilationTime();
+ else
+ throw new UnsupportedOperationException("Compilation time monitoring "
+ + "is not supported");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java
new file mode 100644
index 00000000000..b752e6b8672
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java
@@ -0,0 +1,84 @@
+/* GarbageCollectorMXBeanImpl.java - Implementation of a GC bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.GarbageCollectorMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about one of the garbage
+ * collectors used by the current invocation of the
+ * virtual machine. An instance of this bean for each garbage
+ * collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class GarbageCollectorMXBeanImpl
+ extends MemoryManagerMXBeanImpl
+ implements GarbageCollectorMXBean
+{
+
+ /**
+ * Constructs a new <code>GarbageCollectorMXBeanImpl</code>.
+ *
+ * @param name the name of the garbage collector this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public GarbageCollectorMXBeanImpl(String name)
+ throws NotCompliantMBeanException
+ {
+ super(name, GarbageCollectorMXBean.class);
+ }
+
+ public long getCollectionCount()
+ {
+ return VMGarbageCollectorMXBeanImpl.getCollectionCount(name);
+ }
+
+ public long getCollectionTime()
+ {
+ return VMGarbageCollectorMXBeanImpl.getCollectionTime(name);
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/MemoryMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/MemoryMXBeanImpl.java
new file mode 100644
index 00000000000..064e19a1970
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/MemoryMXBeanImpl.java
@@ -0,0 +1,322 @@
+/* MemoryMXBeanImpl.java - Implementation of a memory bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryNotificationInfo;
+import java.lang.management.MemoryUsage;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class MemoryMXBeanImpl
+ extends BeanImpl
+ implements MemoryMXBean, NotificationEmitter
+{
+
+ private List listeners;
+
+ private long notificationCount;
+
+ public static CompositeType notifType;
+
+ public static CompositeType usageType;
+
+ static
+ {
+ try
+ {
+ CompositeType usageType =
+ 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
+ });
+ CompositeType notifType =
+ new CompositeType(MemoryNotificationInfo.class.getName(),
+ "Provides the notification info on memory usage",
+ new String[] { "poolName", "usage", "count" },
+ new String[] { "Name of the memory pool",
+ "Usage level of the memory pool",
+ "Number of times the threshold " +
+ "has been crossed"
+ },
+ new OpenType[] {
+ SimpleType.STRING, usageType, SimpleType.LONG
+ });
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalStateException("Something went wrong in creating " +
+ "the composite data types.", e);
+ }
+ }
+
+ /**
+ * Constructs a new <code>MemoryMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public MemoryMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(MemoryMXBean.class);
+ listeners = new ArrayList();
+ notificationCount = 0;
+ }
+
+ public void gc()
+ {
+ System.gc();
+ }
+
+ public MemoryUsage getHeapMemoryUsage()
+ {
+ return VMMemoryMXBeanImpl.getHeapMemoryUsage();
+ }
+
+ public MemoryUsage getNonHeapMemoryUsage()
+ {
+ return VMMemoryMXBeanImpl.getNonHeapMemoryUsage();
+ }
+
+ public int getObjectPendingFinalizationCount()
+ {
+ return VMMemoryMXBeanImpl.getObjectPendingFinalizationCount();
+ }
+
+ public boolean isVerbose()
+ {
+ return VMMemoryMXBeanImpl.isVerbose();
+ }
+
+ public void setVerbose(boolean verbose)
+ {
+ checkControlPermissions();
+ VMMemoryMXBeanImpl.setVerbose(verbose);
+ }
+
+ private class ListenerData
+ {
+ private NotificationListener listener;
+ private NotificationFilter filter;
+ private Object passback;
+
+ public ListenerData(NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ {
+ this.listener = listener;
+ this.filter = filter;
+ this.passback = passback;
+ }
+
+ public NotificationListener getListener()
+ {
+ return listener;
+ }
+
+ public NotificationFilter getFilter()
+ {
+ return filter;
+ }
+
+ public Object getPassback()
+ {
+ return passback;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ListenerData)
+ {
+ ListenerData data = (ListenerData) obj;
+ return (data.getListener() == listener &&
+ data.getFilter() == filter &&
+ data.getPassback() == passback);
+ }
+ return false;
+ }
+
+ }
+
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ {
+ if (listener == null)
+ throw new IllegalArgumentException("Null listener added to bean.");
+ listeners.add(new ListenerData(listener, filter, passback));
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ return new MBeanNotificationInfo[]
+ {
+ new MBeanNotificationInfo(new String[]
+ {
+ MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED,
+ MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED
+ },
+ Notification.class.getName(),
+ "Memory Usage Notifications")
+ };
+ }
+
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ Iterator it = listeners.iterator();
+ boolean foundOne = false;
+ while (it.hasNext())
+ {
+ ListenerData data = (ListenerData) it.next();
+ if (data.getListener() == listener)
+ {
+ it.remove();
+ foundOne = true;
+ }
+ }
+ if (!foundOne)
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ "is not registered with this bean.");
+ }
+
+ public void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws ListenerNotFoundException
+ {
+ if (!(listeners.remove(new ListenerData(listener, filter, passback))))
+ {
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ " with filter " + filter +
+ "and passback " + passback +
+ ", is not registered with this bean.");
+ }
+ }
+
+ void fireNotification(String type, String poolName, long init, long used,
+ long committed, long max, long count)
+ {
+ Notification notif = new Notification(type, this, notificationCount);
+ MemoryUsage usage = new MemoryUsage(init, used, committed, max);
+ CompositeData data;
+ try
+ {
+ data = new CompositeDataSupport(notifType,
+ new String[] {
+ "poolName", "usage", "count"
+ },
+ new Object[] {
+ poolName, usage, Long.valueOf(count)
+ });
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalStateException("Something went wrong in creating " +
+ "the composite data instance.", e);
+ }
+ notif.setUserData(data);
+ Iterator it = listeners.iterator();
+ while (it.hasNext())
+ {
+ ListenerData ldata = (ListenerData) it.next();
+ NotificationFilter filter = ldata.getFilter();
+ if (filter == null || filter.isNotificationEnabled(notif))
+ ldata.getListener().handleNotification(notif, ldata.getPassback());
+ }
+ ++notificationCount;
+ }
+
+ void fireThresholdExceededNotification(String poolName, long init,
+ long used, long committed,
+ long max, long count)
+ {
+ fireNotification(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED,
+ poolName, init, used, committed, max, count);
+ }
+
+ void fireCollectionThresholdExceededNotification(String poolName,
+ long init,
+ long used,
+ long committed,
+ long max,
+ long count)
+ {
+ fireNotification(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED,
+ poolName, init, used, committed, max, count);
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java
new file mode 100644
index 00000000000..5766af9cc64
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java
@@ -0,0 +1,112 @@
+/* MemoryManagerMXBeanImpl.java - Implementation of a memory manager bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryManagerMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about one of the memory
+ * managers used by the current invocation of the
+ * virtual machine. An instance of this bean for each memory
+ * manager is obtained by calling
+ * {@link ManagementFactory#getMemoryPoolMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MemoryManagerMXBeanImpl
+ extends BeanImpl
+ implements MemoryManagerMXBean
+{
+
+ /**
+ * The name of the memory manager.
+ */
+ protected String name;
+
+ /**
+ * Constructs a new <code>MemoryManagerMXBeanImpl</code>.
+ *
+ * @param name the name of the manager this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public MemoryManagerMXBeanImpl(String name)
+ throws NotCompliantMBeanException
+ {
+ this(name, MemoryManagerMXBean.class);
+ }
+
+ /**
+ * Constructs a new <code>MemoryManagerMXBeanImpl</code>
+ * implementing the specified bean interface.
+ *
+ * @param name the name of the manager this bean represents.
+ * @param iface the bean interface being implemented.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ protected MemoryManagerMXBeanImpl(String name, Class iface)
+ throws NotCompliantMBeanException
+ {
+ super(iface);
+ this.name = name;
+ }
+
+ public String[] getMemoryPoolNames()
+ {
+ return VMMemoryManagerMXBeanImpl.getMemoryPoolNames(name);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isValid()
+ {
+ return VMMemoryManagerMXBeanImpl.isValid(name);
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
new file mode 100644
index 00000000000..ed4dccd769e
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
@@ -0,0 +1,225 @@
+/* MemoryPoolMXBeanImpl.java - Implementation of a memory pool bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryUsage;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about one of the memory
+ * resources or pools used by the current invocation of the
+ * virtual machine. An instance of this bean for each memory
+ * pool is obtained by calling
+ * {@link ManagementFactory#getMemoryPoolMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class MemoryPoolMXBeanImpl
+ extends BeanImpl
+ implements MemoryPoolMXBean
+{
+
+ /**
+ * The name of the pool.
+ */
+ private String name;
+
+ /**
+ * Constant for collection usage threshold.
+ */
+ private static final String COLLECTION_USAGE_THRESHOLD =
+ "gnu.java.lang.management.CollectionUsageThresholdSupport";
+
+ /**
+ * Constant for thread time support.
+ */
+ private static final String USAGE_THRESHOLD =
+ "gnu.java.lang.management.UsageThresholdSupport";
+
+ /**
+ * Constructs a new <code>MemoryPoolMXBeanImpl</code>.
+ *
+ * @param name the name of the pool this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public MemoryPoolMXBeanImpl(String name)
+ throws NotCompliantMBeanException
+ {
+ super(MemoryPoolMXBean.class);
+ this.name = name;
+ }
+
+ public MemoryUsage getCollectionUsage()
+ {
+ return VMMemoryPoolMXBeanImpl.getCollectionUsage(name);
+ }
+
+ public long getCollectionUsageThreshold()
+ {
+ if (isCollectionUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getCollectionUsageThreshold(name);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public long getCollectionUsageThresholdCount()
+ {
+ if (isCollectionUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getCollectionUsageThresholdCount(name);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public String[] getMemoryManagerNames()
+ {
+ return VMMemoryPoolMXBeanImpl.getMemoryManagerNames(name);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public MemoryUsage getPeakUsage()
+ {
+ if (isValid())
+ return VMMemoryPoolMXBeanImpl.getPeakUsage(name);
+ else
+ return null;
+ }
+
+ public String getType()
+ {
+ return VMMemoryPoolMXBeanImpl.getType(name);
+ }
+
+ public MemoryUsage getUsage()
+ {
+ if (isValid())
+ return VMMemoryPoolMXBeanImpl.getUsage(name);
+ else
+ return null;
+ }
+
+ public long getUsageThreshold()
+ {
+ if (isUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getUsageThreshold(name);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+ public long getUsageThresholdCount()
+ {
+ if (isUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getUsageThresholdCount(name);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+ public boolean isCollectionUsageThresholdExceeded()
+ {
+ return getCollectionUsage().getUsed() >= getCollectionUsageThreshold();
+ }
+
+ public boolean isCollectionUsageThresholdSupported()
+ {
+ return SystemProperties.getProperty(COLLECTION_USAGE_THRESHOLD) != null;
+ }
+
+ public boolean isUsageThresholdExceeded()
+ {
+ return getUsage().getUsed() >= getUsageThreshold();
+ }
+
+ public boolean isUsageThresholdSupported()
+ {
+ return SystemProperties.getProperty(USAGE_THRESHOLD) != null;
+ }
+
+ public boolean isValid()
+ {
+ return VMMemoryPoolMXBeanImpl.isValid(name);
+ }
+
+ public void resetPeakUsage()
+ {
+ checkControlPermissions();
+ VMMemoryPoolMXBeanImpl.resetPeakUsage(name);
+ }
+
+ public void setCollectionUsageThreshold(long threshold)
+ {
+ checkControlPermissions();
+ if (threshold < 0)
+ throw new IllegalArgumentException("Threshold of " + threshold +
+ "is less than zero.");
+ if (isCollectionUsageThresholdSupported())
+ VMMemoryPoolMXBeanImpl.setCollectionUsageThreshold(name, threshold);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public void setUsageThreshold(long threshold)
+ {
+ checkControlPermissions();
+ if (threshold < 0)
+ throw new IllegalArgumentException("Threshold of " + threshold +
+ "is less than zero.");
+ if (isUsageThresholdSupported())
+ VMMemoryPoolMXBeanImpl.setUsageThreshold(name, threshold);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+}
+
diff --git a/libjava/classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
new file mode 100644
index 00000000000..9eefc0d9db5
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
@@ -0,0 +1,90 @@
+/* OperatingSystemMXBeanImpl.java - Implementation of an operating system bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.OperatingSystemMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about the underlying operating
+ * system.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class OperatingSystemMXBeanImpl
+ extends BeanImpl
+ implements OperatingSystemMXBean
+{
+
+ /**
+ * Constructs a new <code>OperatingSystemMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public OperatingSystemMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(OperatingSystemMXBean.class);
+ }
+
+ public String getArch()
+ {
+ return System.getProperty("os.arch");
+ }
+
+ public int getAvailableProcessors()
+ {
+ return Runtime.getRuntime().availableProcessors();
+ }
+
+ public String getName()
+ {
+ return System.getProperty("os.name");
+ }
+
+ public String getVersion()
+ {
+ return System.getProperty("os.version");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java
new file mode 100644
index 00000000000..e3ebd162e17
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java
@@ -0,0 +1,197 @@
+/* RuntimeMXBeanImpl.java - Implementation of an runtime bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import java.lang.management.RuntimeMXBean;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class RuntimeMXBeanImpl
+ extends BeanImpl
+ implements RuntimeMXBean
+{
+
+ private static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
+ private static final String JAVA_BOOT_CLASS_PATH = "java.boot.class.path";
+
+ private long startTime = -1;
+
+ private String bootClassPath = null;
+
+ private boolean bootClassPathSupported = true;
+
+ /**
+ * Constructs a new <code>RuntimeMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public RuntimeMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(RuntimeMXBean.class);
+ }
+
+ public String getBootClassPath()
+ {
+ checkMonitorPermissions();
+ if (isBootClassPathSupported())
+ return bootClassPath;
+ else
+ throw
+ new UnsupportedOperationException("Retrieving the boot " +
+ "classpath is not supported.");
+ }
+
+ public String getClassPath()
+ {
+ return System.getProperty("java.class.path");
+ }
+
+ public List getInputArguments()
+ {
+ checkMonitorPermissions();
+ return Arrays.asList(VMRuntimeMXBeanImpl.getInputArguments());
+ }
+
+ public String getLibraryPath()
+ {
+ return System.getProperty("java.library.path");
+ }
+
+ public String getManagementSpecVersion()
+ {
+ return "1.0";
+ }
+
+ public String getName()
+ {
+ return VMRuntimeMXBeanImpl.getName();
+ }
+
+ public String getSpecName()
+ {
+ return System.getProperty("java.vm.specification.name");
+ }
+
+ public String getSpecVendor()
+ {
+ return System.getProperty("java.vm.specification.vendor");
+ }
+
+ public String getSpecVersion()
+ {
+ return System.getProperty("java.vm.specification.version");
+ }
+
+ public long getStartTime()
+ {
+ if (startTime == -1)
+ startTime = VMRuntimeMXBeanImpl.getStartTime();
+ return startTime;
+ }
+
+ public Map getSystemProperties()
+ {
+ Map map = new HashMap();
+ Properties props = System.getProperties();
+ Iterator entries = props.entrySet().iterator();
+ while (entries.hasNext())
+ {
+ Map.Entry next = (Map.Entry) entries.next();
+ Object key = next.getKey();
+ Object value = next.getValue();
+ if (key instanceof String &&
+ value instanceof String)
+ map.put(key, value);
+ }
+ return map;
+ }
+
+ public long getUptime()
+ {
+ return new Date().getTime() - getStartTime();
+ }
+
+ public String getVmName()
+ {
+ return System.getProperty("java.vm.name");
+ }
+
+ public String getVmVendor()
+ {
+ return System.getProperty("java.vm.vendor");
+ }
+
+ public String getVmVersion()
+ {
+ return System.getProperty("java.vm.version");
+ }
+
+ public boolean isBootClassPathSupported()
+ {
+ if (bootClassPath == null)
+ {
+ bootClassPath = SystemProperties.getProperty(JAVA_BOOT_CLASS_PATH);
+ if (bootClassPath == null)
+ bootClassPath = SystemProperties.getProperty(SUN_BOOT_CLASS_PATH);
+ if (bootClassPath == null)
+ bootClassPathSupported = false;
+ }
+ return bootClassPathSupported;
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/lang/management/ThreadMXBeanImpl.java b/libjava/classpath/gnu/java/lang/management/ThreadMXBeanImpl.java
new file mode 100644
index 00000000000..609b58da737
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/ThreadMXBeanImpl.java
@@ -0,0 +1,291 @@
+/* ThreadMXBeanImpl.java - Implementation of a thread bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * Provides access to information about the threads
+ * of the virtual machine. An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * See {@link java.lang.management.ThreadMXBean} for
+ * full documentation.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class ThreadMXBeanImpl
+ extends BeanImpl
+ implements ThreadMXBean
+{
+
+ /**
+ * Constant for current thread time support.
+ */
+ private static final String CURRENT_THREAD_TIME_SUPPORT =
+ "gnu.java.lang.management.CurrentThreadTimeSupport";
+
+ /**
+ * Constant for thread time support.
+ */
+ private static final String THREAD_TIME_SUPPORT =
+ "gnu.java.lang.management.ThreadTimeSupport";
+
+ /**
+ * Constant for thread contention support.
+ */
+ private static final String CONTENTION_SUPPORT =
+ "gnu.java.lang.management.ThreadContentionSupport";
+
+ /**
+ * Constant for initial value of thread time support.
+ */
+ private static final String TIME_ENABLED =
+ "gnu.java.lang.management.ThreadTimeInitallyEnabled";
+
+ /**
+ * Flag to indicate whether time monitoring is enabled or not.
+ */
+ private boolean timeEnabled;
+
+ /**
+ * Flag to indicate whether contention monitoring is enabled or not.
+ */
+ private boolean contentionEnabled;
+
+ /**
+ * Default constructor to set up flag states. The
+ * VM has to specify whether time monitoring is initially
+ * enabled or not.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public ThreadMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(ThreadMXBean.class);
+ timeEnabled = Boolean.parseBoolean(SystemProperties.getProperty(TIME_ENABLED));
+ contentionEnabled = false;
+ }
+
+ public long[] findMonitorDeadlockedThreads()
+ {
+ checkMonitorPermissions();
+ return VMThreadMXBeanImpl.findMonitorDeadlockedThreads();
+ }
+
+ public long[] getAllThreadIds()
+ {
+ checkMonitorPermissions();
+ return VMThreadMXBeanImpl.getAllThreadIds();
+ }
+
+ public long getCurrentThreadCpuTime()
+ {
+ if (!isCurrentThreadCpuTimeSupported())
+ throw new UnsupportedOperationException("Current thread CPU " +
+ "time not supported.");
+ if (!timeEnabled)
+ return -1;
+ return VMThreadMXBeanImpl.getCurrentThreadCpuTime();
+ }
+
+ public long getCurrentThreadUserTime()
+ {
+ if (!isCurrentThreadCpuTimeSupported())
+ throw new UnsupportedOperationException("Current thread user " +
+ "time not supported.");
+ if (!timeEnabled)
+ return -1;
+ return VMThreadMXBeanImpl.getCurrentThreadUserTime();
+ }
+
+ public int getDaemonThreadCount()
+ {
+ return VMThreadMXBeanImpl.getDaemonThreadCount();
+ }
+
+ public int getPeakThreadCount()
+ {
+ return VMThreadMXBeanImpl.getPeakThreadCount();
+ }
+
+ public int getThreadCount()
+ {
+ return VMThreadMXBeanImpl.getThreadCount();
+ }
+
+ public long getThreadCpuTime(long id)
+ {
+ if (!isThreadCpuTimeSupported())
+ throw new UnsupportedOperationException("Thread CPU time not " +
+ "supported.");
+ if (id <= 0)
+ throw new IllegalArgumentException("Invalid thread id: " + id);
+ if (!timeEnabled)
+ return -1;
+ return VMThreadMXBeanImpl.getThreadCpuTime(id);
+ }
+
+ public ThreadInfo getThreadInfo(long id)
+ {
+ return getThreadInfo(id, 0);
+ }
+
+ public ThreadInfo[] getThreadInfo(long[] ids)
+ {
+ return getThreadInfo(ids, 0);
+ }
+
+ public ThreadInfo getThreadInfo(long id, int maxDepth)
+ {
+ checkMonitorPermissions();
+ if (id <= 0)
+ throw new IllegalArgumentException("Invalid thread id: " + id);
+ if (maxDepth < 0)
+ throw new IllegalArgumentException("Invalid depth: " + maxDepth);
+ return VMThreadMXBeanImpl.getThreadInfoForId(id, maxDepth);
+ }
+
+ public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth)
+ {
+ checkMonitorPermissions();
+ if (maxDepth < 0)
+ throw new IllegalArgumentException("Invalid depth: " + maxDepth);
+ ThreadInfo[] infos = new ThreadInfo[ids.length];
+ for (int a = 0; a < ids.length; ++a)
+ {
+ if (ids[a] <= 0)
+ throw new IllegalArgumentException("Invalid thread id " + a +
+ ": " + ids[a]);
+ infos[a] = VMThreadMXBeanImpl.getThreadInfoForId(ids[a], maxDepth);
+ }
+ return infos;
+ }
+
+ public long getThreadUserTime(long id)
+ {
+ if (!isThreadCpuTimeSupported())
+ throw new UnsupportedOperationException("Thread user time not " +
+ "supported.");
+ if (id <= 0)
+ throw new IllegalArgumentException("Invalid thread id: " + id);
+ if (!timeEnabled)
+ return -1;
+ return VMThreadMXBeanImpl.getThreadUserTime(id);
+ }
+
+ public long getTotalStartedThreadCount()
+ {
+ return VMThreadMXBeanImpl.getTotalStartedThreadCount();
+ }
+
+ public boolean isCurrentThreadCpuTimeSupported()
+ {
+ if (isThreadCpuTimeSupported())
+ return true;
+ return SystemProperties.getProperty(CURRENT_THREAD_TIME_SUPPORT) != null;
+ }
+
+ public boolean isThreadContentionMonitoringEnabled()
+ {
+ if (isThreadContentionMonitoringSupported())
+ return contentionEnabled;
+ else
+ throw new UnsupportedOperationException("Contention monitoring " +
+ "not supported.");
+ }
+
+ public boolean isThreadContentionMonitoringSupported()
+ {
+ return SystemProperties.getProperty(CONTENTION_SUPPORT) != null;
+ }
+
+ public boolean isThreadCpuTimeEnabled()
+ {
+ if (isThreadCpuTimeSupported() ||
+ isCurrentThreadCpuTimeSupported())
+ return timeEnabled;
+ else
+ throw new UnsupportedOperationException("Thread time not " +
+ "supported.");
+ }
+
+ public boolean isThreadCpuTimeSupported()
+ {
+ return SystemProperties.getProperty(THREAD_TIME_SUPPORT) != null;
+ }
+
+ public void resetPeakThreadCount()
+ {
+ checkControlPermissions();
+ VMThreadMXBeanImpl.resetPeakThreadCount();
+ }
+
+ public void setThreadContentionMonitoringEnabled(boolean enable)
+ {
+ checkControlPermissions();
+ if (isThreadContentionMonitoringSupported())
+ contentionEnabled = enable;
+ else
+ throw new UnsupportedOperationException("Contention monitoring " +
+ "not supported.");
+ }
+
+ public void setThreadCpuTimeEnabled(boolean enable)
+ {
+ checkControlPermissions();
+ if (isThreadCpuTimeSupported() ||
+ isCurrentThreadCpuTimeSupported())
+ timeEnabled = enable;
+ else
+ throw new UnsupportedOperationException("Thread time not " +
+ "supported.");
+ }
+
+}
+
diff --git a/libjava/classpath/gnu/java/lang/management/package.html b/libjava/classpath/gnu/java/lang/management/package.html
new file mode 100644
index 00000000000..fc1bafc0cdf
--- /dev/null
+++ b/libjava/classpath/gnu/java/lang/management/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.lang.management package.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.lang.management</title></head>
+
+<body>
+<p>GNU implementations of the Java system management beans.</p>
+
+</body>
+</html>
diff --git a/libjava/classpath/gnu/java/net/IndexListParser.java b/libjava/classpath/gnu/java/net/IndexListParser.java
index 23d2aa660cb..1165929fc35 100644
--- a/libjava/classpath/gnu/java/net/IndexListParser.java
+++ b/libjava/classpath/gnu/java/net/IndexListParser.java
@@ -125,7 +125,11 @@ public class IndexListParser
br.close();
}
- // else INDEX.LIST does not exist
+ else
+ {
+ // INDEX.LIST does not exist
+ clearAll();
+ }
}
catch (Exception ex)
{
diff --git a/libjava/classpath/gnu/java/net/loader/FileResource.java b/libjava/classpath/gnu/java/net/loader/FileResource.java
new file mode 100644
index 00000000000..8071bbf91f8
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/FileResource.java
@@ -0,0 +1,82 @@
+/* FileResource.java -- a Resource for file URLs
+ 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.net.loader;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public final class FileResource extends Resource
+{
+ final File file;
+
+ public FileResource(FileURLLoader loader, File file)
+ {
+ super(loader);
+ this.file = file;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ public int getLength()
+ {
+ return (int) file.length();
+ }
+
+ public URL getURL()
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
+ }
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/FileURLLoader.java b/libjava/classpath/gnu/java/net/loader/FileURLLoader.java
new file mode 100644
index 00000000000..39d33a4e4be
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/FileURLLoader.java
@@ -0,0 +1,145 @@
+/* FileURLLoader.java -- a URLLoader for file URLs
+ 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.net.loader;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.util.StringTokenizer;
+
+/**
+ * A <code>FileURLLoader</code> is a type of <code>URLLoader</code>
+ * only loading from file url.
+ */
+public final class FileURLLoader extends URLLoader
+{
+ File dir; //the file for this file url
+
+ public FileURLLoader(URLClassLoader classloader,
+ URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL url, URL absoluteUrl)
+ {
+ super(classloader, cache, factory, url, absoluteUrl);
+ dir = new File(absoluteUrl.getFile());
+ }
+
+ /** get resource with the name "name" in the file url */
+ public Resource getResource(String name)
+ {
+ try
+ {
+ // Make sure that all components in name are valid by walking through
+ // them
+ File file = walkPathComponents(name);
+
+ if (file == null)
+ return null;
+
+ return new FileResource(this, file);
+ }
+ catch (IOException e)
+ {
+ // Fall through...
+ }
+ return null;
+ }
+
+ /**
+ * Walk all path tokens and check them for validity. At no moment, we are
+ * allowed to reach a directory located "above" the root directory, stored
+ * in "dir" property. We are also not allowed to enter a non existing
+ * directory or a non directory component (plain file, symbolic link, ...).
+ * An empty or null path is valid. Pathnames components are separated by
+ * <code>File.separatorChar</code>
+ *
+ * @param resourceFileName the name to be checked for validity.
+ * @return the canonical file pointed by the resourceFileName or null if the
+ * walking failed
+ * @throws IOException in case of issue when creating the canonical
+ * resulting file
+ * @see File#separatorChar
+ */
+ private File walkPathComponents(String resourceFileName) throws IOException
+ {
+ StringTokenizer stringTokenizer = new StringTokenizer(resourceFileName, File.separator);
+ File currentFile = dir;
+ int tokenCount = stringTokenizer.countTokens();
+
+ for (int i = 0; i < tokenCount - 1; i++)
+ {
+ String currentToken = stringTokenizer.nextToken();
+
+ // If we are at the root directory and trying to go up, the walking is
+ // finished with an error
+ if ("..".equals(currentToken) && currentFile.equals(dir))
+ return null;
+
+ currentFile = new File(currentFile, currentToken);
+
+ // If the current file doesn't exist or is not a directory, the walking is
+ // finished with an error
+ if (! (currentFile.exists() && currentFile.isDirectory()))
+ return null;
+
+ }
+
+ // Treat the last token differently, if it exists, because it does not need
+ // to be a directory
+ if (tokenCount > 0)
+ {
+ String currentToken = stringTokenizer.nextToken();
+
+ if ("..".equals(currentToken) && currentFile.equals(dir))
+ return null;
+
+ currentFile = new File(currentFile, currentToken);
+
+ // If the current file doesn't exist, the walking is
+ // finished with an error
+ if (! currentFile.exists())
+ return null;
+ }
+
+ return currentFile.getCanonicalFile();
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/JarURLLoader.java b/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
new file mode 100644
index 00000000000..9385760d547
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
@@ -0,0 +1,215 @@
+package gnu.java.net.loader;
+
+import gnu.java.net.IndexListParser;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ * A <code>JarURLLoader</code> is a type of <code>URLLoader</code>
+ * only loading from jar url.
+ */
+public final class JarURLLoader extends URLLoader
+{
+ // True if we've initialized -- i.e., tried open the jar file.
+ boolean initialized;
+ // The jar file for this url.
+ JarFile jarfile;
+ // Base jar: url for all resources loaded from jar.
+ final URL baseJarURL;
+ // The "Class-Path" attribute of this Jar's manifest.
+ ArrayList classPath;
+ // If not null, a mapping from INDEX.LIST for this jar only.
+ // This is a set of all prefixes and top-level files that
+ // ought to be available in this jar.
+ Set indexSet;
+
+ // This constructor is used internally. It purposely does not open
+ // the jar file -- it defers this until later. This allows us to
+ // implement INDEX.LIST lazy-loading semantics.
+ private JarURLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL absoluteUrl,
+ Set indexSet)
+ {
+ super(classloader, cache, factory, baseURL, absoluteUrl);
+
+ URL newBaseURL = null;
+ try
+ {
+ // Cache url prefix for all resources in this jar url.
+ String base = baseURL.toExternalForm() + "!/";
+ newBaseURL = new URL("jar", "", -1, base, cache.get(factory, "jar"));
+ }
+ catch (MalformedURLException ignore)
+ {
+ // Ignore.
+ }
+ this.baseJarURL = newBaseURL;
+ this.classPath = null;
+ this.indexSet = indexSet;
+ }
+
+ // This constructor is used by URLClassLoader. It will immediately
+ // try to read the jar file, in case we've found an index or a class-path
+ // setting. FIXME: it would be nice to defer this as well, but URLClassLoader
+ // makes this hard.
+ public JarURLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL absoluteUrl)
+ {
+ this(classloader, cache, factory, baseURL, absoluteUrl, null);
+ initialize();
+ }
+
+ private void initialize()
+ {
+ JarFile jarfile = null;
+ try
+ {
+ jarfile =
+ ((JarURLConnection) baseJarURL.openConnection()).getJarFile();
+
+ Manifest manifest;
+ Attributes attributes;
+ String classPathString;
+
+ IndexListParser parser = new IndexListParser(jarfile, baseJarURL,
+ baseURL);
+ LinkedHashMap indexMap = parser.getHeaders();
+ if (indexMap != null)
+ {
+ // Note that the index also computes
+ // the resulting Class-Path -- there are jars out there
+ // where the index lists some required jars which do
+ // not appear in the Class-Path attribute in the manifest.
+ this.classPath = new ArrayList();
+ Iterator it = indexMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ URL subURL = (URL) entry.getKey();
+ Set prefixes = (Set) entry.getValue();
+ if (subURL.equals(baseURL))
+ this.indexSet = prefixes;
+ else
+ {
+ JarURLLoader subLoader = new JarURLLoader(classloader,
+ cache,
+ factory, subURL,
+ subURL,
+ prefixes);
+ // Note that we don't care if the sub-loader itself has an
+ // index or a class-path -- only the top-level jar
+ // file gets this treatment; its index should cover
+ // everything.
+ this.classPath.add(subLoader);
+ }
+ }
+ }
+ else if ((manifest = jarfile.getManifest()) != null
+ && (attributes = manifest.getMainAttributes()) != null
+ && ((classPathString
+ = attributes.getValue(Attributes.Name.CLASS_PATH))
+ != null))
+ {
+ this.classPath = new ArrayList();
+ StringTokenizer st = new StringTokenizer(classPathString, " ");
+ while (st.hasMoreElements ())
+ {
+ String e = st.nextToken ();
+ try
+ {
+ URL subURL = new URL(baseURL, e);
+ // We've seen at least one jar file whose Class-Path
+ // attribute includes the original jar. If we process
+ // that normally we end up with infinite recursion.
+ if (subURL.equals(baseURL))
+ continue;
+ JarURLLoader subLoader = new JarURLLoader(classloader,
+ cache, factory,
+ subURL, subURL);
+ this.classPath.add(subLoader);
+ ArrayList extra = subLoader.getClassPath();
+ if (extra != null)
+ this.classPath.addAll(extra);
+ }
+ catch (java.net.MalformedURLException xx)
+ {
+ // Give up
+ }
+ }
+ }
+ }
+ catch (IOException ioe)
+ {
+ /* ignored */
+ }
+
+ this.jarfile = jarfile;
+ this.initialized = true;
+ }
+
+ /** get resource with the name "name" in the jar url */
+ public Resource getResource(String name)
+ {
+ if (name.startsWith("/"))
+ name = name.substring(1);
+ if (indexSet != null)
+ {
+ // Trust the index.
+ String basename = name;
+ int offset = basename.lastIndexOf('/');
+ if (offset != -1)
+ basename = basename.substring(0, offset);
+ if (! indexSet.contains(basename))
+ return null;
+ // FIXME: if the index claim to hold the resource, and jar file
+ // doesn't have it, we're supposed to throw an exception. However,
+ // in our model this is tricky to implement, as another URLLoader from
+ // the same top-level jar may have an overlapping index entry.
+ }
+
+ if (! initialized)
+ initialize();
+ if (jarfile == null)
+ return null;
+
+ JarEntry je = jarfile.getJarEntry(name);
+ if (je != null)
+ return new JarURLResource(this, name, je);
+ else
+ return null;
+ }
+
+ public Manifest getManifest()
+ {
+ try
+ {
+ return (jarfile == null) ? null : jarfile.getManifest();
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+
+ public ArrayList getClassPath()
+ {
+ return classPath;
+ }
+}
diff --git a/libjava/classpath/gnu/java/net/loader/JarURLResource.java b/libjava/classpath/gnu/java/net/loader/JarURLResource.java
new file mode 100644
index 00000000000..a9db5ce0b1e
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/JarURLResource.java
@@ -0,0 +1,94 @@
+/* JarURLResource.java -- a Resource for jar URLs
+ 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.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.jar.JarEntry;
+
+public final class JarURLResource extends Resource
+{
+ private final JarEntry entry;
+ private final String name;
+
+ public JarURLResource(JarURLLoader loader, String name, JarEntry entry)
+ {
+ super(loader);
+ this.entry = entry;
+ this.name = name;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return ((JarURLLoader) loader).jarfile.getInputStream(entry);
+ }
+
+ public int getLength()
+ {
+ return (int) entry.getSize();
+ }
+
+ public Certificate[] getCertificates()
+ {
+ // We have to get the entry from the jar file again, because the
+ // certificates will not be available until the entire entry has
+ // been read.
+ return ((JarEntry) ((JarURLLoader) loader).jarfile.getEntry(name))
+ .getCertificates();
+ }
+
+ public URL getURL()
+ {
+ try
+ {
+ return new URL(((JarURLLoader) loader).baseJarURL, name,
+ loader.cache.get(loader.factory, "jar"));
+ }
+ catch (MalformedURLException e)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
+ }
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/RemoteResource.java b/libjava/classpath/gnu/java/net/loader/RemoteResource.java
new file mode 100644
index 00000000000..f18031581ea
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/RemoteResource.java
@@ -0,0 +1,78 @@
+/* Resource.java -- a Resource for "remote" URLs
+ 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.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * A resource from some remote location.
+ */
+public final class RemoteResource extends Resource
+{
+ private final URL url;
+ private final InputStream stream;
+ final int length;
+
+ public RemoteResource(RemoteURLLoader loader, String name, URL url,
+ InputStream stream, int length)
+ {
+ super(loader);
+ this.url = url;
+ this.stream = stream;
+ this.length = length;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return stream;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+
+ public URL getURL()
+ {
+ return url;
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java b/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java
new file mode 100644
index 00000000000..f044740faa5
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java
@@ -0,0 +1,101 @@
+/* RemoteURLLoader.java -- a URLLoader for "remote" objects
+ 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.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * Loader for remote directories.
+ */
+public final class RemoteURLLoader extends URLLoader
+{
+ private final String protocol;
+
+ public RemoteURLLoader(URLClassLoader classloader,
+ URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL url)
+ {
+ super(classloader, cache, factory, url);
+ protocol = url.getProtocol();
+ }
+
+ /**
+ * Get a remote resource.
+ * Returns null if no such resource exists.
+ */
+ public Resource getResource(String name)
+ {
+ try
+ {
+ URL url = new URL(baseURL, name, cache.get(factory, protocol));
+ URLConnection connection = url.openConnection();
+
+ // Open the connection and check the stream
+ // just to be sure it exists.
+ int length = connection.getContentLength();
+ InputStream stream = connection.getInputStream();
+
+ // We can do some extra checking if it is a http request
+ if (connection instanceof HttpURLConnection)
+ {
+ int response =
+ ((HttpURLConnection) connection).getResponseCode();
+ if (response / 100 != 2)
+ return null;
+ }
+
+ if (stream != null)
+ return new RemoteResource(this, name, url, stream, length);
+ else
+ return null;
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/Resource.java b/libjava/classpath/gnu/java/net/loader/Resource.java
new file mode 100644
index 00000000000..e367a338802
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/Resource.java
@@ -0,0 +1,110 @@
+/* Resource.java -- a resource for URLLoader
+ 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.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.cert.Certificate;
+
+/**
+ * A <code>Resource</code> represents a resource in some
+ * <code>URLLoader</code>. It also contains all information (e.g.,
+ * <code>URL</code>, <code>CodeSource</code>, <code>Manifest</code> and
+ * <code>InputStream</code>) that is necessary for loading resources
+ * and creating classes from a <code>URL</code>.
+ */
+public abstract class Resource
+{
+ final URLLoader loader;
+
+ public Resource(URLLoader loader)
+ {
+ this.loader = loader;
+ }
+
+ /**
+ * Returns the non-null <code>CodeSource</code> associated with
+ * this resource.
+ */
+ public CodeSource getCodeSource()
+ {
+ Certificate[] certs = getCertificates();
+ if (certs == null)
+ return loader.noCertCodeSource;
+ else
+ return new CodeSource(loader.baseURL, certs);
+ }
+
+ /**
+ * Returns <code>Certificates</code> associated with this
+ * resource, or null when there are none.
+ */
+ public Certificate[] getCertificates()
+ {
+ return null;
+ }
+
+ /**
+ * Return the URLLoader for this resource.
+ */
+ public final URLLoader getLoader()
+ {
+ return loader;
+ }
+
+ /**
+ * Return a <code>URL</code> that can be used to access this resource.
+ */
+ public abstract URL getURL();
+
+ /**
+ * Returns the size of this <code>Resource</code> in bytes or
+ * <code>-1</code> when unknown.
+ */
+ public abstract int getLength();
+
+ /**
+ * Returns the non-null <code>InputStream</code> through which
+ * this resource can be loaded.
+ */
+ public abstract InputStream getInputStream() throws IOException;
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/URLLoader.java b/libjava/classpath/gnu/java/net/loader/URLLoader.java
new file mode 100644
index 00000000000..d073c54296a
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/URLLoader.java
@@ -0,0 +1,147 @@
+/* URLLoader.java -- base helper class for URLClassLoader
+ 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.net.loader;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.security.CodeSource;
+import java.util.ArrayList;
+import java.util.jar.Manifest;
+
+/**
+ * A <code>URLLoader</code> contains all logic to load resources from a
+ * given base <code>URL</code>.
+ */
+public abstract class URLLoader
+{
+ /**
+ * Our classloader to get info from if needed.
+ */
+ final URLClassLoader classloader;
+
+ /**
+ * The base URL from which all resources are loaded.
+ */
+ final URL baseURL;
+
+ /**
+ * The stream handler factory.
+ */
+ final URLStreamHandlerFactory factory;
+
+ /**
+ * The source for stream handlers.
+ */
+ final URLStreamHandlerCache cache;
+
+ /**
+ * A <code>CodeSource</code> without any associated certificates.
+ * It is common for classes to not have certificates associated
+ * with them. If they come from the same <code>URLLoader</code>
+ * then it is safe to share the associated <code>CodeSource</code>
+ * between them since <code>CodeSource</code> is immutable.
+ */
+ final CodeSource noCertCodeSource;
+
+ public URLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL)
+ {
+ this(classloader, cache, factory, baseURL, baseURL);
+ }
+
+ public URLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL overrideURL)
+ {
+ this.classloader = classloader;
+ this.baseURL = baseURL;
+ this.factory = factory;
+ this.cache = cache;
+ this.noCertCodeSource = new CodeSource(overrideURL, null);
+ }
+
+ /**
+ * Return the base URL of this loader.
+ */
+ public final URL getBaseURL()
+ {
+ return baseURL;
+ }
+
+ /**
+ * Returns a <code>Class</code> loaded by this
+ * <code>URLLoader</code>, or <code>null</code> when this loader
+ * either can't load the class or doesn't know how to load classes
+ * at all. Most subclasses do not need to override this; it is only
+ * useful in situations where the subclass has a more direct way of
+ * making <code>Class</code> objects.
+ */
+ public Class getClass(String className)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a <code>Resource</code> loaded by this
+ * <code>URLLoader</code>, or <code>null</code> when no
+ * <code>Resource</code> with the given name exists.
+ */
+ public abstract Resource getResource(String s);
+
+ /**
+ * Returns the <code>Manifest</code> associated with the
+ * <code>Resource</code>s loaded by this <code>URLLoader</code> or
+ * <code>null</code> there is no such <code>Manifest</code>.
+ */
+ public Manifest getManifest()
+ {
+ return null;
+ }
+
+ /**
+ * Return a list of new URLLoader objects representing any
+ * class path entries added by this container.
+ */
+ public ArrayList getClassPath()
+ {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java b/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
new file mode 100644
index 00000000000..295a15d2b53
--- /dev/null
+++ b/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
@@ -0,0 +1,84 @@
+/* URLStreamHandlerCache.java -- a cache for URLStreamHandlers
+ 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.net.loader;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.HashMap;
+
+/**
+ */
+public class URLStreamHandlerCache
+{
+ /**
+ * A cache to store mappings between handler factory and its
+ * private protocol handler cache (also a HashMap), so we can avoid
+ * creating handlers each time the same protocol comes.
+ */
+ private HashMap factoryCache = new HashMap(5);
+
+ public URLStreamHandlerCache()
+ {
+ }
+
+ public synchronized void add(URLStreamHandlerFactory factory)
+ {
+ // Since we only support three protocols so far, 5 is enough
+ // for cache initial size.
+ if (factory != null && factoryCache.get(factory) == null)
+ factoryCache.put(factory, new HashMap(5));
+ }
+
+ public synchronized URLStreamHandler get(URLStreamHandlerFactory factory,
+ String protocol)
+ {
+ if (factory == null)
+ return null;
+ // Check if there're handler for the same protocol in cache.
+ HashMap cache = (HashMap) factoryCache.get(factory);
+ URLStreamHandler handler = (URLStreamHandler) cache.get(protocol);
+ if (handler == null)
+ {
+ // Add it to cache.
+ handler = factory.createURLStreamHandler(protocol);
+ cache.put(protocol, handler);
+ }
+ return handler;
+ }
+}
diff --git a/libjava/classpath/gnu/java/net/local/LocalSocket.java b/libjava/classpath/gnu/java/net/local/LocalSocket.java
index b977d69c1bc..b262c794e3d 100644
--- a/libjava/classpath/gnu/java/net/local/LocalSocket.java
+++ b/libjava/classpath/gnu/java/net/local/LocalSocket.java
@@ -247,12 +247,13 @@ public final class LocalSocket extends Socket
public void setSoTimeout (int i) throws SocketException
{
- throw new SocketException ("local sockets do not support this option");
+ // Ignore.
}
public int getSoTimeout () throws SocketException
{
- throw new SocketException ("local sockets do not support this option");
+ // We don't support timeout, so we return 0.
+ return 0;
}
public void setSendBufferSize (int i) throws SocketException
diff --git a/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java b/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java
index f907e5f469f..f43305a8027 100644
--- a/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
index 33d9756aa0c..f5e831c6a01 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
@@ -466,7 +466,8 @@ public class HTTPConnection
*/
synchronized HTTPConnection get(String host,
int port,
- boolean secure)
+ boolean secure,
+ int connectionTimeout, int timeout)
{
String ttl =
SystemProperties.getProperty("classpath.net.http.keepAliveTTL");
@@ -494,7 +495,7 @@ public class HTTPConnection
}
if (c == null)
{
- c = new HTTPConnection(host, port, secure);
+ c = new HTTPConnection(host, port, secure, connectionTimeout, timeout);
c.setPool(this);
}
return c;
diff --git a/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java b/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
index 0dce7c75b0c..a46d1204b6d 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
@@ -65,7 +65,7 @@ import javax.net.ssl.SSLSocketFactory;
* @author Chris Burdess (dog@gnu.org)
*/
public class HTTPURLConnection
- extends HttpsURLConnection
+ extends HttpsURLConnection
implements HandshakeCompletedListener
{
/*
@@ -346,11 +346,11 @@ public class HTTPURLConnection
HTTPConnection connection;
if (keepAlive)
{
- connection = HTTPConnection.Pool.instance.get(host, port, secure);
+ connection = HTTPConnection.Pool.instance.get(host, port, secure, getConnectTimeout(), 0);
}
else
{
- connection = new HTTPConnection(host, port, secure);
+ connection = new HTTPConnection(host, port, secure, 0, getConnectTimeout());
}
return connection;
}
@@ -653,5 +653,27 @@ public class HTTPURLConnection
handshakeEvent = event;
}
+ /**
+ * Set the connection timeout speed, in milliseconds, or zero if the timeout
+ * is to be considered infinite.
+ *
+ * Overloaded.
+ *
+ */
+ public void setConnectTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ super.setConnectTimeout( timeout );
+ if( connection == null )
+ return;
+ try
+ {
+ connection.getSocket().setSoTimeout( timeout );
+ }
+ catch(IOException se)
+ {
+ // Ignore socket exceptions.
+ }
+ }
}
diff --git a/libjava/classpath/gnu/java/net/protocol/jar/Connection.java b/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
index 41c5d6dcf69..f99806ae42d 100644
--- a/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
+++ b/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
@@ -188,7 +188,7 @@ public final class Connection extends JarURLConnection
else if (field.equals("last-modified"))
{
// Both creating and manipulating dateFormat need synchronization.
- synchronized (this.getClass())
+ synchronized (Connection.class)
{
if (dateFormat == null)
dateFormat = new SimpleDateFormat
diff --git a/libjava/classpath/gnu/java/nio/PipeImpl.java b/libjava/classpath/gnu/java/nio/PipeImpl.java
index f7b01c8b740..cccaa39885f 100644
--- a/libjava/classpath/gnu/java/nio/PipeImpl.java
+++ b/libjava/classpath/gnu/java/nio/PipeImpl.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.nio;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Pipe;
@@ -47,12 +48,14 @@ class PipeImpl extends Pipe
public static final class SourceChannelImpl extends Pipe.SourceChannel
{
private int native_fd;
+ private VMChannel vmch;
public SourceChannelImpl (SelectorProvider selectorProvider,
int native_fd)
{
super (selectorProvider);
this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
}
protected final void implCloseSelectableChannel()
@@ -64,19 +67,19 @@ class PipeImpl extends Pipe
protected void implConfigureBlocking (boolean blocking)
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.setBlocking(blocking);
}
public final int read (ByteBuffer src)
throws IOException
{
- throw new Error ("Not implemented");
+ return vmch.read(src);
}
public final long read (ByteBuffer[] srcs)
throws IOException
{
- return read (srcs, 0, srcs.length);
+ return vmch.readScattering(srcs, 0, srcs.length);
}
public final synchronized long read (ByteBuffer[] srcs, int offset,
@@ -89,13 +92,7 @@ class PipeImpl extends Pipe
|| len > srcs.length - offset)
throw new IndexOutOfBoundsException();
- long bytesRead = 0;
-
- for (int index = 0; index < len; index++)
- bytesRead += read (srcs [offset + index]);
-
- return bytesRead;
-
+ return vmch.readScattering(srcs, offset, len);
}
public final int getNativeFD()
@@ -107,12 +104,14 @@ class PipeImpl extends Pipe
public static final class SinkChannelImpl extends Pipe.SinkChannel
{
private int native_fd;
+ private VMChannel vmch;
public SinkChannelImpl (SelectorProvider selectorProvider,
int native_fd)
{
super (selectorProvider);
this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
}
protected final void implCloseSelectableChannel()
@@ -124,19 +123,19 @@ class PipeImpl extends Pipe
protected final void implConfigureBlocking (boolean blocking)
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.setBlocking(blocking);
}
public final int write (ByteBuffer dst)
throws IOException
{
- throw new Error ("Not implemented");
+ return vmch.write(dst);
}
public final long write (ByteBuffer[] srcs)
throws IOException
{
- return write (srcs, 0, srcs.length);
+ return vmch.writeGathering(srcs, 0, srcs.length);
}
public final synchronized long write (ByteBuffer[] srcs, int offset, int len)
@@ -147,13 +146,8 @@ class PipeImpl extends Pipe
|| len < 0
|| len > srcs.length - offset)
throw new IndexOutOfBoundsException();
-
- long bytesWritten = 0;
- for (int index = 0; index < len; index++)
- bytesWritten += write (srcs [offset + index]);
-
- return bytesWritten;
+ return vmch.writeGathering(srcs, offset, len);
}
public final int getNativeFD()
diff --git a/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java b/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
index a1f125e9f8b..8745377c58f 100644
--- a/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
+++ b/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
@@ -1,5 +1,5 @@
/* SelectionKeyImpl.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,8 +47,8 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
{
private int readyOps;
private int interestOps;
- private SelectorImpl impl;
- SelectableChannel ch;
+ private final SelectorImpl impl;
+ final SelectableChannel ch;
public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl)
{
@@ -61,7 +61,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
return ch;
}
- public int readyOps ()
+ public synchronized int readyOps ()
{
if (!isValid())
throw new CancelledKeyException();
@@ -69,7 +69,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
return readyOps;
}
- public SelectionKey readyOps (int ops)
+ public synchronized SelectionKey readyOps (int ops)
{
if (!isValid())
throw new CancelledKeyException();
@@ -83,15 +83,21 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
if (!isValid())
throw new CancelledKeyException();
- return interestOps;
+ synchronized (impl.selectedKeys())
+ {
+ return interestOps;
+ }
}
public SelectionKey interestOps (int ops)
{
if (!isValid())
throw new CancelledKeyException();
-
- interestOps = ops;
+
+ synchronized (impl.selectedKeys())
+ {
+ interestOps = ops;
+ }
return this;
}
diff --git a/libjava/classpath/gnu/java/nio/SelectorImpl.java b/libjava/classpath/gnu/java/nio/SelectorImpl.java
index e10f7157443..d0ec4871367 100644
--- a/libjava/classpath/gnu/java/nio/SelectorImpl.java
+++ b/libjava/classpath/gnu/java/nio/SelectorImpl.java
@@ -1,5 +1,5 @@
/* SelectorImpl.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -379,16 +379,19 @@ public class SelectorImpl extends AbstractSelector
result = new DatagramChannelSelectionKey (ch, this);
else if (ch instanceof ServerSocketChannelImpl)
result = new ServerSocketChannelSelectionKey (ch, this);
+ else if (ch instanceof gnu.java.nio.SocketChannelImpl)
+ result = new gnu.java.nio.SocketChannelSelectionKeyImpl((gnu.java.nio.SocketChannelImpl)ch, this);
else
throw new InternalError ("No known channel type");
synchronized (keys)
{
keys.add (result);
+
+ result.interestOps (ops);
+ result.attach (att);
}
- result.interestOps (ops);
- result.attach (att);
return result;
}
}
diff --git a/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java b/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java
new file mode 100644
index 00000000000..30fb2dfba44
--- /dev/null
+++ b/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java
@@ -0,0 +1,69 @@
+/* SocketChannelSelectionKey.java -- Selection key for Socket Channel
+ 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.nio;
+
+
+/**
+ * @author Michael Barker <mike@middlesoft.co.uk>
+ *
+ */
+public class SocketChannelSelectionKeyImpl extends SelectionKeyImpl
+{
+
+ SocketChannelImpl ch;
+
+ /**
+ * @param ch
+ * @param impl
+ */
+ public SocketChannelSelectionKeyImpl(SocketChannelImpl ch, SelectorImpl impl)
+ {
+ super(ch, impl);
+ this.ch = (SocketChannelImpl) ch;
+ }
+
+ /**
+ * Returns the native file/socket descriptor as an int.
+ */
+ public int getNativeFD()
+ {
+ return ch.getPlainSocketImpl().getNativeFD();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java b/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
index 671ae5bb15f..ed439e141ef 100644
--- a/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
+++ b/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
@@ -40,6 +40,7 @@ package gnu.java.nio.channels;
import gnu.classpath.Configuration;
import gnu.java.nio.FileLockImpl;
+import gnu.java.nio.VMChannel;
import java.io.File;
import java.io.FileNotFoundException;
@@ -102,6 +103,7 @@ public final class FileChannelImpl extends FileChannel
// we want to make sure this has the value -1. This is the most
// efficient way to accomplish that.
private int fd = -1;
+ private VMChannel ch;
private int mode;
@@ -123,6 +125,7 @@ public final class FileChannelImpl extends FileChannel
description = path;
fd = open (path, mode);
this.mode = mode;
+ this.ch = VMChannel.getVMChannel(this);
// First open the file and then check if it is a a directory
// to avoid race condition.
@@ -155,6 +158,7 @@ public final class FileChannelImpl extends FileChannel
this.fd = fd;
this.mode = mode;
this.description = "descriptor(" + fd + ")";
+ this.ch = VMChannel.getVMChannel(this);
}
private native int open (String path, int mode) throws FileNotFoundException;
@@ -181,6 +185,7 @@ public final class FileChannelImpl extends FileChannel
public int read (ByteBuffer dst) throws IOException
{
+ /*
int result;
byte[] buffer = new byte [dst.remaining ()];
@@ -190,6 +195,8 @@ public final class FileChannelImpl extends FileChannel
dst.put (buffer, 0, result);
return result;
+ */
+ return ch.read(dst);
}
public int read (ByteBuffer dst, long position)
@@ -214,33 +221,12 @@ public final class FileChannelImpl extends FileChannel
public long read (ByteBuffer[] dsts, int offset, int length)
throws IOException
{
- long result = 0;
-
- for (int i = offset; i < offset + length; i++)
- {
- result += read (dsts [i]);
- }
-
- return result;
+ return ch.readScattering(dsts, offset, length);
}
public int write (ByteBuffer src) throws IOException
{
- int len = src.remaining ();
- if (src.hasArray())
- {
- byte[] buffer = src.array();
- write(buffer, src.arrayOffset() + src.position(), len);
- src.position(src.position() + len);
- }
- else
- {
- // Use a more efficient native method! FIXME!
- byte[] buffer = new byte [len];
- src.get (buffer, 0, len);
- write (buffer, 0, len);
- }
- return len;
+ return ch.write(src);
}
public int write (ByteBuffer src, long position)
@@ -274,14 +260,7 @@ public final class FileChannelImpl extends FileChannel
public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
- long result = 0;
-
- for (int i = offset;i < offset + length;i++)
- {
- result += write (srcs[i]);
- }
-
- return result;
+ return ch.writeGathering(srcs, offset, length);
}
public native MappedByteBuffer mapImpl (char mode, long position, int size)
@@ -563,4 +542,12 @@ public final class FileChannelImpl extends FileChannel
+ ",mode=" + mode + ","
+ description + "]");
}
+
+ /**
+ * @return The native file descriptor.
+ */
+ public int getNativeFD()
+ {
+ return fd;
+ }
}
diff --git a/libjava/classpath/gnu/java/nio/charset/Provider.java b/libjava/classpath/gnu/java/nio/charset/Provider.java
index ad3b1da8471..b56e5a90e72 100644
--- a/libjava/classpath/gnu/java/nio/charset/Provider.java
+++ b/libjava/classpath/gnu/java/nio/charset/Provider.java
@@ -155,9 +155,9 @@ public final class Provider extends CharsetProvider
/**
* Load non-mandatory charsets.
*/
- private void loadExtended ()
+ private synchronized void loadExtended ()
{
- if(extendedLoaded)
+ if (extendedLoaded)
return;
addCharset (new ISO_8859_3 ()); // ISO-8859-3 aka ISO-LATIN-3
@@ -165,6 +165,12 @@ public final class Provider extends CharsetProvider
addCharset (new ISO_8859_8 ()); // ISO-8859-8 (Hebrew)
// Some more codepages
+ addCharset (new Cp424());
+ addCharset (new Cp437());
+ addCharset (new Cp737());
+ addCharset (new Cp775());
+ addCharset (new Cp850());
+ addCharset (new Cp852());
addCharset (new Cp855()); // IBM Cyrillic
addCharset (new Cp857()); // IBM Turkish
addCharset (new Cp860()); // MSDOS Portugese
@@ -176,6 +182,24 @@ public final class Provider extends CharsetProvider
addCharset (new Cp866()); // MSDOS Russian
addCharset (new Cp869()); // IBM modern Greek
addCharset (new Cp874()); // IBM Thai
+
+ addCharset (new MacCentralEurope());
+ addCharset (new MacCroatian());
+ addCharset (new MacCyrillic());
+ addCharset (new MacDingbat());
+ addCharset (new MacGreek());
+ addCharset (new MacIceland());
+ addCharset (new MacRoman());
+ addCharset (new MacRomania());
+ addCharset (new MacSymbol());
+ addCharset (new MacThai());
+ addCharset (new MacTurkish());
+ addCharset (new MS874());
+
+ addCharset (new Windows1255());
+ addCharset (new Windows1256());
+ addCharset (new Windows1258());
+
extendedLoaded = true;
}
@@ -199,7 +223,7 @@ public final class Provider extends CharsetProvider
public Charset charsetForName (String charsetName)
{
Charset cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
- if(cs == null && !extendedLoaded)
+ if (cs == null)
{
loadExtended();
cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
diff --git a/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java b/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
index 09595ec5fe5..5b7dadfd217 100644
--- a/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
@@ -178,7 +178,7 @@ public class ActivatableServerRef extends UnicastServerRef
Class cls = aClass;
// where ist the _Stub? (check superclasses also)
- Class expCls = expCls = findStubSkelClass(cls);
+ Class expCls = findStubSkelClass(cls);
if (expCls != null)
{
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java b/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
index cd891a1aaea..2f7cb9a2d94 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
@@ -150,7 +150,7 @@ public class UnicastServerRef
Class cls = obj.getClass();
// where ist the _Stub? (check superclasses also)
- Class expCls = expCls = findStubSkelClass(cls);
+ Class expCls = findStubSkelClass(cls);
if (expCls != null)
{
diff --git a/libjava/classpath/gnu/java/security/Configuration.java.in b/libjava/classpath/gnu/java/security/Configuration.java.in
new file mode 100644
index 00000000000..1deb543d4b3
--- /dev/null
+++ b/libjava/classpath/gnu/java/security/Configuration.java.in
@@ -0,0 +1,56 @@
+/* Configuration.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.security;
+
+/**
+ * This file defines compile-time constants that can be accessed by
+ * our crypto code. All crypto code should use and define such
+ * constants here instead of using the gnu.classpath.Configuration class.
+ */
+public interface Configuration
+{
+
+ /**
+ * The value of DEBUG is substituted according to whether the
+ * "--enable-debug" argument was passed to configure. Code
+ * which is made conditional based on the value of this flag - typically
+ * code that generates debugging output - will be removed by the optimizer
+ * in a non-debug build.
+ */
+ boolean DEBUG = @LIBDEBUG@;
+}
diff --git a/libjava/classpath/gnu/java/security/Engine.java b/libjava/classpath/gnu/java/security/Engine.java
index 4b6bd10d9dd..c6271e3f219 100644
--- a/libjava/classpath/gnu/java/security/Engine.java
+++ b/libjava/classpath/gnu/java/security/Engine.java
@@ -42,6 +42,7 @@ import java.lang.reflect.InvocationTargetException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Enumeration;
/**
* Generic implementation of the getInstance methods in the various
@@ -141,26 +142,49 @@ public final class Engine
|| provider == null || initArgs == null)
throw new IllegalArgumentException();
- // If there is no property "service.algorithm"
- if (provider.getProperty(service + "." + algorithm) == null)
+
+ Enumeration enumer = provider.propertyNames();
+ String key;
+ String alias;
+ int count = 0;
+ boolean algorithmFound = false;
+
+ while (enumer.hasMoreElements())
{
- // Iterate through aliases, until we find the class name or resolve
- // too many aliases.
- String alias = null;
- int count = 0;
- while ((alias = provider.getProperty(
- ALG_ALIAS + service + "." + algorithm)) != null)
+ key = (String) enumer.nextElement();
+
+ if (key.equalsIgnoreCase(service + "." + algorithm))
{
- if (algorithm.equals(alias)) // Refers to itself!
- break;
- algorithm = alias;
- if (count++ > MAX_ALIASES)
- throw new NoSuchAlgorithmException("too many aliases");
+ // remove the service portion from the key
+ algorithm = key.substring(service.length() + 1);
+
+ algorithmFound = true;
+ break;
+
}
- if (provider.getProperty(service + "." + algorithm) == null)
- throw new NoSuchAlgorithmException(algorithm);
- }
+ else if (key.equalsIgnoreCase(ALG_ALIAS + service + "." + algorithm))
+ {
+ alias = (String) provider.getProperty(key);
+
+ if (! algorithm.equalsIgnoreCase(alias)) // does not refer to itself
+ {
+ algorithm = alias;
+ if (count++ > MAX_ALIASES)
+ throw new NoSuchAlgorithmException("too many aliases");
+
+ // need to reset enumeration to now look for the alias
+ enumer = provider.propertyNames();
+ }
+ }
+ }
+
+ if (! algorithmFound)
+ {
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+
// Find and instantiate the implementation.
Class clazz = null;
ClassLoader loader = provider.getClass().getClassLoader();
diff --git a/libjava/classpath/gnu/java/security/OID.java b/libjava/classpath/gnu/java/security/OID.java
index 473b6ba5a29..f61cf0fc37c 100644
--- a/libjava/classpath/gnu/java/security/OID.java
+++ b/libjava/classpath/gnu/java/security/OID.java
@@ -1,5 +1,5 @@
/* OID.java -- numeric representation of an object identifier
- 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.
@@ -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.
*/
@@ -211,7 +214,6 @@ public class OID implements Cloneable, Comparable, java.io.Serializable
/**
* Construct a new OID from the given DER bytes.
*
- * @param root The root OID.
* @param encoded The encoded relative OID.
* @param relative The relative flag.
*/
@@ -230,13 +232,6 @@ public class OID implements Cloneable, Comparable, java.io.Serializable
}
}
- /**
- * Our private constructor.
- */
- private OID()
- {
- }
-
// Instance methods.
// ------------------------------------------------------------------------
@@ -326,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/libjava/classpath/gnu/java/security/PolicyFile.java b/libjava/classpath/gnu/java/security/PolicyFile.java
index 3064f041b9d..8da3a7d72fe 100644
--- a/libjava/classpath/gnu/java/security/PolicyFile.java
+++ b/libjava/classpath/gnu/java/security/PolicyFile.java
@@ -1,5 +1,5 @@
/* PolicyFile.java -- policy file reader
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -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;
@@ -148,16 +148,17 @@ public final class PolicyFile extends Policy
// Constants and fields.
// -------------------------------------------------------------------------
- private static final Logger logger = SystemLogger.SYSTEM;
-
+ 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/libjava/classpath/gnu/java/security/Properties.java b/libjava/classpath/gnu/java/security/Properties.java
index 860b7d928ff..a515a54280a 100644
--- a/libjava/classpath/gnu/java/security/Properties.java
+++ b/libjava/classpath/gnu/java/security/Properties.java
@@ -38,38 +38,23 @@ exception statement from your version. */
package gnu.java.security;
+import gnu.java.security.Configuration;
+
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.PrintWriter;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.PropertyPermission;
+import java.util.logging.Logger;
/**
- * <p>A global object containing build-specific properties that affect the
- * behaviour of the generated binaries from this library.</p>
+ * A global object containing build-specific properties that affect the
+ * behaviour of the generated binaries from this library.
*/
public final class Properties
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "Properties";
-
- private static final boolean DEBUG = false;
-
- // private static final int debuglevel = 9;
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(final String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(Properties.class.getName());
public static final String VERSION = "gnu.crypto.version";
@@ -95,9 +80,6 @@ public final class Properties
private boolean doRSABlinding = true;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private Properties()
{
@@ -105,18 +87,15 @@ public final class Properties
init();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the string representation of the library global configuration
- * property with the designated <code>key</code>.</p>
- *
+ * Returns the string representation of the library global configuration
+ * property with the designated <code>key</code>.
+ *
* @param key the case-insensitive, non-null and non-empty name of a
- * configuration property.
+ * configuration property.
* @return the string representation of the designated property, or
- * <code>null</code> if such property is not yet set, or <code>key</code> is
- * empty.
+ * <code>null</code> if such property is not yet set, or
+ * <code>key</code> is empty.
*/
public static final synchronized String getProperty(String key)
{
@@ -132,13 +111,13 @@ public final class Properties
}
/**
- * <p>Sets the value of a designated library global configuration property,
- * to a string representation of what should be a legal value.</p>
- *
+ * Sets the value of a designated library global configuration property, to a
+ * string representation of what should be a legal value.
+ *
* @param key the case-insensitive, non-null and non-empty name of a
- * configuration property.
- * @param value the non-null, non-empty string representation of a legal
- * value of the configuration property named by <code>key</code>.
+ * configuration property.
+ * @param value the non-null, non-empty string representation of a legal value
+ * of the configuration property named by <code>key</code>.
*/
public static final synchronized void setProperty(String key, String value)
{
@@ -169,13 +148,14 @@ public final class Properties
}
/**
- * <p>A convenience method that returns, as a boolean, the library global
+ * A convenience method that returns, as a boolean, the library global
* configuration property indicating if the default Pseudo Random Number
- * Generator produces, or not, the same bit stream when instantiated.</p>
- *
- * @return <code>true</code> if the default PRNG produces the same bit stream
- * with every VM instance. Returns <code>false</code> if the default PRNG is
- * seeded with the time of day of its first invocation.
+ * Generator produces, or not, the same bit stream when instantiated.
+ *
+ * @return <code>true</code> if the default PRNG produces the same bit
+ * stream with every VM instance. Returns <code>false</code> if the
+ * default PRNG is seeded with the time of day of its first
+ * invocation.
*/
public static final synchronized boolean isReproducible()
{
@@ -186,15 +166,15 @@ public final class Properties
}
/**
- * <p>A convenience method that returns, as a boolean, the library global
- * configuration property indicating if the implementations of symmetric
- * key block ciphers check, or not, for possible/potential weak and semi-weak
- * keys that may be produced in the course of generating round encryption
- * and/or decryption keys.</p>
- *
- * @return <code>true</code> if the cipher implementations check for weak and
- * semi-weak keys. Returns <code>false</code> if the cipher implementations
- * do not check for weak or semi-weak keys.
+ * A convenience method that returns, as a boolean, the library global
+ * configuration property indicating if the implementations of symmetric key
+ * block ciphers check, or not, for possible/potential weak and semi-weak keys
+ * that may be produced in the course of generating round encryption and/or
+ * decryption keys.
+ *
+ * @return <code>true</code> if the cipher implementations check for weak
+ * and semi-weak keys. Returns <code>false</code> if the cipher
+ * implementations do not check for weak or semi-weak keys.
*/
public static final synchronized boolean checkForWeakKeys()
{
@@ -205,13 +185,14 @@ public final class Properties
}
/**
- * <p>A convenience method that returns, as a boolean, the library global
+ * A convenience method that returns, as a boolean, the library global
* configuration property indicating if RSA decryption (RSADP primitive),
- * does, or not, blinding against timing attacks.</p>
- *
+ * does, or not, blinding against timing attacks.
+ *
* @return <code>true</code> if the RSA decryption primitive includes a
- * blinding operation. Returns <code>false</code> if the RSA decryption
- * primitive does not include the additional blinding operation.
+ * blinding operation. Returns <code>false</code> if the RSA
+ * decryption primitive does not include the additional blinding
+ * operation.
*/
public static final synchronized boolean doRSABlinding()
{
@@ -222,11 +203,11 @@ public final class Properties
}
/**
- * <p>A convenience method to set the global property for reproducibility of
- * the default PRNG bit stream output.</p>
- *
+ * A convenience method to set the global property for reproducibility of the
+ * default PRNG bit stream output.
+ *
* @param value if <code>true</code> then the default PRNG bit stream output
- * is the same with every invocation of the VM.
+ * is the same with every invocation of the VM.
*/
public static final synchronized void setReproducible(final boolean value)
{
@@ -238,12 +219,12 @@ public final class Properties
}
/**
- * <p>A convenience method to set the global property for checking for weak
- * and semi-weak cipher keys.</p>
- *
+ * A convenience method to set the global property for checking for weak and
+ * semi-weak cipher keys.
+ *
* @param value if <code>true</code> then the cipher implementations will
- * invoke additional checks for weak and semi-weak key values that may get
- * generated.
+ * invoke additional checks for weak and semi-weak key values that
+ * may get generated.
*/
public static final synchronized void setCheckForWeakKeys(final boolean value)
{
@@ -255,11 +236,11 @@ public final class Properties
}
/**
- * <p>A convenience method to set the global property fo adding a blinding
- * operation when executing the RSA decryption primitive.</p>
- *
+ * A convenience method to set the global property fo adding a blinding
+ * operation when executing the RSA decryption primitive.
+ *
* @param value if <code>true</code> then the code for performing the RSA
- * decryption primitive will include a blinding operation.
+ * decryption primitive will include a blinding operation.
*/
public static final synchronized void setDoRSABlinding(final boolean value)
{
@@ -277,15 +258,12 @@ public final class Properties
return singleton;
}
- // Instance methods
- // -------------------------------------------------------------------------
private void init()
{
// default values
props.put(REPRODUCIBLE_PRNG, (reproducible ? "true" : "false"));
props.put(CHECK_WEAK_KEYS, (checkForWeakKeys ? "true" : "false"));
props.put(DO_RSA_BLINDING, (doRSABlinding ? "true" : "false"));
-
// 1. allow site-wide override by reading a properties file
String propFile = null;
try
@@ -300,9 +278,8 @@ public final class Properties
}
catch (SecurityException se)
{
- if (DEBUG)
- debug("Reading property " + PROPERTIES_FILE
- + " not allowed. Ignored.");
+ if (Configuration.DEBUG)
+ log.fine("Reading property " + PROPERTIES_FILE + " not allowed. Ignored.");
}
if (propFile != null)
{
@@ -316,27 +293,24 @@ public final class Properties
}
catch (IOException ioe)
{
- if (DEBUG)
- debug("IO error reading " + propFile + ": " + ioe.getMessage());
+ if (Configuration.DEBUG)
+ log.fine("IO error reading " + propFile + ": " + ioe.getMessage());
}
catch (SecurityException se)
{
- if (DEBUG)
- debug("Security error reading " + propFile + ": "
- + se.getMessage());
+ if (Configuration.DEBUG)
+ log.fine("Security error reading " + propFile + ": "
+ + se.getMessage());
}
}
-
// 2. allow vm-specific override by allowing -D options in launcher
handleBooleanProperty(REPRODUCIBLE_PRNG);
handleBooleanProperty(CHECK_WEAK_KEYS);
handleBooleanProperty(DO_RSA_BLINDING);
-
// re-sync the 'known' properties
reproducible = Boolean.valueOf((String) props.get(REPRODUCIBLE_PRNG)).booleanValue();
checkForWeakKeys = Boolean.valueOf((String) props.get(CHECK_WEAK_KEYS)).booleanValue();
doRSABlinding = Boolean.valueOf((String) props.get(DO_RSA_BLINDING)).booleanValue();
-
// This does not change.
props.put(VERSION, Registry.VERSION_STRING);
}
@@ -350,24 +324,24 @@ public final class Properties
}
catch (SecurityException x)
{
- if (DEBUG)
- debug("SecurityManager forbids reading system properties. Ignored");
+ if (Configuration.DEBUG)
+ log.fine("SecurityManager forbids reading system properties. Ignored");
}
if (s != null)
{
s = s.trim().toLowerCase();
- // we have to test for explicit "true" or "false". anything else may
+ // we have to test for explicit "true" or "false". anything else may
// hide valid value set previously
if (s.equals(TRUE) || s.equals(FALSE))
{
- if (DEBUG)
- debug("Setting " + name + " to '" + s + "'");
+ if (Configuration.DEBUG)
+ log.fine("Setting " + name + " to '" + s + "'");
props.put(name, s);
}
else
{
- if (DEBUG)
- debug("Invalid value for -D" + name + ": " + s + ". Ignored");
+ if (Configuration.DEBUG)
+ log.fine("Invalid value for -D" + name + ": " + s + ". Ignored");
}
}
}
diff --git a/libjava/classpath/gnu/java/security/Registry.java b/libjava/classpath/gnu/java/security/Registry.java
index 0cb92513502..053d7177833 100644
--- a/libjava/classpath/gnu/java/security/Registry.java
+++ b/libjava/classpath/gnu/java/security/Registry.java
@@ -44,10 +44,6 @@ package gnu.java.security;
*/
public interface Registry
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/** The name of our Providers. */
String GNU_SECURITY = "GNU";
String GNU_CRYPTO = "GNU-CRYPTO";
@@ -93,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";
@@ -177,6 +185,9 @@ public interface Registry
/** TLSv1 padding scheme. */
String TLS1_PAD = "tls1";
+ /** ISO 10126-2 padding scheme. */
+ String ISO10126_PAD = "iso10126";
+
// Pseudo-random number generators..........................................
/** (Apparently) RC4 keystream PRNG. */
@@ -300,38 +311,38 @@ public interface Registry
// D (0x44) for DSS, R (0x52) for RSA, H (0x48) for Diffie-Hellman, or S
// (0x53) for SRP-6, and finally P (0x50) for Public, p (0x70) for private,
// or S (0x53) for signature.
- byte[] MAGIC_RAW_DSS_PUBLIC_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x44,
- 0x50 };
+ byte[] MAGIC_RAW_DSS_PUBLIC_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x44, 0x50 };
- byte[] MAGIC_RAW_DSS_PRIVATE_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x44,
- 0x70 };
+ byte[] MAGIC_RAW_DSS_PRIVATE_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x44, 0x70 };
- byte[] MAGIC_RAW_DSS_SIGNATURE = new byte[] { 0x47, RAW_ENCODING_ID, 0x44,
- 0x53 };
+ byte[] MAGIC_RAW_DSS_SIGNATURE = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x44, 0x53 };
- byte[] MAGIC_RAW_RSA_PUBLIC_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x52,
- 0x50 };
+ byte[] MAGIC_RAW_RSA_PUBLIC_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x52, 0x50 };
- byte[] MAGIC_RAW_RSA_PRIVATE_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x52,
- 0x70 };
+ byte[] MAGIC_RAW_RSA_PRIVATE_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x52, 0x70 };
- byte[] MAGIC_RAW_RSA_PSS_SIGNATURE = new byte[] { 0x47, RAW_ENCODING_ID,
- 0x52, 0x53 };
+ byte[] MAGIC_RAW_RSA_PSS_SIGNATURE = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x52, 0x53 };
- byte[] MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE = new byte[] { 0x47, RAW_ENCODING_ID,
- 0x52, 0x54 };
+ byte[] MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x52, 0x54 };
- byte[] MAGIC_RAW_DH_PUBLIC_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x48,
- 0x50 };
+ byte[] MAGIC_RAW_DH_PUBLIC_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x48, 0x50 };
- byte[] MAGIC_RAW_DH_PRIVATE_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x48,
- 0x70 };
+ byte[] MAGIC_RAW_DH_PRIVATE_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x48, 0x70 };
- byte[] MAGIC_RAW_SRP_PUBLIC_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x53,
- 0x50 };
+ byte[] MAGIC_RAW_SRP_PUBLIC_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x53, 0x50 };
- byte[] MAGIC_RAW_SRP_PRIVATE_KEY = new byte[] { 0x47, RAW_ENCODING_ID, 0x53,
- 0x70 };
+ byte[] MAGIC_RAW_SRP_PRIVATE_KEY = new byte[] {
+ 0x47, RAW_ENCODING_ID, 0x53, 0x70 };
// SASL Property names .....................................................
@@ -344,8 +355,7 @@ public interface Registry
String SASL_PASSWORD = SASL_PREFIX + ".password";
/** Name of authentication information provider packages. */
- String SASL_AUTH_INFO_PROVIDER_PKGS = SASL_PREFIX
- + ".auth.info.provider.pkgs";
+ String SASL_AUTH_INFO_PROVIDER_PKGS = SASL_PREFIX + ".auth.info.provider.pkgs";
/** SASL authorization ID. */
String SASL_AUTHORISATION_ID = SASL_PREFIX + ".authorisation.ID";
@@ -452,7 +462,4 @@ public interface Registry
int GKR_CIPHER_AES_128_OFB = 0;
int GKR_CIPHER_AES_128_CBC = 1;
-
- // Methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/hash/BaseHash.java b/libjava/classpath/gnu/java/security/hash/BaseHash.java
index 720b835392a..ff1750aeae0 100644
--- a/libjava/classpath/gnu/java/security/hash/BaseHash.java
+++ b/libjava/classpath/gnu/java/security/hash/BaseHash.java
@@ -39,14 +39,11 @@ exception statement from your version. */
package gnu.java.security.hash;
/**
- * <p>A base abstract class to facilitate hash implementations.</p>
+ * A base abstract class to facilitate hash implementations.
*/
-public abstract class BaseHash implements IMessageDigest
+public abstract class BaseHash
+ implements IMessageDigest
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The canonical name prefix of the hash. */
protected String name;
@@ -62,12 +59,9 @@ public abstract class BaseHash implements IMessageDigest
/** Temporary input buffer. */
protected byte[] buffer;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name prefix of this instance.
* @param hashSize the block size of the output in bytes.
* @param blockSize the block size of the internal transform.
@@ -84,14 +78,6 @@ public abstract class BaseHash implements IMessageDigest
resetContext();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IMessageDigest interface implementation ---------------------------------
-
public String name()
{
return name;
@@ -114,9 +100,7 @@ public abstract class BaseHash implements IMessageDigest
count++;
buffer[i] = b;
if (i == (blockSize - 1))
- {
- transform(buffer, 0);
- }
+ transform(buffer, 0);
}
public void update(byte[] b)
@@ -136,16 +120,13 @@ public abstract class BaseHash implements IMessageDigest
System.arraycopy(b, offset, buffer, n, partLen);
transform(buffer, 0);
for (i = partLen; i + blockSize - 1 < len; i += blockSize)
- {
- transform(b, offset + i);
- }
+ transform(b, offset + i);
+
n = 0;
}
if (i < len)
- {
- System.arraycopy(b, offset + i, buffer, n, len - i);
- }
+ System.arraycopy(b, offset + i, buffer, n, len - i);
}
public byte[] digest()
@@ -163,31 +144,27 @@ public abstract class BaseHash implements IMessageDigest
{ // reset this instance for future re-use
count = 0L;
for (int i = 0; i < blockSize;)
- {
- buffer[i++] = 0;
- }
+ buffer[i++] = 0;
resetContext();
}
- // methods to be implemented by concrete subclasses ------------------------
-
public abstract Object clone();
public abstract boolean selfTest();
/**
- * <p>Returns the byte array to use as padding before completing a hash
- * operation.</p>
- *
+ * Returns the byte array to use as padding before completing a hash
+ * operation.
+ *
* @return the bytes to pad the remaining bytes in the buffer before
- * completing a hash operation.
+ * completing a hash operation.
*/
protected abstract byte[] padBuffer();
/**
- * <p>Constructs the result from the contents of the current context.</p>
- *
+ * Constructs the result from the contents of the current context.
+ *
* @return the output of the completed hash operation.
*/
protected abstract byte[] getResult();
@@ -196,11 +173,11 @@ public abstract class BaseHash implements IMessageDigest
protected abstract void resetContext();
/**
- * <p>The block digest transformation per se.</p>
- *
+ * The block digest transformation per se.
+ *
* @param in the <i>blockSize</i> long block, as an array of bytes to digest.
* @param offset the index where the data to digest is located within the
- * input buffer.
+ * input buffer.
*/
protected abstract void transform(byte[] in, int offset);
}
diff --git a/libjava/classpath/gnu/java/security/hash/HashFactory.java b/libjava/classpath/gnu/java/security/hash/HashFactory.java
index e5209212365..2a4e487858c 100644
--- a/libjava/classpath/gnu/java/security/hash/HashFactory.java
+++ b/libjava/classpath/gnu/java/security/hash/HashFactory.java
@@ -45,113 +45,73 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>A <i>Factory</i> to instantiate message digest algorithm instances.</p>
+ * A <i>Factory</i> to instantiate message digest algorithm instances.
*/
public class HashFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
private HashFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Return an instance of a hash algorithm given its name.</p>
- *
+ * Return an instance of a hash algorithm given its name.
+ *
* @param name the name of the hash algorithm.
* @return an instance of the hash algorithm, or null if none found.
* @exception InternalError if the implementation does not pass its self-
- * test.
+ * test.
*/
public static IMessageDigest getInstance(String name)
{
if (name == null)
- {
- return null;
- }
+ return null;
name = name.trim();
IMessageDigest result = null;
if (name.equalsIgnoreCase(Registry.WHIRLPOOL_HASH))
- {
- result = new Whirlpool();
- }
+ result = new Whirlpool();
else if (name.equalsIgnoreCase(Registry.RIPEMD128_HASH)
|| name.equalsIgnoreCase(Registry.RIPEMD_128_HASH))
- {
- result = new RipeMD128();
- }
+ result = new RipeMD128();
else if (name.equalsIgnoreCase(Registry.RIPEMD160_HASH)
|| name.equalsIgnoreCase(Registry.RIPEMD_160_HASH))
- {
- result = new RipeMD160();
- }
+ result = new RipeMD160();
else if (name.equalsIgnoreCase(Registry.SHA160_HASH)
|| name.equalsIgnoreCase(Registry.SHA_1_HASH)
|| name.equalsIgnoreCase(Registry.SHA1_HASH)
|| name.equalsIgnoreCase(Registry.SHA_HASH))
- {
- result = new Sha160();
- }
+ result = new Sha160();
else if (name.equalsIgnoreCase(Registry.SHA256_HASH))
- {
- result = new Sha256();
- }
+ result = new Sha256();
else if (name.equalsIgnoreCase(Registry.SHA384_HASH))
- {
- result = new Sha384();
- }
+ result = new Sha384();
else if (name.equalsIgnoreCase(Registry.SHA512_HASH))
- {
- result = new Sha512();
- }
+ result = new Sha512();
else if (name.equalsIgnoreCase(Registry.TIGER_HASH))
- {
- result = new Tiger();
- }
+ result = new Tiger();
else if (name.equalsIgnoreCase(Registry.HAVAL_HASH))
- {
- result = new Haval();
- }
+ result = new Haval();
else if (name.equalsIgnoreCase(Registry.MD5_HASH))
- {
- result = new MD5();
- }
+ result = new MD5();
else if (name.equalsIgnoreCase(Registry.MD4_HASH))
- {
- result = new MD4();
- }
+ result = new MD4();
else if (name.equalsIgnoreCase(Registry.MD2_HASH))
- {
- result = new MD2();
- }
+ result = new MD2();
else if (name.equalsIgnoreCase(Registry.HAVAL_HASH))
- {
- result = new Haval();
- }
+ result = new Haval();
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link Set} of names of hash algorithms supported by this
- * <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of names of hash algorithms supported by this
+ * <i>Factory</i>.
+ *
* @return a {@link Set} of hash names (Strings).
*/
public static final Set getNames()
@@ -172,7 +132,4 @@ public class HashFactory
return Collections.unmodifiableSet(hs);
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/hash/Haval.java b/libjava/classpath/gnu/java/security/hash/Haval.java
index 1bf75652de7..662934f34ea 100644
--- a/libjava/classpath/gnu/java/security/hash/Haval.java
+++ b/libjava/classpath/gnu/java/security/hash/Haval.java
@@ -42,25 +42,21 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>The <i>HAVAL</i> message-digest algorithm is a variable output length,
- * with variable number of rounds. By default, this implementation allows
- * <i>HAVAL</i> to be used as a drop-in replacement for <i>MD5</i>.</p>
- *
- * <p>References:</p>
- *
+ * The <i>HAVAL</i> message-digest algorithm is a variable output length, with
+ * variable number of rounds. By default, this implementation allows <i>HAVAL</i>
+ * to be used as a drop-in replacement for <i>MD5</i>.
+ * <p>
+ * References:
* <ol>
- * <li>HAVAL - A One-Way Hashing Algorithm with Variable Length of Output<br>
- * Advances in Cryptology - AUSCRYPT'92, Lecture Notes in Computer Science,<br>
- * Springer-Verlag, 1993; <br>
- * Y. Zheng, J. Pieprzyk and J. Seberry.</li>
+ * <li>HAVAL - A One-Way Hashing Algorithm with Variable Length of Output<br>
+ * Advances in Cryptology - AUSCRYPT'92, Lecture Notes in Computer Science,<br>
+ * Springer-Verlag, 1993; <br>
+ * Y. Zheng, J. Pieprzyk and J. Seberry.</li>
* </ol>
*/
-public class Haval extends BaseHash
+public class Haval
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final int HAVAL_VERSION = 1;
public static final int HAVAL_128_BIT = 16;
@@ -88,20 +84,18 @@ public class Haval extends BaseHash
/**
* Number of HAVAL rounds. Allowed values are integers in the range <code>3
- * .. 5</code>. The default is <code>3</code>.
+ * .. 5</code>.
+ * The default is <code>3</code>.
*/
private int rounds = HAVAL_3_ROUND;
/** 128-bit interim result. */
private int h0, h1, h2, h3, h4, h5, h6, h7;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Calls the constructor with two argument using {@link #HAVAL_128_BIT} as
- * the value for the output size (i.e. <code>128</code> bits, and
- * {@link #HAVAL_3_ROUND} for the value of number of rounds.</p>
+ * Calls the constructor with two argument using {@link #HAVAL_128_BIT} as the
+ * value for the output size (i.e. <code>128</code> bits, and
+ * {@link #HAVAL_3_ROUND} for the value of number of rounds.
*/
public Haval()
{
@@ -109,9 +103,9 @@ public class Haval extends BaseHash
}
/**
- * <p>Calls the constructor with two arguments using the designated output
- * size, and {@link #HAVAL_3_ROUND} for the value of number of rounds.</p>
- *
+ * Calls the constructor with two arguments using the designated output size,
+ * and {@link #HAVAL_3_ROUND} for the value of number of rounds.
+ *
* @param size the output size in bytes of this instance.
* @throws IllegalArgumentException if the designated output size is invalid.
* @see #HAVAL_128_BIT
@@ -126,16 +120,16 @@ public class Haval extends BaseHash
}
/**
- * <p>Constructs a <code>Haval</code> instance with the designated output
- * size (in bytes). Valid output <code>size</code> values are <code>16</code>,
- * <code>20</code>, <code>24</code>, <code>28</code> and <code>32</code>.
- * Valid values for <code>rounds</code> are in the range <code>3..5</code>
- * inclusive.</p>
- *
+ * Constructs a <code>Haval</code> instance with the designated output size
+ * (in bytes). Valid output <code>size</code> values are <code>16</code>,
+ * <code>20</code>, <code>24</code>, <code>28</code> and
+ * <code>32</code>. Valid values for <code>rounds</code> are in the range
+ * <code>3..5</code> inclusive.
+ *
* @param size the output size in bytes of this instance.
* @param rounds the number of rounds to apply when transforming data.
* @throws IllegalArgumentException if the designated output size is invalid,
- * or if the number of rounds is invalid.
+ * or if the number of rounds is invalid.
* @see #HAVAL_128_BIT
* @see #HAVAL_160_BIT
* @see #HAVAL_192_BIT
@@ -149,24 +143,24 @@ public class Haval extends BaseHash
{
super(Registry.HAVAL_HASH, size, BLOCK_SIZE);
- if (size != HAVAL_128_BIT && size != HAVAL_160_BIT && size != HAVAL_192_BIT
- && size != HAVAL_224_BIT && size != HAVAL_256_BIT)
- {
- throw new IllegalArgumentException("Invalid HAVAL output size");
- }
+ if (size != HAVAL_128_BIT
+ && size != HAVAL_160_BIT
+ && size != HAVAL_192_BIT
+ && size != HAVAL_224_BIT
+ && size != HAVAL_256_BIT)
+ throw new IllegalArgumentException("Invalid HAVAL output size");
- if (rounds != HAVAL_3_ROUND && rounds != HAVAL_4_ROUND
+ if (rounds != HAVAL_3_ROUND
+ && rounds != HAVAL_4_ROUND
&& rounds != HAVAL_5_ROUND)
- {
- throw new IllegalArgumentException("Invalid HAVAL number of rounds");
- }
+ throw new IllegalArgumentException("Invalid HAVAL number of rounds");
this.rounds = rounds;
}
/**
- * <p>Private constructor for cloning purposes.</p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param md the instance to clone.
*/
private Haval(Haval md)
@@ -185,93 +179,142 @@ public class Haval extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new Haval(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected synchronized void transform(byte[] in, int i)
{
- int X0 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X1 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X2 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X3 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X4 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X5 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X6 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X7 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X8 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X9 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X10 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X11 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X12 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X13 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X14 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X15 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X16 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X17 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X18 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X19 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X20 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X21 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X22 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X23 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X24 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X25 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X26 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X27 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X28 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X29 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X30 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X31 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
-
+ int X0 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X1 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X2 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X3 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X4 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X5 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X6 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X7 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X8 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X9 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X10 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X11 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X12 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X13 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X14 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X15 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X16 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X17 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X18 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X19 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X20 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X21 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X22 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X23 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X24 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X25 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X26 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X27 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X28 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X29 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X30 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
+ int X31 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 24;
int t0 = h0, t1 = h1, t2 = h2, t3 = h3, t4 = h4, t5 = h5, t6 = h6, t7 = h7;
-
// Pass 1
t7 = FF1(t7, t6, t5, t4, t3, t2, t1, t0, X0);
t6 = FF1(t6, t5, t4, t3, t2, t1, t0, t7, X1);
@@ -458,7 +501,6 @@ public class Haval extends BaseHash
t0 = FF5(t0, t7, t6, t5, t4, t3, t2, t1, X15, 0x409F60C4);
}
}
-
h7 += t7;
h6 += t6;
h5 += t5;
@@ -471,30 +513,30 @@ public class Haval extends BaseHash
protected byte[] padBuffer()
{
- // pad out to 118 mod 128. other 10 bytes have special use.
- int n = (int) (count % BLOCK_SIZE);
+ // pad out to 118 mod 128. other 10 bytes have special use.
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 118) ? (118 - n) : (246 - n);
byte[] result = new byte[padding + 10];
result[0] = (byte) 0x01;
-
// save the version number (LSB 3), the number of rounds (3 bits in the
// middle), the fingerprint length (MSB 2 bits and next byte) and the
// number of bits in the unpadded message.
int bl = hashSize * 8;
- result[padding++] = (byte) (((bl & 0x03) << 6) | ((rounds & 0x07) << 3) | (HAVAL_VERSION & 0x07));
- result[padding++] = (byte) (bl >>> 2);
-
+ int sigByte = (bl & 0x03) << 6;
+ sigByte |= (rounds & 0x07) << 3;
+ sigByte |= HAVAL_VERSION & 0x07;
+ result[padding++] = (byte) sigByte;
+ result[padding++] = (byte)(bl >>> 2);
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
result[padding++] = (byte) bits;
- result[padding++] = (byte) (bits >>> 8);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 48);
- result[padding] = (byte) (bits >>> 56);
-
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding ] = (byte)(bits >>> 56);
return result;
}
@@ -505,49 +547,48 @@ public class Haval extends BaseHash
byte[] result = new byte[hashSize];
if (hashSize >= HAVAL_256_BIT)
{
- result[31] = (byte) (h7 >>> 24);
- result[30] = (byte) (h7 >>> 16);
- result[29] = (byte) (h7 >>> 8);
+ result[31] = (byte)(h7 >>> 24);
+ result[30] = (byte)(h7 >>> 16);
+ result[29] = (byte)(h7 >>> 8);
result[28] = (byte) h7;
}
if (hashSize >= HAVAL_224_BIT)
{
- result[27] = (byte) (h6 >>> 24);
- result[26] = (byte) (h6 >>> 16);
- result[25] = (byte) (h6 >>> 8);
+ result[27] = (byte)(h6 >>> 24);
+ result[26] = (byte)(h6 >>> 16);
+ result[25] = (byte)(h6 >>> 8);
result[24] = (byte) h6;
}
if (hashSize >= HAVAL_192_BIT)
{
- result[23] = (byte) (h5 >>> 24);
- result[22] = (byte) (h5 >>> 16);
- result[21] = (byte) (h5 >>> 8);
+ result[23] = (byte)(h5 >>> 24);
+ result[22] = (byte)(h5 >>> 16);
+ result[21] = (byte)(h5 >>> 8);
result[20] = (byte) h5;
}
if (hashSize >= HAVAL_160_BIT)
{
- result[19] = (byte) (h4 >>> 24);
- result[18] = (byte) (h4 >>> 16);
- result[17] = (byte) (h4 >>> 8);
+ result[19] = (byte)(h4 >>> 24);
+ result[18] = (byte)(h4 >>> 16);
+ result[17] = (byte)(h4 >>> 8);
result[16] = (byte) h4;
}
- result[15] = (byte) (h3 >>> 24);
- result[14] = (byte) (h3 >>> 16);
- result[13] = (byte) (h3 >>> 8);
+ result[15] = (byte)(h3 >>> 24);
+ result[14] = (byte)(h3 >>> 16);
+ result[13] = (byte)(h3 >>> 8);
result[12] = (byte) h3;
- result[11] = (byte) (h2 >>> 24);
- result[10] = (byte) (h2 >>> 16);
- result[9] = (byte) (h2 >>> 8);
- result[8] = (byte) h2;
- result[7] = (byte) (h1 >>> 24);
- result[6] = (byte) (h1 >>> 16);
- result[5] = (byte) (h1 >>> 8);
- result[4] = (byte) h1;
- result[3] = (byte) (h0 >>> 24);
- result[2] = (byte) (h0 >>> 16);
- result[1] = (byte) (h0 >>> 8);
- result[0] = (byte) h0;
-
+ result[11] = (byte)(h2 >>> 24);
+ result[10] = (byte)(h2 >>> 16);
+ result[ 9] = (byte)(h2 >>> 8);
+ result[ 8] = (byte) h2;
+ result[ 7] = (byte)(h1 >>> 24);
+ result[ 6] = (byte)(h1 >>> 16);
+ result[ 5] = (byte)(h1 >>> 8);
+ result[ 4] = (byte) h1;
+ result[ 3] = (byte)(h0 >>> 24);
+ result[ 2] = (byte)(h0 >>> 16);
+ result[ 1] = (byte)(h0 >>> 8);
+ result[ 0] = (byte) h0;
return result;
}
@@ -567,13 +608,12 @@ public class Haval extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new Haval().digest())));
+ String d = Util.toString(new Haval().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
- // helper methods ----------------------------------------------------------
-
/** Tailors the last output. */
private void tailorDigestBits()
{
@@ -581,17 +621,25 @@ public class Haval extends BaseHash
switch (hashSize)
{
case HAVAL_128_BIT:
- t = (h7 & 0x000000FF) | (h6 & 0xFF000000) | (h5 & 0x00FF0000)
- | (h4 & 0x0000FF00);
+ t = (h7 & 0x000000FF)
+ | (h6 & 0xFF000000)
+ | (h5 & 0x00FF0000)
+ | (h4 & 0x0000FF00);
h0 += t >>> 8 | t << 24;
- t = (h7 & 0x0000FF00) | (h6 & 0x000000FF) | (h5 & 0xFF000000)
- | (h4 & 0x00FF0000);
+ t = (h7 & 0x0000FF00)
+ | (h6 & 0x000000FF)
+ | (h5 & 0xFF000000)
+ | (h4 & 0x00FF0000);
h1 += t >>> 16 | t << 16;
- t = (h7 & 0x00FF0000) | (h6 & 0x0000FF00) | (h5 & 0x000000FF)
- | (h4 & 0xFF000000);
+ t = (h7 & 0x00FF0000)
+ | (h6 & 0x0000FF00)
+ | (h5 & 0x000000FF)
+ | (h4 & 0xFF000000);
h2 += t >>> 24 | t << 8;
- t = (h7 & 0xFF000000) | (h6 & 0x00FF0000) | (h5 & 0x0000FF00)
- | (h4 & 0x000000FF);
+ t = (h7 & 0xFF000000)
+ | (h6 & 0x00FF0000)
+ | (h5 & 0x0000FF00)
+ | (h4 & 0x000000FF);
h3 += t;
break;
case HAVAL_160_BIT:
@@ -625,9 +673,9 @@ public class Haval extends BaseHash
h1 += ((h7 >>> 22) & 0x1F);
h2 += ((h7 >>> 18) & 0x0F);
h3 += ((h7 >>> 13) & 0x1F);
- h4 += ((h7 >>> 9) & 0x0F);
- h5 += ((h7 >>> 4) & 0x1F);
- h6 += (h7 & 0x0F);
+ h4 += ((h7 >>> 9) & 0x0F);
+ h5 += ((h7 >>> 4) & 0x1F);
+ h6 += (h7 & 0x0F);
}
}
@@ -748,8 +796,8 @@ public class Haval extends BaseHash
private int f4(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
{
- return x4 & (x5 & ~x2 ^ x3 & ~x6 ^ x1 ^ x6 ^ x0) ^ x3 & (x1 & x2 ^ x5 ^ x6)
- ^ x2 & x6 ^ x0;
+ return x4 & (x5 & ~x2 ^ x3 & ~x6 ^ x1 ^ x6 ^ x0) ^ x3
+ & (x1 & x2 ^ x5 ^ x6) ^ x2 & x6 ^ x0;
}
private int f5(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
diff --git a/libjava/classpath/gnu/java/security/hash/IMessageDigest.java b/libjava/classpath/gnu/java/security/hash/IMessageDigest.java
index b3d7f69ca2e..2c5bdd41a57 100644
--- a/libjava/classpath/gnu/java/security/hash/IMessageDigest.java
+++ b/libjava/classpath/gnu/java/security/hash/IMessageDigest.java
@@ -39,64 +39,56 @@ exception statement from your version. */
package gnu.java.security.hash;
/**
- * <p>The basic visible methods of any hash algorithm.</p>
- *
- * <p>A hash (or message digest) algorithm produces its output by iterating a
- * basic compression function on blocks of data.</p>
+ * The basic visible methods of any hash algorithm.
+ * <p>
+ * A hash (or message digest) algorithm produces its output by iterating a basic
+ * compression function on blocks of data.
*/
-public interface IMessageDigest extends Cloneable
+public interface IMessageDigest
+ extends Cloneable
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of this algorithm.</p>
- *
+ * Returns the canonical name of this algorithm.
+ *
* @return the canonical name of this instance.
*/
String name();
/**
- * <p>Returns the output length in bytes of this message digest algorithm.</p>
- *
+ * Returns the output length in bytes of this message digest algorithm.
+ *
* @return the output length in bytes of this message digest algorithm.
*/
int hashSize();
/**
- * <p>Returns the algorithm's (inner) block size in bytes.</p>
- *
+ * Returns the algorithm's (inner) block size in bytes.
+ *
* @return the algorithm's inner block size in bytes.
*/
int blockSize();
/**
- * <p>Continues a message digest operation using the input byte.</p>
- *
+ * Continues a message digest operation using the input byte.
+ *
* @param b the input byte to digest.
*/
void update(byte b);
/**
- * <p>Continues a message digest operation, by filling the buffer, processing
+ * Continues a message digest operation, by filling the buffer, processing
* data in the algorithm's HASH_SIZE-bit block(s), updating the context and
- * count, and buffering the remaining bytes in buffer for the next
- * operation.</p>
- *
+ * count, and buffering the remaining bytes in buffer for the next operation.
+ *
* @param in the input block.
*/
void update(byte[] in);
/**
- * <p>Continues a message digest operation, by filling the buffer, processing
+ * Continues a message digest operation, by filling the buffer, processing
* data in the algorithm's HASH_SIZE-bit block(s), updating the context and
- * count, and buffering the remaining bytes in buffer for the next
- * operation.</p>
- *
+ * count, and buffering the remaining bytes in buffer for the next operation.
+ *
* @param in the input block.
* @param offset start of meaningful bytes in input block.
* @param length number of bytes, in input block, to consider.
@@ -104,31 +96,31 @@ public interface IMessageDigest extends Cloneable
void update(byte[] in, int offset, int length);
/**
- * <p>Completes the message digest by performing final operations such as
- * padding and resetting the instance.</p>
- *
+ * Completes the message digest by performing final operations such as padding
+ * and resetting the instance.
+ *
* @return the array of bytes representing the hash value.
*/
byte[] digest();
/**
- * <p>Resets the current context of this instance clearing any eventually cached
- * intermediary values.</p>
+ * Resets the current context of this instance clearing any eventually cached
+ * intermediary values.
*/
void reset();
/**
- * <p>A basic test. Ensures that the digest of a pre-determined message is equal
- * to a known pre-computed value.</p>
- *
- * @return <tt>true</tt> if the implementation passes a basic self-test.
- * Returns <tt>false</tt> otherwise.
+ * A basic test. Ensures that the digest of a pre-determined message is equal
+ * to a known pre-computed value.
+ *
+ * @return <code>true</code> if the implementation passes a basic self-test.
+ * Returns <code>false</code> otherwise.
*/
boolean selfTest();
/**
- * <p>Returns a clone copy of this instance.</p>
- *
+ * Returns a clone copy of this instance.
+ *
* @return a clone copy of this instance.
*/
Object clone();
diff --git a/libjava/classpath/gnu/java/security/hash/MD2.java b/libjava/classpath/gnu/java/security/hash/MD2.java
index 2a93c42c44a..8f6b265b037 100644
--- a/libjava/classpath/gnu/java/security/hash/MD2.java
+++ b/libjava/classpath/gnu/java/security/hash/MD2.java
@@ -42,13 +42,12 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>An implementation of the MD2 message digest algorithm.</p>
- *
- * <p>MD2 is not widely used. Unless it is needed for compatibility with
- * existing systems, it is not recommended for use in new applications.</p>
- *
- * <p>References:</p>
- *
+ * An implementation of the MD2 message digest algorithm.
+ * <p>
+ * MD2 is not widely used. Unless it is needed for compatibility with
+ * existing systems, it is not recommended for use in new applications.
+ * <p>
+ * References:
* <ol>
* <li>The <a href="http://www.ietf.org/rfc/rfc1319.txt">MD2</a>
* Message-Digest Algorithm.<br>
@@ -57,12 +56,9 @@ import gnu.java.security.util.Util;
* under section RFC 1319.</li>
* </ol>
*/
-public class MD2 extends BaseHash
+public class MD2
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** An MD2 message digest is always 128-bits long, or 16 bytes. */
private static final int DIGEST_LENGTH = 16;
@@ -70,34 +66,39 @@ public class MD2 extends BaseHash
private static final int BLOCK_LENGTH = 16;
/** 256 byte "random" permutation of the digits of pi. */
- private static final byte[] PI = { 41, 46, 67, -55, -94, -40, 124, 1, 61, 54,
- 84, -95, -20, -16, 6, 19, 98, -89, 5, -13,
- -64, -57, 115, -116, -104, -109, 43, -39,
- -68, 76, -126, -54, 30, -101, 87, 60, -3,
- -44, -32, 22, 103, 66, 111, 24, -118, 23,
- -27, 18, -66, 78, -60, -42, -38, -98, -34,
- 73, -96, -5, -11, -114, -69, 47, -18, 122,
- -87, 104, 121, -111, 21, -78, 7, 63, -108,
- -62, 16, -119, 11, 34, 95, 33, -128, 127,
- 93, -102, 90, -112, 50, 39, 53, 62, -52,
- -25, -65, -9, -105, 3, -1, 25, 48, -77, 72,
- -91, -75, -47, -41, 94, -110, 42, -84, 86,
- -86, -58, 79, -72, 56, -46, -106, -92, 125,
- -74, 118, -4, 107, -30, -100, 116, 4, -15,
- 69, -99, 112, 89, 100, 113, -121, 32, -122,
- 91, -49, 101, -26, 45, -88, 2, 27, 96, 37,
- -83, -82, -80, -71, -10, 28, 70, 97, 105,
- 52, 64, 126, 15, 85, 71, -93, 35, -35, 81,
- -81, 58, -61, 92, -7, -50, -70, -59, -22,
- 38, 44, 83, 13, 110, -123, 40, -124, 9,
- -45, -33, -51, -12, 65, -127, 77, 82, 106,
- -36, 55, -56, 108, -63, -85, -6, 36, -31,
- 123, 8, 12, -67, -79, 74, 120, -120, -107,
- -117, -29, 99, -24, 109, -23, -53, -43, -2,
- 59, 0, 29, 57, -14, -17, -73, 14, 102, 88,
- -48, -28, -90, 119, 114, -8, -21, 117, 75,
- 10, 49, 68, 80, -76, -113, -19, 31, 26,
- -37, -103, -115, 51, -97, 17, -125, 20 };
+ private static final byte[] PI = {
+ 41, 46, 67, -55, -94, -40, 124, 1,
+ 61, 54, 84, -95, -20, -16, 6, 19,
+ 98, -89, 5, -13, -64, -57, 115, -116,
+ -104, -109, 43, -39, -68, 76, -126, -54,
+ 30, -101, 87, 60, -3, -44, -32, 22,
+ 103, 66, 111, 24, -118, 23, -27, 18,
+ -66, 78, -60, -42, -38, -98, -34, 73,
+ -96, -5, -11, -114, -69, 47, -18, 122,
+ -87, 104, 121, -111, 21, -78, 7, 63,
+ -108, -62, 16, -119, 11, 34, 95, 33,
+ -128, 127, 93, -102, 90, -112, 50, 39,
+ 53, 62, -52, -25, -65, -9, -105, 3,
+ -1, 25, 48, -77, 72, -91, -75, -47,
+ -41, 94, -110, 42, -84, 86, -86, -58,
+ 79, -72, 56, -46, -106, -92, 125, -74,
+ 118, -4, 107, -30, -100, 116, 4, -15,
+ 69, -99, 112, 89, 100, 113, -121, 32,
+ -122, 91, -49, 101, -26, 45, -88, 2,
+ 27, 96, 37, -83, -82, -80, -71, -10,
+ 28, 70, 97, 105, 52, 64, 126, 15,
+ 85, 71, -93, 35, -35, 81, -81, 58,
+ -61, 92, -7, -50, -70, -59, -22, 38,
+ 44, 83, 13, 110, -123, 40, -124, 9,
+ -45, -33, -51, -12, 65, -127, 77, 82,
+ 106, -36, 55, -56, 108, -63, -85, -6,
+ 36, -31, 123, 8, 12, -67, -79, 74,
+ 120, -120, -107, -117, -29, 99, -24, 109,
+ -23, -53, -43, -2, 59, 0, 29, 57,
+ -14, -17, -73, 14, 102, 88, -48, -28,
+ -90, 119, 114, -8, -21, 117, 75, 10,
+ 49, 68, 80, -76, -113, -19, 31, 26,
+ -37, -103, -115, 51, - 97, 17, -125, 20 };
/** The output of this message digest when no data has been input. */
private static final String DIGEST0 = "8350E5A3E24C153DF2275C9F80692773";
@@ -114,9 +115,6 @@ public class MD2 extends BaseHash
*/
private byte[] work;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Creates a new MD2 digest ready for use. */
public MD2()
{
@@ -124,7 +122,7 @@ public class MD2 extends BaseHash
}
/**
- * <p>Private constructor used for cloning.</p>
+ * Private constructor used for cloning.
*
* @param md2 the instance to clone.
*/
@@ -135,38 +133,23 @@ public class MD2 extends BaseHash
// superclass field
this.count = md2.count;
this.buffer = (byte[]) md2.buffer.clone();
-
// private field
this.checksum = (byte[]) md2.checksum.clone();
this.work = (byte[]) md2.work.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new MD2(this);
}
- // Implementation of abstract methods in BaseHash --------------------------
-
protected byte[] getResult()
{
byte[] result = new byte[DIGEST_LENGTH];
-
// Encrypt checksum as last block.
encryptBlock(checksum, 0);
-
for (int i = 0; i < BLOCK_LENGTH; i++)
- {
- result[i] = work[i];
- }
+ result[i] = work[i];
return result;
}
@@ -181,17 +164,18 @@ public class MD2 extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new MD2().digest())));
+ String d = Util.toString(new MD2().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
/**
- * <p>Generates an array of padding bytes. The padding is defined as
+ * Generates an array of padding bytes. The padding is defined as
* <code>i</code> bytes of value <code>i</code>, where <code>i</code> is the
* number of bytes to fill the last block of the message to
* <code>BLOCK_LENGTH</code> bytes (or <code>BLOCK_LENGTH</code> bytes when
- * the last block was completely full).</p>
+ * the last block was completely full).
*
* @return the bytes to pad the remaining bytes in the buffer before
* completing a hash operation.
@@ -200,47 +184,26 @@ public class MD2 extends BaseHash
{
int length = BLOCK_LENGTH - (int) (count % BLOCK_LENGTH);
if (length == 0)
- {
- length = BLOCK_LENGTH;
- }
+ length = BLOCK_LENGTH;
+
byte[] pad = new byte[length];
for (int i = 0; i < length; i++)
- {
- pad[i] = (byte) length;
- }
+ pad[i] = (byte) length;
+
return pad;
}
/**
- * <p>Adds <code>BLOCK_LENGTH</code> bytes to the running digest.</p>
+ * Adds <code>BLOCK_LENGTH</code> bytes to the running digest.
*
* @param in the byte array to take the <code>BLOCK_LENGTH</code> bytes from.
* @param off the offset to start from in the given byte array.
*/
protected void transform(byte[] in, int off)
{
- // encryptBlock(in, off);
- // updateCheckSum(in, off);
updateCheckSumAndEncryptBlock(in, off);
}
- // Private instance methods ------------------------------------------------
-
- /**
- * Updates the checksum with the <code>BLOCK_LENGTH</code> bytes from the
- * given array starting at <code>off</code>.
- */
- /*
- private void updateCheckSum(byte[] in, int off) {
- byte l = checksum[BLOCK_LENGTH-1];
- for (int i = 0; i < BLOCK_LENGTH; i++) {
- byte b = in[off+i];
- // l = (byte)((checksum[i] & 0xFF) ^ (PI[((b & 0xFF) ^ (l & 0xFF))] & 0xFF));
- l = (byte)(checksum[i] ^ PI[(b ^ l) & 0xFF]);
- checksum[i] = l;
- }
- }
- */
/**
* Adds a new block (<code>BLOCK_LENGTH</code> bytes) to the running digest
* from the given byte array starting from the given offset.
@@ -251,20 +214,17 @@ public class MD2 extends BaseHash
{
byte b = in[off + i];
work[BLOCK_LENGTH + i] = b;
- work[BLOCK_LENGTH * 2 + i] = (byte) (work[i] ^ b);
+ work[BLOCK_LENGTH * 2 + i] = (byte)(work[i] ^ b);
}
-
byte t = 0;
for (int i = 0; i < 18; i++)
{
for (int j = 0; j < 3 * BLOCK_LENGTH; j++)
{
- // t = (byte)((work[j] & 0xFF) ^ (PI[t & 0xFF] & 0xFF));
- t = (byte) (work[j] ^ PI[t & 0xFF]);
+ t = (byte)(work[j] ^ PI[t & 0xFF]);
work[j] = t;
}
- // t = (byte)((t + i) & 0xFF);
- t = (byte) (t + i);
+ t = (byte)(t + i);
}
}
@@ -278,24 +238,19 @@ public class MD2 extends BaseHash
{
byte b = in[off + i];
work[BLOCK_LENGTH + i] = b;
- // work[BLOCK_LENGTH*2+i] = (byte)((work[i] & 0xFF) ^ (b & 0xFF));
- work[BLOCK_LENGTH * 2 + i] = (byte) (work[i] ^ b);
- // l = (byte)((checksum[i] & 0xFF) ^ (PI[((b & 0xFF) ^ (l & 0xFF))] & 0xFF));
- l = (byte) (checksum[i] ^ PI[(b ^ l) & 0xFF]);
+ work[BLOCK_LENGTH * 2 + i] = (byte)(work[i] ^ b);
+ l = (byte)(checksum[i] ^ PI[(b ^ l) & 0xFF]);
checksum[i] = l;
}
-
byte t = 0;
for (int i = 0; i < 18; i++)
{
for (int j = 0; j < 3 * BLOCK_LENGTH; j++)
{
- // t = (byte)((work[j] & 0xFF) ^ (PI[t & 0xFF] & 0xFF));
- t = (byte) (work[j] ^ PI[t & 0xFF]);
+ t = (byte)(work[j] ^ PI[t & 0xFF]);
work[j] = t;
}
- // t = (byte)((t + i) & 0xFF);
- t = (byte) (t + i);
+ t = (byte)(t + i);
}
}
}
diff --git a/libjava/classpath/gnu/java/security/hash/MD4.java b/libjava/classpath/gnu/java/security/hash/MD4.java
index a09eb170554..dfc1c6bd69f 100644
--- a/libjava/classpath/gnu/java/security/hash/MD4.java
+++ b/libjava/classpath/gnu/java/security/hash/MD4.java
@@ -42,14 +42,13 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>An implementation of Ron Rivest's MD4 message digest algorithm.</p>
- *
- * <p>MD4 was the precursor to the stronger {@link gnu.crypto.hash.MD5}
+ * An implementation of Ron Rivest's MD4 message digest algorithm.
+ * <p>
+ * MD4 was the precursor to the stronger {@link gnu.java.security.hash.MD5}
* algorithm, and while not considered cryptograpically secure itself, MD4 is
- * in use in various applications. It is slightly faster than MD5.</p>
- *
- * <p>References:</p>
- *
+ * in use in various applications. It is slightly faster than MD5.
+ * <p>
+ * References:
* <ol>
* <li>The <a href="http://www.ietf.org/rfc/rfc1320.txt">MD4</a>
* Message-Digest Algorithm.<br>
@@ -58,12 +57,9 @@ import gnu.java.security.util.Util;
*
* @author Casey Marshall (rsdio@metastatic.org)
*/
-public class MD4 extends BaseHash
+public class MD4
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** An MD4 message digest is always 128-bits long, or 16 bytes. */
private static final int DIGEST_LENGTH = 16;
@@ -86,13 +82,9 @@ public class MD4 extends BaseHash
private int a, b, c, d;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Public constructor. Initializes the chaining variables, sets the byte
+ * Public constructor. Initializes the chaining variables, sets the byte
* count to <code>0</code>, and creates a new block of <code>512</code> bits.
- * </p>
*/
public MD4()
{
@@ -100,7 +92,7 @@ public class MD4 extends BaseHash
}
/**
- * <p>Trivial private constructor for cloning purposes.</p>
+ * Trivial private constructor for cloning purposes.
*
* @param that the instance to clone.
*/
@@ -116,30 +108,18 @@ public class MD4 extends BaseHash
this.buffer = (byte[]) that.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new MD4(this);
}
- // Implementation of abstract methods in BashHash --------------------------
-
protected byte[] getResult()
{
- byte[] digest = { (byte) a, (byte) (a >>> 8), (byte) (a >>> 16),
- (byte) (a >>> 24), (byte) b, (byte) (b >>> 8),
- (byte) (b >>> 16), (byte) (b >>> 24), (byte) c,
- (byte) (c >>> 8), (byte) (c >>> 16), (byte) (c >>> 24),
- (byte) d, (byte) (d >>> 8), (byte) (d >>> 16),
- (byte) (d >>> 24) };
- return digest;
+ return new byte[] {
+ (byte) a, (byte)(a >>> 8), (byte)(a >>> 16), (byte)(a >>> 24),
+ (byte) b, (byte)(b >>> 8), (byte)(b >>> 16), (byte)(b >>> 24),
+ (byte) c, (byte)(c >>> 8), (byte)(c >>> 16), (byte)(c >>> 24),
+ (byte) d, (byte)(d >>> 8), (byte)(d >>> 16), (byte)(d >>> 24) };
}
protected void resetContext()
@@ -154,68 +134,97 @@ public class MD4 extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new MD4().digest())));
+ String d = Util.toString(new MD4().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_LENGTH);
+ int n = (int)(count % BLOCK_LENGTH);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] pad = new byte[padding + 8];
-
pad[0] = (byte) 0x80;
long bits = count << 3;
pad[padding++] = (byte) bits;
- pad[padding++] = (byte) (bits >>> 8);
- pad[padding++] = (byte) (bits >>> 16);
- pad[padding++] = (byte) (bits >>> 24);
- pad[padding++] = (byte) (bits >>> 32);
- pad[padding++] = (byte) (bits >>> 40);
- pad[padding++] = (byte) (bits >>> 48);
- pad[padding] = (byte) (bits >>> 56);
-
+ pad[padding++] = (byte)(bits >>> 8);
+ pad[padding++] = (byte)(bits >>> 16);
+ pad[padding++] = (byte)(bits >>> 24);
+ pad[padding++] = (byte)(bits >>> 32);
+ pad[padding++] = (byte)(bits >>> 40);
+ pad[padding++] = (byte)(bits >>> 48);
+ pad[padding ] = (byte)(bits >>> 56);
return pad;
}
protected void transform(byte[] in, int i)
{
- int X0 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X1 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X2 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X3 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X4 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X5 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X6 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X7 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X8 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X9 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X10 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X11 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X12 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X13 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X14 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X15 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i] << 24;
-
+ int X0 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X1 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X2 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X3 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X4 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X5 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X6 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X7 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X8 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X9 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X10 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X11 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X12 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X13 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X14 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X15 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i] << 24;
int aa, bb, cc, dd;
-
aa = a;
bb = b;
cc = c;
diff --git a/libjava/classpath/gnu/java/security/hash/MD5.java b/libjava/classpath/gnu/java/security/hash/MD5.java
index 165392394fc..653078512d5 100644
--- a/libjava/classpath/gnu/java/security/hash/MD5.java
+++ b/libjava/classpath/gnu/java/security/hash/MD5.java
@@ -42,26 +42,22 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>The MD5 message-digest algorithm takes as input a message of arbitrary
+ * The MD5 message-digest algorithm takes as input a message of arbitrary
* length and produces as output a 128-bit "fingerprint" or "message digest" of
* the input. It is conjectured that it is computationally infeasible to
* produce two messages having the same message digest, or to produce any
- * message having a given prespecified target message digest.</p>
- *
- * <p>References:</p>
- *
+ * message having a given prespecified target message digest.
+ * <p>
+ * References:
* <ol>
* <li>The <a href="http://www.ietf.org/rfc/rfc1321.txt">MD5</a> Message-
* Digest Algorithm.<br>
* R. Rivest.</li>
* </ol>
*/
-public class MD5 extends BaseHash
+public class MD5
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int BLOCK_SIZE = 64; // inner block size in bytes
private static final String DIGEST0 = "D41D8CD98F00B204E9800998ECF8427E";
@@ -72,9 +68,6 @@ public class MD5 extends BaseHash
/** 128-bit interim result. */
private int h0, h1, h2, h3;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public MD5()
{
@@ -82,7 +75,7 @@ public class MD5 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -98,61 +91,81 @@ public class MD5 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new MD5(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected synchronized void transform(byte[] in, int i)
{
- int X0 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X1 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X2 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X3 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X4 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X5 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X6 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X7 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X8 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X9 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X10 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X11 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X12 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X13 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X14 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X15 = (in[i++] & 0xFF) | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF) << 16
- | in[i] << 24;
-
+ int X0 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X1 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X2 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X3 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X4 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X5 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X6 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X7 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X8 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X9 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X10 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X11 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X12 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X13 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X14 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i++] << 24;
+ int X15 = (in[i++] & 0xFF)
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) << 16
+ | in[i] << 24;
int A = h0;
int B = h1;
int C = h2;
int D = h3;
-
// hex constants are from md5.c in FSF Gnu Privacy Guard 0.9.2
// round 1
A += ((B & C) | (~B & D)) + X0 + 0xD76AA478;
@@ -310,39 +323,31 @@ public class MD5 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] result = new byte[padding + 8];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
result[padding++] = (byte) bits;
- result[padding++] = (byte) (bits >>> 8);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 48);
- result[padding] = (byte) (bits >>> 56);
-
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding ] = (byte)(bits >>> 56);
return result;
}
protected byte[] getResult()
{
- byte[] result = new byte[] { (byte) h0, (byte) (h0 >>> 8),
- (byte) (h0 >>> 16), (byte) (h0 >>> 24),
- (byte) h1, (byte) (h1 >>> 8),
- (byte) (h1 >>> 16), (byte) (h1 >>> 24),
- (byte) h2, (byte) (h2 >>> 8),
- (byte) (h2 >>> 16), (byte) (h2 >>> 24),
- (byte) h3, (byte) (h3 >>> 8),
- (byte) (h3 >>> 16), (byte) (h3 >>> 24) };
-
- return result;
+ return new byte[] {
+ (byte) h0, (byte)(h0 >>> 8), (byte)(h0 >>> 16), (byte)(h0 >>> 24),
+ (byte) h1, (byte)(h1 >>> 8), (byte)(h1 >>> 16), (byte)(h1 >>> 24),
+ (byte) h2, (byte)(h2 >>> 8), (byte)(h2 >>> 16), (byte)(h2 >>> 24),
+ (byte) h3, (byte)(h3 >>> 8), (byte)(h3 >>> 16), (byte)(h3 >>> 24) };
}
protected void resetContext()
@@ -358,7 +363,8 @@ public class MD5 extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new MD5().digest())));
+ String d = Util.toString(new MD5().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/java/security/hash/RipeMD128.java b/libjava/classpath/gnu/java/security/hash/RipeMD128.java
index 31874a0c29a..62f5a05e5bf 100644
--- a/libjava/classpath/gnu/java/security/hash/RipeMD128.java
+++ b/libjava/classpath/gnu/java/security/hash/RipeMD128.java
@@ -42,54 +42,48 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>RIPEMD-128 is a 128-bit message digest.</p>
- *
- * <p>References:</p>
- *
+ * RIPEMD-128 is a 128-bit message digest.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html">
* RIPEMD160</a>: A Strengthened Version of RIPEMD.<br>
* Hans Dobbertin, Antoon Bosselaers and Bart Preneel.</li>
* </ol>
*/
-public class RipeMD128 extends BaseHash
+public class RipeMD128
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int BLOCK_SIZE = 64; // inner block size in bytes
private static final String DIGEST0 = "CDF26213A150DC3ECB610F18F6B38B46";
/** Constants for the transform method. */
// selection of message word
- private static final int[] R = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0,
- 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8,
- 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10,
- 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2 };
-
- private static final int[] Rp = { 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1,
- 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14,
- 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14,
- 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4,
- 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14 };
+ private static final int[] R = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2 };
+
+ private static final int[] Rp = {
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14 };
// amount for rotate left (rol)
- private static final int[] S = { 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15,
- 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12,
- 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9,
- 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12,
- 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5,
- 12 };
-
- private static final int[] Sp = { 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11,
- 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11,
- 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8,
- 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15,
- 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5,
- 15, 8 };
+ private static final int[] S = {
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12 };
+
+ private static final int[] Sp = {
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8 };
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
@@ -100,9 +94,6 @@ public class RipeMD128 extends BaseHash
/** 512 bits work buffer = 16 x 32-bit words */
private int[] X = new int[16];
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public RipeMD128()
{
@@ -110,7 +101,7 @@ public class RipeMD128 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -126,40 +117,26 @@ public class RipeMD128 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new RipeMD128(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
int A, B, C, D, Ap, Bp, Cp, Dp, T, s, i;
-
- // encode 64 bytes from input block into an array of 16 unsigned
- // integers.
+ // encode 64 bytes from input block into an array of 16 unsigned integers.
for (i = 0; i < 16; i++)
- {
- X[i] = (in[offset++] & 0xFF) | (in[offset++] & 0xFF) << 8
- | (in[offset++] & 0xFF) << 16 | in[offset++] << 24;
- }
-
+ X[i] = (in[offset++] & 0xFF)
+ | (in[offset++] & 0xFF) << 8
+ | (in[offset++] & 0xFF) << 16
+ | in[offset++] << 24;
A = Ap = h0;
B = Bp = h1;
C = Cp = h2;
D = Dp = h3;
-
- for (i = 0; i < 16; i++)
- { // rounds 0...15
+ for (i = 0; i < 16; i++) // rounds 0...15
+ {
s = S[i];
T = A + (B ^ C ^ D) + X[i];
A = D;
@@ -174,9 +151,8 @@ public class RipeMD128 extends BaseHash
Cp = Bp;
Bp = T << s | T >>> (32 - s);
}
-
- for (; i < 32; i++)
- { // rounds 16...31
+ for (; i < 32; i++) // rounds 16...31
+ {
s = S[i];
T = A + ((B & C) | (~B & D)) + X[R[i]] + 0x5A827999;
A = D;
@@ -191,9 +167,8 @@ public class RipeMD128 extends BaseHash
Cp = Bp;
Bp = T << s | T >>> (32 - s);
}
-
- for (; i < 48; i++)
- { // rounds 32...47
+ for (; i < 48; i++) // rounds 32...47
+ {
s = S[i];
T = A + ((B | ~C) ^ D) + X[R[i]] + 0x6ED9EBA1;
A = D;
@@ -208,9 +183,8 @@ public class RipeMD128 extends BaseHash
Cp = Bp;
Bp = T << s | T >>> (32 - s);
}
-
- for (; i < 64; i++)
- { // rounds 48...63
+ for (; i < 64; i++) // rounds 48...63
+ {
s = S[i];
T = A + ((B & D) | (C & ~D)) + X[R[i]] + 0x8F1BBCDC;
A = D;
@@ -225,7 +199,6 @@ public class RipeMD128 extends BaseHash
Cp = Bp;
Bp = T << s | T >>> (32 - s);
}
-
T = h1 + C + Dp;
h1 = h2 + D + Ap;
h2 = h3 + A + Bp;
@@ -235,39 +208,32 @@ public class RipeMD128 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] result = new byte[padding + 8];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
result[padding++] = (byte) bits;
- result[padding++] = (byte) (bits >>> 8);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 48);
- result[padding] = (byte) (bits >>> 56);
-
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding ] = (byte)(bits >>> 56);
return result;
}
protected byte[] getResult()
{
- byte[] result = new byte[] { (byte) h0, (byte) (h0 >>> 8),
- (byte) (h0 >>> 16), (byte) (h0 >>> 24),
- (byte) h1, (byte) (h1 >>> 8),
- (byte) (h1 >>> 16), (byte) (h1 >>> 24),
- (byte) h2, (byte) (h2 >>> 8),
- (byte) (h2 >>> 16), (byte) (h2 >>> 24),
- (byte) h3, (byte) (h3 >>> 8),
- (byte) (h3 >>> 16), (byte) (h3 >>> 24) };
-
- return result;
+ return new byte[] {
+ (byte) h0, (byte)(h0 >>> 8), (byte)(h0 >>> 16), (byte)(h0 >>> 24),
+ (byte) h1, (byte)(h1 >>> 8), (byte)(h1 >>> 16), (byte)(h1 >>> 24),
+ (byte) h2, (byte)(h2 >>> 8), (byte)(h2 >>> 16), (byte)(h2 >>> 24),
+ (byte) h3, (byte)(h3 >>> 8), (byte)(h3 >>> 16), (byte)(h3 >>> 24)
+ };
}
protected void resetContext()
@@ -283,8 +249,8 @@ public class RipeMD128 extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf
- (DIGEST0.equals(Util.toString(new RipeMD128().digest())));
+ String d = Util.toString(new RipeMD128().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/java/security/hash/RipeMD160.java b/libjava/classpath/gnu/java/security/hash/RipeMD160.java
index 642ffb32de6..7949bc2547c 100644
--- a/libjava/classpath/gnu/java/security/hash/RipeMD160.java
+++ b/libjava/classpath/gnu/java/security/hash/RipeMD160.java
@@ -42,59 +42,51 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>RIPEMD-160 is a 160-bit message digest.</p>
- *
- * <p>References:</p>
- *
+ * RIPEMD-160 is a 160-bit message digest.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html">
* RIPEMD160</a>: A Strengthened Version of RIPEMD.<br>
* Hans Dobbertin, Antoon Bosselaers and Bart Preneel.</li>
* </ol>
*/
-public class RipeMD160 extends BaseHash
+public class RipeMD160
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int BLOCK_SIZE = 64; // inner block size in bytes
private static final String DIGEST0 = "9C1185A5C5E9FC54612808977EE8F548B2258D31";
// selection of message word
- private static final int[] R = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0,
- 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8,
- 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10,
- 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0,
- 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15,
- 13 };
-
- private static final int[] Rp = { 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1,
- 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14,
- 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14,
- 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4,
- 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0,
- 3, 9, 11 };
+ private static final int[] R = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 };
+
+ private static final int[] Rp = {
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 };
// amount for rotate left (rol)
- private static final int[] S = { 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15,
- 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12,
- 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9,
- 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12,
- 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5,
- 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13,
- 14, 11, 8, 5, 6 };
-
- private static final int[] Sp = { 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11,
- 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11,
- 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8,
- 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15,
- 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5,
- 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6,
- 5, 15, 13, 11, 11 };
+ private static final int[] S = {
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 };
+
+ private static final int[] Sp = {
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 };
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
@@ -105,9 +97,6 @@ public class RipeMD160 extends BaseHash
/** 512 bits work buffer = 16 x 32-bit words */
private int[] X = new int[16];
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public RipeMD160()
{
@@ -115,7 +104,7 @@ public class RipeMD160 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -132,40 +121,27 @@ public class RipeMD160 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return (new RipeMD160(this));
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
int A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, T, s, i;
-
// encode 64 bytes from input block into an array of 16 unsigned integers
for (i = 0; i < 16; i++)
- {
- X[i] = (in[offset++] & 0xFF) | (in[offset++] & 0xFF) << 8
- | (in[offset++] & 0xFF) << 16 | in[offset++] << 24;
- }
-
+ X[i] = (in[offset++] & 0xFF)
+ | (in[offset++] & 0xFF) << 8
+ | (in[offset++] & 0xFF) << 16
+ | in[offset++] << 24;
A = Ap = h0;
B = Bp = h1;
C = Cp = h2;
D = Dp = h3;
E = Ep = h4;
-
- for (i = 0; i < 16; i++)
- { // rounds 0...15
+ for (i = 0; i < 16; i++) // rounds 0...15
+ {
s = S[i];
T = A + (B ^ C ^ D) + X[i];
A = E;
@@ -182,9 +158,8 @@ public class RipeMD160 extends BaseHash
Cp = Bp;
Bp = (T << s | T >>> (32 - s)) + Ap;
}
-
- for (; i < 32; i++)
- { // rounds 16...31
+ for (; i < 32; i++) // rounds 16...31
+ {
s = S[i];
T = A + ((B & C) | (~B & D)) + X[R[i]] + 0x5A827999;
A = E;
@@ -201,9 +176,8 @@ public class RipeMD160 extends BaseHash
Cp = Bp;
Bp = (T << s | T >>> (32 - s)) + Ap;
}
-
- for (; i < 48; i++)
- { // rounds 32...47
+ for (; i < 48; i++) // rounds 32...47
+ {
s = S[i];
T = A + ((B | ~C) ^ D) + X[R[i]] + 0x6ED9EBA1;
A = E;
@@ -220,9 +194,8 @@ public class RipeMD160 extends BaseHash
Cp = Bp;
Bp = (T << s | T >>> (32 - s)) + Ap;
}
-
- for (; i < 64; i++)
- { // rounds 48...63
+ for (; i < 64; i++) // rounds 48...63
+ {
s = S[i];
T = A + ((B & D) | (C & ~D)) + X[R[i]] + 0x8F1BBCDC;
A = E;
@@ -239,9 +212,8 @@ public class RipeMD160 extends BaseHash
Cp = Bp;
Bp = (T << s | T >>> (32 - s)) + Ap;
}
-
- for (; i < 80; i++)
- { // rounds 64...79
+ for (; i < 80; i++) // rounds 64...79
+ {
s = S[i];
T = A + (B ^ (C | ~D)) + X[R[i]] + 0xA953FD4E;
A = E;
@@ -258,7 +230,6 @@ public class RipeMD160 extends BaseHash
Cp = Bp;
Bp = (T << s | T >>> (32 - s)) + Ap;
}
-
T = h1 + C + Dp;
h1 = h2 + D + Ep;
h2 = h3 + E + Ap;
@@ -269,41 +240,33 @@ public class RipeMD160 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] result = new byte[padding + 8];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
result[padding++] = (byte) bits;
- result[padding++] = (byte) (bits >>> 8);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 48);
- result[padding] = (byte) (bits >>> 56);
-
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding ] = (byte)(bits >>> 56);
return result;
}
protected byte[] getResult()
{
- byte[] result = new byte[] { (byte) h0, (byte) (h0 >>> 8),
- (byte) (h0 >>> 16), (byte) (h0 >>> 24),
- (byte) h1, (byte) (h1 >>> 8),
- (byte) (h1 >>> 16), (byte) (h1 >>> 24),
- (byte) h2, (byte) (h2 >>> 8),
- (byte) (h2 >>> 16), (byte) (h2 >>> 24),
- (byte) h3, (byte) (h3 >>> 8),
- (byte) (h3 >>> 16), (byte) (h3 >>> 24),
- (byte) h4, (byte) (h4 >>> 8),
- (byte) (h4 >>> 16), (byte) (h4 >>> 24) };
-
- return result;
+ return new byte[] {
+ (byte) h0, (byte)(h0 >>> 8), (byte)(h0 >>> 16), (byte)(h0 >>> 24),
+ (byte) h1, (byte)(h1 >>> 8), (byte)(h1 >>> 16), (byte)(h1 >>> 24),
+ (byte) h2, (byte)(h2 >>> 8), (byte)(h2 >>> 16), (byte)(h2 >>> 24),
+ (byte) h3, (byte)(h3 >>> 8), (byte)(h3 >>> 16), (byte)(h3 >>> 24),
+ (byte) h4, (byte)(h4 >>> 8), (byte)(h4 >>> 16), (byte)(h4 >>> 24)
+ };
}
protected void resetContext()
@@ -320,8 +283,8 @@ public class RipeMD160 extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf
- (DIGEST0.equals(Util.toString(new RipeMD160().digest())));
+ String d = Util.toString(new RipeMD160().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/java/security/hash/Sha160.java b/libjava/classpath/gnu/java/security/hash/Sha160.java
index 037b118e601..6adeba07079 100644
--- a/libjava/classpath/gnu/java/security/hash/Sha160.java
+++ b/libjava/classpath/gnu/java/security/hash/Sha160.java
@@ -42,7 +42,7 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>The Secure Hash Algorithm (SHA-1) is required for use with the Digital
+ * The Secure Hash Algorithm (SHA-1) is required for use with the Digital
* Signature Algorithm (DSA) as specified in the Digital Signature Standard
* (DSS) and whenever a secure hash algorithm is required for federal
* applications. For a message of length less than 2^64 bits, the SHA-1
@@ -51,15 +51,14 @@ import gnu.java.security.util.Util;
* message. The SHA-1 is also used to compute a message digest for the received
* version of the message during the process of verifying the signature. Any
* change to the message in transit will, with very high probability, result in
- * a different message digest, and the signature will fail to verify.</p>
- *
- * <p>The SHA-1 is designed to have the following properties: it is
+ * a different message digest, and the signature will fail to verify.
+ * <p>
+ * The SHA-1 is designed to have the following properties: it is
* computationally infeasible to find a message which corresponds to a given
* message digest, or to find two different messages which produce the same
- * message digest.</p>
- *
- * <p>References:</p>
- *
+ * message digest.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.itl.nist.gov/fipspubs/fip180-1.htm">SECURE HASH
* STANDARD</a><br>
@@ -67,12 +66,9 @@ import gnu.java.security.util.Util;
* </li>
* </ol>
*/
-public class Sha160 extends BaseHash
+public class Sha160
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int BLOCK_SIZE = 64; // inner block size in bytes
private static final String DIGEST0 = "A9993E364706816ABA3E25717850C26C9CD0D89D";
@@ -85,9 +81,6 @@ public class Sha160 extends BaseHash
/** 160-bit interim result. */
private int h0, h1, h2, h3, h4;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Sha160()
{
@@ -95,7 +88,7 @@ public class Sha160 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -112,58 +105,20 @@ public class Sha160 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final int[] G(int hh0, int hh1, int hh2, int hh3, int hh4,
byte[] in, int offset)
{
- // int[] w = new int[80];
- // int i, T;
- // for (i = 0; i < 16; i++) {
- // w[i] = in[offset++] << 24 |
- // (in[offset++] & 0xFF) << 16 |
- // (in[offset++] & 0xFF) << 8 |
- // (in[offset++] & 0xFF);
- // }
- // for (i = 16; i < 80; i++) {
- // T = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16];
- // w[i] = T << 1 | T >>> 31;
- // }
-
- // return sha(hh0, hh1, hh2, hh3, hh4, in, offset, w);
return sha(hh0, hh1, hh2, hh3, hh4, in, offset);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new Sha160(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
- // int i, T;
- // for (i = 0; i < 16; i++) {
- // W[i] = in[offset++] << 24 |
- // (in[offset++] & 0xFF) << 16 |
- // (in[offset++] & 0xFF) << 8 |
- // (in[offset++] & 0xFF);
- // }
- // for (i = 16; i < 80; i++) {
- // T = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16];
- // W[i] = T << 1 | T >>> 31;
- // }
-
- // int[] result = sha(h0, h1, h2, h3, h4, in, offset, W);
int[] result = sha(h0, h1, h2, h3, h4, in, offset);
-
h0 = result[0];
h1 = result[1];
h2 = result[2];
@@ -173,41 +128,32 @@ public class Sha160 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] result = new byte[padding + 8];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
- result[padding++] = (byte) (bits >>> 56);
- result[padding++] = (byte) (bits >>> 48);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 8);
- result[padding] = (byte) bits;
-
+ result[padding++] = (byte)(bits >>> 56);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding ] = (byte) bits;
return result;
}
protected byte[] getResult()
{
- byte[] result = new byte[] { (byte) (h0 >>> 24), (byte) (h0 >>> 16),
- (byte) (h0 >>> 8), (byte) h0,
- (byte) (h1 >>> 24), (byte) (h1 >>> 16),
- (byte) (h1 >>> 8), (byte) h1,
- (byte) (h2 >>> 24), (byte) (h2 >>> 16),
- (byte) (h2 >>> 8), (byte) h2,
- (byte) (h3 >>> 24), (byte) (h3 >>> 16),
- (byte) (h3 >>> 8), (byte) h3,
- (byte) (h4 >>> 24), (byte) (h4 >>> 16),
- (byte) (h4 >>> 8), (byte) h4 };
-
- return result;
+ return new byte[] {
+ (byte)(h0 >>> 24), (byte)(h0 >>> 16), (byte)(h0 >>> 8), (byte) h0,
+ (byte)(h1 >>> 24), (byte)(h1 >>> 16), (byte)(h1 >>> 8), (byte) h1,
+ (byte)(h2 >>> 24), (byte)(h2 >>> 16), (byte)(h2 >>> 8), (byte) h2,
+ (byte)(h3 >>> 24), (byte)(h3 >>> 16), (byte)(h3 >>> 8), (byte) h3,
+ (byte)(h4 >>> 24), (byte)(h4 >>> 16), (byte)(h4 >>> 8), (byte) h4 };
}
protected void resetContext()
@@ -234,11 +180,9 @@ public class Sha160 extends BaseHash
return valid.booleanValue();
}
- // SHA specific methods ----------------------------------------------------
-
- private static final synchronized int[]
- // sha(int hh0, int hh1, int hh2, int hh3, int hh4, byte[] in, int offset, int[] w) {
- sha(int hh0, int hh1, int hh2, int hh3, int hh4, byte[] in, int offset)
+ private static synchronized final int[] sha(int hh0, int hh1, int hh2,
+ int hh3, int hh4, byte[] in,
+ int offset)
{
int A = hh0;
int B = hh1;
@@ -246,20 +190,17 @@ public class Sha160 extends BaseHash
int D = hh3;
int E = hh4;
int r, T;
-
for (r = 0; r < 16; r++)
- {
- w[r] = in[offset++] << 24 | (in[offset++] & 0xFF) << 16
- | (in[offset++] & 0xFF) << 8 | (in[offset++] & 0xFF);
- }
+ w[r] = in[offset++] << 24
+ | (in[offset++] & 0xFF) << 16
+ | (in[offset++] & 0xFF) << 8
+ | (in[offset++] & 0xFF);
for (r = 16; r < 80; r++)
{
T = w[r - 3] ^ w[r - 8] ^ w[r - 14] ^ w[r - 16];
w[r] = T << 1 | T >>> 31;
}
-
- // rounds 0-19
- for (r = 0; r < 20; r++)
+ for (r = 0; r < 20; r++) // rounds 0-19
{
T = (A << 5 | A >>> 27) + ((B & C) | (~B & D)) + E + w[r] + 0x5A827999;
E = D;
@@ -268,9 +209,7 @@ public class Sha160 extends BaseHash
B = A;
A = T;
}
-
- // rounds 20-39
- for (r = 20; r < 40; r++)
+ for (r = 20; r < 40; r++) // rounds 20-39
{
T = (A << 5 | A >>> 27) + (B ^ C ^ D) + E + w[r] + 0x6ED9EBA1;
E = D;
@@ -279,21 +218,16 @@ public class Sha160 extends BaseHash
B = A;
A = T;
}
-
- // rounds 40-59
- for (r = 40; r < 60; r++)
+ for (r = 40; r < 60; r++) // rounds 40-59
{
- T = (A << 5 | A >>> 27) + (B & C | B & D | C & D) + E + w[r]
- + 0x8F1BBCDC;
+ T = (A << 5 | A >>> 27) + (B & C | B & D | C & D) + E + w[r] + 0x8F1BBCDC;
E = D;
D = C;
C = B << 30 | B >>> 2;
B = A;
A = T;
}
-
- // rounds 60-79
- for (r = 60; r < 80; r++)
+ for (r = 60; r < 80; r++) // rounds 60-79
{
T = (A << 5 | A >>> 27) + (B ^ C ^ D) + E + w[r] + 0xCA62C1D6;
E = D;
@@ -302,7 +236,6 @@ public class Sha160 extends BaseHash
B = A;
A = T;
}
-
return new int[] { hh0 + A, hh1 + B, hh2 + C, hh3 + D, hh4 + E };
}
}
diff --git a/libjava/classpath/gnu/java/security/hash/Sha256.java b/libjava/classpath/gnu/java/security/hash/Sha256.java
index 284425ea43a..536b1c8bab3 100644
--- a/libjava/classpath/gnu/java/security/hash/Sha256.java
+++ b/libjava/classpath/gnu/java/security/hash/Sha256.java
@@ -42,46 +42,41 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>Implementation of SHA2-1 [SHA-256] per the IETF Draft Specification.</p>
- *
- * <p>References:</p>
+ * Implementation of SHA2-1 [SHA-256] per the IETF Draft Specification.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://ftp.ipv4.heanet.ie/pub/ietf/internet-drafts/draft-ietf-ipsec-ciph-aes-cbc-03.txt">
* Descriptions of SHA-256, SHA-384, and SHA-512</a>,</li>
* <li>http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf</li>
* </ol>
*/
-public class Sha256 extends BaseHash
+public class Sha256
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
- private static final int[] k = { 0x428a2f98, 0x71374491, 0xb5c0fbcf,
- 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
- 0x923f82a4, 0xab1c5ed5, 0xd807aa98,
- 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
- 0xc19bf174, 0xe49b69c1, 0xefbe4786,
- 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f,
- 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8,
- 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
- 0x06ca6351, 0x14292967, 0x27b70a85,
- 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e,
- 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
- 0xc24b8b70, 0xc76c51a3, 0xd192e819,
- 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c,
- 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
- 0x5b9cca4f, 0x682e6ff3, 0x748f82ee,
- 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7,
- 0xc67178f2 };
+ private static final int[] k = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
private static final int BLOCK_SIZE = 64; // inner block size in bytes
- private static final String DIGEST0 = "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD";
+ private static final String DIGEST0 =
+ "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD";
private static final int[] w = new int[64];
@@ -91,9 +86,6 @@ public class Sha256 extends BaseHash
/** 256-bit interim result. */
private int h0, h1, h2, h3, h4, h5, h6, h7;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Sha256()
{
@@ -101,7 +93,7 @@ public class Sha256 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -121,31 +113,20 @@ public class Sha256 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final int[] G(int hh0, int hh1, int hh2, int hh3, int hh4,
int hh5, int hh6, int hh7, byte[] in, int offset)
{
return sha(hh0, hh1, hh2, hh3, hh4, hh5, hh6, hh7, in, offset);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new Sha256(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
int[] result = sha(h0, h1, h2, h3, h4, h5, h6, h7, in, offset);
-
h0 = result[0];
h1 = result[1];
h2 = result[2];
@@ -158,41 +139,35 @@ public class Sha256 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] result = new byte[padding + 8];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
long bits = count << 3;
- result[padding++] = (byte) (bits >>> 56);
- result[padding++] = (byte) (bits >>> 48);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 8);
- result[padding] = (byte) bits;
-
+ result[padding++] = (byte)(bits >>> 56);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding ] = (byte) bits;
return result;
}
protected byte[] getResult()
{
- return new byte[] { (byte) (h0 >>> 24), (byte) (h0 >>> 16),
- (byte) (h0 >>> 8), (byte) h0, (byte) (h1 >>> 24),
- (byte) (h1 >>> 16), (byte) (h1 >>> 8), (byte) h1,
- (byte) (h2 >>> 24), (byte) (h2 >>> 16),
- (byte) (h2 >>> 8), (byte) h2, (byte) (h3 >>> 24),
- (byte) (h3 >>> 16), (byte) (h3 >>> 8), (byte) h3,
- (byte) (h4 >>> 24), (byte) (h4 >>> 16),
- (byte) (h4 >>> 8), (byte) h4, (byte) (h5 >>> 24),
- (byte) (h5 >>> 16), (byte) (h5 >>> 8), (byte) h5,
- (byte) (h6 >>> 24), (byte) (h6 >>> 16),
- (byte) (h6 >>> 8), (byte) h6, (byte) (h7 >>> 24),
- (byte) (h7 >>> 16), (byte) (h7 >>> 8), (byte) h7 };
+ return new byte[] {
+ (byte)(h0 >>> 24), (byte)(h0 >>> 16), (byte)(h0 >>> 8), (byte) h0,
+ (byte)(h1 >>> 24), (byte)(h1 >>> 16), (byte)(h1 >>> 8), (byte) h1,
+ (byte)(h2 >>> 24), (byte)(h2 >>> 16), (byte)(h2 >>> 8), (byte) h2,
+ (byte)(h3 >>> 24), (byte)(h3 >>> 16), (byte)(h3 >>> 8), (byte) h3,
+ (byte)(h4 >>> 24), (byte)(h4 >>> 16), (byte)(h4 >>> 8), (byte) h4,
+ (byte)(h5 >>> 24), (byte)(h5 >>> 16), (byte)(h5 >>> 8), (byte) h5,
+ (byte)(h6 >>> 24), (byte)(h6 >>> 16), (byte)(h6 >>> 8), (byte) h6,
+ (byte)(h7 >>> 24), (byte)(h7 >>> 16), (byte)(h7 >>> 8), (byte) h7 };
}
protected void resetContext()
@@ -219,13 +194,10 @@ public class Sha256 extends BaseHash
String result = Util.toString(md.digest());
valid = Boolean.valueOf(DIGEST0.equals(result));
}
-
return valid.booleanValue();
}
- // SHA specific methods ----------------------------------------------------
-
- private static final synchronized int[] sha(int hh0, int hh1, int hh2,
+ private static synchronized final int[] sha(int hh0, int hh1, int hh2,
int hh3, int hh4, int hh5,
int hh6, int hh7, byte[] in,
int offset)
@@ -239,29 +211,31 @@ public class Sha256 extends BaseHash
int G = hh6;
int H = hh7;
int r, T, T2;
-
for (r = 0; r < 16; r++)
- {
- w[r] = (in[offset++] << 24 | (in[offset++] & 0xFF) << 16
- | (in[offset++] & 0xFF) << 8 | (in[offset++] & 0xFF));
- }
+ w[r] = (in[offset++] << 24
+ | (in[offset++] & 0xFF) << 16
+ | (in[offset++] & 0xFF) << 8
+ | (in[offset++] & 0xFF));
for (r = 16; r < 64; r++)
{
- T = w[r - 2];
+ T = w[r - 2];
T2 = w[r - 15];
w[r] = ((((T >>> 17) | (T << 15)) ^ ((T >>> 19) | (T << 13)) ^ (T >>> 10))
+ w[r - 7]
- + (((T2 >>> 7) | (T2 << 25)) ^ ((T2 >>> 18) | (T2 << 14)) ^ (T2 >>> 3))
- + w[r - 16]);
+ + (((T2 >>> 7) | (T2 << 25))
+ ^ ((T2 >>> 18) | (T2 << 14))
+ ^ (T2 >>> 3)) + w[r - 16]);
}
-
for (r = 0; r < 64; r++)
{
T = (H
- + (((E >>> 6) | (E << 26)) ^ ((E >>> 11) | (E << 21)) ^ ((E >>> 25) | (E << 7)))
+ + (((E >>> 6) | (E << 26))
+ ^ ((E >>> 11) | (E << 21))
+ ^ ((E >>> 25) | (E << 7)))
+ ((E & F) ^ (~E & G)) + k[r] + w[r]);
- T2 = ((((A >>> 2) | (A << 30)) ^ ((A >>> 13) | (A << 19)) ^ ((A >>> 22) | (A << 10)))
- + ((A & B) ^ (A & C) ^ (B & C)));
+ T2 = ((((A >>> 2) | (A << 30))
+ ^ ((A >>> 13) | (A << 19))
+ ^ ((A >>> 22) | (A << 10))) + ((A & B) ^ (A & C) ^ (B & C)));
H = G;
G = F;
F = E;
@@ -271,8 +245,8 @@ public class Sha256 extends BaseHash
B = A;
A = T + T2;
}
-
- return new int[] { hh0 + A, hh1 + B, hh2 + C, hh3 + D, hh4 + E, hh5 + F,
- hh6 + G, hh7 + H };
+ return new int[] {
+ hh0 + A, hh1 + B, hh2 + C, hh3 + D,
+ hh4 + E, hh5 + F, hh6 + G, hh7 + H };
}
}
diff --git a/libjava/classpath/gnu/java/security/hash/Sha384.java b/libjava/classpath/gnu/java/security/hash/Sha384.java
index 332f048d782..a47eb67db95 100644
--- a/libjava/classpath/gnu/java/security/hash/Sha384.java
+++ b/libjava/classpath/gnu/java/security/hash/Sha384.java
@@ -42,66 +42,52 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>Implementation of SHA2-2 [SHA-384] per the IETF Draft Specification.</p>
- *
- * <p>References:</p>
+ * Implementation of SHA2-2 [SHA-384] per the IETF Draft Specification.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://ftp.ipv4.heanet.ie/pub/ietf/internet-drafts/draft-ietf-ipsec-ciph-aes-cbc-03.txt">
* Descriptions of SHA-256, SHA-384, and SHA-512</a>,</li>
* <li>http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf</li>
* </ol>
*/
-public class Sha384 extends BaseHash
+public class Sha384
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final long[] k = { 0x428a2f98d728ae22L, 0x7137449123ef65cdL,
- 0xb5c0fbcfec4d3b2fL, 0xe9b5dba58189dbbcL,
- 0x3956c25bf348b538L, 0x59f111f1b605d019L,
- 0x923f82a4af194f9bL, 0xab1c5ed5da6d8118L,
- 0xd807aa98a3030242L, 0x12835b0145706fbeL,
- 0x243185be4ee4b28cL, 0x550c7dc3d5ffb4e2L,
- 0x72be5d74f27b896fL, 0x80deb1fe3b1696b1L,
- 0x9bdc06a725c71235L, 0xc19bf174cf692694L,
- 0xe49b69c19ef14ad2L, 0xefbe4786384f25e3L,
- 0x0fc19dc68b8cd5b5L, 0x240ca1cc77ac9c65L,
- 0x2de92c6f592b0275L, 0x4a7484aa6ea6e483L,
- 0x5cb0a9dcbd41fbd4L, 0x76f988da831153b5L,
- 0x983e5152ee66dfabL, 0xa831c66d2db43210L,
- 0xb00327c898fb213fL, 0xbf597fc7beef0ee4L,
- 0xc6e00bf33da88fc2L, 0xd5a79147930aa725L,
- 0x06ca6351e003826fL, 0x142929670a0e6e70L,
- 0x27b70a8546d22ffcL, 0x2e1b21385c26c926L,
- 0x4d2c6dfc5ac42aedL, 0x53380d139d95b3dfL,
- 0x650a73548baf63deL, 0x766a0abb3c77b2a8L,
- 0x81c2c92e47edaee6L, 0x92722c851482353bL,
- 0xa2bfe8a14cf10364L, 0xa81a664bbc423001L,
- 0xc24b8b70d0f89791L, 0xc76c51a30654be30L,
- 0xd192e819d6ef5218L, 0xd69906245565a910L,
- 0xf40e35855771202aL, 0x106aa07032bbd1b8L,
- 0x19a4c116b8d2d0c8L, 0x1e376c085141ab53L,
- 0x2748774cdf8eeb99L, 0x34b0bcb5e19b48a8L,
- 0x391c0cb3c5c95a63L, 0x4ed8aa4ae3418acbL,
- 0x5b9cca4f7763e373L, 0x682e6ff3d6b2b8a3L,
- 0x748f82ee5defb2fcL, 0x78a5636f43172f60L,
- 0x84c87814a1f0ab72L, 0x8cc702081a6439ecL,
- 0x90befffa23631e28L, 0xa4506cebde82bde9L,
- 0xbef9a3f7b2c67915L, 0xc67178f2e372532bL,
- 0xca273eceea26619cL, 0xd186b8c721c0c207L,
- 0xeada7dd6cde0eb1eL, 0xf57d4f7fee6ed178L,
- 0x06f067aa72176fbaL, 0x0a637dc5a2c898a6L,
- 0x113f9804bef90daeL, 0x1b710b35131c471bL,
- 0x28db77f523047d84L, 0x32caab7b40c72493L,
- 0x3c9ebe0a15c9bebcL, 0x431d67c49c100d4cL,
- 0x4cc5d4becb3e42b6L, 0x597f299cfc657e2aL,
- 0x5fcb6fab3ad6faecL, 0x6c44198c4a475817L };
+ private static final long[] k = {
+ 0x428a2f98d728ae22L, 0x7137449123ef65cdL, 0xb5c0fbcfec4d3b2fL,
+ 0xe9b5dba58189dbbcL, 0x3956c25bf348b538L, 0x59f111f1b605d019L,
+ 0x923f82a4af194f9bL, 0xab1c5ed5da6d8118L, 0xd807aa98a3030242L,
+ 0x12835b0145706fbeL, 0x243185be4ee4b28cL, 0x550c7dc3d5ffb4e2L,
+ 0x72be5d74f27b896fL, 0x80deb1fe3b1696b1L, 0x9bdc06a725c71235L,
+ 0xc19bf174cf692694L, 0xe49b69c19ef14ad2L, 0xefbe4786384f25e3L,
+ 0x0fc19dc68b8cd5b5L, 0x240ca1cc77ac9c65L, 0x2de92c6f592b0275L,
+ 0x4a7484aa6ea6e483L, 0x5cb0a9dcbd41fbd4L, 0x76f988da831153b5L,
+ 0x983e5152ee66dfabL, 0xa831c66d2db43210L, 0xb00327c898fb213fL,
+ 0xbf597fc7beef0ee4L, 0xc6e00bf33da88fc2L, 0xd5a79147930aa725L,
+ 0x06ca6351e003826fL, 0x142929670a0e6e70L, 0x27b70a8546d22ffcL,
+ 0x2e1b21385c26c926L, 0x4d2c6dfc5ac42aedL, 0x53380d139d95b3dfL,
+ 0x650a73548baf63deL, 0x766a0abb3c77b2a8L, 0x81c2c92e47edaee6L,
+ 0x92722c851482353bL, 0xa2bfe8a14cf10364L, 0xa81a664bbc423001L,
+ 0xc24b8b70d0f89791L, 0xc76c51a30654be30L, 0xd192e819d6ef5218L,
+ 0xd69906245565a910L, 0xf40e35855771202aL, 0x106aa07032bbd1b8L,
+ 0x19a4c116b8d2d0c8L, 0x1e376c085141ab53L, 0x2748774cdf8eeb99L,
+ 0x34b0bcb5e19b48a8L, 0x391c0cb3c5c95a63L, 0x4ed8aa4ae3418acbL,
+ 0x5b9cca4f7763e373L, 0x682e6ff3d6b2b8a3L, 0x748f82ee5defb2fcL,
+ 0x78a5636f43172f60L, 0x84c87814a1f0ab72L, 0x8cc702081a6439ecL,
+ 0x90befffa23631e28L, 0xa4506cebde82bde9L, 0xbef9a3f7b2c67915L,
+ 0xc67178f2e372532bL, 0xca273eceea26619cL, 0xd186b8c721c0c207L,
+ 0xeada7dd6cde0eb1eL, 0xf57d4f7fee6ed178L, 0x06f067aa72176fbaL,
+ 0x0a637dc5a2c898a6L, 0x113f9804bef90daeL, 0x1b710b35131c471bL,
+ 0x28db77f523047d84L, 0x32caab7b40c72493L, 0x3c9ebe0a15c9bebcL,
+ 0x431d67c49c100d4cL, 0x4cc5d4becb3e42b6L, 0x597f299cfc657e2aL,
+ 0x5fcb6fab3ad6faecL, 0x6c44198c4a475817L };
private static final int BLOCK_SIZE = 128; // inner block size in bytes
- private static final String DIGEST0 = "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED"
- + "8086072BA1E7CC2358BAECA134C825A7";
+ private static final String DIGEST0 =
+ "CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED"
+ + "8086072BA1E7CC2358BAECA134C825A7";
private static final long[] w = new long[80];
@@ -111,9 +97,6 @@ public class Sha384 extends BaseHash
/** 512-bit interim result. */
private long h0, h1, h2, h3, h4, h5, h6, h7;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Sha384()
{
@@ -121,7 +104,7 @@ public class Sha384 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -141,9 +124,6 @@ public class Sha384 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final long[] G(long hh0, long hh1, long hh2, long hh3,
long hh4, long hh5, long hh6, long hh7,
byte[] in, int offset)
@@ -151,22 +131,14 @@ public class Sha384 extends BaseHash
return sha(hh0, hh1, hh2, hh3, hh4, hh5, hh6, hh7, in, offset);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new Sha384(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
long[] result = sha(h0, h1, h2, h3, h4, h5, h6, h7, in, offset);
-
h0 = result[0];
h1 = result[1];
h2 = result[2];
@@ -179,57 +151,41 @@ public class Sha384 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 112) ? (112 - n) : (240 - n);
byte[] result = new byte[padding + 16];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
// TODO: FIX Only ~35 bits of 128 bit counter usable this way
long bits = count << 3;
padding += 8;
- result[padding++] = (byte) (bits >>> 56);
- result[padding++] = (byte) (bits >>> 48);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 8);
- result[padding] = (byte) bits;
-
+ result[padding++] = (byte)(bits >>> 56);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding ] = (byte) bits;
return result;
}
protected byte[] getResult()
{
- return new byte[] { (byte) (h0 >>> 56), (byte) (h0 >>> 48),
- (byte) (h0 >>> 40), (byte) (h0 >>> 32),
- (byte) (h0 >>> 24), (byte) (h0 >>> 16),
- (byte) (h0 >>> 8), (byte) h0, (byte) (h1 >>> 56),
- (byte) (h1 >>> 48), (byte) (h1 >>> 40),
- (byte) (h1 >>> 32), (byte) (h1 >>> 24),
- (byte) (h1 >>> 16), (byte) (h1 >>> 8), (byte) h1,
- (byte) (h2 >>> 56), (byte) (h2 >>> 48),
- (byte) (h2 >>> 40), (byte) (h2 >>> 32),
- (byte) (h2 >>> 24), (byte) (h2 >>> 16),
- (byte) (h2 >>> 8), (byte) h2, (byte) (h3 >>> 56),
- (byte) (h3 >>> 48), (byte) (h3 >>> 40),
- (byte) (h3 >>> 32), (byte) (h3 >>> 24),
- (byte) (h3 >>> 16), (byte) (h3 >>> 8), (byte) h3,
- (byte) (h4 >>> 56), (byte) (h4 >>> 48),
- (byte) (h4 >>> 40), (byte) (h4 >>> 32),
- (byte) (h4 >>> 24), (byte) (h4 >>> 16),
- (byte) (h4 >>> 8), (byte) h4, (byte) (h5 >>> 56),
- (byte) (h5 >>> 48), (byte) (h5 >>> 40),
- (byte) (h5 >>> 32), (byte) (h5 >>> 24),
- (byte) (h5 >>> 16), (byte) (h5 >>> 8), (byte) h5
- // (byte)(h6 >>> 56), (byte)(h6 >>> 48), (byte)(h6 >>> 40), (byte)(h6 >>> 32),
- // (byte)(h6 >>> 24), (byte)(h6 >>> 16), (byte)(h6 >>> 8), (byte) h6,
- // (byte)(h7 >>> 56), (byte)(h7 >>> 48), (byte)(h7 >>> 40), (byte)(h7 >>> 32),
- // (byte)(h7 >>> 24), (byte)(h7 >>> 16), (byte)(h7 >>> 8), (byte) h7
- };
+ return new byte[] {
+ (byte)(h0 >>> 56), (byte)(h0 >>> 48), (byte)(h0 >>> 40), (byte)(h0 >>> 32),
+ (byte)(h0 >>> 24), (byte)(h0 >>> 16), (byte)(h0 >>> 8), (byte) h0,
+ (byte)(h1 >>> 56), (byte)(h1 >>> 48), (byte)(h1 >>> 40), (byte)(h1 >>> 32),
+ (byte)(h1 >>> 24), (byte)(h1 >>> 16), (byte)(h1 >>> 8), (byte) h1,
+ (byte)(h2 >>> 56), (byte)(h2 >>> 48), (byte)(h2 >>> 40), (byte)(h2 >>> 32),
+ (byte)(h2 >>> 24), (byte)(h2 >>> 16), (byte)(h2 >>> 8), (byte) h2,
+ (byte)(h3 >>> 56), (byte)(h3 >>> 48), (byte)(h3 >>> 40), (byte)(h3 >>> 32),
+ (byte)(h3 >>> 24), (byte)(h3 >>> 16), (byte)(h3 >>> 8), (byte) h3,
+ (byte)(h4 >>> 56), (byte)(h4 >>> 48), (byte)(h4 >>> 40), (byte)(h4 >>> 32),
+ (byte)(h4 >>> 24), (byte)(h4 >>> 16), (byte)(h4 >>> 8), (byte) h4,
+ (byte)(h5 >>> 56), (byte)(h5 >>> 48), (byte)(h5 >>> 40), (byte)(h5 >>> 32),
+ (byte)(h5 >>> 24), (byte)(h5 >>> 16), (byte)(h5 >>> 8), (byte) h5 };
}
protected void resetContext()
@@ -259,9 +215,7 @@ public class Sha384 extends BaseHash
return valid.booleanValue();
}
- // SHA specific methods ----------------------------------------------------
-
- private static final synchronized long[] sha(long hh0, long hh1, long hh2,
+ private static synchronized final long[] sha(long hh0, long hh1, long hh2,
long hh3, long hh4, long hh5,
long hh6, long hh7, byte[] in,
int offset)
@@ -276,35 +230,38 @@ public class Sha384 extends BaseHash
long H = hh7;
long T, T2;
int r;
-
for (r = 0; r < 16; r++)
- {
- w[r] = (long) in[offset++] << 56 | ((long) in[offset++] & 0xFF) << 48
- | ((long) in[offset++] & 0xFF) << 40
- | ((long) in[offset++] & 0xFF) << 32
- | ((long) in[offset++] & 0xFF) << 24
- | ((long) in[offset++] & 0xFF) << 16
- | ((long) in[offset++] & 0xFF) << 8
- | ((long) in[offset++] & 0xFF);
- }
+ w[r] = (long) in[offset++] << 56
+ | ((long) in[offset++] & 0xFF) << 48
+ | ((long) in[offset++] & 0xFF) << 40
+ | ((long) in[offset++] & 0xFF) << 32
+ | ((long) in[offset++] & 0xFF) << 24
+ | ((long) in[offset++] & 0xFF) << 16
+ | ((long) in[offset++] & 0xFF) << 8
+ | ((long) in[offset++] & 0xFF);
for (r = 16; r < 80; r++)
{
T = w[r - 2];
T2 = w[r - 15];
w[r] = (((T >>> 19) | (T << 45)) ^ ((T >>> 61) | (T << 3)) ^ (T >>> 6))
+ w[r - 7]
- + (((T2 >>> 1) | (T2 << 63)) ^ ((T2 >>> 8) | (T2 << 56)) ^ (T2 >>> 7))
+ + (((T2 >>> 1) | (T2 << 63))
+ ^ ((T2 >>> 8) | (T2 << 56))
+ ^ (T2 >>> 7))
+ w[r - 16];
}
-
for (r = 0; r < 80; r++)
{
T = H
- + (((E >>> 14) | (E << 50)) ^ ((E >>> 18) | (E << 46)) ^ ((E >>> 41) | (E << 23)))
+ + (((E >>> 14) | (E << 50))
+ ^ ((E >>> 18) | (E << 46))
+ ^ ((E >>> 41) | (E << 23)))
+ ((E & F) ^ ((~E) & G)) + k[r] + w[r];
// T IS INCORRECT SOMEHOW
- T2 = (((A >>> 28) | (A << 36)) ^ ((A >>> 34) | (A << 30)) ^ ((A >>> 39) | (A << 25)))
+ T2 = (((A >>> 28) | (A << 36))
+ ^ ((A >>> 34) | (A << 30))
+ ^ ((A >>> 39) | (A << 25)))
+ ((A & B) ^ (A & C) ^ (B & C));
H = G;
G = F;
@@ -315,8 +272,8 @@ public class Sha384 extends BaseHash
B = A;
A = T + T2;
}
-
- return new long[] { hh0 + A, hh1 + B, hh2 + C, hh3 + D, hh4 + E, hh5 + F,
- hh6 + G, hh7 + H };
+ return new long[] {
+ hh0 + A, hh1 + B, hh2 + C, hh3 + D,
+ hh4 + E, hh5 + F, hh6 + G, hh7 + H };
}
}
diff --git a/libjava/classpath/gnu/java/security/hash/Sha512.java b/libjava/classpath/gnu/java/security/hash/Sha512.java
index da035dcfc2d..e6f553ed40a 100644
--- a/libjava/classpath/gnu/java/security/hash/Sha512.java
+++ b/libjava/classpath/gnu/java/security/hash/Sha512.java
@@ -42,66 +42,52 @@ import gnu.java.security.Registry;
import gnu.java.security.util.Util;
/**
- * <p>Implementation of SHA2-3 [SHA-512] per the IETF Draft Specification.</p>
- *
- * <p>References:</p>
+ * Implementation of SHA2-3 [SHA-512] per the IETF Draft Specification.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://ftp.ipv4.heanet.ie/pub/ietf/internet-drafts/draft-ietf-ipsec-ciph-aes-cbc-03.txt">
* Descriptions of SHA-256, SHA-384, and SHA-512</a>,</li>
* <li>http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf</li>
* </ol>
*/
-public class Sha512 extends BaseHash
+public class Sha512
+ extends BaseHash
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final long[] k = { 0x428a2f98d728ae22L, 0x7137449123ef65cdL,
- 0xb5c0fbcfec4d3b2fL, 0xe9b5dba58189dbbcL,
- 0x3956c25bf348b538L, 0x59f111f1b605d019L,
- 0x923f82a4af194f9bL, 0xab1c5ed5da6d8118L,
- 0xd807aa98a3030242L, 0x12835b0145706fbeL,
- 0x243185be4ee4b28cL, 0x550c7dc3d5ffb4e2L,
- 0x72be5d74f27b896fL, 0x80deb1fe3b1696b1L,
- 0x9bdc06a725c71235L, 0xc19bf174cf692694L,
- 0xe49b69c19ef14ad2L, 0xefbe4786384f25e3L,
- 0x0fc19dc68b8cd5b5L, 0x240ca1cc77ac9c65L,
- 0x2de92c6f592b0275L, 0x4a7484aa6ea6e483L,
- 0x5cb0a9dcbd41fbd4L, 0x76f988da831153b5L,
- 0x983e5152ee66dfabL, 0xa831c66d2db43210L,
- 0xb00327c898fb213fL, 0xbf597fc7beef0ee4L,
- 0xc6e00bf33da88fc2L, 0xd5a79147930aa725L,
- 0x06ca6351e003826fL, 0x142929670a0e6e70L,
- 0x27b70a8546d22ffcL, 0x2e1b21385c26c926L,
- 0x4d2c6dfc5ac42aedL, 0x53380d139d95b3dfL,
- 0x650a73548baf63deL, 0x766a0abb3c77b2a8L,
- 0x81c2c92e47edaee6L, 0x92722c851482353bL,
- 0xa2bfe8a14cf10364L, 0xa81a664bbc423001L,
- 0xc24b8b70d0f89791L, 0xc76c51a30654be30L,
- 0xd192e819d6ef5218L, 0xd69906245565a910L,
- 0xf40e35855771202aL, 0x106aa07032bbd1b8L,
- 0x19a4c116b8d2d0c8L, 0x1e376c085141ab53L,
- 0x2748774cdf8eeb99L, 0x34b0bcb5e19b48a8L,
- 0x391c0cb3c5c95a63L, 0x4ed8aa4ae3418acbL,
- 0x5b9cca4f7763e373L, 0x682e6ff3d6b2b8a3L,
- 0x748f82ee5defb2fcL, 0x78a5636f43172f60L,
- 0x84c87814a1f0ab72L, 0x8cc702081a6439ecL,
- 0x90befffa23631e28L, 0xa4506cebde82bde9L,
- 0xbef9a3f7b2c67915L, 0xc67178f2e372532bL,
- 0xca273eceea26619cL, 0xd186b8c721c0c207L,
- 0xeada7dd6cde0eb1eL, 0xf57d4f7fee6ed178L,
- 0x06f067aa72176fbaL, 0x0a637dc5a2c898a6L,
- 0x113f9804bef90daeL, 0x1b710b35131c471bL,
- 0x28db77f523047d84L, 0x32caab7b40c72493L,
- 0x3c9ebe0a15c9bebcL, 0x431d67c49c100d4cL,
- 0x4cc5d4becb3e42b6L, 0x597f299cfc657e2aL,
- 0x5fcb6fab3ad6faecL, 0x6c44198c4a475817L };
+ private static final long[] k = {
+ 0x428a2f98d728ae22L, 0x7137449123ef65cdL, 0xb5c0fbcfec4d3b2fL,
+ 0xe9b5dba58189dbbcL, 0x3956c25bf348b538L, 0x59f111f1b605d019L,
+ 0x923f82a4af194f9bL, 0xab1c5ed5da6d8118L, 0xd807aa98a3030242L,
+ 0x12835b0145706fbeL, 0x243185be4ee4b28cL, 0x550c7dc3d5ffb4e2L,
+ 0x72be5d74f27b896fL, 0x80deb1fe3b1696b1L, 0x9bdc06a725c71235L,
+ 0xc19bf174cf692694L, 0xe49b69c19ef14ad2L, 0xefbe4786384f25e3L,
+ 0x0fc19dc68b8cd5b5L, 0x240ca1cc77ac9c65L, 0x2de92c6f592b0275L,
+ 0x4a7484aa6ea6e483L, 0x5cb0a9dcbd41fbd4L, 0x76f988da831153b5L,
+ 0x983e5152ee66dfabL, 0xa831c66d2db43210L, 0xb00327c898fb213fL,
+ 0xbf597fc7beef0ee4L, 0xc6e00bf33da88fc2L, 0xd5a79147930aa725L,
+ 0x06ca6351e003826fL, 0x142929670a0e6e70L, 0x27b70a8546d22ffcL,
+ 0x2e1b21385c26c926L, 0x4d2c6dfc5ac42aedL, 0x53380d139d95b3dfL,
+ 0x650a73548baf63deL, 0x766a0abb3c77b2a8L, 0x81c2c92e47edaee6L,
+ 0x92722c851482353bL, 0xa2bfe8a14cf10364L, 0xa81a664bbc423001L,
+ 0xc24b8b70d0f89791L, 0xc76c51a30654be30L, 0xd192e819d6ef5218L,
+ 0xd69906245565a910L, 0xf40e35855771202aL, 0x106aa07032bbd1b8L,
+ 0x19a4c116b8d2d0c8L, 0x1e376c085141ab53L, 0x2748774cdf8eeb99L,
+ 0x34b0bcb5e19b48a8L, 0x391c0cb3c5c95a63L, 0x4ed8aa4ae3418acbL,
+ 0x5b9cca4f7763e373L, 0x682e6ff3d6b2b8a3L, 0x748f82ee5defb2fcL,
+ 0x78a5636f43172f60L, 0x84c87814a1f0ab72L, 0x8cc702081a6439ecL,
+ 0x90befffa23631e28L, 0xa4506cebde82bde9L, 0xbef9a3f7b2c67915L,
+ 0xc67178f2e372532bL, 0xca273eceea26619cL, 0xd186b8c721c0c207L,
+ 0xeada7dd6cde0eb1eL, 0xf57d4f7fee6ed178L, 0x06f067aa72176fbaL,
+ 0x0a637dc5a2c898a6L, 0x113f9804bef90daeL, 0x1b710b35131c471bL,
+ 0x28db77f523047d84L, 0x32caab7b40c72493L, 0x3c9ebe0a15c9bebcL,
+ 0x431d67c49c100d4cL, 0x4cc5d4becb3e42b6L, 0x597f299cfc657e2aL,
+ 0x5fcb6fab3ad6faecL, 0x6c44198c4a475817L };
private static final int BLOCK_SIZE = 128; // inner block size in bytes
- private static final String DIGEST0 = "DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A"
- + "2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F";
+ private static final String DIGEST0 =
+ "DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A"
+ + "2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F";
private static final long[] w = new long[80];
@@ -111,9 +97,6 @@ public class Sha512 extends BaseHash
/** 512-bit interim result. */
private long h0, h1, h2, h3, h4, h5, h6, h7;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Sha512()
{
@@ -121,7 +104,7 @@ public class Sha512 extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -141,9 +124,6 @@ public class Sha512 extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final long[] G(long hh0, long hh1, long hh2, long hh3,
long hh4, long hh5, long hh6, long hh7,
byte[] in, int offset)
@@ -151,22 +131,14 @@ public class Sha512 extends BaseHash
return sha(hh0, hh1, hh2, hh3, hh4, hh5, hh6, hh7, in, offset);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new Sha512(this);
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
long[] result = sha(h0, h1, h2, h3, h4, h5, h6, h7, in, offset);
-
h0 = result[0];
h1 = result[1];
h2 = result[2];
@@ -179,59 +151,45 @@ public class Sha512 extends BaseHash
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 112) ? (112 - n) : (240 - n);
byte[] result = new byte[padding + 16];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save number of bits, casting the long to an array of 8 bytes
// TODO: FIX Only ~35 bits of 128 bit counter usable this way
long bits = count << 3;
padding += 8;
- result[padding++] = (byte) (bits >>> 56);
- result[padding++] = (byte) (bits >>> 48);
- result[padding++] = (byte) (bits >>> 40);
- result[padding++] = (byte) (bits >>> 32);
- result[padding++] = (byte) (bits >>> 24);
- result[padding++] = (byte) (bits >>> 16);
- result[padding++] = (byte) (bits >>> 8);
- result[padding] = (byte) bits;
-
+ result[padding++] = (byte)(bits >>> 56);
+ result[padding++] = (byte)(bits >>> 48);
+ result[padding++] = (byte)(bits >>> 40);
+ result[padding++] = (byte)(bits >>> 32);
+ result[padding++] = (byte)(bits >>> 24);
+ result[padding++] = (byte)(bits >>> 16);
+ result[padding++] = (byte)(bits >>> 8);
+ result[padding ] = (byte) bits;
return result;
}
protected byte[] getResult()
{
- return new byte[] { (byte) (h0 >>> 56), (byte) (h0 >>> 48),
- (byte) (h0 >>> 40), (byte) (h0 >>> 32),
- (byte) (h0 >>> 24), (byte) (h0 >>> 16),
- (byte) (h0 >>> 8), (byte) h0, (byte) (h1 >>> 56),
- (byte) (h1 >>> 48), (byte) (h1 >>> 40),
- (byte) (h1 >>> 32), (byte) (h1 >>> 24),
- (byte) (h1 >>> 16), (byte) (h1 >>> 8), (byte) h1,
- (byte) (h2 >>> 56), (byte) (h2 >>> 48),
- (byte) (h2 >>> 40), (byte) (h2 >>> 32),
- (byte) (h2 >>> 24), (byte) (h2 >>> 16),
- (byte) (h2 >>> 8), (byte) h2, (byte) (h3 >>> 56),
- (byte) (h3 >>> 48), (byte) (h3 >>> 40),
- (byte) (h3 >>> 32), (byte) (h3 >>> 24),
- (byte) (h3 >>> 16), (byte) (h3 >>> 8), (byte) h3,
- (byte) (h4 >>> 56), (byte) (h4 >>> 48),
- (byte) (h4 >>> 40), (byte) (h4 >>> 32),
- (byte) (h4 >>> 24), (byte) (h4 >>> 16),
- (byte) (h4 >>> 8), (byte) h4, (byte) (h5 >>> 56),
- (byte) (h5 >>> 48), (byte) (h5 >>> 40),
- (byte) (h5 >>> 32), (byte) (h5 >>> 24),
- (byte) (h5 >>> 16), (byte) (h5 >>> 8), (byte) h5,
- (byte) (h6 >>> 56), (byte) (h6 >>> 48),
- (byte) (h6 >>> 40), (byte) (h6 >>> 32),
- (byte) (h6 >>> 24), (byte) (h6 >>> 16),
- (byte) (h6 >>> 8), (byte) h6, (byte) (h7 >>> 56),
- (byte) (h7 >>> 48), (byte) (h7 >>> 40),
- (byte) (h7 >>> 32), (byte) (h7 >>> 24),
- (byte) (h7 >>> 16), (byte) (h7 >>> 8), (byte) h7 };
+ return new byte[] {
+ (byte)(h0 >>> 56), (byte)(h0 >>> 48), (byte)(h0 >>> 40), (byte)(h0 >>> 32),
+ (byte)(h0 >>> 24), (byte)(h0 >>> 16), (byte)(h0 >>> 8), (byte) h0,
+ (byte)(h1 >>> 56), (byte)(h1 >>> 48), (byte)(h1 >>> 40), (byte)(h1 >>> 32),
+ (byte)(h1 >>> 24), (byte)(h1 >>> 16), (byte)(h1 >>> 8), (byte) h1,
+ (byte)(h2 >>> 56), (byte)(h2 >>> 48), (byte)(h2 >>> 40), (byte)(h2 >>> 32),
+ (byte)(h2 >>> 24), (byte)(h2 >>> 16), (byte)(h2 >>> 8), (byte) h2,
+ (byte)(h3 >>> 56), (byte)(h3 >>> 48), (byte)(h3 >>> 40), (byte)(h3 >>> 32),
+ (byte)(h3 >>> 24), (byte)(h3 >>> 16), (byte)(h3 >>> 8), (byte) h3,
+ (byte)(h4 >>> 56), (byte)(h4 >>> 48), (byte)(h4 >>> 40), (byte)(h4 >>> 32),
+ (byte)(h4 >>> 24), (byte)(h4 >>> 16), (byte)(h4 >>> 8), (byte) h4,
+ (byte)(h5 >>> 56), (byte)(h5 >>> 48), (byte)(h5 >>> 40), (byte)(h5 >>> 32),
+ (byte)(h5 >>> 24), (byte)(h5 >>> 16), (byte)(h5 >>> 8), (byte) h5,
+ (byte)(h6 >>> 56), (byte)(h6 >>> 48), (byte)(h6 >>> 40), (byte)(h6 >>> 32),
+ (byte)(h6 >>> 24), (byte)(h6 >>> 16), (byte)(h6 >>> 8), (byte) h6,
+ (byte)(h7 >>> 56), (byte)(h7 >>> 48), (byte)(h7 >>> 40), (byte)(h7 >>> 32),
+ (byte)(h7 >>> 24), (byte)(h7 >>> 16), (byte)(h7 >>> 8), (byte) h7 };
}
protected void resetContext()
@@ -261,9 +219,7 @@ public class Sha512 extends BaseHash
return valid.booleanValue();
}
- // SHA specific methods ----------------------------------------------------
-
- private static final synchronized long[] sha(long hh0, long hh1, long hh2,
+ private static synchronized final long[] sha(long hh0, long hh1, long hh2,
long hh3, long hh4, long hh5,
long hh6, long hh7, byte[] in,
int offset)
@@ -278,33 +234,36 @@ public class Sha512 extends BaseHash
long H = hh7;
long T, T2;
int r;
-
for (r = 0; r < 16; r++)
- {
- w[r] = (long) in[offset++] << 56 | ((long) in[offset++] & 0xFF) << 48
- | ((long) in[offset++] & 0xFF) << 40
- | ((long) in[offset++] & 0xFF) << 32
- | ((long) in[offset++] & 0xFF) << 24
- | ((long) in[offset++] & 0xFF) << 16
- | ((long) in[offset++] & 0xFF) << 8
- | ((long) in[offset++] & 0xFF);
- }
+ w[r] = (long) in[offset++] << 56
+ | ((long) in[offset++] & 0xFF) << 48
+ | ((long) in[offset++] & 0xFF) << 40
+ | ((long) in[offset++] & 0xFF) << 32
+ | ((long) in[offset++] & 0xFF) << 24
+ | ((long) in[offset++] & 0xFF) << 16
+ | ((long) in[offset++] & 0xFF) << 8
+ | ((long) in[offset++] & 0xFF);
for (r = 16; r < 80; r++)
{
T = w[r - 2];
T2 = w[r - 15];
w[r] = (((T >>> 19) | (T << 45)) ^ ((T >>> 61) | (T << 3)) ^ (T >>> 6))
+ w[r - 7]
- + (((T2 >>> 1) | (T2 << 63)) ^ ((T2 >>> 8) | (T2 << 56)) ^ (T2 >>> 7))
+ + (((T2 >>> 1) | (T2 << 63))
+ ^ ((T2 >>> 8) | (T2 << 56))
+ ^ (T2 >>> 7))
+ w[r - 16];
}
-
for (r = 0; r < 80; r++)
{
T = H
- + (((E >>> 14) | (E << 50)) ^ ((E >>> 18) | (E << 46)) ^ ((E >>> 41) | (E << 23)))
+ + (((E >>> 14) | (E << 50))
+ ^ ((E >>> 18) | (E << 46))
+ ^ ((E >>> 41) | (E << 23)))
+ ((E & F) ^ ((~E) & G)) + k[r] + w[r];
- T2 = (((A >>> 28) | (A << 36)) ^ ((A >>> 34) | (A << 30)) ^ ((A >>> 39) | (A << 25)))
+ T2 = (((A >>> 28) | (A << 36))
+ ^ ((A >>> 34) | (A << 30))
+ ^ ((A >>> 39) | (A << 25)))
+ ((A & B) ^ (A & C) ^ (B & C));
H = G;
G = F;
@@ -315,8 +274,8 @@ public class Sha512 extends BaseHash
B = A;
A = T + T2;
}
-
- return new long[] { hh0 + A, hh1 + B, hh2 + C, hh3 + D, hh4 + E, hh5 + F,
- hh6 + G, hh7 + H };
+ return new long[] {
+ hh0 + A, hh1 + B, hh2 + C, hh3 + D,
+ hh4 + E, hh5 + F, hh6 + G, hh7 + H };
}
}
diff --git a/libjava/classpath/gnu/java/security/hash/Tiger.java b/libjava/classpath/gnu/java/security/hash/Tiger.java
index be0921dceb5..101df39efe9 100644
--- a/libjava/classpath/gnu/java/security/hash/Tiger.java
+++ b/libjava/classpath/gnu/java/security/hash/Tiger.java
@@ -46,29 +46,27 @@ import gnu.java.security.util.Util;
* Biham, with the goal of producing a secure, fast hash function that
* performs especially well on next-generation 64-bit architectures, but
* is still efficient on 32- and 16-bit architectures.
- *
- * <p>Tiger processes data in 512-bit blocks and produces a 192-bit
- * digest.</p>
- *
- * <p>References:</p>
+ * <p>
+ * Tiger processes data in 512-bit blocks and produces a 192-bit
+ * digest.
+ * <p>
+ * References:
* <ol>
* <li><a
* href="http://www.cs.technion.ac.il/~biham/Reports/Tiger/">Tiger: A
* Fast New Hash Function</a>, Ross Anderson and Eli Biham.</a></li>
* </ol>
*/
-public class Tiger extends BaseHash
+public class Tiger
+ extends BaseHash
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
private static final int HASH_SIZE = 24;
private static final int BLOCK_SIZE = 64;
/** Result when no data has been input. */
- private static final String DIGEST0 = "3293AC630C13F0245F92BBB1766E16167A4E58492DDE73F3";
+ private static final String DIGEST0 =
+ "3293AC630C13F0245F92BBB1766E16167A4E58492DDE73F3";
private static final long A = 0x0123456789ABCDEFL;
@@ -77,524 +75,360 @@ public class Tiger extends BaseHash
private static final long C = 0xF096A5B4C3B2E187L;
/** S-Box T1. */
- private static final long[] T1 = { 0x02AAB17CF7E90C5EL, 0xAC424B03E243A8ECL,
- 0x72CD5BE30DD5FCD3L, 0x6D019B93F6F97F3AL,
- 0xCD9978FFD21F9193L, 0x7573A1C9708029E2L,
- 0xB164326B922A83C3L, 0x46883EEE04915870L,
- 0xEAACE3057103ECE6L, 0xC54169B808A3535CL,
- 0x4CE754918DDEC47CL, 0x0AA2F4DFDC0DF40CL,
- 0x10B76F18A74DBEFAL, 0xC6CCB6235AD1AB6AL,
- 0x13726121572FE2FFL, 0x1A488C6F199D921EL,
- 0x4BC9F9F4DA0007CAL, 0x26F5E6F6E85241C7L,
- 0x859079DBEA5947B6L, 0x4F1885C5C99E8C92L,
- 0xD78E761EA96F864BL, 0x8E36428C52B5C17DL,
- 0x69CF6827373063C1L, 0xB607C93D9BB4C56EL,
- 0x7D820E760E76B5EAL, 0x645C9CC6F07FDC42L,
- 0xBF38A078243342E0L, 0x5F6B343C9D2E7D04L,
- 0xF2C28AEB600B0EC6L, 0x6C0ED85F7254BCACL,
- 0x71592281A4DB4FE5L, 0x1967FA69CE0FED9FL,
- 0xFD5293F8B96545DBL, 0xC879E9D7F2A7600BL,
- 0x860248920193194EL, 0xA4F9533B2D9CC0B3L,
- 0x9053836C15957613L, 0xDB6DCF8AFC357BF1L,
- 0x18BEEA7A7A370F57L, 0x037117CA50B99066L,
- 0x6AB30A9774424A35L, 0xF4E92F02E325249BL,
- 0x7739DB07061CCAE1L, 0xD8F3B49CECA42A05L,
- 0xBD56BE3F51382F73L, 0x45FAED5843B0BB28L,
- 0x1C813D5C11BF1F83L, 0x8AF0E4B6D75FA169L,
- 0x33EE18A487AD9999L, 0x3C26E8EAB1C94410L,
- 0xB510102BC0A822F9L, 0x141EEF310CE6123BL,
- 0xFC65B90059DDB154L, 0xE0158640C5E0E607L,
- 0x884E079826C3A3CFL, 0x930D0D9523C535FDL,
- 0x35638D754E9A2B00L, 0x4085FCCF40469DD5L,
- 0xC4B17AD28BE23A4CL, 0xCAB2F0FC6A3E6A2EL,
- 0x2860971A6B943FCDL, 0x3DDE6EE212E30446L,
- 0x6222F32AE01765AEL, 0x5D550BB5478308FEL,
- 0xA9EFA98DA0EDA22AL, 0xC351A71686C40DA7L,
- 0x1105586D9C867C84L, 0xDCFFEE85FDA22853L,
- 0xCCFBD0262C5EEF76L, 0xBAF294CB8990D201L,
- 0xE69464F52AFAD975L, 0x94B013AFDF133E14L,
- 0x06A7D1A32823C958L, 0x6F95FE5130F61119L,
- 0xD92AB34E462C06C0L, 0xED7BDE33887C71D2L,
- 0x79746D6E6518393EL, 0x5BA419385D713329L,
- 0x7C1BA6B948A97564L, 0x31987C197BFDAC67L,
- 0xDE6C23C44B053D02L, 0x581C49FED002D64DL,
- 0xDD474D6338261571L, 0xAA4546C3E473D062L,
- 0x928FCE349455F860L, 0x48161BBACAAB94D9L,
- 0x63912430770E6F68L, 0x6EC8A5E602C6641CL,
- 0x87282515337DDD2BL, 0x2CDA6B42034B701BL,
- 0xB03D37C181CB096DL, 0xE108438266C71C6FL,
- 0x2B3180C7EB51B255L, 0xDF92B82F96C08BBCL,
- 0x5C68C8C0A632F3BAL, 0x5504CC861C3D0556L,
- 0xABBFA4E55FB26B8FL, 0x41848B0AB3BACEB4L,
- 0xB334A273AA445D32L, 0xBCA696F0A85AD881L,
- 0x24F6EC65B528D56CL, 0x0CE1512E90F4524AL,
- 0x4E9DD79D5506D35AL, 0x258905FAC6CE9779L,
- 0x2019295B3E109B33L, 0xF8A9478B73A054CCL,
- 0x2924F2F934417EB0L, 0x3993357D536D1BC4L,
- 0x38A81AC21DB6FF8BL, 0x47C4FBF17D6016BFL,
- 0x1E0FAADD7667E3F5L, 0x7ABCFF62938BEB96L,
- 0xA78DAD948FC179C9L, 0x8F1F98B72911E50DL,
- 0x61E48EAE27121A91L, 0x4D62F7AD31859808L,
- 0xECEBA345EF5CEAEBL, 0xF5CEB25EBC9684CEL,
- 0xF633E20CB7F76221L, 0xA32CDF06AB8293E4L,
- 0x985A202CA5EE2CA4L, 0xCF0B8447CC8A8FB1L,
- 0x9F765244979859A3L, 0xA8D516B1A1240017L,
- 0x0BD7BA3EBB5DC726L, 0xE54BCA55B86ADB39L,
- 0x1D7A3AFD6C478063L, 0x519EC608E7669EDDL,
- 0x0E5715A2D149AA23L, 0x177D4571848FF194L,
- 0xEEB55F3241014C22L, 0x0F5E5CA13A6E2EC2L,
- 0x8029927B75F5C361L, 0xAD139FABC3D6E436L,
- 0x0D5DF1A94CCF402FL, 0x3E8BD948BEA5DFC8L,
- 0xA5A0D357BD3FF77EL, 0xA2D12E251F74F645L,
- 0x66FD9E525E81A082L, 0x2E0C90CE7F687A49L,
- 0xC2E8BCBEBA973BC5L, 0x000001BCE509745FL,
- 0x423777BBE6DAB3D6L, 0xD1661C7EAEF06EB5L,
- 0xA1781F354DAACFD8L, 0x2D11284A2B16AFFCL,
- 0xF1FC4F67FA891D1FL, 0x73ECC25DCB920ADAL,
- 0xAE610C22C2A12651L, 0x96E0A810D356B78AL,
- 0x5A9A381F2FE7870FL, 0xD5AD62EDE94E5530L,
- 0xD225E5E8368D1427L, 0x65977B70C7AF4631L,
- 0x99F889B2DE39D74FL, 0x233F30BF54E1D143L,
- 0x9A9675D3D9A63C97L, 0x5470554FF334F9A8L,
- 0x166ACB744A4F5688L, 0x70C74CAAB2E4AEADL,
- 0xF0D091646F294D12L, 0x57B82A89684031D1L,
- 0xEFD95A5A61BE0B6BL, 0x2FBD12E969F2F29AL,
- 0x9BD37013FEFF9FE8L, 0x3F9B0404D6085A06L,
- 0x4940C1F3166CFE15L, 0x09542C4DCDF3DEFBL,
- 0xB4C5218385CD5CE3L, 0xC935B7DC4462A641L,
- 0x3417F8A68ED3B63FL, 0xB80959295B215B40L,
- 0xF99CDAEF3B8C8572L, 0x018C0614F8FCB95DL,
- 0x1B14ACCD1A3ACDF3L, 0x84D471F200BB732DL,
- 0xC1A3110E95E8DA16L, 0x430A7220BF1A82B8L,
- 0xB77E090D39DF210EL, 0x5EF4BD9F3CD05E9DL,
- 0x9D4FF6DA7E57A444L, 0xDA1D60E183D4A5F8L,
- 0xB287C38417998E47L, 0xFE3EDC121BB31886L,
- 0xC7FE3CCC980CCBEFL, 0xE46FB590189BFD03L,
- 0x3732FD469A4C57DCL, 0x7EF700A07CF1AD65L,
- 0x59C64468A31D8859L, 0x762FB0B4D45B61F6L,
- 0x155BAED099047718L, 0x68755E4C3D50BAA6L,
- 0xE9214E7F22D8B4DFL, 0x2ADDBF532EAC95F4L,
- 0x32AE3909B4BD0109L, 0x834DF537B08E3450L,
- 0xFA209DA84220728DL, 0x9E691D9B9EFE23F7L,
- 0x0446D288C4AE8D7FL, 0x7B4CC524E169785BL,
- 0x21D87F0135CA1385L, 0xCEBB400F137B8AA5L,
- 0x272E2B66580796BEL, 0x3612264125C2B0DEL,
- 0x057702BDAD1EFBB2L, 0xD4BABB8EACF84BE9L,
- 0x91583139641BC67BL, 0x8BDC2DE08036E024L,
- 0x603C8156F49F68EDL, 0xF7D236F7DBEF5111L,
- 0x9727C4598AD21E80L, 0xA08A0896670A5FD7L,
- 0xCB4A8F4309EBA9CBL, 0x81AF564B0F7036A1L,
- 0xC0B99AA778199ABDL, 0x959F1EC83FC8E952L,
- 0x8C505077794A81B9L, 0x3ACAAF8F056338F0L,
- 0x07B43F50627A6778L, 0x4A44AB49F5ECCC77L,
- 0x3BC3D6E4B679EE98L, 0x9CC0D4D1CF14108CL,
- 0x4406C00B206BC8A0L, 0x82A18854C8D72D89L,
- 0x67E366B35C3C432CL, 0xB923DD61102B37F2L,
- 0x56AB2779D884271DL, 0xBE83E1B0FF1525AFL,
- 0xFB7C65D4217E49A9L, 0x6BDBE0E76D48E7D4L,
- 0x08DF828745D9179EL, 0x22EA6A9ADD53BD34L,
- 0xE36E141C5622200AL, 0x7F805D1B8CB750EEL,
- 0xAFE5C7A59F58E837L, 0xE27F996A4FB1C23CL,
- 0xD3867DFB0775F0D0L, 0xD0E673DE6E88891AL,
- 0x123AEB9EAFB86C25L, 0x30F1D5D5C145B895L,
- 0xBB434A2DEE7269E7L, 0x78CB67ECF931FA38L,
- 0xF33B0372323BBF9CL, 0x52D66336FB279C74L,
- 0x505F33AC0AFB4EAAL, 0xE8A5CD99A2CCE187L,
- 0x534974801E2D30BBL, 0x8D2D5711D5876D90L,
- 0x1F1A412891BC038EL, 0xD6E2E71D82E56648L,
- 0x74036C3A497732B7L, 0x89B67ED96361F5ABL,
- 0xFFED95D8F1EA02A2L, 0xE72B3BD61464D43DL,
- 0xA6300F170BDC4820L, 0xEBC18760ED78A77AL };
+ private static final long[] T1 = {
+ 0x02AAB17CF7E90C5EL, 0xAC424B03E243A8ECL, 0x72CD5BE30DD5FCD3L,
+ 0x6D019B93F6F97F3AL, 0xCD9978FFD21F9193L, 0x7573A1C9708029E2L,
+ 0xB164326B922A83C3L, 0x46883EEE04915870L, 0xEAACE3057103ECE6L,
+ 0xC54169B808A3535CL, 0x4CE754918DDEC47CL, 0x0AA2F4DFDC0DF40CL,
+ 0x10B76F18A74DBEFAL, 0xC6CCB6235AD1AB6AL, 0x13726121572FE2FFL,
+ 0x1A488C6F199D921EL, 0x4BC9F9F4DA0007CAL, 0x26F5E6F6E85241C7L,
+ 0x859079DBEA5947B6L, 0x4F1885C5C99E8C92L, 0xD78E761EA96F864BL,
+ 0x8E36428C52B5C17DL, 0x69CF6827373063C1L, 0xB607C93D9BB4C56EL,
+ 0x7D820E760E76B5EAL, 0x645C9CC6F07FDC42L, 0xBF38A078243342E0L,
+ 0x5F6B343C9D2E7D04L, 0xF2C28AEB600B0EC6L, 0x6C0ED85F7254BCACL,
+ 0x71592281A4DB4FE5L, 0x1967FA69CE0FED9FL, 0xFD5293F8B96545DBL,
+ 0xC879E9D7F2A7600BL, 0x860248920193194EL, 0xA4F9533B2D9CC0B3L,
+ 0x9053836C15957613L, 0xDB6DCF8AFC357BF1L, 0x18BEEA7A7A370F57L,
+ 0x037117CA50B99066L, 0x6AB30A9774424A35L, 0xF4E92F02E325249BL,
+ 0x7739DB07061CCAE1L, 0xD8F3B49CECA42A05L, 0xBD56BE3F51382F73L,
+ 0x45FAED5843B0BB28L, 0x1C813D5C11BF1F83L, 0x8AF0E4B6D75FA169L,
+ 0x33EE18A487AD9999L, 0x3C26E8EAB1C94410L, 0xB510102BC0A822F9L,
+ 0x141EEF310CE6123BL, 0xFC65B90059DDB154L, 0xE0158640C5E0E607L,
+ 0x884E079826C3A3CFL, 0x930D0D9523C535FDL, 0x35638D754E9A2B00L,
+ 0x4085FCCF40469DD5L, 0xC4B17AD28BE23A4CL, 0xCAB2F0FC6A3E6A2EL,
+ 0x2860971A6B943FCDL, 0x3DDE6EE212E30446L, 0x6222F32AE01765AEL,
+ 0x5D550BB5478308FEL, 0xA9EFA98DA0EDA22AL, 0xC351A71686C40DA7L,
+ 0x1105586D9C867C84L, 0xDCFFEE85FDA22853L, 0xCCFBD0262C5EEF76L,
+ 0xBAF294CB8990D201L, 0xE69464F52AFAD975L, 0x94B013AFDF133E14L,
+ 0x06A7D1A32823C958L, 0x6F95FE5130F61119L, 0xD92AB34E462C06C0L,
+ 0xED7BDE33887C71D2L, 0x79746D6E6518393EL, 0x5BA419385D713329L,
+ 0x7C1BA6B948A97564L, 0x31987C197BFDAC67L, 0xDE6C23C44B053D02L,
+ 0x581C49FED002D64DL, 0xDD474D6338261571L, 0xAA4546C3E473D062L,
+ 0x928FCE349455F860L, 0x48161BBACAAB94D9L, 0x63912430770E6F68L,
+ 0x6EC8A5E602C6641CL, 0x87282515337DDD2BL, 0x2CDA6B42034B701BL,
+ 0xB03D37C181CB096DL, 0xE108438266C71C6FL, 0x2B3180C7EB51B255L,
+ 0xDF92B82F96C08BBCL, 0x5C68C8C0A632F3BAL, 0x5504CC861C3D0556L,
+ 0xABBFA4E55FB26B8FL, 0x41848B0AB3BACEB4L, 0xB334A273AA445D32L,
+ 0xBCA696F0A85AD881L, 0x24F6EC65B528D56CL, 0x0CE1512E90F4524AL,
+ 0x4E9DD79D5506D35AL, 0x258905FAC6CE9779L, 0x2019295B3E109B33L,
+ 0xF8A9478B73A054CCL, 0x2924F2F934417EB0L, 0x3993357D536D1BC4L,
+ 0x38A81AC21DB6FF8BL, 0x47C4FBF17D6016BFL, 0x1E0FAADD7667E3F5L,
+ 0x7ABCFF62938BEB96L, 0xA78DAD948FC179C9L, 0x8F1F98B72911E50DL,
+ 0x61E48EAE27121A91L, 0x4D62F7AD31859808L, 0xECEBA345EF5CEAEBL,
+ 0xF5CEB25EBC9684CEL, 0xF633E20CB7F76221L, 0xA32CDF06AB8293E4L,
+ 0x985A202CA5EE2CA4L, 0xCF0B8447CC8A8FB1L, 0x9F765244979859A3L,
+ 0xA8D516B1A1240017L, 0x0BD7BA3EBB5DC726L, 0xE54BCA55B86ADB39L,
+ 0x1D7A3AFD6C478063L, 0x519EC608E7669EDDL, 0x0E5715A2D149AA23L,
+ 0x177D4571848FF194L, 0xEEB55F3241014C22L, 0x0F5E5CA13A6E2EC2L,
+ 0x8029927B75F5C361L, 0xAD139FABC3D6E436L, 0x0D5DF1A94CCF402FL,
+ 0x3E8BD948BEA5DFC8L, 0xA5A0D357BD3FF77EL, 0xA2D12E251F74F645L,
+ 0x66FD9E525E81A082L, 0x2E0C90CE7F687A49L, 0xC2E8BCBEBA973BC5L,
+ 0x000001BCE509745FL, 0x423777BBE6DAB3D6L, 0xD1661C7EAEF06EB5L,
+ 0xA1781F354DAACFD8L, 0x2D11284A2B16AFFCL, 0xF1FC4F67FA891D1FL,
+ 0x73ECC25DCB920ADAL, 0xAE610C22C2A12651L, 0x96E0A810D356B78AL,
+ 0x5A9A381F2FE7870FL, 0xD5AD62EDE94E5530L, 0xD225E5E8368D1427L,
+ 0x65977B70C7AF4631L, 0x99F889B2DE39D74FL, 0x233F30BF54E1D143L,
+ 0x9A9675D3D9A63C97L, 0x5470554FF334F9A8L, 0x166ACB744A4F5688L,
+ 0x70C74CAAB2E4AEADL, 0xF0D091646F294D12L, 0x57B82A89684031D1L,
+ 0xEFD95A5A61BE0B6BL, 0x2FBD12E969F2F29AL, 0x9BD37013FEFF9FE8L,
+ 0x3F9B0404D6085A06L, 0x4940C1F3166CFE15L, 0x09542C4DCDF3DEFBL,
+ 0xB4C5218385CD5CE3L, 0xC935B7DC4462A641L, 0x3417F8A68ED3B63FL,
+ 0xB80959295B215B40L, 0xF99CDAEF3B8C8572L, 0x018C0614F8FCB95DL,
+ 0x1B14ACCD1A3ACDF3L, 0x84D471F200BB732DL, 0xC1A3110E95E8DA16L,
+ 0x430A7220BF1A82B8L, 0xB77E090D39DF210EL, 0x5EF4BD9F3CD05E9DL,
+ 0x9D4FF6DA7E57A444L, 0xDA1D60E183D4A5F8L, 0xB287C38417998E47L,
+ 0xFE3EDC121BB31886L, 0xC7FE3CCC980CCBEFL, 0xE46FB590189BFD03L,
+ 0x3732FD469A4C57DCL, 0x7EF700A07CF1AD65L, 0x59C64468A31D8859L,
+ 0x762FB0B4D45B61F6L, 0x155BAED099047718L, 0x68755E4C3D50BAA6L,
+ 0xE9214E7F22D8B4DFL, 0x2ADDBF532EAC95F4L, 0x32AE3909B4BD0109L,
+ 0x834DF537B08E3450L, 0xFA209DA84220728DL, 0x9E691D9B9EFE23F7L,
+ 0x0446D288C4AE8D7FL, 0x7B4CC524E169785BL, 0x21D87F0135CA1385L,
+ 0xCEBB400F137B8AA5L, 0x272E2B66580796BEL, 0x3612264125C2B0DEL,
+ 0x057702BDAD1EFBB2L, 0xD4BABB8EACF84BE9L, 0x91583139641BC67BL,
+ 0x8BDC2DE08036E024L, 0x603C8156F49F68EDL, 0xF7D236F7DBEF5111L,
+ 0x9727C4598AD21E80L, 0xA08A0896670A5FD7L, 0xCB4A8F4309EBA9CBL,
+ 0x81AF564B0F7036A1L, 0xC0B99AA778199ABDL, 0x959F1EC83FC8E952L,
+ 0x8C505077794A81B9L, 0x3ACAAF8F056338F0L, 0x07B43F50627A6778L,
+ 0x4A44AB49F5ECCC77L, 0x3BC3D6E4B679EE98L, 0x9CC0D4D1CF14108CL,
+ 0x4406C00B206BC8A0L, 0x82A18854C8D72D89L, 0x67E366B35C3C432CL,
+ 0xB923DD61102B37F2L, 0x56AB2779D884271DL, 0xBE83E1B0FF1525AFL,
+ 0xFB7C65D4217E49A9L, 0x6BDBE0E76D48E7D4L, 0x08DF828745D9179EL,
+ 0x22EA6A9ADD53BD34L, 0xE36E141C5622200AL, 0x7F805D1B8CB750EEL,
+ 0xAFE5C7A59F58E837L, 0xE27F996A4FB1C23CL, 0xD3867DFB0775F0D0L,
+ 0xD0E673DE6E88891AL, 0x123AEB9EAFB86C25L, 0x30F1D5D5C145B895L,
+ 0xBB434A2DEE7269E7L, 0x78CB67ECF931FA38L, 0xF33B0372323BBF9CL,
+ 0x52D66336FB279C74L, 0x505F33AC0AFB4EAAL, 0xE8A5CD99A2CCE187L,
+ 0x534974801E2D30BBL, 0x8D2D5711D5876D90L, 0x1F1A412891BC038EL,
+ 0xD6E2E71D82E56648L, 0x74036C3A497732B7L, 0x89B67ED96361F5ABL,
+ 0xFFED95D8F1EA02A2L, 0xE72B3BD61464D43DL, 0xA6300F170BDC4820L,
+ 0xEBC18760ED78A77AL };
/** S-Box T2. */
- private static final long[] T2 = { 0xE6A6BE5A05A12138L, 0xB5A122A5B4F87C98L,
- 0x563C6089140B6990L, 0x4C46CB2E391F5DD5L,
- 0xD932ADDBC9B79434L, 0x08EA70E42015AFF5L,
- 0xD765A6673E478CF1L, 0xC4FB757EAB278D99L,
- 0xDF11C6862D6E0692L, 0xDDEB84F10D7F3B16L,
- 0x6F2EF604A665EA04L, 0x4A8E0F0FF0E0DFB3L,
- 0xA5EDEEF83DBCBA51L, 0xFC4F0A2A0EA4371EL,
- 0xE83E1DA85CB38429L, 0xDC8FF882BA1B1CE2L,
- 0xCD45505E8353E80DL, 0x18D19A00D4DB0717L,
- 0x34A0CFEDA5F38101L, 0x0BE77E518887CAF2L,
- 0x1E341438B3C45136L, 0xE05797F49089CCF9L,
- 0xFFD23F9DF2591D14L, 0x543DDA228595C5CDL,
- 0x661F81FD99052A33L, 0x8736E641DB0F7B76L,
- 0x15227725418E5307L, 0xE25F7F46162EB2FAL,
- 0x48A8B2126C13D9FEL, 0xAFDC541792E76EEAL,
- 0x03D912BFC6D1898FL, 0x31B1AAFA1B83F51BL,
- 0xF1AC2796E42AB7D9L, 0x40A3A7D7FCD2EBACL,
- 0x1056136D0AFBBCC5L, 0x7889E1DD9A6D0C85L,
- 0xD33525782A7974AAL, 0xA7E25D09078AC09BL,
- 0xBD4138B3EAC6EDD0L, 0x920ABFBE71EB9E70L,
- 0xA2A5D0F54FC2625CL, 0xC054E36B0B1290A3L,
- 0xF6DD59FF62FE932BL, 0x3537354511A8AC7DL,
- 0xCA845E9172FADCD4L, 0x84F82B60329D20DCL,
- 0x79C62CE1CD672F18L, 0x8B09A2ADD124642CL,
- 0xD0C1E96A19D9E726L, 0x5A786A9B4BA9500CL,
- 0x0E020336634C43F3L, 0xC17B474AEB66D822L,
- 0x6A731AE3EC9BAAC2L, 0x8226667AE0840258L,
- 0x67D4567691CAECA5L, 0x1D94155C4875ADB5L,
- 0x6D00FD985B813FDFL, 0x51286EFCB774CD06L,
- 0x5E8834471FA744AFL, 0xF72CA0AEE761AE2EL,
- 0xBE40E4CDAEE8E09AL, 0xE9970BBB5118F665L,
- 0x726E4BEB33DF1964L, 0x703B000729199762L,
- 0x4631D816F5EF30A7L, 0xB880B5B51504A6BEL,
- 0x641793C37ED84B6CL, 0x7B21ED77F6E97D96L,
- 0x776306312EF96B73L, 0xAE528948E86FF3F4L,
- 0x53DBD7F286A3F8F8L, 0x16CADCE74CFC1063L,
- 0x005C19BDFA52C6DDL, 0x68868F5D64D46AD3L,
- 0x3A9D512CCF1E186AL, 0x367E62C2385660AEL,
- 0xE359E7EA77DCB1D7L, 0x526C0773749ABE6EL,
- 0x735AE5F9D09F734BL, 0x493FC7CC8A558BA8L,
- 0xB0B9C1533041AB45L, 0x321958BA470A59BDL,
- 0x852DB00B5F46C393L, 0x91209B2BD336B0E5L,
- 0x6E604F7D659EF19FL, 0xB99A8AE2782CCB24L,
- 0xCCF52AB6C814C4C7L, 0x4727D9AFBE11727BL,
- 0x7E950D0C0121B34DL, 0x756F435670AD471FL,
- 0xF5ADD442615A6849L, 0x4E87E09980B9957AL,
- 0x2ACFA1DF50AEE355L, 0xD898263AFD2FD556L,
- 0xC8F4924DD80C8FD6L, 0xCF99CA3D754A173AL,
- 0xFE477BACAF91BF3CL, 0xED5371F6D690C12DL,
- 0x831A5C285E687094L, 0xC5D3C90A3708A0A4L,
- 0x0F7F903717D06580L, 0x19F9BB13B8FDF27FL,
- 0xB1BD6F1B4D502843L, 0x1C761BA38FFF4012L,
- 0x0D1530C4E2E21F3BL, 0x8943CE69A7372C8AL,
- 0xE5184E11FEB5CE66L, 0x618BDB80BD736621L,
- 0x7D29BAD68B574D0BL, 0x81BB613E25E6FE5BL,
- 0x071C9C10BC07913FL, 0xC7BEEB7909AC2D97L,
- 0xC3E58D353BC5D757L, 0xEB017892F38F61E8L,
- 0xD4EFFB9C9B1CC21AL, 0x99727D26F494F7ABL,
- 0xA3E063A2956B3E03L, 0x9D4A8B9A4AA09C30L,
- 0x3F6AB7D500090FB4L, 0x9CC0F2A057268AC0L,
- 0x3DEE9D2DEDBF42D1L, 0x330F49C87960A972L,
- 0xC6B2720287421B41L, 0x0AC59EC07C00369CL,
- 0xEF4EAC49CB353425L, 0xF450244EEF0129D8L,
- 0x8ACC46E5CAF4DEB6L, 0x2FFEAB63989263F7L,
- 0x8F7CB9FE5D7A4578L, 0x5BD8F7644E634635L,
- 0x427A7315BF2DC900L, 0x17D0C4AA2125261CL,
- 0x3992486C93518E50L, 0xB4CBFEE0A2D7D4C3L,
- 0x7C75D6202C5DDD8DL, 0xDBC295D8E35B6C61L,
- 0x60B369D302032B19L, 0xCE42685FDCE44132L,
- 0x06F3DDB9DDF65610L, 0x8EA4D21DB5E148F0L,
- 0x20B0FCE62FCD496FL, 0x2C1B912358B0EE31L,
- 0xB28317B818F5A308L, 0xA89C1E189CA6D2CFL,
- 0x0C6B18576AAADBC8L, 0xB65DEAA91299FAE3L,
- 0xFB2B794B7F1027E7L, 0x04E4317F443B5BEBL,
- 0x4B852D325939D0A6L, 0xD5AE6BEEFB207FFCL,
- 0x309682B281C7D374L, 0xBAE309A194C3B475L,
- 0x8CC3F97B13B49F05L, 0x98A9422FF8293967L,
- 0x244B16B01076FF7CL, 0xF8BF571C663D67EEL,
- 0x1F0D6758EEE30DA1L, 0xC9B611D97ADEB9B7L,
- 0xB7AFD5887B6C57A2L, 0x6290AE846B984FE1L,
- 0x94DF4CDEACC1A5FDL, 0x058A5BD1C5483AFFL,
- 0x63166CC142BA3C37L, 0x8DB8526EB2F76F40L,
- 0xE10880036F0D6D4EL, 0x9E0523C9971D311DL,
- 0x45EC2824CC7CD691L, 0x575B8359E62382C9L,
- 0xFA9E400DC4889995L, 0xD1823ECB45721568L,
- 0xDAFD983B8206082FL, 0xAA7D29082386A8CBL,
- 0x269FCD4403B87588L, 0x1B91F5F728BDD1E0L,
- 0xE4669F39040201F6L, 0x7A1D7C218CF04ADEL,
- 0x65623C29D79CE5CEL, 0x2368449096C00BB1L,
- 0xAB9BF1879DA503BAL, 0xBC23ECB1A458058EL,
- 0x9A58DF01BB401ECCL, 0xA070E868A85F143DL,
- 0x4FF188307DF2239EL, 0x14D565B41A641183L,
- 0xEE13337452701602L, 0x950E3DCF3F285E09L,
- 0x59930254B9C80953L, 0x3BF299408930DA6DL,
- 0xA955943F53691387L, 0xA15EDECAA9CB8784L,
- 0x29142127352BE9A0L, 0x76F0371FFF4E7AFBL,
- 0x0239F450274F2228L, 0xBB073AF01D5E868BL,
- 0xBFC80571C10E96C1L, 0xD267088568222E23L,
- 0x9671A3D48E80B5B0L, 0x55B5D38AE193BB81L,
- 0x693AE2D0A18B04B8L, 0x5C48B4ECADD5335FL,
- 0xFD743B194916A1CAL, 0x2577018134BE98C4L,
- 0xE77987E83C54A4ADL, 0x28E11014DA33E1B9L,
- 0x270CC59E226AA213L, 0x71495F756D1A5F60L,
- 0x9BE853FB60AFEF77L, 0xADC786A7F7443DBFL,
- 0x0904456173B29A82L, 0x58BC7A66C232BD5EL,
- 0xF306558C673AC8B2L, 0x41F639C6B6C9772AL,
- 0x216DEFE99FDA35DAL, 0x11640CC71C7BE615L,
- 0x93C43694565C5527L, 0xEA038E6246777839L,
- 0xF9ABF3CE5A3E2469L, 0x741E768D0FD312D2L,
- 0x0144B883CED652C6L, 0xC20B5A5BA33F8552L,
- 0x1AE69633C3435A9DL, 0x97A28CA4088CFDECL,
- 0x8824A43C1E96F420L, 0x37612FA66EEEA746L,
- 0x6B4CB165F9CF0E5AL, 0x43AA1C06A0ABFB4AL,
- 0x7F4DC26FF162796BL, 0x6CBACC8E54ED9B0FL,
- 0xA6B7FFEFD2BB253EL, 0x2E25BC95B0A29D4FL,
- 0x86D6A58BDEF1388CL, 0xDED74AC576B6F054L,
- 0x8030BDBC2B45805DL, 0x3C81AF70E94D9289L,
- 0x3EFF6DDA9E3100DBL, 0xB38DC39FDFCC8847L,
- 0x123885528D17B87EL, 0xF2DA0ED240B1B642L,
- 0x44CEFADCD54BF9A9L, 0x1312200E433C7EE6L,
- 0x9FFCC84F3A78C748L, 0xF0CD1F72248576BBL,
- 0xEC6974053638CFE4L, 0x2BA7B67C0CEC4E4CL,
- 0xAC2F4DF3E5CE32EDL, 0xCB33D14326EA4C11L,
- 0xA4E9044CC77E58BCL, 0x5F513293D934FCEFL,
- 0x5DC9645506E55444L, 0x50DE418F317DE40AL,
- 0x388CB31A69DDE259L, 0x2DB4A83455820A86L,
- 0x9010A91E84711AE9L, 0x4DF7F0B7B1498371L,
- 0xD62A2EABC0977179L, 0x22FAC097AA8D5C0EL };
+ private static final long[] T2 = {
+ 0xE6A6BE5A05A12138L, 0xB5A122A5B4F87C98L, 0x563C6089140B6990L,
+ 0x4C46CB2E391F5DD5L, 0xD932ADDBC9B79434L, 0x08EA70E42015AFF5L,
+ 0xD765A6673E478CF1L, 0xC4FB757EAB278D99L, 0xDF11C6862D6E0692L,
+ 0xDDEB84F10D7F3B16L, 0x6F2EF604A665EA04L, 0x4A8E0F0FF0E0DFB3L,
+ 0xA5EDEEF83DBCBA51L, 0xFC4F0A2A0EA4371EL, 0xE83E1DA85CB38429L,
+ 0xDC8FF882BA1B1CE2L, 0xCD45505E8353E80DL, 0x18D19A00D4DB0717L,
+ 0x34A0CFEDA5F38101L, 0x0BE77E518887CAF2L, 0x1E341438B3C45136L,
+ 0xE05797F49089CCF9L, 0xFFD23F9DF2591D14L, 0x543DDA228595C5CDL,
+ 0x661F81FD99052A33L, 0x8736E641DB0F7B76L, 0x15227725418E5307L,
+ 0xE25F7F46162EB2FAL, 0x48A8B2126C13D9FEL, 0xAFDC541792E76EEAL,
+ 0x03D912BFC6D1898FL, 0x31B1AAFA1B83F51BL, 0xF1AC2796E42AB7D9L,
+ 0x40A3A7D7FCD2EBACL, 0x1056136D0AFBBCC5L, 0x7889E1DD9A6D0C85L,
+ 0xD33525782A7974AAL, 0xA7E25D09078AC09BL, 0xBD4138B3EAC6EDD0L,
+ 0x920ABFBE71EB9E70L, 0xA2A5D0F54FC2625CL, 0xC054E36B0B1290A3L,
+ 0xF6DD59FF62FE932BL, 0x3537354511A8AC7DL, 0xCA845E9172FADCD4L,
+ 0x84F82B60329D20DCL, 0x79C62CE1CD672F18L, 0x8B09A2ADD124642CL,
+ 0xD0C1E96A19D9E726L, 0x5A786A9B4BA9500CL, 0x0E020336634C43F3L,
+ 0xC17B474AEB66D822L, 0x6A731AE3EC9BAAC2L, 0x8226667AE0840258L,
+ 0x67D4567691CAECA5L, 0x1D94155C4875ADB5L, 0x6D00FD985B813FDFL,
+ 0x51286EFCB774CD06L, 0x5E8834471FA744AFL, 0xF72CA0AEE761AE2EL,
+ 0xBE40E4CDAEE8E09AL, 0xE9970BBB5118F665L, 0x726E4BEB33DF1964L,
+ 0x703B000729199762L, 0x4631D816F5EF30A7L, 0xB880B5B51504A6BEL,
+ 0x641793C37ED84B6CL, 0x7B21ED77F6E97D96L, 0x776306312EF96B73L,
+ 0xAE528948E86FF3F4L, 0x53DBD7F286A3F8F8L, 0x16CADCE74CFC1063L,
+ 0x005C19BDFA52C6DDL, 0x68868F5D64D46AD3L, 0x3A9D512CCF1E186AL,
+ 0x367E62C2385660AEL, 0xE359E7EA77DCB1D7L, 0x526C0773749ABE6EL,
+ 0x735AE5F9D09F734BL, 0x493FC7CC8A558BA8L, 0xB0B9C1533041AB45L,
+ 0x321958BA470A59BDL, 0x852DB00B5F46C393L, 0x91209B2BD336B0E5L,
+ 0x6E604F7D659EF19FL, 0xB99A8AE2782CCB24L, 0xCCF52AB6C814C4C7L,
+ 0x4727D9AFBE11727BL, 0x7E950D0C0121B34DL, 0x756F435670AD471FL,
+ 0xF5ADD442615A6849L, 0x4E87E09980B9957AL, 0x2ACFA1DF50AEE355L,
+ 0xD898263AFD2FD556L, 0xC8F4924DD80C8FD6L, 0xCF99CA3D754A173AL,
+ 0xFE477BACAF91BF3CL, 0xED5371F6D690C12DL, 0x831A5C285E687094L,
+ 0xC5D3C90A3708A0A4L, 0x0F7F903717D06580L, 0x19F9BB13B8FDF27FL,
+ 0xB1BD6F1B4D502843L, 0x1C761BA38FFF4012L, 0x0D1530C4E2E21F3BL,
+ 0x8943CE69A7372C8AL, 0xE5184E11FEB5CE66L, 0x618BDB80BD736621L,
+ 0x7D29BAD68B574D0BL, 0x81BB613E25E6FE5BL, 0x071C9C10BC07913FL,
+ 0xC7BEEB7909AC2D97L, 0xC3E58D353BC5D757L, 0xEB017892F38F61E8L,
+ 0xD4EFFB9C9B1CC21AL, 0x99727D26F494F7ABL, 0xA3E063A2956B3E03L,
+ 0x9D4A8B9A4AA09C30L, 0x3F6AB7D500090FB4L, 0x9CC0F2A057268AC0L,
+ 0x3DEE9D2DEDBF42D1L, 0x330F49C87960A972L, 0xC6B2720287421B41L,
+ 0x0AC59EC07C00369CL, 0xEF4EAC49CB353425L, 0xF450244EEF0129D8L,
+ 0x8ACC46E5CAF4DEB6L, 0x2FFEAB63989263F7L, 0x8F7CB9FE5D7A4578L,
+ 0x5BD8F7644E634635L, 0x427A7315BF2DC900L, 0x17D0C4AA2125261CL,
+ 0x3992486C93518E50L, 0xB4CBFEE0A2D7D4C3L, 0x7C75D6202C5DDD8DL,
+ 0xDBC295D8E35B6C61L, 0x60B369D302032B19L, 0xCE42685FDCE44132L,
+ 0x06F3DDB9DDF65610L, 0x8EA4D21DB5E148F0L, 0x20B0FCE62FCD496FL,
+ 0x2C1B912358B0EE31L, 0xB28317B818F5A308L, 0xA89C1E189CA6D2CFL,
+ 0x0C6B18576AAADBC8L, 0xB65DEAA91299FAE3L, 0xFB2B794B7F1027E7L,
+ 0x04E4317F443B5BEBL, 0x4B852D325939D0A6L, 0xD5AE6BEEFB207FFCL,
+ 0x309682B281C7D374L, 0xBAE309A194C3B475L, 0x8CC3F97B13B49F05L,
+ 0x98A9422FF8293967L, 0x244B16B01076FF7CL, 0xF8BF571C663D67EEL,
+ 0x1F0D6758EEE30DA1L, 0xC9B611D97ADEB9B7L, 0xB7AFD5887B6C57A2L,
+ 0x6290AE846B984FE1L, 0x94DF4CDEACC1A5FDL, 0x058A5BD1C5483AFFL,
+ 0x63166CC142BA3C37L, 0x8DB8526EB2F76F40L, 0xE10880036F0D6D4EL,
+ 0x9E0523C9971D311DL, 0x45EC2824CC7CD691L, 0x575B8359E62382C9L,
+ 0xFA9E400DC4889995L, 0xD1823ECB45721568L, 0xDAFD983B8206082FL,
+ 0xAA7D29082386A8CBL, 0x269FCD4403B87588L, 0x1B91F5F728BDD1E0L,
+ 0xE4669F39040201F6L, 0x7A1D7C218CF04ADEL, 0x65623C29D79CE5CEL,
+ 0x2368449096C00BB1L, 0xAB9BF1879DA503BAL, 0xBC23ECB1A458058EL,
+ 0x9A58DF01BB401ECCL, 0xA070E868A85F143DL, 0x4FF188307DF2239EL,
+ 0x14D565B41A641183L, 0xEE13337452701602L, 0x950E3DCF3F285E09L,
+ 0x59930254B9C80953L, 0x3BF299408930DA6DL, 0xA955943F53691387L,
+ 0xA15EDECAA9CB8784L, 0x29142127352BE9A0L, 0x76F0371FFF4E7AFBL,
+ 0x0239F450274F2228L, 0xBB073AF01D5E868BL, 0xBFC80571C10E96C1L,
+ 0xD267088568222E23L, 0x9671A3D48E80B5B0L, 0x55B5D38AE193BB81L,
+ 0x693AE2D0A18B04B8L, 0x5C48B4ECADD5335FL, 0xFD743B194916A1CAL,
+ 0x2577018134BE98C4L, 0xE77987E83C54A4ADL, 0x28E11014DA33E1B9L,
+ 0x270CC59E226AA213L, 0x71495F756D1A5F60L, 0x9BE853FB60AFEF77L,
+ 0xADC786A7F7443DBFL, 0x0904456173B29A82L, 0x58BC7A66C232BD5EL,
+ 0xF306558C673AC8B2L, 0x41F639C6B6C9772AL, 0x216DEFE99FDA35DAL,
+ 0x11640CC71C7BE615L, 0x93C43694565C5527L, 0xEA038E6246777839L,
+ 0xF9ABF3CE5A3E2469L, 0x741E768D0FD312D2L, 0x0144B883CED652C6L,
+ 0xC20B5A5BA33F8552L, 0x1AE69633C3435A9DL, 0x97A28CA4088CFDECL,
+ 0x8824A43C1E96F420L, 0x37612FA66EEEA746L, 0x6B4CB165F9CF0E5AL,
+ 0x43AA1C06A0ABFB4AL, 0x7F4DC26FF162796BL, 0x6CBACC8E54ED9B0FL,
+ 0xA6B7FFEFD2BB253EL, 0x2E25BC95B0A29D4FL, 0x86D6A58BDEF1388CL,
+ 0xDED74AC576B6F054L, 0x8030BDBC2B45805DL, 0x3C81AF70E94D9289L,
+ 0x3EFF6DDA9E3100DBL, 0xB38DC39FDFCC8847L, 0x123885528D17B87EL,
+ 0xF2DA0ED240B1B642L, 0x44CEFADCD54BF9A9L, 0x1312200E433C7EE6L,
+ 0x9FFCC84F3A78C748L, 0xF0CD1F72248576BBL, 0xEC6974053638CFE4L,
+ 0x2BA7B67C0CEC4E4CL, 0xAC2F4DF3E5CE32EDL, 0xCB33D14326EA4C11L,
+ 0xA4E9044CC77E58BCL, 0x5F513293D934FCEFL, 0x5DC9645506E55444L,
+ 0x50DE418F317DE40AL, 0x388CB31A69DDE259L, 0x2DB4A83455820A86L,
+ 0x9010A91E84711AE9L, 0x4DF7F0B7B1498371L, 0xD62A2EABC0977179L,
+ 0x22FAC097AA8D5C0EL };
/** S-Box T3. */
- private static final long[] T3 = { 0xF49FCC2FF1DAF39BL, 0x487FD5C66FF29281L,
- 0xE8A30667FCDCA83FL, 0x2C9B4BE3D2FCCE63L,
- 0xDA3FF74B93FBBBC2L, 0x2FA165D2FE70BA66L,
- 0xA103E279970E93D4L, 0xBECDEC77B0E45E71L,
- 0xCFB41E723985E497L, 0xB70AAA025EF75017L,
- 0xD42309F03840B8E0L, 0x8EFC1AD035898579L,
- 0x96C6920BE2B2ABC5L, 0x66AF4163375A9172L,
- 0x2174ABDCCA7127FBL, 0xB33CCEA64A72FF41L,
- 0xF04A4933083066A5L, 0x8D970ACDD7289AF5L,
- 0x8F96E8E031C8C25EL, 0xF3FEC02276875D47L,
- 0xEC7BF310056190DDL, 0xF5ADB0AEBB0F1491L,
- 0x9B50F8850FD58892L, 0x4975488358B74DE8L,
- 0xA3354FF691531C61L, 0x0702BBE481D2C6EEL,
- 0x89FB24057DEDED98L, 0xAC3075138596E902L,
- 0x1D2D3580172772EDL, 0xEB738FC28E6BC30DL,
- 0x5854EF8F63044326L, 0x9E5C52325ADD3BBEL,
- 0x90AA53CF325C4623L, 0xC1D24D51349DD067L,
- 0x2051CFEEA69EA624L, 0x13220F0A862E7E4FL,
- 0xCE39399404E04864L, 0xD9C42CA47086FCB7L,
- 0x685AD2238A03E7CCL, 0x066484B2AB2FF1DBL,
- 0xFE9D5D70EFBF79ECL, 0x5B13B9DD9C481854L,
- 0x15F0D475ED1509ADL, 0x0BEBCD060EC79851L,
- 0xD58C6791183AB7F8L, 0xD1187C5052F3EEE4L,
- 0xC95D1192E54E82FFL, 0x86EEA14CB9AC6CA2L,
- 0x3485BEB153677D5DL, 0xDD191D781F8C492AL,
- 0xF60866BAA784EBF9L, 0x518F643BA2D08C74L,
- 0x8852E956E1087C22L, 0xA768CB8DC410AE8DL,
- 0x38047726BFEC8E1AL, 0xA67738B4CD3B45AAL,
- 0xAD16691CEC0DDE19L, 0xC6D4319380462E07L,
- 0xC5A5876D0BA61938L, 0x16B9FA1FA58FD840L,
- 0x188AB1173CA74F18L, 0xABDA2F98C99C021FL,
- 0x3E0580AB134AE816L, 0x5F3B05B773645ABBL,
- 0x2501A2BE5575F2F6L, 0x1B2F74004E7E8BA9L,
- 0x1CD7580371E8D953L, 0x7F6ED89562764E30L,
- 0xB15926FF596F003DL, 0x9F65293DA8C5D6B9L,
- 0x6ECEF04DD690F84CL, 0x4782275FFF33AF88L,
- 0xE41433083F820801L, 0xFD0DFE409A1AF9B5L,
- 0x4325A3342CDB396BL, 0x8AE77E62B301B252L,
- 0xC36F9E9F6655615AL, 0x85455A2D92D32C09L,
- 0xF2C7DEA949477485L, 0x63CFB4C133A39EBAL,
- 0x83B040CC6EBC5462L, 0x3B9454C8FDB326B0L,
- 0x56F56A9E87FFD78CL, 0x2DC2940D99F42BC6L,
- 0x98F7DF096B096E2DL, 0x19A6E01E3AD852BFL,
- 0x42A99CCBDBD4B40BL, 0xA59998AF45E9C559L,
- 0x366295E807D93186L, 0x6B48181BFAA1F773L,
- 0x1FEC57E2157A0A1DL, 0x4667446AF6201AD5L,
- 0xE615EBCACFB0F075L, 0xB8F31F4F68290778L,
- 0x22713ED6CE22D11EL, 0x3057C1A72EC3C93BL,
- 0xCB46ACC37C3F1F2FL, 0xDBB893FD02AAF50EL,
- 0x331FD92E600B9FCFL, 0xA498F96148EA3AD6L,
- 0xA8D8426E8B6A83EAL, 0xA089B274B7735CDCL,
- 0x87F6B3731E524A11L, 0x118808E5CBC96749L,
- 0x9906E4C7B19BD394L, 0xAFED7F7E9B24A20CL,
- 0x6509EADEEB3644A7L, 0x6C1EF1D3E8EF0EDEL,
- 0xB9C97D43E9798FB4L, 0xA2F2D784740C28A3L,
- 0x7B8496476197566FL, 0x7A5BE3E6B65F069DL,
- 0xF96330ED78BE6F10L, 0xEEE60DE77A076A15L,
- 0x2B4BEE4AA08B9BD0L, 0x6A56A63EC7B8894EL,
- 0x02121359BA34FEF4L, 0x4CBF99F8283703FCL,
- 0x398071350CAF30C8L, 0xD0A77A89F017687AL,
- 0xF1C1A9EB9E423569L, 0x8C7976282DEE8199L,
- 0x5D1737A5DD1F7ABDL, 0x4F53433C09A9FA80L,
- 0xFA8B0C53DF7CA1D9L, 0x3FD9DCBC886CCB77L,
- 0xC040917CA91B4720L, 0x7DD00142F9D1DCDFL,
- 0x8476FC1D4F387B58L, 0x23F8E7C5F3316503L,
- 0x032A2244E7E37339L, 0x5C87A5D750F5A74BL,
- 0x082B4CC43698992EL, 0xDF917BECB858F63CL,
- 0x3270B8FC5BF86DDAL, 0x10AE72BB29B5DD76L,
- 0x576AC94E7700362BL, 0x1AD112DAC61EFB8FL,
- 0x691BC30EC5FAA427L, 0xFF246311CC327143L,
- 0x3142368E30E53206L, 0x71380E31E02CA396L,
- 0x958D5C960AAD76F1L, 0xF8D6F430C16DA536L,
- 0xC8FFD13F1BE7E1D2L, 0x7578AE66004DDBE1L,
- 0x05833F01067BE646L, 0xBB34B5AD3BFE586DL,
- 0x095F34C9A12B97F0L, 0x247AB64525D60CA8L,
- 0xDCDBC6F3017477D1L, 0x4A2E14D4DECAD24DL,
- 0xBDB5E6D9BE0A1EEBL, 0x2A7E70F7794301ABL,
- 0xDEF42D8A270540FDL, 0x01078EC0A34C22C1L,
- 0xE5DE511AF4C16387L, 0x7EBB3A52BD9A330AL,
- 0x77697857AA7D6435L, 0x004E831603AE4C32L,
- 0xE7A21020AD78E312L, 0x9D41A70C6AB420F2L,
- 0x28E06C18EA1141E6L, 0xD2B28CBD984F6B28L,
- 0x26B75F6C446E9D83L, 0xBA47568C4D418D7FL,
- 0xD80BADBFE6183D8EL, 0x0E206D7F5F166044L,
- 0xE258A43911CBCA3EL, 0x723A1746B21DC0BCL,
- 0xC7CAA854F5D7CDD3L, 0x7CAC32883D261D9CL,
- 0x7690C26423BA942CL, 0x17E55524478042B8L,
- 0xE0BE477656A2389FL, 0x4D289B5E67AB2DA0L,
- 0x44862B9C8FBBFD31L, 0xB47CC8049D141365L,
- 0x822C1B362B91C793L, 0x4EB14655FB13DFD8L,
- 0x1ECBBA0714E2A97BL, 0x6143459D5CDE5F14L,
- 0x53A8FBF1D5F0AC89L, 0x97EA04D81C5E5B00L,
- 0x622181A8D4FDB3F3L, 0xE9BCD341572A1208L,
- 0x1411258643CCE58AL, 0x9144C5FEA4C6E0A4L,
- 0x0D33D06565CF620FL, 0x54A48D489F219CA1L,
- 0xC43E5EAC6D63C821L, 0xA9728B3A72770DAFL,
- 0xD7934E7B20DF87EFL, 0xE35503B61A3E86E5L,
- 0xCAE321FBC819D504L, 0x129A50B3AC60BFA6L,
- 0xCD5E68EA7E9FB6C3L, 0xB01C90199483B1C7L,
- 0x3DE93CD5C295376CL, 0xAED52EDF2AB9AD13L,
- 0x2E60F512C0A07884L, 0xBC3D86A3E36210C9L,
- 0x35269D9B163951CEL, 0x0C7D6E2AD0CDB5FAL,
- 0x59E86297D87F5733L, 0x298EF221898DB0E7L,
- 0x55000029D1A5AA7EL, 0x8BC08AE1B5061B45L,
- 0xC2C31C2B6C92703AL, 0x94CC596BAF25EF42L,
- 0x0A1D73DB22540456L, 0x04B6A0F9D9C4179AL,
- 0xEFFDAFA2AE3D3C60L, 0xF7C8075BB49496C4L,
- 0x9CC5C7141D1CD4E3L, 0x78BD1638218E5534L,
- 0xB2F11568F850246AL, 0xEDFABCFA9502BC29L,
- 0x796CE5F2DA23051BL, 0xAAE128B0DC93537CL,
- 0x3A493DA0EE4B29AEL, 0xB5DF6B2C416895D7L,
- 0xFCABBD25122D7F37L, 0x70810B58105DC4B1L,
- 0xE10FDD37F7882A90L, 0x524DCAB5518A3F5CL,
- 0x3C9E85878451255BL, 0x4029828119BD34E2L,
- 0x74A05B6F5D3CECCBL, 0xB610021542E13ECAL,
- 0x0FF979D12F59E2ACL, 0x6037DA27E4F9CC50L,
- 0x5E92975A0DF1847DL, 0xD66DE190D3E623FEL,
- 0x5032D6B87B568048L, 0x9A36B7CE8235216EL,
- 0x80272A7A24F64B4AL, 0x93EFED8B8C6916F7L,
- 0x37DDBFF44CCE1555L, 0x4B95DB5D4B99BD25L,
- 0x92D3FDA169812FC0L, 0xFB1A4A9A90660BB6L,
- 0x730C196946A4B9B2L, 0x81E289AA7F49DA68L,
- 0x64669A0F83B1A05FL, 0x27B3FF7D9644F48BL,
- 0xCC6B615C8DB675B3L, 0x674F20B9BCEBBE95L,
- 0x6F31238275655982L, 0x5AE488713E45CF05L,
- 0xBF619F9954C21157L, 0xEABAC46040A8EAE9L,
- 0x454C6FE9F2C0C1CDL, 0x419CF6496412691CL,
- 0xD3DC3BEF265B0F70L, 0x6D0E60F5C3578A9EL };
+ private static final long[] T3 = {
+ 0xF49FCC2FF1DAF39BL, 0x487FD5C66FF29281L, 0xE8A30667FCDCA83FL,
+ 0x2C9B4BE3D2FCCE63L, 0xDA3FF74B93FBBBC2L, 0x2FA165D2FE70BA66L,
+ 0xA103E279970E93D4L, 0xBECDEC77B0E45E71L, 0xCFB41E723985E497L,
+ 0xB70AAA025EF75017L, 0xD42309F03840B8E0L, 0x8EFC1AD035898579L,
+ 0x96C6920BE2B2ABC5L, 0x66AF4163375A9172L, 0x2174ABDCCA7127FBL,
+ 0xB33CCEA64A72FF41L, 0xF04A4933083066A5L, 0x8D970ACDD7289AF5L,
+ 0x8F96E8E031C8C25EL, 0xF3FEC02276875D47L, 0xEC7BF310056190DDL,
+ 0xF5ADB0AEBB0F1491L, 0x9B50F8850FD58892L, 0x4975488358B74DE8L,
+ 0xA3354FF691531C61L, 0x0702BBE481D2C6EEL, 0x89FB24057DEDED98L,
+ 0xAC3075138596E902L, 0x1D2D3580172772EDL, 0xEB738FC28E6BC30DL,
+ 0x5854EF8F63044326L, 0x9E5C52325ADD3BBEL, 0x90AA53CF325C4623L,
+ 0xC1D24D51349DD067L, 0x2051CFEEA69EA624L, 0x13220F0A862E7E4FL,
+ 0xCE39399404E04864L, 0xD9C42CA47086FCB7L, 0x685AD2238A03E7CCL,
+ 0x066484B2AB2FF1DBL, 0xFE9D5D70EFBF79ECL, 0x5B13B9DD9C481854L,
+ 0x15F0D475ED1509ADL, 0x0BEBCD060EC79851L, 0xD58C6791183AB7F8L,
+ 0xD1187C5052F3EEE4L, 0xC95D1192E54E82FFL, 0x86EEA14CB9AC6CA2L,
+ 0x3485BEB153677D5DL, 0xDD191D781F8C492AL, 0xF60866BAA784EBF9L,
+ 0x518F643BA2D08C74L, 0x8852E956E1087C22L, 0xA768CB8DC410AE8DL,
+ 0x38047726BFEC8E1AL, 0xA67738B4CD3B45AAL, 0xAD16691CEC0DDE19L,
+ 0xC6D4319380462E07L, 0xC5A5876D0BA61938L, 0x16B9FA1FA58FD840L,
+ 0x188AB1173CA74F18L, 0xABDA2F98C99C021FL, 0x3E0580AB134AE816L,
+ 0x5F3B05B773645ABBL, 0x2501A2BE5575F2F6L, 0x1B2F74004E7E8BA9L,
+ 0x1CD7580371E8D953L, 0x7F6ED89562764E30L, 0xB15926FF596F003DL,
+ 0x9F65293DA8C5D6B9L, 0x6ECEF04DD690F84CL, 0x4782275FFF33AF88L,
+ 0xE41433083F820801L, 0xFD0DFE409A1AF9B5L, 0x4325A3342CDB396BL,
+ 0x8AE77E62B301B252L, 0xC36F9E9F6655615AL, 0x85455A2D92D32C09L,
+ 0xF2C7DEA949477485L, 0x63CFB4C133A39EBAL, 0x83B040CC6EBC5462L,
+ 0x3B9454C8FDB326B0L, 0x56F56A9E87FFD78CL, 0x2DC2940D99F42BC6L,
+ 0x98F7DF096B096E2DL, 0x19A6E01E3AD852BFL, 0x42A99CCBDBD4B40BL,
+ 0xA59998AF45E9C559L, 0x366295E807D93186L, 0x6B48181BFAA1F773L,
+ 0x1FEC57E2157A0A1DL, 0x4667446AF6201AD5L, 0xE615EBCACFB0F075L,
+ 0xB8F31F4F68290778L, 0x22713ED6CE22D11EL, 0x3057C1A72EC3C93BL,
+ 0xCB46ACC37C3F1F2FL, 0xDBB893FD02AAF50EL, 0x331FD92E600B9FCFL,
+ 0xA498F96148EA3AD6L, 0xA8D8426E8B6A83EAL, 0xA089B274B7735CDCL,
+ 0x87F6B3731E524A11L, 0x118808E5CBC96749L, 0x9906E4C7B19BD394L,
+ 0xAFED7F7E9B24A20CL, 0x6509EADEEB3644A7L, 0x6C1EF1D3E8EF0EDEL,
+ 0xB9C97D43E9798FB4L, 0xA2F2D784740C28A3L, 0x7B8496476197566FL,
+ 0x7A5BE3E6B65F069DL, 0xF96330ED78BE6F10L, 0xEEE60DE77A076A15L,
+ 0x2B4BEE4AA08B9BD0L, 0x6A56A63EC7B8894EL, 0x02121359BA34FEF4L,
+ 0x4CBF99F8283703FCL, 0x398071350CAF30C8L, 0xD0A77A89F017687AL,
+ 0xF1C1A9EB9E423569L, 0x8C7976282DEE8199L, 0x5D1737A5DD1F7ABDL,
+ 0x4F53433C09A9FA80L, 0xFA8B0C53DF7CA1D9L, 0x3FD9DCBC886CCB77L,
+ 0xC040917CA91B4720L, 0x7DD00142F9D1DCDFL, 0x8476FC1D4F387B58L,
+ 0x23F8E7C5F3316503L, 0x032A2244E7E37339L, 0x5C87A5D750F5A74BL,
+ 0x082B4CC43698992EL, 0xDF917BECB858F63CL, 0x3270B8FC5BF86DDAL,
+ 0x10AE72BB29B5DD76L, 0x576AC94E7700362BL, 0x1AD112DAC61EFB8FL,
+ 0x691BC30EC5FAA427L, 0xFF246311CC327143L, 0x3142368E30E53206L,
+ 0x71380E31E02CA396L, 0x958D5C960AAD76F1L, 0xF8D6F430C16DA536L,
+ 0xC8FFD13F1BE7E1D2L, 0x7578AE66004DDBE1L, 0x05833F01067BE646L,
+ 0xBB34B5AD3BFE586DL, 0x095F34C9A12B97F0L, 0x247AB64525D60CA8L,
+ 0xDCDBC6F3017477D1L, 0x4A2E14D4DECAD24DL, 0xBDB5E6D9BE0A1EEBL,
+ 0x2A7E70F7794301ABL, 0xDEF42D8A270540FDL, 0x01078EC0A34C22C1L,
+ 0xE5DE511AF4C16387L, 0x7EBB3A52BD9A330AL, 0x77697857AA7D6435L,
+ 0x004E831603AE4C32L, 0xE7A21020AD78E312L, 0x9D41A70C6AB420F2L,
+ 0x28E06C18EA1141E6L, 0xD2B28CBD984F6B28L, 0x26B75F6C446E9D83L,
+ 0xBA47568C4D418D7FL, 0xD80BADBFE6183D8EL, 0x0E206D7F5F166044L,
+ 0xE258A43911CBCA3EL, 0x723A1746B21DC0BCL, 0xC7CAA854F5D7CDD3L,
+ 0x7CAC32883D261D9CL, 0x7690C26423BA942CL, 0x17E55524478042B8L,
+ 0xE0BE477656A2389FL, 0x4D289B5E67AB2DA0L, 0x44862B9C8FBBFD31L,
+ 0xB47CC8049D141365L, 0x822C1B362B91C793L, 0x4EB14655FB13DFD8L,
+ 0x1ECBBA0714E2A97BL, 0x6143459D5CDE5F14L, 0x53A8FBF1D5F0AC89L,
+ 0x97EA04D81C5E5B00L, 0x622181A8D4FDB3F3L, 0xE9BCD341572A1208L,
+ 0x1411258643CCE58AL, 0x9144C5FEA4C6E0A4L, 0x0D33D06565CF620FL,
+ 0x54A48D489F219CA1L, 0xC43E5EAC6D63C821L, 0xA9728B3A72770DAFL,
+ 0xD7934E7B20DF87EFL, 0xE35503B61A3E86E5L, 0xCAE321FBC819D504L,
+ 0x129A50B3AC60BFA6L, 0xCD5E68EA7E9FB6C3L, 0xB01C90199483B1C7L,
+ 0x3DE93CD5C295376CL, 0xAED52EDF2AB9AD13L, 0x2E60F512C0A07884L,
+ 0xBC3D86A3E36210C9L, 0x35269D9B163951CEL, 0x0C7D6E2AD0CDB5FAL,
+ 0x59E86297D87F5733L, 0x298EF221898DB0E7L, 0x55000029D1A5AA7EL,
+ 0x8BC08AE1B5061B45L, 0xC2C31C2B6C92703AL, 0x94CC596BAF25EF42L,
+ 0x0A1D73DB22540456L, 0x04B6A0F9D9C4179AL, 0xEFFDAFA2AE3D3C60L,
+ 0xF7C8075BB49496C4L, 0x9CC5C7141D1CD4E3L, 0x78BD1638218E5534L,
+ 0xB2F11568F850246AL, 0xEDFABCFA9502BC29L, 0x796CE5F2DA23051BL,
+ 0xAAE128B0DC93537CL, 0x3A493DA0EE4B29AEL, 0xB5DF6B2C416895D7L,
+ 0xFCABBD25122D7F37L, 0x70810B58105DC4B1L, 0xE10FDD37F7882A90L,
+ 0x524DCAB5518A3F5CL, 0x3C9E85878451255BL, 0x4029828119BD34E2L,
+ 0x74A05B6F5D3CECCBL, 0xB610021542E13ECAL, 0x0FF979D12F59E2ACL,
+ 0x6037DA27E4F9CC50L, 0x5E92975A0DF1847DL, 0xD66DE190D3E623FEL,
+ 0x5032D6B87B568048L, 0x9A36B7CE8235216EL, 0x80272A7A24F64B4AL,
+ 0x93EFED8B8C6916F7L, 0x37DDBFF44CCE1555L, 0x4B95DB5D4B99BD25L,
+ 0x92D3FDA169812FC0L, 0xFB1A4A9A90660BB6L, 0x730C196946A4B9B2L,
+ 0x81E289AA7F49DA68L, 0x64669A0F83B1A05FL, 0x27B3FF7D9644F48BL,
+ 0xCC6B615C8DB675B3L, 0x674F20B9BCEBBE95L, 0x6F31238275655982L,
+ 0x5AE488713E45CF05L, 0xBF619F9954C21157L, 0xEABAC46040A8EAE9L,
+ 0x454C6FE9F2C0C1CDL, 0x419CF6496412691CL, 0xD3DC3BEF265B0F70L,
+ 0x6D0E60F5C3578A9EL };
/** S-Box T4. */
- private static final long[] T4 = { 0x5B0E608526323C55L, 0x1A46C1A9FA1B59F5L,
- 0xA9E245A17C4C8FFAL, 0x65CA5159DB2955D7L,
- 0x05DB0A76CE35AFC2L, 0x81EAC77EA9113D45L,
- 0x528EF88AB6AC0A0DL, 0xA09EA253597BE3FFL,
- 0x430DDFB3AC48CD56L, 0xC4B3A67AF45CE46FL,
- 0x4ECECFD8FBE2D05EL, 0x3EF56F10B39935F0L,
- 0x0B22D6829CD619C6L, 0x17FD460A74DF2069L,
- 0x6CF8CC8E8510ED40L, 0xD6C824BF3A6ECAA7L,
- 0x61243D581A817049L, 0x048BACB6BBC163A2L,
- 0xD9A38AC27D44CC32L, 0x7FDDFF5BAAF410ABL,
- 0xAD6D495AA804824BL, 0xE1A6A74F2D8C9F94L,
- 0xD4F7851235DEE8E3L, 0xFD4B7F886540D893L,
- 0x247C20042AA4BFDAL, 0x096EA1C517D1327CL,
- 0xD56966B4361A6685L, 0x277DA5C31221057DL,
- 0x94D59893A43ACFF7L, 0x64F0C51CCDC02281L,
- 0x3D33BCC4FF6189DBL, 0xE005CB184CE66AF1L,
- 0xFF5CCD1D1DB99BEAL, 0xB0B854A7FE42980FL,
- 0x7BD46A6A718D4B9FL, 0xD10FA8CC22A5FD8CL,
- 0xD31484952BE4BD31L, 0xC7FA975FCB243847L,
- 0x4886ED1E5846C407L, 0x28CDDB791EB70B04L,
- 0xC2B00BE2F573417FL, 0x5C9590452180F877L,
- 0x7A6BDDFFF370EB00L, 0xCE509E38D6D9D6A4L,
- 0xEBEB0F00647FA702L, 0x1DCC06CF76606F06L,
- 0xE4D9F28BA286FF0AL, 0xD85A305DC918C262L,
- 0x475B1D8732225F54L, 0x2D4FB51668CCB5FEL,
- 0xA679B9D9D72BBA20L, 0x53841C0D912D43A5L,
- 0x3B7EAA48BF12A4E8L, 0x781E0E47F22F1DDFL,
- 0xEFF20CE60AB50973L, 0x20D261D19DFFB742L,
- 0x16A12B03062A2E39L, 0x1960EB2239650495L,
- 0x251C16FED50EB8B8L, 0x9AC0C330F826016EL,
- 0xED152665953E7671L, 0x02D63194A6369570L,
- 0x5074F08394B1C987L, 0x70BA598C90B25CE1L,
- 0x794A15810B9742F6L, 0x0D5925E9FCAF8C6CL,
- 0x3067716CD868744EL, 0x910AB077E8D7731BL,
- 0x6A61BBDB5AC42F61L, 0x93513EFBF0851567L,
- 0xF494724B9E83E9D5L, 0xE887E1985C09648DL,
- 0x34B1D3C675370CFDL, 0xDC35E433BC0D255DL,
- 0xD0AAB84234131BE0L, 0x08042A50B48B7EAFL,
- 0x9997C4EE44A3AB35L, 0x829A7B49201799D0L,
- 0x263B8307B7C54441L, 0x752F95F4FD6A6CA6L,
- 0x927217402C08C6E5L, 0x2A8AB754A795D9EEL,
- 0xA442F7552F72943DL, 0x2C31334E19781208L,
- 0x4FA98D7CEAEE6291L, 0x55C3862F665DB309L,
- 0xBD0610175D53B1F3L, 0x46FE6CB840413F27L,
- 0x3FE03792DF0CFA59L, 0xCFE700372EB85E8FL,
- 0xA7BE29E7ADBCE118L, 0xE544EE5CDE8431DDL,
- 0x8A781B1B41F1873EL, 0xA5C94C78A0D2F0E7L,
- 0x39412E2877B60728L, 0xA1265EF3AFC9A62CL,
- 0xBCC2770C6A2506C5L, 0x3AB66DD5DCE1CE12L,
- 0xE65499D04A675B37L, 0x7D8F523481BFD216L,
- 0x0F6F64FCEC15F389L, 0x74EFBE618B5B13C8L,
- 0xACDC82B714273E1DL, 0xDD40BFE003199D17L,
- 0x37E99257E7E061F8L, 0xFA52626904775AAAL,
- 0x8BBBF63A463D56F9L, 0xF0013F1543A26E64L,
- 0xA8307E9F879EC898L, 0xCC4C27A4150177CCL,
- 0x1B432F2CCA1D3348L, 0xDE1D1F8F9F6FA013L,
- 0x606602A047A7DDD6L, 0xD237AB64CC1CB2C7L,
- 0x9B938E7225FCD1D3L, 0xEC4E03708E0FF476L,
- 0xFEB2FBDA3D03C12DL, 0xAE0BCED2EE43889AL,
- 0x22CB8923EBFB4F43L, 0x69360D013CF7396DL,
- 0x855E3602D2D4E022L, 0x073805BAD01F784CL,
- 0x33E17A133852F546L, 0xDF4874058AC7B638L,
- 0xBA92B29C678AA14AL, 0x0CE89FC76CFAADCDL,
- 0x5F9D4E0908339E34L, 0xF1AFE9291F5923B9L,
- 0x6E3480F60F4A265FL, 0xEEBF3A2AB29B841CL,
- 0xE21938A88F91B4ADL, 0x57DFEFF845C6D3C3L,
- 0x2F006B0BF62CAAF2L, 0x62F479EF6F75EE78L,
- 0x11A55AD41C8916A9L, 0xF229D29084FED453L,
- 0x42F1C27B16B000E6L, 0x2B1F76749823C074L,
- 0x4B76ECA3C2745360L, 0x8C98F463B91691BDL,
- 0x14BCC93CF1ADE66AL, 0x8885213E6D458397L,
- 0x8E177DF0274D4711L, 0xB49B73B5503F2951L,
- 0x10168168C3F96B6BL, 0x0E3D963B63CAB0AEL,
- 0x8DFC4B5655A1DB14L, 0xF789F1356E14DE5CL,
- 0x683E68AF4E51DAC1L, 0xC9A84F9D8D4B0FD9L,
- 0x3691E03F52A0F9D1L, 0x5ED86E46E1878E80L,
- 0x3C711A0E99D07150L, 0x5A0865B20C4E9310L,
- 0x56FBFC1FE4F0682EL, 0xEA8D5DE3105EDF9BL,
- 0x71ABFDB12379187AL, 0x2EB99DE1BEE77B9CL,
- 0x21ECC0EA33CF4523L, 0x59A4D7521805C7A1L,
- 0x3896F5EB56AE7C72L, 0xAA638F3DB18F75DCL,
- 0x9F39358DABE9808EL, 0xB7DEFA91C00B72ACL,
- 0x6B5541FD62492D92L, 0x6DC6DEE8F92E4D5BL,
- 0x353F57ABC4BEEA7EL, 0x735769D6DA5690CEL,
- 0x0A234AA642391484L, 0xF6F9508028F80D9DL,
- 0xB8E319A27AB3F215L, 0x31AD9C1151341A4DL,
- 0x773C22A57BEF5805L, 0x45C7561A07968633L,
- 0xF913DA9E249DBE36L, 0xDA652D9B78A64C68L,
- 0x4C27A97F3BC334EFL, 0x76621220E66B17F4L,
- 0x967743899ACD7D0BL, 0xF3EE5BCAE0ED6782L,
- 0x409F753600C879FCL, 0x06D09A39B5926DB6L,
- 0x6F83AEB0317AC588L, 0x01E6CA4A86381F21L,
- 0x66FF3462D19F3025L, 0x72207C24DDFD3BFBL,
- 0x4AF6B6D3E2ECE2EBL, 0x9C994DBEC7EA08DEL,
- 0x49ACE597B09A8BC4L, 0xB38C4766CF0797BAL,
- 0x131B9373C57C2A75L, 0xB1822CCE61931E58L,
- 0x9D7555B909BA1C0CL, 0x127FAFDD937D11D2L,
- 0x29DA3BADC66D92E4L, 0xA2C1D57154C2ECBCL,
- 0x58C5134D82F6FE24L, 0x1C3AE3515B62274FL,
- 0xE907C82E01CB8126L, 0xF8ED091913E37FCBL,
- 0x3249D8F9C80046C9L, 0x80CF9BEDE388FB63L,
- 0x1881539A116CF19EL, 0x5103F3F76BD52457L,
- 0x15B7E6F5AE47F7A8L, 0xDBD7C6DED47E9CCFL,
- 0x44E55C410228BB1AL, 0xB647D4255EDB4E99L,
- 0x5D11882BB8AAFC30L, 0xF5098BBB29D3212AL,
- 0x8FB5EA14E90296B3L, 0x677B942157DD025AL,
- 0xFB58E7C0A390ACB5L, 0x89D3674C83BD4A01L,
- 0x9E2DA4DF4BF3B93BL, 0xFCC41E328CAB4829L,
- 0x03F38C96BA582C52L, 0xCAD1BDBD7FD85DB2L,
- 0xBBB442C16082AE83L, 0xB95FE86BA5DA9AB0L,
- 0xB22E04673771A93FL, 0x845358C9493152D8L,
- 0xBE2A488697B4541EL, 0x95A2DC2DD38E6966L,
- 0xC02C11AC923C852BL, 0x2388B1990DF2A87BL,
- 0x7C8008FA1B4F37BEL, 0x1F70D0C84D54E503L,
- 0x5490ADEC7ECE57D4L, 0x002B3C27D9063A3AL,
- 0x7EAEA3848030A2BFL, 0xC602326DED2003C0L,
- 0x83A7287D69A94086L, 0xC57A5FCB30F57A8AL,
- 0xB56844E479EBE779L, 0xA373B40F05DCBCE9L,
- 0xD71A786E88570EE2L, 0x879CBACDBDE8F6A0L,
- 0x976AD1BCC164A32FL, 0xAB21E25E9666D78BL,
- 0x901063AAE5E5C33CL, 0x9818B34448698D90L,
- 0xE36487AE3E1E8ABBL, 0xAFBDF931893BDCB4L,
- 0x6345A0DC5FBBD519L, 0x8628FE269B9465CAL,
- 0x1E5D01603F9C51ECL, 0x4DE44006A15049B7L,
- 0xBF6C70E5F776CBB1L, 0x411218F2EF552BEDL,
- 0xCB0C0708705A36A3L, 0xE74D14754F986044L,
- 0xCD56D9430EA8280EL, 0xC12591D7535F5065L,
- 0xC83223F1720AEF96L, 0xC3A0396F7363A51FL };
+ private static final long[] T4 = {
+ 0x5B0E608526323C55L, 0x1A46C1A9FA1B59F5L, 0xA9E245A17C4C8FFAL,
+ 0x65CA5159DB2955D7L, 0x05DB0A76CE35AFC2L, 0x81EAC77EA9113D45L,
+ 0x528EF88AB6AC0A0DL, 0xA09EA253597BE3FFL, 0x430DDFB3AC48CD56L,
+ 0xC4B3A67AF45CE46FL, 0x4ECECFD8FBE2D05EL, 0x3EF56F10B39935F0L,
+ 0x0B22D6829CD619C6L, 0x17FD460A74DF2069L, 0x6CF8CC8E8510ED40L,
+ 0xD6C824BF3A6ECAA7L, 0x61243D581A817049L, 0x048BACB6BBC163A2L,
+ 0xD9A38AC27D44CC32L, 0x7FDDFF5BAAF410ABL, 0xAD6D495AA804824BL,
+ 0xE1A6A74F2D8C9F94L, 0xD4F7851235DEE8E3L, 0xFD4B7F886540D893L,
+ 0x247C20042AA4BFDAL, 0x096EA1C517D1327CL, 0xD56966B4361A6685L,
+ 0x277DA5C31221057DL, 0x94D59893A43ACFF7L, 0x64F0C51CCDC02281L,
+ 0x3D33BCC4FF6189DBL, 0xE005CB184CE66AF1L, 0xFF5CCD1D1DB99BEAL,
+ 0xB0B854A7FE42980FL, 0x7BD46A6A718D4B9FL, 0xD10FA8CC22A5FD8CL,
+ 0xD31484952BE4BD31L, 0xC7FA975FCB243847L, 0x4886ED1E5846C407L,
+ 0x28CDDB791EB70B04L, 0xC2B00BE2F573417FL, 0x5C9590452180F877L,
+ 0x7A6BDDFFF370EB00L, 0xCE509E38D6D9D6A4L, 0xEBEB0F00647FA702L,
+ 0x1DCC06CF76606F06L, 0xE4D9F28BA286FF0AL, 0xD85A305DC918C262L,
+ 0x475B1D8732225F54L, 0x2D4FB51668CCB5FEL, 0xA679B9D9D72BBA20L,
+ 0x53841C0D912D43A5L, 0x3B7EAA48BF12A4E8L, 0x781E0E47F22F1DDFL,
+ 0xEFF20CE60AB50973L, 0x20D261D19DFFB742L, 0x16A12B03062A2E39L,
+ 0x1960EB2239650495L, 0x251C16FED50EB8B8L, 0x9AC0C330F826016EL,
+ 0xED152665953E7671L, 0x02D63194A6369570L, 0x5074F08394B1C987L,
+ 0x70BA598C90B25CE1L, 0x794A15810B9742F6L, 0x0D5925E9FCAF8C6CL,
+ 0x3067716CD868744EL, 0x910AB077E8D7731BL, 0x6A61BBDB5AC42F61L,
+ 0x93513EFBF0851567L, 0xF494724B9E83E9D5L, 0xE887E1985C09648DL,
+ 0x34B1D3C675370CFDL, 0xDC35E433BC0D255DL, 0xD0AAB84234131BE0L,
+ 0x08042A50B48B7EAFL, 0x9997C4EE44A3AB35L, 0x829A7B49201799D0L,
+ 0x263B8307B7C54441L, 0x752F95F4FD6A6CA6L, 0x927217402C08C6E5L,
+ 0x2A8AB754A795D9EEL, 0xA442F7552F72943DL, 0x2C31334E19781208L,
+ 0x4FA98D7CEAEE6291L, 0x55C3862F665DB309L, 0xBD0610175D53B1F3L,
+ 0x46FE6CB840413F27L, 0x3FE03792DF0CFA59L, 0xCFE700372EB85E8FL,
+ 0xA7BE29E7ADBCE118L, 0xE544EE5CDE8431DDL, 0x8A781B1B41F1873EL,
+ 0xA5C94C78A0D2F0E7L, 0x39412E2877B60728L, 0xA1265EF3AFC9A62CL,
+ 0xBCC2770C6A2506C5L, 0x3AB66DD5DCE1CE12L, 0xE65499D04A675B37L,
+ 0x7D8F523481BFD216L, 0x0F6F64FCEC15F389L, 0x74EFBE618B5B13C8L,
+ 0xACDC82B714273E1DL, 0xDD40BFE003199D17L, 0x37E99257E7E061F8L,
+ 0xFA52626904775AAAL, 0x8BBBF63A463D56F9L, 0xF0013F1543A26E64L,
+ 0xA8307E9F879EC898L, 0xCC4C27A4150177CCL, 0x1B432F2CCA1D3348L,
+ 0xDE1D1F8F9F6FA013L, 0x606602A047A7DDD6L, 0xD237AB64CC1CB2C7L,
+ 0x9B938E7225FCD1D3L, 0xEC4E03708E0FF476L, 0xFEB2FBDA3D03C12DL,
+ 0xAE0BCED2EE43889AL, 0x22CB8923EBFB4F43L, 0x69360D013CF7396DL,
+ 0x855E3602D2D4E022L, 0x073805BAD01F784CL, 0x33E17A133852F546L,
+ 0xDF4874058AC7B638L, 0xBA92B29C678AA14AL, 0x0CE89FC76CFAADCDL,
+ 0x5F9D4E0908339E34L, 0xF1AFE9291F5923B9L, 0x6E3480F60F4A265FL,
+ 0xEEBF3A2AB29B841CL, 0xE21938A88F91B4ADL, 0x57DFEFF845C6D3C3L,
+ 0x2F006B0BF62CAAF2L, 0x62F479EF6F75EE78L, 0x11A55AD41C8916A9L,
+ 0xF229D29084FED453L, 0x42F1C27B16B000E6L, 0x2B1F76749823C074L,
+ 0x4B76ECA3C2745360L, 0x8C98F463B91691BDL, 0x14BCC93CF1ADE66AL,
+ 0x8885213E6D458397L, 0x8E177DF0274D4711L, 0xB49B73B5503F2951L,
+ 0x10168168C3F96B6BL, 0x0E3D963B63CAB0AEL, 0x8DFC4B5655A1DB14L,
+ 0xF789F1356E14DE5CL, 0x683E68AF4E51DAC1L, 0xC9A84F9D8D4B0FD9L,
+ 0x3691E03F52A0F9D1L, 0x5ED86E46E1878E80L, 0x3C711A0E99D07150L,
+ 0x5A0865B20C4E9310L, 0x56FBFC1FE4F0682EL, 0xEA8D5DE3105EDF9BL,
+ 0x71ABFDB12379187AL, 0x2EB99DE1BEE77B9CL, 0x21ECC0EA33CF4523L,
+ 0x59A4D7521805C7A1L, 0x3896F5EB56AE7C72L, 0xAA638F3DB18F75DCL,
+ 0x9F39358DABE9808EL, 0xB7DEFA91C00B72ACL, 0x6B5541FD62492D92L,
+ 0x6DC6DEE8F92E4D5BL, 0x353F57ABC4BEEA7EL, 0x735769D6DA5690CEL,
+ 0x0A234AA642391484L, 0xF6F9508028F80D9DL, 0xB8E319A27AB3F215L,
+ 0x31AD9C1151341A4DL, 0x773C22A57BEF5805L, 0x45C7561A07968633L,
+ 0xF913DA9E249DBE36L, 0xDA652D9B78A64C68L, 0x4C27A97F3BC334EFL,
+ 0x76621220E66B17F4L, 0x967743899ACD7D0BL, 0xF3EE5BCAE0ED6782L,
+ 0x409F753600C879FCL, 0x06D09A39B5926DB6L, 0x6F83AEB0317AC588L,
+ 0x01E6CA4A86381F21L, 0x66FF3462D19F3025L, 0x72207C24DDFD3BFBL,
+ 0x4AF6B6D3E2ECE2EBL, 0x9C994DBEC7EA08DEL, 0x49ACE597B09A8BC4L,
+ 0xB38C4766CF0797BAL, 0x131B9373C57C2A75L, 0xB1822CCE61931E58L,
+ 0x9D7555B909BA1C0CL, 0x127FAFDD937D11D2L, 0x29DA3BADC66D92E4L,
+ 0xA2C1D57154C2ECBCL, 0x58C5134D82F6FE24L, 0x1C3AE3515B62274FL,
+ 0xE907C82E01CB8126L, 0xF8ED091913E37FCBL, 0x3249D8F9C80046C9L,
+ 0x80CF9BEDE388FB63L, 0x1881539A116CF19EL, 0x5103F3F76BD52457L,
+ 0x15B7E6F5AE47F7A8L, 0xDBD7C6DED47E9CCFL, 0x44E55C410228BB1AL,
+ 0xB647D4255EDB4E99L, 0x5D11882BB8AAFC30L, 0xF5098BBB29D3212AL,
+ 0x8FB5EA14E90296B3L, 0x677B942157DD025AL, 0xFB58E7C0A390ACB5L,
+ 0x89D3674C83BD4A01L, 0x9E2DA4DF4BF3B93BL, 0xFCC41E328CAB4829L,
+ 0x03F38C96BA582C52L, 0xCAD1BDBD7FD85DB2L, 0xBBB442C16082AE83L,
+ 0xB95FE86BA5DA9AB0L, 0xB22E04673771A93FL, 0x845358C9493152D8L,
+ 0xBE2A488697B4541EL, 0x95A2DC2DD38E6966L, 0xC02C11AC923C852BL,
+ 0x2388B1990DF2A87BL, 0x7C8008FA1B4F37BEL, 0x1F70D0C84D54E503L,
+ 0x5490ADEC7ECE57D4L, 0x002B3C27D9063A3AL, 0x7EAEA3848030A2BFL,
+ 0xC602326DED2003C0L, 0x83A7287D69A94086L, 0xC57A5FCB30F57A8AL,
+ 0xB56844E479EBE779L, 0xA373B40F05DCBCE9L, 0xD71A786E88570EE2L,
+ 0x879CBACDBDE8F6A0L, 0x976AD1BCC164A32FL, 0xAB21E25E9666D78BL,
+ 0x901063AAE5E5C33CL, 0x9818B34448698D90L, 0xE36487AE3E1E8ABBL,
+ 0xAFBDF931893BDCB4L, 0x6345A0DC5FBBD519L, 0x8628FE269B9465CAL,
+ 0x1E5D01603F9C51ECL, 0x4DE44006A15049B7L, 0xBF6C70E5F776CBB1L,
+ 0x411218F2EF552BEDL, 0xCB0C0708705A36A3L, 0xE74D14754F986044L,
+ 0xCD56D9430EA8280EL, 0xC12591D7535F5065L, 0xC83223F1720AEF96L,
+ 0xC3A0396F7363A51FL };
// The cached self-test result.
private static Boolean valid;
@@ -602,9 +436,6 @@ public class Tiger extends BaseHash
// The context.
private long a, b, c;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Trivial 0-arguments constructor.
*/
@@ -628,9 +459,6 @@ public class Tiger extends BaseHash
this.buffer = (that.buffer != null) ? (byte[]) that.buffer.clone() : null;
}
- // Instance methods implementing BaseHash.
- // -----------------------------------------------------------------------
-
public Object clone()
{
return new Tiger(this);
@@ -640,42 +468,39 @@ public class Tiger extends BaseHash
{
if (valid == null)
{
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new Tiger().digest())));
+ String d = Util.toString(new Tiger().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
}
return valid.booleanValue();
}
protected byte[] padBuffer()
{
- int n = (int) (count % BLOCK_SIZE);
+ int n = (int)(count % BLOCK_SIZE);
int padding = (n < 56) ? (56 - n) : (120 - n);
byte[] pad = new byte[padding + 8];
-
pad[0] = 1;
long bits = count << 3;
-
pad[padding++] = (byte) bits;
- pad[padding++] = (byte) (bits >>> 8);
- pad[padding++] = (byte) (bits >>> 16);
- pad[padding++] = (byte) (bits >>> 24);
- pad[padding++] = (byte) (bits >>> 32);
- pad[padding++] = (byte) (bits >>> 40);
- pad[padding++] = (byte) (bits >>> 48);
- pad[padding] = (byte) (bits >>> 56);
-
+ pad[padding++] = (byte)(bits >>> 8);
+ pad[padding++] = (byte)(bits >>> 16);
+ pad[padding++] = (byte)(bits >>> 24);
+ pad[padding++] = (byte)(bits >>> 32);
+ pad[padding++] = (byte)(bits >>> 40);
+ pad[padding++] = (byte)(bits >>> 48);
+ pad[padding ] = (byte)(bits >>> 56);
return pad;
}
protected byte[] getResult()
{
- return new byte[] { (byte) a, (byte) (a >>> 8), (byte) (a >>> 16),
- (byte) (a >>> 24), (byte) (a >>> 32), (byte) (a >>> 40),
- (byte) (a >>> 48), (byte) (a >>> 56), (byte) b,
- (byte) (b >>> 8), (byte) (b >>> 16), (byte) (b >>> 24),
- (byte) (b >>> 32), (byte) (b >>> 40), (byte) (b >>> 48),
- (byte) (b >>> 56), (byte) c, (byte) (c >>> 8),
- (byte) (c >>> 16), (byte) (c >>> 24), (byte) (c >>> 32),
- (byte) (c >>> 40), (byte) (c >>> 48), (byte) (c >>> 56) };
+ return new byte[] {
+ (byte) a, (byte)(a >>> 8), (byte)(a >>> 16), (byte)(a >>> 24),
+ (byte)(a >>> 32), (byte)(a >>> 40), (byte)(a >>> 48), (byte)(a >>> 56),
+ (byte) b, (byte)(b >>> 8), (byte)(b >>> 16), (byte)(b >>> 24),
+ (byte)(b >>> 32), (byte)(b >>> 40), (byte)(b >>> 48), (byte)(b >>> 56),
+ (byte) c, (byte)(c >>> 8), (byte)(c >>> 16), (byte)(c >>> 24),
+ (byte)(c >>> 32), (byte)(c >>> 40), (byte)(c >>> 48), (byte)(c >>> 56) };
}
protected void resetContext()
@@ -688,117 +513,153 @@ public class Tiger extends BaseHash
protected void transform(byte[] in, int offset)
{
long x0, x1, x2, x3, x4, x5, x6, x7;
-
- x0 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x1 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x2 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x3 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x4 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x5 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x6 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset++] & 0xFF) << 56);
- x7 = ((long) in[offset++] & 0xFF) | ((long) (in[offset++] & 0xFF) << 8)
- | ((long) (in[offset++] & 0xFF) << 16)
- | ((long) (in[offset++] & 0xFF) << 24)
- | ((long) (in[offset++] & 0xFF) << 32)
- | ((long) (in[offset++] & 0xFF) << 40)
- | ((long) (in[offset++] & 0xFF) << 48)
- | ((long) (in[offset] & 0xFF) << 56);
-
+ x0 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x1 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x2 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x3 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x4 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x5 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x6 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset++] & 0xFF) << 56);
+ x7 = ((long) in[offset++] & 0xFF)
+ | ((long) (in[offset++] & 0xFF) << 8)
+ | ((long) (in[offset++] & 0xFF) << 16)
+ | ((long) (in[offset++] & 0xFF) << 24)
+ | ((long) (in[offset++] & 0xFF) << 32)
+ | ((long) (in[offset++] & 0xFF) << 40)
+ | ((long) (in[offset++] & 0xFF) << 48)
+ | ((long) (in[offset ] & 0xFF) << 56);
// save_abc ::=
long aa = a, bb = b, cc = c;
-
// pass(aa, bb, cc, 5) ::=
cc ^= x0;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 5;
aa ^= x1;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 5;
bb ^= x2;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 5;
cc ^= x3;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 5;
aa ^= x4;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 5;
bb ^= x5;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 5;
cc ^= x6;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 5;
aa ^= x7;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 5;
-
// key_schedule ::=
x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5L;
x1 ^= x0;
@@ -816,57 +677,87 @@ public class Tiger extends BaseHash
x5 ^= x4;
x6 += x5;
x7 -= x6 ^ 0x0123456789ABCDEFL;
-
// pass(cc, aa, bb, 7) ::=
bb ^= x0;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 7;
cc ^= x1;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 7;
aa ^= x2;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 7;
bb ^= x3;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 7;
cc ^= x4;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 7;
aa ^= x5;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 7;
bb ^= x6;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 7;
cc ^= x7;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 7;
-
// key_schedule ::=
x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5L;
x1 ^= x0;
@@ -884,57 +775,87 @@ public class Tiger extends BaseHash
x5 ^= x4;
x6 += x5;
x7 -= x6 ^ 0x0123456789ABCDEFL;
-
// pass(bb,cc,aa,9) ::=
aa ^= x0;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 9;
bb ^= x1;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 9;
cc ^= x2;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 9;
aa ^= x3;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 9;
bb ^= x4;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 9;
cc ^= x5;
- aa -= T1[(int) cc & 0xff] ^ T2[(int) (cc >> 16) & 0xff]
- ^ T3[(int) (cc >> 32) & 0xff] ^ T4[(int) (cc >> 48) & 0xff];
- bb += T4[(int) (cc >> 8) & 0xff] ^ T3[(int) (cc >> 24) & 0xff]
- ^ T2[(int) (cc >> 40) & 0xff] ^ T1[(int) (cc >> 56) & 0xff];
+ aa -= T1[(int) cc & 0xff]
+ ^ T2[(int)(cc >> 16) & 0xff]
+ ^ T3[(int)(cc >> 32) & 0xff]
+ ^ T4[(int)(cc >> 48) & 0xff];
+ bb += T4[(int)(cc >> 8) & 0xff]
+ ^ T3[(int)(cc >> 24) & 0xff]
+ ^ T2[(int)(cc >> 40) & 0xff]
+ ^ T1[(int)(cc >> 56) & 0xff];
bb *= 9;
aa ^= x6;
- bb -= T1[(int) aa & 0xff] ^ T2[(int) (aa >> 16) & 0xff]
- ^ T3[(int) (aa >> 32) & 0xff] ^ T4[(int) (aa >> 48) & 0xff];
- cc += T4[(int) (aa >> 8) & 0xff] ^ T3[(int) (aa >> 24) & 0xff]
- ^ T2[(int) (aa >> 40) & 0xff] ^ T1[(int) (aa >> 56) & 0xff];
+ bb -= T1[(int) aa & 0xff]
+ ^ T2[(int)(aa >> 16) & 0xff]
+ ^ T3[(int)(aa >> 32) & 0xff]
+ ^ T4[(int)(aa >> 48) & 0xff];
+ cc += T4[(int)(aa >> 8) & 0xff]
+ ^ T3[(int)(aa >> 24) & 0xff]
+ ^ T2[(int)(aa >> 40) & 0xff]
+ ^ T1[(int)(aa >> 56) & 0xff];
cc *= 9;
bb ^= x7;
- cc -= T1[(int) bb & 0xff] ^ T2[(int) (bb >> 16) & 0xff]
- ^ T3[(int) (bb >> 32) & 0xff] ^ T4[(int) (bb >> 48) & 0xff];
- aa += T4[(int) (bb >> 8) & 0xff] ^ T3[(int) (bb >> 24) & 0xff]
- ^ T2[(int) (bb >> 40) & 0xff] ^ T1[(int) (bb >> 56) & 0xff];
+ cc -= T1[(int) bb & 0xff]
+ ^ T2[(int)(bb >> 16) & 0xff]
+ ^ T3[(int)(bb >> 32) & 0xff]
+ ^ T4[(int)(bb >> 48) & 0xff];
+ aa += T4[(int)(bb >> 8) & 0xff]
+ ^ T3[(int)(bb >> 24) & 0xff]
+ ^ T2[(int)(bb >> 40) & 0xff]
+ ^ T1[(int)(bb >> 56) & 0xff];
aa *= 9;
-
// feedforward ::=
a ^= aa;
b = bb - b;
diff --git a/libjava/classpath/gnu/java/security/hash/Whirlpool.java b/libjava/classpath/gnu/java/security/hash/Whirlpool.java
index b10fa53cd7f..89df5c51bf3 100644
--- a/libjava/classpath/gnu/java/security/hash/Whirlpool.java
+++ b/libjava/classpath/gnu/java/security/hash/Whirlpool.java
@@ -38,9 +38,12 @@ exception statement from your version. */
package gnu.java.security.hash;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
+import java.util.logging.Logger;
+
/**
* Whirlpool, a new 512-bit hashing function operating on messages less than
* 2 ** 256 bits in length. The function structure is designed according to the
@@ -59,18 +62,10 @@ import gnu.java.security.util.Util;
* <a href="mailto:vincent.rijmen@iaik.tugraz.at">Vincent Rijmen</a>.</li>
* </ol>
*/
-public final class Whirlpool extends BaseHash
+public final class Whirlpool
+ extends BaseHash
{
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 3;
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Whirlpool.class.getName());
private static final int BLOCK_SIZE = 64; // inner block size in bytes
/** The digest of the 0-bit long message. */
@@ -83,22 +78,22 @@ public final class Whirlpool extends BaseHash
/** Whirlpool S-box; p. 19. */
private static final String S_box = // p. 19 [WHIRLPOOL]
- "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152" +
- "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57" +
- "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85" +
- "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8" +
- "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333" +
- "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0" +
- "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE" +
- "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d" +
- "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF" +
- "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A" +
- "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c" +
- "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04" +
- "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB" +
- "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9" +
- "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1" +
- "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
+ "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152"
+ + "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57"
+ + "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85"
+ + "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8"
+ + "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333"
+ + "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0"
+ + "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE"
+ + "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d"
+ + "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF"
+ + "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A"
+ + "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c"
+ + "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04"
+ + "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB"
+ + "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9"
+ + "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1"
+ + "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
/** The 64-bit lookup tables; section 7.1 p. 13. */
private static final long[] T0 = new long[256];
@@ -130,12 +125,9 @@ public final class Whirlpool extends BaseHash
/** work area for holding block cipher's intermediate values. */
private long w0, w1, w2, w3, w4, w5, w6, w7;
- // Static code - to intialise lookup tables --------------------------------
-
static
{
long time = System.currentTimeMillis();
-
int ROOT = 0x11D; // para. 2.1 [WHIRLPOOL]
int i, r, j;
long s1, s2, s4, s5, s8, s9, t;
@@ -171,7 +163,6 @@ public final class Whirlpool extends BaseHash
T6[i] = t >>> 48 | t << 16;
T7[i] = t >>> 56 | t << 8;
}
-
for (r = 0, i = 0; r < R; )
rc[r++] = (T0[i++] & 0xFF00000000000000L)
^ (T1[i++] & 0x00FF000000000000L)
@@ -181,103 +172,91 @@ public final class Whirlpool extends BaseHash
^ (T5[i++] & 0x0000000000FF0000L)
^ (T6[i++] & 0x000000000000FF00L)
^ (T7[i++] & 0x00000000000000FFL);
-
time = System.currentTimeMillis() - time;
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println("==========");
- System.out.println();
- System.out.println("Static data");
- System.out.println();
-
- System.out.println();
- System.out.println("T0[]:");
+ log.fine("Static data");
+ log.fine("T0[]:");
+ StringBuilder sb;
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T0[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T0[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T1[]:");
+ log.fine("T1[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T1[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T1[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T2[]:");
+ log.fine("T2[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T2[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T2[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T3[]:");
+ log.fine("T3[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T3[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T3[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T4[]:");
+ log.fine("\nT4[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T4[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T4[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T5[]:");
+ log.fine("T5[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T6[]:");
+ log.fine("T6[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T7[]:");
+ log.fine("T7[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
+ sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", ");
- System.out.println();
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("rc[]:");
+ log.fine("rc[]:");
for (i = 0; i < R; i++)
- System.out.println("0x" + Util.toString(rc[i]));
-
- System.out.println();
+ log.fine("0x" + Util.toString(rc[i]));
- System.out.println();
- System.out.println("Total initialization time: " + time + " ms.");
- System.out.println();
+ log.fine("Total initialization time: " + time + " ms.");
}
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Whirlpool()
{
@@ -285,7 +264,7 @@ public final class Whirlpool extends BaseHash
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param md the instance to clone.
*/
@@ -305,21 +284,11 @@ public final class Whirlpool extends BaseHash
this.buffer = (byte[]) md.buffer.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return (new Whirlpool(this));
}
- // Implementation of concrete methods in BaseHash --------------------------
-
protected void transform(byte[] in, int offset)
{
// apply mu to the input
@@ -387,7 +356,6 @@ public final class Whirlpool extends BaseHash
| (in[offset++] & 0xFFL) << 16
| (in[offset++] & 0xFFL) << 8
| (in[offset++] & 0xFFL);
-
// transform K into the key schedule Kr; 0 <= r <= R
k00 = H0;
k01 = H1;
@@ -397,7 +365,6 @@ public final class Whirlpool extends BaseHash
k05 = H5;
k06 = H6;
k07 = H7;
-
nn0 = n0 ^ k00;
nn1 = n1 ^ k01;
nn2 = n2 ^ k02;
@@ -406,10 +373,8 @@ public final class Whirlpool extends BaseHash
nn5 = n5 ^ k05;
nn6 = n6 ^ k06;
nn7 = n7 ^ k07;
-
// intermediate cipher output
w0 = w1 = w2 = w3 = w4 = w5 = w6 = w7 = 0L;
-
for (int r = 0; r < R; r++)
{
// 1. compute intermediate round key schedule by applying ro[rc]
@@ -478,7 +443,6 @@ public final class Whirlpool extends BaseHash
^ T5[(int)((k02 >> 16) & 0xFFL)]
^ T6[(int)((k01 >> 8) & 0xFFL)]
^ T7[(int)( k00 & 0xFFL)];
-
k00 = Kr0;
k01 = Kr1;
k02 = Kr2;
@@ -487,7 +451,6 @@ public final class Whirlpool extends BaseHash
k05 = Kr5;
k06 = Kr6;
k07 = Kr7;
-
// 2. incrementally compute the cipher output
w0 = T0[(int)((nn0 >> 56) & 0xFFL)]
^ T1[(int)((nn7 >> 48) & 0xFFL)]
@@ -553,7 +516,6 @@ public final class Whirlpool extends BaseHash
^ T5[(int)((nn2 >> 16) & 0xFFL)]
^ T6[(int)((nn1 >> 8) & 0xFFL)]
^ T7[(int)( nn0 & 0xFFL)] ^ Kr7;
-
nn0 = w0;
nn1 = w1;
nn2 = w2;
@@ -563,7 +525,6 @@ public final class Whirlpool extends BaseHash
nn6 = w6;
nn7 = w7;
}
-
// apply the Miyaguchi-Preneel hash scheme
H0 ^= w0 ^ n0;
H1 ^= w1 ^ n1;
@@ -588,12 +549,9 @@ public final class Whirlpool extends BaseHash
// count + 33 + padding = 0 (mod BLOCK_SIZE)
int n = (int)((count + 33) % BLOCK_SIZE);
int padding = n == 0 ? 33 : BLOCK_SIZE - n + 33;
-
byte[] result = new byte[padding];
-
// padding is always binary 1 followed by binary 0s
result[0] = (byte) 0x80;
-
// save (right justified) the number of bits hashed
long bits = count * 8;
int i = padding - 8;
@@ -605,14 +563,13 @@ public final class Whirlpool extends BaseHash
result[i++] = (byte)(bits >>> 16);
result[i++] = (byte)(bits >>> 8);
result[i ] = (byte) bits;
-
return result;
}
protected byte[] getResult()
{
// apply inverse mu to the context
- byte[] result = new byte[] {
+ return new byte[] {
(byte)(H0 >>> 56), (byte)(H0 >>> 48), (byte)(H0 >>> 40), (byte)(H0 >>> 32),
(byte)(H0 >>> 24), (byte)(H0 >>> 16), (byte)(H0 >>> 8), (byte) H0,
(byte)(H1 >>> 56), (byte)(H1 >>> 48), (byte)(H1 >>> 40), (byte)(H1 >>> 32),
@@ -628,10 +585,8 @@ public final class Whirlpool extends BaseHash
(byte)(H6 >>> 56), (byte)(H6 >>> 48), (byte)(H6 >>> 40), (byte)(H6 >>> 32),
(byte)(H6 >>> 24), (byte)(H6 >>> 16), (byte)(H6 >>> 8), (byte) H6,
(byte)(H7 >>> 56), (byte)(H7 >>> 48), (byte)(H7 >>> 40), (byte)(H7 >>> 32),
- (byte)(H7 >>> 24), (byte)(H7 >>> 16), (byte)(H7 >>> 8), (byte) H7
- };
+ (byte)(H7 >>> 24), (byte)(H7 >>> 16), (byte)(H7 >>> 8), (byte) H7 };
- return result;
}
protected void resetContext()
@@ -642,8 +597,10 @@ public final class Whirlpool extends BaseHash
public boolean selfTest()
{
if (valid == null)
- valid = Boolean.valueOf(DIGEST0.equals(Util.toString(new Whirlpool().digest())));
-
+ {
+ String d = Util.toString(new Whirlpool().digest());
+ valid = Boolean.valueOf(DIGEST0.equals(d));
+ }
return valid.booleanValue();
}
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/HavalSpi.java b/libjava/classpath/gnu/java/security/jce/hash/HavalSpi.java
index 05595edeae8..159ba3dd8ff 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/HavalSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/HavalSpi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * The implementation of the <code>HAVAL</code> <i>Service Provider Interface</i>
- * (<b>SPI</b>) Adapter.<p>
+ * The implementation of the HAVAL <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class HavalSpi extends MessageDigestAdapter
+public class HavalSpi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public HavalSpi()
{
super(Registry.HAVAL_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/MD2Spi.java b/libjava/classpath/gnu/java/security/jce/hash/MD2Spi.java
index 001cbaf3c8e..268f2fa6941 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/MD2Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/MD2Spi.java
@@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the MD2 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the MD2 <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter.
*/
-public class MD2Spi extends MessageDigestAdapter
+public class MD2Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public MD2Spi()
{
super(Registry.MD2_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/MD4Spi.java b/libjava/classpath/gnu/java/security/jce/hash/MD4Spi.java
index 41fef87bf38..c050ef2df7f 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/MD4Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/MD4Spi.java
@@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the MD4 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the MD4 <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter.
*/
-public class MD4Spi extends MessageDigestAdapter
+public class MD4Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public MD4Spi()
{
super(Registry.MD4_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/MD5Spi.java b/libjava/classpath/gnu/java/security/jce/hash/MD5Spi.java
index aa1a8844e36..6297416940e 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/MD5Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/MD5Spi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD5 <i>Service Provider Interface</i> (<b>SPI</b>)
- * adapter.<p>
+ * adapter.
*/
-public class MD5Spi extends MessageDigestAdapter
+public class MD5Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public MD5Spi()
{
super(Registry.MD5_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/MessageDigestAdapter.java b/libjava/classpath/gnu/java/security/jce/hash/MessageDigestAdapter.java
index e30beca3df3..7342ee55123 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/MessageDigestAdapter.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/MessageDigestAdapter.java
@@ -46,35 +46,30 @@ import java.security.MessageDigestSpi;
/**
* The implementation of a generic {@link java.security.MessageDigest} adapter
- * class to wrap gnu.crypto hash instances.<p>
- *
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
- * {@link java.security.MessageDigest} class, which provides the functionality
- * of a message digest algorithm, such as MD5 or SHA. Message digests are secure
- * one-way hash functions that take arbitrary-sized data and output a fixed-
- * length hash value.<p>
- *
- * All the abstract methods in the {@link java.security.MessageDigestSpi} class
- * are implemented by this class and all its sub-classes.<p>
- *
+ * class to wrap GNU hash instances.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * the {@link java.security.MessageDigest} class, which provides the
+ * functionality of a message digest algorithm, such as MD5 or SHA. Message
+ * digests are secure one-way hash functions that take arbitrary-sized data and
+ * output a fixed-length hash value.
+ * <p>
+ * All the abstract methods in the {@link MessageDigestSpi} class are
+ * implemented by this class and all its sub-classes.
+ * <p>
* All the implementations which subclass this object, and which are serviced by
- * the GNU Crypto provider implement the {@link java.lang.Cloneable} interface.<p>
+ * the GNU provider implement the {@link Cloneable} interface.
*/
-class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
+class MessageDigestAdapter
+ extends MessageDigestSpi
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Our underlying hash instance. */
private IMessageDigest adaptee;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial protected constructor.
- *
+ *
* @param mdName the canonical name of the hash algorithm.
*/
protected MessageDigestAdapter(String mdName)
@@ -84,7 +79,7 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
/**
* Private constructor for cloning purposes.
- *
+ *
* @param adaptee a clone of the underlying hash algorithm instance.
*/
private MessageDigestAdapter(IMessageDigest adaptee)
@@ -94,12 +89,6 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
this.adaptee = adaptee;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // java.security.MessageDigestSpi interface implementation
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new MessageDigestAdapter((IMessageDigest) adaptee.clone());
@@ -130,9 +119,8 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
{
int result = adaptee.hashSize();
if (len < result)
- {
- throw new DigestException();
- }
+ throw new DigestException();
+
byte[] md = adaptee.digest();
System.arraycopy(md, 0, buf, offset, result);
return result;
diff --git a/libjava/classpath/gnu/java/security/jce/hash/RipeMD128Spi.java b/libjava/classpath/gnu/java/security/jce/hash/RipeMD128Spi.java
index 404214d91ba..159a1173c15 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/RipeMD128Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/RipeMD128Spi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD-128 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.<p>
+ * (<b>SPI</b>) adapter.
*/
-public class RipeMD128Spi extends MessageDigestAdapter
+public class RipeMD128Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RipeMD128Spi()
{
super(Registry.RIPEMD128_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/RipeMD160Spi.java b/libjava/classpath/gnu/java/security/jce/hash/RipeMD160Spi.java
index 841f46b3bc2..579ccb26f14 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/RipeMD160Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/RipeMD160Spi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD-160 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.<p>
+ * (<b>SPI</b>) adapter.
*/
-public class RipeMD160Spi extends MessageDigestAdapter
+public class RipeMD160Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RipeMD160Spi()
{
super(Registry.RIPEMD160_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/Sha160Spi.java b/libjava/classpath/gnu/java/security/jce/hash/Sha160Spi.java
index 41988438270..901cac19158 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/Sha160Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/Sha160Spi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the SHA-1 (160-bit) <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.<p>
+ * (<b>SPI</b>) adapter.
*/
-public class Sha160Spi extends MessageDigestAdapter
+public class Sha160Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha160Spi()
{
super(Registry.SHA160_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/Sha256Spi.java b/libjava/classpath/gnu/java/security/jce/hash/Sha256Spi.java
index f07e1894115..9d471e65a66 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/Sha256Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/Sha256Spi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-2-1 (256-bit) <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-2-1 (256-bit) <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class Sha256Spi extends MessageDigestAdapter
+public class Sha256Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha256Spi()
{
super(Registry.SHA256_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/Sha384Spi.java b/libjava/classpath/gnu/java/security/jce/hash/Sha384Spi.java
index fc17077e831..30d5fce09bc 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/Sha384Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/Sha384Spi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-2-2 (384-bit) <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-2-2 (384-bit) <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class Sha384Spi extends MessageDigestAdapter
+public class Sha384Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha384Spi()
{
super(Registry.SHA384_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/Sha512Spi.java b/libjava/classpath/gnu/java/security/jce/hash/Sha512Spi.java
index 0b4c3d62c65..a2d44ab2461 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/Sha512Spi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/Sha512Spi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-2-3 (512-bit) <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-2-3 (512-bit) <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class Sha512Spi extends MessageDigestAdapter
+public class Sha512Spi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha512Spi()
{
super(Registry.SHA512_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/TigerSpi.java b/libjava/classpath/gnu/java/security/jce/hash/TigerSpi.java
index 599437410e6..a21e5fe1081 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/TigerSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/TigerSpi.java
@@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the Tiger <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the Tiger <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class TigerSpi extends MessageDigestAdapter
+public class TigerSpi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public TigerSpi()
{
super(Registry.TIGER_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/hash/WhirlpoolSpi.java b/libjava/classpath/gnu/java/security/jce/hash/WhirlpoolSpi.java
index d1864bc7cd4..d7a7a4504d4 100644
--- a/libjava/classpath/gnu/java/security/jce/hash/WhirlpoolSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/hash/WhirlpoolSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Whirlpool <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.<p>
+ * (<b>SPI</b>) adapter.
*/
-public class WhirlpoolSpi extends MessageDigestAdapter
+public class WhirlpoolSpi
+ extends MessageDigestAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public WhirlpoolSpi()
{
super(Registry.WHIRLPOOL_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/HavalRandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/HavalRandomSpi.java
index 0c39a37fd1b..c3d4b941261 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/HavalRandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/HavalRandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the HAVAL-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) Adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class HavalRandomSpi extends SecureRandomAdapter
+public class HavalRandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public HavalRandomSpi()
{
super(Registry.HAVAL_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/MD2RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/MD2RandomSpi.java
index 72a7f4873e4..8ba286804e6 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/MD2RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/MD2RandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD2-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class MD2RandomSpi extends SecureRandomAdapter
+public class MD2RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public MD2RandomSpi()
{
super(Registry.MD2_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/MD4RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/MD4RandomSpi.java
index f5f98f8f39b..d4d182970c7 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/MD4RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/MD4RandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD4-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class MD4RandomSpi extends SecureRandomAdapter
+public class MD4RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public MD4RandomSpi()
{
super(Registry.MD4_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/MD5RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/MD5RandomSpi.java
index 0181247bc5e..be38add0a0d 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/MD5RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/MD5RandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD5-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class MD5RandomSpi extends SecureRandomAdapter
+public class MD5RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public MD5RandomSpi()
{
super(Registry.MD5_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/RipeMD128RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/RipeMD128RandomSpi.java
index 5580716a491..530c3ec2141 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/RipeMD128RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/RipeMD128RandomSpi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the RIPEMD128-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * The implementation of the RIPEMD128-based SecureRandom <i>Service Provider
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class RipeMD128RandomSpi extends SecureRandomAdapter
+public class RipeMD128RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RipeMD128RandomSpi()
{
super(Registry.RIPEMD128_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/RipeMD160RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/RipeMD160RandomSpi.java
index 734fe824a4c..6875cdfa91a 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/RipeMD160RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/RipeMD160RandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD160-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class RipeMD160RandomSpi extends SecureRandomAdapter
+public class RipeMD160RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RipeMD160RandomSpi()
{
super(Registry.RIPEMD160_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java b/libjava/classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java
index 70d30f15301..5be402ff005 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java
@@ -45,34 +45,28 @@ import java.security.SecureRandomSpi;
import java.util.Collections;
/**
- * <p>The implementation of a generic {@link java.security.SecureRandom} adapter
- * class to wrap gnu.crypto prng instances based on Message Digest algorithms.</p>
- *
- * <p>This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * The implementation of a generic {@link java.security.SecureRandom} adapter
+ * class to wrap GNU PRNG instances based on Message Digest algorithms.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link java.security.SecureRandom} class, which provides the
- * functionality of a cryptographically strong pseudo-random number generator.</p>
- *
- * <p>All the abstract methods in the {@link SecureRandomSpi} class are
- * implemented by this class and all its sub-classes.</p>
+ * functionality of a cryptographically strong pseudo-random number generator.
+ * <p>
+ * All the abstract methods in the {@link SecureRandomSpi} class are implemented
+ * by this class and all its sub-classes.
*/
-abstract class SecureRandomAdapter extends SecureRandomSpi
+abstract class SecureRandomAdapter
+ extends SecureRandomSpi
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Our underlying prng instance. */
private MDGenerator adaptee = new MDGenerator();
/** The name of the message digest algorithm used by the adaptee. */
private String mdName;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial protected constructor.</p>
- *
+ * Trivial protected constructor.
+ *
* @param mdName the canonical name of the underlying hash algorithm.
*/
protected SecureRandomAdapter(String mdName)
@@ -80,23 +74,14 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
super();
this.mdName = mdName;
- adaptee.init (Collections.singletonMap (MDGenerator.MD_NAME, mdName));
+ adaptee.init(Collections.singletonMap(MDGenerator.MD_NAME, mdName));
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.SecureRandomSpi interface implementation ------------------
-
public byte[] engineGenerateSeed(int numBytes)
{
if (numBytes < 1)
- {
- return new byte[0];
- }
+ return new byte[0];
+
byte[] result = new byte[numBytes];
this.engineNextBytes(result);
return result;
@@ -104,10 +89,8 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
public void engineNextBytes(byte[] bytes)
{
- if (!adaptee.isInitialised())
- {
- this.engineSetSeed(new byte[0]);
- }
+ if (! adaptee.isInitialised())
+ this.engineSetSeed(new byte[0]);
try
{
adaptee.nextBytes(bytes, 0, bytes.length);
@@ -119,6 +102,6 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
public void engineSetSeed(byte[] seed)
{
- adaptee.addRandomBytes (seed);
+ adaptee.addRandomBytes(seed);
}
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/Sha160RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/Sha160RandomSpi.java
index c93b02d3fb8..9fded67e0ce 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/Sha160RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/Sha160RandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the SHA1-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class Sha160RandomSpi extends SecureRandomAdapter
+public class Sha160RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha160RandomSpi()
{
super(Registry.SHA160_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/Sha256RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/Sha256RandomSpi.java
index 736996430e1..e3999ffe6e9 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/Sha256RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/Sha256RandomSpi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-256 based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-256 based SecureRandom <i>Service Provider
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class Sha256RandomSpi extends SecureRandomAdapter
+public class Sha256RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha256RandomSpi()
{
super(Registry.SHA256_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/Sha384RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/Sha384RandomSpi.java
index afbf19303c8..978c8fe38b2 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/Sha384RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/Sha384RandomSpi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-384 based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-384 based SecureRandom <i>Service Provider
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class Sha384RandomSpi extends SecureRandomAdapter
+public class Sha384RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha384RandomSpi()
{
super(Registry.SHA384_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/Sha512RandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/Sha512RandomSpi.java
index b2b33776008..a89e26f004e 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/Sha512RandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/Sha512RandomSpi.java
@@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
- * <p>The implementation of the SHA-512 based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.</p>
+ * The implementation of the SHA-512 based SecureRandom <i>Service Provider
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class Sha512RandomSpi extends SecureRandomAdapter
+public class Sha512RandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Sha512RandomSpi()
{
super(Registry.SHA512_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/TigerRandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/TigerRandomSpi.java
index b4795b98ecc..ba4b22fb892 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/TigerRandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/TigerRandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Tiger based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class TigerRandomSpi extends SecureRandomAdapter
+public class TigerRandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public TigerRandomSpi()
{
super(Registry.TIGER_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java b/libjava/classpath/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java
index f327f9df2c7..9d937e65f3e 100644
--- a/libjava/classpath/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java
@@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Whirlpool-based SecureRandom <i>Service Provider
- * Interface</i> (<b>SPI</b>) adapter.<p>
+ * Interface</i> (<b>SPI</b>) adapter.
*/
-public class WhirlpoolRandomSpi extends SecureRandomAdapter
+public class WhirlpoolRandomSpi
+ extends SecureRandomAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public WhirlpoolRandomSpi()
{
super(Registry.WHIRLPOOL_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/DSSKeyFactory.java b/libjava/classpath/gnu/java/security/jce/sig/DSSKeyFactory.java
index bb4d85c899d..7b57dba70a5 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/DSSKeyFactory.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/DSSKeyFactory.java
@@ -61,10 +61,11 @@ import java.security.spec.X509EncodedKeySpec;
/**
* DSA key factory.
- *
+ *
* @author Casey Marshall (rsdio@metastatic.org)
*/
-public class DSSKeyFactory extends KeyFactorySpi
+public class DSSKeyFactory
+ extends KeyFactorySpi
{
// implicit 0-arguments constructor
@@ -80,7 +81,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = spec.getY();
return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
}
-
if (keySpec instanceof X509EncodedKeySpec)
{
X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
@@ -93,12 +93,9 @@ public class DSSKeyFactory extends KeyFactorySpi
}
catch (RuntimeException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
@@ -114,7 +111,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = spec.getX();
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
-
if (keySpec instanceof PKCS8EncodedKeySpec)
{
PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
@@ -127,12 +123,9 @@ public class DSSKeyFactory extends KeyFactorySpi
}
catch (RuntimeException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
-
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
@@ -150,7 +143,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = dsaKey.getY();
return new DSAPublicKeySpec(y, p, q, g);
}
-
if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
{
if (key instanceof DSSPublicKey)
@@ -159,19 +151,16 @@ public class DSSKeyFactory extends KeyFactorySpi
byte[] encoded = dssKey.getEncoded(Registry.X509_ENCODING_ID);
return new X509EncodedKeySpec(encoded);
}
-
if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new X509EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (public) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (public) key specification");
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
-
if (key instanceof DSAPrivateKey)
{
if (keySpec.isAssignableFrom(DSAPrivateKeySpec.class))
@@ -183,7 +172,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = dsaKey.getX();
return new DSAPrivateKeySpec(x, p, q, g);
}
-
if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
{
if (key instanceof DSSPrivateKey)
@@ -192,19 +180,16 @@ public class DSSKeyFactory extends KeyFactorySpi
byte[] encoded = dssKey.getEncoded(Registry.PKCS8_ENCODING_ID);
return new PKCS8EncodedKeySpec(encoded);
}
-
if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new PKCS8EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (private) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (private) key specification");
}
-
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
-
throw new InvalidKeySpecException("Wrong key type or unsupported key specification");
}
@@ -222,7 +207,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = dsaKey.getY();
return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
}
-
if (key instanceof DSAPrivateKey)
{
DSAPrivateKey dsaKey = (DSAPrivateKey) key;
@@ -232,7 +216,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = dsaKey.getX();
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
-
throw new InvalidKeyException("Wrong key type");
}
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java b/libjava/classpath/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java
index 44503b26b9a..c4453810653 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java
@@ -52,33 +52,21 @@ import java.util.HashMap;
/**
* The implementation of a {@link java.security.KeyPairGenerator} adapter class
- * to wrap gnu.crypto DSS keypair generator instances.<p>
- *
- * In case the client does not explicitly initialize the KeyPairGenerator (via
- * a call to an <code>initialize()</code> method), the GNU Crypto provider
- * uses a default <i>modulus</i> size (keysize) of 1024 bits.<p>
+ * to wrap GNU DSS keypair generator instances.
+ * <p>
+ * In case the client does not explicitly initialize the KeyPairGenerator (via a
+ * call to an <code>initialize()</code> method), the GNU provider uses a
+ * default <i>modulus</i> size (keysize) of 1024 bits.
*/
-public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
- DSAKeyPairGenerator
+public class DSSKeyPairGeneratorSpi
+ extends KeyPairGeneratorAdapter
+ implements DSAKeyPairGenerator
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public DSSKeyPairGeneratorSpi()
{
super(Registry.DSS_KPG);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public void initialize(int keysize, SecureRandom random)
{
this.initialize(keysize, false, random);
@@ -90,43 +78,34 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
HashMap attributes = new HashMap();
if (params != null)
{
- if (!(params instanceof DSAParameterSpec))
+ if (! (params instanceof DSAParameterSpec))
throw new InvalidAlgorithmParameterException(
- "Parameters argument is not a non-null instance, or " +
- "sub-instance, of java.security.spec.DSAParameterSpec");
-
+ "Parameters argument is not a non-null instance, or "
+ + "sub-instance, of java.security.spec.DSAParameterSpec");
attributes.put(DSSKeyPairGenerator.DSS_PARAMETERS, params);
}
-
if (random != null)
- {
- attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
- }
+ attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
try
{
adaptee.setup(attributes);
}
catch (IllegalArgumentException x)
{
- InvalidAlgorithmParameterException y =
- new InvalidAlgorithmParameterException();
- y.initCause(x);
- throw y;
+ throw new InvalidAlgorithmParameterException(x.getMessage(), x);
}
}
- // java.security.interfaces.DSAKeyPairGenerator interface implementation -----
-
public void initialize(DSAParams params, SecureRandom random)
throws InvalidParameterException
{
if (params == null || !(params instanceof DSAParameterSpec))
throw new InvalidParameterException(
- "Parameters argument is either null or is not an instance, or " +
- "sub-instance, of java.security.spec.DSAParameterSpec");
+ "Parameters argument is either null or is not an instance, or "
+ + "sub-instance, of java.security.spec.DSAParameterSpec");
DSAParameterSpec spec = (DSAParameterSpec) params;
try
{
@@ -134,7 +113,7 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
}
catch (InvalidAlgorithmParameterException x)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}
@@ -144,22 +123,22 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
throws InvalidParameterException
{
HashMap attributes = new HashMap();
- attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, new Integer(modlen));
+ attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(modlen));
if (random != null)
attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(DSSKeyPairGenerator.USE_DEFAULTS,
- Boolean.valueOf(!genParams));
+ Boolean.valueOf(! genParams));
attributes.put(DSSKeyPairGenerator.STRICT_DEFAULTS, Boolean.TRUE);
attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
try
{
adaptee.setup(attributes);
}
catch (IllegalArgumentException x)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/DSSParameters.java b/libjava/classpath/gnu/java/security/jce/sig/DSSParameters.java
index ba1f414faea..eaccb009551 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/DSSParameters.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/DSSParameters.java
@@ -136,7 +136,6 @@ public class DSSParameters
if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME))
throw new IOException("Unknown or unsupported format: " + format);
}
-
engineInit(params);
}
@@ -191,7 +190,6 @@ public class DSSParameters
if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME))
throw new IOException("Unknown or unsupported format: " + format);
}
-
return engineGetEncoded();
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/DSSRawSignatureSpi.java b/libjava/classpath/gnu/java/security/jce/sig/DSSRawSignatureSpi.java
index a63c51afab8..9b20c03b110 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/DSSRawSignatureSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/DSSRawSignatureSpi.java
@@ -42,27 +42,15 @@ import gnu.java.security.Registry;
import gnu.java.security.sig.dss.DSSSignatureRawCodec;
/**
- * The implementation of <i>Service Provider Interface</i> (<b>SPI</b>) adapter
- * for the DSS (Digital Signature Standard) signature scheme, encoded and/or
- * decoded in RAW format.<p>
+ * The implementation of <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter for the DSS (Digital Signature Standard) signature scheme, encoded
+ * and/or decoded in RAW format.
*/
-public class DSSRawSignatureSpi extends SignatureAdapter
+public class DSSRawSignatureSpi
+ extends SignatureAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public DSSRawSignatureSpi()
{
super(Registry.DSS_SIG, new DSSSignatureRawCodec());
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java b/libjava/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java
index 60152c279fa..19ec088c555 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.jce.sig;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.key.dss.DSSPrivateKey;
import gnu.java.security.key.dss.DSSPublicKey;
@@ -79,11 +80,6 @@ public class EncodedKeyFactory
{
private static final Logger log = Logger.getLogger(EncodedKeyFactory.class.getName());
- // implicit 0-arguments constructor
-
- // Class methods
- // --------------------------------------------------------------------------
-
private static Object invokeConstructor(String className, Object[] params)
throws InvalidKeySpecException
{
@@ -96,21 +92,15 @@ public class EncodedKeyFactory
}
catch (InstantiationException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (IllegalAccessException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(y);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (InvocationTargetException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@@ -124,9 +114,7 @@ public class EncodedKeyFactory
}
catch (ClassNotFoundException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@@ -144,9 +132,7 @@ public class EncodedKeyFactory
}
catch (NoSuchMethodException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@@ -162,15 +148,11 @@ public class EncodedKeyFactory
}
catch (IllegalAccessException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (InvocationTargetException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@@ -184,20 +166,15 @@ public class EncodedKeyFactory
}
catch (NoSuchMethodException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
- // Instance methods
- // --------------------------------------------------------------------------
-
protected PublicKey engineGeneratePublic(KeySpec keySpec)
throws InvalidKeySpecException
{
- log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec);
PublicKey result = null;
if (keySpec instanceof DSAPublicKeySpec)
result = decodeDSSPublicKey((DSAPublicKeySpec) keySpec);
@@ -220,10 +197,10 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
- log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore",
- ignored);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore",
+ ignored);
}
-
if (! ok) // try RSA
try
{
@@ -232,24 +209,24 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
- log.log(Level.FINE,
- "Exception in GnuRSAPublicKey.valueOf(). Ignore",
- ignored);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE,
+ "Exception in GnuRSAPublicKey.valueOf(). Ignore",
+ ignored);
}
-
if (! ok) // try DH
result = decodeDHPublicKey(input);
}
-
- log.exiting(this.getClass().getName(), "engineGeneratePublic()", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGeneratePublic()", result);
return result;
}
protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
throws InvalidKeySpecException
{
- log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec);
PrivateKey result = null;
if (keySpec instanceof DSAPrivateKeySpec)
result = decodeDSSPrivateKey((DSAPrivateKeySpec) keySpec);
@@ -272,10 +249,10 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
- log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore",
- ignored);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore",
+ ignored);
}
-
if (! ok) // try RSA
try
{
@@ -284,16 +261,16 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
- log.log(Level.FINE,
- "Exception in GnuRSAPrivateKey.valueOf(). Ignore",
- ignored);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE,
+ "Exception in GnuRSAPrivateKey.valueOf(). Ignore",
+ ignored);
}
-
if (! ok) // try DH
result = decodeDHPrivateKey(input);
}
-
- log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result);
return result;
}
@@ -321,7 +298,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link DSAPublicKeySpec} to decode.
* @return an instance of {@link DSSPublicKey} constructed from the
- * information in the designated key-specification.
+ * information in the designated key-specification.
*/
private DSSPublicKey decodeDSSPublicKey(DSAPublicKeySpec spec)
{
@@ -335,7 +312,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link RSAPublicKeySpec} to decode.
* @return an instance of {@link GnuRSAPublicKey} constructed from the
- * information in the designated key-specification.
+ * information in the designated key-specification.
*/
private GnuRSAPublicKey decodeRSAPublicKey(RSAPublicKeySpec spec)
{
@@ -358,7 +335,7 @@ public class EncodedKeyFactory
BigInteger p = spec.getP();
BigInteger g = spec.getG();
BigInteger y = spec.getY();
- Object[] params = new Object[] {new Integer(Registry.X509_ENCODING_ID),
+ Object[] params = new Object[] {Integer.valueOf(Registry.X509_ENCODING_ID),
null, p, g, y};
Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPublicKey",
params);
@@ -384,7 +361,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link DSAPrivateKeySpec} to decode.
* @return an instance of {@link DSSPrivateKey} constructed from the
- * information in the designated key-specification.
+ * information in the designated key-specification.
*/
private PrivateKey decodeDSSPrivateKey(DSAPrivateKeySpec spec)
{
@@ -398,7 +375,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link RSAPrivateCrtKeySpec} to decode.
* @return an instance of {@link GnuRSAPrivateKey} constructed from the
- * information in the designated key-specification.
+ * information in the designated key-specification.
*/
private PrivateKey decodeRSAPrivateKey(RSAPrivateCrtKeySpec spec)
{
@@ -428,7 +405,7 @@ public class EncodedKeyFactory
BigInteger p = spec.getP();
BigInteger g = spec.getG();
BigInteger x = spec.getX();
- Object[] params = new Object[] {new Integer(Registry.PKCS8_ENCODING_ID),
+ Object[] params = new Object[] {Integer.valueOf(Registry.PKCS8_ENCODING_ID),
null, p, g, x};
Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPrivateKey",
params);
diff --git a/libjava/classpath/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java b/libjava/classpath/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java
index edf19f627e0..bcbbe477d1e 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java
@@ -49,36 +49,30 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* The implementation of a generic {@link java.security.KeyPairGenerator}
- * adapter class to wrap gnu.crypto keypair generator instances.<p>
- *
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
- * {@link java.security.KeyPairGenerator} class, which is used to generate pairs
- * of public and private keys.<p>
- *
+ * adapter class to wrap GNU keypair generator instances.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * the {@link java.security.KeyPairGenerator} class, which is used to generate
+ * pairs of public and private keys.
+ * <p>
* All the abstract methods in the {@link java.security.KeyPairGeneratorSpi}
- * class are implemented by this class and all its sub-classes.<p>
- *
- * In case the client does not explicitly initialize the KeyPairGenerator (via
- * a call to an <code>initialize()</code> method), the GNU Crypto provider
- * supplies (and document) default values to be used. For example, the GNU
- * Crypto provider uses a default <i>modulus</i> size (keysize) of 1024 bits for
- * the DSS (Digital Signature Standard) a.k.a <i>DSA</i>.<p>
+ * class are implemented by this class and all its sub-classes.
+ * <p>
+ * In case the client does not explicitly initialize the KeyPairGenerator (via a
+ * call to an <code>initialize()</code> method), the GNU provider supplies
+ * (and document) default values to be used. For example, the GNU provider uses
+ * a default <i>modulus</i> size (keysize) of 1024 bits for the DSS (Digital
+ * Signature Standard) a.k.a <i>DSA</i>.
*/
-public abstract class KeyPairGeneratorAdapter extends KeyPairGenerator
+public abstract class KeyPairGeneratorAdapter
+ extends KeyPairGenerator
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Our underlying keypair instance. */
protected IKeyPairGenerator adaptee;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial protected constructor.
- *
+ *
* @param kpgName the canonical name of the keypair generator algorithm.
*/
protected KeyPairGeneratorAdapter(String kpgName)
@@ -88,12 +82,6 @@ public abstract class KeyPairGeneratorAdapter extends KeyPairGenerator
this.adaptee = KeyPairGeneratorFactory.getInstance(kpgName);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // java.security.KeyPairGeneratorSpi interface implementation
- // -------------------------------------------------------------------------
-
public abstract void initialize(int keysize, SecureRandom random);
public abstract void initialize(AlgorithmParameterSpec params,
diff --git a/libjava/classpath/gnu/java/security/jce/sig/RSAKeyFactory.java b/libjava/classpath/gnu/java/security/jce/sig/RSAKeyFactory.java
index 674e2afb6a5..3ba49edc256 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/RSAKeyFactory.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/RSAKeyFactory.java
@@ -76,7 +76,6 @@ public class RSAKeyFactory
BigInteger e = spec.getPublicExponent();
return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
}
-
if (keySpec instanceof X509EncodedKeySpec)
{
X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
@@ -88,12 +87,9 @@ public class RSAKeyFactory
}
catch (RuntimeException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
@@ -114,16 +110,6 @@ public class RSAKeyFactory
return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
n, e, d, p, q, dP, dQ, qInv);
}
-
-// if (keySpec instanceof RSAPrivateKeySpec)
-// {
-// RSAPrivateKeySpec spec = (RSAPrivateKeySpec) keySpec;
-// BigInteger n = spec.getModulus();
-// BigInteger d = spec.getPrivateExponent();
-// return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
-// n, null, d, null, null, null, null, null);
-// }
-
if (keySpec instanceof PKCS8EncodedKeySpec)
{
PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
@@ -135,12 +121,9 @@ public class RSAKeyFactory
}
catch (RuntimeException x)
{
- InvalidKeySpecException y = new InvalidKeySpecException();
- y.initCause(x);
- throw y;
+ throw new InvalidKeySpecException(x.getMessage(), x);
}
}
-
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
@@ -156,7 +139,6 @@ public class RSAKeyFactory
BigInteger e = rsaKey.getPublicExponent();
return new RSAPublicKeySpec(n, e);
}
-
if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
{
if (key instanceof GnuRSAPublicKey)
@@ -171,13 +153,11 @@ public class RSAKeyFactory
byte[] encoded = key.getEncoded();
return new X509EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (public) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (public) key specification");
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
-
if ((key instanceof RSAPrivateCrtKey)
&& keySpec.isAssignableFrom(RSAPrivateCrtKeySpec.class))
{
@@ -192,7 +172,6 @@ public class RSAKeyFactory
BigInteger qInv = rsaKey.getCrtCoefficient();
return new RSAPrivateCrtKeySpec(n, e, d, p, q, dP, dQ, qInv);
}
-
if ((key instanceof RSAPrivateKey)
&& keySpec.isAssignableFrom(RSAPrivateKeySpec.class))
{
@@ -201,7 +180,6 @@ public class RSAKeyFactory
BigInteger d = rsaKey.getPrivateExponent();
return new RSAPrivateKeySpec(n, d);
}
-
if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
{
if (key instanceof GnuRSAPrivateKey)
@@ -210,17 +188,16 @@ public class RSAKeyFactory
byte[] encoded = rsaKey.getEncoded(Registry.PKCS8_ENCODING_ID);
return new PKCS8EncodedKeySpec(encoded);
}
-
if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new PKCS8EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (private) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (private) key specification");
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported key specification");
}
protected Key engineTranslateKey(Key key) throws InvalidKeyException
@@ -235,7 +212,6 @@ public class RSAKeyFactory
BigInteger e = rsaKey.getPublicExponent();
return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
}
-
if (key instanceof RSAPrivateCrtKey)
{
RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
@@ -250,16 +226,6 @@ public class RSAKeyFactory
return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
n, e, d, p, q, dP, dQ, qInv);
}
-
-// if (key instanceof RSAPrivateKey)
-// {
-// RSAPrivateKey rsaKey = (RSAPrivateKey) key;
-// BigInteger n = rsaKey.getModulus();
-// BigInteger d = rsaKey.getPrivateExponent();
-// return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
-// n, null, d, null, null, null, null, null);
-// }
-
throw new InvalidKeyException("Unsupported key type");
}
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java b/libjava/classpath/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java
index 24dc7c50177..ef53b81159c 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java
@@ -49,43 +49,29 @@ import java.util.HashMap;
/**
* The implementation of a {@link java.security.KeyPairGenerator} adapter class
- * to wrap gnu.crypto RSA keypair generator instances.<p>
- *
- * In case the client does not explicitly initialize the KeyPairGenerator (via
- * a call to an <code>initialize()</code> method), the GNU Crypto provider
- * uses a default <i>modulus</i> size (keysize) of 1024 bits.<p>
+ * to wrap GNU RSA keypair generator instances.
+ * <p>
+ * In case the client does not explicitly initialize the KeyPairGenerator (via a
+ * call to an <code>initialize()</code> method), the GNU provider uses a
+ * default <i>modulus</i> size (keysize) of 1024 bits.
*/
-public class RSAKeyPairGeneratorSpi extends KeyPairGeneratorAdapter
+public class RSAKeyPairGeneratorSpi
+ extends KeyPairGeneratorAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RSAKeyPairGeneratorSpi()
{
super(Registry.RSA_KPG);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public void initialize(int keysize, SecureRandom random)
{
HashMap attributes = new HashMap();
- attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, new Integer(keysize));
+ attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(keysize));
if (random != null)
- {
- attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
- }
+ attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
@@ -95,21 +81,16 @@ public class RSAKeyPairGeneratorSpi extends KeyPairGeneratorAdapter
HashMap attributes = new HashMap();
if (params != null)
{
- if (!(params instanceof RSAKeyGenParameterSpec))
- {
- throw new InvalidAlgorithmParameterException("params");
- }
+ if (! (params instanceof RSAKeyGenParameterSpec))
+ throw new InvalidAlgorithmParameterException("params");
attributes.put(RSAKeyPairGenerator.RSA_PARAMETERS, params);
}
-
if (random != null)
- {
- attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
- }
+ attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java b/libjava/classpath/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java
index f3548d884d6..f1ccbde4dc2 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java
@@ -42,26 +42,15 @@ import gnu.java.security.Registry;
import gnu.java.security.sig.rsa.RSAPSSSignatureRawCodec;
/**
- * The implementation of <i>Service Provider Interface</i> (<b>SPI</b>) adapter
- * for the RSA-PSS signature scheme, encoded and/or decoded in RAW format.<p>
+ * The implementation of <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter for the RSA-PSS signature scheme, encoded and/or decoded in RAW
+ * format.
*/
-public class RSAPSSRawSignatureSpi extends SignatureAdapter
+public class RSAPSSRawSignatureSpi
+ extends SignatureAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RSAPSSRawSignatureSpi()
{
super(Registry.RSA_PSS_SIG, new RSAPSSSignatureRawCodec());
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/jce/sig/SignatureAdapter.java b/libjava/classpath/gnu/java/security/jce/sig/SignatureAdapter.java
index 4dcbe78e570..a65d727eed3 100644
--- a/libjava/classpath/gnu/java/security/jce/sig/SignatureAdapter.java
+++ b/libjava/classpath/gnu/java/security/jce/sig/SignatureAdapter.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.jce.sig;
+import gnu.java.security.Configuration;
import gnu.java.security.sig.BaseSignature;
import gnu.java.security.sig.ISignature;
import gnu.java.security.sig.ISignatureCodec;
@@ -57,38 +58,34 @@ import java.util.logging.Logger;
/**
* The implementation of a generic {@link java.security.Signature} adapter class
- * to wrap gnu.crypto signature instances.<p>
- *
- * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
- * {@link java.security.Signature} class, which provides the functionality of a
- * digital signature algorithm. Digital signatures are used for authentication
- * and integrity assurance of digital data.<p>
- *
- * All the abstract methods in the {@link java.security.SignatureSpi} class are
- * implemented by this class and all its sub-classes.<p>
- *
+ * to wrap GNU signature instances.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * the {@link java.security.Signature} class, which provides the functionality
+ * of a digital signature algorithm. Digital signatures are used for
+ * authentication and integrity assurance of digital data.
+ * <p>
+ * All the abstract methods in the {@link SignatureSpi} class are implemented by
+ * this class and all its sub-classes.
+ * <p>
* All the implementations which subclass this object, and which are serviced by
- * the GNU Crypto provider implement the {@link java.lang.Cloneable} interface.<p>
+ * the GNU provider implement the {@link Cloneable} interface.
*/
-class SignatureAdapter extends SignatureSpi implements Cloneable
+class SignatureAdapter
+ extends SignatureSpi
+ implements Cloneable
{
private static final Logger log = Logger.getLogger(SignatureAdapter.class.getName());
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Our underlying signature instance. */
private ISignature adaptee;
/** Our underlying signature encoder/decoder engine. */
private ISignatureCodec codec;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * Trivial protected constructor.<p>
- *
+ * Trivial protected constructor.
+ *
* @param sigName the canonical name of the signature scheme.
* @param codec the signature codec engine to use with this scheme.
*/
@@ -98,8 +95,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
/**
- * Private constructor for cloning purposes.<p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param adaptee a clone of the underlying signature scheme instance.
* @param codec the signature codec engine to use with this scheme.
*/
@@ -111,12 +108,6 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
this.codec = codec;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // java.security.SignatureSpi interface implementation
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new SignatureAdapter((ISignature) adaptee.clone(), codec);
@@ -132,7 +123,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
- throw new InvalidKeyException(String.valueOf(x));
+ throw new InvalidKeyException(x.getMessage(), x);
}
}
@@ -146,7 +137,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
- throw new InvalidKeyException(String.valueOf(x));
+ throw new InvalidKeyException(x.getMessage(), x);
}
}
@@ -162,7 +153,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
- throw new InvalidKeyException(String.valueOf(x));
+ throw new InvalidKeyException(x.getMessage(), x);
}
}
@@ -174,7 +165,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
- throw new SignatureException(String.valueOf(x));
+ throw new SignatureException(x.getMessage(), x);
}
}
@@ -187,7 +178,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
- throw new SignatureException(String.valueOf(x));
+ throw new SignatureException(x.getMessage(), x);
}
}
@@ -200,9 +191,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
- throw new SignatureException(String.valueOf(x));
+ throw new SignatureException(x.getMessage(), x);
}
-
byte[] result = codec.encodeSignature(signature);
return result;
}
@@ -213,9 +203,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
byte[] signature = this.engineSign();
int result = signature.length;
if (result > len)
- {
- throw new SignatureException("len");
- }
+ throw new SignatureException("Not enough room to store signature");
System.arraycopy(signature, 0, outbuf, offset, result);
return result;
@@ -223,8 +211,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
public boolean engineVerify(byte[] sigBytes) throws SignatureException
{
- log.entering("SignatureAdapter", "engineVerify");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineVerify");
Object signature = codec.decodeSignature(sigBytes);
boolean result = false;
try
@@ -233,10 +221,11 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
- throw new SignatureException(String.valueOf(x));
+ throw new SignatureException(x.getMessage(), x);
}
-
- log.exiting("SignatureAdapter", "engineVerify", new Boolean(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineVerify",
+ Boolean.valueOf(result));
return result;
}
diff --git a/libjava/classpath/gnu/java/security/key/IKeyPairCodec.java b/libjava/classpath/gnu/java/security/key/IKeyPairCodec.java
index 965a317d4ff..f09743d2b60 100644
--- a/libjava/classpath/gnu/java/security/key/IKeyPairCodec.java
+++ b/libjava/classpath/gnu/java/security/key/IKeyPairCodec.java
@@ -44,16 +44,13 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>The visible methods of an object that knows how to encode and decode
+ * The visible methods of an object that knows how to encode and decode
* cryptographic asymmetric keypairs. Codecs are useful for (a) externalising
* public and private keys for storage and on-the-wire transmission, as well as
- * (b) re-creating their internal Java representation from external sources.</p>
+ * (b) re-creating their internal Java representation from external sources.
*/
public interface IKeyPairCodec
{
- // Constants
- // -------------------------------------------------------------------------
-
/** Constant identifying the <i>Raw</i> encoding format. */
int RAW_FORMAT = Registry.RAW_ENCODING_ID;
@@ -69,62 +66,59 @@ public interface IKeyPairCodec
*/
int ASN1_FORMAT = Registry.ASN1_ENCODING_ID;
- // Method(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the unique identifier (within this library) of the format used
- * to externalise public and private keys.</p>
- *
+ * Returns the unique identifier (within this library) of the format used to
+ * externalise public and private keys.
+ *
* @return the identifier of the format, the object supports.
*/
int getFormatID();
/**
- * <p>Encodes an instance of a public key for storage or transmission purposes.</p>
- *
+ * Encodes an instance of a public key for storage or transmission purposes.
+ *
* @param key the non-null key to encode.
* @return a byte sequence representing the encoding of the designated key
- * according to the format supported by this codec.
+ * according to the format supported by this codec.
* @exception IllegalArgumentException if the designated key is not supported
- * by this codec.
+ * by this codec.
*/
byte[] encodePublicKey(PublicKey key);
/**
- * <p>Encodes an instance of a private key for storage or transmission purposes.</p>
- *
+ * Encodes an instance of a private key for storage or transmission purposes.
+ *
* @param key the non-null key to encode.
* @return a byte sequence representing the encoding of the designated key
- * according to the format supported by this codec.
+ * according to the format supported by this codec.
* @exception IllegalArgumentException if the designated key is not supported
- * by this codec.
+ * by this codec.
*/
byte[] encodePrivateKey(PrivateKey key);
/**
- * <p>Decodes an instance of an external public key into its native Java
- * representation.</p>
- *
+ * Decodes an instance of an external public key into its native Java
+ * representation.
+ *
* @param input the source of the externalised key to decode.
* @return a concrete instance of a public key, reconstructed from the
- * designated input.
+ * designated input.
* @exception IllegalArgumentException if the designated input does not
- * contain a known representation of a public key for the format supported by
- * the concrete codec.
+ * contain a known representation of a public key for the format
+ * supported by the concrete codec.
*/
PublicKey decodePublicKey(byte[] input);
/**
- * <p>Decodes an instance of an external private key into its native Java
- * representation.</p>
- *
+ * Decodes an instance of an external private key into its native Java
+ * representation.
+ *
* @param input the source of the externalised key to decode.
* @return a concrete instance of a private key, reconstructed from the
- * designated input.
+ * designated input.
* @exception IllegalArgumentException if the designated input does not
- * contain a known representation of a private key for the format supported
- * by the concrete codec.
+ * contain a known representation of a private key for the format
+ * supported by the concrete codec.
*/
PrivateKey decodePrivateKey(byte[] input);
}
diff --git a/libjava/classpath/gnu/java/security/key/IKeyPairGenerator.java b/libjava/classpath/gnu/java/security/key/IKeyPairGenerator.java
index 2e0b299286b..8d7842e935f 100644
--- a/libjava/classpath/gnu/java/security/key/IKeyPairGenerator.java
+++ b/libjava/classpath/gnu/java/security/key/IKeyPairGenerator.java
@@ -42,38 +42,31 @@ import java.security.KeyPair;
import java.util.Map;
/**
- * The visible methods of every asymmetric keypair generator.<p>
+ * The visible methods of every asymmetric keypair generator.
*/
public interface IKeyPairGenerator
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * Returns the canonical name of this keypair generator.<p>
- *
+ * Returns the canonical name of this keypair generator.
+ *
* @return the canonical name of this instance.
*/
String name();
/**
- * [Re]-initialises this instance for use with a given set of attributes.<p>
- *
+ * [Re]-initialises this instance for use with a given set of attributes.
+ *
* @param attributes a map of name/value pairs to use for setting up the
- * instance.
+ * instance.
* @exception IllegalArgumentException if at least one of the mandatory
- * attributes is missing or an invalid value was specified.
+ * attributes is missing or an invalid value was specified.
*/
void setup(Map attributes);
/**
* Generates a new keypair based on the attributes used to configure the
* instance.
- *
+ *
* @return a new keypair.
*/
KeyPair generate();
diff --git a/libjava/classpath/gnu/java/security/key/KeyPairCodecFactory.java b/libjava/classpath/gnu/java/security/key/KeyPairCodecFactory.java
index 1a8b8aa0388..e68a7d65c3a 100644
--- a/libjava/classpath/gnu/java/security/key/KeyPairCodecFactory.java
+++ b/libjava/classpath/gnu/java/security/key/KeyPairCodecFactory.java
@@ -207,10 +207,8 @@ public class KeyPairCodecFactory
hs.add(Registry.RSA_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME);
hs.add(Registry.DH_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
hs.add(Registry.SRP_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
-
names = Collections.unmodifiableSet(hs);
}
-
return names;
}
diff --git a/libjava/classpath/gnu/java/security/key/KeyPairGeneratorFactory.java b/libjava/classpath/gnu/java/security/key/KeyPairGeneratorFactory.java
index 8c2f348c9c7..4872fc3d1a1 100644
--- a/libjava/classpath/gnu/java/security/key/KeyPairGeneratorFactory.java
+++ b/libjava/classpath/gnu/java/security/key/KeyPairGeneratorFactory.java
@@ -48,68 +48,48 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>A Factory to instantiate asymmetric keypair generators.</p>
+ * A Factory to instantiate asymmetric keypair generators.
*/
public class KeyPairGeneratorFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private KeyPairGeneratorFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a keypair generator given its name.</p>
- *
+ * Returns an instance of a keypair generator given its name.
+ *
* @param name the case-insensitive key generator name.
- * @return an instance of the keypair generator, or <code>null</code> if none
- * found.
+ * @return an instance of the keypair generator, or <code>null</code> if
+ * none found.
*/
public static IKeyPairGenerator getInstance(String name)
{
if (name == null)
- {
- return null;
- }
+ return null;
name = name.trim();
IKeyPairGenerator result = null;
if (name.equalsIgnoreCase(Registry.DSA_KPG)
|| name.equalsIgnoreCase(Registry.DSS_KPG))
- {
- result = new DSSKeyPairGenerator();
- }
+ result = new DSSKeyPairGenerator();
else if (name.equalsIgnoreCase(Registry.RSA_KPG))
- {
- result = new RSAKeyPairGenerator();
- }
+ result = new RSAKeyPairGenerator();
else if (name.equalsIgnoreCase(Registry.DH_KPG))
- {
- result = makeInstance ("gnu.javax.crypto.key.dh.GnuDHKeyPairGenerator");
- }
+ result = makeInstance("gnu.javax.crypto.key.dh.GnuDHKeyPairGenerator");
else if (name.equalsIgnoreCase(Registry.SRP_KPG))
- {
- result = makeInstance ("gnu.javax.crypto.key.srp6.SRPKeyPairGenerator");
- }
+ result = makeInstance("gnu.javax.crypto.key.srp6.SRPKeyPairGenerator");
return result;
}
/**
- * <p>Returns a {@link Set} of keypair generator names supported by this
+ * Returns a {@link Set} of keypair generator names supported by this
* <i>Factory</i>. Those keypair generators may be used in conjunction with
- * the digital signature schemes with appendix supported by this library.</p>
- *
+ * the digital signature schemes with appendix supported by this library.
+ *
* @return a {@link Set} of keypair generator names (Strings).
*/
public static final Set getNames()
@@ -120,26 +100,21 @@ public class KeyPairGeneratorFactory
hs.add(Registry.RSA_KPG);
hs.add(Registry.DH_KPG);
hs.add(Registry.SRP_KPG);
-
return Collections.unmodifiableSet(hs);
}
- private static IKeyPairGenerator makeInstance (String clazz)
+ private static IKeyPairGenerator makeInstance(String clazz)
{
try
{
- Class c = Class.forName (clazz);
- Constructor ctor = c.getConstructor (new Class[0]);
- return (IKeyPairGenerator) ctor.newInstance (new Object[0]);
+ Class c = Class.forName(clazz);
+ Constructor ctor = c.getConstructor(new Class[0]);
+ return (IKeyPairGenerator) ctor.newInstance(new Object[0]);
}
catch (Exception x)
{
throw new IllegalArgumentException(
- "strong crypto key pair generator not available: " + clazz,
- x);
+ "strong crypto key pair generator not available: " + clazz, x);
}
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSKey.java b/libjava/classpath/gnu/java/security/key/dss/DSSKey.java
index 40aaea89352..657de8dd02d 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSKey.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSKey.java
@@ -38,74 +38,77 @@ 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;
import java.security.spec.DSAParameterSpec;
/**
- * <p>A base asbtract class for both public and private DSS (Digital Signature
+ * A base asbtract class for both public and private DSS (Digital Signature
* Standard) keys. It encapsulates the three DSS numbers: <code>p</code>,
- * <code>q</code> and <code>g</code>.</p>
- *
- * <p>According to the JDK, cryptographic <i>Keys</i> all have a <i>format</i>.
+ * <code>q</code> and <code>g</code>.
+ * <p>
+ * According to the JDK, cryptographic <i>Keys</i> all have a <i>format</i>.
* The format used in this implementation is called <i>Raw</i>, and basically
* consists of the raw byte sequences of algorithm parameters. The exact order
- * of the byte sequences and the implementation details are given in each of
- * the relevant <code>getEncoded()</code> methods of each of the private and
- * public keys.</p>
- *
+ * of the byte sequences and the implementation details are given in each of the
+ * relevant <code>getEncoded()</code> methods of each of the private and
+ * public keys.
+ * <p>
+ * <b>IMPORTANT</b>: Under certain circumstances (e.g. in an X.509 certificate
+ * with inherited AlgorithmIdentifier's parameters of a SubjectPublicKeyInfo
+ * element) these three MPIs may be <code>null</code>.
+ *
* @see DSSPrivateKey#getEncoded
* @see DSSPublicKey#getEncoded
*/
-public abstract class DSSKey implements Key, DSAKey
+public abstract class DSSKey
+ implements Key, DSAKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * A prime modulus, where <code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup></code>
- * for <code>512 &lt;= L &lt;= 1024</code> and <code>L</code> a multiple of
+ * A prime modulus, where
+ * <code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup></code> for
+ * <code>512 &lt;= L &lt;= 1024</code> and <code>L</code> a multiple of
* <code>64</code>.
*/
protected final BigInteger p;
/**
- * A prime divisor of <code>p - 1</code>, where <code>2<sup>159</sup> &lt; q
+ * A prime divisor of <code>p - 1</code>, where
+ * <code>2<sup>159</sup> &lt; q
* &lt; 2<sup>160</sup></code>.
*/
protected final BigInteger q;
/**
- * <code>g = h<sup>(p-1)</sup>/q mod p</code>, where <code>h</code> is any
- * integer with <code>1 &lt; h &lt; p - 1</code> such that <code>h<sup>
- * (p-1)</sup>/q mod p > 1</code> (<code>g</code> has order <code>q mod p
+ * <code>g = h<sup>(p-1)</sup>/q mod p</code>, where <code>h</code> is
+ * any integer with <code>1 &lt; h &lt; p - 1</code> such that <code>h<sup>
+ * (p-1)</sup>/q mod p > 1</code> (<code>g</code>
+ * has order <code>q mod p
* </code>).
*/
protected final BigInteger g;
/**
- * Identifier of the default encoding format to use when externalizing the
- * key material.
+ * Identifier of the default encoding format to use when externalizing the key
+ * material.
*/
protected final int defaultFormat;
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial protected constructor.
*
* @param defaultFormat the identifier of the encoding format to use by
- * default when externalizing the key.
+ * default when externalizing the key.
* @param p the DSS parameter <code>p</code>.
* @param q the DSS parameter <code>q</code>.
* @param g the DSS parameter <code>g</code>.
@@ -121,21 +124,11 @@ public abstract class DSSKey implements Key, DSAKey
this.g = g;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.interfaces.DSAKey interface implementation ----------------
-
public DSAParams getParams()
{
return new DSAParameterSpec(p, q, g);
}
- // java.security.Key interface implementation ------------------------------
-
public String getAlgorithm()
{
return Registry.DSS_KPG;
@@ -152,27 +145,31 @@ public abstract class DSSKey implements Key, DSAKey
return FormatUtil.getEncodingShortName(defaultFormat);
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
+ * Returns <code>true</code> if the designated object is an instance of
* {@link DSAKey} and has the same DSS (Digital Signature Standard) parameter
- * values as this one.</p>
- *
+ * values as this one.
+ * <p>
+ * Always returns <code>false</code> if the MPIs of this key are
+ * <i>inherited</i>. This may be the case when the key is re-constructed from
+ * an X.509 certificate with absent or NULL AlgorithmIdentifier's parameters
+ * field.
+ *
* @param obj the other non-null DSS key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
+ if (hasInheritedParameters())
+ return false;
+
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof DSAKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof DSAKey))
+ return false;
+
DSAKey that = (DSAKey) obj;
return p.equals(that.getParams().getP())
&& q.equals(that.getParams().getQ())
@@ -183,19 +180,32 @@ public abstract class DSSKey implements Key, DSAKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
- str = new StringBuilder().append(ls)
- .append("defaultFormat=").append(defaultFormat).append(",").append(ls)
- .append("p=0x").append(p.toString(16)).append(",").append(ls)
- .append("q=0x").append(q.toString(16)).append(",").append(ls)
- .append("g=0x").append(g.toString(16))
- .toString();
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
+ StringBuilder sb = new StringBuilder(ls)
+ .append("defaultFormat=").append(defaultFormat).append(",")
+ .append(ls);
+ if (hasInheritedParameters())
+ sb.append("p=inherited,").append(ls)
+ .append("q=inherited,").append(ls)
+ .append("g=inherited");
+ else
+ sb.append("p=0x").append(p.toString(16)).append(",").append(ls)
+ .append("q=0x").append(q.toString(16)).append(",").append(ls)
+ .append("g=0x").append(g.toString(16));
+ str = sb.toString();
}
-
return str;
}
- // abstract methods to be implemented by subclasses ------------------------
-
public abstract byte[] getEncoded(int format);
+
+ /**
+ * @return <code>true</code> if <code>p</code>, <code>q</code> and
+ * <code>g</code> are all <code>null</code>. Returns
+ * <code>false</code> otherwise.
+ */
+ public boolean hasInheritedParameters()
+ {
+ return p == null && q == null && g == null;
+ }
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java
index 5aa746147eb..1bad0b62ed6 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.java.security.key.dss;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.hash.Sha160;
import gnu.java.security.key.IKeyPairGenerator;
import gnu.java.security.util.PRNG;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.PrivateKey;
@@ -51,76 +51,57 @@ import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.spec.DSAParameterSpec;
import java.util.Map;
+import java.util.logging.Logger;
/**
- * <p>A key-pair generator for asymetric keys to use in conjunction with the DSS
- * (Digital Signature Standard).</p>
- *
- * References:<br>
+ * A key-pair generator for asymetric keys to use in conjunction with the DSS
+ * (Digital Signature Standard).
+ * <p>
+ * References:
+ * <p>
* <a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital Signature
- * Standard (DSS)</a>, Federal Information Processing Standards Publication 186.
- * National Institute of Standards and Technology.
+ * Standard (DSS)</a>, Federal Information Processing Standards Publication
+ * 186. National Institute of Standards and Technology.
*/
-public class DSSKeyPairGenerator implements IKeyPairGenerator
+public class DSSKeyPairGenerator
+ implements IKeyPairGenerator
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "dss";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 5;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(DSSKeyPairGenerator.class.getName());
/** The BigInteger constant 2. */
- private static final BigInteger TWO = new BigInteger("2");
+ private static final BigInteger TWO = BigInteger.valueOf(2L);
/** Property name of the length (Integer) of the modulus (p) of a DSS key. */
public static final String MODULUS_LENGTH = "gnu.crypto.dss.L";
/**
* Property name of the Boolean indicating wether or not to use default pre-
- * computed values of <code>p</code>, <code>q</code> and <code>g</code> for
- * a given modulus length. The ultimate behaviour of this generator with
+ * computed values of <code>p</code>, <code>q</code> and <code>g</code>
+ * for a given modulus length. The ultimate behaviour of this generator with
* regard to using pre-computed parameter sets will depend on the value of
* this property and of the following one {@link #STRICT_DEFAULTS}:
- *
* <ol>
- * <li>If this property is {@link Boolean#FALSE} then this generator
- * will accept being setup for generating parameters for any modulus length
- * provided the modulus length is between <code>512</code> and
- * <code>1024</code>, and is of the form <code>512 + 64 * n</code>. In
- * addition, a new paramter set will always be generated; i.e. no pre-
- * computed values are used.</li>
- *
- * <li>If this property is {@link Boolean#TRUE} and the value of
- * {@link #STRICT_DEFAULTS} is also {@link Boolean#TRUE} then this generator
- * will only accept being setup for generating parameters for modulus
- * lengths of <code>512</code>, <code>768</code> and <code>1024</code>. Any
- * other value, of the modulus length, even if between <code>512</code> and
- * <code>1024</code>, and of the form <code>512 + 64 * n</code>, will cause
- * an {@link IllegalArgumentException} to be thrown. When those modulus
- * length (<code>512</code>, <code>768</code>, and <code>1024</code>) are
- * specified, the paramter set is always the same.</li>
- *
- * <li>Finally, if this property is {@link Boolean#TRUE} and the value of
- * {@link #STRICT_DEFAULTS} is {@link Boolean#FALSE} then this generator
- * will behave as in point 1 above, except that it will use pre-computed
- * values when possible; i.e. the modulus length is one of <code>512</code>,
- * <code>768</code>, or <code>1024</code>.</li>
+ * <li>If this property is {@link Boolean#FALSE} then this generator will
+ * accept being setup for generating parameters for any modulus length
+ * provided the modulus length is between <code>512</code> and
+ * <code>1024</code>, and is of the form <code>512 + 64 * n</code>. In
+ * addition, a new paramter set will always be generated; i.e. no pre-
+ * computed values are used.</li>
+ * <li>If this property is {@link Boolean#TRUE} and the value of
+ * {@link #STRICT_DEFAULTS} is also {@link Boolean#TRUE} then this generator
+ * will only accept being setup for generating parameters for modulus lengths
+ * of <code>512</code>, <code>768</code> and <code>1024</code>. Any
+ * other value, of the modulus length, even if between <code>512</code> and
+ * <code>1024</code>, and of the form <code>512 + 64 * n</code>, will
+ * cause an {@link IllegalArgumentException} to be thrown. When those modulus
+ * length (<code>512</code>, <code>768</code>, and <code>1024</code>)
+ * are specified, the paramter set is always the same.</li>
+ * <li>Finally, if this property is {@link Boolean#TRUE} and the value of
+ * {@link #STRICT_DEFAULTS} is {@link Boolean#FALSE} then this generator will
+ * behave as in point 1 above, except that it will use pre-computed values
+ * when possible; i.e. the modulus length is one of <code>512</code>,
+ * <code>768</code>, or <code>1024</code>.</li>
* </ol>
- *
* The default value of this property is {@link Boolean#TRUE}.
*/
public static final String USE_DEFAULTS = "gnu.crypto.dss.use.defaults";
@@ -145,8 +126,8 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
/**
* Property name of an optional {@link DSAParameterSpec} instance to use for
- * this generator's <code>p</code>, <code>q</code>, and <code>g</code> values.
- * The default is to generate these values or use pre-computed ones,
+ * this generator's <code>p</code>, <code>q</code>, and <code>g</code>
+ * values. The default is to generate these values or use pre-computed ones,
* depending on the value of the <code>USE_DEFAULTS</code> attribute.
*/
public static final String DSS_PARAMETERS = "gnu.crypto.dss.params";
@@ -165,55 +146,41 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
private static final int DEFAULT_ENCODING_FORMAT = Registry.RAW_ENCODING_ID;
/** Initial SHS context. */
- private static final int[] T_SHS = new int[] { 0x67452301, 0xEFCDAB89,
- 0x98BADCFE, 0x10325476,
- 0xC3D2E1F0 };
+ private static final int[] T_SHS = new int[] {
+ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0
+ };
// from jdk1.3.1/docs/guide/security/CryptoSpec.html#AppB
public static final DSAParameterSpec KEY_PARAMS_512 = new DSAParameterSpec(
- new BigInteger(
- "fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae"
- + "01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17",
- 16),
- new BigInteger(
- "962eddcc369cba8ebb260ee6b6a126d9346e38c5",
- 16),
- new BigInteger(
- "678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e"
- + "35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4",
- 16));
-
+ new BigInteger(
+ "fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae"
+ + "01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17", 16),
+ new BigInteger("962eddcc369cba8ebb260ee6b6a126d9346e38c5", 16),
+ new BigInteger(
+ "678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e"
+ + "35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4", 16));
public static final DSAParameterSpec KEY_PARAMS_768 = new DSAParameterSpec(
- new BigInteger(
- "e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d8901419"
- + "22d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d77"
- + "7d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf",
- 16),
- new BigInteger(
- "9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511",
- 16),
- new BigInteger(
- "30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4"
- + "dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d8"
- + "3c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252",
- 16));
-
+ new BigInteger(
+ "e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d8901419"
+ + "22d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d77"
+ + "7d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf", 16),
+ new BigInteger("9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511", 16),
+ new BigInteger(
+ "30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4"
+ + "dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d8"
+ + "3c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252", 16));
public static final DSAParameterSpec KEY_PARAMS_1024 = new DSAParameterSpec(
- new BigInteger(
- "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669"
- + "455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b7"
- + "6b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb"
- + "83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7",
- 16),
- new BigInteger(
- "9760508f15230bccb292b982a2eb840bf0581cf5",
- 16),
- new BigInteger(
- "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d078267"
- + "5159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e1"
- + "3c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243b"
- + "cca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a",
- 16));
+ new BigInteger(
+ "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669"
+ + "455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b7"
+ + "6b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb"
+ + "83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7", 16),
+ new BigInteger("9760508f15230bccb292b982a2eb840bf0581cf5", 16),
+ new BigInteger(
+ "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d078267"
+ + "5159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e1"
+ + "3c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243b"
+ + "cca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a", 16));
private static final BigInteger TWO_POW_160 = TWO.pow(160);
@@ -243,31 +210,18 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
/** Preferred encoding format of generated keys. */
private int preferredFormat;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- // implicit 0-arguments constructor
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.key.IKeyPairGenerator interface implementation ---------------
-
public String name()
{
return Registry.DSS_KPG;
}
/**
- * <p>Configures this instance.</p>
- *
+ * Configures this instance.
+ *
* @param attributes the map of name/value pairs to use.
- * @exception IllegalArgumentException if the designated MODULUS_LENGTH
- * value is not greater than 512, less than 1024 and not of the form
- * <code>512 + 64j</code>.
+ * @exception IllegalArgumentException if the designated MODULUS_LENGTH value
+ * is not greater than 512, less than 1024 and not of the form
+ * <code>512 + 64j</code>.
*/
public void setup(Map attributes)
{
@@ -280,9 +234,7 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
// should we use the default pre-computed params?
Boolean useDefaults = (Boolean) attributes.get(USE_DEFAULTS);
if (useDefaults == null)
- {
- useDefaults = Boolean.TRUE;
- }
+ useDefaults = Boolean.TRUE;
Boolean strictDefaults = (Boolean) attributes.get(STRICT_DEFAULTS);
if (strictDefaults == null)
@@ -334,16 +286,12 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
q = null;
g = null;
}
-
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
// what is the preferred encoding format
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
- preferredFormat = formatID == null
- ? DEFAULT_ENCODING_FORMAT
- : formatID.intValue();
-
+ preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
+ : formatID.intValue();
// set the seed-key
byte[] kb = new byte[20]; // we need 160 bits of randomness
nextRandomBytes(kb);
@@ -361,76 +309,65 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator
p = params[FIPS186.DSA_PARAMS_P];
e = params[FIPS186.DSA_PARAMS_E];
g = params[FIPS186.DSA_PARAMS_G];
- if (DEBUG && debuglevel > 0)
+ if (Configuration.DEBUG)
{
- debug("seed: " + seed.toString(16));
- debug("counter: " + counter.intValue());
- debug("q: " + q.toString(16));
- debug("p: " + p.toString(16));
- debug("e: " + e.toString(16));
- debug("g: " + g.toString(16));
+ log.fine("seed: " + seed.toString(16));
+ log.fine("counter: " + counter.intValue());
+ log.fine("q: " + q.toString(16));
+ log.fine("p: " + p.toString(16));
+ log.fine("e: " + e.toString(16));
+ log.fine("g: " + g.toString(16));
}
}
-
BigInteger x = nextX();
BigInteger y = g.modPow(x, p);
-
PublicKey pubK = new DSSPublicKey(preferredFormat, p, q, g, y);
PrivateKey secK = new DSSPrivateKey(preferredFormat, p, q, g, x);
-
return new KeyPair(pubK, secK);
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>This method applies the following algorithm described in 3.1 of
- * FIPS-186:</p>
- *
+ * This method applies the following algorithm described in 3.1 of FIPS-186:
* <ol>
- * <li>XSEED = optional user input.</li>
- * <li>XVAL = (XKEY + XSEED) mod 2<sup>b</sup>.</li>
- * <li>x = G(t, XVAL) mod q.</li>
- * <li>XKEY = (1 + XKEY + x) mod 2<sup>b</sup>.</li>
+ * <li>XSEED = optional user input.</li>
+ * <li>XVAL = (XKEY + XSEED) mod 2<sup>b</sup>.</li>
+ * <li>x = G(t, XVAL) mod q.</li>
+ * <li>XKEY = (1 + XKEY + x) mod 2<sup>b</sup>.</li>
* </ol>
- *
- * <p>Where <code>b</code> is the length of a secret b-bit seed-key (XKEY).</p>
- *
- * <p>Note that in this implementation, XSEED, the optional user input, is
- * always zero.</p>
+ * <p>
+ * Where <code>b</code> is the length of a secret b-bit seed-key (XKEY).
+ * <p>
+ * Note that in this implementation, XSEED, the optional user input, is always
+ * zero.
*/
private synchronized BigInteger nextX()
{
byte[] xk = XKEY.toByteArray();
byte[] in = new byte[64]; // 512-bit block for SHS
System.arraycopy(xk, 0, in, 0, xk.length);
-
int[] H = Sha160.G(T_SHS[0], T_SHS[1], T_SHS[2], T_SHS[3], T_SHS[4], in, 0);
byte[] h = new byte[20];
for (int i = 0, j = 0; i < 5; i++)
{
- h[j++] = (byte) (H[i] >>> 24);
- h[j++] = (byte) (H[i] >>> 16);
- h[j++] = (byte) (H[i] >>> 8);
+ h[j++] = (byte)(H[i] >>> 24);
+ h[j++] = (byte)(H[i] >>> 16);
+ h[j++] = (byte)(H[i] >>> 8);
h[j++] = (byte) H[i];
}
BigInteger result = new BigInteger(1, h).mod(q);
XKEY = XKEY.add(result).add(BigInteger.ONE).mod(TWO_POW_160);
-
return result;
}
/**
- * <p>Fills the designated byte array with random data.</p>
- *
+ * 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);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java
index 3a115b96378..06b8e849a50 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.dss;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.der.DER;
@@ -158,11 +159,10 @@ public class DSSKeyPairPKCS8Codec
}
catch (IOException e)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(e.getMessage());
y.initCause(e);
throw y;
}
-
return result;
}
@@ -184,8 +184,8 @@ public class DSSKeyPairPKCS8Codec
*/
public PrivateKey decodePrivateKey(byte[] input)
{
- log.entering("DSSKeyPairPKCS8Codec", "decodePrivateKey");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "decodePrivateKey");
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
@@ -226,9 +226,11 @@ public class DSSKeyPairPKCS8Codec
g = (BigInteger) val.getValue();
val = der.read();
- log.finest("val = " + val);
+ if (Configuration.DEBUG)
+ log.fine("val = " + val);
byte[] xBytes = (byte[]) val.getValue();
- log.finest(Util.dumpString(xBytes, "xBytes: "));
+ if (Configuration.DEBUG)
+ log.fine(Util.dumpString(xBytes, "xBytes: "));
DERReader der2 = new DERReader(xBytes);
val = der2.read();
DerUtil.checkIsBigInteger(val, "Wrong X field");
@@ -236,12 +238,12 @@ public class DSSKeyPairPKCS8Codec
}
catch (IOException e)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(e.getMessage());
y.initCause(e);
throw y;
}
-
- log.exiting("DSSKeyPairPKCS8Codec", "decodePrivateKey");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "decodePrivateKey");
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairRawCodec.java b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairRawCodec.java
index 7c5491d6f37..b1135b75f1f 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairRawCodec.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairRawCodec.java
@@ -47,91 +47,72 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>An object that implements the {@link IKeyPairCodec} operations for the
- * <i>Raw</i> format to use with DSS keypairs.</p>
+ * An object that implements the {@link IKeyPairCodec} operations for the
+ * <i>Raw</i> format to use with DSS keypairs.
*/
-public class DSSKeyPairRawCodec implements IKeyPairCodec
+public class DSSKeyPairRawCodec
+ implements IKeyPairCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.keys.IKeyPairCodec interface implementation ------------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated DSS (Digital Signature
- * Standard) public key according to the <i>Raw</i> format supported by
- * this library.</p>
- *
- * <p>The <i>Raw</i> format for a DSA public key, in this implementation, is
- * a byte sequence consisting of the following:</p>
+ * Returns the encoded form of the designated DSS (Digital Signature Standard)
+ * public key according to the <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for a DSA public key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DSS_PUBLIC_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>p</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>p</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>q</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>q</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>y</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>y</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_DSS_PUBLIC_KEY},
+ * <li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>p</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>p</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>q</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>q</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>y</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>y</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not a DSS
- * (Digital Signature Standard) one.
+ * (Digital Signature Standard) one.
* @see Registry#MAGIC_RAW_DSS_PUBLIC_KEY
*/
public byte[] encodePublicKey(PublicKey key)
{
- if (!(key instanceof DSSPublicKey))
- {
- throw new IllegalArgumentException("key");
- }
+ if (! (key instanceof DSSPublicKey))
+ throw new IllegalArgumentException("key");
DSSPublicKey dssKey = (DSSPublicKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_DSS_PUBLIC_KEY[0]);
baos.write(Registry.MAGIC_RAW_DSS_PUBLIC_KEY[1]);
baos.write(Registry.MAGIC_RAW_DSS_PUBLIC_KEY[2]);
baos.write(Registry.MAGIC_RAW_DSS_PUBLIC_KEY[3]);
-
// version
baos.write(0x01);
-
// p
byte[] buffer = dssKey.getParams().getP().toByteArray();
int length = buffer.length;
@@ -140,7 +121,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// q
buffer = dssKey.getParams().getQ().toByteArray();
length = buffer.length;
@@ -149,7 +129,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = dssKey.getParams().getG().toByteArray();
length = buffer.length;
@@ -158,7 +137,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// y
buffer = dssKey.getY().toByteArray();
length = buffer.length;
@@ -167,7 +145,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -178,112 +155,106 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_DSS_PUBLIC_KEY[1]
|| k[2] != Registry.MAGIC_RAW_DSS_PUBLIC_KEY[2]
|| k[3] != Registry.MAGIC_RAW_DSS_PUBLIC_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
- int i = 5;
+ throw new IllegalArgumentException("version");
+ int i = 5;
int l;
byte[] buffer;
-
// p
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger p = new BigInteger(1, buffer);
-
// q
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger q = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// y
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger y = new BigInteger(1, buffer);
-
return new DSSPublicKey(p, q, g, y);
}
/**
- * <p>Returns the encoded form of the designated DSS (Digital Signature
- * Standard) private key according to the <i>Raw</i> format supported by
- * this library.</p>
- *
- * <p>The <i>Raw</i> format for a DSA private key, in this implementation, is
- * a byte sequence consisting of the following:</p>
+ * Returns the encoded form of the designated DSS (Digital Signature Standard)
+ * private key according to the <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for a DSA private key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DSS_PRIVATE_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>p</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>p</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>q</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>q</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the DSA parameter
- * <code>x</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSA parameter
- * <code>x</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_DSS_PRIVATE_KEY},
+ * <li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>p</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>p</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>q</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>q</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSA parameter
+ * <code>x</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSA parameter <code>x</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not a DSS
- * (Digital Signature Standard) one.
+ * (Digital Signature Standard) one.
*/
public byte[] encodePrivateKey(PrivateKey key)
{
- if (!(key instanceof DSSPrivateKey))
- {
- throw new IllegalArgumentException("key");
- }
+ if (! (key instanceof DSSPrivateKey))
+ throw new IllegalArgumentException("key");
DSSPrivateKey dssKey = (DSSPrivateKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_DSS_PRIVATE_KEY[0]);
baos.write(Registry.MAGIC_RAW_DSS_PRIVATE_KEY[1]);
baos.write(Registry.MAGIC_RAW_DSS_PRIVATE_KEY[2]);
baos.write(Registry.MAGIC_RAW_DSS_PRIVATE_KEY[3]);
-
// version
baos.write(0x01);
-
// p
byte[] buffer = dssKey.getParams().getP().toByteArray();
int length = buffer.length;
@@ -292,7 +263,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// q
buffer = dssKey.getParams().getQ().toByteArray();
length = buffer.length;
@@ -301,7 +271,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = dssKey.getParams().getG().toByteArray();
length = buffer.length;
@@ -310,7 +279,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// x
buffer = dssKey.getX().toByteArray();
length = buffer.length;
@@ -319,7 +287,6 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -330,52 +297,51 @@ public class DSSKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_DSS_PRIVATE_KEY[1]
|| k[2] != Registry.MAGIC_RAW_DSS_PRIVATE_KEY[2]
|| k[3] != Registry.MAGIC_RAW_DSS_PRIVATE_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
- int i = 5;
+ throw new IllegalArgumentException("version");
+ int i = 5;
int l;
byte[] buffer;
-
// p
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger p = new BigInteger(1, buffer);
-
// q
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger q = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// x
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger x = new BigInteger(1, buffer);
-
return new DSSPrivateKey(p, q, g, x);
}
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairX509Codec.java b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairX509Codec.java
index 516ef92afd5..a5e8e9d47eb 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairX509Codec.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSKeyPairX509Codec.java
@@ -94,9 +94,15 @@ public class DSSKeyPairX509Codec
* g INTEGER
* }
* </pre>
- *
- * <p>The <i>subjectPublicKey</i> field, which is a BIT STRING, contains the
- * DER-encoded form of the DSA public key as an INTEGER.</p>
+ * <p>
+ * Note that RFC-3280 (page 79) implies that some certificates MAY have an
+ * absent, or NULL, parameters field in their AlgorithmIdentifier element,
+ * implying that those parameters MUST be <i>inherited</i> from another
+ * certificate. This implementation, encodes a <i>NULL</i> element as the DER
+ * value of the parameters field when such is the case.
+ * <p>
+ * The <i>subjectPublicKey</i> field, which is a BIT STRING, contains the
+ * DER-encoded form of the DSA public key as an INTEGER.
*
* <pre>
* DSAPublicKey ::= INTEGER -- public key, Y
@@ -118,20 +124,25 @@ public class DSSKeyPairX509Codec
DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, DSA_ALG_OID);
DSSPublicKey dssKey = (DSSPublicKey) key;
- BigInteger p = dssKey.getParams().getP();
- BigInteger q = dssKey.getParams().getQ();
- BigInteger g = dssKey.getParams().getG();
- BigInteger y = dssKey.getY();
-
- DERValue derP = new DERValue(DER.INTEGER, p);
- DERValue derQ = new DERValue(DER.INTEGER, q);
- DERValue derG = new DERValue(DER.INTEGER, g);
-
- ArrayList params = new ArrayList(3);
- params.add(derP);
- params.add(derQ);
- params.add(derG);
- DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params);
+ DERValue derParams;
+ if (dssKey.hasInheritedParameters())
+ derParams = new DERValue(DER.NULL, null);
+ else
+ {
+ BigInteger p = dssKey.getParams().getP();
+ BigInteger q = dssKey.getParams().getQ();
+ BigInteger g = dssKey.getParams().getG();
+
+ DERValue derP = new DERValue(DER.INTEGER, p);
+ DERValue derQ = new DERValue(DER.INTEGER, q);
+ DERValue derG = new DERValue(DER.INTEGER, g);
+
+ ArrayList params = new ArrayList(3);
+ params.add(derP);
+ params.add(derQ);
+ params.add(derG);
+ derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params);
+ }
ArrayList algorithmID = new ArrayList(2);
algorithmID.add(derOID);
@@ -139,6 +150,7 @@ public class DSSKeyPairX509Codec
DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
algorithmID);
+ BigInteger y = dssKey.getY();
DERValue derDSAPublicKey = new DERValue(DER.INTEGER, y);
byte[] yBytes = derDSAPublicKey.getEncoded();
DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(yBytes));
@@ -157,11 +169,10 @@ public class DSSKeyPairX509Codec
}
catch (IOException x)
{
- InvalidParameterException e = new InvalidParameterException();
+ InvalidParameterException e = new InvalidParameterException(x.getMessage());
e.initCause(x);
throw e;
}
-
return result;
}
@@ -186,7 +197,10 @@ public class DSSKeyPairX509Codec
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
- BigInteger p, g, q, y;
+ BigInteger p = null;
+ BigInteger g = null;
+ BigInteger q = null;
+ BigInteger y;
DERReader der = new DERReader(input);
try
{
@@ -204,20 +218,35 @@ public class DSSKeyPairX509Codec
if (! algOID.equals(DSA_ALG_OID))
throw new InvalidParameterException("Unexpected OID: " + algOID);
- DERValue derParams = der.read();
- DerUtil.checkIsConstructed(derParams, "Wrong DSS Parameters field");
-
DERValue val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong P field");
- p = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong Q field");
- q = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong G field");
- g = (BigInteger) val.getValue();
-
- val = der.read();
+ // RFC-3280, page 79 states: "If the subjectPublicKeyInfo field of the
+ // certificate contains an algorithm field with null parameters or
+ // parameters are omitted, compare the certificate subjectPublicKey
+ // algorithm to the working_public_key_algorithm. If the certificate
+ // subjectPublicKey algorithm and the working_public_key_algorithm are
+ // different, set the working_public_key_parameters to null."
+ // in other words, the parameters field of an AlgorithmIdentifier
+ // element MAY NOT be present at all, or if present MAY be NULL!
+ // the Mauve test ValidDSAParameterInheritenceTest5, in
+ // gnu.testlet.java.security.cert.pkix.pkits, is/was failing because
+ // of this.
+ if (val.getTag() == DER.NULL)
+ val = der.read();
+ else if (val.isConstructed())
+ {
+ val = der.read();
+ DerUtil.checkIsBigInteger(val, "Wrong P field");
+ p = (BigInteger) val.getValue();
+ val = der.read();
+ DerUtil.checkIsBigInteger(val, "Wrong Q field");
+ q = (BigInteger) val.getValue();
+ val = der.read();
+ DerUtil.checkIsBigInteger(val, "Wrong G field");
+ g = (BigInteger) val.getValue();
+
+ val = der.read();
+ }
+
if (! (val.getValue() instanceof BitString))
throw new InvalidParameterException("Wrong SubjectPublicKey field");
@@ -230,11 +259,10 @@ public class DSSKeyPairX509Codec
}
catch (IOException x)
{
- InvalidParameterException e = new InvalidParameterException();
+ InvalidParameterException e = new InvalidParameterException(x.getMessage());
e.initCause(x);
throw e;
}
-
return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSPrivateKey.java b/libjava/classpath/gnu/java/security/key/dss/DSSPrivateKey.java
index fe59cb6d77b..6ed8de8460d 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSPrivateKey.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSPrivateKey.java
@@ -38,38 +38,34 @@ exception statement from your version. */
package gnu.java.security.key.dss;
-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 java.security.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
/**
- * <p>An object that embodies a DSS (Digital Signature Standard) private key.</p>
- *
+ * An object that embodies a DSS (Digital Signature Standard) private key.
+ *
* @see #getEncoded
*/
-public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
+public class DSSPrivateKey
+ extends DSSKey
+ implements PrivateKey, DSAPrivateKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
-
/**
- * <p>A randomly or pseudorandomly generated integer with <code>0 &lt; x &lt;
- * q</code>.</p>
+ * A randomly or pseudorandomly generated integer with <code>0 &lt; x &lt;
+ * q</code>.
*/
private final BigInteger x;
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Convenience constructor. Calls the constructor with 5 arguments passing
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
@@ -104,13 +100,9 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
: preferredFormat,
p, q, g);
-
this.x = x;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* A class method that takes the output of the <code>encodePrivateKey()</code>
* method of a DSS keypair codec object (an instance implementing
@@ -135,30 +127,22 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
catch (IllegalArgumentException ignored)
{
}
-
// try PKCS#8 codec
return (DSSPrivateKey) new DSSKeyPairPKCS8Codec().decodePrivateKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.interfaces.DSAPrivateKey interface implementation ---------
-
public BigInteger getX()
{
return x;
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the encoded form of this private key according to the
- * designated format.</p>
- *
+ * Returns the encoded form of this private key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @exception IllegalArgumentException if the format is not supported.
* @see DSSKeyPairRawCodec
*/
@@ -181,24 +165,22 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
+ * Returns <code>true</code> if the designated object is an instance of
* {@link DSAPrivateKey} and has the same DSS (Digital Signature Standard)
- * parameter values as this one.</p>
- *
+ * parameter values as this one.
+ *
* @param obj the other non-null DSS key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof DSAPrivateKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof DSAPrivateKey))
+ return false;
+
DSAPrivateKey that = (DSAPrivateKey) obj;
return super.equals(that) && x.equals(that.getX());
}
@@ -207,13 +189,15 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
{
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(DEBUG ? x.toString(16) : "**...*").append(ls)
- .append(")").toString();
+ .append(super.toString()).append(",").append(ls)
+ .append("x=0x").append(Configuration.DEBUG ? x.toString(16)
+ : "**...*").append(ls)
+ .append(")")
+ .toString();
}
-
return str;
}
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java b/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
index 52292131336..9e1c4cf0a04 100644
--- a/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
+++ b/libjava/classpath/gnu/java/security/key/dss/DSSPublicKey.java
@@ -38,36 +38,33 @@ 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;
/**
- * <p>An object that embodies a DSS (Digital Signature Standard) public key.</p>
+ * An object that embodies a DSS (Digital Signature Standard) public key.
*
* @see #getEncoded
*/
-public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
+public class DSSPublicKey
+ extends DSSKey
+ implements PublicKey, DSAPublicKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * <code>y = g<sup>x</sup> mod p</code> where <code>x</code> is the private
- * part of the DSA key.
+ * <code>y = g<sup>x</sup> mod p</code> where <code>x</code> is the
+ * private part of the DSA key.
*/
private final BigInteger y;
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Conveience constructor. Calls the constructor with 5 arguments passing
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
@@ -85,8 +82,8 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
}
/**
- * Constructs a new instance of <code>DSSPublicKey</code> given the designated
- * arguments.
+ * Constructs a new instance of <code>DSSPublicKey</code> given the
+ * designated arguments.
*
* @param preferredFormat the identifier of the preferred encoding format to
* use when externalizing this key.
@@ -102,13 +99,9 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.X509_ENCODING_ID
: preferredFormat,
p, q, g);
-
this.y = y;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* A class method that takes the output of the <code>encodePublicKey()</code>
* method of a DSS keypair codec object (an instance implementing
@@ -133,30 +126,22 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
catch (IllegalArgumentException ignored)
{
}
-
// try X.509 codec
return (DSSPublicKey) new DSSKeyPairX509Codec().decodePublicKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.interfaces.DSAPublicKey interface implementation ----------
-
public BigInteger getY()
{
return y;
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the encoded form of this public key according to the designated
- * format.</p>
+ * Returns the encoded form of this public key according to the designated
+ * format.
*
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @exception IllegalArgumentException if the format is not supported.
* @see DSSKeyPairRawCodec
*/
@@ -179,24 +164,22 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
+ * Returns <code>true</code> if the designated object is an instance of
* {@link DSAPublicKey} and has the same DSS (Digital Signature Standard)
- * parameter values as this one.</p>
+ * parameter values as this one.
*
* @param obj the other non-null DSS key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof DSAPublicKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof DSAPublicKey))
+ return false;
+
DSAPublicKey that = (DSAPublicKey) obj;
return super.equals(that) && y.equals(that.getY());
}
@@ -205,13 +188,14 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
{
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)
- .append(")").toString();
+ .append(super.toString()).append(",").append(ls)
+ .append("y=0x").append(y.toString(16)).append(ls)
+ .append(")")
+ .toString();
}
-
return str;
}
}
diff --git a/libjava/classpath/gnu/java/security/key/dss/FIPS186.java b/libjava/classpath/gnu/java/security/key/dss/FIPS186.java
index 5984bcc9393..7277599bd54 100644
--- a/libjava/classpath/gnu/java/security/key/dss/FIPS186.java
+++ b/libjava/classpath/gnu/java/security/key/dss/FIPS186.java
@@ -40,26 +40,21 @@ package gnu.java.security.key.dss;
import gnu.java.security.hash.Sha160;
import gnu.java.security.util.PRNG;
-import gnu.java.security.util.Prime2;
import java.math.BigInteger;
import java.security.SecureRandom;
/**
- * <p>An implementation of the DSA parameters generation as described in
- * FIPS-186.</p>
- *
- * References:<br>
+ * An implementation of the DSA parameters generation as described in FIPS-186.
+ * <p>
+ * References:
+ * <p>
* <a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital Signature
- * Standard (DSS)</a>, Federal Information Processing Standards Publication 186.
- * National Institute of Standards and Technology.
+ * Standard (DSS)</a>, Federal Information Processing Standards Publication
+ * 186. National Institute of Standards and Technology.
*/
public class FIPS186
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final int DSA_PARAMS_SEED = 0;
public static final int DSA_PARAMS_COUNTER = 1;
@@ -73,7 +68,7 @@ public class FIPS186
public static final int DSA_PARAMS_G = 5;
/** The BigInteger constant 2. */
- private static final BigInteger TWO = new BigInteger("2");
+ private static final BigInteger TWO = BigInteger.valueOf(2L);
private static final BigInteger TWO_POW_160 = TWO.pow(160);
@@ -89,9 +84,6 @@ public class FIPS186
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public FIPS186(int L, SecureRandom rnd)
{
super();
@@ -100,38 +92,31 @@ public class FIPS186
this.rnd = rnd;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* This method generates the DSS <code>p</code>, <code>q</code>, and
* <code>g</code> parameters only when <code>L</code> (the modulus length)
* is not one of the following: <code>512</code>, <code>768</code> and
- * <code>1024</code>. For those values of <code>L</code>, this implementation
- * uses pre-computed values of <code>p</code>, <code>q</code>, and
- * <code>g</code> given in the document <i>CryptoSpec</i> included in the
- * security guide documentation of the standard JDK distribution.<p>
- *
+ * <code>1024</code>. For those values of <code>L</code>, this
+ * implementation uses pre-computed values of <code>p</code>,
+ * <code>q</code>, and <code>g</code> given in the document <i>CryptoSpec</i>
+ * included in the security guide documentation of the standard JDK
+ * distribution.
+ * <p>
* The DSS requires two primes , <code>p</code> and <code>q</code>,
* satisfying the following three conditions:
- *
* <ul>
- * <li><code>2<sup>159</sup> &lt; q &lt; 2<sup>160</sup></code></li>
- * <li><code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup></code> for a
- * specified <code>L</code>, where <code>L = 512 + 64j</code> for some
- * <code>0 &lt;= j &lt;= 8</code></li>
- * <li>q divides p - 1.</li>
+ * <li><code>2<sup>159</sup> &lt; q &lt; 2<sup>160</sup></code></li>
+ * <li><code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup></code> for a
+ * specified <code>L</code>, where <code>L = 512 + 64j</code> for some
+ * <code>0 &lt;= j &lt;= 8</code></li>
+ * <li>q divides p - 1.</li>
* </ul>
- *
* The algorithm used to find these primes is as described in FIPS-186,
* section 2.2: GENERATION OF PRIMES. This prime generation scheme starts by
- * using the {@link Sha160} and a user supplied <i>SEED</i>
- * to construct a prime, <code>q</code>, in the range 2<sup>159</sup> &lt; q
- * &lt; 2<sup>160</sup>. Once this is accomplished, the same <i>SEED</i>
- * value is used to construct an <code>X</code> in the range <code>2<sup>L-1
+ * using the {@link Sha160} and a user supplied <i>SEED</i> to construct a
+ * prime, <code>q</code>, in the range 2<sup>159</sup> &lt; q &lt; 2<sup>160</sup>.
+ * Once this is accomplished, the same <i>SEED</i> value is used to construct
+ * an <code>X</code> in the range <code>2<sup>L-1
* </sup> &lt; X &lt; 2<sup>L</sup>. The prime, <code>p</code>, is then
* formed by rounding <code>X</code> to a number congruent to <code>1 mod
* 2q</code>. In this implementation we use the same <i>SEED</i> value given
@@ -169,9 +154,8 @@ public class FIPS186
u = sha.digest();
}
for (int i = 0; i < a.length; i++)
- {
- a[i] ^= u[i];
- }
+ a[i] ^= u[i];
+
U = new BigInteger(1, a);
// 3. Form q from U by setting the most significant bit (the
// 2**159 bit) and the least significant bit to 1. In terms of
@@ -183,12 +167,9 @@ public class FIPS186
// probability of a non-prime number passing the test is at
// most 1/2**80.
// 5. If q is not prime, go to step 1.
- if (Prime2.isProbablePrime(q))
- {
- break step1;
- }
+ if (q.isProbablePrime(80))
+ break step1;
} // step1
-
// 6. Let counter = 0 and offset = 2.
counter = 0;
offset = 2;
@@ -201,9 +182,9 @@ public class FIPS186
{
for (int k = 0; k <= n; k++)
{
- a = SEED_PLUS_OFFSET.add(
- BigInteger.valueOf(k & 0xFFFFFFFFL)).mod(
- TWO_POW_160).toByteArray();
+ a = SEED_PLUS_OFFSET
+ .add(BigInteger.valueOf(k & 0xFFFFFFFFL))
+ .mod(TWO_POW_160).toByteArray();
sha.update(a, 0, a.length);
V[k] = new BigInteger(1, sha.digest());
}
@@ -214,9 +195,8 @@ public class FIPS186
// Note that 0 <= W < 2**(L-1) and hence 2**(L-1) <= X < 2**L.
W = V[0];
for (int k = 1; k < n; k++)
- {
- W = W.add(V[k].multiply(TWO.pow(k * 160)));
- }
+ W = W.add(V[k].multiply(TWO.pow(k * 160)));
+
W = W.add(V[n].mod(TWO.pow(b)).multiply(TWO.pow(n * 160)));
X = W.add(TWO.pow(L - 1));
// 9. Let c = X mod 2q and set p = X - (c - 1).
@@ -228,22 +208,17 @@ public class FIPS186
{
// 11. Perform a robust primality test on p.
// 12. If p passes the test performed in step 11, go to step 15.
- if (Prime2.isProbablePrime(p))
- {
- break algorithm;
- }
+ if (p.isProbablePrime(80))
+ break algorithm;
}
// 13. Let counter = counter + 1 and offset = offset + n + 1.
counter++;
offset += n + 1;
// 14. If counter >= 4096 go to step 1, otherwise go to step 7.
if (counter >= 4096)
- {
- continue algorithm;
- }
+ continue algorithm;
} // step7
} // algorithm
-
// compute g. from FIPS-186, Appendix 4:
// 1. Generate p and q as specified in Appendix 2.
// 2. Let e = (p - 1) / q
@@ -258,28 +233,21 @@ public class FIPS186
// 4. Set g = h**e mod p
g = h.modPow(e, p);
// 5. If g = 1, go to step 3
- if (!g.equals(BigInteger.ONE))
- {
- break;
- }
+ if (! g.equals(BigInteger.ONE))
+ break;
}
-
return new BigInteger[] { SEED, BigInteger.valueOf(counter), q, p, e, g };
}
- // helper methods ----------------------------------------------------------
-
/**
* 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);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAKey.java b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAKey.java
index 3009dd71fa0..4bdce4011a5 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAKey.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAKey.java
@@ -38,23 +38,21 @@ 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;
/**
- * <p>A base asbtract class for both public and private RSA keys.</p>
+ * A base asbtract class for both public and private RSA keys.
*/
-public abstract class GnuRSAKey implements Key, RSAKey
+public abstract class GnuRSAKey
+ implements Key, RSAKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The public modulus of an RSA key pair. */
private final BigInteger n;
@@ -62,17 +60,14 @@ public abstract class GnuRSAKey implements Key, RSAKey
private final BigInteger e;
/**
- * Identifier of the default encoding format to use when externalizing the
- * key material.
+ * Identifier of the default encoding format to use when externalizing the key
+ * material.
*/
protected final int defaultFormat;
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial protected constructor.
*
@@ -91,21 +86,11 @@ public abstract class GnuRSAKey implements Key, RSAKey
this.e = e;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.interfaces.RSAKey interface implementation ----------------
-
public BigInteger getModulus()
{
return getN();
}
- // java.security.Key interface implementation ------------------------------
-
public String getAlgorithm()
{
return Registry.RSA_KPG;
@@ -122,11 +107,9 @@ public abstract class GnuRSAKey implements Key, RSAKey
return FormatUtil.getEncodingShortName(defaultFormat);
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the modulus <code>n</code>.</p>
- *
+ * Returns the modulus <code>n</code>.
+ *
* @return the modulus <code>n</code>.
*/
public BigInteger getN()
@@ -135,8 +118,8 @@ public abstract class GnuRSAKey implements Key, RSAKey
}
/**
- * <p>Returns the public exponent <code>e</code>.</p>
- *
+ * Returns the public exponent <code>e</code>.
+ *
* @return the public exponent <code>e</code>.
*/
public BigInteger getPublicExponent()
@@ -145,8 +128,8 @@ public abstract class GnuRSAKey implements Key, RSAKey
}
/**
- * <p>Same as {@link #getPublicExponent()}.</p>
- *
+ * Same as {@link #getPublicExponent()}.
+ *
* @return the public exponent <code>e</code>.
*/
public BigInteger getE()
@@ -155,23 +138,21 @@ public abstract class GnuRSAKey implements Key, RSAKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * {@link RSAKey} and has the same RSA parameter values as this one.</p>
- *
+ * Returns <code>true</code> if the designated object is an instance of
+ * {@link RSAKey} and has the same RSA parameter values as this one.
+ *
* @param obj the other non-null RSA key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(final Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof RSAKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof RSAKey))
+ return false;
+
final RSAKey that = (RSAKey) obj;
return n.equals(that.getModulus());
}
@@ -180,8 +161,9 @@ public abstract class GnuRSAKey implements Key, RSAKey
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
- str = new StringBuilder().append(ls)
+ 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)
.append("e=0x").append(e.toString(16))
@@ -190,7 +172,5 @@ public abstract class GnuRSAKey implements Key, RSAKey
return str;
}
- // abstract methods to be implemented by subclasses ------------------------
-
public abstract byte[] getEncoded(int format);
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
index 92053448763..00a1b822ad0 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
@@ -38,42 +38,39 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.Configuration;
+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;
/**
- * <p>An object that embodies an RSA private key.</p>
- *
- * <p>References:</p>
+ * An object that embodies an RSA private key.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
- RSAPrivateCrtKey
+public class GnuRSAPrivateKey
+ extends GnuRSAKey
+ implements PrivateKey, RSAPrivateCrtKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
-
/** The first prime divisor of the modulus. */
private final BigInteger p;
/** The second prime divisor of the modulus. */
private final BigInteger q;
- /** The public exponent of an RSA key. */
- // private final BigInteger e;
/** The private exponent of an RSA private key. */
private final BigInteger d;
@@ -89,21 +86,17 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Convenience constructor. Calls the constructor with 5 arguments passing
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
* encoding format.
- *
+ *
* @param p the modulus first prime divisor.
* @param q the modulus second prime divisor.
* @param e the public exponent.
* @param d the private exponent.
*/
- public GnuRSAPrivateKey(BigInteger p, BigInteger q, BigInteger e,
- BigInteger d)
+ public GnuRSAPrivateKey(BigInteger p, BigInteger q, BigInteger e, BigInteger d)
{
this(Registry.RAW_ENCODING_ID, p, q, e, d);
}
@@ -122,7 +115,9 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
public GnuRSAPrivateKey(int preferredFormat, BigInteger p, BigInteger q,
BigInteger e, BigInteger d)
{
- this(preferredFormat, p.multiply(q), e, d, p, q,
+ this(preferredFormat,
+ p.multiply(q),
+ e, d, p, q,
e.modInverse(p.subtract(BigInteger.ONE)),
e.modInverse(q.subtract(BigInteger.ONE)),
q.modInverse(p));
@@ -135,19 +130,20 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
* @param preferredFormat the indetifier of the preferred encoding format to
* use when externalizing this key.
* @param n the public modulus, which is also the product of <code>p</code>
- * and <code>q</code>.
+ * and <code>q</code>.
* @param e the public exponent.
* @param d the private exponent.
* @param p the modulus first prime divisor.
* @param q the modulus second prime divisor.
* @param dP the first prime's exponen. A positive integer less than
- * <code>p</code> and <code>q</code>, satisfying <code>e * dP = 1 (mod p-1)
- * </code>.
+ * <code>p</code> and <code>q</code>, satisfying
+ * <code>e * dP = 1 (mod p-1)</code>.
* @param dQ the second prime's exponent. A positive integer less than
- * <code>p</code> and <code>q</code>, satisfying <code>e * dQ = 1 (mod p-1)
- * </code>.
+ * <code>p</code> and <code>q</code>, satisfying
+ * <code>e * dQ = 1 (mod p-1)</code>.
* @param qInv the Chinese Remainder Theorem coefiicient. A positive integer
- * less than <code>p</code>, satisfying <code>q * qInv = 1 (mod p)</code>.
+ * less than <code>p</code>, satisfying
+ * <code>q * qInv = 1 (mod p)</code>.
*/
public GnuRSAPrivateKey(int preferredFormat, BigInteger n, BigInteger e,
BigInteger d, BigInteger p, BigInteger q,
@@ -156,24 +152,20 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
: preferredFormat,
n, e);
-
this.d = d;
this.p = p;
this.q = q;
// the exponents dP and dQ are positive integers less than p and q
// respectively satisfying
- // e * dP = 1 (mod p-1);
- // e * dQ = 1 (mod q-1),
+ // e * dP = 1 (mod p-1);
+ // e * dQ = 1 (mod q-1),
this.dP = dP;
this.dQ = dQ;
// the CRT coefficient qInv is a positive integer less than p satisfying
- // q * qInv = 1 (mod p).
+ // q * qInv = 1 (mod p).
this.qInv = qInv;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* A class method that takes the output of the <code>encodePrivateKey()</code>
* method of an RSA keypair codec object (an instance implementing
@@ -198,14 +190,10 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
catch (IllegalArgumentException ignored)
{
}
-
// try PKCS#8 codec
return (GnuRSAPrivateKey) new RSAKeyPairPKCS8Codec().decodePrivateKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public BigInteger getPrimeP()
{
return p;
@@ -231,22 +219,18 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
return qInv;
}
- // java.security.interfaces.RSAPrivateKey interface implementation ---------
-
public BigInteger getPrivateExponent()
{
return d;
}
- // Other instance methods --------------------------------------------------
-
/**
- * Returns the encoded form of this private key according to the
- * designated format.
- *
+ * Returns the encoded form of this private key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @throws IllegalArgumentException if the format is not supported.
* @see RSAKeyPairRawCodec
* @see RSAKeyPairPKCS8Codec
@@ -270,19 +254,18 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * this class and has the same RSA parameter values as this one.</p>
- *
+ * Returns <code>true</code> if the designated object is an instance of this
+ * class and has the same RSA parameter values as this one.
+ *
* @param obj the other non-null RSA key to compare to.
* @return <code>true</code> if the designated object is of the same type
- * and value as this one.
+ * and value as this one.
*/
public boolean equals(final Object obj)
{
if (obj == null)
- {
- return false;
- }
+ return false;
+
if (obj instanceof RSAPrivateKey)
{
final RSAPrivateKey that = (RSAPrivateKey) obj;
@@ -304,16 +287,24 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
{
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(DEBUG ? d.toString(16) : "**...*").append(ls)
- .append("p=0x").append(DEBUG ? p.toString(16) : "**...*").append(ls)
- .append("q=0x").append(DEBUG ? q.toString(16) : "**...*").append(ls)
- .append("dP=0x").append(DEBUG ? dP.toString(16) : "**...*").append(ls)
- .append("dQ=0x").append(DEBUG ? dQ.toString(16) : "**...*").append(ls)
- .append("qInv=0x").append(DEBUG ? qInv.toString(16) : "**...*").append(ls)
- .append(")").toString();
+ .append("d=0x").append(Configuration.DEBUG ? d.toString(16)
+ : "**...*").append(ls)
+ .append("p=0x").append(Configuration.DEBUG ? p.toString(16)
+ : "**...*").append(ls)
+ .append("q=0x").append(Configuration.DEBUG ? q.toString(16)
+ : "**...*").append(ls)
+ .append("dP=0x").append(Configuration.DEBUG ? dP.toString(16)
+ : "**...*").append(ls)
+ .append("dQ=0x").append(Configuration.DEBUG ? dQ.toString(16)
+ : "**...*").append(ls)
+ .append("qInv=0x").append(Configuration.DEBUG ? qInv.toString(16)
+ : "**...*").append(ls)
+ .append(")")
+ .toString();
}
return str;
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java
index 8badede1422..fe28d0ba3b0 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java
@@ -38,42 +38,39 @@ 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;
/**
- * <p>An object that encapsulates an RSA public key.</p>
- *
- * <p>References:</p>
+ * An object that encapsulates an RSA public key.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
- RSAPublicKey
+public class GnuRSAPublicKey
+ extends GnuRSAKey
+ implements PublicKey, RSAPublicKey
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** String representation of this key. Cached for speed. */
private transient String str;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Conveience constructor. Calls the constructor with 3 arguments passing
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
* encoding format.
- *
+ *
* @param n the modulus.
* @param e the public exponent.
*/
@@ -98,9 +95,6 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
n, e);
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* A class method that takes the output of the <code>encodePublicKey()</code>
* method of an RSA keypair codec object (an instance implementing
@@ -125,21 +119,17 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
catch (IllegalArgumentException ignored)
{
}
-
// try X.509 codec
return (GnuRSAPublicKey) new RSAKeyPairX509Codec().decodePublicKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the encoded form of this public key according to the designated
- * format.</p>
- *
+ * Returns the encoded form of this public key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @throws IllegalArgumentException if the format is not supported.
* @see RSAKeyPairRawCodec
*/
@@ -162,23 +152,21 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * this class and has the same RSA parameter values as this one.</p>
- *
+ * Returns <code>true</code> if the designated object is an instance of this
+ * class and has the same RSA parameter values as this one.
+ *
* @param obj the other non-null RSA key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(final Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof RSAPublicKey))
- {
- return false;
- }
+ return false;
+
+ if (! (obj instanceof RSAPublicKey))
+ return false;
+
final RSAPublicKey that = (RSAPublicKey) obj;
return super.equals(that)
&& getPublicExponent().equals(that.getPublicExponent());
@@ -188,10 +176,12 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
{
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(")").toString();
+ .append(")")
+ .toString();
}
return str;
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java
index 39063381f37..c31cc4cc1e0 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairGenerator;
import gnu.java.security.util.PRNG;
-import gnu.java.security.util.Prime2;
import java.math.BigInteger;
import java.security.KeyPair;
@@ -53,25 +53,23 @@ import java.util.Map;
import java.util.logging.Logger;
/**
- * <p>A key-pair generator for asymetric keys to use in conjunction with the RSA
- * scheme.</p>
- *
- * <p>Reference:</p>
+ * A key-pair generator for asymetric keys to use in conjunction with the RSA
+ * scheme.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix</a>, part B. Primitive
- * specification and supporting documentation. Jakob Jonsson and Burt Kaliski.
- * </li>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac/">Handbook of Applied
- * Cryptography</a>, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
- * Vanstone. Section 11.3 RSA and related signature schemes.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix</a>, part B. Primitive specification
+ * and supporting documentation. Jakob Jonsson and Burt Kaliski. </li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac/">Handbook of Applied
+ * Cryptography</a>, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
+ * Vanstone. Section 11.3 RSA and related signature schemes.</li>
* </ol>
*/
-public class RSAKeyPairGenerator implements IKeyPairGenerator
+public class RSAKeyPairGenerator
+ implements IKeyPairGenerator
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final Logger log = Logger.getLogger(RSAKeyPairGenerator.class.getName());
/** The BigInteger constant 1. */
@@ -90,8 +88,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.rsa.prng";
/**
- * Property name of an optional {@link RSAKeyGenParameterSpec} instance to
- * use for this generator's <code>n</code>, and <code>e</code> values. The
+ * Property name of an optional {@link RSAKeyGenParameterSpec} instance to use
+ * for this generator's <code>n</code>, and <code>e</code> values. The
* default is to generate <code>n</code> and use a fixed value for
* <code>e</.code> (Fermat's F4 number).
*/
@@ -128,38 +126,28 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
/** Preferred encoding format of generated keys. */
private int preferredFormat;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.key.IKeyPairGenerator interface implementation ---------------
-
public String name()
{
return Registry.RSA_KPG;
}
/**
- * <p>Configures this instance.</p>
- *
+ * Configures this instance.
+ *
* @param attributes the map of name/value pairs to use.
- * @exception IllegalArgumentException if the designated MODULUS_LENGTH
- * value is less than 1024.
+ * @exception IllegalArgumentException if the designated MODULUS_LENGTH value
+ * is less than 1024.
*/
public void setup(Map attributes)
{
- log.entering(this.getClass().getName(), "setup", attributes);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setup", attributes);
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
// are we given a set of RSA params or we shall use our own?
RSAKeyGenParameterSpec params = (RSAKeyGenParameterSpec) attributes.get(RSA_PARAMETERS);
-
// find out the modulus length
if (params != null)
{
@@ -171,32 +159,30 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
Integer l = (Integer) attributes.get(MODULUS_LENGTH);
L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue());
}
-
if (L < 1024)
- {
- throw new IllegalArgumentException(MODULUS_LENGTH);
- }
+ throw new IllegalArgumentException(MODULUS_LENGTH);
// what is the preferred encoding format
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
: formatID.intValue();
-
- log.exiting(this.getClass().getName(), "setup");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setup");
}
/**
- * <p>The algorithm used here is described in <i>nessie-pss-B.pdf</i>
- * document which is part of the RSA-PSS submission to NESSIE.</p>
- *
+ * <p>
+ * The algorithm used here is described in <i>nessie-pss-B.pdf</i> document
+ * which is part of the RSA-PSS submission to NESSIE.
+ * </p>
+ *
* @return an RSA keypair.
*/
public KeyPair generate()
{
- log.entering(this.getClass().getName(), "generate");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "generate");
BigInteger p, q, n, d;
-
// 1. Generate a prime p in the interval [2**(M-1), 2**M - 1], where
// M = CEILING(L/2), and such that GCD(p, e) = 1
int M = (L + 1) / 2;
@@ -208,12 +194,9 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
nextRandomBytes(kb);
p = new BigInteger(1, kb).setBit(0);
if (p.compareTo(lower) >= 0 && p.compareTo(upper) <= 0
- && Prime2.isProbablePrime(p) && p.gcd(e).equals(ONE))
- {
- break step1;
- }
+ && p.isProbablePrime(80) && p.gcd(e).equals(ONE))
+ break step1;
}
-
// 2. Generate a prime q such that the product of p and q is an L-bit
// number, and such that GCD(q, e) = 1
step2: while (true)
@@ -221,45 +204,34 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
nextRandomBytes(kb);
q = new BigInteger(1, kb).setBit(0);
n = p.multiply(q);
- if (n.bitLength() == L && Prime2.isProbablePrime(q)
- && q.gcd(e).equals(ONE))
- {
- break step2;
- }
-
+ if (n.bitLength() == L && q.isProbablePrime(80) && q.gcd(e).equals(ONE))
+ break step2;
// TODO: test for p != q
}
-
// TODO: ensure p < q
-
// 3. Put n = pq. The public key is (n, e).
// 4. Compute the parameters necessary for the private key K (see
// Section 2.2).
BigInteger phi = p.subtract(ONE).multiply(q.subtract(ONE));
d = e.modInverse(phi);
-
// 5. Output the public key and the private key.
PublicKey pubK = new GnuRSAPublicKey(preferredFormat, n, e);
PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d);
-
KeyPair result = new KeyPair(pubK, secK);
- log.exiting(this.getClass().getName(), "generate", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "generate", result);
return result;
}
- // helper methods ----------------------------------------------------------
-
/**
- * <p>Fills the designated byte array with random data.</p>
- *
+ * 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);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
index 0b980903251..7a51d0a0dd0 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
@@ -38,15 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.ArrayList;
-import java.util.logging.Logger;
-
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.der.DER;
@@ -56,6 +48,15 @@ import gnu.java.security.der.DERWriter;
import gnu.java.security.key.IKeyPairCodec;
import gnu.java.security.util.DerUtil;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.InvalidParameterException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
/**
* An implementation of an {@link IKeyPairCodec} that knows how to encode /
* decode PKCS#8 ASN.1 external representation of RSA private keys.
@@ -84,7 +85,6 @@ public class RSAKeyPairPKCS8Codec
/**
* Returns the PKCS#8 ASN.1 <i>PrivateKeyInfo</i> representation of an RSA
* private key. The ASN.1 specification is as follows:
- *
* <pre>
* PrivateKeyInfo ::= SEQUENCE {
* version INTEGER, -- MUST be 0
@@ -97,10 +97,12 @@ public class RSAKeyPairPKCS8Codec
* parameters ANY DEFINED BY algorithm OPTIONAL
* }
* </pre>
- *
- * <p>The <i>privateKey</i> field, which is an OCTET STRING, contains the
- * DER-encoded form of the RSA private key defined as:</p>
- *
+ * <p>
+ * As indicated in RFC-2459: "The parameters field shall have ASN.1 type NULL
+ * for this algorithm identifier.".
+ * <p>
+ * The <i>privateKey</i> field, which is an OCTET STRING, contains the
+ * DER-encoded form of the RSA private key defined as:
* <pre>
* RSAPrivateKey ::= SEQUENCE {
* version INTEGER, -- MUST be 0
@@ -122,8 +124,8 @@ public class RSAKeyPairPKCS8Codec
*/
public byte[] encodePrivateKey(PrivateKey key)
{
- log.entering(this.getClass().getName(), "encodePrivateKey()", key);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "encodePrivateKey()", key);
if (! (key instanceof GnuRSAPrivateKey))
throw new InvalidParameterException("Wrong key type");
@@ -141,8 +143,9 @@ public class RSAKeyPairPKCS8Codec
DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, RSA_ALG_OID);
- ArrayList algorithmID = new ArrayList(1);
+ ArrayList algorithmID = new ArrayList(2);
algorithmID.add(derOID);
+ algorithmID.add(new DERValue(DER.NULL, null));
DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
algorithmID);
@@ -190,8 +193,8 @@ public class RSAKeyPairPKCS8Codec
y.initCause(x);
throw y;
}
-
- log.exiting(this.getClass().getName(), "encodePrivateKey()", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "encodePrivateKey()", result);
return result;
}
@@ -213,8 +216,8 @@ public class RSAKeyPairPKCS8Codec
*/
public PrivateKey decodePrivateKey(byte[] input)
{
- log.entering(this.getClass().getName(), "decodePrivateKey()", input);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "decodePrivateKey()", input);
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
@@ -239,9 +242,12 @@ public class RSAKeyPairPKCS8Codec
if (! algOID.equals(RSA_ALG_OID))
throw new InvalidParameterException("Unexpected OID: " + algOID);
+ // rfc-2459 states that this field is OPTIONAL but NULL if/when present
DERValue val = der.read();
- byte[] pkBytes = (byte[]) val.getValue();
+ if (val.getTag() == DER.NULL)
+ val = der.read();
+ byte[] pkBytes = (byte[]) val.getValue();
der = new DERReader(pkBytes);
DERValue derRSAPrivateKey = der.read();
DerUtil.checkIsConstructed(derRSAPrivateKey, "Wrong RSAPrivateKey field");
@@ -284,10 +290,10 @@ public class RSAKeyPairPKCS8Codec
y.initCause(x);
throw y;
}
-
- PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, n, e,
- d, p, q, dP, dQ, qInv);
- log.exiting(this.getClass().getName(), "decodePrivateKey()", result);
+ PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
+ n, e, d, p, q, dP, dQ, qInv);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "decodePrivateKey()", result);
return result;
}
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java
index fb7cea99edd..c2650e6a49c 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java
@@ -47,80 +47,60 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>An object that implements the {@link IKeyPairCodec} interface for the
- * <i>Raw</i> format to use with RSA keypairs.</p>
- *
- * @version $Revision: 1.1 $
+ * An object that implements the {@link IKeyPairCodec} interface for the <i>Raw</i>
+ * format to use with RSA keypairs.
*/
-public class RSAKeyPairRawCodec implements IKeyPairCodec
+public class RSAKeyPairRawCodec
+ implements IKeyPairCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.key.IKeyPairCodec interface implementation -------------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated RSA public key according to
- * the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for an RSA public key, in this implementation, is
- * a byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated RSA public key according to the
+ * <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for an RSA public key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PUBLIC_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>n</code> (the modulus) in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>n</code>,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>e</code> (the public exponent) in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>e</code>.</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_RSA_PUBLIC_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>n</code> (the modulus) in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>n</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>e</code> (the public exponent) in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>e</code>.
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @exception IllegalArgumentException if the designated key is not an RSA
- * one.
+ * one.
*/
public byte[] encodePublicKey(PublicKey key)
{
- if (!(key instanceof GnuRSAPublicKey))
- {
- throw new IllegalArgumentException("key");
- }
+ if (! (key instanceof GnuRSAPublicKey))
+ throw new IllegalArgumentException("key");
GnuRSAPublicKey rsaKey = (GnuRSAPublicKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[0]);
baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[1]);
baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[2]);
baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[3]);
-
// version
baos.write(0x01);
-
// n
byte[] buffer = rsaKey.getModulus().toByteArray();
int length = buffer.length;
@@ -129,7 +109,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// e
buffer = rsaKey.getPublicExponent().toByteArray();
length = buffer.length;
@@ -138,7 +117,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -149,92 +127,87 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[1]
|| k[2] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[2]
|| k[3] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
- int i = 5;
+ throw new IllegalArgumentException("version");
+ int i = 5;
int l;
byte[] buffer;
-
// n
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger n = new BigInteger(1, buffer);
-
// e
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger e = new BigInteger(1, buffer);
-
return new GnuRSAPublicKey(n, e);
}
/**
- * <p>Returns the encoded form of the designated RSA private key according to
- * the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for an RSA private key, in this implementation,
- * is a byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated RSA private key according to the
+ * <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for an RSA private key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PRIVATE_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>p</code> (the first prime factor of the modulus) in internet
- * order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>p</code>,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>q</code> (the second prime factor of the modulus) in internet
- * order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>q</code>,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>e</code> (the public exponent) in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>e</code>,</li>
- * <li>4-byte count of following bytes representing the RSA parameter
- * <code>d</code> (the private exponent) in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the RSA parameter <code>d</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_RSA_PRIVATE_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>p</code> (the first prime factor of the modulus) in internet order,
+ * </li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>p</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>q</code> (the second prime factor of the modulus) in internet
+ * order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>q</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>e</code> (the public exponent) in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>e</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the RSA parameter
+ * <code>d</code> (the private exponent) in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the RSA parameter <code>d</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
*/
public byte[] encodePrivateKey(PrivateKey key)
{
- if (!(key instanceof GnuRSAPrivateKey))
- {
- throw new IllegalArgumentException("key");
- }
+ if (! (key instanceof GnuRSAPrivateKey))
+ throw new IllegalArgumentException("key");
GnuRSAPrivateKey rsaKey = (GnuRSAPrivateKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[0]);
baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[1]);
baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[2]);
baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[3]);
-
// version
baos.write(0x01);
-
// p
byte[] buffer = rsaKey.getPrimeP().toByteArray();
int length = buffer.length;
@@ -243,7 +216,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// q
buffer = rsaKey.getPrimeQ().toByteArray();
length = buffer.length;
@@ -252,7 +224,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// e
buffer = rsaKey.getPublicExponent().toByteArray();
length = buffer.length;
@@ -261,7 +232,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// d
buffer = rsaKey.getPrivateExponent().toByteArray();
length = buffer.length;
@@ -270,7 +240,6 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -281,52 +250,51 @@ public class RSAKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[1]
|| k[2] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[2]
|| k[3] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
- int i = 5;
+ throw new IllegalArgumentException("version");
+ int i = 5;
int l;
byte[] buffer;
-
// p
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger p = new BigInteger(1, buffer);
-
// q
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger q = new BigInteger(1, buffer);
-
// e
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger e = new BigInteger(1, buffer);
-
// d
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger d = new BigInteger(1, buffer);
-
return new GnuRSAPrivateKey(p, q, e, d);
}
}
diff --git a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java
index 882d9c7b2ca..b11e1c01371 100644
--- a/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java
+++ b/libjava/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.der.BitString;
@@ -114,8 +115,8 @@ public class RSAKeyPairX509Codec
*/
public byte[] encodePublicKey(PublicKey key)
{
- log.entering(this.getClass().getName(), "encodePublicKey()", key);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "encodePublicKey()", key);
if (! (key instanceof GnuRSAPublicKey))
throw new InvalidParameterException("key");
@@ -156,12 +157,12 @@ public class RSAKeyPairX509Codec
}
catch (IOException x)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}
-
- log.exiting(this.getClass().getName(), "encodePublicKey()", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "encodePublicKey()", result);
return result;
}
@@ -183,8 +184,8 @@ public class RSAKeyPairX509Codec
*/
public PublicKey decodePublicKey(byte[] input)
{
- log.entering(this.getClass().getName(), "decodePublicKey()", input);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "decodePublicKey()", input);
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
@@ -229,13 +230,13 @@ public class RSAKeyPairX509Codec
}
catch (IOException x)
{
- InvalidParameterException y = new InvalidParameterException();
+ InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}
-
PublicKey result = new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
- log.exiting(this.getClass().getName(), "decodePublicKey()", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "decodePublicKey()", result);
return result;
}
diff --git a/libjava/classpath/gnu/java/security/pkcs/PKCS7SignedData.java b/libjava/classpath/gnu/java/security/pkcs/PKCS7SignedData.java
index 0781f4ba97c..d59dba3cd0f 100644
--- a/libjava/classpath/gnu/java/security/pkcs/PKCS7SignedData.java
+++ b/libjava/classpath/gnu/java/security/pkcs/PKCS7SignedData.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.security.pkcs;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.ber.BER;
import gnu.java.security.ber.BEREncodingException;
@@ -52,9 +53,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
import java.math.BigInteger;
-
import java.security.cert.CRL;
import java.security.cert.CRLException;
import java.security.cert.Certificate;
@@ -62,7 +61,6 @@ import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509CRL;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -174,21 +172,22 @@ public class PKCS7SignedData
if (!val.isConstructed())
throw new BEREncodingException("malformed SignedData");
- log.finest("SignedData: " + val);
+ if (Configuration.DEBUG)
+ log.fine("SignedData: " + val);
val = ber.read();
if (val.getTag() != BER.INTEGER)
throw new BEREncodingException("expecting Version");
version = (BigInteger) val.getValue();
-
- log.finest(" Version: " + version);
+ if (Configuration.DEBUG)
+ log.fine(" Version: " + version);
digestAlgorithms = new HashSet();
val = ber.read();
if (!val.isConstructed())
throw new BEREncodingException("malformed DigestAlgorithmIdentifiers");
-
- log.finest(" DigestAlgorithmIdentifiers: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" DigestAlgorithmIdentifiers: " + val);
int count = 0;
DERValue val2 = ber.read();
while (val2 != BER.END_OF_SEQUENCE &&
@@ -196,14 +195,14 @@ public class PKCS7SignedData
{
if (!val2.isConstructed())
throw new BEREncodingException("malformed AlgorithmIdentifier");
-
- log.finest(" AlgorithmIdentifier: " + val2);
+ if (Configuration.DEBUG)
+ log.fine(" AlgorithmIdentifier: " + val2);
count += val2.getEncodedLength();
val2 = ber.read();
if (val2.getTag() != BER.OBJECT_IDENTIFIER)
throw new BEREncodingException("malformed AlgorithmIdentifier");
-
- log.finest(" digestAlgorithmIdentifiers OID: " + val2.getValue());
+ if (Configuration.DEBUG)
+ log.fine(" digestAlgorithmIdentifiers OID: " + val2.getValue());
List algId = new ArrayList(2);
algId.add(val2.getValue());
val2 = ber.read();
@@ -224,23 +223,27 @@ public class PKCS7SignedData
else
algId.add(null);
- log.finest(" digestAlgorithmIdentifiers params: ");
- log.finest(Util.dumpString((byte[]) algId.get(1),
- " digestAlgorithmIdentifiers params: "));
+ if (Configuration.DEBUG)
+ {
+ log.fine(" digestAlgorithmIdentifiers params: ");
+ log.fine(Util.dumpString((byte[]) algId.get(1),
+ " digestAlgorithmIdentifiers params: "));
+ }
digestAlgorithms.add(algId);
}
val = ber.read();
if (!val.isConstructed())
throw new BEREncodingException("malformed ContentInfo");
-
- log.finest(" ContentInfo: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" ContentInfo: " + val);
val2 = ber.read();
if (val2.getTag() != BER.OBJECT_IDENTIFIER)
throw new BEREncodingException("malformed ContentType");
contentType = (OID) val2.getValue();
- log.finest(" ContentType OID: " + contentType);
+ if (Configuration.DEBUG)
+ log.fine(" ContentType OID: " + contentType);
if (BERValue.isIndefinite(val)
|| (val.getLength() > 0 && val.getLength() > val2.getEncodedLength()))
{
@@ -252,17 +255,18 @@ public class PKCS7SignedData
val2 = ber.read();
}
}
-
- log.finest(" Content: ");
- log.finest(Util.dumpString(content, " Content: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" Content: ");
+ log.fine(Util.dumpString(content, " Content: "));
+ }
val = ber.read();
if (val.getTag() == 0)
{
if (!val.isConstructed())
throw new BEREncodingException("malformed ExtendedCertificatesAndCertificates");
-
- log.finest(" ExtendedCertificatesAndCertificates: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" ExtendedCertificatesAndCertificates: " + val);
count = 0;
val2 = ber.read();
List certs = new LinkedList();
@@ -271,7 +275,8 @@ public class PKCS7SignedData
{
Certificate cert =
x509.generateCertificate(new ByteArrayInputStream(val2.getEncoded()));
- log.finest(" Certificate: " + cert);
+ if (Configuration.DEBUG)
+ log.fine(" Certificate: " + cert);
certs.add(cert);
count += val2.getEncodedLength();
ber.skip(val2.getLength());
@@ -286,8 +291,8 @@ public class PKCS7SignedData
{
if (!val.isConstructed())
throw new BEREncodingException("malformed CertificateRevocationLists");
-
- log.finest(" CertificateRevocationLists: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" CertificateRevocationLists: " + val);
count = 0;
val2 = ber.read();
List crls = new LinkedList();
@@ -295,7 +300,8 @@ public class PKCS7SignedData
(val.getLength() > 0 && val.getLength() > count))
{
CRL crl = x509.generateCRL(new ByteArrayInputStream(val2.getEncoded()));
- log.finest(" CRL: " + crl);
+ if (Configuration.DEBUG)
+ log.fine(" CRL: " + crl);
crls.add(crl);
count += val2.getEncodedLength();
ber.skip(val2.getLength());
@@ -309,8 +315,8 @@ public class PKCS7SignedData
signerInfos = new HashSet();
if (!val.isConstructed())
throw new BEREncodingException("malformed SignerInfos");
-
- log.finest(" SignerInfos: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" SignerInfos: " + val);
// FIXME read this more carefully.
// Since we are just reading a file (probably) we just read until we
diff --git a/libjava/classpath/gnu/java/security/pkcs/SignerInfo.java b/libjava/classpath/gnu/java/security/pkcs/SignerInfo.java
index 7b38bfefdaf..3066401ac4b 100644
--- a/libjava/classpath/gnu/java/security/pkcs/SignerInfo.java
+++ b/libjava/classpath/gnu/java/security/pkcs/SignerInfo.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.security.pkcs;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.ber.BER;
import gnu.java.security.ber.BEREncodingException;
@@ -50,7 +51,6 @@ import gnu.java.security.util.Util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.logging.Logger;
@@ -101,7 +101,8 @@ public class SignerInfo
public SignerInfo(BERReader ber) throws IOException
{
DERValue val = ber.read();
- log.finest("SignerInfo: " + val);
+ if (Configuration.DEBUG)
+ log.fine("SignerInfo: " + val);
if (!val.isConstructed())
throw new BEREncodingException("malformed SignerInfo");
@@ -110,13 +111,13 @@ public class SignerInfo
throw new BEREncodingException("malformed Version");
version = (BigInteger) val.getValue();
- log.finest(" Version: " + version);
+ log.fine(" Version: " + version);
val = ber.read();
if (!val.isConstructed())
throw new BEREncodingException("malformed IssuerAndSerialNumber");
-
- log.finest(" IssuerAndSerialNumber: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" IssuerAndSerialNumber: " + val);
val = ber.read();
if (!val.isConstructed())
@@ -124,20 +125,22 @@ public class SignerInfo
issuer = new X500Principal(val.getEncoded());
ber.skip(val.getLength());
- log.finest(" Issuer: " + issuer);
+ if (Configuration.DEBUG)
+ log.fine(" Issuer: " + issuer);
val = ber.read();
if (val.getTag() != BER.INTEGER)
throw new BEREncodingException("malformed SerialNumber");
serialNumber = (BigInteger) val.getValue();
- log.finest(" SerialNumber: " + serialNumber);
+ if (Configuration.DEBUG)
+ log.fine(" SerialNumber: " + serialNumber);
val = ber.read();
if (!val.isConstructed())
throw new BEREncodingException("malformed DigestAlgorithmIdentifier");
-
- log.finest(" DigestAlgorithmIdentifier: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" DigestAlgorithmIdentifier: " + val);
int count = 0;
DERValue val2 = ber.read();
@@ -145,7 +148,8 @@ public class SignerInfo
throw new BEREncodingException("malformed AlgorithmIdentifier");
digestAlgorithmId = (OID) val2.getValue();
- log.finest(" digestAlgorithm OID: " + digestAlgorithmId);
+ if (Configuration.DEBUG)
+ log.fine(" digestAlgorithm OID: " + digestAlgorithmId);
if (BERValue.isIndefinite(val))
{
@@ -170,10 +174,12 @@ public class SignerInfo
else
digestAlgorithmParams = null;
- log.finest(" digestAlgorithm params: ");
- log.finest(Util.dumpString(digestAlgorithmParams,
- " digestAlgorithm params: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" digestAlgorithm params: ");
+ log.fine(Util.dumpString(digestAlgorithmParams,
+ " digestAlgorithm params: "));
+ }
val = ber.read();
if (val.getTag() == 0)
{
@@ -187,21 +193,24 @@ public class SignerInfo
else
authenticatedAttributes = null;
- log.finest(" AuthenticatedAttributes: ");
- log.finest(Util.dumpString(authenticatedAttributes,
- " AuthenticatedAttributes: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" AuthenticatedAttributes: ");
+ log.fine(Util.dumpString(authenticatedAttributes,
+ " AuthenticatedAttributes: "));
+ }
if (!val.isConstructed())
throw new BEREncodingException("malformed DigestEncryptionAlgorithmIdentifier");
-
- log.finest(" DigestEncryptionAlgorithmIdentifier: " + val);
+ if (Configuration.DEBUG)
+ log.fine(" DigestEncryptionAlgorithmIdentifier: " + val);
count = 0;
val2 = ber.read();
if (val2.getTag() != BER.OBJECT_IDENTIFIER)
throw new BEREncodingException("malformed AlgorithmIdentifier");
digestEncryptionAlgorithmId = (OID) val2.getValue();
- log.finest(" digestEncryptionAlgorithm OID: " + digestEncryptionAlgorithmId);
+ if (Configuration.DEBUG)
+ log.fine(" digestEncryptionAlgorithm OID: " + digestEncryptionAlgorithmId);
if (BERValue.isIndefinite(val))
{
@@ -226,27 +235,33 @@ public class SignerInfo
else
digestEncryptionAlgorithmParams = null;
- log.finest(" digestEncryptionAlgorithm params: ");
- log.finest(Util.dumpString(digestEncryptionAlgorithmParams,
- " digestEncryptionAlgorithm params: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" digestEncryptionAlgorithm params: ");
+ log.fine(Util.dumpString(digestEncryptionAlgorithmParams,
+ " digestEncryptionAlgorithm params: "));
+ }
val = ber.read();
if (val.getTag() != BER.OCTET_STRING)
throw new BEREncodingException("malformed EncryptedDigest");
encryptedDigest = (byte[]) val.getValue();
- log.finest(" EncryptedDigest: ");
- log.finest(Util.dumpString(encryptedDigest, " EncryptedDigest: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" EncryptedDigest: ");
+ log.fine(Util.dumpString(encryptedDigest, " EncryptedDigest: "));
+ }
if (ber.peek() == 1)
unauthenticatedAttributes = ber.read().getEncoded();
else
unauthenticatedAttributes = null;
- log.finest(" UnauthenticatedAttributes: ");
- log.finest(Util.dumpString(unauthenticatedAttributes,
- " UnauthenticatedAttributes: "));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine(" UnauthenticatedAttributes: ");
+ log.fine(Util.dumpString(unauthenticatedAttributes,
+ " UnauthenticatedAttributes: "));
+ }
if (ber.peek() == 0)
ber.read();
}
diff --git a/libjava/classpath/gnu/java/security/prng/BasePRNG.java b/libjava/classpath/gnu/java/security/prng/BasePRNG.java
index fe815d7004e..3b7c8cf071f 100644
--- a/libjava/classpath/gnu/java/security/prng/BasePRNG.java
+++ b/libjava/classpath/gnu/java/security/prng/BasePRNG.java
@@ -41,14 +41,11 @@ package gnu.java.security.prng;
import java.util.Map;
/**
- * <p>An abstract class to facilitate implementing PRNG algorithms.</p>
+ * An abstract class to facilitate implementing PRNG algorithms.
*/
-public abstract class BasePRNG implements IRandom
+public abstract class BasePRNG
+ implements IRandom
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The canonical name prefix of the PRNG algorithm. */
protected String name;
@@ -61,12 +58,9 @@ public abstract class BasePRNG implements IRandom
/** The index into buffer of where the next byte will come from. */
protected int ndx;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name of this instance.
*/
protected BasePRNG(String name)
@@ -78,14 +72,6 @@ public abstract class BasePRNG implements IRandom
buffer = new byte[0];
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IRandom interface implementation ----------------------------------------
-
public String name()
{
return name;
@@ -101,10 +87,9 @@ public abstract class BasePRNG implements IRandom
public byte nextByte() throws IllegalStateException, LimitReachedException
{
- if (!initialised)
- {
- throw new IllegalStateException();
- }
+ if (! initialised)
+ throw new IllegalStateException();
+
return nextByteInternal();
}
@@ -117,7 +102,7 @@ public abstract class BasePRNG implements IRandom
public void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException, LimitReachedException
{
- if (!initialised)
+ if (! initialised)
throw new IllegalStateException("not initialized");
if (length == 0)
@@ -127,7 +112,6 @@ public abstract class BasePRNG implements IRandom
throw new ArrayIndexOutOfBoundsException("offset=" + offset + " length="
+ length + " limit="
+ out.length);
-
if (ndx >= buffer.length)
{
fillBlock();
@@ -163,9 +147,6 @@ public abstract class BasePRNG implements IRandom
throw new UnsupportedOperationException("random state is non-modifiable");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public boolean isInitialised()
{
return initialised;
@@ -182,8 +163,6 @@ public abstract class BasePRNG implements IRandom
return buffer[ndx++];
}
- // abstract methods to implement by subclasses -----------------------------
-
public Object clone() throws CloneNotSupportedException
{
BasePRNG result = (BasePRNG) super.clone();
diff --git a/libjava/classpath/gnu/java/security/prng/EntropySource.java b/libjava/classpath/gnu/java/security/prng/EntropySource.java
index 260c668f8df..95f68f04872 100644
--- a/libjava/classpath/gnu/java/security/prng/EntropySource.java
+++ b/libjava/classpath/gnu/java/security/prng/EntropySource.java
@@ -43,7 +43,6 @@ package gnu.java.security.prng;
*/
public interface EntropySource
{
-
/**
* Returns the estimated quality of this source. This value should be
* between 0 and 100 (the running quality is computed as a percentage,
diff --git a/libjava/classpath/gnu/java/security/prng/IRandom.java b/libjava/classpath/gnu/java/security/prng/IRandom.java
index 2c89e7ad56f..66ad6d2241b 100644
--- a/libjava/classpath/gnu/java/security/prng/IRandom.java
+++ b/libjava/classpath/gnu/java/security/prng/IRandom.java
@@ -41,140 +41,134 @@ package gnu.java.security.prng;
import java.util.Map;
/**
- * <p>The basic visible methods of any pseudo-random number generator.</p>
- *
- * <p>The [HAC] defines a PRNG (as implemented in this library) as follows:</p>
- *
+ * The basic visible methods of any pseudo-random number generator.
+ * <p>
+ * The [HAC] defines a PRNG (as implemented in this library) as follows:
* <ul>
- * <li>"5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass
- * the <em>next-bit test</em> if there is no polynomial-time algorithm which,
- * on input of the first <code>L</code> bits of an output sequence <code>S</code>,
- * can predict the <code>(L+1)</code>st bit of <code>S</code> with a
- * probability significantly grater than <code>1/2</code>."</li>
- *
- * <li>"5.8 Definition: A PRBG that passes the <em>next-bit test</em>
- * (possibly under some plausible but unproved mathematical assumption such
- * as the intractability of factoring integers) is called a
- * <em>cryptographically secure pseudorandom bit generator</em> (CSPRBG)."</li>
+ * <li>"5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass the
+ * <em>next-bit test</em> if there is no polynomial-time algorithm which, on
+ * input of the first <code>L</code> bits of an output sequence <code>S</code>,
+ * can predict the <code>(L+1)</code><sup>st</sup> bit of <code>S</code> with a
+ * probability significantly greater than <code>1/2</code>."</li>
+ * <li>"5.8 Definition: A PRBG that passes the <em>next-bit test</em>
+ * (possibly under some plausible but unproved mathematical assumption such as
+ * the intractability of factoring integers) is called a <em>cryptographically
+ * secure pseudorandom bit generator</em> (CSPRBG)."</li>
* </ul>
- *
- * <p><b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
+ * <p>
+ * <b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
* package implement the {@link Cloneable} interface, it is important to note
- * here that such an operation, for those algorithms that use an underlting
+ * here that such an operation, for those algorithms that use an underlying
* symmetric key block cipher, <b>DOES NOT</b> clone any session key material
* that may have been used in initialising the source PRNG (the instance to be
- * cloned). Instead a clone of an already initialised PRNG, that uses and
+ * cloned). Instead a clone of an already initialised PRNG, that uses an
* underlying symmetric key block cipher, is another instance with a clone of
- * the same cipher that operates with the <b>same block size</b> but without any
- * knowledge of neither key material nor key size.</p>
- *
- * <p>References:</p>
- *
+ * the same cipher that operates with the <b>same block size</b> but without
+ * any knowledge of neither key material nor key size.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
- * Applied Cryptography.<br>
- * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
- * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
+ * Applied Cryptography.<br>
+ * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
+ * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
*/
-public interface IRandom extends Cloneable
+public interface IRandom
+ extends Cloneable
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of this instance.</p>
- *
- * @return the canonical name of this instance. */
+ * Returns the canonical name of this instance.
+ *
+ * @return the canonical name of this instance.
+ */
String name();
/**
- * <p>Initialises the pseudo-random number generator scheme with the
- * appropriate attributes.</p>
- *
+ * Initialises the pseudo-random number generator scheme with the appropriate
+ * attributes.
+ *
* @param attributes a set of name-value pairs that describe the desired
- * future instance behaviour.
+ * future instance behaviour.
* @exception IllegalArgumentException if at least one of the defined name/
- * value pairs contains invalid data.
+ * value pairs contains invalid data.
*/
void init(Map attributes);
/**
- * <p>Returns the next 8 bits of random data generated from this instance.</p>
- *
+ * Returns the next 8 bits of random data generated from this instance.
+ *
* @return the next 8 bits of random data generated from this instance.
* @exception IllegalStateException if the instance is not yet initialised.
* @exception LimitReachedException if this instance has reached its
- * theoretical limit for generating non-repetitive pseudo-random data.
+ * theoretical limit for generating non-repetitive pseudo-random
+ * data.
*/
byte nextByte() throws IllegalStateException, LimitReachedException;
/**
- * <p>Fills the designated byte array, starting from byte at index
- * <code>offset</code>, for a maximum of <code>length</code> bytes with the
- * output of this generator instance.
- *
+ * Fills the designated byte array, starting from byte at index
+ * <code>offset</code>, for a maximum of <code>length</code> bytes with
+ * the output of this generator instance.
+ *
* @param out the placeholder to contain the generated random bytes.
* @param offset the starting index in <i>out</i> to consider. This method
- * does nothing if this parameter is not within <code>0</code> and
- * <code>out.length</code>.
- * @param length the maximum number of required random bytes. This method
- * does nothing if this parameter is less than <code>1</code>.
+ * does nothing if this parameter is not within <code>0</code> and
+ * <code>out.length</code>.
+ * @param length the maximum number of required random bytes. This method does
+ * nothing if this parameter is less than <code>1</code>.
* @exception IllegalStateException if the instance is not yet initialised.
* @exception LimitReachedException if this instance has reached its
- * theoretical limit for generating non-repetitive pseudo-random data.
+ * theoretical limit for generating non-repetitive pseudo-random
+ * data.
*/
void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException, LimitReachedException;
/**
- * <p>Supplement, or possibly replace, the random state of this PRNG with
- * a random byte.</p>
- *
- * <p>Implementations are not required to implement this method in any
- * meaningful way; this may be a no-operation, and implementations may
- * throw an {@link UnsupportedOperationException}.</p>
- *
+ * Supplement, or possibly replace, the random state of this PRNG with a
+ * random byte.
+ * <p>
+ * Implementations are not required to implement this method in any meaningful
+ * way; this may be a no-operation, and implementations may throw an
+ * {@link UnsupportedOperationException}.
+ *
* @param b The byte to add.
*/
void addRandomByte(byte b);
/**
- * <p>Supplement, or possibly replace, the random state of this PRNG with
- * a sequence of new random bytes.</p>
- *
- * <p>Implementations are not required to implement this method in any
- * meaningful way; this may be a no-operation, and implementations may
- * throw an {@link UnsupportedOperationException}.</p>
- *
+ * Supplement, or possibly replace, the random state of this PRNG with a
+ * sequence of new random bytes.
+ * <p>
+ * Implementations are not required to implement this method in any meaningful
+ * way; this may be a no-operation, and implementations may throw an
+ * {@link UnsupportedOperationException}.
+ *
* @param in The buffer of new random bytes to add.
*/
void addRandomBytes(byte[] in);
/**
- * <p>Supplement, or possibly replace, the random state of this PRNG with
- * a sequence of new random bytes.</p>
- *
- * <p>Implementations are not required to implement this method in any
- * meaningful way; this may be a no-operation, and implementations may
- * throw an {@link UnsupportedOperationException}.</p>
- *
+ * Supplement, or possibly replace, the random state of this PRNG with a
+ * sequence of new random bytes.
+ * <p>
+ * Implementations are not required to implement this method in any meaningful
+ * way; this may be a no-operation, and implementations may throw an
+ * {@link UnsupportedOperationException}.
+ *
* @param in The buffer of new random bytes to add.
* @param offset The offset from whence to begin reading random bytes.
* @param length The number of random bytes to add.
- * @exception IndexOutOfBoundsException If <i>offset</i>, <i>length</i>,
- * or <i>offset</i>+<i>length</i> is out of bounds.
+ * @exception IndexOutOfBoundsException If <i>offset</i>, <i>length</i>, or
+ * <i>offset</i>+<i>length</i> is out of bounds.
*/
void addRandomBytes(byte[] in, int offset, int length);
/**
- * <p>Returns a clone copy of this instance.</p>
- *
+ * Returns a clone copy of this instance.
+ *
* @return a clone copy of this instance.
*/
Object clone() throws CloneNotSupportedException;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/java/security/prng/LimitReachedException.java b/libjava/classpath/gnu/java/security/prng/LimitReachedException.java
index 2fd8bfa7fd1..8d5b30baf90 100644
--- a/libjava/classpath/gnu/java/security/prng/LimitReachedException.java
+++ b/libjava/classpath/gnu/java/security/prng/LimitReachedException.java
@@ -42,15 +42,9 @@ package gnu.java.security.prng;
* A checked exception that indicates that a pseudo random number generated has
* reached its theoretical limit in generating random bytes.
*/
-public class LimitReachedException extends Exception
+public class LimitReachedException
+ extends Exception
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public LimitReachedException()
{
super();
@@ -60,10 +54,4 @@ public class LimitReachedException extends Exception
{
super(msg);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instant methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/java/security/prng/MDGenerator.java b/libjava/classpath/gnu/java/security/prng/MDGenerator.java
index 073c559ae04..574a2f9d64b 100644
--- a/libjava/classpath/gnu/java/security/prng/MDGenerator.java
+++ b/libjava/classpath/gnu/java/security/prng/MDGenerator.java
@@ -45,19 +45,17 @@ import gnu.java.security.hash.IMessageDigest;
import java.util.Map;
/**
- * <p>A simple pseudo-random number generator that relies on a hash algorithm,
- * that (a) starts its operation by hashing a <code>seed</code>, and then (b)
- * continuously re-hashing its output. If no hash algorithm name is specified
- * in the {@link Map} of attributes used to initialise the instance then the
+ * A simple pseudo-random number generator that relies on a hash algorithm, that
+ * (a) starts its operation by hashing a <code>seed</code>, and then (b)
+ * continuously re-hashing its output. If no hash algorithm name is specified in
+ * the {@link Map} of attributes used to initialise the instance then the
* SHA-160 algorithm is used as the underlying hash function. Also, if no
- * <code>seed</code> is given, an empty octet sequence is used.</p>
+ * <code>seed</code> is given, an empty octet sequence is used.
*/
-public class MDGenerator extends BasePRNG implements Cloneable
+public class MDGenerator
+ extends BasePRNG
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Property name of underlying hash algorithm for this generator. */
public static final String MD_NAME = "gnu.crypto.prng.md.hash.name";
@@ -67,23 +65,12 @@ public class MDGenerator extends BasePRNG implements Cloneable
/** The underlying hash instance. */
private IMessageDigest md;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public MDGenerator()
{
super(Registry.MD_PRNG);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BaseRandom ------------------------
-
public void setup(Map attributes)
{
// find out which hash to use
@@ -95,22 +82,15 @@ public class MDGenerator extends BasePRNG implements Cloneable
// ensure we have a reliable implementation of this hash
md = HashFactory.getInstance(Registry.SHA160_HASH);
}
- else
- { // a clone. reset it for reuse
- md.reset();
- }
- }
- else
- { // ensure we have a reliable implementation of this hash
- md = HashFactory.getInstance(underlyingMD);
+ else // a clone. reset it for reuse
+ md.reset();
}
-
+ else // ensure we have a reliable implementation of this hash
+ md = HashFactory.getInstance(underlyingMD);
// get the seeed
byte[] seed = (byte[]) attributes.get(SEEED);
if (seed == null)
- {
- seed = new byte[0];
- }
+ seed = new byte[0];
md.update(seed, 0, seed.length);
}
@@ -122,22 +102,20 @@ public class MDGenerator extends BasePRNG implements Cloneable
md.update(buffer, 0, buffer.length);
}
- public void addRandomByte (final byte b)
+ public void addRandomByte(final byte b)
{
if (md == null)
- throw new IllegalStateException ("not initialized");
- md.update (b);
+ throw new IllegalStateException("not initialized");
+ md.update(b);
}
- public void addRandomBytes (final byte[] buf, final int off, final int len)
+ public void addRandomBytes(final byte[] buf, final int off, final int len)
{
if (md == null)
- throw new IllegalStateException ("not initialized");
- md.update (buf, off, len);
+ throw new IllegalStateException("not initialized");
+ md.update(buf, off, len);
}
- // Cloneable interface implementation ---------------------------------------
-
public Object clone() throws CloneNotSupportedException
{
MDGenerator result = (MDGenerator) super.clone();
diff --git a/libjava/classpath/gnu/java/security/prng/PRNGFactory.java b/libjava/classpath/gnu/java/security/prng/PRNGFactory.java
index 8b5141456e6..ae15d053b82 100644
--- a/libjava/classpath/gnu/java/security/prng/PRNGFactory.java
+++ b/libjava/classpath/gnu/java/security/prng/PRNGFactory.java
@@ -42,60 +42,46 @@ import gnu.java.security.Registry;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
/**
- * <p>A Factory to instantiate pseudo random number generators.</p>
+ * A Factory to instantiate pseudo random number generators.
*/
-public class PRNGFactory implements Registry
+public class PRNGFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
protected PRNGFactory()
{
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a padding algorithm given its name.</p>
- *
+ * Returns an instance of a padding algorithm given its name.
+ *
* @param prng the case-insensitive name of the PRNG.
* @return an instance of the pseudo-random number generator.
* @exception InternalError if the implementation does not pass its self-
- * test.
+ * test.
*/
public static final IRandom getInstance(String prng)
{
if (prng == null)
- {
- return null;
- }
+ return null;
prng = prng.trim();
IRandom result = null;
if (prng.equalsIgnoreCase(MD_PRNG))
- {
- result = new MDGenerator();
- }
+ result = new MDGenerator();
return result;
}
/**
- * <p>Returns a {@link Set} of names of padding algorithms supported by this
- * <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of names of padding algorithms supported by this
+ * <i>Factory</i>.
+ *
* @return a {@link Set} of pseudo-random number generator algorithm names
- * (Strings).
+ * (Strings).
*/
public static final Set getNames()
{
@@ -103,7 +89,4 @@ public class PRNGFactory implements Registry
hs.add(MD_PRNG);
return Collections.unmodifiableSet(hs);
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/java/security/prng/RandomEvent.java b/libjava/classpath/gnu/java/security/prng/RandomEvent.java
index c07062125dc..fc4607a8a1e 100644
--- a/libjava/classpath/gnu/java/security/prng/RandomEvent.java
+++ b/libjava/classpath/gnu/java/security/prng/RandomEvent.java
@@ -41,12 +41,11 @@ package gnu.java.security.prng;
import java.util.EventObject;
/**
- * An interface for entropy accumulators that will be notified of random
- * events.
+ * A type for entropy accumulators that will be notified of random events.
*/
-public class RandomEvent extends EventObject
+public class RandomEvent
+ extends EventObject
{
-
private final byte sourceNumber;
private final byte poolNumber;
@@ -61,7 +60,7 @@ public class RandomEvent extends EventObject
this.poolNumber = poolNumber;
if (data.length == 0 || data.length > 32)
throw new IllegalArgumentException(
- "random events take between 1 and 32 bytes of data");
+ "random events take between 1 and 32 bytes of data");
this.data = (byte[]) data.clone();
}
@@ -79,4 +78,4 @@ public class RandomEvent extends EventObject
{
return data;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/java/security/prng/RandomEventListener.java b/libjava/classpath/gnu/java/security/prng/RandomEventListener.java
index 1dc14619fe9..beb9087f418 100644
--- a/libjava/classpath/gnu/java/security/prng/RandomEventListener.java
+++ b/libjava/classpath/gnu/java/security/prng/RandomEventListener.java
@@ -41,10 +41,10 @@ package gnu.java.security.prng;
import java.util.EventListener;
/**
- * An interface for entropy accumulators that will be notified of random
- * events.
+ * An interface for entropy accumulators that will be notified of random events.
*/
-public interface RandomEventListener extends EventListener
+public interface RandomEventListener
+ extends EventListener
{
void addRandomEvent(RandomEvent event);
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/java/security/provider/Gnu.java b/libjava/classpath/gnu/java/security/provider/Gnu.java
index 6ea96c1e4f3..62bb0a29eef 100644
--- a/libjava/classpath/gnu/java/security/provider/Gnu.java
+++ b/libjava/classpath/gnu/java/security/provider/Gnu.java
@@ -42,12 +42,16 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.Provider;
-public final class Gnu extends Provider
+public final class Gnu
+ extends Provider
{
public Gnu()
{
- super("GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores, Diffie-Hellman key agreement and key pair generator");
-
+ super("GNU", 1.0,
+ "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 "
+ + "Certificates and CRLs, PKIX certificate path validators, "
+ + "Collection cert stores, Diffie-Hellman key agreement and "
+ + "key pair generator");
AccessController.doPrivileged (new PrivilegedAction()
{
public Object run()
@@ -163,29 +167,41 @@ public final class Gnu extends Provider
put("Alg.Alias.KeyFactory.PKCS#8", "Encoded");
put("Alg.Alias.KeyFactory.PKCS8", "Encoded");
- put("MessageDigest.HAVAL", gnu.java.security.jce.hash.HavalSpi.class.getName());
+ put("MessageDigest.HAVAL",
+ gnu.java.security.jce.hash.HavalSpi.class.getName());
put("MessageDigest.HAVAL ImplementedIn", "Software");
- put("MessageDigest.MD2", gnu.java.security.jce.hash.MD2Spi.class.getName());
+ put("MessageDigest.MD2",
+ gnu.java.security.jce.hash.MD2Spi.class.getName());
put("MessageDigest.MD2 ImplementedIn", "Software");
- put("MessageDigest.MD4", gnu.java.security.jce.hash.MD4Spi.class.getName());
+ put("MessageDigest.MD4",
+ gnu.java.security.jce.hash.MD4Spi.class.getName());
put("MessageDigest.MD4 ImplementedIn", "Software");
- put("MessageDigest.MD5", gnu.java.security.jce.hash.MD5Spi.class.getName());
+ put("MessageDigest.MD5",
+ gnu.java.security.jce.hash.MD5Spi.class.getName());
put("MessageDigest.MD5 ImplementedIn", "Software");
- put("MessageDigest.RIPEMD128", gnu.java.security.jce.hash.RipeMD128Spi.class.getName());
+ put("MessageDigest.RIPEMD128",
+ gnu.java.security.jce.hash.RipeMD128Spi.class.getName());
put("MessageDigest.RIPEMD128 ImplementedIn", "Software");
- put("MessageDigest.RIPEMD160", gnu.java.security.jce.hash.RipeMD160Spi.class.getName());
+ put("MessageDigest.RIPEMD160",
+ gnu.java.security.jce.hash.RipeMD160Spi.class.getName());
put("MessageDigest.RIPEMD160 ImplementedIn", "Software");
- put("MessageDigest.SHA-160", gnu.java.security.jce.hash.Sha160Spi.class.getName());
+ put("MessageDigest.SHA-160",
+ gnu.java.security.jce.hash.Sha160Spi.class.getName());
put("MessageDigest.SHA-160 ImplementedIn", "Software");
- put("MessageDigest.SHA-256", gnu.java.security.jce.hash.Sha256Spi.class.getName());
+ put("MessageDigest.SHA-256",
+ gnu.java.security.jce.hash.Sha256Spi.class.getName());
put("MessageDigest.SHA-256 ImplementedIn", "Software");
- put("MessageDigest.SHA-384", gnu.java.security.jce.hash.Sha384Spi.class.getName());
+ put("MessageDigest.SHA-384",
+ gnu.java.security.jce.hash.Sha384Spi.class.getName());
put("MessageDigest.SHA-384 ImplementedIn", "Software");
- put("MessageDigest.SHA-512", gnu.java.security.jce.hash.Sha512Spi.class.getName());
+ put("MessageDigest.SHA-512",
+ gnu.java.security.jce.hash.Sha512Spi.class.getName());
put("MessageDigest.SHA-512 ImplementedIn", "Software");
- put("MessageDigest.TIGER", gnu.java.security.jce.hash.TigerSpi.class.getName());
+ put("MessageDigest.TIGER",
+ gnu.java.security.jce.hash.TigerSpi.class.getName());
put("MessageDigest.TIGER ImplementedIn", "Software");
- put("MessageDigest.WHIRLPOOL", gnu.java.security.jce.hash.WhirlpoolSpi.class.getName());
+ put("MessageDigest.WHIRLPOOL",
+ gnu.java.security.jce.hash.WhirlpoolSpi.class.getName());
put("MessageDigest.WHIRLPOOL ImplementedIn", "Software");
put("Alg.Alias.MessageDigest.SHS", "SHA-160");
@@ -224,29 +240,41 @@ public final class Gnu extends Provider
put("SecureRandom.SHA1PRNG",
gnu.java.security.jce.prng.Sha160RandomSpi.class.getName());
- put("SecureRandom.MD2PRNG", gnu.java.security.jce.prng.MD2RandomSpi.class.getName());
+ put("SecureRandom.MD2PRNG",
+ gnu.java.security.jce.prng.MD2RandomSpi.class.getName());
put("SecureRandom.MD2PRNG ImplementedIn", "Software");
- put("SecureRandom.MD4PRNG", gnu.java.security.jce.prng.MD4RandomSpi.class.getName());
+ put("SecureRandom.MD4PRNG",
+ gnu.java.security.jce.prng.MD4RandomSpi.class.getName());
put("SecureRandom.MD4PRNG ImplementedIn", "Software");
- put("SecureRandom.MD5PRNG", gnu.java.security.jce.prng.MD5RandomSpi.class.getName());
+ put("SecureRandom.MD5PRNG",
+ gnu.java.security.jce.prng.MD5RandomSpi.class.getName());
put("SecureRandom.MD5PRNG ImplementedIn", "Software");
- put("SecureRandom.RIPEMD128PRNG", gnu.java.security.jce.prng.RipeMD128RandomSpi.class.getName());
+ put("SecureRandom.RIPEMD128PRNG",
+ gnu.java.security.jce.prng.RipeMD128RandomSpi.class.getName());
put("SecureRandom.RIPEMD128PRNG ImplementedIn", "Software");
- put("SecureRandom.RIPEMD160PRNG", gnu.java.security.jce.prng.RipeMD160RandomSpi.class.getName());
+ put("SecureRandom.RIPEMD160PRNG",
+ gnu.java.security.jce.prng.RipeMD160RandomSpi.class.getName());
put("SecureRandom.RIPEMD160PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-160PRNG", gnu.java.security.jce.prng.Sha160RandomSpi.class.getName());
+ put("SecureRandom.SHA-160PRNG",
+ gnu.java.security.jce.prng.Sha160RandomSpi.class.getName());
put("SecureRandom.SHA-160PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-256PRNG", gnu.java.security.jce.prng.Sha256RandomSpi.class.getName());
+ put("SecureRandom.SHA-256PRNG",
+ gnu.java.security.jce.prng.Sha256RandomSpi.class.getName());
put("SecureRandom.SHA-256PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-384PRNG", gnu.java.security.jce.prng.Sha384RandomSpi.class.getName());
+ put("SecureRandom.SHA-384PRNG",
+ gnu.java.security.jce.prng.Sha384RandomSpi.class.getName());
put("SecureRandom.SHA-384PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-512PRNG", gnu.java.security.jce.prng.Sha512RandomSpi.class.getName());
+ put("SecureRandom.SHA-512PRNG",
+ gnu.java.security.jce.prng.Sha512RandomSpi.class.getName());
put("SecureRandom.SHA-512PRNG ImplementedIn", "Software");
- put("SecureRandom.TIGERPRNG", gnu.java.security.jce.prng.TigerRandomSpi.class.getName());
+ put("SecureRandom.TIGERPRNG",
+ gnu.java.security.jce.prng.TigerRandomSpi.class.getName());
put("SecureRandom.TIGERPRNG ImplementedIn", "Software");
- put("SecureRandom.HAVALPRNG", gnu.java.security.jce.prng.HavalRandomSpi.class.getName());
+ put("SecureRandom.HAVALPRNG",
+ gnu.java.security.jce.prng.HavalRandomSpi.class.getName());
put("SecureRandom.HAVALPRNG ImplementedIn", "Software");
- put("SecureRandom.WHIRLPOOLPRNG", gnu.java.security.jce.prng.WhirlpoolRandomSpi.class.getName());
+ put("SecureRandom.WHIRLPOOLPRNG",
+ gnu.java.security.jce.prng.WhirlpoolRandomSpi.class.getName());
put("SecureRandom.WHIRLPOOLPRNG ImplementedIn", "Software");
put("Alg.Alias.SecureRandom.SHA-1PRNG", "SHA-160PRNG");
diff --git a/libjava/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java b/libjava/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java
index 880163731f1..cdfad3f61c2 100644
--- a/libjava/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java
+++ b/libjava/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java
@@ -1,5 +1,5 @@
/* PKIXCertPathValidatorImpl.java -- PKIX certificate path validator.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.provider;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.key.dss.DSSPublicKey;
@@ -81,63 +82,48 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.util.logging.Logger;
/**
- * An implementation of the Public Key Infrastructure's X.509
- * certificate path validation algorithm.
- *
- * <p>See <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280:
- * Internet X.509 Public Key Infrastructure Certificate and
- * Certificate Revocation List (CRL) Profile</a>.
- *
+ * An implementation of the Public Key Infrastructure's X.509 certificate path
+ * validation algorithm.
+ * <p>
+ * See <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280: Internet X.509
+ * Public Key Infrastructure Certificate and Certificate Revocation List (CRL)
+ * Profile</a>.
+ *
* @author Casey Marshall (rsdio@metastatic.org)
*/
-public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
+public class PKIXCertPathValidatorImpl
+ extends CertPathValidatorSpi
{
-
- // Constants.
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug (String msg)
- {
- System.err.print (">> PKIXCertPathValidatorImpl: ");
- System.err.println (msg);
- }
+ private static final Logger log = Logger.getLogger(PKIXCertPathValidatorImpl.class.getName());
public static final String ANY_POLICY = "2.5.29.32.0";
- // Constructor.
- // -------------------------------------------------------------------------
-
public PKIXCertPathValidatorImpl()
{
super();
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
public CertPathValidatorResult engineValidate(CertPath path,
CertPathParameters params)
- throws CertPathValidatorException, InvalidAlgorithmParameterException
+ throws CertPathValidatorException, InvalidAlgorithmParameterException
{
- if (!(params instanceof PKIXParameters))
+ if (! (params instanceof PKIXParameters))
throw new InvalidAlgorithmParameterException("not a PKIXParameters object");
-
// First check if the certificate path is valid.
//
// This means that:
//
- // (a) for all x in {1, ..., n-1}, the subject of certificate x is
- // the issuer of certificate x+1;
+ // (a) for all x in {1, ..., n-1}, the subject of certificate x is
+ // the issuer of certificate x+1;
//
- // (b) for all x in {1, ..., n}, the certificate was valid at the
- // time in question.
+ // (b) for all x in {1, ..., n}, the certificate was valid at the
+ // time in question.
//
// Because this is the X.509 algorithm, we also check if all
// cerificates are of type X509Certificate.
-
PolicyNodeImpl rootNode = new PolicyNodeImpl();
Set initPolicies = ((PKIXParameters) params).getInitialPolicies();
rootNode.setValidPolicy(ANY_POLICY);
@@ -160,7 +146,6 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
{
throw new CertPathValidatorException("invalid certificate path");
}
-
String sigProvider = ((PKIXParameters) params).getSigProvider();
PublicKey prevKey = null;
Date now = ((PKIXParameters) params).getDate();
@@ -178,7 +163,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
throw new CertPathValidatorException(ce.toString());
}
Set uce = getCritExts(p[i]);
- for (Iterator check = checks.iterator(); check.hasNext(); )
+ for (Iterator check = checks.iterator(); check.hasNext();)
{
try
{
@@ -188,23 +173,21 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
{
}
}
-
PolicyConstraint constr = null;
if (p[i] instanceof GnuPKIExtension)
{
- Extension pcx =
- ((GnuPKIExtension) p[i]).getExtension (PolicyConstraint.ID);
+ Extension pcx = ((GnuPKIExtension) p[i]).getExtension(PolicyConstraint.ID);
if (pcx != null)
constr = (PolicyConstraint) pcx.getValue();
}
else
{
- byte[] pcx = p[i].getExtensionValue (PolicyConstraint.ID.toString());
+ byte[] pcx = p[i].getExtensionValue(PolicyConstraint.ID.toString());
if (pcx != null)
{
try
{
- constr = new PolicyConstraint (pcx);
+ constr = new PolicyConstraint(pcx);
}
catch (Exception x)
{
@@ -212,14 +195,10 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
}
}
if (constr != null && constr.getRequireExplicitPolicy() >= 0)
- {
- policyConstraints.add (new int[]
- { p.length-i, constr.getRequireExplicitPolicy() });
- }
-
- updatePolicyTree(p[i], rootNode, p.length-i, (PKIXParameters) params,
- checkExplicitPolicy (p.length-i, policyConstraints));
-
+ policyConstraints.add(new int[] { p.length - i,
+ constr.getRequireExplicitPolicy() });
+ updatePolicyTree(p[i], rootNode, p.length - i, (PKIXParameters) params,
+ checkExplicitPolicy(p.length - i, policyConstraints));
// The rest of the tests involve this cert's relationship with the
// next in the path. If this cert is the end entity, we can stop.
if (i == 0)
@@ -236,36 +215,35 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
// If the DSA public key is missing its parameters, use those
// from the previous cert's key.
if (dsa == null || dsa.getP() == null || dsa.getG() == null
- || dsa.getQ() == null)
+ || dsa.getQ() == null)
{
if (prevKey == null)
throw new InvalidKeyException("DSA keys not chainable");
- if (!(prevKey instanceof DSAPublicKey))
+ if (! (prevKey instanceof DSAPublicKey))
throw new InvalidKeyException("DSA keys not chainable");
dsa = ((DSAPublicKey) prevKey).getParams();
pubKey = new DSSPublicKey(Registry.X509_ENCODING_ID,
- dsa.getP(),
- dsa.getQ(),
+ dsa.getP(), dsa.getQ(),
dsa.getG(),
((DSAPublicKey) pubKey).getY());
}
}
if (sigProvider == null)
- p[i-1].verify(pubKey);
+ p[i - 1].verify(pubKey);
else
- p[i-1].verify(pubKey, sigProvider);
+ p[i - 1].verify(pubKey, sigProvider);
prevKey = pubKey;
}
catch (Exception e)
{
throw new CertPathValidatorException(e.toString());
}
- if (!p[i].getSubjectDN().equals(p[i-1].getIssuerDN()))
+ if (! p[i].getSubjectDN().equals(p[i - 1].getIssuerDN()))
throw new CertPathValidatorException("issuer DN mismatch");
- boolean[] issuerUid = p[i-1].getIssuerUniqueID();
+ boolean[] issuerUid = p[i - 1].getIssuerUniqueID();
boolean[] subjectUid = p[i].getSubjectUniqueID();
if (issuerUid != null && subjectUid != null)
- if (!Arrays.equals(issuerUid, subjectUid))
+ if (! Arrays.equals(issuerUid, subjectUid))
throw new CertPathValidatorException("UID mismatch");
// Check the certificate against the revocation lists.
@@ -282,7 +260,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
}
List certStores = ((PKIXParameters) params).getCertStores();
List crls = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext(); )
+ for (Iterator it = certStores.iterator(); it.hasNext();)
{
CertStore cs = (CertStore) it.next();
try
@@ -297,30 +275,30 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
if (crls.isEmpty())
throw new CertPathValidatorException("no CRLs for issuer");
boolean certOk = false;
- for (Iterator it = crls.iterator(); it.hasNext(); )
+ for (Iterator it = crls.iterator(); it.hasNext();)
{
CRL crl = (CRL) it.next();
- if (!(crl instanceof X509CRL))
+ if (! (crl instanceof X509CRL))
continue;
X509CRL xcrl = (X509CRL) crl;
- if (!checkCRL(xcrl, p, now, p[i], pubKey, certStores))
+ if (! checkCRL(xcrl, p, now, p[i], pubKey, certStores))
continue;
- if (xcrl.isRevoked(p[i-1]))
+ if (xcrl.isRevoked(p[i - 1]))
throw new CertPathValidatorException("certificate is revoked");
else
certOk = true;
}
- if (!certOk)
- throw new CertPathValidatorException("certificate's validity could not be determined");
+ if (! certOk)
+ throw new CertPathValidatorException(
+ "certificate's validity could not be determined");
}
}
rootNode.setReadOnly();
-
// Now ensure that the first certificate in the chain was issued
// by a trust anchor.
Exception cause = null;
Set anchors = ((PKIXParameters) params).getTrustAnchors();
- for (Iterator i = anchors.iterator(); i.hasNext(); )
+ for (Iterator i = anchors.iterator(); i.hasNext();)
{
TrustAnchor anchor = (TrustAnchor) i.next();
X509Certificate anchorCert = null;
@@ -338,7 +316,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
{
if (anchorCert != null)
anchorCert.checkValidity(now);
- p[p.length-1].verify(anchorKey);
+ p[p.length - 1].verify(anchorKey);
if (anchorCert != null && anchorCert.getBasicConstraints() >= 0
&& anchorCert.getBasicConstraints() < p.length)
continue;
@@ -358,7 +336,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
selector.addIssuerName(anchor.getCAName());
List certStores = ((PKIXParameters) params).getCertStores();
List crls = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext(); )
+ for (Iterator it = certStores.iterator(); it.hasNext();)
{
CertStore cs = (CertStore) it.next();
try
@@ -372,10 +350,10 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
}
if (crls.isEmpty())
continue;
- for (Iterator it = crls.iterator(); it.hasNext(); )
+ for (Iterator it = crls.iterator(); it.hasNext();)
{
CRL crl = (CRL) it.next();
- if (!(crl instanceof X509CRL))
+ if (! (crl instanceof X509CRL))
continue;
X509CRL xcrl = (X509CRL) crl;
try
@@ -389,11 +367,10 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
Date nextUpdate = xcrl.getNextUpdate();
if (nextUpdate != null && nextUpdate.compareTo(now) < 0)
continue;
- if (xcrl.isRevoked(p[p.length-1]))
+ if (xcrl.isRevoked(p[p.length - 1]))
throw new CertPathValidatorException("certificate is revoked");
}
}
-
// The chain is valid; return the result.
return new PKIXCertPathValidatorResult(anchor, rootNode,
p[0].getPublicKey());
@@ -404,44 +381,39 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
continue;
}
}
-
// The path is not valid.
CertPathValidatorException cpve =
- new CertPathValidatorException("path validation failed");
+ new CertPathValidatorException("path validation failed");
if (cause != null)
- cpve.initCause (cause);
+ cpve.initCause(cause);
throw cpve;
}
- // Own methods.
- // -------------------------------------------------------------------------
-
/**
- * Check if a given CRL is acceptable for checking the revocation status
- * of certificates in the path being checked.
- *
- * <p>The CRL is accepted iff:</p>
- *
+ * Check if a given CRL is acceptable for checking the revocation status of
+ * certificates in the path being checked.
+ * <p>
+ * The CRL is accepted iff:
* <ol>
* <li>The <i>nextUpdate</i> field (if present) is in the future.</li>
* <li>The CRL does not contain any unsupported critical extensions.</li>
* <li>The CRL is signed by one of the certificates in the path, or,</li>
- * <li>The CRL is signed by the given public key and was issued by the
- * public key's subject, or,</li>
- * <li>The CRL is signed by a certificate in the given cert stores, and
- * that cert is signed by one of the certificates in the path.</li>
+ * <li>The CRL is signed by the given public key and was issued by the public
+ * key's subject, or,</li>
+ * <li>The CRL is signed by a certificate in the given cert stores, and that
+ * cert is signed by one of the certificates in the path.</li>
* </ol>
- *
+ *
* @param crl The CRL being checked.
* @param path The path this CRL is being checked against.
* @param now The value to use as 'now'.
- * @param pubKeySubject The subject of the public key.
+ * @param pubKeyCert The certificate authenticating the public key.
* @param pubKey The public key to check.
* @return True if the CRL is acceptable.
*/
- private static boolean checkCRL(X509CRL crl, X509Certificate[] path, Date now,
- X509Certificate pubKeyCert, PublicKey pubKey,
- List certStores)
+ private static boolean checkCRL(X509CRL crl, X509Certificate[] path,
+ Date now, X509Certificate pubKeyCert,
+ PublicKey pubKey, List certStores)
{
Date nextUpdate = crl.getNextUpdate();
if (nextUpdate != null && nextUpdate.compareTo(now) < 0)
@@ -450,12 +422,12 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
return false;
for (int i = 0; i < path.length; i++)
{
- if (!path[i].getSubjectDN().equals(crl.getIssuerDN()))
+ if (! path[i].getSubjectDN().equals(crl.getIssuerDN()))
continue;
boolean[] keyUsage = path[i].getKeyUsage();
if (keyUsage != null)
{
- if (!keyUsage[KeyUsage.CRL_SIGN])
+ if (! keyUsage[KeyUsage.CRL_SIGN])
continue;
}
try
@@ -474,7 +446,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
boolean[] keyUsage = pubKeyCert.getKeyUsage();
if (keyUsage != null)
{
- if (!keyUsage[KeyUsage.CRL_SIGN])
+ if (! keyUsage[KeyUsage.CRL_SIGN])
throw new Exception();
}
crl.verify(pubKey);
@@ -489,7 +461,7 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
X509CertSelectorImpl select = new X509CertSelectorImpl();
select.addSubjectName(crl.getIssuerDN());
List certs = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext(); )
+ for (Iterator it = certStores.iterator(); it.hasNext();)
{
CertStore cs = (CertStore) it.next();
try
@@ -500,17 +472,17 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
{
}
}
- for (Iterator it = certs.iterator(); it.hasNext(); )
+ for (Iterator it = certs.iterator(); it.hasNext();)
{
X509Certificate c = (X509Certificate) it.next();
for (int i = 0; i < path.length; i++)
{
- if (!c.getIssuerDN().equals(path[i].getSubjectDN()))
+ if (! c.getIssuerDN().equals(path[i].getSubjectDN()))
continue;
boolean[] keyUsage = c.getKeyUsage();
if (keyUsage != null)
{
- if (!keyUsage[KeyUsage.CRL_SIGN])
+ if (! keyUsage[KeyUsage.CRL_SIGN])
continue;
}
try
@@ -542,10 +514,10 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
if (cert instanceof GnuPKIExtension)
{
Collection exts = ((GnuPKIExtension) cert).getExtensions();
- for (Iterator it = exts.iterator(); it.hasNext(); )
+ for (Iterator it = exts.iterator(); it.hasNext();)
{
Extension ext = (Extension) it.next();
- if (ext.isCritical() && !ext.isSupported())
+ if (ext.isCritical() && ! ext.isSupported())
s.add(ext.getOid().toString());
}
}
@@ -558,13 +530,13 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
* Perform a basic sanity check on the CA certificate at <code>index</code>.
*/
private static void basicSanity(X509Certificate[] path, int index)
- throws CertPathValidatorException
+ throws CertPathValidatorException
{
X509Certificate cert = path[index];
int pathLen = 0;
for (int i = index - 1; i > 0; i--)
{
- if (!path[i].getIssuerDN().equals(path[i].getSubjectDN()))
+ if (! path[i].getIssuerDN().equals(path[i].getSubjectDN()))
pathLen++;
}
Extension e = null;
@@ -585,25 +557,30 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
if (e == null)
throw new CertPathValidatorException("no basicConstraints");
BasicConstraints bc = (BasicConstraints) e.getValue();
- if (!bc.isCA())
- throw new CertPathValidatorException("certificate cannot be used to verify signatures");
- if (bc.getPathLengthConstraint() >= 0 && bc.getPathLengthConstraint() < pathLen)
+ if (! bc.isCA())
+ throw new CertPathValidatorException(
+ "certificate cannot be used to verify signatures");
+ if (bc.getPathLengthConstraint() >= 0
+ && bc.getPathLengthConstraint() < pathLen)
throw new CertPathValidatorException("path is too long");
boolean[] keyUsage = cert.getKeyUsage();
if (keyUsage != null)
{
- if (!keyUsage[KeyUsage.KEY_CERT_SIGN])
- throw new CertPathValidatorException("certificate cannot be used to sign certificates");
+ if (! keyUsage[KeyUsage.KEY_CERT_SIGN])
+ throw new CertPathValidatorException(
+ "certificate cannot be used to sign certificates");
}
}
- private static void updatePolicyTree(X509Certificate cert, PolicyNodeImpl root,
- int depth, PKIXParameters params,
+ private static void updatePolicyTree(X509Certificate cert,
+ PolicyNodeImpl root, int depth,
+ PKIXParameters params,
boolean explicitPolicy)
- throws CertPathValidatorException
+ throws CertPathValidatorException
{
- if (DEBUG) debug("updatePolicyTree depth == " + depth);
+ if (Configuration.DEBUG)
+ log.fine("updatePolicyTree depth == " + depth);
Set nodes = new HashSet();
LinkedList stack = new LinkedList();
Iterator current = null;
@@ -614,21 +591,24 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
while (current.hasNext())
{
PolicyNodeImpl p = (PolicyNodeImpl) current.next();
- if (DEBUG) debug("visiting node == " + p);
+ if (Configuration.DEBUG)
+ log.fine("visiting node == " + p);
if (p.getDepth() == depth - 1)
{
- if (DEBUG) debug("added node");
+ if (Configuration.DEBUG)
+ log.fine("added node");
nodes.add(p);
}
else
{
- if (DEBUG) debug("skipped node");
+ if (Configuration.DEBUG)
+ log.fine("skipped node");
stack.addLast(current);
current = p.getChildren();
}
}
}
- while (!stack.isEmpty());
+ while (! stack.isEmpty());
Extension e = null;
CertificatePolicies policies = null;
@@ -646,18 +626,23 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
else
cp = Collections.EMPTY_LIST;
boolean match = false;
- if (DEBUG) debug("nodes are == " + nodes);
- if (DEBUG) debug("cert policies are == " + cp);
- for (Iterator it = nodes.iterator(); it.hasNext(); )
+ if (Configuration.DEBUG)
+ {
+ log.fine("nodes are == " + nodes);
+ log.fine("cert policies are == " + cp);
+ }
+ for (Iterator it = nodes.iterator(); it.hasNext();)
{
PolicyNodeImpl parent = (PolicyNodeImpl) it.next();
- if (DEBUG) debug("adding policies to " + parent);
- for (Iterator it2 = cp.iterator(); it2.hasNext(); )
+ if (Configuration.DEBUG)
+ log.fine("adding policies to " + parent);
+ for (Iterator it2 = cp.iterator(); it2.hasNext();)
{
OID policy = (OID) it2.next();
- if (DEBUG) debug("trying to add policy == " + policy);
- if (policy.toString().equals(ANY_POLICY) &&
- params.isAnyPolicyInhibited())
+ if (Configuration.DEBUG)
+ log.fine("trying to add policy == " + policy);
+ if (policy.toString().equals(ANY_POLICY)
+ && params.isAnyPolicyInhibited())
continue;
PolicyNodeImpl child = new PolicyNodeImpl();
child.setValidPolicy(policy.toString());
@@ -672,32 +657,34 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi
parent.addChild(child);
match = true;
}
- else if (ANY_POLICY.equals (policy.toString()))
+ else if (ANY_POLICY.equals(policy.toString()))
{
- parent.addChild (child);
+ parent.addChild(child);
match = true;
}
if (match && policies != null)
{
- List qualifiers = policies.getPolicyQualifierInfos (policy);
+ List qualifiers = policies.getPolicyQualifierInfos(policy);
if (qualifiers != null)
- child.addAllPolicyQualifiers (qualifiers);
+ child.addAllPolicyQualifiers(qualifiers);
}
}
}
- if (!match && (params.isExplicitPolicyRequired() || explicitPolicy))
+ if (! match && (params.isExplicitPolicyRequired() || explicitPolicy))
throw new CertPathValidatorException("policy tree building failed");
}
- private boolean checkExplicitPolicy (int depth, List explicitPolicies)
+ private boolean checkExplicitPolicy(int depth, List explicitPolicies)
{
- if (DEBUG) debug ("checkExplicitPolicy depth=" + depth);
- for (Iterator it = explicitPolicies.iterator(); it.hasNext(); )
+ if (Configuration.DEBUG)
+ log.fine("checkExplicitPolicy depth=" + depth);
+ for (Iterator it = explicitPolicies.iterator(); it.hasNext();)
{
int[] i = (int[]) it.next();
int caDepth = i[0];
int limit = i[1];
- if (DEBUG) debug (" caDepth=" + caDepth + " limit=" + limit);
+ if (Configuration.DEBUG)
+ log.fine(" caDepth=" + caDepth + " limit=" + limit);
if (depth - caDepth >= limit)
return true;
}
diff --git a/libjava/classpath/gnu/java/security/provider/X509CertificateFactory.java b/libjava/classpath/gnu/java/security/provider/X509CertificateFactory.java
index 1a415eabb05..7d61779f937 100644
--- a/libjava/classpath/gnu/java/security/provider/X509CertificateFactory.java
+++ b/libjava/classpath/gnu/java/security/provider/X509CertificateFactory.java
@@ -59,30 +59,24 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-public class X509CertificateFactory extends CertificateFactorySpi
+public class X509CertificateFactory
+ extends CertificateFactorySpi
{
-
- // Constants.
- // ------------------------------------------------------------------------
-
public static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----";
+
public static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
+
public static final String BEGIN_X509_CRL = "-----BEGIN X509 CRL-----";
- public static final String END_X509_CRL = "-----END X509 CRL-----";
- // Constructors.
- // ------------------------------------------------------------------------
+ public static final String END_X509_CRL = "-----END X509 CRL-----";
public X509CertificateFactory()
{
super();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public Certificate engineGenerateCertificate(InputStream inStream)
- throws CertificateException
+ throws CertificateException
{
try
{
@@ -91,13 +85,13 @@ public class X509CertificateFactory extends CertificateFactorySpi
catch (IOException ioe)
{
CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause (ioe);
+ ce.initCause(ioe);
throw ce;
}
}
public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException
+ throws CertificateException
{
LinkedList certs = new LinkedList();
while (true)
@@ -113,7 +107,7 @@ public class X509CertificateFactory extends CertificateFactorySpi
catch (IOException ioe)
{
CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause (ioe);
+ ce.initCause(ioe);
throw ce;
}
}
@@ -129,13 +123,13 @@ public class X509CertificateFactory extends CertificateFactorySpi
catch (IOException ioe)
{
CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause (ioe);
+ crle.initCause(ioe);
throw crle;
}
}
public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException
+ throws CRLException
{
LinkedList crls = new LinkedList();
while (true)
@@ -151,7 +145,7 @@ public class X509CertificateFactory extends CertificateFactorySpi
catch (IOException ioe)
{
CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause (ioe);
+ crle.initCause(ioe);
throw crle;
}
}
@@ -164,13 +158,13 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
public CertPath engineGenerateCertPath(InputStream in)
- throws CertificateEncodingException
+ throws CertificateEncodingException
{
return new X509CertPath(in);
}
public CertPath engineGenerateCertPath(InputStream in, String encoding)
- throws CertificateEncodingException
+ throws CertificateEncodingException
{
return new X509CertPath(in, encoding);
}
@@ -180,21 +174,17 @@ public class X509CertificateFactory extends CertificateFactorySpi
return X509CertPath.ENCODINGS.iterator();
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private X509Certificate generateCert(InputStream inStream)
- throws IOException, CertificateException
+ throws IOException, CertificateException
{
if (inStream == null)
throw new CertificateException("missing input stream");
- if (!inStream.markSupported())
+ if (! inStream.markSupported())
inStream = new BufferedInputStream(inStream, 8192);
inStream.mark(20);
int i = inStream.read();
if (i == -1)
throw new EOFException();
-
// If the input is in binary DER format, the first byte MUST be
// 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
// UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
@@ -217,9 +207,9 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
while (i != '\n' && i != '\r');
}
- while (!line.toString().equals(BEGIN_CERTIFICATE));
+ while (! line.toString().equals(BEGIN_CERTIFICATE));
X509Certificate ret = new X509Certificate(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
+ new BufferedInputStream(new Base64InputStream(inStream), 8192));
line.setLength(0);
line.append('-'); // Base64InputStream will eat this.
do
@@ -232,7 +222,7 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
while (i != '\n' && i != '\r');
// XXX ???
- if (!line.toString().equals(END_CERTIFICATE))
+ if (! line.toString().equals(END_CERTIFICATE))
throw new CertificateException("no end-of-certificate marker");
return ret;
}
@@ -243,18 +233,17 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
}
- private X509CRL generateCRL(InputStream inStream)
- throws IOException, CRLException
+ private X509CRL generateCRL(InputStream inStream) throws IOException,
+ CRLException
{
if (inStream == null)
throw new CRLException("missing input stream");
- if (!inStream.markSupported())
+ if (! inStream.markSupported())
inStream = new BufferedInputStream(inStream, 8192);
inStream.mark(20);
int i = inStream.read();
if (i == -1)
throw new EOFException();
-
// If the input is in binary DER format, the first byte MUST be
// 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
// UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
@@ -277,9 +266,9 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
while (i != '\n' && i != '\r');
}
- while (!line.toString().startsWith(BEGIN_X509_CRL));
+ while (! line.toString().startsWith(BEGIN_X509_CRL));
X509CRL ret = new X509CRL(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
+ new BufferedInputStream(new Base64InputStream(inStream), 8192));
line.setLength(0);
line.append('-'); // Base64InputStream will eat this.
do
@@ -292,7 +281,7 @@ public class X509CertificateFactory extends CertificateFactorySpi
}
while (i != '\n' && i != '\r');
// XXX ???
- if (!line.toString().startsWith(END_X509_CRL))
+ if (! line.toString().startsWith(END_X509_CRL))
throw new CRLException("no end-of-CRL marker");
return ret;
}
diff --git a/libjava/classpath/gnu/java/security/sig/BaseSignature.java b/libjava/classpath/gnu/java/security/sig/BaseSignature.java
index dd964d4819d..9c76cacba0f 100644
--- a/libjava/classpath/gnu/java/security/sig/BaseSignature.java
+++ b/libjava/classpath/gnu/java/security/sig/BaseSignature.java
@@ -49,15 +49,11 @@ import java.util.Map;
import java.util.Random;
/**
- * <p>A base abstract class to facilitate implementations of concrete
- * Signatures.</p>
+ * A base abstract class to facilitate implementations of concrete Signatures.
*/
-public abstract class BaseSignature implements ISignature
+public abstract class BaseSignature
+ implements ISignature
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The canonical name of this signature scheme. */
protected String schemeName;
@@ -79,9 +75,6 @@ public abstract class BaseSignature implements ISignature
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial constructor.
*
@@ -101,14 +94,6 @@ public abstract class BaseSignature implements ISignature
this.md = md;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.sig.ISignature interface implementation ----------------------
-
public String name()
{
return schemeName + "-" + md.name();
@@ -117,51 +102,41 @@ public abstract class BaseSignature implements ISignature
public void setupVerify(Map attributes) throws IllegalArgumentException
{
setup(attributes);
-
// do we have a public key?
PublicKey key = (PublicKey) attributes.get(VERIFIER_KEY);
if (key != null)
- {
- setupForVerification(key);
- }
+ setupForVerification(key);
}
public void setupSign(Map attributes) throws IllegalArgumentException
{
setup(attributes);
-
// do we have a private key?
PrivateKey key = (PrivateKey) attributes.get(SIGNER_KEY);
if (key != null)
- {
- setupForSigning(key);
- }
+ setupForSigning(key);
}
public void update(byte b)
{
if (md == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
+
md.update(b);
}
public void update(byte[] b, int off, int len)
{
if (md == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
+
md.update(b, off, len);
}
public Object sign()
{
if (md == null || privateKey == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return generateSignature();
}
@@ -169,15 +144,11 @@ public abstract class BaseSignature implements ISignature
public boolean verify(Object sig)
{
if (md == null || publicKey == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return verifySignature(sig);
}
- // abstract methods to be implemented by concrete subclasses ---------------
-
public abstract Object clone();
protected abstract void setupForVerification(PublicKey key)
@@ -191,8 +162,6 @@ public abstract class BaseSignature implements ISignature
protected abstract boolean verifySignature(Object signature)
throws IllegalStateException;
- // Other instance methods --------------------------------------------------
-
/** Initialises the internal fields of this instance. */
protected void init()
{
@@ -204,33 +173,27 @@ public abstract class BaseSignature implements ISignature
}
/**
- * <p>Fills the designated byte array with random data.</p>
- *
+ * Fills the designated byte array with random data.
+ *
* @param buffer the byte array to fill with random data.
*/
protected void nextRandomBytes(byte[] buffer)
{
if (rnd != null)
- {
- rnd.nextBytes(buffer);
- }
+ rnd.nextBytes(buffer);
else if (irnd != null)
- {
- try
- {
- irnd.nextBytes(buffer, 0, buffer.length);
- }
- catch (IllegalStateException x)
- {
- throw new RuntimeException("nextRandomBytes(): "
- + String.valueOf(x));
- }
- catch (LimitReachedException x)
- {
- throw new RuntimeException("nextRandomBytes(): "
- + String.valueOf(x));
- }
- }
+ try
+ {
+ irnd.nextBytes(buffer, 0, buffer.length);
+ }
+ catch (IllegalStateException x)
+ {
+ throw new RuntimeException("nextRandomBytes(): " + x);
+ }
+ catch (LimitReachedException x)
+ {
+ throw new RuntimeException("nextRandomBytes(): " + x);
+ }
else
getDefaultPRNG().nextBytes(buffer);
}
@@ -238,17 +201,12 @@ public abstract class BaseSignature implements ISignature
private void setup(Map attributes)
{
init();
-
// do we have a Random or SecureRandom, or should we use our own?
Object obj = attributes.get(SOURCE_OF_RANDOMNESS);
if (obj instanceof Random)
- {
- rnd = (Random) obj;
- }
+ rnd = (Random) obj;
else if (obj instanceof IRandom)
- {
- irnd = (IRandom) obj;
- }
+ irnd = (IRandom) obj;
}
private PRNG getDefaultPRNG()
diff --git a/libjava/classpath/gnu/java/security/sig/ISignature.java b/libjava/classpath/gnu/java/security/sig/ISignature.java
index e77f39d2cf1..ff25f29d9fa 100644
--- a/libjava/classpath/gnu/java/security/sig/ISignature.java
+++ b/libjava/classpath/gnu/java/security/sig/ISignature.java
@@ -41,28 +41,24 @@ package gnu.java.security.sig;
import java.util.Map;
/**
- * <p>The visible methods of every signature-with-appendix scheme.</p>
- *
- * <p>The Handbook of Applied Cryptography (HAC), by A. Menezes &amp; al. states:
+ * The visible methods of every signature-with-appendix scheme.
+ * <p>
+ * The Handbook of Applied Cryptography (HAC), by A. Menezes &amp; al. states:
* "Digital signature schemes which require the message as input to the
- * verification algorithm are called <i>digital signature schemes with
- * appendix</i>. ... They rely on cryptographic hash functions rather than
- * customised redundancy functions, and are less prone to existential forgery
- * attacks."</p>
- *
- * <p>References:</p>
+ * verification algorithm are called <i>digital signature schemes with appendix</i>.
+ * ... They rely on cryptographic hash functions rather than customised
+ * redundancy functions, and are less prone to existential forgery attacks."
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac/">Handbook of Applied
- * Cryptography</a>, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
- * Vanstone. Section 11.2.2 Digital signature schemes with appendix.</li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac/">Handbook of Applied
+ * Cryptography</a>, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
+ * Vanstone. Section 11.2.2 Digital signature schemes with appendix.</li>
* </ol>
*/
-public interface ISignature extends Cloneable
+public interface ISignature
+ extends Cloneable
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/** Property name of the verifier's public key. */
public static final String VERIFIER_KEY = "gnu.crypto.sig.public.key";
@@ -71,96 +67,93 @@ public interface ISignature extends Cloneable
/**
* Property name of an optional {@link java.security.SecureRandom},
- * {@link java.util.Random}, or {@link gnu.crypto.prng.IRandom} instance to
- * use. The default is to use a classloader singleton from
- * {@link gnu.crypto.util.PRNG}.
+ * {@link java.util.Random}, or {@link gnu.java.security.prng.IRandom}
+ * instance to use. The default is to use a classloader singleton from
+ * {@link gnu.java.security.util.PRNG}.
*/
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.sig.prng";
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of this signature scheme.</p>
- *
+ * Returns the canonical name of this signature scheme.
+ *
* @return the canonical name of this instance.
*/
String name();
/**
- * <p>Initialises this instance for signature verification.</p>
- *
+ * Initialises this instance for signature verification.
+ *
* @param attributes the attributes to use for setting up this instance.
* @throws IllegalArgumentException if the designated public key is not
- * appropriate for this signature scheme.
+ * appropriate for this signature scheme.
* @see #SOURCE_OF_RANDOMNESS
* @see #VERIFIER_KEY
*/
void setupVerify(Map attributes) throws IllegalArgumentException;
/**
- * <p>Initialises this instance for signature generation.</p>
- *
+ * Initialises this instance for signature generation.
+ *
* @param attributes the attributes to use for setting up this instance.
* @throws IllegalArgumentException if the designated private key is not
- * appropriate for this signature scheme.
+ * appropriate for this signature scheme.
* @see #SOURCE_OF_RANDOMNESS
* @see #SIGNER_KEY
*/
void setupSign(Map attributes) throws IllegalArgumentException;
/**
- * <p>Digests one byte of a message for signing or verification purposes.</p>
- *
+ * Digests one byte of a message for signing or verification purposes.
+ *
* @param b the message byte to digest.
- * @throws IllegalStateException if this instance was not setup for
- * signature generation/verification.
+ * @throws IllegalStateException if this instance was not setup for signature
+ * generation/verification.
*/
void update(byte b) throws IllegalStateException;
/**
- * <p>Digests a sequence of bytes from a message for signing or verification
- * purposes.</p>
- *
+ * Digests a sequence of bytes from a message for signing or verification
+ * purposes.
+ *
* @param buffer the byte sequence to consider.
* @param offset the byte poisition in <code>buffer</code> of the first byte
- * to consider.
- * @param length the number of bytes in <code>buffer</code> starting from the
- * byte at index <code>offset</code> to digest.
- * @throws IllegalStateException if this instance was not setup for
- * signature generation/verification.
+ * to consider.
+ * @param length the number of bytes in <code>buffer</code> starting from
+ * the byte at index <code>offset</code> to digest.
+ * @throws IllegalStateException if this instance was not setup for signature
+ * generation/verification.
*/
void update(byte[] buffer, int offset, int length)
throws IllegalStateException;
/**
- * <p>Terminates a signature generation phase by digesting and processing the
- * context of the underlying message digest algorithm instance.</p>
- *
+ * Terminates a signature generation phase by digesting and processing the
+ * context of the underlying message digest algorithm instance.
+ *
* @return a {@link Object} representing the native output of the signature
- * scheme implementation.
- * @throws IllegalStateException if this instance was not setup for
- * signature generation.
+ * scheme implementation.
+ * @throws IllegalStateException if this instance was not setup for signature
+ * generation.
*/
Object sign() throws IllegalStateException;
/**
- * <p>Terminates a signature verification phase by digesting and processing
- * the context of the underlying message digest algorithm instance.</p>
- *
+ * Terminates a signature verification phase by digesting and processing the
+ * context of the underlying message digest algorithm instance.
+ *
* @param signature a native signature object previously generated by an
- * invocation of the <code>sign()</code> method.
+ * invocation of the <code>sign()</code> method.
* @return <code>true</code> iff the outpout of the verification phase
- * confirms that the designated signature object has been generated using the
- * corresponding public key of the recepient.
- * @throws IllegalStateException if this instance was not setup for
- * signature verification.
+ * confirms that the designated signature object has been generated
+ * using the corresponding public key of the recepient.
+ * @throws IllegalStateException if this instance was not setup for signature
+ * verification.
*/
boolean verify(Object signature) throws IllegalStateException;
/**
- * <p>Returns a clone copy of this instance.</p>
- *
+ * Returns a clone copy of this instance.
+ *
* @return a clone copy of this instance.
*/
Object clone();
diff --git a/libjava/classpath/gnu/java/security/sig/ISignatureCodec.java b/libjava/classpath/gnu/java/security/sig/ISignatureCodec.java
index b6ab0ba9b1e..aaae6ccb034 100644
--- a/libjava/classpath/gnu/java/security/sig/ISignatureCodec.java
+++ b/libjava/classpath/gnu/java/security/sig/ISignatureCodec.java
@@ -41,23 +41,16 @@ package gnu.java.security.sig;
import gnu.java.security.Registry;
/**
- * <p>The visible methods of an object that knows how to encode and decode
+ * The visible methods of an object that knows how to encode and decode
* cryptographic signatures. Codecs are useful for (a) externalising signature
* output data for storage and on-the-wire transmission, as well as (b) re-
- * creating their internal Java representation from external sources.</p>
+ * creating their internal Java representation from external sources.
*/
public interface ISignatureCodec
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/** Constant identifying the <i>Raw</i> encoding format. */
int RAW_FORMAT = Registry.RAW_ENCODING_ID;
- // Method(s)
- // -------------------------------------------------------------------------
-
int getFormatID();
byte[] encodeSignature(Object signature);
diff --git a/libjava/classpath/gnu/java/security/sig/SignatureFactory.java b/libjava/classpath/gnu/java/security/sig/SignatureFactory.java
index d5bd728ad8a..28b68925b21 100644
--- a/libjava/classpath/gnu/java/security/sig/SignatureFactory.java
+++ b/libjava/classpath/gnu/java/security/sig/SignatureFactory.java
@@ -53,38 +53,28 @@ public class SignatureFactory
{
private static Set names;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private SignatureFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* Returns an instance of a signature-with-appendix scheme given its name.
- *
+ *
* @param ssa the case-insensitive signature-with-appendix scheme name.
* @return an instance of the scheme, or <code>null</code> if none found.
*/
public static final ISignature getInstance(String ssa)
{
if (ssa == null)
- {
- return null;
- }
+ return null;
ssa = ssa.trim();
ssa = ssa.toLowerCase();
ISignature result = null;
if (ssa.equalsIgnoreCase(Registry.DSA_SIG) || ssa.equals(Registry.DSS_SIG))
- {
- result = new DSSSignature();
- }
+ result = new DSSSignature();
else if (ssa.startsWith(Registry.RSA_SIG_PREFIX))
result = RSASignatureFactory.getInstance(ssa);
@@ -92,9 +82,9 @@ public class SignatureFactory
}
/**
- * Returns a {@link Set} of signature-with-appendix scheme names supported
- * by this <i>Factory</i>.
- *
+ * Returns a {@link Set} of signature-with-appendix scheme names supported by
+ * this <i>Factory</i>.
+ *
* @return a {@link Set} of signature-with-appendix scheme names (Strings).
*/
public static synchronized final Set getNames()
@@ -104,10 +94,8 @@ public class SignatureFactory
HashSet hs = new HashSet();
hs.add(Registry.DSS_SIG);
hs.addAll(RSASignatureFactory.getNames());
-
names = Collections.unmodifiableSet(hs);
}
-
return names;
}
}
diff --git a/libjava/classpath/gnu/java/security/sig/dss/DSSSignature.java b/libjava/classpath/gnu/java/security/sig/dss/DSSSignature.java
index 370a93854e1..1ef1bea1a7f 100644
--- a/libjava/classpath/gnu/java/security/sig/dss/DSSSignature.java
+++ b/libjava/classpath/gnu/java/security/sig/dss/DSSSignature.java
@@ -55,72 +55,65 @@ import java.util.Map;
import java.util.Random;
/**
- * <p>The DSS (Digital Signature Standard) algorithm makes use of the following
- * parameters:</p>
- *
+ * The DSS (Digital Signature Standard) algorithm makes use of the following
+ * parameters:
* <ol>
- * <li>p: A prime modulus, where <code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup>
- * </code> for <code>512 &lt;= L &lt;= 1024</code> and <code>L</code> a
- * multiple of <code>64</code>.</li>
- * <li>q: A prime divisor of <code>p - 1</code>, where <code>2<sup>159</sup>
+ * <li>p: A prime modulus, where
+ * <code>2<sup>L-1</sup> &lt; p &lt; 2<sup>L</sup> </code> for <code>512 &lt;= L
+ * &lt;= 1024</code> and <code>L</code> a multiple of <code>64</code>.</li>
+ * <li>q: A prime divisor of <code>p - 1</code>, where <code>2<sup>159</sup>
* &lt; q &lt; 2<sup>160</sup></code>.</li>
- * <li>g: Where <code>g = h<sup>(p-1)</sup>/q mod p</code>, where
- * <code>h</code> is any integer with <code>1 &lt; h &lt; p - 1</code> such
- * that <code>h<sup> (p-1)</sup>/q mod p > 1</code> (<code>g</code> has order
- * <code>q mod p</code>).</li>
- * <li>x: A randomly or pseudorandomly generated integer with <code>0 &lt; x
+ * <li>g: Where <code>g = h<sup>(p-1)</sup>/q mod p</code>, where
+ * <code>h</code> is any integer with <code>1 &lt; h &lt; p - 1</code> such
+ * that <code>h<sup> (p-1)</sup>/q mod p > 1</code> (<code>g</code> has order
+ * <code>q mod p</code>).</li>
+ * <li>x: A randomly or pseudorandomly generated integer with <code>0 &lt; x
* &lt; q</code>.</li>
- * <li>y: <code>y = g<sup>x</sup> mod p</code>.</li>
- * <li>k: A randomly or pseudorandomly generated integer with <code>0 &lt; k
+ * <li>y: <code>y = g<sup>x</sup> mod p</code>.</li>
+ * <li>k: A randomly or pseudorandomly generated integer with <code>0 &lt; k
* &lt; q</code>.</li>
* </ol>
- *
- * <p>The integers <code>p</code>, <code>q</code>, and <code>g</code> can be
+ * <p>
+ * The integers <code>p</code>, <code>q</code>, and <code>g</code> can be
* public and can be common to a group of users. A user's private and public
- * keys are <code>x</code> and <code>y</code>, respectively. They are normally
- * fixed for a period of time. Parameters <code>x</code> and <code>k</code> are
- * used for signature generation only, and must be kept secret. Parameter
- * <code>k</code> must be regenerated for each signature.</p>
- *
- * <p>The signature of a message <code>M</code> is the pair of numbers <code>r</code>
- * and <code>s</code> computed according to the equations below:</p>
- *
+ * keys are <code>x</code> and <code>y</code>, respectively. They are
+ * normally fixed for a period of time. Parameters <code>x</code> and
+ * <code>k</code> are used for signature generation only, and must be kept
+ * secret. Parameter <code>k</code> must be regenerated for each signature.
+ * <p>
+ * The signature of a message <code>M</code> is the pair of numbers
+ * <code>r</code> and <code>s</code> computed according to the equations below:
* <ul>
- * <li><code>r = (g<sup>k</sup> mod p) mod q</code> and</li>
- * <li><code>s = (k<sup>-1</sup>(SHA(M) + xr)) mod q</code>.</li>
+ * <li><code>r = (g<sup>k</sup> mod p) mod q</code> and</li>
+ * <li><code>s = (k<sup>-1</sup>(SHA(M) + xr)) mod q</code>.</li>
* </ul>
- *
- * <p>In the above, <code>k<sup>-1</sup></code> is the multiplicative inverse of
- * <code>k</code>, <code>mod q</code>; i.e., <code>(k<sup>-1</sup> k) mod q = 1
- * </code> and <code>0 &lt; k-1 &lt; q</code>. The value of <code>SHA(M)</code>
- * is a 160-bit string output by the Secure Hash Algorithm specified in FIPS 180.
- * For use in computing <code>s</code>, this string must be converted to an
- * integer.</p>
- *
- * <p>As an option, one may wish to check if <code>r == 0</code> or <code>s == 0
- * </code>. If either <code>r == 0</code> or <code>s == 0</code>, a new value
- * of <code>k</code> should be generated and the signature should be
- * recalculated (it is extremely unlikely that <code>r == 0</code> or <code>s ==
- * 0</code> if signatures are generated properly).</p>
- *
- * <p>The signature is transmitted along with the message to the verifier.</p>
- *
- * <p>References:</p>
+ * <p>
+ * In the above, <code>k<sup>-1</sup></code> is the multiplicative inverse of
+ * <code>k</code>, <code>mod q</code>; i.e., <code>(k<sup>-1</sup> k) mod q =
+ * 1</code> and <code>0 &lt; k-1 &lt; q</code>. The value of <code>SHA(M)</code>
+ * is a 160-bit string output by the Secure Hash Algorithm specified in FIPS
+ * 180. For use in computing <code>s</code>, this string must be converted to
+ * an integer.
+ * <p>
+ * As an option, one may wish to check if <code>r == 0</code> or <code>s == 0
+ * </code>.
+ * If either <code>r == 0</code> or <code>s == 0</code>, a new value of
+ * <code>k</code> should be generated and the signature should be recalculated
+ * (it is extremely unlikely that <code>r == 0</code> or <code>s == 0</code> if
+ * signatures are generated properly).
+ * <p>
+ * The signature is transmitted along with the message to the verifier.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital
- * Signature Standard (DSS)</a>, Federal Information Processing Standards
- * Publication 186. National Institute of Standards and Technology.</li>
+ * <li><a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital Signature
+ * Standard (DSS)</a>, Federal Information Processing Standards Publication
+ * 186. National Institute of Standards and Technology.</li>
* </ol>
*/
-public class DSSSignature extends BaseSignature
+public class DSSSignature
+ extends BaseSignature
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public DSSSignature()
{
@@ -137,16 +130,12 @@ public class DSSSignature extends BaseSignature
this.md = (IMessageDigest) that.md.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h)
{
final DSSSignature sig = new DSSSignature();
final Map attributes = new HashMap();
attributes.put(ISignature.SIGNER_KEY, k);
sig.setupSign(attributes);
-
return sig.computeRS(h);
}
@@ -157,11 +146,9 @@ public class DSSSignature extends BaseSignature
final Map attributes = new HashMap();
attributes.put(ISignature.SIGNER_KEY, k);
if (rnd != null)
- {
- attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd);
- }
- sig.setupSign(attributes);
+ attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd);
+ sig.setupSign(attributes);
return sig.computeRS(h);
}
@@ -172,11 +159,9 @@ public class DSSSignature extends BaseSignature
final Map attributes = new HashMap();
attributes.put(ISignature.SIGNER_KEY, k);
if (irnd != null)
- {
- attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd);
- }
- sig.setupSign(attributes);
+ attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd);
+ sig.setupSign(attributes);
return sig.computeRS(h);
}
@@ -187,13 +172,9 @@ public class DSSSignature extends BaseSignature
final Map attributes = new HashMap();
attributes.put(ISignature.VERIFIER_KEY, k);
sig.setupVerify(attributes);
-
return sig.checkRS(rs, h);
}
- // Implementation of abstract methods in superclass
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new DSSSignature(this);
@@ -202,81 +183,37 @@ public class DSSSignature extends BaseSignature
protected void setupForVerification(PublicKey k)
throws IllegalArgumentException
{
- if (!(k instanceof DSAPublicKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof DSAPublicKey))
+ throw new IllegalArgumentException();
+
this.publicKey = k;
}
protected void setupForSigning(PrivateKey k) throws IllegalArgumentException
{
- if (!(k instanceof DSAPrivateKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof DSAPrivateKey))
+ throw new IllegalArgumentException();
+
this.privateKey = k;
}
protected Object generateSignature() throws IllegalStateException
{
- // BigInteger p = ((DSAPrivateKey) privateKey).getParams().getP();
- // BigInteger q = ((DSAPrivateKey) privateKey).getParams().getQ();
- // BigInteger g = ((DSAPrivateKey) privateKey).getParams().getG();
- // BigInteger x = ((DSAPrivateKey) privateKey).getX();
- // BigInteger m = new BigInteger(1, md.digest());
- // BigInteger k, r, s;
- //
- // byte[] kb = new byte[20]; // we'll use 159 bits only
- // while (true) {
- // this.nextRandomBytes(kb);
- // k = new BigInteger(1, kb);
- // k.clearBit(159);
- // r = g.modPow(k, p).mod(q);
- // if (r.equals(BigInteger.ZERO)) {
- // continue;
- // }
- // s = m.add(x.multiply(r)).multiply(k.modInverse(q)).mod(q);
- // if (s.equals(BigInteger.ZERO)) {
- // continue;
- // }
- // break;
- // }
final BigInteger[] rs = computeRS(md.digest());
-
- // return encodeSignature(r, s);
return encodeSignature(rs[0], rs[1]);
}
protected boolean verifySignature(Object sig) throws IllegalStateException
{
final BigInteger[] rs = decodeSignature(sig);
- // BigInteger r = rs[0];
- // BigInteger s = rs[1];
- //
- // BigInteger g = ((DSAPublicKey) publicKey).getParams().getG();
- // BigInteger p = ((DSAPublicKey) publicKey).getParams().getP();
- // BigInteger q = ((DSAPublicKey) publicKey).getParams().getQ();
- // BigInteger y = ((DSAPublicKey) publicKey).getY();
- // BigInteger w = s.modInverse(q);
- //
- // byte bytes[] = md.digest();
- // BigInteger u1 = w.multiply(new BigInteger(1, bytes)).mod(q);
- // BigInteger u2 = r.multiply(w).mod(q);
- //
- // BigInteger v = g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
- // return v.equals(r);
return checkRS(rs, md.digest());
}
- // Other instance methods
- // -------------------------------------------------------------------------
-
/**
- * Returns the output of a signature generation phase.<p>
- *
+ * Returns the output of a signature generation phase.
+ *
* @return an object encapsulating the DSS signature pair <code>r</code> and
- * <code>s</code>.
+ * <code>s</code>.
*/
private Object encodeSignature(BigInteger r, BigInteger s)
{
@@ -284,9 +221,9 @@ public class DSSSignature extends BaseSignature
}
/**
- * Returns the output of a previously generated signature object as a pair
- * of {@link java.math.BigInteger}.<p>
- *
+ * Returns the output of a previously generated signature object as a pair of
+ * {@link java.math.BigInteger}.
+ *
* @return the DSS signature pair <code>r</code> and <code>s</code>.
*/
private BigInteger[] decodeSignature(Object signature)
@@ -302,7 +239,6 @@ public class DSSSignature extends BaseSignature
final BigInteger x = ((DSAPrivateKey) privateKey).getX();
final BigInteger m = new BigInteger(1, digestBytes);
BigInteger k, r, s;
-
final byte[] kb = new byte[20]; // we'll use 159 bits only
while (true)
{
@@ -311,17 +247,14 @@ public class DSSSignature extends BaseSignature
k.clearBit(159);
r = g.modPow(k, p).mod(q);
if (r.equals(BigInteger.ZERO))
- {
- continue;
- }
+ continue;
+
s = m.add(x.multiply(r)).multiply(k.modInverse(q)).mod(q);
if (s.equals(BigInteger.ZERO))
- {
- continue;
- }
+ continue;
+
break;
}
-
return new BigInteger[] { r, s };
}
@@ -329,16 +262,13 @@ public class DSSSignature extends BaseSignature
{
final BigInteger r = rs[0];
final BigInteger s = rs[1];
-
final BigInteger g = ((DSAPublicKey) publicKey).getParams().getG();
final BigInteger p = ((DSAPublicKey) publicKey).getParams().getP();
final BigInteger q = ((DSAPublicKey) publicKey).getParams().getQ();
final BigInteger y = ((DSAPublicKey) publicKey).getY();
final BigInteger w = s.modInverse(q);
-
final BigInteger u1 = w.multiply(new BigInteger(1, digestBytes)).mod(q);
final BigInteger u2 = r.multiply(w).mod(q);
-
final BigInteger v = g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
return v.equals(r);
}
diff --git a/libjava/classpath/gnu/java/security/sig/dss/DSSSignatureRawCodec.java b/libjava/classpath/gnu/java/security/sig/dss/DSSSignatureRawCodec.java
index b0590a573dc..903d7aad6c9 100644
--- a/libjava/classpath/gnu/java/security/sig/dss/DSSSignatureRawCodec.java
+++ b/libjava/classpath/gnu/java/security/sig/dss/DSSSignatureRawCodec.java
@@ -45,61 +45,46 @@ import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
/**
- * <p>An object that implements the {@link ISignatureCodec} operations for the
- * <i>Raw</i> format to use with DSS signatures.</p>
+ * An object that implements the {@link ISignatureCodec} operations for the
+ * <i>Raw</i> format to use with DSS signatures.
*/
-public class DSSSignatureRawCodec implements ISignatureCodec
+public class DSSSignatureRawCodec
+ implements ISignatureCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- // implicit 0-arguments constructor
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.sig.ISignatureCodec interface implementation -----------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated DSS (Digital Signature
- * Standard) signature object according to the <i>Raw</i> format supported by
- * this library.</p>
- *
- * <p>The <i>Raw</i> format for a DSA signature, in this implementation, is a
- * byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated DSS (Digital Signature Standard)
+ * signature object according to the <i>Raw</i> format supported by this
+ * library.
+ * <p>
+ * The <i>Raw</i> format for a DSA signature, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DSS_SIGNATURE},</li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the DSS parameter
- * <code>r</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSS parameter <code>r</code>,</li>
- * <li>4-byte count of following bytes representing the DSS parameter
- * <code>s</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DSS parameter <code>s</code>.</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_DSS_SIGNATURE},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the DSS parameter
+ * <code>r</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSS parameter <code>r</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DSS parameter
+ * <code>s</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DSS parameter <code>s</code>.
+ * </li>
* </ol>
- *
+ *
* @param signature the signature to encode, consisting of the two DSS
- * parameters <code>r</code> and <code>s</code> as a {@link java.math.BigInteger}
- * array.
+ * parameters <code>r</code> and <code>s</code> as a
+ * {@link BigInteger} array.
* @return the <i>Raw</i> format encoding of the designated signature.
* @exception IllegalArgumentException if the designated signature is not a
- * DSS (Digital Signature Standard) one.
+ * DSS (Digital Signature Standard) one.
*/
public byte[] encodeSignature(Object signature)
{
@@ -112,38 +97,32 @@ public class DSSSignatureRawCodec implements ISignatureCodec
}
catch (Exception x)
{
- throw new IllegalArgumentException("key");
+ throw new IllegalArgumentException("signature");
}
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[0]);
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[1]);
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[2]);
baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[3]);
-
// version
baos.write(0x01);
-
// r
byte[] buffer = r.toByteArray();
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
// s
buffer = s.toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -154,36 +133,32 @@ public class DSSSignatureRawCodec implements ISignatureCodec
|| k[1] != Registry.MAGIC_RAW_DSS_SIGNATURE[1]
|| k[2] != Registry.MAGIC_RAW_DSS_SIGNATURE[2]
|| k[3] != Registry.MAGIC_RAW_DSS_SIGNATURE[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
+ throw new IllegalArgumentException("version");
int i = 5;
int l;
byte[] buffer;
-
// r
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger r = new BigInteger(1, buffer);
-
// s
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger s = new BigInteger(1, buffer);
-
return new BigInteger[] { r, s };
}
}
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java b/libjava/classpath/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java
index efe580d5167..39de01f0213 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java
@@ -47,25 +47,21 @@ import java.security.interfaces.RSAKey;
import java.util.Random;
/**
- * <p>An implementation of the EME-PKCS1-V1.5 encoding and decoding methods.</p>
- *
- * <p>EME-PKCS1-V1.5 is parameterised by the entity <code>k</code> which is the
- * byte count of an RSA public shared modulus.</p>
- *
- * <p>References:</p>
+ * An implementation of the EME-PKCS1-V1.5 encoding and decoding methods.
+ * <p>
+ * EME-PKCS1-V1.5 is parameterised by the entity <code>k</code> which is the
+ * byte count of an RSA public shared modulus.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
- * Standards (PKCS) #1:</a><br>
- * RSA Cryptography Specifications Version 2.1.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
+ * Standards (PKCS) #1:</a><br>
+ * RSA Cryptography Specifications Version 2.1.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
public class EME_PKCS1_V1_5
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private int k;
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -73,9 +69,6 @@ public class EME_PKCS1_V1_5
/** Our default source of randomness. */
private PRNG prng = PRNG.getInstance();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
private EME_PKCS1_V1_5(final int k)
{
super();
@@ -83,15 +76,11 @@ public class EME_PKCS1_V1_5
this.k = k;
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final EME_PKCS1_V1_5 getInstance(final int k)
{
if (k < 0)
- {
- throw new IllegalArgumentException("k must be a positive integer");
- }
+ throw new IllegalArgumentException("k must be a positive integer");
+
return new EME_PKCS1_V1_5(k);
}
@@ -102,34 +91,29 @@ public class EME_PKCS1_V1_5
return EME_PKCS1_V1_5.getInstance(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Generates an octet string <code>PS</code> of length <code>k - mLen -
- * 3</code> consisting of pseudo-randomly generated nonzero octets. The
- * length of <code>PS</code> will be at least eight octets.</p>
- *
- * <p>The method then concatenates <code>PS</code>, the message <code>M</code>,
+ * Generates an octet string <code>PS</code> of length <code>k - mLen -
+ * 3</code> consisting of pseudo-randomly generated nonzero octets. The length
+ * of <code>PS</code> will be at least eight octets.
+ * <p>
+ * The method then concatenates <code>PS</code>, the message <code>M</code>,
* and other padding to form an encoded message <code>EM</code> of length
- * <code>k</code> octets as:</p>
- *
+ * <code>k</code> octets as:
* <pre>
- * EM = 0x00 || 0x02 || PS || 0x00 || M.
+ * EM = 0x00 || 0x02 || PS || 0x00 || M.
* </pre>
- *
- * <p>This method uses a default PRNG to obtain the padding bytes.</p>
- *
+ * <p>
+ * This method uses a default PRNG to obtain the padding bytes.
+ *
* @param M the message to encode.
* @return the encoded message <code>EM</code>.
*/
public byte[] encode(final byte[] M)
{
// a. Generate an octet string PS of length k - mLen - 3 consisting
- // of pseudo-randomly generated nonzero octets. The length of PS
- // will be at least eight octets.
+ // of pseudo-randomly generated nonzero octets. The length of PS
+ // will be at least eight octets.
final byte[] PS = new byte[k - M.length - 3];
-
// FIXME. This should be configurable, somehow.
prng.nextBytes(PS);
int i = 0;
@@ -139,17 +123,17 @@ public class EME_PKCS1_V1_5
PS[i] = 1;
}
// b. Concatenate PS, the message M, and other padding to form an
- // encoded message EM of length k octets as
+ // encoded message EM of length k octets as
//
- // EM = 0x00 || 0x02 || PS || 0x00 || M.
+ // EM = 0x00 || 0x02 || PS || 0x00 || M.
return assembleEM(PS, M);
}
/**
- * <p>Similar to {@link #encode(byte[])} method, except that the source of
+ * Similar to {@link #encode(byte[])} method, except that the source of
* randomness to use for obtaining the padding bytes (an instance of
- * {@link IRandom}) is given as a parameter.</p>
- *
+ * {@link IRandom}) is given as a parameter.
+ *
* @param M the message to encode.
* @param irnd the {@link IRandom} instance to use as a source of randomness.
* @return the encoded message <code>EM</code>.
@@ -183,14 +167,13 @@ public class EME_PKCS1_V1_5
{
throw new RuntimeException("encode(): " + String.valueOf(x));
}
-
return assembleEM(PS, M);
}
/**
- * <p>Similar to the {@link #encode(byte[], IRandom)} method, except that
- * the source of randmoness is an instance of {@link Random}.
- *
+ * Similar to the {@link #encode(byte[], IRandom)} method, except that the
+ * source of randmoness is an instance of {@link Random}.
+ *
* @param M the message to encode.
* @param rnd the {@link Random} instance to use as a source of randomness.
* @return the encoded message <code>EM</code>.
@@ -213,33 +196,31 @@ public class EME_PKCS1_V1_5
}
break;
}
-
return assembleEM(PS, M);
}
/**
- * <p>Separate the encoded message <code>EM</code> into an octet string
+ * Separate the encoded message <code>EM</code> into an octet string
* <code>PS</code> consisting of nonzero octets and a message <code>M</code>
- * as:</p>
- *
+ * as:
* <pre>
- * EM = 0x00 || 0x02 || PS || 0x00 || M.
+ * EM = 0x00 || 0x02 || PS || 0x00 || M.
* </pre>
- *
- * <p>If the first octet of <code>EM</code> does not have hexadecimal value
- * <code>0x00</code>, if the second octet of <code>EM</code> does not have
- * hexadecimal value <code>0x02</code>, if there is no octet with hexadecimal
- * value <code>0x00</code> to separate <code>PS</code> from <code>M</code>,
- * or if the length of <code>PS</code> is less than <code>8</code> octets,
- * output "decryption error" and stop.</p>
-
+ * <p>
+ * If the first octet of <code>EM</code> does not have hexadecimal value
+ * <code>0x00</code>, if the second octet of <code>EM</code> does not
+ * have hexadecimal value <code>0x02</code>, if there is no octet with
+ * hexadecimal value <code>0x00</code> to separate <code>PS</code> from
+ * <code>M</code>, or if the length of <code>PS</code> is less than
+ * <code>8</code> octets, output "decryption error" and stop.
+ *
* @param EM the designated encoded message.
* @return the decoded message <code>M</code> framed in the designated
- * <code>EM</code> value.
+ * <code>EM</code> value.
* @throws IllegalArgumentException if the length of the designated entity
- * <code>EM</code> is different than <code>k</code> (the length in bytes of
- * the public shared modulus), or if any of the conditions described above
- * is detected.
+ * <code>EM</code> is different than <code>k</code> (the length
+ * in bytes of the public shared modulus), or if any of the
+ * conditions described above is detected.
*/
public byte[] decode(final byte[] EM)
{
@@ -252,46 +233,34 @@ public class EME_PKCS1_V1_5
// the second octet of EM does not have hexadecimal value 0x02, if
// there is no octet with hexadecimal value 0x00 to separate PS from
// M, or if the length of PS is less than 8 octets, output
- // "decryption error" and stop. (See the note below.)
+ // "decryption error" and stop. (See the note below.)
final int emLen = EM.length;
if (emLen != k)
- {
- throw new IllegalArgumentException("decryption error");
- }
+ throw new IllegalArgumentException("decryption error");
if (EM[0] != 0x00)
- {
- throw new IllegalArgumentException("decryption error");
- }
+ throw new IllegalArgumentException("decryption error");
if (EM[1] != 0x02)
- {
- throw new IllegalArgumentException("decryption error");
- }
+ throw new IllegalArgumentException("decryption error");
int i = 2;
for (; i < emLen; i++)
{
if (EM[i] == 0x00)
- {
- break;
- }
+ break;
}
if (i >= emLen || i < 11)
- {
- throw new IllegalArgumentException("decryption error");
- }
+ throw new IllegalArgumentException("decryption error");
i++;
final byte[] result = new byte[emLen - i];
System.arraycopy(EM, i, result, 0, result.length);
return result;
}
- // helper methods ----------------------------------------------------------
-
private byte[] assembleEM(final byte[] PS, final byte[] M)
{
// b. Concatenate PS, the message M, and other padding to form an
- // encoded message EM of length k octets as
+ // encoded message EM of length k octets as
//
- // EM = 0x00 || 0x02 || PS || 0x00 || M.
+ // EM = 0x00 || 0x02 || PS || 0x00 || M.
baos.reset();
baos.write(0x00);
baos.write(0x02);
@@ -300,7 +269,6 @@ public class EME_PKCS1_V1_5
baos.write(M, 0, M.length);
final byte[] result = baos.toByteArray();
baos.reset();
-
return result;
}
}
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java b/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java
index d155fc88fb4..a0c4de17fab 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java
@@ -45,12 +45,12 @@ import gnu.java.security.hash.IMessageDigest;
import java.io.ByteArrayOutputStream;
/**
- * <p>An implementation of the EMSA-PKCS1-V1.5 encoding scheme.</p>
- *
- * <p>EMSA-PKCS1-V1.5 is parameterised by the choice of hash function Hash and
- * hLen which denotes the length in octets of the hash function output.</p>
- *
- * <p>References:</p>
+ * An implementation of the EMSA-PKCS1-V1.5 encoding scheme.
+ * <p>
+ * EMSA-PKCS1-V1.5 is parameterised by the choice of hash function Hash and
+ * hLen which denotes the length in octets of the hash function output.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
* Standards (PKCS) #1:</a><br>
@@ -58,12 +58,9 @@ import java.io.ByteArrayOutputStream;
* Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class EMSA_PKCS1_V1_5 implements Cloneable
+public class EMSA_PKCS1_V1_5
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/* Notes.
1. For the six hash functions mentioned in Appendix B.1, the DER encoding
T of the DigestInfo value is equal to the following:
@@ -75,67 +72,46 @@ public class EMSA_PKCS1_V1_5 implements Cloneable
SHA-384: (0x)30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30 || H
SHA-512: (0x)30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40 || H
*/
- private static final byte[] MD2_PREFIX = { (byte) 0x30, (byte) 0x20,
- (byte) 0x30, (byte) 0x0c,
- (byte) 0x06, (byte) 0x08,
- (byte) 0x2a, (byte) 0x86,
- (byte) 0x48, (byte) 0x86,
- (byte) 0xf7, (byte) 0x0d,
- (byte) 0x02, (byte) 0x02,
- (byte) 0x05, (byte) 0x00,
- (byte) 0x04, (byte) 0x10 };
-
- private static final byte[] MD5_PREFIX = { (byte) 0x30, (byte) 0x20,
- (byte) 0x30, (byte) 0x0c,
- (byte) 0x06, (byte) 0x08,
- (byte) 0x2a, (byte) 0x86,
- (byte) 0x48, (byte) 0x86,
- (byte) 0xf7, (byte) 0x0d,
- (byte) 0x02, (byte) 0x05,
- (byte) 0x05, (byte) 0x00,
- (byte) 0x04, (byte) 0x10 };
-
- private static final byte[] SHA160_PREFIX = { (byte) 0x30, (byte) 0x21,
- (byte) 0x30, (byte) 0x09,
- (byte) 0x06, (byte) 0x05,
- (byte) 0x2b, (byte) 0x0e,
- (byte) 0x03, (byte) 0x02,
- (byte) 0x1a, (byte) 0x05,
- (byte) 0x00, (byte) 0x04,
- (byte) 0x14 };
-
- private static final byte[] SHA256_PREFIX = { (byte) 0x30, (byte) 0x31,
- (byte) 0x30, (byte) 0x0d,
- (byte) 0x06, (byte) 0x09,
- (byte) 0x60, (byte) 0x86,
- (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03,
- (byte) 0x04, (byte) 0x02,
- (byte) 0x01, (byte) 0x05,
- (byte) 0x00, (byte) 0x04,
- (byte) 0x20 };
-
- private static final byte[] SHA384_PREFIX = { (byte) 0x30, (byte) 0x41,
- (byte) 0x30, (byte) 0x0d,
- (byte) 0x06, (byte) 0x09,
- (byte) 0x60, (byte) 0x86,
- (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03,
- (byte) 0x04, (byte) 0x02,
- (byte) 0x02, (byte) 0x05,
- (byte) 0x00, (byte) 0x04,
- (byte) 0x30 };
-
- private static final byte[] SHA512_PREFIX = { (byte) 0x30, (byte) 0x51,
- (byte) 0x30, (byte) 0x0d,
- (byte) 0x06, (byte) 0x09,
- (byte) 0x60, (byte) 0x86,
- (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03,
- (byte) 0x04, (byte) 0x02,
- (byte) 0x03, (byte) 0x05,
- (byte) 0x00, (byte) 0x04,
- (byte) 0x40 };
+ private static final byte[] MD2_PREFIX = {
+ (byte) 0x30, (byte) 0x20, (byte) 0x30, (byte) 0x0c, (byte) 0x06,
+ (byte) 0x08, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86,
+ (byte) 0xf7, (byte) 0x0d, (byte) 0x02, (byte) 0x02, (byte) 0x05,
+ (byte) 0x00, (byte) 0x04, (byte) 0x10
+ };
+
+ private static final byte[] MD5_PREFIX = {
+ (byte) 0x30, (byte) 0x20, (byte) 0x30, (byte) 0x0c, (byte) 0x06,
+ (byte) 0x08, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86,
+ (byte) 0xf7, (byte) 0x0d, (byte) 0x02, (byte) 0x05, (byte) 0x05,
+ (byte) 0x00, (byte) 0x04, (byte) 0x10
+ };
+
+ private static final byte[] SHA160_PREFIX = {
+ (byte) 0x30, (byte) 0x21, (byte) 0x30, (byte) 0x09, (byte) 0x06,
+ (byte) 0x05, (byte) 0x2b, (byte) 0x0e, (byte) 0x03, (byte) 0x02,
+ (byte) 0x1a, (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x14
+ };
+
+ private static final byte[] SHA256_PREFIX = {
+ (byte) 0x30, (byte) 0x31, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
+ (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
+ (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x01,
+ (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x20
+ };
+
+ private static final byte[] SHA384_PREFIX = {
+ (byte) 0x30, (byte) 0x41, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
+ (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
+ (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x02,
+ (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x30
+ };
+
+ private static final byte[] SHA512_PREFIX = {
+ (byte) 0x30, (byte) 0x51, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
+ (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
+ (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x03,
+ (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x40
+ };
/** The underlying hash function to use with this instance. */
private IMessageDigest hash;
@@ -146,11 +122,8 @@ public class EMSA_PKCS1_V1_5 implements Cloneable
/** The DER part of DigestInfo not containing the hash value itself. */
private byte[] prefix;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial private constructor to enforce use through Factory method.</p>
+ * Trivial private constructor to enforce use through Factory method.
*
* @param hash the message digest instance to use with this scheme instance.
*/
@@ -162,41 +135,24 @@ public class EMSA_PKCS1_V1_5 implements Cloneable
hLen = hash.hashSize();
final String name = hash.name();
if (name.equals(Registry.MD2_HASH))
- {
- prefix = MD2_PREFIX;
- }
+ prefix = MD2_PREFIX;
else if (name.equals(Registry.MD5_HASH))
- {
- prefix = MD5_PREFIX;
- }
+ prefix = MD5_PREFIX;
else if (name.equals(Registry.SHA160_HASH))
- {
- prefix = SHA160_PREFIX;
- }
+ prefix = SHA160_PREFIX;
else if (name.equals(Registry.SHA256_HASH))
- {
- prefix = SHA256_PREFIX;
- }
+ prefix = SHA256_PREFIX;
else if (name.equals(Registry.SHA384_HASH))
- {
- prefix = SHA384_PREFIX;
- }
+ prefix = SHA384_PREFIX;
else if (name.equals(Registry.SHA512_HASH))
- {
- prefix = SHA512_PREFIX;
- }
+ prefix = SHA512_PREFIX;
else
- {
- throw new UnsupportedOperationException(); // should not happen
- }
+ throw new UnsupportedOperationException(); // should not happen
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of this object given a designated name of a hash
- * function.</p>
+ * Returns an instance of this object given a designated name of a hash
+ * function.
*
* @param mdName the canonical name of a hash function.
* @return an instance of this object configured for use with the designated
@@ -208,32 +164,26 @@ public class EMSA_PKCS1_V1_5 implements Cloneable
{
final IMessageDigest hash = HashFactory.getInstance(mdName);
final String name = hash.name();
- if (!(name.equals(Registry.MD2_HASH) || name.equals(Registry.MD5_HASH)
+ if (! (name.equals(Registry.MD2_HASH)
+ || name.equals(Registry.MD5_HASH)
|| name.equals(Registry.SHA160_HASH)
|| name.equals(Registry.SHA256_HASH)
- || name.equals(Registry.SHA384_HASH) || name.equals(Registry.SHA512_HASH)))
- {
- throw new UnsupportedOperationException("hash with no OID: " + name);
- }
+ || name.equals(Registry.SHA384_HASH)
+ || name.equals(Registry.SHA512_HASH)))
+ throw new UnsupportedOperationException("hash with no OID: " + name);
+
return new EMSA_PKCS1_V1_5(hash);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Cloneable interface implementation --------------------------------------
-
public Object clone()
{
return getInstance(hash.name());
}
- // own methods -------------------------------------------------------------
-
/**
- * <p>Frames the hash of a message, along with an ID of the hash function in
+ * Frames the hash of a message, along with an ID of the hash function in
* a DER sequence according to the specifications of EMSA-PKCS1-V1.5 as
- * described in RFC-3447 (see class documentation).</p>
+ * described in RFC-3447 (see class documentation).
*
* @param mHash the byte sequence resulting from applying the message digest
* algorithm Hash to the message <i>M</i>.
@@ -270,17 +220,13 @@ public class EMSA_PKCS1_V1_5 implements Cloneable
// 3. If emLen < tLen + 11, output "intended encoded message length too
// short" and stop.
if (emLen < tLen + 11)
- {
- throw new IllegalArgumentException("emLen too short");
- }
+ throw new IllegalArgumentException("emLen too short");
// 4. Generate an octet string PS consisting of emLen - tLen - 3 octets
// with hexadecimal value 0xff. The length of PS will be at least 8
// octets.
final byte[] PS = new byte[emLen - tLen - 3];
for (int i = 0; i < PS.length; i++)
- {
- PS[i] = (byte) 0xFF;
- }
+ PS[i] = (byte) 0xFF;
// 5. Concatenate PS, the DER encoding T, and other padding to form the
// encoded message EM as: EM = 0x00 || 0x01 || PS || 0x00 || T.
baos.reset();
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java b/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java
index c1c9760ed5c..97b3afcf8c1 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java
@@ -38,57 +38,42 @@ exception statement from your version. */
package gnu.java.security.sig.rsa;
+import gnu.java.security.Configuration;
import gnu.java.security.hash.HashFactory;
import gnu.java.security.hash.IMessageDigest;
import gnu.java.security.util.Util;
-import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.logging.Logger;
/**
- * <p>An implementation of the EMSA-PSS encoding/decoding scheme.</p>
- *
- * <p>EMSA-PSS coincides with EMSA4 in IEEE P1363a D5 except that EMSA-PSS acts
- * on octet strings and not on bit strings. In particular, the bit lengths of
- * the hash and the salt must be multiples of 8 in EMSA-PSS. Moreover, EMSA4
- * outputs an integer of a desired bit length rather than an octet string.</p>
- *
- * <p>EMSA-PSS is parameterized by the choice of hash function Hash and mask
+ * An implementation of the EMSA-PSS encoding/decoding scheme.
+ * <p>
+ * EMSA-PSS coincides with EMSA4 in IEEE P1363a D5 except that EMSA-PSS acts on
+ * octet strings and not on bit strings. In particular, the bit lengths of the
+ * hash and the salt must be multiples of 8 in EMSA-PSS. Moreover, EMSA4 outputs
+ * an integer of a desired bit length rather than an octet string.
+ * <p>
+ * EMSA-PSS is parameterized by the choice of hash function Hash and mask
* generation function MGF. In this submission, MGF is based on a Hash
* definition that coincides with the corresponding definitions in IEEE Std
* 1363-2000, PKCS #1 v2.0, and the draft ANSI X9.44. In PKCS #1 v2.0 and the
* draft ANSI X9.44, the recommended hash function is SHA-1, while IEEE Std
- * 1363-2000 recommends SHA-1 and RIPEMD-160.</p>
- *
- * <p>References:</p>
+ * 1363-2000 recommends SHA-1 and RIPEMD-160.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class EMSA_PSS implements Cloneable
+public class EMSA_PSS
+ implements Cloneable
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "emsa-pss";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 5;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(EMSA_PSS.class.getName());
/** The underlying hash function to use with this instance. */
private IMessageDigest hash;
@@ -96,12 +81,9 @@ public class EMSA_PSS implements Cloneable
/** The output size of the hash function in octets. */
private int hLen;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial private constructor to enforce use through Factory method.</p>
- *
+ * Trivial private constructor to enforce use through Factory method.
+ *
* @param hash the message digest instance to use with this scheme instance.
*/
private EMSA_PSS(IMessageDigest hash)
@@ -112,16 +94,13 @@ public class EMSA_PSS implements Cloneable
hLen = hash.hashSize();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of this object given a designated name of a hash
- * function.</p>
- *
+ * Returns an instance of this object given a designated name of a hash
+ * function.
+ *
* @param mdName the canonical name of a hash function.
* @return an instance of this object configured for use with the designated
- * options.
+ * options.
*/
public static EMSA_PSS getInstance(String mdName)
{
@@ -129,51 +108,38 @@ public class EMSA_PSS implements Cloneable
return new EMSA_PSS(hash);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Cloneable interface implementation --------------------------------------
-
public Object clone()
{
return getInstance(hash.name());
}
- // own methods -------------------------------------------------------------
-
/**
- * <p>The encoding operation EMSA-PSS-Encode computes the hash of a message
+ * The encoding operation EMSA-PSS-Encode computes the hash of a message
* <code>M</code> using a hash function and maps the result to an encoded
* message <code>EM</code> of a specified length using a mask generation
- * function.</p>
- *
+ * function.
+ *
* @param mHash the byte sequence resulting from applying the message digest
- * algorithm Hash to the message <i>M</i>.
+ * algorithm Hash to the message <i>M</i>.
* @param emBits the maximal bit length of the integer OS2IP(EM), at least
- * <code>8.hLen + 8.sLen + 9</code>.
+ * <code>8.hLen + 8.sLen + 9</code>.
* @param salt the salt to use when encoding the output.
* @return the encoded message <code>EM</code>, an octet string of length
- * <code>emLen = CEILING(emBits / 8)</code>.
+ * <code>emLen = CEILING(emBits / 8)</code>.
* @exception IllegalArgumentException if an exception occurs.
- *
*/
public byte[] encode(byte[] mHash, int emBits, byte[] salt)
{
int sLen = salt.length;
-
// 1. If the length of M is greater than the input limitation for the hash
// function (2**61 - 1 octets for SHA-1) then output "message too long"
// and stop.
// 2. Let mHash = Hash(M), an octet string of length hLen.
if (hLen != mHash.length)
- {
- throw new IllegalArgumentException("wrong hash");
- }
+ throw new IllegalArgumentException("wrong hash");
// 3. If emBits < 8.hLen + 8.sLen + 9, output 'encoding error' and stop.
if (emBits < (8 * hLen + 8 * sLen + 9))
- {
- throw new IllegalArgumentException("encoding error");
- }
+ throw new IllegalArgumentException("encoding error");
int emLen = (emBits + 7) / 8;
// 4. Generate a random octet string salt of length sLen; if sLen = 0,
// then salt is the empty string.
@@ -187,9 +153,8 @@ public class EMSA_PSS implements Cloneable
synchronized (hash)
{
for (i = 0; i < 8; i++)
- {
- hash.update((byte) 0x00);
- }
+ hash.update((byte) 0x00);
+
hash.update(mHash, 0, hLen);
hash.update(salt, 0, sLen);
H = hash.digest();
@@ -202,16 +167,14 @@ public class EMSA_PSS implements Cloneable
System.arraycopy(salt, 0, DB, emLen - sLen - hLen - 1, sLen);
// 9. Let dbMask = MGF(H, emLen - hLen - 1).
byte[] dbMask = MGF(H, emLen - hLen - 1);
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- debug("dbMask (encode): " + Util.toString(dbMask));
- debug("DB (encode): " + Util.toString(DB));
+ log.fine("dbMask (encode): " + Util.toString(dbMask));
+ log.fine("DB (encode): " + Util.toString(DB));
}
// 10. Let maskedDB = DB XOR dbMask.
for (i = 0; i < DB.length; i++)
- {
- DB[i] = (byte) (DB[i] ^ dbMask[i]);
- }
+ DB[i] = (byte)(DB[i] ^ dbMask[i]);
// 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in
// maskedDB to zero.
DB[0] &= (0xFF >>> (8 * emLen - emBits));
@@ -226,14 +189,14 @@ public class EMSA_PSS implements Cloneable
}
/**
- * <p>The decoding operation EMSA-PSS-Decode recovers the message hash from
- * an encoded message <code>EM</code> and compares it to the hash of
- * <code>M</code>.</p>
- *
+ * The decoding operation EMSA-PSS-Decode recovers the message hash from an
+ * encoded message <code>EM</code> and compares it to the hash of
+ * <code>M</code>.
+ *
* @param mHash the byte sequence resulting from applying the message digest
- * algorithm Hash to the message <i>M</i>.
+ * algorithm Hash to the message <i>M</i>.
* @param EM the <i>encoded message</i>, an octet string of length
- * <code>emLen = CEILING(emBits/8).
+ * <code>emLen = CEILING(emBits/8).
* @param emBits the maximal bit length of the integer OS2IP(EM), at least
* <code>8.hLen + 8.sLen + 9</code>.
* @param sLen the length, in octets, of the expected salt.
@@ -244,60 +207,50 @@ public class EMSA_PSS implements Cloneable
*/
public boolean decode(byte[] mHash, byte[] EM, int emBits, int sLen)
{
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- debug("mHash: " + Util.toString(mHash));
- debug("EM: " + Util.toString(EM));
- debug("emBits: " + String.valueOf(emBits));
- debug("sLen: " + String.valueOf(sLen));
+ log.fine("mHash: " + Util.toString(mHash));
+ log.fine("EM: " + Util.toString(EM));
+ log.fine("emBits: " + String.valueOf(emBits));
+ log.fine("sLen: " + String.valueOf(sLen));
}
if (sLen < 0)
- {
- throw new IllegalArgumentException("sLen");
- }
-
+ throw new IllegalArgumentException("sLen");
// 1. If the length of M is greater than the input limitation for the hash
- // function (2**61 ? 1 octets for SHA-1) then output 'inconsistent' and
- // stop.
+ // function (2**61 ? 1 octets for SHA-1) then output 'inconsistent' and
+ // stop.
// 2. Let mHash = Hash(M), an octet string of length hLen.
if (hLen != mHash.length)
{
- if (DEBUG && debuglevel > 8)
- {
- debug("hLen != mHash.length; hLen: " + String.valueOf(hLen));
- }
+ if (Configuration.DEBUG)
+ log.fine("hLen != mHash.length; hLen: " + String.valueOf(hLen));
throw new IllegalArgumentException("wrong hash");
}
// 3. If emBits < 8.hLen + 8.sLen + 9, output 'decoding error' and stop.
if (emBits < (8 * hLen + 8 * sLen + 9))
{
- if (DEBUG && debuglevel > 8)
- {
- debug("emBits < (8hLen + 8sLen + 9); sLen: " + String.valueOf(sLen));
- }
+ if (Configuration.DEBUG)
+ log.fine("emBits < (8hLen + 8sLen + 9); sLen: "
+ + String.valueOf(sLen));
throw new IllegalArgumentException("decoding error");
}
int emLen = (emBits + 7) / 8;
// 4. If the rightmost octet of EM does not have hexadecimal value bc,
- // output 'inconsistent' and stop.
+ // output 'inconsistent' and stop.
if ((EM[EM.length - 1] & 0xFF) != 0xBC)
{
- if (DEBUG && debuglevel > 8)
- {
- debug("EM does not end with 0xBC");
- }
+ if (Configuration.DEBUG)
+ log.fine("EM does not end with 0xBC");
return false;
}
// 5. Let maskedDB be the leftmost emLen ? hLen ? 1 octets of EM, and let
- // H be the next hLen octets.
+ // H be the next hLen octets.
// 6. If the leftmost 8.emLen ? emBits bits of the leftmost octet in
- // maskedDB are not all equal to zero, output 'inconsistent' and stop.
+ // maskedDB are not all equal to zero, output 'inconsistent' and stop.
if ((EM[0] & (0xFF << (8 - (8 * emLen - emBits)))) != 0)
{
- if (DEBUG && debuglevel > 8)
- {
- debug("Leftmost 8emLen - emBits bits of EM are not 0s");
- }
+ if (Configuration.DEBUG)
+ log.fine("Leftmost 8emLen - emBits bits of EM are not 0s");
return false;
}
byte[] DB = new byte[emLen - hLen - 1];
@@ -309,56 +262,48 @@ public class EMSA_PSS implements Cloneable
// 8. Let DB = maskedDB XOR dbMask.
int i;
for (i = 0; i < DB.length; i++)
- {
- DB[i] = (byte) (DB[i] ^ dbMask[i]);
- }
+ DB[i] = (byte)(DB[i] ^ dbMask[i]);
// 9. Set the leftmost 8.emLen ? emBits bits of DB to zero.
DB[0] &= (0xFF >>> (8 * emLen - emBits));
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- debug("dbMask (decode): " + Util.toString(dbMask));
- debug("DB (decode): " + Util.toString(DB));
+ log.fine("dbMask (decode): " + Util.toString(dbMask));
+ log.fine("DB (decode): " + Util.toString(DB));
}
// 10. If the emLen -hLen -sLen -2 leftmost octets of DB are not zero or
- // if the octet at position emLen -hLen -sLen -1 is not equal to 0x01,
- // output 'inconsistent' and stop.
+ // if the octet at position emLen -hLen -sLen -1 is not equal to 0x01,
+ // output 'inconsistent' and stop.
// IMPORTANT (rsn): this is an error in the specs, the index of the 0x01
- // byte should be emLen -hLen -sLen -2 and not -1! authors have been
- // advised
+ // byte should be emLen -hLen -sLen -2 and not -1! authors have been advised
for (i = 0; i < (emLen - hLen - sLen - 2); i++)
{
if (DB[i] != 0)
{
- if (DEBUG && debuglevel > 8)
- {
- debug("DB[" + String.valueOf(i) + "] != 0x00");
- }
+ if (Configuration.DEBUG)
+ log.fine("DB[" + String.valueOf(i) + "] != 0x00");
return false;
}
}
if (DB[i] != 0x01)
{ // i == emLen -hLen -sLen -2
- if (DEBUG && debuglevel > 8)
- {
- debug("DB's byte at position (emLen -hLen -sLen -2); i.e. "
- + String.valueOf(i) + " is not 0x01");
- }
+ if (Configuration.DEBUG)
+ log.fine("DB's byte at position (emLen -hLen -sLen -2); i.e. "
+ + String.valueOf(i) + " is not 0x01");
return false;
}
// 11. Let salt be the last sLen octets of DB.
byte[] salt = new byte[sLen];
System.arraycopy(DB, DB.length - sLen, salt, 0, sLen);
// 12. Let M0 = 00 00 00 00 00 00 00 00 || mHash || salt;
- // M0 is an octet string of length 8 + hLen + sLen with eight initial
- // zero octets.
+ // M0 is an octet string of length 8 + hLen + sLen with eight initial
+ // zero octets.
// 13. Let H0 = Hash(M0), an octet string of length hLen.
byte[] H0;
synchronized (hash)
{
for (i = 0; i < 8; i++)
- {
- hash.update((byte) 0x00);
- }
+ hash.update((byte) 0x00);
+
hash.update(mHash, 0, hLen);
hash.update(salt, 0, sLen);
H0 = hash.digest();
@@ -367,34 +312,30 @@ public class EMSA_PSS implements Cloneable
return Arrays.equals(H, H0);
}
- // helper methods ----------------------------------------------------------
-
/**
- * <p>A mask generation function takes an octet string of variable length
- * and a desired output length as input, and outputs an octet string of the
- * desired length. There may be restrictions on the length of the input and
- * output octet strings, but such bounds are generally very large. Mask
- * generation functions are deterministic; the octet string output is
- * completely determined by the input octet string. The output of a mask
- * generation function should be pseudorandom, that is, it should be
- * infeasible to predict, given one part of the output but not the input,
- * another part of the output. The provable security of RSA-PSS relies on
- * the random nature of the output of the mask generation function, which in
- * turn relies on the random nature of the underlying hash function.</p>
- *
+ * A mask generation function takes an octet string of variable length and a
+ * desired output length as input, and outputs an octet string of the desired
+ * length. There may be restrictions on the length of the input and output
+ * octet strings, but such bounds are generally very large. Mask generation
+ * functions are deterministic; the octet string output is completely
+ * determined by the input octet string. The output of a mask generation
+ * function should be pseudorandom, that is, it should be infeasible to
+ * predict, given one part of the output but not the input, another part of
+ * the output. The provable security of RSA-PSS relies on the random nature of
+ * the output of the mask generation function, which in turn relies on the
+ * random nature of the underlying hash function.
+ *
* @param Z a seed.
* @param l the desired output length in octets.
* @return the mask.
* @exception IllegalArgumentException if the desired output length is too
- * long.
+ * long.
*/
private byte[] MGF(byte[] Z, int l)
{
// 1. If l > (2**32).hLen, output 'mask too long' and stop.
if (l < 1 || (l & 0xFFFFFFFFL) > ((hLen & 0xFFFFFFFFL) << 32L))
- {
- throw new IllegalArgumentException("mask too long");
- }
+ throw new IllegalArgumentException("mask too long");
// 2. Let T be the empty octet string.
byte[] result = new byte[l];
// 3. For i = 0 to CEILING(l/hLen) ? 1, do
@@ -409,14 +350,14 @@ public class EMSA_PSS implements Cloneable
int length;
for (int i = 0; i < limit; i++)
{
- // 3.1 Convert i to an octet string C of length 4 with the primitive
- // I2OSP: C = I2OSP(i, 4).
- // 3.2 Concatenate the hash of the seed Z and C to the octet string T:
- // T = T || Hash(Z || C)
+ // 3.1 Convert i to an octet string C of length 4 with the primitive
+ // I2OSP: C = I2OSP(i, 4).
+ // 3.2 Concatenate the hash of the seed Z and C to the octet string T:
+ // T = T || Hash(Z || C)
hashZC = (IMessageDigest) hashZ.clone();
- hashZC.update((byte) (i >>> 24));
- hashZC.update((byte) (i >>> 16));
- hashZC.update((byte) (i >>> 8));
+ hashZC.update((byte)(i >>> 24));
+ hashZC.update((byte)(i >>> 16));
+ hashZC.update((byte)(i >>> 8));
hashZC.update((byte) i);
t = hashZC.digest();
length = l - sofar;
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/RSA.java b/libjava/classpath/gnu/java/security/sig/rsa/RSA.java
index 7d1707e195d..cdd9eaa5b8a 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/RSA.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/RSA.java
@@ -49,31 +49,26 @@ import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
/**
- * <p>Utility methods related to the RSA algorithm.</p>
- *
- * <p>References:</p>
+ * Utility methods related to the RSA algorithm.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
- *
- * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
- * Standards (PKCS) #1:</a><br>
- * RSA Cryptography Specifications Version 2.1.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
- *
- * <li><a href="http://crypto.stanford.edu/~dabo/abstracts/ssl-timing.html">
- * Remote timing attacks are practical</a><br>
- * D. Boneh and D. Brumley.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
+ * Standards (PKCS) #1:</a><br>
+ * RSA Cryptography Specifications Version 2.1.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a href="http://crypto.stanford.edu/~dabo/abstracts/ssl-timing.html">
+ * Remote timing attacks are practical</a><br>
+ * D. Boneh and D. Brumley.</li>
* </ol>
*/
public class RSA
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final BigInteger ZERO = BigInteger.ZERO;
private static final BigInteger ONE = BigInteger.ONE;
@@ -81,37 +76,28 @@ public class RSA
/** Our default source of randomness. */
private static final PRNG prng = PRNG.getInstance();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial private constructor to enforce Singleton pattern. */
private RSA()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Signature and verification methods --------------------------------------
-
/**
- * <p>An implementation of the <b>RSASP</b> method: Assuming that the
- * designated RSA private key is a valid one, this method computes a
- * <i>signature representative</i> for a designated <i>message
- * representative</i> signed by the holder of the designated RSA private
- * key.<p>
- *
+ * An implementation of the <b>RSASP</b> method: Assuming that the designated
+ * RSA private key is a valid one, this method computes a <i>signature
+ * representative</i> for a designated <i>message representative</i> signed
+ * by the holder of the designated RSA private key.
+ *
* @param K the RSA private key.
* @param m the <i>message representative</i>: an integer between
- * <code>0</code> and <code>n - 1</code>, where <code>n</code> is the RSA
- * <i>modulus</i>.
+ * <code>0</code> and <code>n - 1</code>, where <code>n</code>
+ * is the RSA <i>modulus</i>.
* @return the <i>signature representative</i>, an integer between
- * <code>0</code> and <code>n - 1</code>, where <code>n</code> is the RSA
- * <i>modulus</i>.
+ * <code>0</code> and <code>n - 1</code>, where <code>n</code>
+ * is the RSA <i>modulus</i>.
* @throws ClassCastException if <code>K</code> is not an RSA one.
* @throws IllegalArgumentException if <code>m</code> (the <i>message
- * representative</i>) is out of range.
+ * representative</i>) is out of range.
*/
public static final BigInteger sign(final PrivateKey K, final BigInteger m)
{
@@ -121,27 +107,27 @@ public class RSA
}
catch (IllegalArgumentException x)
{
- throw new IllegalArgumentException(
- "message representative out of range");
+ throw new IllegalArgumentException("message representative out of range");
}
}
/**
- * <p>An implementation of the <b>RSAVP</b> method: Assuming that the
- * designated RSA public key is a valid one, this method computes a
- * <i>message representative</i> for the designated <i>signature
- * representative</i> generated by an RSA private key, for a message
- * intended for the holder of the designated RSA public key.</p>
- *
+ * An implementation of the <b>RSAVP</b> method: Assuming that the designated
+ * RSA public key is a valid one, this method computes a <i>message
+ * representative</i> for the designated <i>signature representative</i>
+ * generated by an RSA private key, for a message intended for the holder of
+ * the designated RSA public key.
+ *
* @param K the RSA public key.
* @param s the <i>signature representative</i>, an integer between
- * <code>0</code> and <code>n - 1</code>, where <code>n</code> is the RSA
- * <i>modulus</i>.
+ * <code>0</code> and <code>n - 1</code>, where <code>n</code>
+ * is the RSA <i>modulus</i>.
* @return a <i>message representative</i>: an integer between <code>0</code>
- * and <code>n - 1</code>, where <code>n</code> is the RSA <i>modulus</i>.
+ * and <code>n - 1</code>, where <code>n</code> is the RSA
+ * <i>modulus</i>.
* @throws ClassCastException if <code>K</code> is not an RSA one.
* @throws IllegalArgumentException if <code>s</code> (the <i>signature
- * representative</i>) is out of range.
+ * representative</i>) is out of range.
*/
public static final BigInteger verify(final PublicKey K, final BigInteger s)
{
@@ -151,25 +137,24 @@ public class RSA
}
catch (IllegalArgumentException x)
{
- throw new IllegalArgumentException(
- "signature representative out of range");
+ throw new IllegalArgumentException("signature representative out of range");
}
}
- // Encryption and decryption methods ---------------------------------------
-
/**
- * <p>An implementation of the <code>RSAEP</code> algorithm.</p>
- *
+ * An implementation of the <code>RSAEP</code> algorithm.
+ *
* @param K the recipient's RSA public key.
* @param m the message representative as an MPI.
* @return the resulting MPI --an MPI between <code>0</code> and
- * <code>n - 1</code> (<code>n</code> being the public shared modulus)-- that
- * will eventually be padded with an appropriate framing/padding scheme.
+ * <code>n - 1</code> (<code>n</code> being the public shared
+ * modulus)-- that will eventually be padded with an appropriate
+ * framing/padding scheme.
* @throws ClassCastException if <code>K</code> is not an RSA one.
* @throws IllegalArgumentException if <code>m</code>, the message
- * representative is not between <code>0</code> and <code>n - 1</code>
- * (<code>n</code> being the public shared modulus).
+ * representative is not between <code>0</code> and
+ * <code>n - 1</code> (<code>n</code> being the public shared
+ * modulus).
*/
public static final BigInteger encrypt(final PublicKey K, final BigInteger m)
{
@@ -179,22 +164,23 @@ public class RSA
}
catch (IllegalArgumentException x)
{
- throw new IllegalArgumentException(
- "message representative out of range");
+ throw new IllegalArgumentException("message representative out of range");
}
}
/**
- * <p>An implementation of the <code>RSADP</code> algorithm.</p>
- *
+ * An implementation of the <code>RSADP</code> algorithm.
+ *
* @param K the recipient's RSA private key.
* @param c the ciphertext representative as an MPI.
* @return the message representative, an MPI between <code>0</code> and
- * <code>n - 1</code> (<code>n</code> being the shared public modulus).
+ * <code>n - 1</code> (<code>n</code> being the shared public
+ * modulus).
* @throws ClassCastException if <code>K</code> is not an RSA one.
* @throws IllegalArgumentException if <code>c</code>, the ciphertext
- * representative is not between <code>0</code> and <code>n - 1</code>
- * (<code>n</code> being the shared public modulus).
+ * representative is not between <code>0</code> and
+ * <code>n - 1</code> (<code>n</code> being the shared public
+ * modulus).
*/
public static final BigInteger decrypt(final PrivateKey K, final BigInteger c)
{
@@ -204,22 +190,19 @@ public class RSA
}
catch (IllegalArgumentException x)
{
- throw new IllegalArgumentException(
- "ciphertext representative out of range");
+ throw new IllegalArgumentException("ciphertext representative out of range");
}
}
- // Conversion methods ------------------------------------------------------
-
/**
- * <p>Converts a <i>multi-precision integer</i> (MPI) <code>s</code> into an
- * octet sequence of length <code>k</code>.</p>
- *
+ * Converts a <i>multi-precision integer</i> (MPI) <code>s</code> into an
+ * octet sequence of length <code>k</code>.
+ *
* @param s the multi-precision integer to convert.
* @param k the length of the output.
* @return the result of the transform.
* @exception IllegalArgumentException if the length in octets of meaningful
- * bytes of <code>s</code> is greater than <code>k</code>.
+ * bytes of <code>s</code> is greater than <code>k</code>.
*/
public static final byte[] I2OSP(final BigInteger s, final int k)
{
@@ -236,9 +219,7 @@ public class RSA
for (int i = 0; i < limit; i++)
{
if (result[i] != 0x00)
- {
- throw new IllegalArgumentException("integer too large");
- }
+ throw new IllegalArgumentException("integer too large");
}
final byte[] newResult = new byte[k];
System.arraycopy(result, limit, newResult, 0, k);
@@ -247,17 +228,13 @@ public class RSA
return result;
}
- // helper methods ----------------------------------------------------------
-
private static final BigInteger RSAEP(final RSAPublicKey K, final BigInteger m)
{
// 1. If the representative m is not between 0 and n - 1, output
- // "representative out of range" and stop.
+ // "representative out of range" and stop.
final BigInteger n = K.getModulus();
if (m.compareTo(ZERO) < 0 || m.compareTo(n.subtract(ONE)) > 0)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
// 2. Let c = m^e mod n.
final BigInteger e = K.getPublicExponent();
final BigInteger result = m.modPow(e, n);
@@ -268,16 +245,13 @@ public class RSA
private static final BigInteger RSADP(final RSAPrivateKey K, BigInteger c)
{
// 1. If the representative c is not between 0 and n - 1, output
- // "representative out of range" and stop.
+ // "representative out of range" and stop.
final BigInteger n = K.getModulus();
if (c.compareTo(ZERO) < 0 || c.compareTo(n.subtract(ONE)) > 0)
- {
- throw new IllegalArgumentException();
- }
-
+ throw new IllegalArgumentException();
// 2. The representative m is computed as follows.
BigInteger result;
- if (!(K instanceof RSAPrivateCrtKey))
+ if (! (K instanceof RSAPrivateCrtKey))
{
// a. If the first form (n, d) of K is used, let m = c^d mod n.
final BigInteger d = K.getPrivateExponent();
@@ -303,38 +277,32 @@ public class RSA
final BigInteger x = r.modPow(e, n).multiply(c).mod(n);
c = x;
}
-
// b. If the second form (p, q, dP, dQ, qInv) and (r_i, d_i, t_i)
- // of K is used, proceed as follows:
+ // of K is used, proceed as follows:
final BigInteger p = ((RSAPrivateCrtKey) K).getPrimeP();
final BigInteger q = ((RSAPrivateCrtKey) K).getPrimeQ();
final BigInteger dP = ((RSAPrivateCrtKey) K).getPrimeExponentP();
final BigInteger dQ = ((RSAPrivateCrtKey) K).getPrimeExponentQ();
final BigInteger qInv = ((RSAPrivateCrtKey) K).getCrtCoefficient();
-
- // i. Let m_1 = c^dP mod p and m_2 = c^dQ mod q.
+ // i. Let m_1 = c^dP mod p and m_2 = c^dQ mod q.
final BigInteger m_1 = c.modPow(dP, p);
final BigInteger m_2 = c.modPow(dQ, q);
- // ii. If u > 2, let m_i = c^(d_i) mod r_i, i = 3, ..., u.
- // iii. Let h = (m_1 - m_2) * qInv mod p.
+ // ii. If u > 2, let m_i = c^(d_i) mod r_i, i = 3, ..., u.
+ // iii. Let h = (m_1 - m_2) * qInv mod p.
final BigInteger h = m_1.subtract(m_2).multiply(qInv).mod(p);
- // iv. Let m = m_2 + q * h.
+ // iv. Let m = m_2 + q * h.
result = m_2.add(q.multiply(h));
-
- if (rsaBlinding)
- { // post-decryption
- result = result.multiply(r.modInverse(n)).mod(n);
- }
+ if (rsaBlinding) // post-decryption
+ result = result.multiply(r.modInverse(n)).mod(n);
}
-
// 3. Output m
return result;
}
/**
- * <p>Returns a random MPI with a random bit-length of the form <code>8b</code>,
- * where <code>b</code> is in the range <code>[32..64]</code>.</p>
- *
+ * Returns a random MPI with a random bit-length of the form <code>8b</code>,
+ * where <code>b</code> is in the range <code>[32..64]</code>.
+ *
* @return a random MPI whose length in bytes is between 32 and 64 inclusive.
*/
private static final BigInteger newR(final BigInteger N)
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java b/libjava/classpath/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java
index e64d30b6937..76460c0cafa 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java
@@ -51,35 +51,29 @@ import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
/**
- * <p>The RSA-PKCS1-V1.5 signature scheme is a digital signature scheme with
+ * The RSA-PKCS1-V1.5 signature scheme is a digital signature scheme with
* appendix (SSA) combining the RSA algorithm with the EMSA-PKCS1-v1_5 encoding
- * method.</p>
- *
- * <p>References:</p>
+ * method.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
- *
- * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
- * Standards (PKCS) #1:</a><br>
- * RSA Cryptography Specifications Version 2.1.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
+ * Standards (PKCS) #1:</a><br>
+ * RSA Cryptography Specifications Version 2.1.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class RSAPKCS1V1_5Signature extends BaseSignature
+public class RSAPKCS1V1_5Signature
+ extends BaseSignature
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The underlying EMSA-PKCS1-v1.5 instance for this object. */
private EMSA_PKCS1_V1_5 pkcs1;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Default 0-arguments constructor. Uses SHA-1 as the default hash.
*/
@@ -89,9 +83,9 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
}
/**
- * <p>Constructs an instance of this object using the designated message
- * digest algorithm as its underlying hash function.</p>
- *
+ * Constructs an instance of this object using the designated message digest
+ * algorithm as its underlying hash function.
+ *
* @param mdName the canonical name of the underlying hash function.
*/
public RSAPKCS1V1_5Signature(final String mdName)
@@ -117,14 +111,6 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
this.pkcs1 = (EMSA_PKCS1_V1_5) that.pkcs1.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in superclass ------------------------
-
public Object clone()
{
return new RSAPKCS1V1_5Signature(this);
@@ -133,49 +119,46 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
protected void setupForVerification(final PublicKey k)
throws IllegalArgumentException
{
- if (!(k instanceof RSAPublicKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof RSAPublicKey))
+ throw new IllegalArgumentException();
+
publicKey = k;
}
protected void setupForSigning(final PrivateKey k)
throws IllegalArgumentException
{
- if (!(k instanceof RSAPrivateKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof RSAPrivateKey))
+ throw new IllegalArgumentException();
+
privateKey = k;
}
protected Object generateSignature() throws IllegalStateException
{
// 1. EMSA-PKCS1-v1_5 encoding: Apply the EMSA-PKCS1-v1_5 encoding
- // operation (Section 9.2) to the message M to produce an encoded
- // message EM of length k octets:
+ // operation (Section 9.2) to the message M to produce an encoded
+ // message EM of length k octets:
//
- // EM = EMSA-PKCS1-V1_5-ENCODE (M, k).
+ // EM = EMSA-PKCS1-V1_5-ENCODE (M, k).
//
- // If the encoding operation outputs "message too long," output
- // "message too long" and stop. If the encoding operation outputs
- // "intended encoded message length too short," output "RSA modulus
- // too short" and stop.
+ // If the encoding operation outputs "message too long," output
+ // "message too long" and stop. If the encoding operation outputs
+ // "intended encoded message length too short," output "RSA modulus
+ // too short" and stop.
final int modBits = ((RSAPrivateKey) privateKey).getModulus().bitLength();
final int k = (modBits + 7) / 8;
final byte[] EM = pkcs1.encode(md.digest(), k);
-
// 2. RSA signature:
- // a. Convert the encoded message EM to an integer message epresentative
- // m (see Section 4.2): m = OS2IP (EM).
+ // a. Convert the encoded message EM to an integer message epresentative
+ // m (see Section 4.2): m = OS2IP (EM).
final BigInteger m = new BigInteger(1, EM);
- // b. Apply the RSASP1 signature primitive (Section 5.2.1) to the RSA
- // private key K and the message representative m to produce an
- // integer signature representative s: s = RSASP1 (K, m).
+ // b. Apply the RSASP1 signature primitive (Section 5.2.1) to the RSA
+ // private key K and the message representative m to produce an
+ // integer signature representative s: s = RSASP1 (K, m).
final BigInteger s = RSA.sign(privateKey, m);
- // c. Convert the signature representative s to a signature S of length
- // k octets (see Section 4.1): S = I2OSP (s, k).
+ // c. Convert the signature representative s to a signature S of length
+ // k octets (see Section 4.1): S = I2OSP (s, k).
// 3. Output the signature S.
return RSA.I2OSP(s, k);
}
@@ -184,28 +167,24 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
throws IllegalStateException
{
if (publicKey == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
final byte[] S = (byte[]) sig;
// 1. Length checking: If the length of the signature S is not k octets,
- // output "invalid signature" and stop.
+ // output "invalid signature" and stop.
final int modBits = ((RSAPublicKey) publicKey).getModulus().bitLength();
final int k = (modBits + 7) / 8;
if (S.length != k)
- {
- return false;
- }
+ return false;
// 2. RSA verification:
- // a. Convert the signature S to an integer signature representative
- // s (see Section 4.2): s = OS2IP (S).
+ // a. Convert the signature S to an integer signature representative
+ // s (see Section 4.2): s = OS2IP (S).
final BigInteger s = new BigInteger(1, S);
- // b. Apply the RSAVP1 verification primitive (Section 5.2.2) to the
- // RSA public key (n, e) and the signature representative s to
- // produce an integer message representative m:
- // m = RSAVP1 ((n, e), s).
- // If RSAVP1 outputs "signature representative out of range,"
- // output "invalid signature" and stop.
+ // b. Apply the RSAVP1 verification primitive (Section 5.2.2) to the
+ // RSA public key (n, e) and the signature representative s to
+ // produce an integer message representative m:
+ // m = RSAVP1 ((n, e), s).
+ // If RSAVP1 outputs "signature representative out of range,"
+ // output "invalid signature" and stop.
final BigInteger m;
try
{
@@ -215,10 +194,10 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
{
return false;
}
- // c. Convert the message representative m to an encoded message EM
- // of length k octets (see Section 4.1): EM = I2OSP (m, k).
- // If I2OSP outputs "integer too large," output "invalid signature"
- // and stop.
+ // c. Convert the message representative m to an encoded message EM
+ // of length k octets (see Section 4.1): EM = I2OSP (m, k).
+ // If I2OSP outputs "integer too large," output "invalid signature"
+ // and stop.
final byte[] EM;
try
{
@@ -229,17 +208,17 @@ public class RSAPKCS1V1_5Signature extends BaseSignature
return false;
}
// 3. EMSA-PKCS1-v1_5 encoding: Apply the EMSA-PKCS1-v1_5 encoding
- // operation (Section 9.2) to the message M to produce a second
- // encoded message EM' of length k octets:
- // EM' = EMSA-PKCS1-V1_5-ENCODE (M, k).
- // If the encoding operation outputs "message too long," output
- // "message too long" and stop. If the encoding operation outputs
- // "intended encoded message length too short," output "RSA modulus
- // too short" and stop.
+ // operation (Section 9.2) to the message M to produce a second
+ // encoded message EM' of length k octets:
+ // EM' = EMSA-PKCS1-V1_5-ENCODE (M, k).
+ // If the encoding operation outputs "message too long," output
+ // "message too long" and stop. If the encoding operation outputs
+ // "intended encoded message length too short," output "RSA modulus
+ // too short" and stop.
final byte[] EMp = pkcs1.encode(md.digest(), k);
// 4. Compare the encoded message EM and the second encoded message EM'.
- // If they are the same, output "valid signature"; otherwise, output
- // "invalid signature."
+ // If they are the same, output "valid signature"; otherwise, output
+ // "invalid signature."
return Arrays.equals(EM, EMp);
}
}
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java b/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java
index 7ec62568a98..27c7fe620fd 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java
@@ -38,60 +38,44 @@ exception statement from your version. */
package gnu.java.security.sig.rsa;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.hash.HashFactory;
import gnu.java.security.hash.IMessageDigest;
import gnu.java.security.sig.BaseSignature;
import gnu.java.security.util.Util;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
+import java.util.logging.Logger;
/**
- * <p>The RSA-PSS signature scheme is a public-key encryption scheme combining
- * the RSA algorithm with the Probabilistic Signature Scheme (PSS) encoding
- * method.</p>
- *
- * <p>The inventors of RSA are Ronald L. Rivest, Adi Shamir, and Leonard Adleman,
+ * The RSA-PSS signature scheme is a public-key encryption scheme combining the
+ * RSA algorithm with the Probabilistic Signature Scheme (PSS) encoding method.
+ * <p>
+ * The inventors of RSA are Ronald L. Rivest, Adi Shamir, and Leonard Adleman,
* while the inventors of the PSS encoding method are Mihir Bellare and Phillip
* Rogaway. During efforts to adopt RSA-PSS into the P1363a standards effort,
* certain adaptations to the original version of RSA-PSS were made by Mihir
* Bellare and Phillip Rogaway and also by Burt Kaliski (the editor of IEEE
- * P1363a) to facilitate implementation and integration into existing protocols.</p>
- *
- * <p>References:</pr>
+ * P1363a) to facilitate implementation and integration into existing protocols.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
- * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
- * Primitive specification and supporting documentation.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a
+ * href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
+ * RSA-PSS Signature Scheme with Appendix, part B.</a><br>
+ * Primitive specification and supporting documentation.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*/
-public class RSAPSSSignature extends BaseSignature
+public class RSAPSSSignature
+ extends BaseSignature
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "rsa-pss";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 1;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(RSAPSSSignature.class.getName());
/** The underlying EMSA-PSS instance for this object. */
private EMSA_PSS pss;
@@ -99,9 +83,6 @@ public class RSAPSSSignature extends BaseSignature
/** The desired length in octets of the EMSA-PSS salt. */
private int sLen;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Default 0-arguments constructor. Uses SHA-1 as the default hash and a
* 0-octet <i>salt</i>.
@@ -112,10 +93,9 @@ public class RSAPSSSignature extends BaseSignature
}
/**
- * <p>Constructs an instance of this object using the designated message
- * digest algorithm as its underlying hash function, and having 0-octet
- * <i>salt</i>.</p>
- *
+ * Constructs an instance of this object using the designated message digest
+ * algorithm as its underlying hash function, and having 0-octet <i>salt</i>.
+ *
* @param mdName the canonical name of the underlying hash function.
*/
public RSAPSSSignature(String mdName)
@@ -124,12 +104,12 @@ public class RSAPSSSignature extends BaseSignature
}
/**
- * <p>Constructs an instance of this object using the designated message
- * digest algorithm as its underlying hash function.</p>
- *
+ * Constructs an instance of this object using the designated message digest
+ * algorithm as its underlying hash function.
+ *
* @param mdName the canonical name of the underlying hash function.
* @param sLen the desired length in octets of the salt to use for encoding /
- * decoding signatures.
+ * decoding signatures.
*/
public RSAPSSSignature(String mdName, int sLen)
{
@@ -155,14 +135,6 @@ public class RSAPSSSignature extends BaseSignature
this.pss = (EMSA_PSS) that.pss.clone();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in superclass ------------------------
-
public Object clone()
{
return new RSAPSSSignature(this);
@@ -171,79 +143,71 @@ public class RSAPSSSignature extends BaseSignature
protected void setupForVerification(PublicKey k)
throws IllegalArgumentException
{
- if (!(k instanceof RSAPublicKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof RSAPublicKey))
+ throw new IllegalArgumentException();
+
publicKey = (RSAPublicKey) k;
}
protected void setupForSigning(PrivateKey k) throws IllegalArgumentException
{
- if (!(k instanceof RSAPrivateKey))
- {
- throw new IllegalArgumentException();
- }
+ if (! (k instanceof RSAPrivateKey))
+ throw new IllegalArgumentException();
+
privateKey = (RSAPrivateKey) k;
}
protected Object generateSignature() throws IllegalStateException
{
// 1. Apply the EMSA-PSS encoding operation to the message M to produce an
- // encoded message EM of length CEILING((modBits ? 1)/8) octets such
- // that the bit length of the integer OS2IP(EM) is at most modBits ? 1:
- // EM = EMSA-PSS-Encode(M,modBits ? 1).
- // Note that the octet length of EM will be one less than k if
- // modBits ? 1 is divisible by 8. If the encoding operation outputs
- // 'message too long' or 'encoding error,' then output 'message too
- // long' or 'encoding error' and stop.
+ // encoded message EM of length CEILING((modBits ? 1)/8) octets such
+ // that the bit length of the integer OS2IP(EM) is at most modBits ? 1:
+ // EM = EMSA-PSS-Encode(M,modBits ? 1).
+ // Note that the octet length of EM will be one less than k if
+ // modBits ? 1 is divisible by 8. If the encoding operation outputs
+ // 'message too long' or 'encoding error,' then output 'message too
+ // long' or 'encoding error' and stop.
int modBits = ((RSAPrivateKey) privateKey).getModulus().bitLength();
byte[] salt = new byte[sLen];
this.nextRandomBytes(salt);
byte[] EM = pss.encode(md.digest(), modBits - 1, salt);
- if (DEBUG && debuglevel > 8)
- {
- debug("EM (sign): " + Util.toString(EM));
- }
+ if (Configuration.DEBUG)
+ log.fine("EM (sign): " + Util.toString(EM));
// 2. Convert the encoded message EM to an integer message representative
- // m (see Section 1.2.2): m = OS2IP(EM).
+ // m (see Section 1.2.2): m = OS2IP(EM).
BigInteger m = new BigInteger(1, EM);
// 3. Apply the RSASP signature primitive to the public key K and the
- // message representative m to produce an integer signature
- // representative s: s = RSASP(K,m).
+ // message representative m to produce an integer signature
+ // representative s: s = RSASP(K,m).
BigInteger s = RSA.sign(privateKey, m);
// 4. Convert the signature representative s to a signature S of length k
- // octets (see Section 1.2.1): S = I2OSP(s, k).
+ // octets (see Section 1.2.1): S = I2OSP(s, k).
// 5. Output the signature S.
int k = (modBits + 7) / 8;
- // return encodeSignature(s, k);
+ // return encodeSignature(s, k);
return RSA.I2OSP(s, k);
}
protected boolean verifySignature(Object sig) throws IllegalStateException
{
if (publicKey == null)
- {
- throw new IllegalStateException();
- }
- // byte[] S = decodeSignature(sig);
+ throw new IllegalStateException();
+ // byte[] S = decodeSignature(sig);
byte[] S = (byte[]) sig;
// 1. If the length of the signature S is not k octets, output 'signature
- // invalid' and stop.
+ // invalid' and stop.
int modBits = ((RSAPublicKey) publicKey).getModulus().bitLength();
int k = (modBits + 7) / 8;
if (S.length != k)
- {
- return false;
- }
+ return false;
// 2. Convert the signature S to an integer signature representative s:
- // s = OS2IP(S).
+ // s = OS2IP(S).
BigInteger s = new BigInteger(1, S);
// 3. Apply the RSAVP verification primitive to the public key (n, e) and
- // the signature representative s to produce an integer message
- // representative m: m = RSAVP((n, e), s).
- // If RSAVP outputs 'signature representative out of range,' then
- // output 'signature invalid' and stop.
+ // the signature representative s to produce an integer message
+ // representative m: m = RSAVP((n, e), s).
+ // If RSAVP outputs 'signature representative out of range,' then
+ // output 'signature invalid' and stop.
BigInteger m = null;
try
{
@@ -254,22 +218,18 @@ public class RSAPSSSignature extends BaseSignature
return false;
}
// 4. Convert the message representative m to an encoded message EM of
- // length emLen = CEILING((modBits - 1)/8) octets, where modBits is
- // equal to the bit length of the modulus: EM = I2OSP(m, emLen).
- // Note that emLen will be one less than k if modBits - 1 is divisible
- // by 8. If I2OSP outputs 'integer too large,' then output 'signature
- // invalid' and stop.
+ // length emLen = CEILING((modBits - 1)/8) octets, where modBits is
+ // equal to the bit length of the modulus: EM = I2OSP(m, emLen).
+ // Note that emLen will be one less than k if modBits - 1 is divisible
+ // by 8. If I2OSP outputs 'integer too large,' then output 'signature
+ // invalid' and stop.
int emBits = modBits - 1;
int emLen = (emBits + 7) / 8;
byte[] EM = m.toByteArray();
- if (DEBUG && debuglevel > 8)
- {
- debug("EM (verify): " + Util.toString(EM));
- }
+ if (Configuration.DEBUG)
+ log.fine("EM (verify): " + Util.toString(EM));
if (EM.length > emLen)
- {
- return false;
- }
+ return false;
else if (EM.length < emLen)
{
byte[] newEM = new byte[emLen];
@@ -277,9 +237,9 @@ public class RSAPSSSignature extends BaseSignature
EM = newEM;
}
// 5. Apply the EMSA-PSS decoding operation to the message M and the
- // encoded message EM: Result = EMSA-PSS-Decode(M, EM, emBits). If
- // Result = 'consistent,' output 'signature verified.' Otherwise,
- // output 'signature invalid.'
+ // encoded message EM: Result = EMSA-PSS-Decode(M, EM, emBits). If
+ // Result = 'consistent,' output 'signature verified.' Otherwise,
+ // output 'signature invalid.'
byte[] mHash = md.digest();
boolean result = false;
try
@@ -292,55 +252,4 @@ public class RSAPSSSignature extends BaseSignature
}
return result;
}
-
- // Other instance methods --------------------------------------------------
-
- /**
- * Converts the <i>signature representative</i> <code>s</code> to a signature
- * <code>S</code> of length <code>k</code> octets; i.e.
- * <code>S = I2OSP(s, k)</code>, where <code>k = CEILING(modBits/8)</code>.
- *
- * @param s the <i>signature representative</i>.
- * @param k the length of the output.
- * @return the signature as an octet sequence.
- * @exception IllegalArgumentException if the length in octets of meaningful
- * bytes of <code>s</code> is greater than <code>k</code>, implying that
- * <code>s</code> is not less than the RSA <i>modulus</i>.
- */
- // private Object encodeSignature(BigInteger s, int k) {
- // if (DEBUG && debuglevel > 8) {
- // debug("s.bitLength(): "+String.valueOf(s.bitLength()));
- // debug("k: "+String.valueOf(k));
- // }
- // byte[] result = s.toByteArray();
- // if (DEBUG && debuglevel > 8) {
- // debug("s: "+Util.toString(result));
- // debug("s (bytes): "+String.valueOf(result.length));
- // }
- // if (result.length < k) {
- // byte[] newResult = new byte[k];
- // System.arraycopy(result, 0, newResult, k-result.length, result.length);
- // result = newResult;
- // } else if (result.length > k) { // leftmost extra bytes should all be 0
- // int limit = result.length - k;
- // for (int i = 0; i < limit; i++) {
- // if (result[i] != 0x00) {
- // throw new IllegalArgumentException("integer too large");
- // }
- // }
- // byte[] newResult = new byte[k];
- // System.arraycopy(result, limit, newResult, 0, k);
- // result = newResult;
- // }
- // return result;
- // }
- /**
- * Returns the output of a previously generated signature object as an octet
- * sequence.<p>
- *
- * @return the octet sequence <code>S</code>.
- */
- // private byte[] decodeSignature(Object signature) {
- // return (byte[]) signature;
- // }
}
diff --git a/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java b/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java
index 2be79165f18..b5e059c20e0 100644
--- a/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java
+++ b/libjava/classpath/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java
@@ -44,53 +44,41 @@ import gnu.java.security.sig.ISignatureCodec;
import java.io.ByteArrayOutputStream;
/**
- * <p>An object that implements the {@link gnu.crypto.sig.ISignatureCodec}
- * operations for the <i>Raw</i> format to use with RSA-PSS signatures.</p>
+ * An object that implements the {@link ISignatureCodec} operations for the
+ * <i>Raw</i> format to use with RSA-PSS signatures.
*/
-public class RSAPSSSignatureRawCodec implements ISignatureCodec
+public class RSAPSSSignatureRawCodec
+ implements ISignatureCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.keys.IKeyPairCodec interface implementation
- // -------------------------------------------------------------------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated RSA-PSS signature object
- * according to the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for an RSA-PSS signature, in this implementation,
- * is a byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated RSA-PSS signature object
+ * according to the <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for an RSA-PSS signature, in this implementation, is
+ * a byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PSS_SIGNATURE},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the RSA-PSS signature
- * bytes in internet order,</li>
- * <li>the RSA-PSS signature bytes in internet order.</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_RSA_PSS_SIGNATURE},
+ * <li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the RSA-PSS signature
+ * bytes in internet order,</li>
+ * <li>the RSA-PSS signature bytes in internet order.</li>
* </ol>
- *
+ *
* @param signature the signature to encode, consisting of the output of the
- * <code>sign()</code> method of a {@link RSAPSSSignature} instance --a byte
- * array.
+ * <code>sign()</code> method of a {@link RSAPSSSignature} instance
+ * --a byte array.
* @return the <i>Raw</i> format encoding of the designated signature.
* @exception IllegalArgumentException if the designated signature is not an
- * RSA-PSS one.
+ * RSA-PSS one.
*/
public byte[] encodeSignature(Object signature)
{
@@ -101,28 +89,23 @@ public class RSAPSSSignatureRawCodec implements ISignatureCodec
}
catch (Exception x)
{
- throw new IllegalArgumentException("key");
+ throw new IllegalArgumentException("signature");
}
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[0]);
baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[1]);
baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[2]);
baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[3]);
-
// version
baos.write(0x01);
-
// signature bytes
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
baos.write((length >>> 8) & 0xFF);
baos.write(length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -133,25 +116,19 @@ public class RSAPSSSignatureRawCodec implements ISignatureCodec
|| k[1] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[1]
|| k[2] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[2]
|| k[3] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
-
+ throw new IllegalArgumentException("version");
int i = 5;
int l;
-
// signature bytes
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
byte[] result = new byte[l];
System.arraycopy(k, i, result, 0, l);
-
return result;
}
}
diff --git a/libjava/classpath/gnu/java/security/util/Base64.java b/libjava/classpath/gnu/java/security/util/Base64.java
index f9998c38f48..9b2ae12dc27 100644
--- a/libjava/classpath/gnu/java/security/util/Base64.java
+++ b/libjava/classpath/gnu/java/security/util/Base64.java
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.java.security.util;
-import java.io.PrintWriter;
+import gnu.java.security.Configuration;
+
import java.io.UnsupportedEncodingException;
+import java.util.logging.Logger;
/**
* Most of this implementation is from Robert Harder's public domain Base64
@@ -47,25 +49,7 @@ import java.io.UnsupportedEncodingException;
*/
public class Base64
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "Base64";
-
- private static final boolean DEBUG = true;
-
- private static final int debuglevel = 9;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(Base64.class.getName());
/** Maximum line length (76) of Base64 output. */
private static final int MAX_LINE_LENGTH = 76;
@@ -81,79 +65,58 @@ public class Base64
private static final byte EQUALS_SIGN_ENC = -1; // equals sign in encoding
/** The 64 valid Base64 values. */
- private static final byte[] ALPHABET = { (byte) 'A', (byte) 'B', (byte) 'C',
- (byte) 'D', (byte) 'E', (byte) 'F',
- (byte) 'G', (byte) 'H', (byte) 'I',
- (byte) 'J', (byte) 'K', (byte) 'L',
- (byte) 'M', (byte) 'N', (byte) 'O',
- (byte) 'P', (byte) 'Q', (byte) 'R',
- (byte) 'S', (byte) 'T', (byte) 'U',
- (byte) 'V', (byte) 'W', (byte) 'X',
- (byte) 'Y', (byte) 'Z', (byte) 'a',
- (byte) 'b', (byte) 'c', (byte) 'd',
- (byte) 'e', (byte) 'f', (byte) 'g',
- (byte) 'h', (byte) 'i', (byte) 'j',
- (byte) 'k', (byte) 'l', (byte) 'm',
- (byte) 'n', (byte) 'o', (byte) 'p',
- (byte) 'q', (byte) 'r', (byte) 's',
- (byte) 't', (byte) 'u', (byte) 'v',
- (byte) 'w', (byte) 'x', (byte) 'y',
- (byte) 'z', (byte) '0', (byte) '1',
- (byte) '2', (byte) '3', (byte) '4',
- (byte) '5', (byte) '6', (byte) '7',
- (byte) '8', (byte) '9', (byte) '+',
- (byte) '/' };
+ private static final byte[] ALPHABET = {
+ (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F',
+ (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L',
+ (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R',
+ (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X',
+ (byte) 'Y', (byte) 'Z', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd',
+ (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j',
+ (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p',
+ (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v',
+ (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z', (byte) '0', (byte) '1',
+ (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7',
+ (byte) '8', (byte) '9', (byte) '+', (byte) '/'
+ };
/**
* Translates a Base64 value to either its 6-bit reconstruction value or a
* negative number indicating some other meaning.
*/
- private static final byte[] DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8
- -5, -5, // Whitespace: Tab and Linefeed
- -9, -9, // Decimal 11 - 12
- -5, // Whitespace: Carriage Return
- -9, -9, -9, -9, -9, -9, -9, -9, -9,
- -9, -9, -9, -9, // Decimal 14 - 26
- -9, -9, -9, -9, -9, // Decimal 27 - 31
- -5, // Whitespace: Space
- -9, -9, -9, -9, -9, -9, -9, -9, -9,
- -9, // Decimal 33 - 42
- 62, // Plus sign at decimal 43
- -9, -9, -9, // Decimal 44 - 46
- 63, // Slash at decimal 47
- 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, // Numbers zero through nine
- -9, -9, -9, // Decimal 58 - 60
- -1, // Equals sign at decimal 61
- -9, -9, -9, // Decimal 62 - 64
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, // Letters 'A' through 'N'
- 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, // Letters 'O' through 'Z'
- -9, -9, -9, -9, -9, -9, // Decimal 91 - 96
- 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, // Letters 'a' through 'm'
- 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, // Letters 'n' through 'z'
- -9, -9, -9, -9 // Decimal 123 - 126
+ private static final byte[] DECODABET = {
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8
+ -5, -5, // Whitespace: Tab and Linefeed
+ -9, -9, // Decimal 11 - 12
+ -5, // Whitespace: Carriage Return
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26
+ -9, -9, -9, -9, -9, // Decimal 27 - 31
+ -5, // Whitespace: Space
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42
+ 62, // Plus sign at decimal 43
+ -9, -9, -9, // Decimal 44 - 46
+ 63, // Slash at decimal 47
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ -9, -9, -9, // Decimal 58 - 60
+ -1, // Equals sign at decimal 61
+ -9, -9, -9, // Decimal 62 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ -9, -9, -9, -9, -9, -9, // Decimal 91 - 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ -9, -9, -9, -9 // Decimal 123 - 126
};
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial private ctor to enfore Singleton pattern. */
private Base64()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* Encodes a byte array into Base64 notation. Equivalent to calling
* <code>encode(source, 0, source.length)</code>.
- *
+ *
* @param src the data to convert.
*/
public static final String encode(final byte[] src)
@@ -163,7 +126,7 @@ public class Base64
/**
* Encodes a byte array into Base64 notation.
- *
+ *
* @param src the data to convert.
* @param off offset in array where conversion should begin.
* @param len length of data to convert.
@@ -176,7 +139,7 @@ public class Base64
final byte[] outBuff = new byte[len43 // Main 4:3
+ ((len % 3) > 0 ? 4 : 0) // Account for padding
+ (breakLines ? (len43 / MAX_LINE_LENGTH)
- : 0)]; // New lines
+ : 0)]; // New lines
int d = 0;
int e = 0;
final int len2 = len - 2;
@@ -192,13 +155,11 @@ public class Base64
lineLength = 0;
}
}
-
- if (d < len)
- { // padding needed
+ if (d < len) // padding needed
+ {
encode3to4(src, d + off, len - d, outBuff, e);
e += 4;
}
-
return new String(outBuff, 0, e);
}
@@ -255,31 +216,26 @@ public class Base64
} // end if: quartet built
} // end if: equals sign or better
}
- else
- {
- throw new IllegalArgumentException("Illegal BASE-64 character at #"
- + i + ": " + src[i]
- + "(decimal)");
- }
+ throw new IllegalArgumentException("Illegal BASE-64 character at #"
+ + i + ": " + src[i] + "(decimal)");
}
-
final byte[] result = new byte[outBuffPosn];
System.arraycopy(outBuff, 0, result, 0, outBuffPosn);
return result;
}
/**
- * <p>Encodes up to three bytes of the array <code>src</code> and writes
- * the resulting four Base64 bytes to <code>dest</code>. The source and
+ * Encodes up to three bytes of the array <code>src</code> and writes the
+ * resulting four Base64 bytes to <code>dest</code>. The source and
* destination arrays can be manipulated anywhere along their length by
- * specifying <code>sOffset</code> and <code>dOffset</code>.</p>
- *
- * <p>This method does not check to make sure the arrays are large enough to
+ * specifying <code>sOffset</code> and <code>dOffset</code>.
+ * <p>
+ * This method does not check to make sure the arrays are large enough to
* accomodate <code>sOffset + 3</code> for the <code>src</code> array or
* <code>dOffset + 4</code> for the <code>dest</code> array. The actual
* number of significant bytes in the input array is given by
- * <code>numBytes</code>.</p>
- *
+ * <code>numBytes</code>.
+ *
* @param src the array to convert.
* @param sOffset the index where conversion begins.
* @param numBytes the number of significant bytes in your array.
@@ -302,25 +258,25 @@ public class Base64
// significant bytes passed in the array.
// We have to shift left 24 in order to flush out the 1's that appear
// when Java treats a value as negative that is cast from a byte to an int.
- final int inBuff = (numBytes > 0 ? ((src[sOffset] << 24) >>> 8) : 0)
+ final int inBuff = (numBytes > 0 ? ((src[sOffset] << 24) >>> 8) : 0)
| (numBytes > 1 ? ((src[sOffset + 1] << 24) >>> 16) : 0)
| (numBytes > 2 ? ((src[sOffset + 2] << 24) >>> 24) : 0);
switch (numBytes)
{
case 3:
- dest[dOffset] = ALPHABET[(inBuff >>> 18)];
+ dest[dOffset ] = ALPHABET[(inBuff >>> 18)];
dest[dOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3F];
- dest[dOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3F];
- dest[dOffset + 3] = ALPHABET[(inBuff) & 0x3F];
+ dest[dOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3F];
+ dest[dOffset + 3] = ALPHABET[(inBuff) & 0x3F];
break;
case 2:
- dest[dOffset] = ALPHABET[(inBuff >>> 18)];
+ dest[dOffset ] = ALPHABET[(inBuff >>> 18)];
dest[dOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3F];
- dest[dOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3F];
+ dest[dOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3F];
dest[dOffset + 3] = EQUALS_SIGN;
break;
case 1:
- dest[dOffset] = ALPHABET[(inBuff >>> 18)];
+ dest[dOffset ] = ALPHABET[(inBuff >>> 18)];
dest[dOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3F];
dest[dOffset + 2] = EQUALS_SIGN;
dest[dOffset + 3] = EQUALS_SIGN;
@@ -330,19 +286,18 @@ public class Base64
}
/**
- * <p>Decodes four bytes from array <code>src</code> and writes the
- * resulting bytes (up to three of them) to <code>dest</code>.</p>
- *
- * <p>The source and destination arrays can be manipulated anywhere along
- * their length by specifying <code>sOffset</code> and <code>dOffset</code>.
- * </p>
- *
- * <p>This method does not check to make sure your arrays are large enough
- * to accomodate <code>sOffset + 4</code> for the <code>src</code> array or
+ * Decodes four bytes from array <code>src</code> and writes the resulting
+ * bytes (up to three of them) to <code>dest</code>.
+ * <p>
+ * The source and destination arrays can be manipulated anywhere along their
+ * length by specifying <code>sOffset</code> and <code>dOffset</code>.
+ * <p>
+ * This method does not check to make sure your arrays are large enough to
+ * accomodate <code>sOffset + 4</code> for the <code>src</code> array or
* <code>dOffset + 3</code> for the <code>dest</code> array. This method
* returns the actual number of bytes that were converted from the Base64
- * encoding.</p>
- *
+ * encoding.
+ *
* @param src the array to convert.
* @param sOffset the index where conversion begins.
* @param dest the array to hold the conversion.
@@ -352,43 +307,41 @@ public class Base64
private static final int decode4to3(final byte[] src, final int sOffset,
final byte[] dest, final int dOffset)
{
- if (src[sOffset + 2] == EQUALS_SIGN)
- { // Example: Dk==
- final int outBuff = ((DECODABET[src[sOffset]] & 0xFF) << 18)
- | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12);
- dest[dOffset] = (byte) (outBuff >>> 16);
+ if (src[sOffset + 2] == EQUALS_SIGN) // Example: Dk==
+ {
+ final int outBuff = ((DECODABET[src[sOffset ]] & 0xFF) << 18)
+ | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12);
+ dest[dOffset] = (byte)(outBuff >>> 16);
return 1;
}
-
- if (src[sOffset + 3] == EQUALS_SIGN)
- { // Example: DkL=
- final int outBuff = ((DECODABET[src[sOffset]] & 0xFF) << 18)
- | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12)
- | ((DECODABET[src[sOffset + 2]] & 0xFF) << 6);
- dest[dOffset] = (byte) (outBuff >>> 16);
- dest[dOffset + 1] = (byte) (outBuff >>> 8);
+ if (src[sOffset + 3] == EQUALS_SIGN) // Example: DkL=
+ {
+ final int outBuff = ((DECODABET[src[sOffset ]] & 0xFF) << 18)
+ | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[src[sOffset + 2]] & 0xFF) << 6);
+ dest[dOffset ] = (byte)(outBuff >>> 16);
+ dest[dOffset + 1] = (byte)(outBuff >>> 8);
return 2;
}
-
- try
- { // Example: DkLE
- final int outBuff = ((DECODABET[src[sOffset]] & 0xFF) << 18)
- | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12)
- | ((DECODABET[src[sOffset + 2]] & 0xFF) << 6)
- | ((DECODABET[src[sOffset + 3]] & 0xFF));
- dest[dOffset] = (byte) (outBuff >> 16);
- dest[dOffset + 1] = (byte) (outBuff >> 8);
+ try // Example: DkLE
+ {
+ final int outBuff = ((DECODABET[src[sOffset ]] & 0xFF) << 18)
+ | ((DECODABET[src[sOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[src[sOffset + 2]] & 0xFF) << 6)
+ | ((DECODABET[src[sOffset + 3]] & 0xFF));
+ dest[dOffset ] = (byte)(outBuff >> 16);
+ dest[dOffset + 1] = (byte)(outBuff >> 8);
dest[dOffset + 2] = (byte) outBuff;
return 3;
}
catch (Exception x)
{
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- debug("" + src[sOffset] + ": " + (DECODABET[src[sOffset]]));
- debug("" + src[sOffset + 1] + ": " + (DECODABET[src[sOffset + 1]]));
- debug("" + src[sOffset + 2] + ": " + (DECODABET[src[sOffset + 2]]));
- debug("" + src[sOffset + 3] + ": " + (DECODABET[src[sOffset + 3]]));
+ log.fine("" + src[sOffset ] + ": " + (DECODABET[src[sOffset ]]));
+ log.fine("" + src[sOffset + 1] + ": " + (DECODABET[src[sOffset + 1]]));
+ log.fine("" + src[sOffset + 2] + ": " + (DECODABET[src[sOffset + 2]]));
+ log.fine("" + src[sOffset + 3] + ": " + (DECODABET[src[sOffset + 3]]));
}
return -1;
}
diff --git a/libjava/classpath/gnu/classpath/ByteArray.java b/libjava/classpath/gnu/java/security/util/ByteArray.java
index 6307b8abd79..0d04d9127ae 100644
--- a/libjava/classpath/gnu/classpath/ByteArray.java
+++ b/libjava/classpath/gnu/java/security/util/ByteArray.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath;
+package gnu.java.security.util;
import java.io.PrintWriter;
import java.io.StringWriter;
diff --git a/libjava/classpath/gnu/java/security/util/ExpirableObject.java b/libjava/classpath/gnu/java/security/util/ExpirableObject.java
index 2d4452015af..e0c4e6b5984 100644
--- a/libjava/classpath/gnu/java/security/util/ExpirableObject.java
+++ b/libjava/classpath/gnu/java/security/util/ExpirableObject.java
@@ -46,26 +46,23 @@ import javax.security.auth.Destroyable;
/**
* The base class for objects with sensitive data that are automatically
- * destroyed after a timeout elapses. On creation, an object that extends
- * this class will automatically be added to a {@link Timer} object that,
- * once a timeout elapses, will automatically call the {@link
- * Destroyable#destroy()} method.
- *
- * <p>Concrete subclasses must implement the {@link doDestroy()} method
- * instead of {@link Destroyable#destroy()}; the behavior of that method
- * should match exactly the behavior desired of <code>destroy()</code>.
- *
- * <p>Note that if a {@link DestroyFailedException} occurs when the timeout
+ * destroyed after a timeout elapses. On creation, an object that extends this
+ * class will automatically be added to a {@link Timer} object that, once a
+ * timeout elapses, will automatically call the {@link Destroyable#destroy()}
+ * method.
+ * <p>
+ * Concrete subclasses must implement the {@link #doDestroy()} method instead of
+ * {@link Destroyable#destroy()}; the behavior of that method should match
+ * exactly the behavior desired of <code>destroy()</code>.
+ * <p>
+ * Note that if a {@link DestroyFailedException} occurs when the timeout
* expires, it will not be reported.
- *
+ *
* @see Destroyable
*/
-public abstract class ExpirableObject implements Destroyable
+public abstract class ExpirableObject
+ implements Destroyable
{
-
- // Constants and fields.
- // -------------------------------------------------------------------------
-
/**
* The default timeout, used in the default constructor.
*/
@@ -82,9 +79,6 @@ public abstract class ExpirableObject implements Destroyable
*/
private final Destroyer destroyer;
- // Constructors.
- // -------------------------------------------------------------------------
-
/**
* Create a new expirable object that will expire after one hour.
*/
@@ -94,12 +88,11 @@ public abstract class ExpirableObject implements Destroyable
}
/**
- * Create a new expirable object that will expire after the specified
- * timeout.
- *
+ * Create a new expirable object that will expire after the specified timeout.
+ *
* @param delay The delay before expiration.
* @throws IllegalArgumentException If <i>delay</i> is negative, or if
- * <code>delay + System.currentTimeMillis()</code> is negative.
+ * <code>delay + System.currentTimeMillis()</code> is negative.
*/
protected ExpirableObject(final long delay)
{
@@ -107,14 +100,11 @@ public abstract class ExpirableObject implements Destroyable
EXPIRER.schedule(destroyer, delay);
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
/**
- * Destroys this object. This method calls {@link doDestroy}, then, if
- * no exception is thrown, cancels the task that would destroy this object
- * when the timeout is reached.
- *
+ * Destroys this object. This method calls {@link #doDestroy}, then, if no
+ * exception is thrown, cancels the task that would destroy this object when
+ * the timeout is reached.
+ *
* @throws DestroyFailedException If this operation fails.
*/
public final void destroy() throws DestroyFailedException
@@ -126,42 +116,30 @@ public abstract class ExpirableObject implements Destroyable
/**
* Subclasses must implement this method instead of the {@link
* Destroyable#destroy()} method.
- *
+ *
* @throws DestroyFailedException If this operation fails.
*/
protected abstract void doDestroy() throws DestroyFailedException;
- // Inner classes.
- // -------------------------------------------------------------------------
-
/**
* The task that destroys the target when the timeout elapses.
*/
- private final class Destroyer extends TimerTask
+ private final class Destroyer
+ extends TimerTask
{
-
- // Fields.
- // -----------------------------------------------------------------------
-
private final ExpirableObject target;
- // Constructor.
- // -----------------------------------------------------------------------
-
Destroyer(final ExpirableObject target)
{
super();
this.target = target;
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
public void run()
{
try
{
- if (!target.isDestroyed())
+ if (! target.isDestroyed())
target.doDestroy();
}
catch (DestroyFailedException dfe)
diff --git a/libjava/classpath/gnu/java/security/util/IntegerUtil.java b/libjava/classpath/gnu/java/security/util/IntegerUtil.java
new file mode 100644
index 00000000000..f071308084c
--- /dev/null
+++ b/libjava/classpath/gnu/java/security/util/IntegerUtil.java
@@ -0,0 +1,109 @@
+/* IntegerUtil.java -- JDK 5 Integer methods with 1.4 API
+ 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.security.util;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Utility class which offers Integer related methods found in RI's version 5
+ * but written with RI's 1.4 API.
+ */
+public abstract class IntegerUtil
+{
+ /** Maximum size of our cache of constructed Integers. */
+ private static final int CACHE_SIZE = 100;
+ /** LRU (Least Recently Used) cache, of the last accessed 100 Integers. */
+ private static final Map cache = new LinkedHashMap(CACHE_SIZE + 1, 0.75F, true)
+ {
+ public boolean removeEldestEntry(Map.Entry entry)
+ {
+ return size() > CACHE_SIZE;
+ }
+ };
+
+ /** Trivial private constructor to enforce Singleton usage. */
+ private IntegerUtil()
+ {
+ super();
+ }
+
+ /**
+ * Similar to {@link Integer#valueOf(String)} except it caches the result in
+ * a local LRU cache of 100 elements, organized by access order.
+ * <p>
+ * This method MUST be used in the gnu.java.security and gnu.javax.crypto
+ * packages to ensure they would work with a version 1.4 only of the Java
+ * class library API.
+ *
+ * @param aString a string representation of an integer.
+ * @return the {@link Integer} object representing the designated string.
+ */
+ public static final Integer valueOf(String aString)
+ {
+ Integer result;
+ synchronized (cache)
+ {
+ result = (Integer) cache.get(aString);
+ if (result == null)
+ {
+ result = Integer.valueOf(aString);
+ cache.put(aString, result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Simulates the <code>valueOf(int)</code> method found in {@link Integer} of
+ * the RI's version 1.5 using a local LRU cache of 100 elements, organized by
+ * access order.
+ * <p>
+ * This method MUST be used in the gnu.java.security and gnu.javax.crypto
+ * packages to ensure they would work with a version 1.4 only of the Java
+ * class library API.
+ *
+ * @param anInt a decimal integer.
+ * @return the {@link Integer} object representing the designated primitive.
+ */
+ public static final Integer valueOf(int anInt)
+ {
+ return valueOf(Integer.toString(anInt, 10));
+ }
+}
diff --git a/libjava/classpath/gnu/java/security/util/PRNG.java b/libjava/classpath/gnu/java/security/util/PRNG.java
index 138cc6bcb0c..7bb27cbf452 100644
--- a/libjava/classpath/gnu/java/security/util/PRNG.java
+++ b/libjava/classpath/gnu/java/security/util/PRNG.java
@@ -45,27 +45,20 @@ import gnu.java.security.prng.LimitReachedException;
import gnu.java.security.prng.MDGenerator;
/**
- * A useful hash-based (SHA) pseudo-random number generator used
- * throughout this library.
+ * A useful hash-based (SHA) pseudo-random number generator used throughout this
+ * library.
*
* @see MDGenerator
*/
public class PRNG
{
- // Constans and fields
- // --------------------------------------------------------------------------
-
/** The underlying {@link IRandom}. */
private IRandom delegate;
- // Constructor(s)
- // --------------------------------------------------------------------------
-
/**
* Private constructor to enforce using the Factory method.
*
- * @param delegate
- * the undelying {@link IRandom} object used.
+ * @param delegate the undelying {@link IRandom} object used.
*/
private PRNG(IRandom delegate)
{
@@ -74,9 +67,6 @@ public class PRNG
this.delegate = delegate;
}
- // Class methods
- // --------------------------------------------------------------------------
-
public static final PRNG getInstance()
{
IRandom delegate = new MDGenerator();
@@ -86,10 +76,10 @@ public class PRNG
// initialise it with a seed
long t = System.currentTimeMillis();
byte[] seed = new byte[] {
- (byte) (t >>> 56), (byte) (t >>> 48),
- (byte) (t >>> 40), (byte) (t >>> 32),
- (byte) (t >>> 24), (byte) (t >>> 16),
- (byte) (t >>> 8), (byte) t};
+ (byte)(t >>> 56), (byte)(t >>> 48),
+ (byte)(t >>> 40), (byte)(t >>> 32),
+ (byte)(t >>> 24), (byte)(t >>> 16),
+ (byte)(t >>> 8), (byte) t };
map.put(MDGenerator.SEEED, seed);
delegate.init(map); // default is to use SHA-1 hash
}
@@ -97,19 +87,14 @@ public class PRNG
{
throw new ExceptionInInitializerError(x);
}
-
return new PRNG(delegate);
}
- // Instance methods
- // --------------------------------------------------------------------------
-
/**
* Completely fills the designated <code>buffer</code> with random data
* generated by the underlying delegate.
*
- * @param buffer
- * the place holder of random bytes generated by the underlying
+ * @param buffer the place holder of random bytes generated by the underlying
* delegate. On output, the contents of <code>buffer</code> are
* replaced with pseudo-random data, iff the <code>buffer</code>
* size is not zero.
diff --git a/libjava/classpath/gnu/java/security/util/Prime2.java b/libjava/classpath/gnu/java/security/util/Prime2.java
deleted file mode 100644
index 6e46f5fcadc..00000000000
--- a/libjava/classpath/gnu/java/security/util/Prime2.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/* Prime2.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
-your option) any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-USA
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.security.util;
-
-import java.io.PrintWriter;
-import java.lang.ref.WeakReference;
-import java.math.BigInteger;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-/**
- * <p>A collection of prime number related utilities used in this library.</p>
- */
-public class Prime2
-{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "prime";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 5;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final int DEFAULT_CERTAINTY = 20; // XXX is this a good value?
-
- private static final BigInteger ZERO = BigInteger.ZERO;
-
- private static final BigInteger ONE = BigInteger.ONE;
-
- private static final BigInteger TWO = BigInteger.valueOf(2L);
-
- /**
- * The first SMALL_PRIME primes: Algorithm P, section 1.3.2, The Art of
- * Computer Programming, Donald E. Knuth.
- */
- private static final int SMALL_PRIME_COUNT = 1000;
-
- private static final BigInteger[] SMALL_PRIME = new BigInteger[SMALL_PRIME_COUNT];
- static
- {
- long time = -System.currentTimeMillis();
- SMALL_PRIME[0] = TWO;
- int N = 3;
- int J = 0;
- int prime;
- P2: while (true)
- {
- SMALL_PRIME[++J] = BigInteger.valueOf(N);
- if (J >= 999)
- {
- break P2;
- }
- P4: while (true)
- {
- N += 2;
- P6: for (int K = 1; true; K++)
- {
- prime = SMALL_PRIME[K].intValue();
- if ((N % prime) == 0)
- {
- continue P4;
- }
- else if ((N / prime) <= prime)
- {
- continue P2;
- }
- }
- }
- }
- time += System.currentTimeMillis();
- if (DEBUG && debuglevel > 8)
- {
- StringBuffer sb;
- for (int i = 0; i < (SMALL_PRIME_COUNT / 10); i++)
- {
- sb = new StringBuffer();
- for (int j = 0; j < 10; j++)
- {
- sb.append(String.valueOf(SMALL_PRIME[i * 10 + j])).append(" ");
- }
- debug(sb.toString());
- }
- }
- if (DEBUG && debuglevel > 4)
- {
- debug("Generating first " + String.valueOf(SMALL_PRIME_COUNT)
- + " primes took: " + String.valueOf(time) + " ms.");
- }
- }
-
- private static final Map knownPrimes = new WeakHashMap();
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- /** Trivial constructor to enforce Singleton pattern. */
- private Prime2()
- {
- super();
- }
-
- // Class methods
- // -------------------------------------------------------------------------
-
- /**
- * <p>Trial division for the first 1000 small primes.</p>
- *
- * <p>Returns <code>true</code> if at least one small prime, among the first
- * 1000 ones, was found to divide the designated number. Retuens <code>false</code>
- * otherwise.</p>
- *
- * @param w the number to test.
- * @return <code>true</code> if at least one small prime was found to divide
- * the designated number.
- */
- public static boolean hasSmallPrimeDivisor(BigInteger w)
- {
- BigInteger prime;
- for (int i = 0; i < SMALL_PRIME_COUNT; i++)
- {
- prime = SMALL_PRIME[i];
- if (w.mod(prime).equals(ZERO))
- {
- if (DEBUG && debuglevel > 4)
- {
- debug(prime.toString(16) + " | " + w.toString(16) + "...");
- }
- return true;
- }
- }
- if (DEBUG && debuglevel > 4)
- {
- debug(w.toString(16) + " has no small prime divisors...");
- }
- return false;
- }
-
- /**
- * <p>Java port of Colin Plumb primality test (Euler Criterion)
- * implementation for a base of 2 --from bnlib-1.1 release, function
- * primeTest() in prime.c. this is his comments.</p>
- *
- * <p>"Now, check that bn is prime. If it passes to the base 2, it's prime
- * beyond all reasonable doubt, and everything else is just gravy, but it
- * gives people warm fuzzies to do it.</p>
- *
- * <p>This starts with verifying Euler's criterion for a base of 2. This is
- * the fastest pseudoprimality test that I know of, saving a modular squaring
- * over a Fermat test, as well as being stronger. 7/8 of the time, it's as
- * strong as a strong pseudoprimality test, too. (The exception being when
- * <code>bn == 1 mod 8</code> and <code>2</code> is a quartic residue, i.e.
- * <code>bn</code> is of the form <code>a^2 + (8*b)^2</code>.) The precise
- * series of tricks used here is not documented anywhere, so here's an
- * explanation. Euler's criterion states that if <code>p</code> is prime
- * then <code>a^((p-1)/2)</code> is congruent to <code>Jacobi(a,p)</code>,
- * modulo <code>p</code>. <code>Jacobi(a, p)</code> is a function which is
- * <code>+1</code> if a is a square modulo <code>p</code>, and <code>-1</code>
- * if it is not. For <code>a = 2</code>, this is particularly simple. It's
- * <code>+1</code> if <code>p == +/-1 (mod 8)</code>, and <code>-1</code> if
- * <code>m == +/-3 (mod 8)</code>. If <code>p == 3 (mod 4)</code>, then all
- * a strong test does is compute <code>2^((p-1)/2)</code>. and see if it's
- * <code>+1</code> or <code>-1</code>. (Euler's criterion says <i>which</i>
- * it should be.) If <code>p == 5 (mod 8)</code>, then <code>2^((p-1)/2)</code>
- * is <code>-1</code>, so the initial step in a strong test, looking at
- * <code>2^((p-1)/4)</code>, is wasted --you're not going to find a
- * <code>+/-1</code> before then if it <b>is</b> prime, and it shouldn't
- * have either of those values if it isn't. So don't bother.</p>
- *
- * <p>The remaining case is <code>p == 1 (mod 8)</code>. In this case, we
- * expect <code>2^((p-1)/2) == 1 (mod p)</code>, so we expect that the
- * square root of this, <code>2^((p-1)/4)</code>, will be <code>+/-1 (mod p)
- * </code>. Evaluating this saves us a modular squaring 1/4 of the time. If
- * it's <code>-1</code>, a strong pseudoprimality test would call <code>p</code>
- * prime as well. Only if the result is <code>+1</code>, indicating that
- * <code>2</code> is not only a quadratic residue, but a quartic one as well,
- * does a strong pseudoprimality test verify more things than this test does.
- * Good enough.</p>
- *
- * <p>We could back that down another step, looking at <code>2^((p-1)/8)</code>
- * if there was a cheap way to determine if <code>2</code> were expected to
- * be a quartic residue or not. Dirichlet proved that <code>2</code> is a
- * quadratic residue iff <code>p</code> is of the form <code>a^2 + (8*b^2)</code>.
- * All primes <code>== 1 (mod 4)</code> can be expressed as <code>a^2 +
- * (2*b)^2</code>, but I see no cheap way to evaluate this condition."</p>
- *
- * @param bn the number to test.
- * @return <code>true</code> iff the designated number passes Euler criterion
- * as implemented by Colin Plumb in his <i>bnlib</i> version 1.1.
- */
- public static boolean passEulerCriterion(final BigInteger bn)
- {
- BigInteger bn_minus_one = bn.subtract(ONE);
- BigInteger e = bn_minus_one;
- // l is the 3 least-significant bits of e
- int l = e.and(BigInteger.valueOf(7L)).intValue();
- int j = 1; // Where to start in prime array for strong prime tests
- BigInteger a;
- int k;
-
- if (l != 0)
- {
- e = e.shiftRight(1);
- a = TWO.modPow(e, bn);
- if (l == 6) // bn == 7 mod 8, expect +1
- {
- if (a.bitLength() != 1)
- {
- debugBI("Fails Euler criterion #1", bn);
- return false; // Not prime
- }
- k = 1;
- }
- else // bn == 3 or 5 mod 8, expect -1 == bn-1
- {
- a = a.add(ONE);
- if (a.compareTo(bn) != 0)
- {
- debugBI("Fails Euler criterion #2", bn);
- return false; // Not prime
- }
- k = 1;
- if ((l & 4) != 0) // bn == 5 mod 8, make odd for strong tests
- {
- e = e.shiftRight(1);
- k = 2;
- }
- }
- }
- else // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn
- {
- e = e.shiftRight(2);
- a = TWO.modPow(e, bn);
- if (a.bitLength() == 1)
- j = 0; // Re-do strong prime test to base 2
- else
- {
- a = a.add(ONE);
- if (a.compareTo(bn) != 0)
- {
- debugBI("Fails Euler criterion #3", bn);
- return false; // Not prime
- }
- }
- // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s.
- k = e.getLowestSetBit();
- e = e.shiftRight(k);
- k += 2;
- }
- // It's prime! Now go on to confirmation tests
-
- // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with
- // probability 2^-k, so its expected value is 2. j = 1 in the usual case
- // when the previous test was as good as a strong prime test, but 1/8 of
- // the time, j = 0 because the strong prime test to the base 2 needs to
- // be re-done.
- for (int i = j; i < 7; i++) // try only the first 7 primes
- {
- a = SMALL_PRIME[i];
- a = a.modPow(e, bn);
- if (a.bitLength() == 1)
- continue; // Passed this test
-
- l = k;
- while (true)
- {
-// a = a.add(ONE);
-// if (a.compareTo(w) == 0) { // Was result bn-1?
- if (a.compareTo(bn_minus_one) == 0) // Was result bn-1?
- break; // Prime
-
- if (--l == 0) // Reached end, not -1? luck?
- {
- debugBI("Fails Euler criterion #4", bn);
- return false; // Failed, not prime
- }
- // This portion is executed, on average, once
-// a = a.subtract(ONE); // Put a back where it was
- a = a.modPow(TWO, bn);
- if (a.bitLength() == 1)
- {
- debugBI("Fails Euler criterion #5", bn);
- return false; // Failed, not prime
- }
- }
- // It worked (to the base primes[i])
- }
- debugBI("Passes Euler criterion", bn);
- return true;
- }
-
- public static boolean isProbablePrime(BigInteger w)
- {
- return isProbablePrime(w, DEFAULT_CERTAINTY);
- }
-
- /**
- * Wrapper around {@link BigInteger#isProbablePrime(int)} with few pre-checks.
- *
- * @param w the integer to test.
- * @param certainty the certainty with which to compute the test.
- */
- public static boolean isProbablePrime(BigInteger w, int certainty)
- {
- // Nonnumbers are not prime.
- if (w == null)
- return false;
-
- // eliminate trivial cases when w == 0 or 1
- if (w.equals(ZERO) || w.equals(ONE))
- return false;
-
- // Test if w is a known small prime.
- for (int i = 0; i < SMALL_PRIME_COUNT; i++)
- if (w.equals(SMALL_PRIME[i]))
- {
- if (DEBUG && debuglevel > 4)
- debug(w.toString(16) + " is a small prime");
- return true;
- }
-
- // Check if it's already a known prime
- WeakReference obj = (WeakReference) knownPrimes.get(w);
- if (obj != null && w.equals(obj.get()))
- {
- if (DEBUG && debuglevel > 4)
- debug("found in known primes");
- return true;
- }
-
- // trial division with first 1000 primes
- if (hasSmallPrimeDivisor(w))
- {
- if (DEBUG && debuglevel > 4)
- debug(w.toString(16) + " has a small prime divisor. Rejected...");
- return false;
- }
-
-// Euler's criterion.
-// if (passEulerCriterion(w)) {
-// if (DEBUG && debuglevel > 4) {
-// debug(w.toString(16)+" passes Euler's criterion...");
-// }
-// } else {
-// if (DEBUG && debuglevel > 4) {
-// debug(w.toString(16)+" fails Euler's criterion. Rejected...");
-// }
-// return false;
-// }
-//
-// if (DEBUG && debuglevel > 4)
-// {
-// debug(w.toString(16) + " is probable prime. Accepted...");
-// }
-
- boolean result = w.isProbablePrime(certainty);
- if (result && certainty > 0) // store it in the known primes weak hash-map
- knownPrimes.put(w, new WeakReference(w));
-
- return result;
- }
-
- // helper methods -----------------------------------------------------------
-
- private static final void debugBI(String msg, BigInteger bn)
- {
- if (DEBUG && debuglevel > 4)
- debug("*** " + msg + ": 0x" + bn.toString(16));
- }
-}
diff --git a/libjava/classpath/gnu/java/security/util/Sequence.java b/libjava/classpath/gnu/java/security/util/Sequence.java
index 5edc7942ef9..5e3a64eaf3e 100644
--- a/libjava/classpath/gnu/java/security/util/Sequence.java
+++ b/libjava/classpath/gnu/java/security/util/Sequence.java
@@ -44,24 +44,18 @@ import java.util.LinkedList;
/**
* A monotonic sequence of integers in the finite field 2<sup>32</sup>.
*/
-public final class Sequence extends AbstractList
+public final class Sequence
+ extends AbstractList
{
-
- // Field.
- // ------------------------------------------------------------------------
-
private final Integer[] sequence;
- // Constructor.
- // ------------------------------------------------------------------------
-
/**
- * Create a sequence of integers from 0 to <i>end</i>, with an increment
- * of 1. If <i>end</i> is less than 0, then the sequence will wrap around
- * through all positive integers then negative integers until the end
- * value is reached. Naturally, this will result in an enormous object,
- * so don't do this.
- *
+ * Create a sequence of integers from 0 to <i>end</i>, with an increment of
+ * 1. If <i>end</i> is less than 0, then the sequence will wrap around
+ * through all positive integers then negative integers until the end value is
+ * reached. Naturally, this will result in an enormous object, so don't do
+ * this.
+ *
* @param end The ending value.
*/
public Sequence(int end)
@@ -71,10 +65,10 @@ public final class Sequence extends AbstractList
/**
* Create a sequence of integers from <i>start</i> to <i>end</i>, with an
- * increment of 1. If <i>end</i> is less than <i>start</i>, then the sequence
- * will wrap around until the end value is reached. Naturally, this will
- * result in an enormous object, so don't do this.
- *
+ * increment of 1. If <i>end</i> is less than <i>start</i>, then the
+ * sequence will wrap around until the end value is reached. Naturally, this
+ * will result in an enormous object, so don't do this.
+ *
* @param start The starting value.
* @param end The ending value.
*/
@@ -88,13 +82,13 @@ public final class Sequence extends AbstractList
* increment of <i>span</i>. If <i>end</i> is less than <i>start</i>, then
* the sequence will wrap around until the end value is reached. Naturally,
* this will result in an enormous object, so don't do this.
- *
- * <p><i>span</i> can be negative, resulting in a decresing sequence.
- *
- * <p>If <i>span</i> is 0, then the sequence will contain {<i>start</i>,
+ * <p>
+ * <i>span</i> can be negative, resulting in a decresing sequence.
+ * <p>
+ * If <i>span</i> is 0, then the sequence will contain {<i>start</i>,
* <i>end</i>} if <i>start</i> != <i>end</i>, or just the singleton
* <i>start</i> if <i>start</i> == <i>end</i>.
- *
+ *
* @param start The starting value.
* @param end The ending value.
* @param span The increment value.
@@ -104,36 +98,26 @@ public final class Sequence extends AbstractList
if (span == 0)
{
if (start != end)
- {
- sequence = new Integer[] { new Integer(start), new Integer(end) };
- }
+ sequence = new Integer[] { Integer.valueOf(start),
+ Integer.valueOf(end) };
else
- {
- sequence = new Integer[] { new Integer(start) };
- }
+ sequence = new Integer[] { Integer.valueOf(start) };
}
else
{
LinkedList l = new LinkedList();
for (int i = start; i != end; i += span)
- {
- l.add(new Integer(i));
- }
- l.add(new Integer(end));
+ l.add(Integer.valueOf(i));
+
+ l.add(Integer.valueOf(end));
sequence = (Integer[]) l.toArray(new Integer[l.size()]);
}
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public Object get(int index)
{
if (index < 0 || index >= size())
- {
- throw new IndexOutOfBoundsException("index=" + index + ", size="
- + size());
- }
+ throw new IndexOutOfBoundsException("index=" + index + ", size=" + size());
return sequence[index];
}
diff --git a/libjava/classpath/gnu/java/security/util/SimpleList.java b/libjava/classpath/gnu/java/security/util/SimpleList.java
index b2525c4b8e2..74f3bafcead 100644
--- a/libjava/classpath/gnu/java/security/util/SimpleList.java
+++ b/libjava/classpath/gnu/java/security/util/SimpleList.java
@@ -43,25 +43,19 @@ import java.util.Collection;
import java.util.Iterator;
/**
- * A simple way to create immutable n-tuples. This class can be created with
- * up to four elements specified via one of the constructors, or with a
- * collection of arbitrary size.
+ * A simple way to create immutable n-tuples. This class can be created with up
+ * to four elements specified via one of the constructors, or with a collection
+ * of arbitrary size.
*/
-public final class SimpleList extends AbstractList
+public final class SimpleList
+ extends AbstractList
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
private final Object[] elements;
- // Constructors.
- // ------------------------------------------------------------------------
-
/**
* Create a singleton list.
- *
- * @param e1 The first element.
+ *
+ * @param element The first element.
*/
public SimpleList(final Object element)
{
@@ -71,7 +65,7 @@ public final class SimpleList extends AbstractList
/**
* Create an ordered pair (2-tuple).
- *
+ *
* @param e1 The first element.
* @param e2 The second element.
*/
@@ -84,7 +78,7 @@ public final class SimpleList extends AbstractList
/**
* Create a 3-tuple.
- *
+ *
* @param e1 The first element.
* @param e2 The second element.
* @param e3 The third element.
@@ -99,7 +93,7 @@ public final class SimpleList extends AbstractList
/**
* Create a 4-tuple.
- *
+ *
* @param e1 The first element.
* @param e2 The second element.
* @param e3 The third element.
@@ -124,10 +118,10 @@ public final class SimpleList extends AbstractList
}
/**
- * Create an n-tuple of arbitrary size. Even if the supplied collection has
- * no natural order, the created n-tuple will have the order that the
- * elements are returned by the collection's iterator.
- *
+ * Create an n-tuple of arbitrary size. Even if the supplied collection has no
+ * natural order, the created n-tuple will have the order that the elements
+ * are returned by the collection's iterator.
+ *
* @param c The collection.
*/
public SimpleList(Collection c)
@@ -135,14 +129,9 @@ public final class SimpleList extends AbstractList
elements = new Object[c.size()];
int i = 0;
for (Iterator it = c.iterator(); it.hasNext() && i < elements.length;)
- {
- elements[i++] = it.next();
- }
+ elements[i++] = it.next();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public int size()
{
if (elements == null)
@@ -153,14 +142,9 @@ public final class SimpleList extends AbstractList
public Object get(int index)
{
if (elements == null)
- {
- throw new IndexOutOfBoundsException("list is empty");
- }
+ throw new IndexOutOfBoundsException("list is empty");
if (index < 0 || index >= elements.length)
- {
- throw new IndexOutOfBoundsException("index=" + index + ", size="
- + size());
- }
+ throw new IndexOutOfBoundsException("index=" + index + ", size=" + size());
return elements[index];
}
diff --git a/libjava/classpath/gnu/java/security/util/Util.java b/libjava/classpath/gnu/java/security/util/Util.java
index f39afb93159..c7a6810fba3 100644
--- a/libjava/classpath/gnu/java/security/util/Util.java
+++ b/libjava/classpath/gnu/java/security/util/Util.java
@@ -41,47 +41,37 @@ package gnu.java.security.util;
import java.math.BigInteger;
/**
- * <p>A collection of utility methods used throughout this project.</p>
+ * A collection of utility methods used throughout this project.
*/
public class Util
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
// Hex charset
private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
// Base-64 charset
- private static final String BASE64_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
+ private static final String BASE64_CHARS =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
private static final char[] BASE64_CHARSET = BASE64_CHARS.toCharArray();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private Util()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a string of hexadecimal digits from a byte array. Each byte is
- * converted to 2 hex symbols; zero(es) included.</p>
- *
- * <p>This method calls the method with same name and three arguments as:</p>
- *
+ * Returns a string of hexadecimal digits from a byte array. Each byte is
+ * converted to 2 hex symbols; zero(es) included.
+ * <p>
+ * This method calls the method with same name and three arguments as:
* <pre>
- * toString(ba, 0, ba.length);
+ * toString(ba, 0, ba.length);
* </pre>
- *
+ *
* @param ba the byte array to convert.
- * @return a string of hexadecimal characters (two for each byte)
- * representing the designated input byte array.
+ * @return a string of hexadecimal characters (two for each byte) representing
+ * the designated input byte array.
*/
public static String toString(byte[] ba)
{
@@ -89,17 +79,17 @@ public class Util
}
/**
- * <p>Returns a string of hexadecimal digits from a byte array, starting at
- * <code>offset</code> and consisting of <code>length</code> bytes. Each byte
- * is converted to 2 hex symbols; zero(es) included.</p>
- *
+ * Returns a string of hexadecimal digits from a byte array, starting at
+ * <code>offset</code> and consisting of <code>length</code> bytes. Each
+ * byte is converted to 2 hex symbols; zero(es) included.
+ *
* @param ba the byte array to convert.
* @param offset the index from which to start considering the bytes to
- * convert.
+ * convert.
* @param length the count of bytes, starting from the designated offset to
- * convert.
- * @return a string of hexadecimal characters (two for each byte)
- * representing the designated input byte sub-array.
+ * convert.
+ * @return a string of hexadecimal characters (two for each byte) representing
+ * the designated input byte sub-array.
*/
public static final String toString(byte[] ba, int offset, int length)
{
@@ -108,26 +98,24 @@ public class Util
{
k = ba[offset + i++];
buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[k & 0x0F];
+ buf[j++] = HEX_DIGITS[ k & 0x0F];
}
return new String(buf);
}
/**
- * <p>Returns a string of hexadecimal digits from a byte array. Each byte is
- * converted to 2 hex symbols; zero(es) included. The argument is
- * treated as a large little-endian integer and is returned as a
- * large big-endian integer.</p>
- *
- * <p>This method calls the method with same name and three arguments as:</p>
- *
+ * Returns a string of hexadecimal digits from a byte array. Each byte is
+ * converted to 2 hex symbols; zero(es) included. The argument is treated as a
+ * large little-endian integer and is returned as a large big-endian integer.
+ * <p>
+ * This method calls the method with same name and three arguments as:
* <pre>
- * toReversedString(ba, 0, ba.length);
+ * toReversedString(ba, 0, ba.length);
* </pre>
- *
+ *
* @param ba the byte array to convert.
- * @return a string of hexadecimal characters (two for each byte)
- * representing the designated input byte array.
+ * @return a string of hexadecimal characters (two for each byte) representing
+ * the designated input byte array.
*/
public static String toReversedString(byte[] ba)
{
@@ -135,20 +123,20 @@ public class Util
}
/**
- * <p>Returns a string of hexadecimal digits from a byte array, starting at
- * <code>offset</code> and consisting of <code>length</code> bytes. Each byte
- * is converted to 2 hex symbols; zero(es) included.</p>
- *
- * <p>The byte array is treated as a large little-endian integer, and
- * is returned as a large big-endian integer.</p>
- *
+ * Returns a string of hexadecimal digits from a byte array, starting at
+ * <code>offset</code> and consisting of <code>length</code> bytes. Each
+ * byte is converted to 2 hex symbols; zero(es) included.
+ * <p>
+ * The byte array is treated as a large little-endian integer, and is returned
+ * as a large big-endian integer.
+ *
* @param ba the byte array to convert.
* @param offset the index from which to start considering the bytes to
- * convert.
+ * convert.
* @param length the count of bytes, starting from the designated offset to
- * convert.
- * @return a string of hexadecimal characters (two for each byte)
- * representing the designated input byte sub-array.
+ * convert.
+ * @return a string of hexadecimal characters (two for each byte) representing
+ * the designated input byte sub-array.
*/
public static final String toReversedString(byte[] ba, int offset, int length)
{
@@ -157,14 +145,16 @@ public class Util
{
k = ba[offset + i--];
buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[k & 0x0F];
+ buf[j++] = HEX_DIGITS[ k & 0x0F];
}
return new String(buf);
}
/**
- * <p>Returns a byte array from a string of hexadecimal digits.</p>
- *
+ * <p>
+ * Returns a byte array from a string of hexadecimal digits.
+ * </p>
+ *
* @param s a string of hexadecimal ASCII characters
* @return the decoded byte array from the input hexadecimal string.
*/
@@ -174,22 +164,20 @@ public class Util
byte[] result = new byte[((limit + 1) / 2)];
int i = 0, j = 0;
if ((limit % 2) == 1)
- {
- result[j++] = (byte) fromDigit(s.charAt(i++));
- }
+ result[j++] = (byte) fromDigit(s.charAt(i++));
while (i < limit)
{
- result[j] = (byte) (fromDigit(s.charAt(i++)) << 4);
+ result[j ] = (byte) (fromDigit(s.charAt(i++)) << 4);
result[j++] |= (byte) fromDigit(s.charAt(i++));
}
return result;
}
/**
- * <p>Returns a byte array from a string of hexadecimal digits, interpreting
- * them as a large big-endian integer and returning it as a large
- * little-endian integer.</p>
- *
+ * Returns a byte array from a string of hexadecimal digits, interpreting them
+ * as a large big-endian integer and returning it as a large little-endian
+ * integer.
+ *
* @param s a string of hexadecimal ASCII characters
* @return the decoded byte array from the input hexadecimal string.
*/
@@ -199,45 +187,37 @@ public class Util
byte[] result = new byte[((limit + 1) / 2)];
int i = 0;
if ((limit % 2) == 1)
- {
- result[i++] = (byte) fromDigit(s.charAt(--limit));
- }
+ result[i++] = (byte) fromDigit(s.charAt(--limit));
while (limit > 0)
{
- result[i] = (byte) fromDigit(s.charAt(--limit));
+ result[i ] = (byte) fromDigit(s.charAt(--limit));
result[i++] |= (byte) (fromDigit(s.charAt(--limit)) << 4);
}
return result;
}
/**
- * <p>Returns a number from <code>0</code> to <code>15</code> corresponding
- * to the designated hexadecimal digit.</p>
- *
+ * Returns a number from <code>0</code> to <code>15</code> corresponding
+ * to the designated hexadecimal digit.
+ *
* @param c a hexadecimal ASCII symbol.
*/
public static int fromDigit(char c)
{
if (c >= '0' && c <= '9')
- {
- return c - '0';
- }
+ return c - '0';
else if (c >= 'A' && c <= 'F')
- {
- return c - 'A' + 10;
- }
+ return c - 'A' + 10;
else if (c >= 'a' && c <= 'f')
- {
- return c - 'a' + 10;
- }
+ return c - 'a' + 10;
else
throw new IllegalArgumentException("Invalid hexadecimal digit: " + c);
}
/**
- * <p>Returns a string of 8 hexadecimal digits (most significant digit first)
- * corresponding to the unsigned integer <code>n</code>.</p>
- *
+ * Returns a string of 8 hexadecimal digits (most significant digit first)
+ * corresponding to the unsigned integer <code>n</code>.
+ *
* @param n the unsigned integer to convert.
* @return a hexadecimal string 8-character long.
*/
@@ -253,8 +233,8 @@ public class Util
}
/**
- * <p>Returns a string of hexadecimal digits from an integer array. Each int
- * is converted to 4 hex symbols.</p>
+ * Returns a string of hexadecimal digits from an integer array. Each int is
+ * converted to 4 hex symbols.
*/
public static String toString(int[] ia)
{
@@ -268,17 +248,17 @@ public class Util
buf[j++] = HEX_DIGITS[(k >>> 20) & 0x0F];
buf[j++] = HEX_DIGITS[(k >>> 16) & 0x0F];
buf[j++] = HEX_DIGITS[(k >>> 12) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 8) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[k & 0x0F];
+ buf[j++] = HEX_DIGITS[(k >>> 8) & 0x0F];
+ buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
+ buf[j++] = HEX_DIGITS[ k & 0x0F];
}
return new String(buf);
}
/**
- * <p>Returns a string of 16 hexadecimal digits (most significant digit first)
- * corresponding to the unsigned long <code>n</code>.</p>
- *
+ * Returns a string of 16 hexadecimal digits (most significant digit first)
+ * corresponding to the unsigned long <code>n</code>.
+ *
* @param n the unsigned long to convert.
* @return a hexadecimal string 16-character long.
*/
@@ -287,18 +267,18 @@ public class Util
char[] b = new char[16];
for (int i = 15; i >= 0; i--)
{
- b[i] = HEX_DIGITS[(int) (n & 0x0FL)];
+ b[i] = HEX_DIGITS[(int)(n & 0x0FL)];
n >>>= 4;
}
return new String(b);
}
/**
- * <p>Similar to the <code>toString()</code> method except that the Unicode
+ * Similar to the <code>toString()</code> method except that the Unicode
* escape character is inserted before every pair of bytes. Useful to
* externalise byte arrays that will be constructed later from such strings;
- * eg. s-box values.</p>
- *
+ * eg. s-box values.
+ *
* @throws ArrayIndexOutOfBoundsException if the length is odd.
*/
public static String toUnicodeString(byte[] ba)
@@ -307,11 +287,11 @@ public class Util
}
/**
- * <p>Similar to the <code>toString()</code> method except that the Unicode
+ * Similar to the <code>toString()</code> method except that the Unicode
* escape character is inserted before every pair of bytes. Useful to
* externalise byte arrays that will be constructed later from such strings;
- * eg. s-box values.</p>
- *
+ * eg. s-box values.
+ *
* @throws ArrayIndexOutOfBoundsException if the length is odd.
*/
public static final String toUnicodeString(byte[] ba, int offset, int length)
@@ -324,31 +304,27 @@ public class Util
while (i < length)
{
sb.append("\\u");
-
k = ba[offset + i++];
sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[k & 0x0F]);
-
+ sb.append(HEX_DIGITS[ k & 0x0F]);
k = ba[offset + i++];
sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[k & 0x0F]);
-
+ sb.append(HEX_DIGITS[ k & 0x0F]);
if ((++j % 8) == 0)
- {
- sb.append("\"+").append('\n').append("\"");
- }
+ sb.append("\"+").append('\n').append("\"");
}
sb.append("\"").append('\n');
return sb.toString();
}
/**
- * <p>Similar to the <code>toString()</code> method except that the Unicode
+ * Similar to the <code>toString()</code> method except that the Unicode
* escape character is inserted before every pair of bytes. Useful to
* externalise integer arrays that will be constructed later from such
- * strings; eg. s-box values.</p>
- *
- * @throws ArrayIndexOutOfBoundsException if the length is not a multiple of 4.
+ * strings; eg. s-box values.
+ *
+ * @throws ArrayIndexOutOfBoundsException if the length is not a multiple of
+ * 4.
*/
public static String toUnicodeString(int[] ia)
{
@@ -367,14 +343,11 @@ public class Util
sb.append(HEX_DIGITS[(k >>> 16) & 0x0F]);
sb.append("\\u");
sb.append(HEX_DIGITS[(k >>> 12) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 8) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[k & 0x0F]);
-
+ sb.append(HEX_DIGITS[(k >>> 8) & 0x0F]);
+ sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
+ sb.append(HEX_DIGITS[ k & 0x0F]);
if ((++j % 4) == 0)
- {
- sb.append("\"+").append('\n').append("\"");
- }
+ sb.append("\"+").append('\n').append("\"");
}
sb.append("\"").append('\n');
return sb.toString();
@@ -388,20 +361,20 @@ public class Util
for (int i = 0; i < limit; i++)
{
c = s.charAt(i >>> 1);
- result[i] = (byte) (((i & 1) == 0) ? c >>> 8 : c);
+ result[i] = (byte)(((i & 1) == 0) ? c >>> 8 : c);
}
return result;
}
/**
- * <p>Dumps a byte array as a string, in a format that is easy to read for
+ * Dumps a byte array as a string, in a format that is easy to read for
* debugging. The string <code>m</code> is prepended to the start of each
- * line.</p>
- *
- * <p>If <code>offset</code> and <code>length</code> are omitted, the whole
+ * line.
+ * <p>
+ * If <code>offset</code> and <code>length</code> are omitted, the whole
* array is used. If <code>m</code> is omitted, nothing is prepended to each
- * line.</p>
- *
+ * line.
+ *
* @param data the byte array to be dumped.
* @param offset the offset within <i>data</i> to start from.
* @param length the number of bytes to dump.
@@ -411,23 +384,17 @@ public class Util
public static String dumpString(byte[] data, int offset, int length, String m)
{
if (data == null)
- {
- return m + "null\n";
- }
+ return m + "null\n";
StringBuffer sb = new StringBuffer(length * 3);
if (length > 32)
- {
- sb.append(m).append("Hexadecimal dump of ").append(length).append(
- " bytes...\n");
- }
+ sb.append(m).append("Hexadecimal dump of ")
+ .append(length).append(" bytes...\n");
// each line will list 32 bytes in 4 groups of 8 each
int end = offset + length;
String s;
int l = Integer.toString(length).length();
if (l < 4)
- {
- l = 4;
- }
+ l = 4;
for (; offset < end; offset += 32)
{
if (length > 32)
@@ -437,16 +404,10 @@ public class Util
}
int i = 0;
for (; i < 32 && offset + i + 7 < end; i += 8)
- {
- sb.append(toString(data, offset + i, 8)).append(' ');
- }
+ sb.append(toString(data, offset + i, 8)).append(' ');
if (i < 32)
- {
- for (; i < 32 && offset + i < end; i++)
- {
- sb.append(byteToString(data[offset + i]));
- }
- }
+ for (; i < 32 && offset + i < end; i++)
+ sb.append(byteToString(data[offset + i]));
sb.append('\n');
}
return sb.toString();
@@ -468,9 +429,9 @@ public class Util
}
/**
- * <p>Returns a string of 2 hexadecimal digits (most significant digit first)
- * corresponding to the lowest 8 bits of <code>n</code>.</p>
- *
+ * Returns a string of 2 hexadecimal digits (most significant digit first)
+ * corresponding to the lowest 8 bits of <code>n</code>.
+ *
* @param n the byte value to convert.
* @return a string of 2 hex characters representing the input.
*/
@@ -481,15 +442,15 @@ public class Util
}
/**
- * <p>Converts a designated byte array to a Base-64 representation, with the
+ * Converts a designated byte array to a Base-64 representation, with the
* exceptions that (a) leading 0-byte(s) are ignored, and (b) the character
- * '.' (dot) shall be used instead of "+' (plus).</p>
- *
- * <p>Used by SASL password file manipulation primitives.</p>
- *
+ * '.' (dot) shall be used instead of "+' (plus).
+ * <p>
+ * Used by SASL password file manipulation primitives.
+ *
* @param buffer an arbitrary sequence of bytes to represent in Base-64.
* @return unpadded (without the '=' character(s)) Base-64 representation of
- * the input.
+ * the input.
*/
public static final String toBase64(byte[] buffer)
{
@@ -535,9 +496,7 @@ public class Util
notleading = true;
}
if (pos >= len)
- {
- break;
- }
+ break;
else
{
try
@@ -555,44 +514,38 @@ public class Util
while (true);
if (notleading)
- {
- return sb.toString();
- }
+ return sb.toString();
return "0";
}
/**
- * <p>The inverse function of the above.</p>
- *
- * <p>Converts a string representing the encoding of some bytes in Base-64
- * to their original form.</p>
- *
+ * The inverse function of the above.
+ * <p>
+ * Converts a string representing the encoding of some bytes in Base-64 to
+ * their original form.
+ *
* @param str the Base-64 encoded representation of some byte(s).
* @return the bytes represented by the <code>str</code>.
- * @throws NumberFormatException if <code>str</code> is <code>null</code>, or
- * <code>str</code> contains an illegal Base-64 character.
+ * @throws NumberFormatException if <code>str</code> is <code>null</code>,
+ * or <code>str</code> contains an illegal Base-64 character.
* @see #toBase64(byte[])
*/
public static final byte[] fromBase64(String str)
{
int len = str.length();
if (len == 0)
- {
- throw new NumberFormatException("Empty string");
- }
+ throw new NumberFormatException("Empty string");
byte[] a = new byte[len + 1];
int i, j;
for (i = 0; i < len; i++)
- {
- try
- {
- a[i] = (byte) BASE64_CHARS.indexOf(str.charAt(i));
- }
- catch (ArrayIndexOutOfBoundsException x)
- {
- throw new NumberFormatException("Illegal character at #" + i);
- }
- }
+ try
+ {
+ a[i] = (byte) BASE64_CHARS.indexOf(str.charAt(i));
+ }
+ catch (ArrayIndexOutOfBoundsException x)
+ {
+ throw new NumberFormatException("Illegal character at #" + i);
+ }
i = len - 1;
j = len;
try
@@ -601,42 +554,31 @@ public class Util
{
a[j] = a[i];
if (--i < 0)
- {
- break;
- }
+ break;
a[j] |= (a[i] & 0x03) << 6;
j--;
- a[j] = (byte) ((a[i] & 0x3C) >>> 2);
+ a[j] = (byte)((a[i] & 0x3C) >>> 2);
if (--i < 0)
- {
- break;
- }
+ break;
a[j] |= (a[i] & 0x0F) << 4;
j--;
- a[j] = (byte) ((a[i] & 0x30) >>> 4);
+ a[j] = (byte)((a[i] & 0x30) >>> 4);
if (--i < 0)
- {
- break;
- }
+ break;
a[j] |= (a[i] << 2);
j--;
a[j] = 0;
if (--i < 0)
- {
- break;
- }
+ break;
}
}
catch (Exception ignored)
{
}
-
try
{ // ignore leading 0-bytes
while (a[j] == 0)
- {
- j++;
- }
+ j++;
}
catch (Exception x)
{
@@ -650,36 +592,31 @@ public class Util
// BigInteger utilities ----------------------------------------------------
/**
- * <p>Treats the input as the MSB representation of a number, and discards
+ * Treats the input as the MSB representation of a number, and discards
* leading zero elements. For efficiency, the input is simply returned if no
- * leading zeroes are found.</p>
- *
+ * leading zeroes are found.
+ *
* @param n the {@link BigInteger} to trim.
* @return the byte array representation of the designated {@link BigInteger}
- * with no leading 0-bytes.
+ * with no leading 0-bytes.
*/
public static final byte[] trim(BigInteger n)
{
byte[] in = n.toByteArray();
if (in.length == 0 || in[0] != 0)
- {
- return in;
- }
+ return in;
int len = in.length;
int i = 1;
while (in[i] == 0 && i < len)
- {
- ++i;
- }
+ ++i;
byte[] result = new byte[len - i];
System.arraycopy(in, i, result, 0, len - i);
return result;
}
/**
- * <p>Returns a hexadecimal dump of the trimmed bytes of a {@link BigInteger}.
- * </p>
- *
+ * Returns a hexadecimal dump of the trimmed bytes of a {@link BigInteger}.
+ *
* @param x the {@link BigInteger} to display.
* @return the string representation of the designated {@link BigInteger}.
*/
diff --git a/libjava/classpath/gnu/java/security/x509/Util.java b/libjava/classpath/gnu/java/security/x509/Util.java
index d27392026f8..1bd268a51e2 100644
--- a/libjava/classpath/gnu/java/security/x509/Util.java
+++ b/libjava/classpath/gnu/java/security/x509/Util.java
@@ -1,5 +1,5 @@
/* Util.java -- Miscellaneous utility methods.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -155,7 +155,7 @@ public final class Util
}
/**
- * See {@link #hexDump(byte[],int,int)}.
+ * See {@link #hexDump(byte[],int,int,String)}.
*/
public static String hexDump(byte[] buf, String prefix)
{
diff --git a/libjava/classpath/gnu/java/security/x509/X509CRL.java b/libjava/classpath/gnu/java/security/x509/X509CRL.java
index 5b2d3b14130..7c471c97284 100644
--- a/libjava/classpath/gnu/java/security/x509/X509CRL.java
+++ b/libjava/classpath/gnu/java/security/x509/X509CRL.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.BitString;
import gnu.java.security.der.DER;
@@ -64,6 +65,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Logger;
import javax.security.auth.x500.X500Principal;
@@ -75,20 +77,7 @@ import javax.security.auth.x500.X500Principal;
public class X509CRL extends java.security.cert.X509CRL
implements GnuPKIExtension
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- if (DEBUG)
- {
- System.err.print(">> X509CRL: ");
- System.err.println(msg);
- }
- }
-
+ private static final Logger log = Logger.getLogger(X509CRL.class.getName());
private static final OID ID_DSA = new OID("1.2.840.10040.4.1");
private static final OID ID_DSA_WITH_SHA1 = new OID("1.2.840.10040.4.3");
private static final OID ID_RSA = new OID("1.2.840.113549.1.1.1");
@@ -350,7 +339,8 @@ public class X509CRL extends java.security.cert.X509CRL
// CertificateList ::= SEQUENCE {
DERReader der = new DERReader(in);
DERValue val = der.read();
- debug("start CertificateList len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start CertificateList len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed CertificateList");
encoded = val.getEncoded();
@@ -359,7 +349,8 @@ public class X509CRL extends java.security.cert.X509CRL
val = der.read();
if (!val.isConstructed())
throw new IOException("malformed TBSCertList");
- debug("start tbsCertList len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start tbsCertList len == " + val.getLength());
tbsCRLBytes = val.getEncoded();
// version Version OPTIONAL,
@@ -372,19 +363,23 @@ public class X509CRL extends java.security.cert.X509CRL
}
else
version = 1;
- debug("read version == " + version);
+ if (Configuration.DEBUG)
+ log.fine("read version == " + version);
// signature AlgorithmIdentifier,
- debug("start AlgorithmIdentifier len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start AlgorithmIdentifier len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed AlgorithmIdentifier");
DERValue algIdVal = der.read();
algId = (OID) algIdVal.getValue();
- debug("read object identifier == " + algId);
+ if (Configuration.DEBUG)
+ log.fine("read object identifier == " + algId);
if (val.getLength() > algIdVal.getEncodedLength())
{
val = der.read();
- debug("read parameters len == " + val.getEncodedLength());
+ if (Configuration.DEBUG)
+ log.fine("read parameters len == " + val.getEncodedLength());
algParams = val.getEncoded();
if (val.isConstructed())
in.skip(val.getLength());
@@ -394,18 +389,21 @@ public class X509CRL extends java.security.cert.X509CRL
val = der.read();
issuerDN = new X500DistinguishedName(val.getEncoded());
der.skip(val.getLength());
- debug("read issuer == " + issuerDN);
+ if (Configuration.DEBUG)
+ log.fine("read issuer == " + issuerDN);
// thisUpdate Time,
thisUpdate = (Date) der.read().getValue();
- debug("read thisUpdate == " + thisUpdate);
+ if (Configuration.DEBUG)
+ log.fine("read thisUpdate == " + thisUpdate);
// nextUpdate Time OPTIONAL,
val = der.read();
if (val.getValue() instanceof Date)
{
nextUpdate = (Date) val.getValue();
- debug("read nextUpdate == " + nextUpdate);
+ if (Configuration.DEBUG)
+ log.fine("read nextUpdate == " + nextUpdate);
val = der.read();
}
@@ -433,7 +431,8 @@ public class X509CRL extends java.security.cert.X509CRL
DERValue exts = der.read();
if (!exts.isConstructed())
throw new IOException("malformed Extensions");
- debug("start Extensions len == " + exts.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extensions len == " + exts.getLength());
int len = 0;
while (len < exts.getLength())
{
@@ -444,32 +443,42 @@ public class X509CRL extends java.security.cert.X509CRL
extensions.put(e.getOid(), e);
der.skip(ext.getLength());
len += ext.getEncodedLength();
- debug("current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("current count == " + len);
}
val = der.read();
}
- debug("read tag == " + val.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag == " + val.getTag());
if (!val.isConstructed())
throw new IOException("malformed AlgorithmIdentifier");
- debug("start AlgorithmIdentifier len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start AlgorithmIdentifier len == " + val.getLength());
DERValue sigAlgVal = der.read();
- debug("read tag == " + sigAlgVal.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag == " + sigAlgVal.getTag());
if (sigAlgVal.getTag() != DER.OBJECT_IDENTIFIER)
throw new IOException("malformed AlgorithmIdentifier");
sigAlg = (OID) sigAlgVal.getValue();
- debug("signature id == " + sigAlg);
- debug("sigAlgVal length == " + sigAlgVal.getEncodedLength());
+ if (Configuration.DEBUG)
+ {
+ log.fine("signature id == " + sigAlg);
+ log.fine("sigAlgVal length == " + sigAlgVal.getEncodedLength());
+ }
if (val.getLength() > sigAlgVal.getEncodedLength())
{
val = der.read();
- debug("sig params tag = " + val.getTag() + " len == " + val.getEncodedLength());
+ if (Configuration.DEBUG)
+ log.fine("sig params tag = " + val.getTag() + " len == "
+ + val.getEncodedLength());
sigAlgParams = (byte[]) val.getEncoded();
if (val.isConstructed())
in.skip(val.getLength());
}
val = der.read();
- debug("read tag = " + val.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag = " + val.getTag());
rawSig = val.getEncoded();
signature = ((BitString) val.getValue()).toByteArray();
}
diff --git a/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java b/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
index a3bcfdea823..26b40363c35 100644
--- a/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
+++ b/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.DERReader;
import gnu.java.security.der.DERValue;
@@ -53,6 +54,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Logger;
/**
* A single entry in a X.509 certificate revocation list.
@@ -63,20 +65,7 @@ import java.util.Set;
class X509CRLEntry extends java.security.cert.X509CRLEntry
implements GnuPKIExtension
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- if (DEBUG)
- {
- System.err.print(">> X509CRLEntry: ");
- System.err.println(msg);
- }
- }
-
+ private static final Logger log = Logger.getLogger(X509CRLEntry.class.getName());
/** The DER encoded form of this CRL entry. */
private byte[] encoded;
@@ -230,26 +219,29 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry
{
// RevokedCertificate ::= SEQUENCE {
DERValue entry = der.read();
- debug("start CRL entry len == " + entry.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start CRL entry len == " + entry.getLength());
if (!entry.isConstructed())
throw new IOException("malformed revokedCertificate");
encoded = entry.getEncoded();
int len = 0;
-
- debug("encoded entry:\n" + Util.hexDump(encoded, ">>>> "));
+ if (Configuration.DEBUG)
+ log.fine("encoded entry:\n" + Util.hexDump(encoded, ">>>> "));
// userCertificate CertificateSerialNumber,
DERValue val = der.read();
serialNo = (BigInteger) val.getValue();
len += val.getEncodedLength();
- debug("userCertificate == " + serialNo + " current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("userCertificate == " + serialNo + " current count == " + len);
// revocationDate Time,
val = der.read();
revocationDate = (Date) val.getValue();
len += val.getEncodedLength();
- debug("revocationDate == " + revocationDate + " current count == " + len);
-
+ if (Configuration.DEBUG)
+ log.fine("revocationDate == " + revocationDate + " current count == "
+ + len);
// crlEntryExtensions Extensions OPTIONAL
// -- if present MUST be v2
if (len < entry.getLength())
@@ -259,19 +251,22 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry
DERValue exts = der.read();
if (!exts.isConstructed())
throw new IOException("malformed Extensions");
- debug("start Extensions len == " + exts.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extensions len == " + exts.getLength());
len = 0;
while (len < exts.getLength())
{
val = der.read();
if (!val.isConstructed())
throw new IOException("malformed Extension");
- debug("start Extension len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extension len == " + val.getLength());
Extension e = new Extension(val.getEncoded());
extensions.put(e.getOid(), e);
der.skip(val.getLength());
len += val.getEncodedLength();
- debug("current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("current count == " + len);
}
}
}
diff --git a/libjava/classpath/gnu/java/security/x509/X509Certificate.java b/libjava/classpath/gnu/java/security/x509/X509Certificate.java
index cf0161701cc..b3f8a696a85 100644
--- a/libjava/classpath/gnu/java/security/x509/X509Certificate.java
+++ b/libjava/classpath/gnu/java/security/x509/X509Certificate.java
@@ -552,7 +552,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
// Certificate ::= SEQUENCE {
DERValue cert = der.read();
logger.log (Component.X509, "start Certificate len == {0}",
- new Integer (cert.getLength()));
+ Integer.valueOf(cert.getLength()));
this.encoded = cert.getEncoded();
if (!cert.isConstructed())
@@ -568,7 +568,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
tbsCertBytes = tbsCert.getEncoded();
logger.log (Component.X509, "start TBSCertificate len == {0}",
- new Integer (tbsCert.getLength()));
+ Integer.valueOf(tbsCert.getLength()));
// Version ::= INTEGER [0] { v1(0), v2(1), v3(2) }
DERValue val = der.read();
@@ -582,7 +582,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
version = 1;
}
logger.log (Component.X509, "read version == {0}",
- new Integer (version));
+ Integer.valueOf(version));
// SerialNumber ::= INTEGER
serialNo = (BigInteger) val.getValue();
@@ -596,7 +596,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
int certAlgLen = val.getLength();
logger.log (Component.X509, "start AlgorithmIdentifier len == {0}",
- new Integer (certAlgLen));
+ Integer.valueOf(certAlgLen));
val = der.read();
// algorithm OBJECT IDENTIFIER,
@@ -677,20 +677,20 @@ public class X509Certificate extends java.security.cert.X509Certificate
{
val = der.read();
logger.log (Component.X509, "start Extensions len == {0}",
- new Integer (val.getLength()));
+ Integer.valueOf(val.getLength()));
int len = 0;
while (len < val.getLength())
{
DERValue ext = der.read();
logger.log (Component.X509, "start extension len == {0}",
- new Integer (ext.getLength()));
+ Integer.valueOf(ext.getLength()));
Extension e = new Extension(ext.getEncoded());
extensions.put(e.getOid(), e);
der.skip(ext.getLength());
len += ext.getEncodedLength();
logger.log (Component.X509, "read extension {0} == {1}",
new Object[] { e.getOid (), e });
- logger.log (Component.X509, "count == {0}", new Integer (len));
+ logger.log (Component.X509, "count == {0}", Integer.valueOf(len));
}
val = der.read ();
@@ -703,7 +703,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
int sigAlgLen = val.getLength();
logger.log (Component.X509, "start AlgorithmIdentifier len == {0}",
- new Integer (sigAlgLen));
+ Integer.valueOf(sigAlgLen));
val = der.read();
sigAlgId = (OID) val.getValue();
logger.log (Component.X509, "read algorithm id == {0}", sigAlgId);
diff --git a/libjava/classpath/gnu/java/security/x509/ext/Extension.java b/libjava/classpath/gnu/java/security/x509/ext/Extension.java
index 97097a2f380..69251987ec9 100644
--- a/libjava/classpath/gnu/java/security/x509/ext/Extension.java
+++ b/libjava/classpath/gnu/java/security/x509/ext/Extension.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509.ext;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
@@ -48,20 +49,11 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class Extension
{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- System.err.print(">> Extension: ");
- System.err.println(msg);
- }
-
+ private static final Logger log = Logger.getLogger(Extension.class.getName());
/**
* This extension's object identifier.
*/
@@ -97,7 +89,8 @@ public class Extension
// Extension ::= SEQUENCE {
DERValue val = der.read();
- if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("read val tag == " + val.getTag() + " len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed Extension");
@@ -106,7 +99,8 @@ public class Extension
if (val.getTag() != DER.OBJECT_IDENTIFIER)
throw new IOException("expecting OBJECT IDENTIFIER");
oid = (OID) val.getValue();
- if (DEBUG) debug("read oid == " + oid);
+ if (Configuration.DEBUG)
+ log.fine("read oid == " + oid);
// critical BOOLEAN DEFAULT FALSE,
val = der.read();
@@ -117,7 +111,8 @@ public class Extension
}
else
critical = false;
- if (DEBUG) debug("is critical == " + critical);
+ if (Configuration.DEBUG)
+ log.fine("is critical == " + critical);
// extnValue OCTET STRING }
if (val.getTag() != DER.OCTET_STRING)
@@ -181,7 +176,8 @@ public class Extension
value = new Value(encval);
isSupported = false;
}
- if (DEBUG) debug("read value == " + value);
+ if (Configuration.DEBUG)
+ log.fine("read value == " + value);
}
public Extension (final OID oid, final Value value, final boolean critical)
diff --git a/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java b/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
index dae94cd9f35..b342cbd5f2e 100644
--- a/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
+++ b/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
@@ -1,5 +1,5 @@
/* GeneralNames.java -- the GeneralNames object
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import gnu.java.security.OID;
import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
import gnu.java.security.der.DERValue;
-import gnu.java.security.x509.X500DistinguishedName;
import java.io.IOException;
import java.net.InetAddress;
@@ -91,7 +90,7 @@ public class GeneralNames
int tagClass = name.getTagClass();
if (tagClass != DER.CONTEXT)
throw new IOException("malformed GeneralName: Tag class is " + tagClass);
- namePair.add(new Integer(name.getTag()));
+ namePair.add(Integer.valueOf(name.getTag()));
DERValue val = null;
switch (name.getTag())
{
diff --git a/libjava/classpath/gnu/java/util/prefs/EventDispatcher.java b/libjava/classpath/gnu/java/util/prefs/EventDispatcher.java
index feabe4dce51..ecddd3a55f2 100644
--- a/libjava/classpath/gnu/java/util/prefs/EventDispatcher.java
+++ b/libjava/classpath/gnu/java/util/prefs/EventDispatcher.java
@@ -74,7 +74,7 @@ public class EventDispatcher extends Thread
{
try
{
- wait();
+ queue.wait();
}
catch (InterruptedException _)
{
@@ -107,6 +107,7 @@ public class EventDispatcher extends Thread
synchronized (queue)
{
queue.add(runner);
+ queue.notify();
}
}
}
diff --git a/libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java b/libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java
new file mode 100644
index 00000000000..ae734b60985
--- /dev/null
+++ b/libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java
@@ -0,0 +1,78 @@
+/* GConfBasedFactory.java -- GConf based PreferencesFactory implementation
+ 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.util.prefs;
+
+import java.util.prefs.Preferences;
+import java.util.prefs.PreferencesFactory;
+
+/**
+ * Factory object that generates a Preferences nodes that are read from a GConf
+ * daemon.
+ *
+ * @author Mario Torre <neugens@limasoftware.net>
+ */
+public class GConfBasedFactory implements PreferencesFactory
+{
+ /** System preference root. */
+ private static final Preferences systemPreferences
+ = new GConfBasedPreferences(null, "", false);
+
+ /** User preference root. */
+ private static final Preferences userPreferences
+ = new GConfBasedPreferences(null, "", true);
+
+ /**
+ * Returns the system root preference node.
+ *
+ * @see java.util.prefs.PreferencesFactory#systemRoot()
+ */
+ public Preferences systemRoot()
+ {
+ return systemPreferences;
+ }
+
+ /**
+ * Returns the user root preference node corresponding to the calling user.
+ *
+ * @see java.util.prefs.PreferencesFactory#userRoot()
+ */
+ public Preferences userRoot()
+ {
+ return userPreferences;
+ }
+}
diff --git a/libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java b/libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java
new file mode 100644
index 00000000000..5702751cf5c
--- /dev/null
+++ b/libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java
@@ -0,0 +1,412 @@
+/* GConfBasedPreferences.java -- GConf based Preferences implementation
+ 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.util.prefs;
+
+import gnu.java.util.prefs.gconf.GConfNativePeer;
+
+import java.security.Permission;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.prefs.AbstractPreferences;
+import java.util.prefs.BackingStoreException;
+
+/**
+ * This is a GConf based preference implementation which writes the preferences
+ * as GConf key-value pairs. System Root is defined to be the
+ * <code>"/system"</code> directory of GConf for the current user, while User
+ * Root is <code>"/apps/java"</code>. These defaults can be modified by
+ * defining two system properties:<br />
+ * <br />
+ * User Root:<br />
+ * <br />
+ *
+ * <pre>
+ * gnu.java.util.prefs.gconf.user_root
+ * </pre>
+ *
+ * <br />
+ * <br />
+ * and System Root:<br />
+ * <br />
+ *
+ * <pre>
+ * gnu.java.util.prefs.gconf.system_root
+ * </pre>
+ *
+ * <br />
+ *
+ * @author Mario Torre <neugens@limasoftware.net>
+ * @version 1.0.1
+ */
+public class GConfBasedPreferences
+ extends AbstractPreferences
+{
+ /** Get access to Runtime permission */
+ private static final Permission PERMISSION
+ = new RuntimePermission("preferences");
+
+ /** CGonf client backend */
+ private static GConfNativePeer backend = new GConfNativePeer();
+
+ /** Default user root path */
+ private static final String DEFAULT_USER_ROOT = "/apps/classpath";
+
+ /** Default system root path */
+ private static final String DEFAULT_SYSTEM_ROOT = "/system";
+
+ /** current node full path */
+ private String node = "";
+
+ /** True if this is a preference node in the user tree, false otherwise. */
+ private final boolean isUser;
+
+ /**
+ * Creates a preference root user node.
+ */
+ public GConfBasedPreferences()
+ {
+ this(true);
+ }
+
+ /**
+ * Creates a preference root node. When <code>isUser</code> is true it will
+ * be user node otherwise it will be a system node.
+ */
+ public GConfBasedPreferences(boolean isUser)
+ {
+ this(null, "", isUser);
+ }
+
+ /**
+ * Creates a new preference node given a parent node and a name, which has to
+ * be relative to its parent. When <code>isUser</code> is true it will be user
+ * node otherwise it will be a system node.
+ *
+ * @param parent The parent node of this newly created node.
+ * @param name A name relative to the parent node.
+ * @param isUser Set to <code>true</code> initializes this node to be
+ * a user node, <code>false</code> initialize it to be a system node.
+ */
+ public GConfBasedPreferences(AbstractPreferences parent, String name,
+ boolean isUser)
+ {
+ super(parent, name);
+ this.isUser = isUser;
+
+ // stores the fully qualified name of this node
+ String absolutePath = this.absolutePath();
+ if (absolutePath != null && absolutePath.endsWith("/"))
+ {
+ absolutePath = absolutePath.substring(0, absolutePath.length() - 1);
+ }
+
+ this.node = this.getRealRoot(isUser) + absolutePath;
+
+ boolean nodeExist = backend.nodeExist(this.node);
+
+ this.newNode = !nodeExist;
+ backend.startWatchingNode(this.node);
+ }
+
+ /**
+ * Returns a child node with the given name.
+ * If the child node does not exists, it will be created.
+ *
+ * @param name The name of the requested node.
+ * @return A new reference to the node, creating the node if it is necessary.
+ */
+ protected AbstractPreferences childSpi(String name)
+ {
+ // we don't check anything here, if the node is a new node this will be
+ // detected in the constructor, so we simply return a new reference to
+ // the requested node.
+ return new GConfBasedPreferences(this, name, this.isUser);
+ }
+
+ /**
+ * Returns an array of names of the children of this preference node.
+ * If the current node does not have children, the returned array will be
+ * of <code>size</code> 0 (that is, not <code>null</code>).
+ *
+ * @return A <code>String</code> array of names of children of the current
+ * node.
+ * @throws BackingStoreException if this operation cannot be completed.
+ */
+ protected String[] childrenNamesSpi() throws BackingStoreException
+ {
+ List nodeList = backend.getChildrenNodes(this.node);
+ String[] nodes = new String[nodeList.size()];
+ nodeList.toArray(nodes);
+
+ return nodes;
+ }
+
+ /**
+ * Suggest a flush to the backend. Actually, this is only a suggestion as
+ * GConf handles this for us asynchronously. More over, both sync and flush
+ * have the same meaning in this class, so calling sync has exactly the same
+ * effect.
+ *
+ * @see #sync
+ * @throws BackingStoreException if this operation cannot be completed.
+ */
+ public void flush() throws BackingStoreException
+ {
+ backend.suggestSync();
+ }
+
+ /**
+ * Request a flush.
+ *
+ * @see #flush
+ * @throws BackingStoreException if this operation cannot be completed.
+ */
+ protected void flushSpi() throws BackingStoreException
+ {
+ this.flush();
+ }
+
+ /**
+ * Returns all of the key in this preference node.
+ * If the current node does not have preferences, the returned array will be
+ * of size zero.
+ *
+ * @return A <code>String</code> array of keys stored under the current
+ * node.
+ * @throws BackingStoreException if this operation cannot be completed.
+ */
+ protected String[] keysSpi() throws BackingStoreException
+ {
+ List keyList = backend.getKeys(this.node);
+ String[] keys = new String[keyList.size()];
+ keyList.toArray(keys);
+
+ return keys;
+ }
+
+ /**
+ * Does a recursive postorder traversal of the preference tree, starting from
+ * the given directory invalidating every preference found in the node.
+ *
+ * @param directory The name of the starting directory (node)
+ */
+ private void postorderRemove(String directory)
+ {
+ try
+ {
+ // gets the listing of directories in this node
+ List dirs = backend.getChildrenNodes(directory);
+
+ if (dirs.size() != 0)
+ {
+ String currentDir = null;
+
+ for (Iterator itr = dirs.iterator(); itr.hasNext();)
+ {
+ currentDir = (String) itr.next();
+
+ // recursive search inside this directory
+ postorderRemove(currentDir);
+ }
+ }
+
+ // remove all the keys associated to this directory
+ List entries = backend.getKeys(directory);
+
+ if (entries.size() != 0)
+ {
+ String key = null;
+
+ for (Iterator keys = entries.iterator(); keys.hasNext();)
+ {
+ key = (String) keys.next();
+ this.removeSpi(key);
+ }
+ }
+ }
+ catch (BackingStoreException ex)
+ {
+ /* ignore */
+ }
+ }
+
+ /**
+ * Stores the given key-value pair into this preference node.
+ *
+ * @param key The key of this preference.
+ * @param value The value of this preference.
+ */
+ protected void putSpi(String key, String value)
+ {
+ backend.setString(this.getGConfKey(key), value);
+ }
+
+ /**
+ * Removes this preference node, including all its children.
+ * Also removes the preferences associated.
+ */
+ protected void removeNodeSpi() throws BackingStoreException
+ {
+ this.postorderRemove(this.node);
+ this.flush();
+ }
+
+ /**
+ * Removes the given key from this preference node.
+ * If the key does not exist, no operation is performed.
+ *
+ * @param key The key to remove.
+ */
+ protected void removeSpi(String key)
+ {
+ backend.unset(this.getGConfKey(key));
+ }
+
+ /**
+ * Suggest a sync to the backend. Actually, this is only a suggestion as GConf
+ * handles this for us asynchronously. More over, both sync and flush have the
+ * same meaning in this class, so calling flush has exactly the same effect.
+ *
+ * @see #flush
+ * @throws BackingStoreException if this operation cannot be completed due to
+ * a failure in the backing store, or inability to communicate with
+ * it.
+ */
+ public void sync() throws BackingStoreException
+ {
+ this.flush();
+ }
+
+ /**
+ * Request a sync.
+ *
+ * @see #sync
+ * @throws BackingStoreException if this operation cannot be completed due to
+ * a failure in the backing store, or inability to communicate with
+ * it.
+ */
+ protected void syncSpi() throws BackingStoreException
+ {
+ this.sync();
+ }
+
+ /**
+ * Returns the value of the given key.
+ * If the keys does not have a value, or there is an error in the backing
+ * store, <code>null</code> is returned instead.
+ *
+ * @param key The key to retrieve.
+ * @return The value associated with the given key.
+ */
+ protected String getSpi(String key)
+ {
+ return backend.getKey(this.getGConfKey(key));
+ }
+
+ /**
+ * Returns <code>true</code> if this preference node is a user node,
+ * <code>false</code> if is a system preference node.
+ *
+ * @return <code>true</code> if this preference node is a user node,
+ * <code>false</code> if is a system preference node.
+ */
+ public boolean isUserNode()
+ {
+ return this.isUser;
+ }
+
+ /*
+ * PRIVATE METHODS
+ */
+
+ /**
+ * Builds a GConf key string suitable for operations on the backend.
+ *
+ * @param key The key to convert into a valid GConf key.
+ * @return A valid Gconf key.
+ */
+ private String getGConfKey(String key)
+ {
+ String nodeName = "";
+
+ if (this.node.endsWith("/"))
+ {
+ nodeName = this.node + key;
+ }
+ else
+ {
+ nodeName = this.node + "/" + key;
+ }
+
+ return nodeName;
+ }
+
+ /**
+ * Builds the root node to use for this preference.
+ *
+ * @param isUser Defines if this node is a user (<code>true</code>) or system
+ * (<code>false</code>) node.
+ * @return The real root of this preference tree.
+ */
+ private String getRealRoot(boolean isUser)
+ {
+ // not sure about this, we should have already these permissions...
+ SecurityManager security = System.getSecurityManager();
+
+ if (security != null)
+ {
+ security.checkPermission(PERMISSION);
+ }
+
+ String root = null;
+
+ if (isUser)
+ {
+ root = System.getProperty("gnu.java.util.prefs.gconf.user_root",
+ DEFAULT_USER_ROOT);
+ }
+ else
+ {
+ root = System.getProperty("gnu.java.util.prefs.gconf.system_root",
+ DEFAULT_SYSTEM_ROOT);
+ }
+
+ return root;
+ }
+}
diff --git a/libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java b/libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
new file mode 100644
index 00000000000..f1cb6278767
--- /dev/null
+++ b/libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
@@ -0,0 +1,298 @@
+/* GConfNativePeer.java -- GConf based preference peer for native 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.java.util.prefs.gconf;
+
+import java.util.List;
+import java.util.prefs.BackingStoreException;
+
+/**
+ * Native peer for GConf based preference backend.
+ *
+ * @author Mario Torre <neugens@limasoftware.net>
+ * @version 1.0.1
+ */
+public final class GConfNativePeer
+{
+ /**
+ * Object to achieve locks for methods that need to be synchronized.
+ */
+ private static final Object[] semaphore = new Object[0];
+
+ /**
+ * Creates a new instance of GConfNativePeer
+ */
+ public GConfNativePeer()
+ {
+ synchronized (semaphore)
+ {
+ init_class();
+ }
+ }
+
+ /**
+ * Queries whether the node <code>node</code> exists in theGConf database.
+ * Returns <code>true</code> or <code>false</code>.
+ *
+ * @param node the node to check.
+ */
+ public boolean nodeExist(String node)
+ {
+ return gconf_client_dir_exists(node);
+ }
+
+ /**
+ * Add the node <code>node</code> to the list of nodes the GConf will watch.
+ * An event is raised everytime this node is changed. You can add a node
+ * multiple times.
+ *
+ * @param node the node to track.
+ */
+ public void startWatchingNode(String node)
+ {
+ gconf_client_add_dir(node);
+ }
+
+ /**
+ * Remove the node <code>node</code> to the list of nodes the GConf is
+ * watching. Note that if a node has been added multiple times, you must
+ * remove it the same number of times before the remove takes effect.
+ *
+ * @param node the node you don't want to track anymore.
+ */
+ public void stopWatchingNode(String node)
+ {
+ gconf_client_remove_dir(node);
+ }
+
+ /**
+ * Change the value of key to val. Automatically creates the key if it didn't
+ * exist before (ie it was unset or it only had a default value).
+ * Key names must be valid GConf key names, that is, there can be more
+ * restrictions than for normal Preference Backend.
+ *
+ * @param key the key to alter (or add).
+ * @param value the new value for this key.
+ * @return true if the key was updated, false otherwise.
+ */
+ public boolean setString(String key, String value)
+ {
+ return gconf_client_set_string(key, value);
+ }
+
+ /**
+ * Unsets the value of key; if key is already unset, has no effect. Depending
+ * on the GConf daemon, unsetting a key may have the side effect to remove it
+ * completely form the database.
+ *
+ * @param key the key to unset.
+ * @return true on success, false if the key was not updated.
+ */
+ public boolean unset(String key)
+ {
+ return gconf_client_unset(key);
+ }
+
+ /**
+ * Gets the value of a configuration key.
+ *
+ * @param key the configuration key.
+ * @return the values of this key, null if the key is not valid.
+ */
+ public String getKey(String key)
+ {
+ return gconf_client_get_string(key);
+ }
+
+ /**
+ * Lists the key in the given node. Does not list subnodes. Keys names are the
+ * stripped names (name relative to the current node) of the keys stored in
+ * this node.
+ *
+ * @param node the node where keys are stored.
+ * @return a java.util.List of keys. If there are no keys in the given node, a
+ * list of size 0 is returned.
+ */
+ public List getKeys(String node) throws BackingStoreException
+ {
+ return gconf_client_gconf_client_all_keys(node);
+ }
+
+ /**
+ * Lists the subnodes in <code>node</code>. The returned list contains
+ * allocated strings. Each string is the name relative tho the given node.
+ *
+ * @param node the node to get subnodes from. If there are no subnodes in the
+ * given node, a list of size 0 is returned.
+ */
+ public List getChildrenNodes(String node) throws BackingStoreException
+ {
+ return gconf_client_gconf_client_all_nodes(node);
+ }
+
+ /**
+ * Suggest to the backend GConf daemon to synch with the database.
+ */
+ public void suggestSync() throws BackingStoreException
+ {
+ gconf_client_suggest_sync();
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ synchronized (semaphore)
+ {
+ finalize_class();
+ }
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
+
+ /* ***** native methods ***** */
+
+ /*
+ * Basicly, these are one to one mappings to GConfClient functions.
+ * GConfClient instances are handled by the native layer, and are hidden from
+ * the main java class.
+ */
+
+ /**
+ * Initialize the GConf native peer and enable the object cache.
+ * It is meant to be used by the static initializer.
+ */
+ native static final private void init_id_cache();
+
+ /**
+ * Initialize the GConf native peer. This is meant to be used by the
+ * class constructor.
+ */
+ native static final private void init_class();
+
+ /**
+ * Class finalizer.
+ */
+ native static final private void finalize_class();
+
+ /**
+ * Queries the GConf database to see if the given node exists, returning
+ * true if the node exist, false otherwise.
+ *
+ * @param node the node to query for existence.
+ * @return true if the node exist, false otherwise.
+ */
+ native static final protected boolean gconf_client_dir_exists(String node);
+
+ /**
+ * Adds the given node to the list of nodes that GConf watches for
+ * changes.
+ *
+ * @param node the node to watch for changes.
+ */
+ native static final protected void gconf_client_add_dir(String node);
+
+ /**
+ * Removes the given node from the list of nodes that GConf watches for
+ * changes.
+ *
+ * @param node the node to remove from from the list of watched nodes.
+ */
+ native static final protected void gconf_client_remove_dir(String node);
+
+ /**
+ * Sets the given key/value pair into the GConf database.
+ * The key must be a valid GConf key.
+ *
+ * @param key the key to store in the GConf database
+ * @param value the value to associate to the given key.
+ * @return true if the change has effect, false otherwise.
+ */
+ native static final protected boolean gconf_client_set_string(String key,
+ String value);
+
+ /**
+ * Returns the key associated to the given key. Null is returned if the
+ * key is not valid.
+ *
+ * @param key the key to return the value of.
+ * @return The value associated to the given key, or null.
+ */
+ native static final protected String gconf_client_get_string(String key);
+
+ /**
+ * Usets the given key, removing the key from the database.
+ *
+ * @param key the key to remove.
+ * @return true if the operation success, false otherwise.
+ */
+ native static final protected boolean gconf_client_unset(String key);
+
+ /**
+ * Suggest to the GConf native peer a sync with the database.
+ *
+ */
+ native static final protected void gconf_client_suggest_sync();
+
+ /**
+ * Returns a list of all nodes under the given node.
+ *
+ * @param node the source node.
+ * @return A list of nodes under the given source node.
+ */
+ native
+ static final protected List gconf_client_gconf_client_all_nodes(String node);
+
+ /**
+ * Returns a list of all keys stored in the given node.
+ *
+ * @param node the source node.
+ * @return A list of all keys stored in the given node.
+ */
+ native
+ static final protected List gconf_client_gconf_client_all_keys(String node);
+
+ static
+ {
+ System.loadLibrary("gconfpeer");
+ init_id_cache();
+ }
+}
diff --git a/libjava/classpath/gnu/regexp/BacktrackStack.java b/libjava/classpath/gnu/java/util/regex/BacktrackStack.java
index 0fc73f044ff..d711945e43b 100644
--- a/libjava/classpath/gnu/regexp/BacktrackStack.java
+++ b/libjava/classpath/gnu/java/util/regex/BacktrackStack.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* An instance of this class represents a stack
diff --git a/libjava/classpath/gnu/regexp/CharIndexed.java b/libjava/classpath/gnu/java/util/regex/CharIndexed.java
index 8aedc49f69c..6cd857e3bc0 100644
--- a/libjava/classpath/gnu/regexp/CharIndexed.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexed.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* Defines the interface used internally so that different types of source
diff --git a/libjava/classpath/gnu/regexp/CharIndexedCharArray.java b/libjava/classpath/gnu/java/util/regex/CharIndexedCharArray.java
index 96a609beb62..6f74c992f8f 100644
--- a/libjava/classpath/gnu/regexp/CharIndexedCharArray.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexedCharArray.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.nio.CharBuffer;
class CharIndexedCharArray extends CharIndexedCharSequence {
diff --git a/libjava/classpath/gnu/regexp/CharIndexedCharSequence.java b/libjava/classpath/gnu/java/util/regex/CharIndexedCharSequence.java
index 5bbe4abfe9f..2eb753b0f5c 100644
--- a/libjava/classpath/gnu/regexp/CharIndexedCharSequence.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexedCharSequence.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.Serializable;
class CharIndexedCharSequence implements CharIndexed, Serializable {
diff --git a/libjava/classpath/gnu/regexp/CharIndexedInputStream.java b/libjava/classpath/gnu/java/util/regex/CharIndexedInputStream.java
index 290a94e7f66..77cd1abd5cc 100644
--- a/libjava/classpath/gnu/regexp/CharIndexedInputStream.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexedInputStream.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
diff --git a/libjava/classpath/gnu/regexp/CharIndexedString.java b/libjava/classpath/gnu/java/util/regex/CharIndexedString.java
index 24982659baf..fab6d78360b 100644
--- a/libjava/classpath/gnu/regexp/CharIndexedString.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexedString.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
class CharIndexedString extends CharIndexedCharSequence {
CharIndexedString(String str, int index) {
diff --git a/libjava/classpath/gnu/regexp/CharIndexedStringBuffer.java b/libjava/classpath/gnu/java/util/regex/CharIndexedStringBuffer.java
index d6b03bba566..10005b66831 100644
--- a/libjava/classpath/gnu/regexp/CharIndexedStringBuffer.java
+++ b/libjava/classpath/gnu/java/util/regex/CharIndexedStringBuffer.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
class CharIndexedStringBuffer extends CharIndexedCharSequence {
diff --git a/libjava/classpath/gnu/regexp/RE.java b/libjava/classpath/gnu/java/util/regex/RE.java
index e0665f097c2..1aab3b781a2 100644
--- a/libjava/classpath/gnu/regexp/RE.java
+++ b/libjava/classpath/gnu/java/util/regex/RE.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Locale;
@@ -130,7 +130,7 @@ public class RE extends REToken {
private static final String VERSION = "1.1.5-dev";
// The localized strings are kept in a separate file
- private static ResourceBundle messages = PropertyResourceBundle.getBundle("gnu/regexp/MessagesBundle", Locale.getDefault());
+ private static ResourceBundle messages = PropertyResourceBundle.getBundle("gnu/java/util/regex/MessagesBundle", Locale.getDefault());
// These are, respectively, the first and last tokens in our linked list
// If there is only one token, firstToken == lastToken
@@ -750,7 +750,20 @@ public class RE extends REToken {
else if ((unit.ch == '^') && !(unit.bk || quot)) {
addToken(currentToken);
currentToken = null;
- addToken(new RETokenStart(subIndex,((cflags & REG_MULTILINE) > 0) ? syntax.getLineSeparator() : null));
+ RETokenStart token = null;
+ if ((cflags & REG_MULTILINE) > 0) {
+ String sep = syntax.getLineSeparator();
+ if (sep == null) {
+ token = new RETokenStart(subIndex, null, true);
+ }
+ else {
+ token = new RETokenStart(subIndex, sep);
+ }
+ }
+ else {
+ token = new RETokenStart(subIndex, null);
+ }
+ addToken(token);
}
// END OF LINE OPERATOR
@@ -759,7 +772,20 @@ public class RE extends REToken {
else if ((unit.ch == '$') && !(unit.bk || quot)) {
addToken(currentToken);
currentToken = null;
- addToken(new RETokenEnd(subIndex,((cflags & REG_MULTILINE) > 0) ? syntax.getLineSeparator() : null));
+ RETokenEnd token = null;
+ if ((cflags & REG_MULTILINE) > 0) {
+ String sep = syntax.getLineSeparator();
+ if (sep == null) {
+ token = new RETokenEnd(subIndex, null, true);
+ }
+ else {
+ token = new RETokenEnd(subIndex, sep);
+ }
+ }
+ else {
+ token = new RETokenEnd(subIndex, null);
+ }
+ addToken(token);
}
// MATCH-ANY-CHARACTER OPERATOR (except possibly newline and null)
diff --git a/libjava/classpath/gnu/regexp/REException.java b/libjava/classpath/gnu/java/util/regex/REException.java
index 73f86fa8add..4104fbcd8a7 100644
--- a/libjava/classpath/gnu/regexp/REException.java
+++ b/libjava/classpath/gnu/java/util/regex/REException.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.text.MessageFormat;
diff --git a/libjava/classpath/gnu/regexp/REFilterInputStream.java b/libjava/classpath/gnu/java/util/regex/REFilterInputStream.java
index 485de56605d..abe86308bbc 100644
--- a/libjava/classpath/gnu/regexp/REFilterInputStream.java
+++ b/libjava/classpath/gnu/java/util/regex/REFilterInputStream.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.FilterInputStream;
import java.io.InputStream;
diff --git a/libjava/classpath/gnu/regexp/REMatch.java b/libjava/classpath/gnu/java/util/regex/REMatch.java
index 140a9c43e1d..3ff5ad794b8 100644
--- a/libjava/classpath/gnu/regexp/REMatch.java
+++ b/libjava/classpath/gnu/java/util/regex/REMatch.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.Serializable;
/**
diff --git a/libjava/classpath/gnu/regexp/REMatchEnumeration.java b/libjava/classpath/gnu/java/util/regex/REMatchEnumeration.java
index f164a69af4f..bc700beac5a 100644
--- a/libjava/classpath/gnu/regexp/REMatchEnumeration.java
+++ b/libjava/classpath/gnu/java/util/regex/REMatchEnumeration.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.NoSuchElementException;
diff --git a/libjava/classpath/gnu/regexp/RESyntax.java b/libjava/classpath/gnu/java/util/regex/RESyntax.java
index 81fd999bfcf..b66b32f5878 100644
--- a/libjava/classpath/gnu/regexp/RESyntax.java
+++ b/libjava/classpath/gnu/java/util/regex/RESyntax.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.Serializable;
import java.util.BitSet;
diff --git a/libjava/classpath/gnu/regexp/REToken.java b/libjava/classpath/gnu/java/util/regex/REToken.java
index f2abc029ff4..155c01878e8 100644
--- a/libjava/classpath/gnu/regexp/REToken.java
+++ b/libjava/classpath/gnu/java/util/regex/REToken.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.io.Serializable;
abstract class REToken implements Serializable, Cloneable {
diff --git a/libjava/classpath/gnu/regexp/RETokenAny.java b/libjava/classpath/gnu/java/util/regex/RETokenAny.java
index a37d9561b3f..b99a54717c9 100644
--- a/libjava/classpath/gnu/regexp/RETokenAny.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenAny.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenAny extends REToken {
/** True if '.' can match a newline (RE_DOT_NEWLINE) */
diff --git a/libjava/classpath/gnu/regexp/RETokenBackRef.java b/libjava/classpath/gnu/java/util/regex/RETokenBackRef.java
index 25ef9522ec8..3a912f9bba7 100644
--- a/libjava/classpath/gnu/regexp/RETokenBackRef.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenBackRef.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenBackRef extends REToken {
private int num;
diff --git a/libjava/classpath/gnu/regexp/RETokenChar.java b/libjava/classpath/gnu/java/util/regex/RETokenChar.java
index 1b3a74855ec..92d3efcf85b 100644
--- a/libjava/classpath/gnu/regexp/RETokenChar.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenChar.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenChar extends REToken {
private char[] ch;
diff --git a/libjava/classpath/gnu/regexp/RETokenEnd.java b/libjava/classpath/gnu/java/util/regex/RETokenEnd.java
index deb2fc54dda..00efdb6a712 100644
--- a/libjava/classpath/gnu/regexp/RETokenEnd.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenEnd.java
@@ -36,17 +36,25 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenEnd extends REToken {
/**
* Indicates whether this token should match on a line break.
*/
private String newline;
+ private boolean check_java_line_terminators;
RETokenEnd(int subIndex,String newline) {
super(subIndex);
this.newline = newline;
+ this.check_java_line_terminators = false;
+ }
+
+ RETokenEnd(int subIndex, String newline, boolean b) {
+ super(subIndex);
+ this.newline = newline;
+ this.check_java_line_terminators = b;
}
int getMaximumLength() {
@@ -58,6 +66,18 @@ final class RETokenEnd extends REToken {
if (ch == CharIndexed.OUT_OF_BOUNDS)
return ((mymatch.eflags & RE.REG_NOTEOL)>0) ?
null : mymatch;
+ if (check_java_line_terminators) {
+ if (ch == '\n') {
+ char ch1 = input.charAt(mymatch.index - 1);
+ if (ch1 == '\r') return null;
+ return mymatch;
+ }
+ if (ch == '\r') return mymatch;
+ if (ch == '\u0085') return mymatch; // A next-line character
+ if (ch == '\u2028') return mymatch; // A line-separator character
+ if (ch == '\u2029') return mymatch; // A paragraph-separator character
+ return null;
+ }
if (newline != null) {
char z;
int i = 0; // position in newline
diff --git a/libjava/classpath/gnu/regexp/RETokenEndOfPreviousMatch.java b/libjava/classpath/gnu/java/util/regex/RETokenEndOfPreviousMatch.java
index 167d10b5fdb..ea5580e1666 100644
--- a/libjava/classpath/gnu/regexp/RETokenEndOfPreviousMatch.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenEndOfPreviousMatch.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
class RETokenEndOfPreviousMatch extends RETokenStart {
diff --git a/libjava/classpath/gnu/regexp/RETokenEndSub.java b/libjava/classpath/gnu/java/util/regex/RETokenEndSub.java
index fca01c7f3a4..57a146d03b9 100644
--- a/libjava/classpath/gnu/regexp/RETokenEndSub.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenEndSub.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenEndSub extends REToken {
RETokenEndSub(int subIndex) {
diff --git a/libjava/classpath/gnu/regexp/RETokenIndependent.java b/libjava/classpath/gnu/java/util/regex/RETokenIndependent.java
index 8bb95c654e3..48f8656123d 100644
--- a/libjava/classpath/gnu/regexp/RETokenIndependent.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenIndependent.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* @author Ito Kazumitsu
diff --git a/libjava/classpath/gnu/regexp/RETokenLookAhead.java b/libjava/classpath/gnu/java/util/regex/RETokenLookAhead.java
index 009872c2f2d..134f17c609c 100644
--- a/libjava/classpath/gnu/regexp/RETokenLookAhead.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenLookAhead.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* @since gnu.regexp 1.1.3
diff --git a/libjava/classpath/gnu/regexp/RETokenLookBehind.java b/libjava/classpath/gnu/java/util/regex/RETokenLookBehind.java
index 8311d1a7ae3..a01a15bc90f 100644
--- a/libjava/classpath/gnu/regexp/RETokenLookBehind.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenLookBehind.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* @author Ito Kazumitsu
diff --git a/libjava/classpath/gnu/regexp/RETokenNamedProperty.java b/libjava/classpath/gnu/java/util/regex/RETokenNamedProperty.java
index 6147e87dc37..a286c5be8c6 100644
--- a/libjava/classpath/gnu/regexp/RETokenNamedProperty.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenNamedProperty.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenNamedProperty extends REToken {
String name;
diff --git a/libjava/classpath/gnu/regexp/RETokenOneOf.java b/libjava/classpath/gnu/java/util/regex/RETokenOneOf.java
index f747d5917a3..bccc783118a 100644
--- a/libjava/classpath/gnu/regexp/RETokenOneOf.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenOneOf.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
import java.util.Vector;
import java.util.Stack;
diff --git a/libjava/classpath/gnu/regexp/RETokenPOSIX.java b/libjava/classpath/gnu/java/util/regex/RETokenPOSIX.java
index dbea98aee82..07298958365 100644
--- a/libjava/classpath/gnu/regexp/RETokenPOSIX.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenPOSIX.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenPOSIX extends REToken {
int type;
diff --git a/libjava/classpath/gnu/regexp/RETokenRange.java b/libjava/classpath/gnu/java/util/regex/RETokenRange.java
index 9d3da324e22..8a65f77f13f 100644
--- a/libjava/classpath/gnu/regexp/RETokenRange.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenRange.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
final class RETokenRange extends REToken {
private char lo, hi;
diff --git a/libjava/classpath/gnu/regexp/RETokenRepeated.java b/libjava/classpath/gnu/java/util/regex/RETokenRepeated.java
index 1bad4c79292..531c4a31124 100644
--- a/libjava/classpath/gnu/regexp/RETokenRepeated.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenRepeated.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
// import java.util.Vector;
// import java.util.Stack;
diff --git a/libjava/classpath/gnu/regexp/RETokenStart.java b/libjava/classpath/gnu/java/util/regex/RETokenStart.java
index b992bd661db..aa5f0c91401 100644
--- a/libjava/classpath/gnu/regexp/RETokenStart.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenStart.java
@@ -35,14 +35,22 @@ 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.regexp;
+package gnu.java.util.regex;
class RETokenStart extends REToken {
private String newline; // matches after a newline
+ private boolean check_java_line_terminators;
RETokenStart(int subIndex, String newline) {
super(subIndex);
this.newline = newline;
+ this.check_java_line_terminators = false;
+ }
+
+ RETokenStart(int subIndex, String newline, boolean b) {
+ super(subIndex);
+ this.newline = newline;
+ this.check_java_line_terminators = b;
}
int getMaximumLength() {
@@ -53,6 +61,21 @@ class RETokenStart extends REToken {
// charAt(index-n) may be unknown on a Reader/InputStream. FIXME
// Match after a newline if in multiline mode
+ if (check_java_line_terminators) {
+ char ch = input.charAt(mymatch.index - 1);
+ if (ch != CharIndexed.OUT_OF_BOUNDS) {
+ if (ch == '\n') return mymatch;
+ if (ch == '\r') {
+ char ch1 = input.charAt(mymatch.index);
+ if (ch1 != '\n') return mymatch;
+ return null;
+ }
+ if (ch == '\u0085') return mymatch; // A next-line character
+ if (ch == '\u2028') return mymatch; // A line-separator character
+ if (ch == '\u2029') return mymatch; // A paragraph-separator character
+ }
+ }
+
if (newline != null) {
int len = newline.length();
if (mymatch.offset >= len) {
diff --git a/libjava/classpath/gnu/regexp/RETokenWordBoundary.java b/libjava/classpath/gnu/java/util/regex/RETokenWordBoundary.java
index 1810339b8e8..538c6bef40c 100644
--- a/libjava/classpath/gnu/regexp/RETokenWordBoundary.java
+++ b/libjava/classpath/gnu/java/util/regex/RETokenWordBoundary.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* Represents a combination lookahead/lookbehind for POSIX [:alnum:].
diff --git a/libjava/classpath/gnu/regexp/UncheckedRE.java b/libjava/classpath/gnu/java/util/regex/UncheckedRE.java
index e6712113828..73a67c65736 100644
--- a/libjava/classpath/gnu/regexp/UncheckedRE.java
+++ b/libjava/classpath/gnu/java/util/regex/UncheckedRE.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.regexp;
+package gnu.java.util.regex;
/**
* UncheckedRE is a subclass of RE that allows programmers an easier means
@@ -51,7 +51,7 @@ package gnu.regexp;
* regular expressions for the syntax specified.
*
* @author <A HREF="mailto:wes@cacas.org">Wes Biggs</A>
- * @see gnu.regexp.RE
+ * @see gnu.java.util.regex.RE
* @since gnu.regexp 1.1.4
*/
diff --git a/libjava/classpath/gnu/javax/crypto/RSACipherImpl.java b/libjava/classpath/gnu/javax/crypto/RSACipherImpl.java
index 0a4c29db6f1..60504ecce85 100644
--- a/libjava/classpath/gnu/javax/crypto/RSACipherImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/RSACipherImpl.java
@@ -1,5 +1,5 @@
-/* DiffieHellmanImpl.java -- implementation of the Diffie-Hellman key agreement.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* RSACipherImpl.java --
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,26 +38,21 @@ 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;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
-
import java.security.interfaces.RSAKey;
-import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
-
import java.security.spec.AlgorithmParameterSpec;
-
import java.util.logging.Logger;
import javax.crypto.BadPaddingException;
@@ -67,10 +62,10 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
-public class RSACipherImpl extends CipherSpi
+public class RSACipherImpl
+ extends CipherSpi
{
private static final Logger logger = SystemLogger.SYSTEM;
-
private static final byte[] EMPTY = new byte[0];
private int opmode = -1;
private RSAPrivateKey decipherKey = null;
@@ -80,48 +75,44 @@ public class RSACipherImpl extends CipherSpi
private byte[] dataBuffer = null;
private int pos = 0;
- protected void engineSetMode (String mode) throws NoSuchAlgorithmException
+ protected void engineSetMode(String mode) throws NoSuchAlgorithmException
{
- throw new NoSuchAlgorithmException ("only one mode available");
+ throw new NoSuchAlgorithmException("only one mode available");
}
- protected void engineSetPadding (String pad) throws NoSuchPaddingException
+ protected void engineSetPadding(String pad) throws NoSuchPaddingException
{
- throw new NoSuchPaddingException ("only one padding available");
+ throw new NoSuchPaddingException("only one padding available");
}
- protected int engineGetBlockSize ()
+ protected int engineGetBlockSize()
{
return 1;
}
- protected int engineGetOutputSize (int inputLen)
+ protected int engineGetOutputSize(int inputLen)
{
int outputLen = 0;
if (decipherKey != null)
- {
- outputLen = (decipherKey.getModulus ().bitLength () + 7) / 8;
- }
+ outputLen = (decipherKey.getModulus().bitLength() + 7) / 8;
else if (encipherKey != null)
- {
- outputLen = (encipherKey.getModulus ().bitLength () + 7) / 8;
- }
+ outputLen = (encipherKey.getModulus().bitLength() + 7) / 8;
else
- throw new IllegalStateException ("not initialized");
+ throw new IllegalStateException("not initialized");
if (inputLen > outputLen)
- throw new IllegalArgumentException ("not configured to encode " + inputLen
- + "bytes; at most " + outputLen);
+ throw new IllegalArgumentException("not configured to encode " + inputLen
+ + "bytes; at most " + outputLen);
return outputLen;
}
- protected int engineGetKeySize (final Key key) throws InvalidKeyException
+ protected int engineGetKeySize(final Key key) throws InvalidKeyException
{
- if (!(key instanceof RSAKey))
- throw new InvalidKeyException ("not an RSA key");
- return ((RSAKey) key).getModulus ().bitLength ();
+ if (! (key instanceof RSAKey))
+ throw new InvalidKeyException("not an RSA key");
+ return ((RSAKey) key).getModulus().bitLength();
}
- protected byte[] engineGetIV ()
+ protected byte[] engineGetIV()
{
return null;
}
@@ -131,18 +122,18 @@ public class RSACipherImpl extends CipherSpi
return null;
}
- protected void engineInit (int opmode, Key key, SecureRandom random)
- throws InvalidKeyException
+ protected void engineInit(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException
{
int outputLen = 0;
if (opmode == Cipher.ENCRYPT_MODE)
{
- if (!(key instanceof RSAPublicKey))
- throw new InvalidKeyException ("expecting a RSAPublicKey");
+ if (! (key instanceof RSAPublicKey))
+ throw new InvalidKeyException("expecting a RSAPublicKey");
encipherKey = (RSAPublicKey) key;
decipherKey = null;
blindingKey = null;
- outputLen = (encipherKey.getModulus ().bitLength () + 7) / 8;
+ outputLen = (encipherKey.getModulus().bitLength() + 7) / 8;
}
else if (opmode == Cipher.DECRYPT_MODE)
{
@@ -151,74 +142,78 @@ public class RSACipherImpl extends CipherSpi
decipherKey = (RSAPrivateKey) key;
encipherKey = null;
blindingKey = null;
- outputLen = (decipherKey.getModulus ().bitLength () + 7) / 8;
+ outputLen = (decipherKey.getModulus().bitLength() + 7) / 8;
}
else if (key instanceof RSAPublicKey)
{
if (decipherKey == null)
- throw new IllegalStateException ("must configure decryption key first");
- if (!decipherKey.getModulus ().equals (((RSAPublicKey) key).getModulus ()))
- throw new InvalidKeyException ("blinding key is not compatible");
+ throw new IllegalStateException("must configure decryption key first");
+ if (! decipherKey.getModulus().equals(((RSAPublicKey) key).getModulus()))
+ throw new InvalidKeyException("blinding key is not compatible");
blindingKey = (RSAPublicKey) key;
return;
}
else
- throw new InvalidKeyException ("expecting either an RSAPrivateKey or an RSAPublicKey (for blinding)");
+ throw new InvalidKeyException(
+ "expecting either an RSAPrivateKey or an RSAPublicKey (for blinding)");
}
else
- throw new IllegalArgumentException ("only encryption and decryption supported");
+ throw new IllegalArgumentException("only encryption and decryption supported");
this.random = random;
this.opmode = opmode;
pos = 0;
dataBuffer = new byte[outputLen];
}
- protected void engineInit (int opmode, Key key, AlgorithmParameterSpec spec, SecureRandom random)
- throws InvalidKeyException
+ protected void engineInit(int opmode, Key key, AlgorithmParameterSpec spec,
+ SecureRandom random) throws InvalidKeyException
{
- engineInit (opmode, key, random);
+ engineInit(opmode, key, random);
}
- protected void engineInit (int opmode, Key key, AlgorithmParameters params, SecureRandom random)
- throws InvalidKeyException
+ protected void engineInit(int opmode, Key key, AlgorithmParameters params,
+ SecureRandom random) throws InvalidKeyException
{
- engineInit (opmode, key, random);
+ engineInit(opmode, key, random);
}
- protected byte[] engineUpdate (byte[] in, int offset, int length)
+ protected byte[] engineUpdate(byte[] in, int offset, int length)
{
if (opmode != Cipher.ENCRYPT_MODE && opmode != Cipher.DECRYPT_MODE)
- throw new IllegalStateException ("not initialized");
- System.arraycopy (in, offset, dataBuffer, pos, length);
+ throw new IllegalStateException("not initialized");
+ System.arraycopy(in, offset, dataBuffer, pos, length);
pos += length;
return EMPTY;
}
- protected int engineUpdate (byte[] in, int offset, int length, byte[] out, int outOffset)
+ protected int engineUpdate(byte[] in, int offset, int length, byte[] out,
+ int outOffset)
{
- engineUpdate (in, offset, length);
+ engineUpdate(in, offset, length);
return 0;
}
- protected byte[] engineDoFinal (byte[] in, int offset, int length)
- throws IllegalBlockSizeException, BadPaddingException
+ protected byte[] engineDoFinal(byte[] in, int offset, int length)
+ throws IllegalBlockSizeException, BadPaddingException
{
- engineUpdate (in, offset, length);
+ engineUpdate(in, offset, length);
if (opmode == Cipher.DECRYPT_MODE)
{
if (pos < dataBuffer.length)
- throw new IllegalBlockSizeException ("expecting exactly " + dataBuffer.length + " bytes");
- BigInteger enc = new BigInteger (1, dataBuffer);
- byte[] dec = rsaDecrypt (enc);
- logger.log (Component.CRYPTO, "RSA: decryption produced\n{0}",
- new ByteArray (dec));
+ throw new IllegalBlockSizeException("expecting exactly "
+ + dataBuffer.length + " bytes");
+ BigInteger enc = new BigInteger(1, dataBuffer);
+ byte[] dec = rsaDecrypt(enc);
+ logger.log(Component.CRYPTO, "RSA: decryption produced\n{0}",
+ new ByteArray(dec));
if (dec[0] != 0x02)
- throw new BadPaddingException ("expected padding type 2");
+ throw new BadPaddingException("expected padding type 2");
int i;
- for (i = 1; i < dec.length && dec[i] != 0x00; i++);
- int len = dec.length - i;
+ for (i = 1; i < dec.length && dec[i] != 0x00; i++)
+ ; // keep incrementing i
+ int len = dec.length - i - 1; // skip the 0x00 byte
byte[] result = new byte[len];
- System.arraycopy (dec, i, result, 0, len);
+ System.arraycopy(dec, i + 1, result, 0, len);
pos = 0;
return result;
}
@@ -226,29 +221,29 @@ public class RSACipherImpl extends CipherSpi
{
offset = dataBuffer.length - pos;
if (offset < 3)
- throw new IllegalBlockSizeException ("input is too large to encrypt");
+ throw new IllegalBlockSizeException("input is too large to encrypt");
byte[] dec = new byte[dataBuffer.length];
dec[0] = 0x02;
if (random == null)
- random = new SecureRandom ();
- byte[] pad = new byte[offset - 2];
- random.nextBytes (pad);
- for (int i = 0; i < pad.length; i++)
- if (pad[i] == 0)
- pad[i] = 1;
- System.arraycopy (pad, 0, dec, 1, pad.length);
+ random = new SecureRandom();
+ byte[] pad = new byte[offset - 2];
+ random.nextBytes(pad);
+ for (int i = 0; i < pad.length; i++)
+ if (pad[i] == 0)
+ pad[i] = 1;
+ System.arraycopy(pad, 0, dec, 1, pad.length);
dec[dec.length - pos] = 0x00;
- System.arraycopy (dataBuffer, 0, dec, offset, pos);
- logger.log (Component.CRYPTO, "RSA: produced padded plaintext\n{0}",
- new ByteArray (dec));
- BigInteger x = new BigInteger (1, dec);
- BigInteger y = x.modPow (encipherKey.getPublicExponent (),
- encipherKey.getModulus ());
- byte[] enc = y.toByteArray ();
+ System.arraycopy(dataBuffer, 0, dec, offset, pos);
+ logger.log(Component.CRYPTO, "RSA: produced padded plaintext\n{0}",
+ new ByteArray(dec));
+ BigInteger x = new BigInteger(1, dec);
+ BigInteger y = x.modPow(encipherKey.getPublicExponent(),
+ encipherKey.getModulus());
+ byte[] enc = y.toByteArray();
if (enc[0] == 0x00)
{
byte[] tmp = new byte[enc.length - 1];
- System.arraycopy (enc, 1, tmp, 0, tmp.length);
+ System.arraycopy(enc, 1, tmp, 0, tmp.length);
enc = tmp;
}
pos = 0;
@@ -256,56 +251,54 @@ public class RSACipherImpl extends CipherSpi
}
}
- protected int engineDoFinal (byte[] out, int offset)
- throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
+ protected int engineDoFinal(byte[] out, int offset)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException
{
- byte[] result = engineDoFinal (EMPTY, 0, 0);
+ byte[] result = engineDoFinal(EMPTY, 0, 0);
if (out.length - offset < result.length)
- throw new ShortBufferException ("need " + result.length + ", have "
- + (out.length - offset));
- System.arraycopy (result, 0, out, offset, result.length);
+ throw new ShortBufferException("need " + result.length + ", have "
+ + (out.length - offset));
+ System.arraycopy(result, 0, out, offset, result.length);
return result.length;
}
- protected int engineDoFinal (final byte[] input, final int offset, final int length,
- final byte[] output, final int outputOffset)
- throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
+ protected int engineDoFinal(final byte[] input, final int offset,
+ final int length, final byte[] output,
+ final int outputOffset)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException
{
- byte[] result = engineDoFinal (input, offset, length);
+ byte[] result = engineDoFinal(input, offset, length);
if (output.length - outputOffset < result.length)
- throw new ShortBufferException ("need " + result.length + ", have "
- + (output.length - outputOffset));
- System.arraycopy (result, 0, output, outputOffset, result.length);
+ throw new ShortBufferException("need " + result.length + ", have "
+ + (output.length - outputOffset));
+ System.arraycopy(result, 0, output, outputOffset, result.length);
return result.length;
}
/**
* Decrypts the ciphertext, employing RSA blinding if possible.
*/
- private byte[] rsaDecrypt (BigInteger enc)
+ private byte[] rsaDecrypt(BigInteger enc)
{
if (random == null)
- random = new SecureRandom ();
- BigInteger n = decipherKey.getModulus ();
+ random = new SecureRandom();
+ BigInteger n = decipherKey.getModulus();
BigInteger r = null;
BigInteger pubExp = null;
if (blindingKey != null)
- pubExp = blindingKey.getPublicExponent ();
+ pubExp = blindingKey.getPublicExponent();
if (pubExp != null && (decipherKey instanceof RSAPrivateCrtKey))
- pubExp = ((RSAPrivateCrtKey) decipherKey).getPublicExponent ();
+ pubExp = ((RSAPrivateCrtKey) decipherKey).getPublicExponent();
if (pubExp != null)
{
- r = new BigInteger (n.bitLength () - 1, random);
- enc = r.modPow (pubExp, n).multiply (enc).mod (n);
+ r = new BigInteger(n.bitLength() - 1, random);
+ enc = r.modPow(pubExp, n).multiply(enc).mod(n);
}
-
- BigInteger dec = enc.modPow (decipherKey.getPrivateExponent (), n);
-
+ BigInteger dec = enc.modPow(decipherKey.getPrivateExponent(), n);
if (pubExp != null)
- {
- dec = dec.multiply (r.modInverse (n)).mod (n);
- }
-
- return dec.toByteArray ();
+ dec = dec.multiply(r.modInverse(n)).mod(n);
+ return dec.toByteArray();
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java b/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
index 2d5bba3646e..49770675bbd 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
@@ -41,23 +41,19 @@ package gnu.javax.crypto.assembly;
import java.util.Map;
/**
- * <p>An <code>Assembly</code> is a construction consisting of a chain of
+ * An <code>Assembly</code> is a construction consisting of a chain of
* {@link Transformer} elements; each wired in pre- or post- transformation
* mode. This chain is terminated by one <code>LoopbackTransformer</code>
- * element.</p>
- *
- * <p>Once constructed, and correctly initialised, the bulk of the methods
- * available on the <code>Assembly</code> are delegated to the <i>head</i>
- * of the {@link Transformer} chain of the <code>Assembly</code>.</p>
- *
+ * element.
+ * <p>
+ * Once constructed, and correctly initialised, the bulk of the methods
+ * available on the <code>Assembly</code> are delegated to the <i>head</i> of
+ * the {@link Transformer} chain of the <code>Assembly</code>.
+ *
* @see Transformer
*/
public class Assembly
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String DIRECTION = "gnu.crypto.assembly.assembly.direction";
/** Flag that tells if the instance is initialised or not; and if yes how. */
@@ -66,9 +62,6 @@ public class Assembly
/** The first Transformer in the chain. */
private Transformer head;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Trivial constructor that sets the <i>chain</i> to a
* <code>LoopbackTransformer</code>.
@@ -81,21 +74,15 @@ public class Assembly
head = new LoopbackTransformer();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* Adds the designated {@link Transformer} and signals that it should operate
* in pre-processing mode; i.e. it should apply its internal transformation
* algorithm on the input data stream, <b>before</b> it passes that stream to
* the next element in the <i>chain</i>.
- *
+ *
* @param t the {@link Transformer} to add at the head of the current chain.
- * @throws IllegalArgumentException if the designated {@link Transformer}
- * has a non-null tail; i.e. it is already an element of a chain.
+ * @throws IllegalArgumentException if the designated {@link Transformer} has
+ * a non-null tail; i.e. it is already an element of a chain.
*/
public void addPreTransformer(Transformer t)
{
@@ -107,10 +94,10 @@ public class Assembly
* in post-processing mode; i.e. it should apply its internal transformation
* algorithm on the input data stream, <b>after</b> it passes that stream to
* the next element in the <i>chain</i>.
- *
+ *
* @param t the {@link Transformer} to add at the head of the current chain.
- * @throws IllegalArgumentException if the designated {@link Transformer}
- * has a non-null tail; i.e. it is already an element of a chain.
+ * @throws IllegalArgumentException if the designated {@link Transformer} has
+ * a non-null tail; i.e. it is already an element of a chain.
*/
public void addPostTransformer(Transformer t)
{
@@ -120,22 +107,18 @@ public class Assembly
/**
* Initialises the <code>Assembly</code> for operation with specific
* characteristics.
- *
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalStateException if the instance is already initialised.
*/
public void init(Map attributes) throws TransformerException
{
if (wired != null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
Direction flow = (Direction) attributes.get(DIRECTION);
if (flow == null)
- {
- flow = Direction.FORWARD;
- }
+ flow = Direction.FORWARD;
attributes.put(Transformer.DIRECTION, flow);
head.init(attributes);
wired = flow;
@@ -155,12 +138,12 @@ public class Assembly
* Convenience method that calls the method with same name and three
* arguments, using a byte array of length <code>1</code> whose contents are
* the designated byte.
- *
+ *
* @param b the byte to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #update(byte[], int, int)
*/
public byte[] update(byte b) throws TransformerException
@@ -172,12 +155,12 @@ public class Assembly
* Convenience method that calls the method with same name and three
* arguments. All bytes in <code>in</code>, starting from index position
* <code>0</code> are considered.
- *
+ *
* @param in the input data bytes.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #update(byte[], int, int)
*/
public byte[] update(byte[] in) throws TransformerException
@@ -187,34 +170,32 @@ public class Assembly
/**
* Processes a designated number of bytes from a given byte array.
- *
+ *
* @param in the input data bytes.
* @param offset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param length the count of bytes to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
*/
public byte[] update(byte[] in, int offset, int length)
throws TransformerException
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return head.update(in, offset, length);
}
/**
- * Convenience method that calls the method with same name and three
- * arguments using a 0-long byte array.
- *
+ * Convenience method that calls the method with same name and three arguments
+ * using a 0-long byte array.
+ *
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate() throws TransformerException
@@ -226,12 +207,12 @@ public class Assembly
* Convenience method that calls the method with same name and three
* arguments, using a byte array of length <code>1</code> whose contents are
* the designated byte.
- *
+ *
* @param b the byte to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate(byte b) throws TransformerException
@@ -243,12 +224,12 @@ public class Assembly
* Convenience method that calls the method with same name and three
* arguments. All bytes in <code>in</code>, starting from index position
* <code>0</code> are considered.
- *
+ *
* @param in the input data bytes.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate(byte[] in) throws TransformerException
@@ -257,39 +238,33 @@ public class Assembly
}
/**
- * Processes a designated number of bytes from a given byte array and
- * signals, at the same time, that this is the last <i>push</i> operation for
- * this <code>Assembly</code>.
- *
+ * Processes a designated number of bytes from a given byte array and signals,
+ * at the same time, that this is the last <i>push</i> operation for this
+ * <code>Assembly</code>.
+ *
* @param in the input data bytes.
* @param offset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param length the count of bytes to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
- * @throws TransformerException if a transformation-related exception
- * occurs during the operation.
+ * @throws TransformerException if a transformation-related exception occurs
+ * during the operation.
*/
public byte[] lastUpdate(byte[] in, int offset, int length)
throws TransformerException
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
byte[] result = head.lastUpdate(in, offset, length);
reset();
return result;
}
- // helper methods ----------------------------------------------------------
-
private void wireTransformer(Transformer t, Operation mode)
{
if (t.tail != null)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
t.setMode(mode);
t.tail = head;
head = t;
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java b/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
index 678a7e7308d..f790956a472 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
@@ -49,36 +49,31 @@ import java.util.Map;
import java.util.Set;
/**
- * <p>A <i>Cascade</i> Cipher is the concatenation of two or more block ciphers
+ * A <i>Cascade</i> Cipher is the concatenation of two or more block ciphers
* each with independent keys. Plaintext is input to the first stage; the output
- * of stage <code>i</code> is input to stage <code>i + 1</code>; and the output
- * of the last stage is the <i>Cascade</i>'s ciphertext output.</p>
- *
- * <p>In the simplest case, all stages in a <code>Cascade</code> have <i>k</i>-bit
+ * of stage <code>i</code> is input to stage <code>i + 1</code>; and the
+ * output of the last stage is the <i>Cascade</i>'s ciphertext output.
+ * <p>
+ * In the simplest case, all stages in a <code>Cascade</code> have <i>k</i>-bit
* keys, and the stage inputs and outputs are all n-bit quantities. The stage
* ciphers may differ (general cascade of ciphers), or all be identical (cascade
- * of identical ciphers).</p>
- *
- * <p>The term "block ciphers" used above refers to implementations of
- * {@link gnu.crypto.mode.IMode}, including the {@link gnu.crypto.mode.ECB}
- * mode which basically exposes a symmetric-key block cipher algorithm as a
- * <i>Mode</i> of Operations.</p>
- *
- * <p>References:</p>
- *
+ * of identical ciphers).
+ * <p>
+ * The term "block ciphers" used above refers to implementations of
+ * {@link gnu.javax.crypto.mode.IMode}, including the
+ * {@link gnu.javax.crypto.mode.ECB} mode which basically exposes a
+ * symmetric-key block cipher algorithm as a <i>Mode</i> of Operations.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
- * Applied Cryptography.<br>
- * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
- * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
+ * Applied Cryptography.<br>
+ * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
+ * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
*/
public class Cascade
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String DIRECTION = "gnu.crypto.assembly.cascade.direction";
/** The map of Stages chained in this cascade. */
@@ -93,9 +88,6 @@ public class Cascade
/** The curently set block-size for this instance. */
protected int blockSize;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Cascade()
{
super();
@@ -106,12 +98,9 @@ public class Cascade
blockSize = 0;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* Returns the Least Common Multiple of two integers.
- *
+ *
* @param a the first integer.
* @param b the second integer.
* @return the LCM of <code>abs(a)</code> and <code>abs(b)</code>.
@@ -123,18 +112,15 @@ public class Cascade
return A.multiply(B).divide(A.gcd(B)).abs().intValue();
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* Adds to the end of the current chain, a designated {@link Stage}.
- *
+ *
* @param stage the {@link Stage} to append to the chain.
* @return a unique identifier for this stage, within this cascade.
* @throws IllegalStateException if the instance is already initialised.
- * @throws IllegalArgumentException if the designated stage is already in
- * the chain, or it has incompatible characteristics with the current
- * elements already in the chain.
+ * @throws IllegalArgumentException if the designated stage is already in the
+ * chain, or it has incompatible characteristics with the current
+ * elements already in the chain.
*/
public Object append(Stage stage) throws IllegalArgumentException
{
@@ -143,13 +129,13 @@ public class Cascade
/**
* Adds to the begining of the current chain, a designated {@link Stage}.
- *
+ *
* @param stage the {@link Stage} to prepend to the chain.
* @return a unique identifier for this stage, within this cascade.
* @throws IllegalStateException if the instance is already initialised.
- * @throws IllegalArgumentException if the designated stage is already in
- * the chain, or it has incompatible characteristics with the current
- * elements already in the chain.
+ * @throws IllegalArgumentException if the designated stage is already in the
+ * chain, or it has incompatible characteristics with the current
+ * elements already in the chain.
*/
public Object prepend(Stage stage) throws IllegalArgumentException
{
@@ -159,62 +145,49 @@ public class Cascade
/**
* Inserts a {@link Stage} into the current chain, at the specified index
* (zero-based) position.
- *
+ *
* @param stage the {@link Stage} to insert into the chain.
* @return a unique identifier for this stage, within this cascade.
- * @throws IllegalArgumentException if the designated stage is already in
- * the chain, or it has incompatible characteristics with the current
- * elements already in the chain.
+ * @throws IllegalArgumentException if the designated stage is already in the
+ * chain, or it has incompatible characteristics with the current
+ * elements already in the chain.
* @throws IllegalStateException if the instance is already initialised.
* @throws IndexOutOfBoundsException if <code>index</code> is less than
- * <code>0</code> or greater than the current size of this cascade.
+ * <code>0</code> or greater than the current size of this
+ * cascade.
*/
public Object insert(int index, Stage stage) throws IllegalArgumentException,
IndexOutOfBoundsException
{
if (stages.containsValue(stage))
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (wired != null || stage == null)
- {
- throw new IllegalStateException();
- }
-
+ throw new IllegalStateException();
if (index < 0 || index > size())
- {
- throw new IndexOutOfBoundsException();
- }
-
+ throw new IndexOutOfBoundsException();
// check that there is a non-empty set of common block-sizes
Set set = stage.blockSizes();
if (stages.isEmpty())
{
if (set.isEmpty())
- {
- throw new IllegalArgumentException("1st stage with no block sizes");
- }
+ throw new IllegalArgumentException("1st stage with no block sizes");
}
else
{
Set common = this.blockSizes();
common.retainAll(set);
if (common.isEmpty())
- {
- throw new IllegalArgumentException("no common block sizes found");
- }
+ throw new IllegalArgumentException("no common block sizes found");
}
-
Object result = new Object();
stageKeys.add(index, result);
stages.put(result, stage);
-
return result;
}
/**
* Returns the current number of stages in this chain.
- *
+ *
* @return the current count of stages in this chain.
*/
public int size()
@@ -226,18 +199,16 @@ public class Cascade
* Returns an {@link Iterator} over the stages contained in this instance.
* Each element of this iterator is a concrete implementation of a {@link
* Stage}.
- *
+ *
* @return an {@link Iterator} over the stages contained in this instance.
- * Each element of the returned iterator is a concrete instance of a {@link
- * Stage}.
+ * Each element of the returned iterator is a concrete instance of a
+ * {@link Stage}.
*/
public Iterator stages()
{
LinkedList result = new LinkedList();
for (Iterator it = stageKeys.listIterator(); it.hasNext();)
- {
- result.addLast(stages.get(it.next()));
- }
+ result.addLast(stages.get(it.next()));
return result.listIterator();
}
@@ -245,9 +216,9 @@ public class Cascade
* Returns the {@link Set} of supported block sizes for this
* <code>Cascade</code> that are common to all of its chained stages. Each
* element in the returned {@link Set} is an instance of {@link Integer}.
- *
- * @return a {@link Set} of supported block sizes common to all the stages
- * of the chain.
+ *
+ * @return a {@link Set} of supported block sizes common to all the stages of
+ * the chain.
*/
public Set blockSizes()
{
@@ -255,42 +226,33 @@ public class Cascade
for (Iterator it = stages.values().iterator(); it.hasNext();)
{
Stage aStage = (Stage) it.next();
- if (result == null)
- { // first time
- result = new HashSet(aStage.blockSizes());
- }
+ if (result == null) // first time
+ result = new HashSet(aStage.blockSizes());
else
- {
- result.retainAll(aStage.blockSizes());
- }
+ result.retainAll(aStage.blockSizes());
}
return result == null ? Collections.EMPTY_SET : result;
}
/**
* Initialises the chain for operation with specific characteristics.
- *
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalStateException if the chain, or any of its stages, is
- * already initialised.
+ * already initialised.
* @throws InvalidKeyException if the intialisation data provided with the
- * stage is incorrect or causes an invalid key to be generated.
+ * stage is incorrect or causes an invalid key to be generated.
* @see Direction#FORWARD
* @see Direction#REVERSED
*/
public void init(Map attributes) throws InvalidKeyException
{
if (wired != null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
Direction flow = (Direction) attributes.get(DIRECTION);
if (flow == null)
- {
- flow = Direction.FORWARD;
- }
-
+ flow = Direction.FORWARD;
int optimalSize = 0;
for (Iterator it = stageKeys.listIterator(); it.hasNext();)
{
@@ -300,30 +262,25 @@ public class Cascade
Stage stage = (Stage) stages.get(id);
stage.init(attr);
optimalSize = optimalSize == 0 ? stage.currentBlockSize()
- : lcm(optimalSize,
- stage.currentBlockSize());
- }
-
- if (flow == Direction.REVERSED)
- { // reverse order
- Collections.reverse(stageKeys);
+ : lcm(optimalSize,
+ stage.currentBlockSize());
}
+ if (flow == Direction.REVERSED) // reverse order
+ Collections.reverse(stageKeys);
wired = flow;
blockSize = optimalSize;
}
/**
* Returns the currently set block size for the chain.
- *
+ *
* @return the current block size for the chain.
* @throws IllegalStateException if the instance is not initialised.
*/
public int currentBlockSize()
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return blockSize;
}
@@ -334,25 +291,21 @@ public class Cascade
public void reset()
{
for (Iterator it = stageKeys.listIterator(); it.hasNext();)
- {
- ((Stage) stages.get(it.next())).reset();
- }
- if (wired == Direction.REVERSED)
- { // reverse it back
- Collections.reverse(stageKeys);
- }
+ ((Stage) stages.get(it.next())).reset();
+ if (wired == Direction.REVERSED) // reverse it back
+ Collections.reverse(stageKeys);
wired = null;
blockSize = 0;
}
/**
* Processes exactly one block of <i>plaintext</i> (if initialised in the
- * {@link Direction#FORWARD} state) or <i>ciphertext</i> (if initialised in the
- * {@link Direction#REVERSED} state).
- *
+ * {@link Direction#FORWARD} state) or <i>ciphertext</i> (if initialised in
+ * the {@link Direction#REVERSED} state).
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
* @param outOffset index of <code>out</code> from which to store result.
* @throws IllegalStateException if the instance is not initialised.
@@ -360,23 +313,17 @@ public class Cascade
public void update(byte[] in, int inOffset, byte[] out, int outOffset)
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
int stageBlockSize, j, i = stages.size();
for (Iterator it = stageKeys.listIterator(); it.hasNext();)
{
Stage stage = (Stage) stages.get(it.next());
stageBlockSize = stage.currentBlockSize();
for (j = 0; j < blockSize; j += stageBlockSize)
- {
- stage.update(in, inOffset + j, out, outOffset + j);
- }
+ stage.update(in, inOffset + j, out, outOffset + j);
i--;
if (i > 0)
- {
- System.arraycopy(out, outOffset, in, inOffset, blockSize);
- }
+ System.arraycopy(out, outOffset, in, inOffset, blockSize);
}
}
@@ -385,18 +332,16 @@ public class Cascade
* encryption / decryption test(s) for all supported block and key sizes of
* underlying block cipher(s) wrapped by Mode leafs. The test also includes
* one (1) variable key Known Answer Test (KAT) for each block cipher.
- *
+ *
* @return <code>true</code> if the implementation passes simple
- * <i>correctness</i> tests. Returns <code>false</code> otherwise.
+ * <i>correctness</i> tests. Returns <code>false</code> otherwise.
*/
public boolean selfTest()
{
for (Iterator it = stageKeys.listIterator(); it.hasNext();)
{
- if (!((Stage) stages.get(it.next())).selfTest())
- {
- return false;
- }
+ if (! ((Stage) stages.get(it.next())).selfTest())
+ return false;
}
return true;
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java b/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
index 81629f5a8e7..b86f42e2aec 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
@@ -44,19 +44,13 @@ import java.util.Map;
import java.util.Set;
/**
- * <p>A Cascade <i>Stage</i> in a Cascade Cipher.</p>
+ * A Cascade <i>Stage</i> in a Cascade Cipher.
*/
-class CascadeStage extends Stage
+class CascadeStage
+ extends Stage
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private Cascade delegate;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
CascadeStage(Cascade cascade, Direction forwardDirection)
{
super(forwardDirection);
@@ -64,12 +58,6 @@ class CascadeStage extends Stage
this.delegate = cascade;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public Set blockSizes()
{
return Collections.unmodifiableSet(delegate.blockSizes());
@@ -79,9 +67,7 @@ class CascadeStage extends Stage
{
Direction flow = (Direction) attributes.get(DIRECTION);
attributes.put(DIRECTION, flow.equals(forward) ? forward
- : Direction.reverse(forward));
- // delegate.init(flow.equals(forward) ? forward : backward);
- // delegate.init(flow.equals(forward) ? forward : Direction.reverse(forward));
+ : Direction.reverse(forward));
delegate.init(attributes);
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
index dbbc7cd286e..5fce51a15eb 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
@@ -45,19 +45,13 @@ import java.util.Map;
* An Adapter to use any {@link Cascade} as a {@link Transformer} in an
* {@link Assembly}.
*/
-class CascadeTransformer extends Transformer
+class CascadeTransformer
+ extends Transformer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private Cascade delegate;
private int blockSize;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
CascadeTransformer(Cascade delegate)
{
super();
@@ -65,12 +59,6 @@ class CascadeTransformer extends Transformer
this.delegate = delegate;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instant methods
- // -------------------------------------------------------------------------
-
void initDelegate(Map attributes) throws TransformerException
{
attributes.put(Cascade.DIRECTION, wired);
@@ -107,11 +95,9 @@ class CascadeTransformer extends Transformer
{
if (inBuffer.size() != 0)
{
- throw new TransformerException(
- "lastUpdateDelegate()",
- new IllegalStateException(
- "Cascade transformer, after last "
- + "update, must be empty but isn't"));
+ IllegalStateException cause = new IllegalStateException(
+ "Cascade transformer, after last update, must be empty but isn't");
+ throw new TransformerException("lastUpdateDelegate()", cause);
}
return new byte[0];
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/DeflateTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/DeflateTransformer.java
index 35328a6c1dc..e5c0b7a5724 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/DeflateTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/DeflateTransformer.java
@@ -44,27 +44,22 @@ import java.util.zip.Deflater;
import java.util.zip.Inflater;
/**
- * <p>A {@link Transformer} Adapter allowing inclusion of a DEFLATE compression
+ * A {@link Transformer} Adapter allowing inclusion of a DEFLATE compression
* algorithm in an {@link Assembly} chain. The {@link Direction#FORWARD}
* transformation is a compression (deflate) of input data, while the
- * {@link Direction#REVERSED} one is a decompression (inflate) that restores
- * the original data.</p>
- *
- * <p>This {@link Transformer} uses a {@link Deflater} instance to carry on the
- * compression, and an {@link Inflater} to do the decompression.</p>
- *
- * <p>When using such a {@link Transformer}, in an {@link Assembly}, there must
+ * {@link Direction#REVERSED} one is a decompression (inflate) that restores the
+ * original data.
+ * <p>
+ * This {@link Transformer} uses a {@link Deflater} instance to carry on the
+ * compression, and an {@link Inflater} to do the decompression.
+ * <p>
+ * When using such a {@link Transformer}, in an {@link Assembly}, there must
* be at least one element behind this instance in the constructed chain;
- * otherwise, a {@link TransformerException} is thrown at initialisation time.</p>
- *
- * @version Revision: $
+ * otherwise, a {@link TransformerException} is thrown at initialisation time.
*/
-class DeflateTransformer extends Transformer
+class DeflateTransformer
+ extends Transformer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private Deflater compressor;
private Inflater decompressor;
@@ -73,46 +68,31 @@ class DeflateTransformer extends Transformer
private byte[] zlibBuffer;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
DeflateTransformer()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
void initDelegate(Map attributes) throws TransformerException
{
if (tail == null)
{
- throw new TransformerException(
- "initDelegate()",
- new IllegalStateException(
- "Compression transformer missing its tail!"));
+ IllegalStateException cause = new IllegalStateException(
+ "Compression transformer missing its tail!");
+ throw new TransformerException("initDelegate()", cause);
}
outputBlockSize = tail.currentBlockSize();
zlibBuffer = new byte[outputBlockSize];
Direction flow = (Direction) attributes.get(DIRECTION);
if (flow == Direction.FORWARD)
- {
- compressor = new Deflater();
- }
+ compressor = new Deflater();
else
- {
- decompressor = new Inflater();
- }
+ decompressor = new Inflater();
}
int delegateBlockSize()
{
- // return outputBlockSize;
return 1;
}
@@ -131,68 +111,36 @@ class DeflateTransformer extends Transformer
if (wired == Direction.FORWARD)
{
compressor.setInput(in, offset, length);
- while (!compressor.needsInput())
- {
- compress();
- }
+ while (! compressor.needsInput())
+ compress();
}
- else
- { // decompression: inflate first and then update tail
- decompress(in, offset, length);
- }
-
+ else // decompression: inflate first and then update tail
+ decompress(in, offset, length);
result = inBuffer.toByteArray();
inBuffer.reset();
return result;
}
- // byte[] lastUpdateDelegate(byte[] in, int offset, int length)
- // throws TransformerException {
- // // process multiples of blocksize as much as possible
- // byte[] result = this.updateDelegate(in, offset, length);
- // inBuffer.write(result, 0, result.length);
- // if (wired == Direction.FORWARD) { // compressing
- // if (!compressor.finished()) {
- // compressor.finish();
- // while (!compressor.finished()) {
- // compress();
- // }
- // }
- // } else { // decompressing
- // if (!decompressor.finished()) {
- // throw new TransformerException("lastUpdateDelegate()",
- // new IllegalStateException("Compression transformer, after last "
- // +"update, must be finished but isn't"));
- // }
- // }
- //
- // result = inBuffer.toByteArray();
- // inBuffer.reset();
- // return result;
- // }
byte[] lastUpdateDelegate() throws TransformerException
{
// process multiples of blocksize as much as possible
- if (wired == Direction.FORWARD)
- { // compressing
- if (!compressor.finished())
+ if (wired == Direction.FORWARD) // compressing
+ {
+ if (! compressor.finished())
{
compressor.finish();
- while (!compressor.finished())
- {
- compress();
- }
+ while (! compressor.finished())
+ compress();
}
}
- else
- { // decompressing
- if (!decompressor.finished())
+ else // decompressing
+ {
+ if (! decompressor.finished())
{
- throw new TransformerException(
- "lastUpdateDelegate()",
- new IllegalStateException(
- "Compression transformer, after last "
- + "update, must be finished but isn't"));
+ IllegalStateException cause = new IllegalStateException(
+ "Compression transformer, after last update, must be finished "
+ + "but isn't");
+ throw new TransformerException("lastUpdateDelegate()", cause);
}
}
byte[] result = inBuffer.toByteArray();
@@ -204,9 +152,7 @@ class DeflateTransformer extends Transformer
{
int len = compressor.deflate(zlibBuffer);
if (len > 0)
- {
- inBuffer.write(zlibBuffer, 0, len);
- }
+ inBuffer.write(zlibBuffer, 0, len);
}
private void decompress(byte[] in, int offset, int length)
@@ -225,9 +171,7 @@ class DeflateTransformer extends Transformer
throw new TransformerException("decompress()", x);
}
if (len > 0)
- {
- inBuffer.write(zlibBuffer, 0, len);
- }
+ inBuffer.write(zlibBuffer, 0, len);
}
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Direction.java b/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
index 58b59a6307f..48c74ed1ba0 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
@@ -39,32 +39,26 @@ exception statement from your version. */
package gnu.javax.crypto.assembly;
/**
- * <p>An enumeration type for wiring {@link Stage} instances into {@link
- * Cascade} Cipher chains, as well as for operating a {@link Cascade} in a
- * given direction.</p>
- *
- * <p>The possible values for this type are two:</p>
+ * An enumeration type for wiring {@link Stage} instances into {@link Cascade}
+ * Cipher chains, as well as for operating a {@link Cascade} in a given
+ * direction.
+ * <p>
+ * The possible values for this type are two:
* <ol>
- * <li>FORWARD: equivalent to {@link gnu.crypto.mode.IMode#ENCRYPTION}, and
- * its inverse value</li>
- * <li>REVERSED: equivalent to {@link gnu.crypto.mode.IMode#DECRYPTION}.</li>
+ * <li>FORWARD: equivalent to {@link gnu.javax.crypto.mode.IMode#ENCRYPTION},
+ * and its inverse value</li>
+ * <li>REVERSED: equivalent to {@link gnu.javax.crypto.mode.IMode#DECRYPTION}.
+ * </li>
* </ol>
*/
public final class Direction
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final Direction FORWARD = new Direction(1);
public static final Direction REVERSED = new Direction(2);
private int value;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
private Direction(int value)
{
super();
@@ -72,17 +66,11 @@ public final class Direction
this.value = value;
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final Direction reverse(Direction d)
{
return (d.equals(FORWARD) ? REVERSED : FORWARD);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public String toString()
{
return (this == FORWARD ? "forward" : "reversed");
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
index 3c0bdfab30c..bba1da77843 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
@@ -44,27 +44,15 @@ import java.util.Map;
* A trivial {@link Transformer} to allow closing a chain in an {@link Assembly}.
* This class is not visible outside this package.
*/
-final class LoopbackTransformer extends Transformer
+final class LoopbackTransformer
+ extends Transformer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- /** Trivial protected constructor. */
+ /** Trivial package-private constructor. */
LoopbackTransformer()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public void init(Map attributes) throws TransformerException
{
}
@@ -84,8 +72,6 @@ final class LoopbackTransformer extends Transformer
return lastUpdateDelegate();
}
- // abstract methods to be implemented by concrete subclasses ---------------
-
void initDelegate(Map attributes) throws TransformerException
{
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java b/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
index 1143348f675..253ab4ae60a 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
@@ -48,25 +48,19 @@ import java.util.Map;
import java.util.Set;
/**
- * <p>An {@link IMode} {@link Stage} in a {@link Cascade} Cipher chain.</p>
- *
- * <p>Such a stage wraps an implementation of a Block Cipher Mode of Operation
+ * An {@link IMode} {@link Stage} in a {@link Cascade} Cipher chain.
+ * <p>
+ * Such a stage wraps an implementation of a Block Cipher Mode of Operation
* ({@link IMode}) to allow inclusion of such an instance in a cascade of block
- * ciphers.</p>
+ * ciphers.
*/
-class ModeStage extends Stage
+class ModeStage
+ extends Stage
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private IMode delegate;
private transient Set cachedBlockSizes;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
ModeStage(IMode mode, Direction forwardDirection)
{
super(forwardDirection);
@@ -75,21 +69,13 @@ class ModeStage extends Stage
cachedBlockSizes = null;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public Set blockSizes()
{
if (cachedBlockSizes == null)
{
HashSet result = new HashSet();
for (Iterator it = delegate.blockSizes(); it.hasNext();)
- {
- result.add(it.next());
- }
+ result.add(it.next());
cachedBlockSizes = Collections.unmodifiableSet(result);
}
return cachedBlockSizes;
@@ -99,9 +85,8 @@ class ModeStage extends Stage
{
Direction flow = (Direction) attributes.get(DIRECTION);
attributes.put(IMode.STATE,
- new Integer(flow.equals(forward) ? IMode.ENCRYPTION
- : IMode.DECRYPTION));
-
+ Integer.valueOf(flow.equals(forward) ? IMode.ENCRYPTION
+ : IMode.DECRYPTION));
delegate.init(attributes);
}
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Operation.java b/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
index 34cae52ea80..28fdf941298 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
@@ -39,34 +39,26 @@ exception statement from your version. */
package gnu.javax.crypto.assembly;
/**
- * <p>An enumeration type for specifying the operation type of a
- * {@link Transformer}.</p>
- *
- * <p>The possible values for this type are two:</p>
+ * An enumeration type for specifying the operation type of a
+ * {@link Transformer}.
+ * <p>
+ * The possible values for this type are two:
* <ol>
- * <li>PRE_PROCESSING: where the input data is first processed by the
- * current {@link Transformer} before being passed to the rest of the chain;
- * and</li>
- * <li>POST_PROCESSING: where the input data is first passed to the rest of
- * the chain, and the resulting bytes are then processed by the current
- * {@link Transformer}.</li>
+ * <li>PRE_PROCESSING: where the input data is first processed by the current
+ * {@link Transformer} before being passed to the rest of the chain; and</li>
+ * <li>POST_PROCESSING: where the input data is first passed to the rest of the
+ * chain, and the resulting bytes are then processed by the current
+ * {@link Transformer}.</li>
* </ol>
*/
public final class Operation
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final Operation PRE_PROCESSING = new Operation(1);
public static final Operation POST_PROCESSING = new Operation(2);
private int value;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
private Operation(int value)
{
super();
@@ -74,12 +66,6 @@ public final class Operation
this.value = value;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public String toString()
{
return (this == PRE_PROCESSING ? "pre-processing" : "post-processing");
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
index c63f92e87bc..c11f4fe88da 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
@@ -44,26 +44,20 @@ import gnu.javax.crypto.pad.WrongPaddingException;
import java.util.Map;
/**
- * <p>An Adapter to use any {@link IPad} as a {@link Transformer} in an
- * {@link Assembly}.</p>
- *
- * <p>When using such a {@link Transformer}, in an {@link Assembly}, there must
+ * An Adapter to use any {@link IPad} as a {@link Transformer} in an
+ * {@link Assembly}.
+ * <p>
+ * When using such a {@link Transformer}, in an {@link Assembly}, there must
* be at least one element behind this instance in the constructed chain;
- * otherwise, a {@link TransformerException} is thrown at initialisation time.</p>
+ * otherwise, a {@link TransformerException} is thrown at initialisation time.
*/
-class PaddingTransformer extends Transformer
+class PaddingTransformer
+ extends Transformer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private IPad delegate;
private int outputBlockSize = 1;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
PaddingTransformer(IPad padding)
{
super();
@@ -71,20 +65,13 @@ class PaddingTransformer extends Transformer
this.delegate = padding;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
void initDelegate(Map attributes) throws TransformerException
{
if (tail == null)
{
- throw new TransformerException(
- "initDelegate()",
- new IllegalStateException(
- "Padding transformer missing its tail!"));
+ IllegalStateException cause = new IllegalStateException(
+ "Padding transformer missing its tail!");
+ throw new TransformerException("initDelegate()", cause);
}
outputBlockSize = tail.currentBlockSize();
delegate.init(outputBlockSize);
@@ -108,9 +95,10 @@ class PaddingTransformer extends Transformer
byte[] tmp = inBuffer.toByteArray();
inBuffer.reset();
byte[] result;
- if (wired == Direction.FORWARD)
- { // padding
- // buffers remaining bytes from (inBuffer + in) that are less than 1 block
+ if (wired == Direction.FORWARD) // padding
+ {
+ // buffers remaining bytes from (inBuffer + in) that are less than 1
+ // block
if (tmp.length < outputBlockSize)
{
inBuffer.write(tmp, 0, tmp.length);
@@ -124,8 +112,8 @@ class PaddingTransformer extends Transformer
System.arraycopy(tmp, 0, result, 0, newlen);
}
}
- else
- { // unpadding
+ else // unpadding
+ {
// always keep in own buffer a max of 1 block to cater for lastUpdate
if (tmp.length < outputBlockSize)
{
@@ -147,14 +135,14 @@ class PaddingTransformer extends Transformer
byte[] result;
// process multiples of blocksize as much as possible
// catenate result from processing inBuffer with last-update( tail )
- if (wired == Direction.FORWARD)
- { // padding
+ if (wired == Direction.FORWARD) // padding
+ {
result = inBuffer.toByteArray();
byte[] padding = delegate.pad(result, 0, result.length);
inBuffer.write(padding, 0, padding.length);
}
- else
- { // unpadding
+ else // unpadding
+ {
byte[] tmp = inBuffer.toByteArray();
inBuffer.reset();
int realLength;
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Stage.java b/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
index 23d50bb8237..d023f62830a 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
@@ -45,59 +45,56 @@ import java.util.Map;
import java.util.Set;
/**
- * <p>A <i>Stage</i> in a Cascade Cipher.</p>
- *
- * <p>Each stage may be either an implementation of a Block Cipher Mode of
- * Operation ({@link IMode}) or another Cascade Cipher ({@link Cascade}). Each
- * stage has also a <i>natural</i> operational direction when constructed for
- * inclusion within a {@link Cascade}. This <i>natural</i> direction dictates
- * how data flows from one stage into another when stages are chained together
- * in a cascade. One can think of a stage and its natural direction as the
- * specification of how to wire the stage into the chain. The following diagrams
- * may help understand the paradigme. The first shows two stages chained each
- * with a {@link Direction#FORWARD} direction.</p>
+ * A <i>Stage</i> in a Cascade Cipher.
+ * <p>
+ * Each stage may be either an implementation of a Block Cipher Mode of
+ * Operation ({@link IMode}) or another Cascade Cipher ({@link Cascade}).
+ * Each stage has also a <i>natural</i> operational direction when constructed
+ * for inclusion within a {@link Cascade}. This <i>natural</i> direction
+ * dictates how data flows from one stage into another when stages are chained
+ * together in a cascade. One can think of a stage and its natural direction as
+ * the specification of how to wire the stage into the chain. The following
+ * diagrams may help understand the paradigme. The first shows two stages
+ * chained each with a {@link Direction#FORWARD} direction.
+ *
* <pre>
- * FORWARD FORWARD
- * +------+ +-------+
- * | | | |
- * | +--in --+ | +--in --+
- * ---+ | Stage | | | Stage | +---
- * +--out--+ | +--out--+ |
- * | | | |
- * +-------+ +------+
+ * FORWARD FORWARD
+ * +------+ +-------+
+ * | | | |
+ * | +--in --+ | +--in --+
+ * ---+ | Stage | | | Stage | +---
+ * +--out--+ | +--out--+ |
+ * | | | |
+ * +-------+ +------+
* </pre>
- * <p>The second diagram shows two stages, one in a {@link Direction#FORWARD}
+ *
+ * <p>
+ * The second diagram shows two stages, one in a {@link Direction#FORWARD}
* direction, while the other is wired in a {@link Direction#REVERSED}
- * direction.</p>
+ * direction.
+ *
* <pre>
- * FORWARD REVERSED
- * +------+ +------+
- * | | | |
- * | +--in --+ +--in --+ |
- * ---+ | Stage | | Stage | +---
- * +--out--+ +--out--+
- * | |
- * +---------------+
+ * FORWARD REVERSED
+ * +------+ +------+
+ * | | | |
+ * | +--in --+ +--in --+ |
+ * ---+ | Stage | | Stage | +---
+ * +--out--+ +--out--+
+ * | |
+ * +---------------+
* </pre>
- *
+ *
* @see ModeStage
* @see CascadeStage
*/
public abstract class Stage
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String DIRECTION = "gnu.crypto.assembly.stage.direction";
protected Direction forward;
protected Direction wired;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected Stage(Direction forwardDirection)
{
super();
@@ -106,9 +103,6 @@ public abstract class Stage
this.wired = null;
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final Stage getInstance(IMode mode, Direction forwardDirection)
{
return new ModeStage(mode, forwardDirection);
@@ -120,32 +114,27 @@ public abstract class Stage
return new CascadeStage(cascade, forwardDirection);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* Returns the {@link Set} of supported block sizes for this
* <code>Stage</code>. Each element in the returned {@link Set} is an
* instance of {@link Integer}.
- *
+ *
* @return a {@link Set} of supported block sizes.
*/
public abstract Set blockSizes();
/**
* Initialises the stage for operation with specific characteristics.
- *
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalStateException if the instance is already initialised.
* @throws InvalidKeyException if the key data is invalid.
*/
public void init(Map attributes) throws InvalidKeyException
{
if (wired != null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
Direction flow = (Direction) attributes.get(DIRECTION);
if (flow == null)
{
@@ -158,7 +147,7 @@ public abstract class Stage
/**
* Returns the currently set block size for the stage.
- *
+ *
* @return the current block size for this stage.
* @throws IllegalStateException if the instance is not initialised.
*/
@@ -178,10 +167,10 @@ public abstract class Stage
* Processes exactly one block of <i>plaintext</i> (if initialised in the
* {@link Direction#FORWARD} state) or <i>ciphertext</i> (if initialised in
* the {@link Direction#REVERSED} state).
- *
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
* @param outOffset index of <code>out</code> from which to store result.
* @throws IllegalStateException if the instance is not initialised.
@@ -189,9 +178,7 @@ public abstract class Stage
public void update(byte[] in, int inOffset, byte[] out, int outOffset)
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
updateDelegate(in, inOffset, out, outOffset);
}
@@ -200,14 +187,12 @@ public abstract class Stage
* encryption / decryption test(s) for all supported block and key sizes of
* underlying block cipher(s) wrapped by Mode leafs. The test also includes
* one (1) variable key Known Answer Test (KAT) for each block cipher.
- *
+ *
* @return <code>true</code> if the implementation passes simple
- * <i>correctness</i> tests. Returns <code>false</code> otherwise.
+ * <i>correctness</i> tests. Returns <code>false</code> otherwise.
*/
public abstract boolean selfTest();
- // abstract methods to be implemented by concrete subclasses ---------------
-
abstract void initDelegate(Map attributes) throws InvalidKeyException;
abstract void resetDelegate();
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java b/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
index 80430dc196f..58a991b93b9 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
@@ -44,50 +44,44 @@ import java.io.ByteArrayOutputStream;
import java.util.Map;
/**
- * <p>A <code>Transformer</code> is an abstract representation of a two-way
+ * A <code>Transformer</code> is an abstract representation of a two-way
* <i>transformation</i> that can be chained together with other instances of
* this type. Examples of such transformations in this library are:
- * {@link Cascade} cipher, {@link gnu.crypto.pad.IPad} algorithm, and a
+ * {@link Cascade} cipher, {@link gnu.javax.crypto.pad.IPad} algorithm, and a
* ZLib-based deflater/inflater algorithm. A special implementation of a
- * <code>Transformer</code> to close a chain is also provided.</p>
- *
- * <p>A <code>Transformer</code> is characterised by the followings:<p>
+ * <code>Transformer</code> to close a chain is also provided.
+ * <p>
+ * A <code>Transformer</code> is characterised by the followings:
* <ul>
- * <li>It can be chained to other instances, to form an {@link Assembly}.</li>
- * <li>When configured in an {@link Assembly}, it can be set to apply its
- * internal transformation on the input data stream before (pre-processing)
- * or after (post-processing) passing the input data to the next element in
- * the chain. Note that the same type <code>Transformer</code> can be used as
- * either in pre-processing or a post-processing modes.</li>
- * <li>A special transformer --<code>LoopbackTransformer</code>-- is used to
- * close the chain.</li>
- * <li>A useful type of <code>Transformer</code> --one we're interested in--
- * has internal buffers. The distinction between a casual push (update)
- * operation and the last one allows to correctly flush any intermediate
- * bytes that may exist in those buffers.</li>
+ * <li>It can be chained to other instances, to form an {@link Assembly}.</li>
+ * <li>When configured in an {@link Assembly}, it can be set to apply its
+ * internal transformation on the input data stream before (pre-processing) or
+ * after (post-processing) passing the input data to the next element in the
+ * chain. Note that the same type <code>Transformer</code> can be used as
+ * either in pre-processing or a post-processing modes.</li>
+ * <li>A special transformer --<code>LoopbackTransformer</code>-- is used
+ * to close the chain.</li>
+ * <li>A useful type of <code>Transformer</code> --one we're interested in--
+ * has internal buffers. The distinction between a casual push (update)
+ * operation and the last one allows to correctly flush any intermediate bytes
+ * that may exist in those buffers.</li>
* </ul>
- *
- * <p>To allow wiring <code>Transformer</code> instances together, a
+ * <p>
+ * To allow wiring <code>Transformer</code> instances together, a
* <i>minimal-output-size</i> in bytes is necessary. The trivial case of a
* value of <code>1</code> for such attribute practically means that no output
* buffering, from the previous element, is needed --which is independant of
- * buffering the input if the <code>Transformer</code> implementation itself is
- * block-based.</p>
- *
+ * buffering the input if the <code>Transformer</code> implementation itself
+ * is block-based.
+ *
* @see CascadeTransformer
* @see PaddingTransformer
* @see DeflateTransformer
*/
public abstract class Transformer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String DIRECTION = "gnu.crypto.assembly.transformer.direction";
- // public static final String MODE = "gnu.crypto.assembly.transformer.mode";
-
protected Direction wired;
protected Operation mode;
@@ -98,9 +92,6 @@ public abstract class Transformer
protected ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(2048);
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial protected constructor. */
protected Transformer()
{
@@ -109,9 +100,6 @@ public abstract class Transformer
this.wired = null;
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final Transformer getCascadeTransformer(Cascade cascade)
{
return new CascadeTransformer(cascade);
@@ -127,81 +115,69 @@ public abstract class Transformer
return new DeflateTransformer();
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* Sets the operational mode of this <code>Transformer</code>.
- *
+ *
* @param mode the processing mode this <code>Transformer</code> is required
- * to operate in.
- * @throws IllegalStateException if this instance has already been assigned
- * an operational mode.
+ * to operate in.
+ * @throws IllegalStateException if this instance has already been assigned an
+ * operational mode.
*/
public void setMode(final Operation mode)
{
if (this.mode != null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
this.mode = mode;
}
/**
* Returns <code>true</code> if this <code>Transformer</code> was wired in
* pre-processing mode; <code>false</code> otherwise.
- *
- * @return <code>true</code> if this <code>Transformer</code> has been wired
- * in pre-processing mode; <code>false</code> otherwise.
- * @throws IllegalStateException if this instance has not yet been assigned
- * an operational <i>type</i>.
+ *
+ * @return <code>true</code> if this <code>Transformer</code> has been
+ * wired in pre-processing mode; <code>false</code> otherwise.
+ * @throws IllegalStateException if this instance has not yet been assigned an
+ * operational <i>type</i>.
*/
public boolean isPreProcessing()
{
if (mode == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return (mode == Operation.PRE_PROCESSING);
}
/**
* Returns <code>true</code> if this <code>Transformer</code> was wired in
* post-processing mode; <code>false</code> otherwise.
- *
- * @return <code>true</code> if this <code>Transformer</code> has been wired
- * in post-processing mode; <code>false</code> otherwise.
- * @throws IllegalStateException if this instance has not yet been assigned
- * an operational <i>type</i>.
+ *
+ * @return <code>true</code> if this <code>Transformer</code> has been
+ * wired in post-processing mode; <code>false</code> otherwise.
+ * @throws IllegalStateException if this instance has not yet been assigned an
+ * operational <i>type</i>.
*/
public boolean isPostProcessing()
{
- return !isPreProcessing();
+ return ! isPreProcessing();
}
/**
* Initialises the <code>Transformer</code> for operation with specific
* characteristics.
- *
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalStateException if the instance is already initialised.
*/
public void init(Map attributes) throws TransformerException
{
if (wired != null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
Direction flow = (Direction) attributes.get(DIRECTION);
if (flow == null)
- {
- flow = Direction.FORWARD;
- }
+ flow = Direction.FORWARD;
wired = flow;
inBuffer.reset();
outBuffer.reset();
-
tail.init(attributes); // initialise tail first
initDelegate(attributes); // initialise this instance
}
@@ -209,15 +185,13 @@ public abstract class Transformer
/**
* Returns the block-size of this <code>Transformer</code>. A value of
* <code>1</code> indicates that this instance is block-agnostic.
- *
+ *
* @return the current minimal required block size.
*/
public int currentBlockSize()
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return delegateBlockSize();
}
@@ -238,12 +212,12 @@ public abstract class Transformer
* Convenience method that calls the method with same name and three
* arguments, using a byte array of length <code>1</code> whose contents are
* the designated byte.
- *
+ *
* @param b the byte to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #update(byte[], int, int)
*/
public byte[] update(byte b) throws TransformerException
@@ -253,14 +227,14 @@ public abstract class Transformer
/**
* Convenience method that calls the same method with three arguments. All
- * bytes in <code>in</code>, starting from index position <code>0</code> are
- * considered.
- *
+ * bytes in <code>in</code>, starting from index position <code>0</code>
+ * are considered.
+ *
* @param in the input data bytes.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #update(byte[], int, int)
*/
public byte[] update(byte[] in) throws TransformerException
@@ -270,48 +244,42 @@ public abstract class Transformer
/**
* Processes a designated number of bytes from a given byte array.
- *
+ *
* @param in the input data bytes.
* @param offset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param length the count of bytes to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
*/
public byte[] update(byte[] in, int offset, int length)
throws TransformerException
{
if (wired == null)
- {
- throw new IllegalStateException();
- }
- byte[] result = (wired == Direction.FORWARD ? forwardUpdate(in, offset,
- length)
- : inverseUpdate(in, offset,
- length));
+ throw new IllegalStateException();
+ byte[] result = (wired == Direction.FORWARD ? forwardUpdate(in, offset, length)
+ : inverseUpdate(in, offset, length));
return result;
}
/**
* Convenience method that calls the same method with three arguments. A
* zero-long byte array is used.
- *
+ *
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate() throws TransformerException
{
byte[] result = (wired == Direction.FORWARD ? lastForwardUpdate()
- : lastInverseUpdate());
- if (inBuffer.size() != 0)
- { // we still have some buffered bytes
- throw new TransformerException("lastUpdate(): input buffer not empty");
- }
+ : lastInverseUpdate());
+ if (inBuffer.size() != 0) // we still have some buffered bytes
+ throw new TransformerException("lastUpdate(): input buffer not empty");
return result;
}
@@ -319,12 +287,12 @@ public abstract class Transformer
* Convenience method that calls the method with same name and three
* arguments, using a byte array of length <code>1</code> whose contents are
* the designated byte.
- *
+ *
* @param b the byte to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate(byte b) throws TransformerException
@@ -334,14 +302,14 @@ public abstract class Transformer
/**
* Convenience method that calls the same method with three arguments. All
- * bytes in <code>in</code>, starting from index position <code>0</code> are
- * considered.
- *
+ * bytes in <code>in</code>, starting from index position <code>0</code>
+ * are considered.
+ *
* @param in the input data bytes.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
* @see #lastUpdate(byte[], int, int)
*/
public byte[] lastUpdate(byte[] in) throws TransformerException
@@ -350,18 +318,18 @@ public abstract class Transformer
}
/**
- * Processes a designated number of bytes from a given byte array and
- * signals, at the same time, that this is the last <i>push</i> operation on
- * this <code>Transformer</code>.
- *
+ * Processes a designated number of bytes from a given byte array and signals,
+ * at the same time, that this is the last <i>push</i> operation on this
+ * <code>Transformer</code>.
+ *
* @param in the input data bytes.
* @param offset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param length the count of bytes to process.
* @return the result of transformation.
* @throws IllegalStateException if the instance is not initialised.
* @throws TransformerException if a transformation-related exception occurs
- * during the operation.
+ * during the operation.
*/
public byte[] lastUpdate(byte[] in, int offset, int length)
throws TransformerException
@@ -378,22 +346,18 @@ public abstract class Transformer
return result;
}
- // helper methods ----------------------------------------------------------
-
private byte[] forwardUpdate(byte[] in, int off, int len)
throws TransformerException
{
- return (isPreProcessing() ? preTransform(in, off, len) : postTransform(in,
- off,
- len));
+ return (isPreProcessing() ? preTransform(in, off, len)
+ : postTransform(in, off, len));
}
private byte[] inverseUpdate(byte[] in, int off, int len)
throws TransformerException
{
- return (isPreProcessing() ? postTransform(in, off, len) : preTransform(in,
- off,
- len));
+ return (isPreProcessing() ? postTransform(in, off, len)
+ : preTransform(in, off, len));
}
private byte[] preTransform(byte[] in, int off, int len)
@@ -444,8 +408,6 @@ public abstract class Transformer
return result;
}
- // abstract methods to be implemented by concrete subclasses ---------------
-
abstract void initDelegate(Map attributes) throws TransformerException;
abstract int delegateBlockSize();
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/TransformerException.java b/libjava/classpath/gnu/javax/crypto/assembly/TransformerException.java
index 412f0f0f183..2c972f858d3 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/TransformerException.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/TransformerException.java
@@ -43,17 +43,11 @@ import java.io.PrintWriter;
/**
*/
-public class TransformerException extends Exception
+public class TransformerException
+ extends Exception
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private Throwable _exception = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public TransformerException()
{
super();
@@ -78,12 +72,6 @@ public class TransformerException extends Exception
this._exception = cause;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instant methods
- // -------------------------------------------------------------------------
-
public Throwable getCause()
{
return _exception;
@@ -98,61 +86,53 @@ public class TransformerException extends Exception
{
super.printStackTrace();
if (_exception != null)
- {
- _exception.printStackTrace();
- }
+ _exception.printStackTrace();
}
/**
* Prints this exception's stack trace to a print stream. If this exception
- * has a root exception; the stack trace of the root exception is also
- * printed to the print stream.
- *
+ * has a root exception; the stack trace of the root exception is also printed
+ * to the print stream.
+ *
* @param ps the non-null print stream to which to print.
*/
public void printStackTrace(PrintStream ps)
{
super.printStackTrace(ps);
if (_exception != null)
- {
- _exception.printStackTrace(ps);
- }
+ _exception.printStackTrace(ps);
}
/**
* Prints this exception's stack trace to a print writer. If this exception
- * has a root exception; the stack trace of the root exception is also
- * printed to the print writer.
- *
+ * has a root exception; the stack trace of the root exception is also printed
+ * to the print writer.
+ *
* @param pw the non-null print writer to use for output.
*/
public void printStackTrace(PrintWriter pw)
{
super.printStackTrace(pw);
if (_exception != null)
- {
- _exception.printStackTrace(pw);
- }
+ _exception.printStackTrace(pw);
}
/**
* Returns the string representation of this exception. The string
- * representation contains this exception's class name, its detailed
- * messsage, and if it has a root exception, the string representation of the
- * root exception. This string representation is meant for debugging and not
- * meant to be interpreted programmatically.
- *
+ * representation contains this exception's class name, its detailed messsage,
+ * and if it has a root exception, the string representation of the root
+ * exception. This string representation is meant for debugging and not meant
+ * to be interpreted programmatically.
+ *
* @return the non-null string representation of this exception.
* @see Throwable#getMessage()
*/
public String toString()
{
- StringBuffer sb = new StringBuffer(this.getClass().getName()).append(": ").append(
- super.toString());
+ StringBuffer sb = new StringBuffer(this.getClass().getName())
+ .append(": ").append(super.toString());
if (_exception != null)
- {
- sb.append("; caused by: ").append(_exception.toString());
- }
+ sb.append("; caused by: ").append(_exception.toString());
return sb.toString();
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java b/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
index ca4e8edfe77..653957ec619 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
@@ -38,111 +38,82 @@ exception statement from your version. */
package gnu.javax.crypto.cipher;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-//import java.io.PrintWriter;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.logging.Logger;
/**
- * <p>Anubis is a 128-bit block cipher that accepts a variable-length key. The
+ * Anubis is a 128-bit block cipher that accepts a variable-length key. The
* cipher is a uniform substitution-permutation network whose inverse only
* differs from the forward operation in the key schedule. The design of both
* the round transformation and the key schedule is based upon the Wide Trail
- * strategy and permits a wide variety of implementation trade-offs.</p>
- *
- * <p>References:</p>
- *
+ * strategy and permits a wide variety of implementation trade-offs.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://planeta.terra.com.br/informatica/paulobarreto/AnubisPage.html">The
- * ANUBIS Block Cipher</a>.<br>
- * <a href="mailto:paulo.barreto@terra.com.br">Paulo S.L.M. Barreto</a> and
- * <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
+ * <li><a
+ * href="http://planeta.terra.com.br/informatica/paulobarreto/AnubisPage.html">The
+ * ANUBIS Block Cipher</a>.<br>
+ * <a href="mailto:paulo.barreto@terra.com.br">Paulo S.L.M. Barreto</a> and <a
+ * href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
* </ol>
*/
-public final class Anubis extends BaseCipher
+public final class Anubis
+ extends BaseCipher
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- // private static final String NAME = "anubis";
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- // private static final PrintWriter err = new PrintWriter(System.out, true);
- // private static void debug(String s) {
- // err.println(">>> "+NAME+": "+s);
- // }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Anubis.class.getName());
private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 16; // in bytes
-
private static final String Sd = // p. 25 [ANUBIS]
- "\uBA54\u2F74\u53D3\uD24D\u50AC\u8DBF\u7052\u9A4C"
- + "\uEAD5\u97D1\u3351\u5BA6\uDE48\uA899\uDB32\uB7FC"
- + "\uE39E\u919B\uE2BB\u416E\uA5CB\u6B95\uA1F3\uB102"
- + "\uCCC4\u1D14\uC363\uDA5D\u5FDC\u7DCD\u7F5A\u6C5C"
- + "\uF726\uFFED\uE89D\u6F8E\u19A0\uF089\u0F07\uAFFB"
- + "\u0815\u0D04\u0164\uDF76\u79DD\u3D16\u3F37\u6D38"
- + "\uB973\uE935\u5571\u7B8C\u7288\uF62A\u3E5E\u2746"
- + "\u0C65\u6861\u03C1\u57D6\uD958\uD866\uD73A\uC83C"
- + "\uFA96\uA798\uECB8\uC7AE\u694B\uABA9\u670A\u47F2"
- + "\uB522\uE5EE\uBE2B\u8112\u831B\u0E23\uF545\u21CE"
- + "\u492C\uF9E6\uB628\u1782\u1A8B\uFE8A\u09C9\u874E"
- + "\uE12E\uE4E0\uEB90\uA41E\u8560\u0025\uF4F1\u940B"
- + "\uE775\uEF34\u31D4\uD086\u7EAD\uFD29\u303B\u9FF8"
- + "\uC613\u0605\uC511\u777C\u7A78\u361C\u3959\u1856"
- + "\uB3B0\u2420\uB292\uA3C0\u4462\u10B4\u8443\u93C2"
- + "\u4ABD\u8F2D\uBC9C\u6A40\uCFA2\u804F\u1FCA\uAA42";
-
+ "\uBA54\u2F74\u53D3\uD24D\u50AC\u8DBF\u7052\u9A4C"
+ + "\uEAD5\u97D1\u3351\u5BA6\uDE48\uA899\uDB32\uB7FC"
+ + "\uE39E\u919B\uE2BB\u416E\uA5CB\u6B95\uA1F3\uB102"
+ + "\uCCC4\u1D14\uC363\uDA5D\u5FDC\u7DCD\u7F5A\u6C5C"
+ + "\uF726\uFFED\uE89D\u6F8E\u19A0\uF089\u0F07\uAFFB"
+ + "\u0815\u0D04\u0164\uDF76\u79DD\u3D16\u3F37\u6D38"
+ + "\uB973\uE935\u5571\u7B8C\u7288\uF62A\u3E5E\u2746"
+ + "\u0C65\u6861\u03C1\u57D6\uD958\uD866\uD73A\uC83C"
+ + "\uFA96\uA798\uECB8\uC7AE\u694B\uABA9\u670A\u47F2"
+ + "\uB522\uE5EE\uBE2B\u8112\u831B\u0E23\uF545\u21CE"
+ + "\u492C\uF9E6\uB628\u1782\u1A8B\uFE8A\u09C9\u874E"
+ + "\uE12E\uE4E0\uEB90\uA41E\u8560\u0025\uF4F1\u940B"
+ + "\uE775\uEF34\u31D4\uD086\u7EAD\uFD29\u303B\u9FF8"
+ + "\uC613\u0605\uC511\u777C\u7A78\u361C\u3959\u1856"
+ + "\uB3B0\u2420\uB292\uA3C0\u4462\u10B4\u8443\u93C2"
+ + "\u4ABD\u8F2D\uBC9C\u6A40\uCFA2\u804F\u1FCA\uAA42";
private static final byte[] S = new byte[256];
-
private static final int[] T0 = new int[256];
-
private static final int[] T1 = new int[256];
-
private static final int[] T2 = new int[256];
-
private static final int[] T3 = new int[256];
-
private static final int[] T4 = new int[256];
-
private static final int[] T5 = new int[256];
-
/**
* Anubis round constants. This is the largest possible considering that we
* always use R values, R = 8 + N, and 4 &lt;= N &lt;= 10.
*/
private static final int[] rc = new int[18];
-
/**
- * KAT vector (from ecb_vk):
- * I=83
+ * KAT vector (from ecb_vk): I=83
* KEY=000000000000000000002000000000000000000000000000
* CT=2E66AB15773F3D32FB6C697509460DF4
*/
- private static final byte[] KAT_KEY = Util.toBytesFromString("000000000000000000002000000000000000000000000000");
-
- private static final byte[] KAT_CT = Util.toBytesFromString("2E66AB15773F3D32FB6C697509460DF4");
-
+ private static final byte[] KAT_KEY =
+ Util.toBytesFromString("000000000000000000002000000000000000000000000000");
+ private static final byte[] KAT_CT =
+ Util.toBytesFromString("2E66AB15773F3D32FB6C697509460DF4");
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
- // Static code - to initialise lookup tables -------------------------------
-
static
{
long time = System.currentTimeMillis();
-
int ROOT = 0x11d; // para. 2.1 [ANUBIS]
int i, s, s2, s4, s6, s8, t;
char c;
@@ -151,213 +122,172 @@ public final class Anubis extends BaseCipher
c = Sd.charAt(i >>> 1);
s = ((i & 1) == 0 ? c >>> 8 : c) & 0xFF;
S[i] = (byte) s;
-
s2 = s << 1;
if (s2 > 0xFF)
- {
- s2 ^= ROOT;
- }
-
+ s2 ^= ROOT;
s4 = s2 << 1;
if (s4 > 0xFF)
- {
- s4 ^= ROOT;
- }
-
+ s4 ^= ROOT;
s6 = s4 ^ s2;
s8 = s4 << 1;
if (s8 > 0xFF)
- {
- s8 ^= ROOT;
- }
-
- T0[i] = s << 24 | s2 << 16 | s4 << 8 | s6;
- T1[i] = s2 << 24 | s << 16 | s6 << 8 | s4;
- T2[i] = s4 << 24 | s6 << 16 | s << 8 | s2;
+ s8 ^= ROOT;
+ T0[i] = s << 24 | s2 << 16 | s4 << 8 | s6;
+ T1[i] = s2 << 24 | s << 16 | s6 << 8 | s4;
+ T2[i] = s4 << 24 | s6 << 16 | s << 8 | s2;
T3[i] = s6 << 24 | s4 << 16 | s2 << 8 | s;
-
- T4[i] = s << 24 | s << 16 | s << 8 | s;
- T5[s] = s << 24 | s2 << 16 | s6 << 8 | s8;
+ T4[i] = s << 24 | s << 16 | s << 8 | s;
+ T5[s] = s << 24 | s2 << 16 | s6 << 8 | s8;
}
-
// compute round constant
for (i = 0, s = 0; i < 18;)
- {
- rc[i++] = S[(s++) & 0xFF] << 24 | (S[(s++) & 0xFF] & 0xFF) << 16
- | (S[(s++) & 0xFF] & 0xFF) << 8 | (S[(s++) & 0xFF] & 0xFF);
- }
-
+ rc[i++] = S[(s++) & 0xFF] << 24
+ | (S[(s++) & 0xFF] & 0xFF) << 16
+ | (S[(s++) & 0xFF] & 0xFF) << 8
+ | (S[(s++) & 0xFF] & 0xFF);
time = System.currentTimeMillis() - time;
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println("==========");
- System.out.println();
- System.out.println("Static data");
- System.out.println();
-
- System.out.println();
- System.out.println("T0[]:");
+ log.fine("Static data");
+ log.fine("T0[]:");
+ StringBuilder sb;
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T0[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T0[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T1[]:");
+ log.fine("T1[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T1[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T1[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T2[]:");
+ log.fine("T2[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T2[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T2[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T3[]:");
+ log.fine("T3[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T3[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T3[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T4[]:");
+ log.fine("T4[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T4[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T4[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T5[]:");
+ log.fine("T5[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (t = 0; t < 4; t++)
- {
- System.out.print("0x" + Util.toString(T5[i * 4 + t]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T5[i * 4 + t])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("rc[]:");
+ log.fine("rc[]:");
for (i = 0; i < 18; i++)
- {
- System.out.println("0x" + Util.toString(rc[i]));
- }
- System.out.println();
-
- System.out.println();
- System.out.println("Total initialization time: " + time + " ms.");
- System.out.println();
+ log.fine("0x" + Util.toString(rc[i]));
+ log.fine("Total initialization time: " + time + " ms.");
}
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Anubis()
{
super(Registry.ANUBIS_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
private static void anubis(byte[] in, int i, byte[] out, int j, int[][] K)
{
// extract encryption round keys
int R = K.length - 1;
int[] Ker = K[0];
-
// mu function + affine key addition
- int a0 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[0];
- int a1 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[1];
- int a2 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[2];
- int a3 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i] & 0xFF))
- ^ Ker[3];
-
+ int a0 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[0];
+ int a1 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[1];
+ int a2 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[2];
+ int a3 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i] & 0xFF) ) ^ Ker[3];
int b0, b1, b2, b3;
// round function
for (int r = 1; r < R; r++)
{
Ker = K[r];
- b0 = T0[a0 >>> 24] ^ T1[a1 >>> 24] ^ T2[a2 >>> 24] ^ T3[a3 >>> 24]
- ^ Ker[0];
- b1 = T0[(a0 >>> 16) & 0xFF] ^ T1[(a1 >>> 16) & 0xFF]
- ^ T2[(a2 >>> 16) & 0xFF] ^ T3[(a3 >>> 16) & 0xFF] ^ Ker[1];
- b2 = T0[(a0 >>> 8) & 0xFF] ^ T1[(a1 >>> 8) & 0xFF]
- ^ T2[(a2 >>> 8) & 0xFF] ^ T3[(a3 >>> 8) & 0xFF] ^ Ker[2];
- b3 = T0[a0 & 0xFF] ^ T1[a1 & 0xFF] ^ T2[a2 & 0xFF] ^ T3[a3 & 0xFF]
- ^ Ker[3];
+ b0 = T0[ a0 >>> 24 ]
+ ^ T1[ a1 >>> 24 ]
+ ^ T2[ a2 >>> 24 ]
+ ^ T3[ a3 >>> 24 ] ^ Ker[0];
+ b1 = T0[(a0 >>> 16) & 0xFF]
+ ^ T1[(a1 >>> 16) & 0xFF]
+ ^ T2[(a2 >>> 16) & 0xFF]
+ ^ T3[(a3 >>> 16) & 0xFF] ^ Ker[1];
+ b2 = T0[(a0 >>> 8) & 0xFF]
+ ^ T1[(a1 >>> 8) & 0xFF]
+ ^ T2[(a2 >>> 8) & 0xFF]
+ ^ T3[(a3 >>> 8) & 0xFF] ^ Ker[2];
+ b3 = T0[ a0 & 0xFF]
+ ^ T1[ a1 & 0xFF]
+ ^ T2[ a2 & 0xFF]
+ ^ T3[ a3 & 0xFF] ^ Ker[3];
a0 = b0;
a1 = b1;
a2 = b2;
a3 = b3;
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("T" + r + "=" + Util.toString(a0)
- + Util.toString(a1) + Util.toString(a2)
- + Util.toString(a3));
- }
+ if (Configuration.DEBUG)
+ log.fine("T" + r + "=" + Util.toString(a0) + Util.toString(a1)
+ + Util.toString(a2) + Util.toString(a3));
}
-
// last round function
Ker = K[R];
int tt = Ker[0];
- out[j++] = (byte) (S[a0 >>> 24] ^ (tt >>> 24));
- out[j++] = (byte) (S[a1 >>> 24] ^ (tt >>> 16));
- out[j++] = (byte) (S[a2 >>> 24] ^ (tt >>> 8));
- out[j++] = (byte) (S[a3 >>> 24] ^ tt);
+ out[j++] = (byte)(S[ a0 >>> 24 ] ^ (tt >>> 24));
+ out[j++] = (byte)(S[ a1 >>> 24 ] ^ (tt >>> 16));
+ out[j++] = (byte)(S[ a2 >>> 24 ] ^ (tt >>> 8));
+ out[j++] = (byte)(S[ a3 >>> 24 ] ^ tt);
tt = Ker[1];
- out[j++] = (byte) (S[(a0 >>> 16) & 0xFF] ^ (tt >>> 24));
- out[j++] = (byte) (S[(a1 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(a2 >>> 16) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[(a3 >>> 16) & 0xFF] ^ tt);
+ out[j++] = (byte)(S[(a0 >>> 16) & 0xFF] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(a1 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(a2 >>> 16) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[(a3 >>> 16) & 0xFF] ^ tt);
tt = Ker[2];
- out[j++] = (byte) (S[(a0 >>> 8) & 0xFF] ^ (tt >>> 24));
- out[j++] = (byte) (S[(a1 >>> 8) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(a2 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[(a3 >>> 8) & 0xFF] ^ tt);
+ out[j++] = (byte)(S[(a0 >>> 8) & 0xFF] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(a1 >>> 8) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(a2 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[(a3 >>> 8) & 0xFF] ^ tt);
tt = Ker[3];
- out[j++] = (byte) (S[a0 & 0xFF] ^ (tt >>> 24));
- out[j++] = (byte) (S[a1 & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[a2 & 0xFF] ^ (tt >>> 8));
- out[j] = (byte) (S[a3 & 0xFF] ^ tt);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("T=" + Util.toString(out, j - 15, 16));
- System.out.println();
- }
+ out[j++] = (byte)(S[ a0 & 0xFF] ^ (tt >>> 24));
+ out[j++] = (byte)(S[ a1 & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[ a2 & 0xFF] ^ (tt >>> 8));
+ out[j ] = (byte)(S[ a3 & 0xFF] ^ tt);
+ if (Configuration.DEBUG)
+ log.fine("T=" + Util.toString(out, j - 15, 16) + "\n");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Anubis result = new Anubis();
@@ -366,12 +296,10 @@ public final class Anubis extends BaseCipher
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_BLOCK_SIZE));
+ al.add(Integer.valueOf(DEFAULT_BLOCK_SIZE));
return Collections.unmodifiableList(al).iterator();
}
@@ -380,17 +308,14 @@ public final class Anubis extends BaseCipher
{
ArrayList al = new ArrayList();
for (int n = 4; n < 10; n++)
- {
- al.add(new Integer(n * 32 / 8));
- }
-
+ al.add(Integer.valueOf(n * 32 / 8));
return Collections.unmodifiableList(al).iterator();
}
/**
- * <p>Expands a user-supplied key material into a session key for a
- * designated <i>block size</i>.</p>
- *
+ * Expands a user-supplied key material into a session key for a designated
+ * <i>block size</i>.
+ *
* @param uk the 32N-bit user-supplied key material; 4 &lt;= N &lt;= 10.
* @param bs the desired block size in bytes.
* @return an Object encapsulating the session key.
@@ -400,95 +325,91 @@ public final class Anubis extends BaseCipher
public Object makeKey(byte[] uk, int bs) throws InvalidKeyException
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (uk == null)
- {
- throw new InvalidKeyException("Empty key");
- }
+ throw new InvalidKeyException("Empty key");
if ((uk.length % 4) != 0)
- {
- throw new InvalidKeyException("Key is not multiple of 32-bit.");
- }
+ throw new InvalidKeyException("Key is not multiple of 32-bit.");
int N = uk.length / 4;
if (N < 4 || N > 10)
- {
- throw new InvalidKeyException("Key is not 32N; 4 <= N <= 10");
- }
+ throw new InvalidKeyException("Key is not 32N; 4 <= N <= 10");
int R = 8 + N;
int[][] Ke = new int[R + 1][4]; // encryption round keys
int[][] Kd = new int[R + 1][4]; // decryption round keys
int[] tk = new int[N];
int[] kk = new int[N];
int r, i, j, k, k0, k1, k2, k3, tt;
-
// apply mu to k0
for (r = 0, i = 0; r < N;)
- {
- tk[r++] = uk[i++] << 24 | (uk[i++] & 0xFF) << 16
- | (uk[i++] & 0xFF) << 8 | (uk[i++] & 0xFF);
- }
+ tk[r++] = uk[i++] << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
for (r = 0; r <= R; r++)
{
if (r > 0)
{
// psi = key evolution function
- kk[0] = T0[(tk[0] >>> 24)] ^ T1[(tk[N - 1] >>> 16) & 0xFF]
- ^ T2[(tk[N - 2] >>> 8) & 0xFF] ^ T3[tk[N - 3] & 0xFF];
- kk[1] = T0[(tk[1] >>> 24)] ^ T1[(tk[0] >>> 16) & 0xFF]
- ^ T2[(tk[N - 1] >>> 8) & 0xFF] ^ T3[tk[N - 2] & 0xFF];
- kk[2] = T0[(tk[2] >>> 24)] ^ T1[(tk[1] >>> 16) & 0xFF]
- ^ T2[(tk[0] >>> 8) & 0xFF] ^ T3[tk[N - 1] & 0xFF];
- kk[3] = T0[(tk[3] >>> 24)] ^ T1[(tk[2] >>> 16) & 0xFF]
- ^ T2[(tk[1] >>> 8) & 0xFF] ^ T3[tk[0] & 0xFF];
-
+ kk[0] = T0[(tk[0 ] >>> 24) ]
+ ^ T1[(tk[N - 1] >>> 16) & 0xFF]
+ ^ T2[(tk[N - 2] >>> 8) & 0xFF]
+ ^ T3[ tk[N - 3] & 0xFF];
+ kk[1] = T0[(tk[1 ] >>> 24) ]
+ ^ T1[(tk[0 ] >>> 16) & 0xFF]
+ ^ T2[(tk[N - 1] >>> 8) & 0xFF]
+ ^ T3[ tk[N - 2] & 0xFF];
+ kk[2] = T0[(tk[2 ] >>> 24) ]
+ ^ T1[(tk[1 ] >>> 16) & 0xFF]
+ ^ T2[(tk[0 ] >>> 8) & 0xFF]
+ ^ T3[ tk[N - 1] & 0xFF];
+ kk[3] = T0[(tk[3 ] >>> 24) ]
+ ^ T1[(tk[2 ] >>> 16) & 0xFF]
+ ^ T2[(tk[1 ] >>> 8) & 0xFF]
+ ^ T3[ tk[0 ] & 0xFF];
for (i = 4; i < N; i++)
- {
- kk[i] = T0[tk[i] >>> 24] ^ T1[(tk[i - 1] >>> 16) & 0xFF]
- ^ T2[(tk[i - 2] >>> 8) & 0xFF] ^ T3[tk[i - 3] & 0xFF];
- }
+ kk[i] = T0[ tk[i ] >>> 24 ]
+ ^ T1[(tk[i - 1] >>> 16) & 0xFF]
+ ^ T2[(tk[i - 2] >>> 8) & 0xFF]
+ ^ T3[ tk[i - 3] & 0xFF];
// apply sigma (affine addition) to round constant
tk[0] = rc[r - 1] ^ kk[0];
for (i = 1; i < N; i++)
- {
- tk[i] = kk[i];
- }
+ tk[i] = kk[i];
}
-
// phi = key selection function
tt = tk[N - 1];
- k0 = T4[tt >>> 24];
+ k0 = T4[ tt >>> 24 ];
k1 = T4[(tt >>> 16) & 0xFF];
- k2 = T4[(tt >>> 8) & 0xFF];
- k3 = T4[tt & 0xFF];
-
+ k2 = T4[(tt >>> 8) & 0xFF];
+ k3 = T4[ tt & 0xFF];
for (k = N - 2; k >= 0; k--)
{
tt = tk[k];
- k0 = T4[tt >>> 24] ^ (T5[(k0 >>> 24) & 0xFF] & 0xFF000000)
- ^ (T5[(k0 >>> 16) & 0xFF] & 0x00FF0000)
- ^ (T5[(k0 >>> 8) & 0xFF] & 0x0000FF00)
- ^ (T5[k0 & 0xFF] & 0x000000FF);
- k1 = T4[(tt >>> 16) & 0xFF] ^ (T5[(k1 >>> 24) & 0xFF] & 0xFF000000)
- ^ (T5[(k1 >>> 16) & 0xFF] & 0x00FF0000)
- ^ (T5[(k1 >>> 8) & 0xFF] & 0x0000FF00)
- ^ (T5[k1 & 0xFF] & 0x000000FF);
- k2 = T4[(tt >>> 8) & 0xFF] ^ (T5[(k2 >>> 24) & 0xFF] & 0xFF000000)
- ^ (T5[(k2 >>> 16) & 0xFF] & 0x00FF0000)
- ^ (T5[(k2 >>> 8) & 0xFF] & 0x0000FF00)
- ^ (T5[(k2) & 0xFF] & 0x000000FF);
- k3 = T4[tt & 0xFF] ^ (T5[(k3 >>> 24) & 0xFF] & 0xFF000000)
- ^ (T5[(k3 >>> 16) & 0xFF] & 0x00FF0000)
- ^ (T5[(k3 >>> 8) & 0xFF] & 0x0000FF00)
- ^ (T5[k3 & 0xFF] & 0x000000FF);
+ k0 = T4[ tt >>> 24 ]
+ ^ (T5[(k0 >>> 24) & 0xFF] & 0xFF000000)
+ ^ (T5[(k0 >>> 16) & 0xFF] & 0x00FF0000)
+ ^ (T5[(k0 >>> 8) & 0xFF] & 0x0000FF00)
+ ^ (T5 [k0 & 0xFF] & 0x000000FF);
+ k1 = T4[(tt >>> 16) & 0xFF]
+ ^ (T5[(k1 >>> 24) & 0xFF] & 0xFF000000)
+ ^ (T5[(k1 >>> 16) & 0xFF] & 0x00FF0000)
+ ^ (T5[(k1 >>> 8) & 0xFF] & 0x0000FF00)
+ ^ (T5[ k1 & 0xFF] & 0x000000FF);
+ k2 = T4[(tt >>> 8) & 0xFF]
+ ^ (T5[(k2 >>> 24) & 0xFF] & 0xFF000000)
+ ^ (T5[(k2 >>> 16) & 0xFF] & 0x00FF0000)
+ ^ (T5[(k2 >>> 8) & 0xFF] & 0x0000FF00)
+ ^ (T5[ k2 & 0xFF] & 0x000000FF);
+ k3 = T4[ tt & 0xFF]
+ ^ (T5[(k3 >>> 24) & 0xFF] & 0xFF000000)
+ ^ (T5[(k3 >>> 16) & 0xFF] & 0x00FF0000)
+ ^ (T5[(k3 >>> 8) & 0xFF] & 0x0000FF00)
+ ^ (T5[ k3 & 0xFF] & 0x000000FF);
}
-
Ke[r][0] = k0;
Ke[r][1] = k1;
Ke[r][2] = k2;
Ke[r][3] = k3;
-
if (r == 0 || r == R)
{
Kd[R - r][0] = k0;
@@ -498,72 +419,61 @@ public final class Anubis extends BaseCipher
}
else
{
- Kd[R - r][0] = T0[S[k0 >>> 24] & 0xFF]
- ^ T1[S[(k0 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(k0 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[k0 & 0xFF] & 0xFF];
- Kd[R - r][1] = T0[S[k1 >>> 24] & 0xFF]
- ^ T1[S[(k1 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(k1 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[k1 & 0xFF] & 0xFF];
- Kd[R - r][2] = T0[S[k2 >>> 24] & 0xFF]
- ^ T1[S[(k2 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(k2 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[k2 & 0xFF] & 0xFF];
- Kd[R - r][3] = T0[S[k3 >>> 24] & 0xFF]
- ^ T1[S[(k3 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(k3 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[k3 & 0xFF] & 0xFF];
+ Kd[R - r][0] = T0[S[ k0 >>> 24 ] & 0xFF]
+ ^ T1[S[(k0 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(k0 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ k0 & 0xFF] & 0xFF];
+ Kd[R - r][1] = T0[S[ k1 >>> 24 ] & 0xFF]
+ ^ T1[S[(k1 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(k1 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ k1 & 0xFF] & 0xFF];
+ Kd[R - r][2] = T0[S[ k2 >>> 24 ] & 0xFF]
+ ^ T1[S[(k2 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(k2 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ k2 & 0xFF] & 0xFF];
+ Kd[R - r][3] = T0[S[ k3 >>> 24 ] & 0xFF]
+ ^ T1[S[(k3 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(k3 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ k3 & 0xFF] & 0xFF];
}
}
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println();
- System.out.println("Key schedule");
- System.out.println();
- System.out.println("Ke[]:");
+ log.fine("Key schedule");
+ log.fine("Ke[]:");
+ StringBuilder sb;
for (r = 0; r < R + 1; r++)
{
- System.out.print("#" + r + ": ");
+ sb = new StringBuilder("#").append(r).append(": ");
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(Ke[r][j]) + ", ");
- System.out.println();
+ sb.append("0x").append(Util.toString(Ke[r][j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("Kd[]:");
+ log.fine("Kd[]:");
for (r = 0; r < R + 1; r++)
{
- System.out.print("#" + r + ": ");
+ sb = new StringBuilder("#").append(r).append(": ");
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(Kd[r][j]) + ", ");
- System.out.println();
+ sb.append("0x").append(Util.toString(Kd[r][j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
}
-
return new Object[] { Ke, Kd };
}
public void encrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[0];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[0];
anubis(in, i, out, j, K);
}
public void decrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[1];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[1];
anubis(in, i, out, j, K);
}
@@ -573,11 +483,9 @@ public final class Anubis extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/BaseCipher.java b/libjava/classpath/gnu/javax/crypto/cipher/BaseCipher.java
index 9d62311ed58..a5bbe698769 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/BaseCipher.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/BaseCipher.java
@@ -38,47 +38,39 @@ exception statement from your version. */
package gnu.javax.crypto.cipher;
-import gnu.java.security.util.Util;
+import gnu.java.security.Configuration;
import java.security.InvalidKeyException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
- * <p>A basic abstract class to facilitate implementing symmetric key block
- * ciphers.</p>
+ * A basic abstract class to facilitate implementing symmetric key block
+ * ciphers.
*/
-public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
+public abstract class BaseCipher
+ implements IBlockCipher, IBlockCipherSpi
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(BaseCipher.class.getName());
/** The canonical name prefix of the cipher. */
protected String name;
-
/** The default block size, in bytes. */
protected int defaultBlockSize;
-
/** The default key size, in bytes. */
protected int defaultKeySize;
-
/** The current block size, in bytes. */
protected int currentBlockSize;
-
/** The session key for this instance. */
protected transient Object currentKey;
-
/** The instance lock. */
protected Object lock = new Object();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name prefix of this instance.
* @param defaultBlockSize the default block size in bytes.
* @param defaultKeySize the default key size in bytes.
@@ -92,27 +84,15 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
this.defaultKeySize = defaultKeySize;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IBlockCipher interface implementation -----------------------------------
-
public abstract Object clone();
public String name()
{
StringBuffer sb = new StringBuffer(name).append('-');
if (currentKey == null)
- {
- sb.append(String.valueOf(8 * defaultBlockSize));
- }
+ sb.append(String.valueOf(8 * defaultBlockSize));
else
- {
- sb.append(String.valueOf(8 * currentBlockSize));
- }
+ sb.append(String.valueOf(8 * currentBlockSize));
return sb.toString();
}
@@ -131,17 +111,13 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
synchronized (lock)
{
if (currentKey != null)
- {
- throw new IllegalStateException();
- }
-
+ throw new IllegalStateException();
Integer bs = (Integer) attributes.get(CIPHER_BLOCK_SIZE);
- if (bs == null)
- { // no block size was specified.
- if (currentBlockSize == 0)
- { // happy birthday
- currentBlockSize = defaultBlockSize;
- } // else it's a clone. use as is
+ if (bs == null) // no block size was specified
+ {
+ if (currentBlockSize == 0) // happy birthday
+ currentBlockSize = defaultBlockSize;
+ // else it's a clone. use as is
}
else
{
@@ -153,17 +129,11 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
{
ok = (currentBlockSize == ((Integer) it.next()).intValue());
if (ok)
- {
- break;
- }
- }
- if (!ok)
- {
- throw new IllegalArgumentException(
- IBlockCipher.CIPHER_BLOCK_SIZE);
+ break;
}
+ if (! ok)
+ throw new IllegalArgumentException(IBlockCipher.CIPHER_BLOCK_SIZE);
}
-
byte[] k = (byte[]) attributes.get(KEY_MATERIAL);
currentKey = makeKey(k, currentBlockSize);
}
@@ -172,9 +142,7 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
public int currentBlockSize()
{
if (currentKey == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return currentBlockSize;
}
@@ -182,7 +150,6 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
{
synchronized (lock)
{
- // currentBlockSize = 0;
currentKey = null;
}
}
@@ -193,10 +160,7 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
synchronized (lock)
{
if (currentKey == null)
- {
- throw new IllegalStateException();
- }
-
+ throw new IllegalStateException();
encrypt(in, inOffset, out, outOffset, currentKey, currentBlockSize);
}
}
@@ -207,10 +171,7 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
synchronized (lock)
{
if (currentKey == null)
- {
- throw new IllegalStateException();
- }
-
+ throw new IllegalStateException();
decrypt(in, inOffset, out, outOffset, currentKey, currentBlockSize);
}
}
@@ -219,25 +180,17 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
{
int ks;
Iterator bit;
-
// do symmetry tests for all block-size/key-size combos
for (Iterator kit = keySizes(); kit.hasNext();)
{
ks = ((Integer) kit.next()).intValue();
for (bit = blockSizes(); bit.hasNext();)
- {
- if (!testSymmetry(ks, ((Integer) bit.next()).intValue()))
- {
- return false;
- }
- }
+ if (! testSymmetry(ks, ((Integer) bit.next()).intValue()))
+ return false;
}
-
return true;
}
- // own methods -------------------------------------------------------------
-
private boolean testSymmetry(int ks, int bs)
{
try
@@ -248,24 +201,18 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
byte[] cpt = new byte[bs];
int i;
for (i = 0; i < ks; i++)
- {
- kb[i] = (byte) i;
- }
+ kb[i] = (byte) i;
for (i = 0; i < bs; i++)
- {
- pt[i] = (byte) i;
- }
-
+ pt[i] = (byte) i;
Object k = makeKey(kb, bs);
encrypt(pt, 0, ct, 0, k, bs);
decrypt(ct, 0, cpt, 0, k, bs);
-
return Arrays.equals(pt, cpt);
-
}
catch (Exception x)
{
- x.printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in testSymmetry() for " + name(), x);
return false;
}
}
@@ -281,24 +228,20 @@ public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
{
int bs = pt.length;
byte[] t = new byte[bs];
-
Object k = makeKey(kb, bs);
-
// test encryption
encrypt(pt, 0, t, 0, k, bs);
- if (!Arrays.equals(t, ct))
- {
- return false;
- }
+ if (! Arrays.equals(t, ct))
+ return false;
// test decryption
decrypt(t, 0, t, 0, k, bs);
return Arrays.equals(t, pt);
-
}
catch (Exception x)
{
- x.printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in testKat() for " + name(), x);
return false;
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java b/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
index ca1fdfbd394..68722e913c4 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
@@ -51,370 +51,210 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * Blowfish is a 16-round, 64-bit Feistel cipher designed by Bruce
- * Schneier. It accepts a variable-length key of up to 448 bits.
- *
- * <p>References:</p>
+ * Blowfish is a 16-round, 64-bit Feistel cipher designed by Bruce Schneier. It
+ * accepts a variable-length key of up to 448 bits.
+ * <p>
+ * References:
* <ol>
- * <li>Schneier, Bruce: <i>Applied Cryptography</i>, Second Edition,
- * 336--339, 647--654 (1996 Bruce Schneier).</li>
- * <li><a href="http://www.counterpane.com/blowfish.html">The
- * Blowfish Encryption Algorithm.</a></li>
+ * <li>Schneier, Bruce: <i>Applied Cryptography</i>, Second Edition, 336--339,
+ * 647--654 (1996 Bruce Schneier).</li>
+ * <li><a href="http://www.counterpane.com/blowfish.html">The Blowfish
+ * Encryption Algorithm.</a></li>
* </ol>
*/
-public class Blowfish extends BaseCipher
+public class Blowfish
+ extends BaseCipher
{
-
- // Constants and variables
- // -----------------------------------------------------------------
-
private static final int DEFAULT_BLOCK_SIZE = 8;
-
private static final int DEFAULT_KEY_SIZE = 8;
-
private static final int MAX_KEY_LENGTH = 56;
-
/** Initial value of the p-array. */
- private static final int[] P = { 0x243f6a88, 0x85a308d3, 0x13198a2e,
- 0x03707344, 0xa4093822, 0x299f31d0,
- 0x082efa98, 0xec4e6c89, 0x452821e6,
- 0x38d01377, 0xbe5466cf, 0x34e90c6c,
- 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5,
- 0xb5470917, 0x9216d5d9, 0x8979fb1b };
-
+ private static final int[] P = {
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
+ 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b };
/** Initial value of S-box 1. */
- static final int[] KS0 = { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
- 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
- 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
- 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
- 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
- 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
- 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
- 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
- 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
- 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
- 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
- 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
- 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
- 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
- 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
- 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
- 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
- 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
- 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
- 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
- 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
- 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
- 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
- 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
- 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
- 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
- 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
- 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
- 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
- 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
- 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
- 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
- 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
- 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
- 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
- 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
- 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
- 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
- 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
- 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
- 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
- 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
- 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
- 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
- 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
- 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
- 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
- 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
- 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
- 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
- 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
- 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
- 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
- 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a };
-
+ static final int[] KS0 = {
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
+ 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
+ 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
+ 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
+ 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
+ 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
+ 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
+ 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
+ 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
+ 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
+ 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
+ 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
+ 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
+ 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
+ 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
+ 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
+ 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
+ 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
+ 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
+ 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
+ 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
+ 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a };
/** Initial value of S-box 2. */
- private static final int[] KS1 = { 0x4b7a70e9, 0xb5b32944, 0xdb75092e,
- 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
- 0x9cee60b8, 0x8fedb266, 0xecaa8c71,
- 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340,
- 0xe4183a3e, 0x3f54989a, 0x5b429d65,
- 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07,
- 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
- 0x4cdd2086, 0x8470eb26, 0x6382e9c6,
- 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
- 0x3c971814, 0x6b6a70a1, 0x687f3584,
- 0x52a0e286, 0xb79c5305, 0xaa500737,
- 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec,
- 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
- 0xf01c1f04, 0x0200b3ff, 0xae0cf51a,
- 0x3cb574b2, 0x25837a58, 0xdc0921bd,
- 0xd19113f9, 0x7ca92ff6, 0x94324773,
- 0x22f54701, 0x3ae5e581, 0x37c2dadc,
- 0xc8b57634, 0x9af3dda7, 0xa9446146,
- 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
- 0xe238cd99, 0x3bea0e2f, 0x3280bba1,
- 0x183eb331, 0x4e548b38, 0x4f6db908,
- 0x6f420d03, 0xf60a04bf, 0x2cb81290,
- 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12,
- 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
- 0x501adde6, 0x9f84cd87, 0x7a584718,
- 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
- 0xec7aec3a, 0xdb851dfa, 0x63094366,
- 0xc464c3d2, 0xef1c1847, 0x3215d908,
- 0xdd433b37, 0x24c2ba16, 0x12a14d43,
- 0x2a65c451, 0x50940002, 0x133ae4dd,
- 0x71dff89e, 0x10314e55, 0x81ac77d6,
- 0x5f11199b, 0x043556f1, 0xd7a3c76b,
- 0x3c11183b, 0x5924a509, 0xf28fe6ed,
- 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
- 0x86e34570, 0xeae96fb1, 0x860e5e0a,
- 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
- 0x2965dcb9, 0x99e71d0f, 0x803e89d6,
- 0x5266c825, 0x2e4cc978, 0x9c10b36a,
- 0xc6150eba, 0x94e2ea78, 0xa5fc3c53,
- 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
- 0x1939260f, 0x19c27960, 0x5223a708,
- 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1,
- 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
- 0x65582185, 0x68ab9802, 0xeecea50f,
- 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
- 0x1521b628, 0x29076170, 0xecdd4775,
- 0x619f1510, 0x13cca830, 0xeb61bd96,
- 0x0334fe1e, 0xaa0363cf, 0xb5735c90,
- 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
- 0xeecc86bc, 0x60622ca7, 0x9cab5cab,
- 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
- 0xa02369b9, 0x655abb50, 0x40685a32,
- 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
- 0x9b540b19, 0x875fa099, 0x95f7997e,
- 0x623d7da8, 0xf837889a, 0x97e32d77,
- 0x11ed935f, 0x16681281, 0x0e358829,
- 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
- 0x57f584a5, 0x1b227263, 0x9b83c3ff,
- 0x1ac24696, 0xcdb30aeb, 0x532e3054,
- 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef,
- 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14,
- 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
- 0xdb6c4f15, 0xfacb4fd0, 0xc742f442,
- 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
- 0xd81e799e, 0x86854dc7, 0xe44b476a,
- 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
- 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3,
- 0x69cb7492, 0x47848a0b, 0x5692b285,
- 0x095bbf00, 0xad19489d, 0x1462b174,
- 0x23820e00, 0x58428d2a, 0x0c55f5ea,
- 0x1dadf43e, 0x233f7061, 0x3372f092,
- 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
- 0x7cde3759, 0xcbee7460, 0x4085f2a7,
- 0xce77326e, 0xa6078084, 0x19f8509e,
- 0xe8efd855, 0x61d99735, 0xa969a7aa,
- 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
- 0x9e447a2e, 0xc3453484, 0xfdd56705,
- 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
- 0x675fda79, 0xe3674340, 0xc5c43465,
- 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b,
- 0xdb83adf7 };
-
+ private static final int[] KS1 = {
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
+ 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
+ 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
+ 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
+ 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
+ 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
+ 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
+ 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
+ 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
+ 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
+ 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
+ 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
+ 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
+ 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
+ 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
+ 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
+ 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
+ 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
+ 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
+ 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
+ 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
+ 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 };
/** Initial value of S-box 3. */
- private static final int[] KS2 = { 0xe93d5a68, 0x948140f7, 0xf64c261c,
- 0x94692934, 0x411520f7, 0x7602d4f7,
- 0xbcf46b2e, 0xd4a20068, 0xd4082471,
- 0x3320f46a, 0x43b7d4b7, 0x500061af,
- 0x1e39f62e, 0x97244546, 0x14214f74,
- 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
- 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec,
- 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
- 0x96eb27b3, 0x55fd3941, 0xda2547e6,
- 0xabca0a9a, 0x28507825, 0x530429f4,
- 0x0a2c86da, 0xe9b66dfb, 0x68dc1462,
- 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006,
- 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
- 0xce78a399, 0x406b2a42, 0x20fe9e35,
- 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
- 0x1dc9faf7, 0x4b6d1856, 0x26a36631,
- 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
- 0x6841e7f7, 0xca7820fb, 0xfb0af54e,
- 0xd8feb397, 0x454056ac, 0xba489527,
- 0x55533a3a, 0x20838d87, 0xfe6ba9b7,
- 0xd096954b, 0x55a867bc, 0xa1159a58,
- 0xcca92963, 0x99e1db33, 0xa62a4a56,
- 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
- 0xfdf8e802, 0x04272f70, 0x80bb155c,
- 0x05282ce3, 0x95c11548, 0xe4c66d22,
- 0x48c1133f, 0xc70f86dc, 0x07f9c9ee,
- 0x41041f0f, 0x404779a4, 0x5d886e17,
- 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f,
- 0x41113564, 0x257b7834, 0x602a9c60,
- 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2,
- 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62,
- 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
- 0xde720c8c, 0x2da2f728, 0xd0127845,
- 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
- 0x5449a36f, 0x877d48fa, 0xc39dfd27,
- 0xf33e8d1e, 0x0a476341, 0x992eff74,
- 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60,
- 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
- 0xc67b5510, 0x6d672c37, 0x2765d43b,
- 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
- 0xb5390f92, 0x690fed0b, 0x667b9ffb,
- 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
- 0xbb132f88, 0x515bad24, 0x7b9479bf,
- 0x763bd6eb, 0x37392eb3, 0xcc115979,
- 0x8026e297, 0xf42e312d, 0x6842ada7,
- 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
- 0x6a124237, 0xb79251e7, 0x06a1bbe6,
- 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
- 0x3d25bdd8, 0xe2e1c3c9, 0x44421659,
- 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988,
- 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
- 0x60787bf8, 0x6003604d, 0xd1fd8346,
- 0xf6381fb0, 0x7745ae04, 0xd736fccc,
- 0x83426b33, 0xf01eab71, 0xb0804187,
- 0x3c005e5f, 0x77a057be, 0xbde8ae24,
- 0x55464299, 0xbf582e61, 0x4e58f48f,
- 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
- 0x5366f9c3, 0xc8b38e74, 0xb475f255,
- 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
- 0x846a0e79, 0x915f95e2, 0x466e598e,
- 0x20b45770, 0x8cd55591, 0xc902de4c,
- 0xb90bace1, 0xbb8205d0, 0x11a86248,
- 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
- 0x662d09a1, 0xc4324633, 0xe85a1f02,
- 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
- 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f,
- 0x2868f169, 0xdcb7da83, 0x573906fe,
- 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01,
- 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06,
- 0x61a806b5, 0xf0177a28, 0xc0f586e0,
- 0x006058aa, 0x30dc7d62, 0x11e69ed7,
- 0x2338ea63, 0x53c2dd94, 0xc2c21634,
- 0xbbcbee56, 0x90bcb6de, 0xebfc7da1,
- 0xce591d76, 0x6f05e409, 0x4b7c0188,
- 0x39720a3d, 0x7c927c24, 0x86e3725f,
- 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
- 0xed545578, 0x08fca5b5, 0xd83d7cd3,
- 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
- 0xa28514d9, 0x6c51133c, 0x6fd5c7e7,
- 0x56e14ec4, 0x362abfce, 0xddc6c837,
- 0xd79a3234, 0x92638212, 0x670efa8e,
- 0x406000e0 };
-
+ private static final int[] KS2 = {
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
+ 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
+ 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
+ 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
+ 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
+ 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
+ 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
+ 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
+ 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
+ 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
+ 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
+ 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
+ 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
+ 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
+ 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
+ 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
+ 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
+ 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
+ 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
+ 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
+ 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
+ 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 };
/** Initial value of S-box 4. */
- private static final int[] KS3 = { 0x3a39ce37, 0xd3faf5cf, 0xabc27737,
- 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
- 0xd3822740, 0x99bc9bbe, 0xd5118e9d,
- 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
- 0xb78c1b6b, 0x21a19045, 0xb26eb1be,
- 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
- 0xc6a376d2, 0x6549c2c8, 0x530ff8ee,
- 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8,
- 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
- 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8,
- 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
- 0x83c061ba, 0x9be96a4d, 0x8fe51550,
- 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
- 0x4ba99586, 0xef5562e9, 0xc72fefd3,
- 0xf752f7da, 0x3f046f69, 0x77fa0a59,
- 0x80e4a915, 0x87b08601, 0x9b09e6ad,
- 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
- 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a,
- 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472,
- 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
- 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d,
- 0x283b57cc, 0xf8d56629, 0x79132e28,
- 0x785f0191, 0xed756055, 0xf7960e44,
- 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
- 0x03a16125, 0x0564f0bd, 0xc3eb9e15,
- 0x3c9057a2, 0x97271aec, 0xa93a072a,
- 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb,
- 0x26dcf319, 0x7533d928, 0xb155fdf5,
- 0x03563482, 0x8aba3cbb, 0x28517711,
- 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862,
- 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
- 0x5121ce64, 0x774fbe32, 0xa8b6e37e,
- 0xc3293d46, 0x48de5369, 0x6413e680,
- 0xa2ae0810, 0xdd6db224, 0x69852dfd,
- 0x09072166, 0xb39a460a, 0x6445c0dd,
- 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd,
- 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44,
- 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
- 0x8d6612ae, 0xbf3c6f47, 0xd29be463,
- 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671,
- 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
- 0x34d2466a, 0x0115af84, 0xe1b00428,
- 0x95983a1d, 0x06b89fb4, 0xce6ea048,
- 0x6f3f3b82, 0x3520ab82, 0x011a1d4b,
- 0x277227f8, 0x611560b1, 0xe7933fdc,
- 0xbb3a792b, 0x344525bd, 0xa08839e1,
- 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
- 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3,
- 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
- 0xd0dadecb, 0xd50ada38, 0x0339c32a,
- 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff,
- 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
- 0x0f91fc71, 0x9b941525, 0xfae59361,
- 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065,
- 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
- 0x4c98a0be, 0x3278e964, 0x9f1f9532,
- 0xe0d392df, 0xd3a0342b, 0x8971f21e,
- 0x1b0a7441, 0x4ba3348c, 0xc5be7120,
- 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
- 0xe60b6f47, 0x0fe3f11d, 0xe54cda54,
- 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5,
- 0xf6fb2299, 0xf523f357, 0xa6327623,
- 0x93a83531, 0x56cccd02, 0xacf08162,
- 0x5a75ebb5, 0x6e163697, 0x88d273cc,
- 0xde966292, 0x81b949d0, 0x4c50901b,
- 0x71c65614, 0xe6c6c7bd, 0x327a140a,
- 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd,
- 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
- 0x71126905, 0xb2040222, 0xb6cbcf7c,
- 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
- 0x38abbd60, 0x2547adf0, 0xba38209c,
- 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0,
- 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
- 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869,
- 0xa65cdea0, 0x3f09252d, 0xc208e69f,
- 0xb74e6132, 0xce77e25b, 0x578fdfe3,
- 0x3ac372e6 };
-
+ private static final int[] KS3 = {
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
+ 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
+ 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
+ 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
+ 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
+ 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
+ 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
+ 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
+ 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
+ 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
+ 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
+ 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
+ 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
+ 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
+ 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
+ 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
+ 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
+ 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
+ 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
+ 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
+ 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
+ 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 };
/** Cache of the self test. */
private static Boolean valid;
-
/**
* Test vector, as published in
* href="http://www.counterpane.com/vectors.txt">http://www.counterpane.com/vectors.txt</a>.
@@ -424,20 +264,13 @@ public class Blowfish extends BaseCipher
* CT=4EF997456198DD78
*/
private static final byte[] TV_KEY = Util.toBytesFromString("0000000000000000");
-
private static final byte[] TV_CT = Util.toBytesFromString("4EF997456198DD78");
- // Constructors
- // -----------------------------------------------------------------------
-
public Blowfish()
{
super(Registry.BLOWFISH_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Clonable interface implementation.
- // -----------------------------------------------------------------------
-
public Object clone()
{
Blowfish result = new Blowfish();
@@ -445,36 +278,14 @@ public class Blowfish extends BaseCipher
return result;
}
- // Implementations of abstract methods from BaseCipher
- // -----------------------------------------------------------------------
-
public Iterator keySizes()
{
return new Sequence(8, MAX_KEY_LENGTH, 8).iterator();
- // return new Iterator() {
- // private int i = 0;
-
- // public boolean hasNext() {
- // return i <= MAX_KEY_LENGTH-8;
- // }
-
- // public Object next() {
- // if (hasNext()) {
- // i += 8;
- // return new Integer(i);
- // }
- // return null;
- // }
-
- // public void remove() {
- // throw new UnsupportedOperationException();
- // }
- // };
}
public Iterator blockSizes()
{
- return Collections.singleton(new Integer(DEFAULT_BLOCK_SIZE)).iterator();
+ return Collections.singleton(Integer.valueOf(DEFAULT_BLOCK_SIZE)).iterator();
}
public Object makeKey(byte[] k, int bs)
@@ -485,7 +296,6 @@ public class Blowfish extends BaseCipher
System.arraycopy(KS1, 0, ctx.s1, 0, KS1.length);
System.arraycopy(KS2, 0, ctx.s2, 0, KS2.length);
System.arraycopy(KS3, 0, ctx.s3, 0, KS3.length);
-
// XOR the key with the P-box
int l = 0;
for (int i = 0; i < ctx.p.length; i++)
@@ -495,13 +305,10 @@ public class Blowfish extends BaseCipher
{
data = (data << 8) | (k[l++] & 0xff);
if (l >= k.length)
- {
- l = 0;
- }
+ l = 0;
}
ctx.p[i] ^= data;
}
-
// We swap the left and right words here only, so we can avoid
// swapping altogether during encryption/decryption.
int t;
@@ -559,18 +366,22 @@ public class Blowfish extends BaseCipher
public void encrypt(byte[] in, int i, byte[] out, int o, Object k, int bs)
{
Block x = new Block();
- x.left = (in[i] & 0xff) << 24 | (in[i + 1] & 0xff) << 16
- | (in[i + 2] & 0xff) << 8 | (in[i + 3] & 0xff);
- x.right = (in[i + 4] & 0xff) << 24 | (in[i + 5] & 0xff) << 16
- | (in[i + 6] & 0xff) << 8 | (in[i + 7] & 0xff);
+ x.left = (in[i ] & 0xff) << 24
+ | (in[i + 1] & 0xff) << 16
+ | (in[i + 2] & 0xff) << 8
+ | (in[i + 3] & 0xff);
+ x.right = (in[i + 4] & 0xff) << 24
+ | (in[i + 5] & 0xff) << 16
+ | (in[i + 6] & 0xff) << 8
+ | (in[i + 7] & 0xff);
blowfishEncrypt(x, (Context) k);
- out[o] = (byte) (x.right >>> 24);
- out[o + 1] = (byte) (x.right >>> 16);
- out[o + 2] = (byte) (x.right >>> 8);
+ out[o ] = (byte)(x.right >>> 24);
+ out[o + 1] = (byte)(x.right >>> 16);
+ out[o + 2] = (byte)(x.right >>> 8);
out[o + 3] = (byte) x.right;
- out[o + 4] = (byte) (x.left >>> 24);
- out[o + 5] = (byte) (x.left >>> 16);
- out[o + 6] = (byte) (x.left >>> 8);
+ out[o + 4] = (byte)(x.left >>> 24);
+ out[o + 5] = (byte)(x.left >>> 16);
+ out[o + 6] = (byte)(x.left >>> 8);
out[o + 7] = (byte) x.left;
x.left = x.right = 0;
}
@@ -578,63 +389,96 @@ public class Blowfish extends BaseCipher
public void decrypt(byte[] in, int i, byte[] out, int o, Object k, int bs)
{
Block x = new Block();
- x.left = (in[i] & 0xff) << 24 | (in[i + 1] & 0xff) << 16
- | (in[i + 2] & 0xff) << 8 | (in[i + 3] & 0xff);
- x.right = (in[i + 4] & 0xff) << 24 | (in[i + 5] & 0xff) << 16
- | (in[i + 6] & 0xff) << 8 | (in[i + 7] & 0xff);
+ x.left = (in[i ] & 0xff) << 24
+ | (in[i + 1] & 0xff) << 16
+ | (in[i + 2] & 0xff) << 8
+ | (in[i + 3] & 0xff);
+ x.right = (in[i + 4] & 0xff) << 24
+ | (in[i + 5] & 0xff) << 16
+ | (in[i + 6] & 0xff) << 8
+ | (in[i + 7] & 0xff);
blowfishDecrypt(x, (Context) k);
- out[o] = (byte) (x.right >>> 24);
- out[o + 1] = (byte) (x.right >>> 16);
- out[o + 2] = (byte) (x.right >>> 8);
+ out[o ] = (byte)(x.right >>> 24);
+ out[o + 1] = (byte)(x.right >>> 16);
+ out[o + 2] = (byte)(x.right >>> 8);
out[o + 3] = (byte) x.right;
- out[o + 4] = (byte) (x.left >>> 24);
- out[o + 5] = (byte) (x.left >>> 16);
- out[o + 6] = (byte) (x.left >>> 8);
+ out[o + 4] = (byte)(x.left >>> 24);
+ out[o + 5] = (byte)(x.left >>> 16);
+ out[o + 6] = (byte)(x.left >>> 8);
out[o + 7] = (byte) x.left;
x.left = x.right = 0;
}
- // Own methods
- // -----------------------------------------------------------------
-
/** Encrypt a single pair of 32-bit integers. */
private void blowfishEncrypt(Block x, Context ctx)
{
int[] p = ctx.p;
int[] s0 = ctx.s0, s1 = ctx.s1, s2 = ctx.s2, s3 = ctx.s3;
x.left ^= p[0];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[1];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[2];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[3];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[4];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[5];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[6];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[7];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[8];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[9];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[10];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[11];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[12];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[13];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[14];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[15];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[16];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[1];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[2];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[3];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[4];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[5];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[6];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[7];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[8];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[9];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[10];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[11];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[12];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[13];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[14];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[15];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[16];
x.right ^= p[17];
}
@@ -644,38 +488,70 @@ public class Blowfish extends BaseCipher
int[] p = ctx.p;
int[] s0 = ctx.s0, s1 = ctx.s1, s2 = ctx.s2, s3 = ctx.s3;
x.left ^= p[17];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[16];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[15];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[14];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[13];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[12];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[11];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[10];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[9];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[8];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[7];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[6];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[5];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[4];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[3];
- x.right ^= ((s0[x.left >>> 24] + s1[x.left >>> 16 & 0xff]) ^ s2[x.left >>> 8 & 0xff])
- + s3[x.left & 0xff] ^ p[2];
- x.left ^= ((s0[x.right >>> 24] + s1[x.right >>> 16 & 0xff]) ^ s2[x.right >>> 8 & 0xff])
- + s3[x.right & 0xff] ^ p[1];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[16];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[15];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[14];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[13];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[12];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[11];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[10];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[9];
+ x.right ^= ((s0[x.left >>> 24]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[8];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[7];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[6];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[5];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[4];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[3];
+ x.right ^= ((s0[x.left >>> 24 ]
+ + s1[x.left >>> 16 & 0xff])
+ ^ s2[x.left >>> 8 & 0xff])
+ + s3[x.left & 0xff] ^ p[2];
+ x.left ^= ((s0[x.right >>> 24 ]
+ + s1[x.right >>> 16 & 0xff])
+ ^ s2[x.right >>> 8 & 0xff])
+ + s3[x.right & 0xff] ^ p[1];
x.right ^= p[0];
}
@@ -685,30 +561,19 @@ public class Blowfish extends BaseCipher
{
boolean result = super.selfTest(); // symmetry
if (result)
- {
- result = testKat(TV_KEY, TV_CT);
- }
+ result = testKat(TV_KEY, TV_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
- // Inner classes.
- // -----------------------------------------------------------------------
-
/** A simple wrapper for the P- and S-boxes. */
- private class Context implements Cloneable
+ private class Context
+ implements Cloneable
{
-
- // Constants and variables.
- // --------------------------------------------------------------------
-
/** The P-array. */
int[] p, s0, s1, s2, s3;
- // Constructors.
- // --------------------------------------------------------------------
-
/** Default 0-arguments constructor. */
Context()
{
@@ -733,9 +598,6 @@ public class Blowfish extends BaseCipher
this.s3 = (int[]) that.s3.clone();
}
- // Clonable interface implementation.
- // --------------------------------------------------------------------
-
public Object clone()
{
return new Context(this);
@@ -746,4 +608,4 @@ public class Blowfish extends BaseCipher
{
int left, right;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java b/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
index a0e0c60f33f..a7521530ce0 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
@@ -47,12 +47,11 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * <p>An implmenetation of the <code>CAST5</code> (a.k.a. CAST-128) algorithm,
- * as per <i>RFC-2144</i>, dated May 1997.</p>
- *
- * <p>In this RFC, <i>Carlisle Adams</i> (the CA in CAST, ST stands for
- * <i>Stafford Tavares</i>) describes CAST5 as:</p>
- *
+ * An implmenetation of the <code>CAST5</code> (a.k.a. CAST-128) algorithm,
+ * as per <i>RFC-2144</i>, dated May 1997.
+ * <p>
+ * In this RFC, <i>Carlisle Adams</i> (the CA in CAST, ST stands for
+ * <i>Stafford Tavares</i>) describes CAST5 as:
* <blockquote>
* "...a DES-like Substitution-Permutation Network (SPN) cryptosystem which
* appears to have good resistance to differential cryptanalysis, linear
@@ -61,19 +60,18 @@ import java.util.Iterator;
* Strict Avalanche Criterion (SAC), Bit Independence Criterion (BIC), no
* complementation property, and an absence of weak and semi-weak keys."
* </blockquote>
- *
- * <p><code>CAST5</code> is a symmetric block cipher with a block-size of 8
+ * <p>
+ * <code>CAST5</code> is a symmetric block cipher with a block-size of 8
* bytes and a variable key-size of up to 128 bits. Its authors, and their
* employer (Entrust Technologies, a Nortel majority-owned company), made it
* available worldwide on a royalty-free basis for commercial and non-commercial
- * uses.</p>
- *
- * <p>The <code>CAST5</code> encryption algorithm has been designed to allow a
+ * uses.
+ * <p>
+ * The <code>CAST5</code> encryption algorithm has been designed to allow a
* key size that can vary from <code>40</code> bits to <code>128</code> bits,
* in 8-bit increments (that is, the allowable key sizes are <code>40, 48, 56,
* 64, ..., 112, 120,</code> and <code>128</code> bits. For variable keysize
- * operation, the specification is as follows:</p>
- *
+ * operation, the specification is as follows:
* <ol>
* <li>For key sizes up to and including <code>80</code> bits (i.e.,
* <code>40, 48, 56, 64, 72,</code> and <code>80</code> bits), the algorithm
@@ -86,25 +84,19 @@ import java.util.Iterator;
* <code>128</code> bits (since the <code>CAST5</code> key schedule assumes
* an input key of <code>128</code> bits).</li>
* </ol>
- *
- * <p>References:</p>
- *
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.ietf.org/rfc/rfc2144.txt">The CAST-128 Encryption
* Algorithm</a>.<br>
* <a href="mailto:cadams@entrust.com">Carlisle Adams</a>.</li>
* </ol>
*/
-public class Cast5 extends BaseCipher
+public class Cast5
+ extends BaseCipher
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int DEFAULT_BLOCK_SIZE = 8; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 5; // in bytes
-
/**
* KAT vector (from rfc-2144):
* 40-bit key = 01 23 45 67 12
@@ -113,727 +105,372 @@ public class Cast5 extends BaseCipher
* ciphertext = 7A C8 16 D1 6E 9B 30 2E
*/
private static final byte[] KAT_KEY = Util.toBytesFromString("0123456712");
-
private static final byte[] KAT_PT = Util.toBytesFromString("0123456789ABCDEF");
-
private static final byte[] KAT_CT = Util.toBytesFromString("7AC816D16E9B302E");
-
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
// CAST5 S-boxes
- private static final int[] S1 = { 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F,
- 0x3F258C7A, 0x1E213F2F, 0x9C004DD3,
- 0x6003E540, 0xCF9FC949, 0xBFD4AF27,
- 0x88BBBDB5, 0xE2034090, 0x98D09675,
- 0x6E63A0E0, 0x15C361D2, 0xC2E7661D,
- 0x22D4FF8E, 0x28683B6F, 0xC07FD059,
- 0xFF2379C8, 0x775F50E2, 0x43C340D3,
- 0xDF2F8656, 0x887CA41A, 0xA2D2BD2D,
- 0xA1C9E0D6, 0x346C4819, 0x61B76D87,
- 0x22540F2F, 0x2ABE32E1, 0xAA54166B,
- 0x22568E3A, 0xA2D341D0, 0x66DB40C8,
- 0xA784392F, 0x004DFF2F, 0x2DB9D2DE,
- 0x97943FAC, 0x4A97C1D8, 0x527644B7,
- 0xB5F437A7, 0xB82CBAEF, 0xD751D159,
- 0x6FF7F0ED, 0x5A097A1F, 0x827B68D0,
- 0x90ECF52E, 0x22B0C054, 0xBC8E5935,
- 0x4B6D2F7F, 0x50BB64A2, 0xD2664910,
- 0xBEE5812D, 0xB7332290, 0xE93B159F,
- 0xB48EE411, 0x4BFF345D, 0xFD45C240,
- 0xAD31973F, 0xC4F6D02E, 0x55FC8165,
- 0xD5B1CAAD, 0xA1AC2DAE, 0xA2D4B76D,
- 0xC19B0C50, 0x882240F2, 0x0C6E4F38,
- 0xA4E4BFD7, 0x4F5BA272, 0x564C1D2F,
- 0xC59C5319, 0xB949E354, 0xB04669FE,
- 0xB1B6AB8A, 0xC71358DD, 0x6385C545,
- 0x110F935D, 0x57538AD5, 0x6A390493,
- 0xE63D37E0, 0x2A54F6B3, 0x3A787D5F,
- 0x6276A0B5, 0x19A6FCDF, 0x7A42206A,
- 0x29F9D4D5, 0xF61B1891, 0xBB72275E,
- 0xAA508167, 0x38901091, 0xC6B505EB,
- 0x84C7CB8C, 0x2AD75A0F, 0x874A1427,
- 0xA2D1936B, 0x2AD286AF, 0xAA56D291,
- 0xD7894360, 0x425C750D, 0x93B39E26,
- 0x187184C9, 0x6C00B32D, 0x73E2BB14,
- 0xA0BEBC3C, 0x54623779, 0x64459EAB,
- 0x3F328B82, 0x7718CF82, 0x59A2CEA6,
- 0x04EE002E, 0x89FE78E6, 0x3FAB0950,
- 0x325FF6C2, 0x81383F05, 0x6963C5C8,
- 0x76CB5AD6, 0xD49974C9, 0xCA180DCF,
- 0x380782D5, 0xC7FA5CF6, 0x8AC31511,
- 0x35E79E13, 0x47DA91D0, 0xF40F9086,
- 0xA7E2419E, 0x31366241, 0x051EF495,
- 0xAA573B04, 0x4A805D8D, 0x548300D0,
- 0x00322A3C, 0xBF64CDDF, 0xBA57A68E,
- 0x75C6372B, 0x50AFD341, 0xA7C13275,
- 0x915A0BF5, 0x6B54BFAB, 0x2B0B1426,
- 0xAB4CC9D7, 0x449CCD82, 0xF7FBF265,
- 0xAB85C5F3, 0x1B55DB94, 0xAAD4E324,
- 0xCFA4BD3F, 0x2DEAA3E2, 0x9E204D02,
- 0xC8BD25AC, 0xEADF55B3, 0xD5BD9E98,
- 0xE31231B2, 0x2AD5AD6C, 0x954329DE,
- 0xADBE4528, 0xD8710F69, 0xAA51C90F,
- 0xAA786BF6, 0x22513F1E, 0xAA51A79B,
- 0x2AD344CC, 0x7B5A41F0, 0xD37CFBAD,
- 0x1B069505, 0x41ECE491, 0xB4C332E6,
- 0x032268D4, 0xC9600ACC, 0xCE387E6D,
- 0xBF6BB16C, 0x6A70FB78, 0x0D03D9C9,
- 0xD4DF39DE, 0xE01063DA, 0x4736F464,
- 0x5AD328D8, 0xB347CC96, 0x75BB0FC3,
- 0x98511BFB, 0x4FFBCC35, 0xB58BCF6A,
- 0xE11F0ABC, 0xBFC5FE4A, 0xA70AEC10,
- 0xAC39570A, 0x3F04442F, 0x6188B153,
- 0xE0397A2E, 0x5727CB79, 0x9CEB418F,
- 0x1CACD68D, 0x2AD37C96, 0x0175CB9D,
- 0xC69DFF09, 0xC75B65F0, 0xD9DB40D8,
- 0xEC0E7779, 0x4744EAD4, 0xB11C3274,
- 0xDD24CB9E, 0x7E1C54BD, 0xF01144F9,
- 0xD2240EB1, 0x9675B3FD, 0xA3AC3755,
- 0xD47C27AF, 0x51C85F4D, 0x56907596,
- 0xA5BB15E6, 0x580304F0, 0xCA042CF1,
- 0x011A37EA, 0x8DBFAADB, 0x35BA3E4A,
- 0x3526FFA0, 0xC37B4D09, 0xBC306ED9,
- 0x98A52666, 0x5648F725, 0xFF5E569D,
- 0x0CED63D0, 0x7C63B2CF, 0x700B45E1,
- 0xD5EA50F1, 0x85A92872, 0xAF1FBDA7,
- 0xD4234870, 0xA7870BF3, 0x2D3B4D79,
- 0x42E04198, 0x0CD0EDE7, 0x26470DB8,
- 0xF881814C, 0x474D6AD7, 0x7C0C5E5C,
- 0xD1231959, 0x381B7298, 0xF5D2F4DB,
- 0xAB838653, 0x6E2F1E23, 0x83719C9E,
- 0xBD91E046, 0x9A56456E, 0xDC39200C,
- 0x20C8C571, 0x962BDA1C, 0xE1E696FF,
- 0xB141AB08, 0x7CCA89B9, 0x1A69E783,
- 0x02CC4843, 0xA2F7C579, 0x429EF47D,
- 0x427B169C, 0x5AC9F049, 0xDD8F0F00,
- 0x5C8165BF };
-
- private static final int[] S2 = { 0x1F201094, 0xEF0BA75B, 0x69E3CF7E,
- 0x393F4380, 0xFE61CF7A, 0xEEC5207A,
- 0x55889C94, 0x72FC0651, 0xADA7EF79,
- 0x4E1D7235, 0xD55A63CE, 0xDE0436BA,
- 0x99C430EF, 0x5F0C0794, 0x18DCDB7D,
- 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605,
- 0xEE15B094, 0xE9FFD909, 0xDC440086,
- 0xEF944459, 0xBA83CCB3, 0xE0C3CDFB,
- 0xD1DA4181, 0x3B092AB1, 0xF997F1C1,
- 0xA5E6CF7B, 0x01420DDB, 0xE4E7EF5B,
- 0x25A1FF41, 0xE180F806, 0x1FC41080,
- 0x179BEE7A, 0xD37AC6A9, 0xFE5830A4,
- 0x98DE8B7F, 0x77E83F4E, 0x79929269,
- 0x24FA9F7B, 0xE113C85B, 0xACC40083,
- 0xD7503525, 0xF7EA615F, 0x62143154,
- 0x0D554B63, 0x5D681121, 0xC866C359,
- 0x3D63CF73, 0xCEE234C0, 0xD4D87E87,
- 0x5C672B21, 0x071F6181, 0x39F7627F,
- 0x361E3084, 0xE4EB573B, 0x602F64A4,
- 0xD63ACD9C, 0x1BBC4635, 0x9E81032D,
- 0x2701F50C, 0x99847AB4, 0xA0E3DF79,
- 0xBA6CF38C, 0x10843094, 0x2537A95E,
- 0xF46F6FFE, 0xA1FF3B1F, 0x208CFB6A,
- 0x8F458C74, 0xD9E0A227, 0x4EC73A34,
- 0xFC884F69, 0x3E4DE8DF, 0xEF0E0088,
- 0x3559648D, 0x8A45388C, 0x1D804366,
- 0x721D9BFD, 0xA58684BB, 0xE8256333,
- 0x844E8212, 0x128D8098, 0xFED33FB4,
- 0xCE280AE1, 0x27E19BA5, 0xD5A6C252,
- 0xE49754BD, 0xC5D655DD, 0xEB667064,
- 0x77840B4D, 0xA1B6A801, 0x84DB26A9,
- 0xE0B56714, 0x21F043B7, 0xE5D05860,
- 0x54F03084, 0x066FF472, 0xA31AA153,
- 0xDADC4755, 0xB5625DBF, 0x68561BE6,
- 0x83CA6B94, 0x2D6ED23B, 0xECCF01DB,
- 0xA6D3D0BA, 0xB6803D5C, 0xAF77A709,
- 0x33B4A34C, 0x397BC8D6, 0x5EE22B95,
- 0x5F0E5304, 0x81ED6F61, 0x20E74364,
- 0xB45E1378, 0xDE18639B, 0x881CA122,
- 0xB96726D1, 0x8049A7E8, 0x22B7DA7B,
- 0x5E552D25, 0x5272D237, 0x79D2951C,
- 0xC60D894C, 0x488CB402, 0x1BA4FE5B,
- 0xA4B09F6B, 0x1CA815CF, 0xA20C3005,
- 0x8871DF63, 0xB9DE2FCB, 0x0CC6C9E9,
- 0x0BEEFF53, 0xE3214517, 0xB4542835,
- 0x9F63293C, 0xEE41E729, 0x6E1D2D7C,
- 0x50045286, 0x1E6685F3, 0xF33401C6,
- 0x30A22C95, 0x31A70850, 0x60930F13,
- 0x73F98417, 0xA1269859, 0xEC645C44,
- 0x52C877A9, 0xCDFF33A6, 0xA02B1741,
- 0x7CBAD9A2, 0x2180036F, 0x50D99C08,
- 0xCB3F4861, 0xC26BD765, 0x64A3F6AB,
- 0x80342676, 0x25A75E7B, 0xE4E6D1FC,
- 0x20C710E6, 0xCDF0B680, 0x17844D3B,
- 0x31EEF84D, 0x7E0824E4, 0x2CCB49EB,
- 0x846A3BAE, 0x8FF77888, 0xEE5D60F6,
- 0x7AF75673, 0x2FDD5CDB, 0xA11631C1,
- 0x30F66F43, 0xB3FAEC54, 0x157FD7FA,
- 0xEF8579CC, 0xD152DE58, 0xDB2FFD5E,
- 0x8F32CE19, 0x306AF97A, 0x02F03EF8,
- 0x99319AD5, 0xC242FA0F, 0xA7E3EBB0,
- 0xC68E4906, 0xB8DA230C, 0x80823028,
- 0xDCDEF3C8, 0xD35FB171, 0x088A1BC8,
- 0xBEC0C560, 0x61A3C9E8, 0xBCA8F54D,
- 0xC72FEFFA, 0x22822E99, 0x82C570B4,
- 0xD8D94E89, 0x8B1C34BC, 0x301E16E6,
- 0x273BE979, 0xB0FFEAA6, 0x61D9B8C6,
- 0x00B24869, 0xB7FFCE3F, 0x08DC283B,
- 0x43DAF65A, 0xF7E19798, 0x7619B72F,
- 0x8F1C9BA4, 0xDC8637A0, 0x16A7D3B1,
- 0x9FC393B7, 0xA7136EEB, 0xC6BCC63E,
- 0x1A513742, 0xEF6828BC, 0x520365D6,
- 0x2D6A77AB, 0x3527ED4B, 0x821FD216,
- 0x095C6E2E, 0xDB92F2FB, 0x5EEA29CB,
- 0x145892F5, 0x91584F7F, 0x5483697B,
- 0x2667A8CC, 0x85196048, 0x8C4BACEA,
- 0x833860D4, 0x0D23E0F9, 0x6C387E8A,
- 0x0AE6D249, 0xB284600C, 0xD835731D,
- 0xDCB1C647, 0xAC4C56EA, 0x3EBD81B3,
- 0x230EABB0, 0x6438BC87, 0xF0B5B1FA,
- 0x8F5EA2B3, 0xFC184642, 0x0A036B7A,
- 0x4FB089BD, 0x649DA589, 0xA345415E,
- 0x5C038323, 0x3E5D3BB9, 0x43D79572,
- 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF,
- 0x7160A539, 0x73BFBE70, 0x83877605,
- 0x4523ECF1 };
-
- private static final int[] S3 = { 0x8DEFC240, 0x25FA5D9F, 0xEB903DBF,
- 0xE810C907, 0x47607FFF, 0x369FE44B,
- 0x8C1FC644, 0xAECECA90, 0xBEB1F9BF,
- 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE,
- 0x920E8806, 0xF0AD0548, 0xE13C8D83,
- 0x927010D5, 0x11107D9F, 0x07647DB9,
- 0xB2E3E4D4, 0x3D4F285E, 0xB9AFA820,
- 0xFADE82E0, 0xA067268B, 0x8272792E,
- 0x553FB2C0, 0x489AE22B, 0xD4EF9794,
- 0x125E3FBC, 0x21FFFCEE, 0x825B1BFD,
- 0x9255C5ED, 0x1257A240, 0x4E1A8302,
- 0xBAE07FFF, 0x528246E7, 0x8E57140E,
- 0x3373F7BF, 0x8C9F8188, 0xA6FC4EE8,
- 0xC982B5A5, 0xA8C01DB7, 0x579FC264,
- 0x67094F31, 0xF2BD3F5F, 0x40FFF7C1,
- 0x1FB78DFC, 0x8E6BD2C1, 0x437BE59B,
- 0x99B03DBF, 0xB5DBC64B, 0x638DC0E6,
- 0x55819D99, 0xA197C81C, 0x4A012D6E,
- 0xC5884A28, 0xCCC36F71, 0xB843C213,
- 0x6C0743F1, 0x8309893C, 0x0FEDDD5F,
- 0x2F7FE850, 0xD7C07F7E, 0x02507FBF,
- 0x5AFB9A04, 0xA747D2D0, 0x1651192E,
- 0xAF70BF3E, 0x58C31380, 0x5F98302E,
- 0x727CC3C4, 0x0A0FB402, 0x0F7FEF82,
- 0x8C96FDAD, 0x5D2C2AAE, 0x8EE99A49,
- 0x50DA88B8, 0x8427F4A0, 0x1EAC5790,
- 0x796FB449, 0x8252DC15, 0xEFBD7D9B,
- 0xA672597D, 0xADA840D8, 0x45F54504,
- 0xFA5D7403, 0xE83EC305, 0x4F91751A,
- 0x925669C2, 0x23EFE941, 0xA903F12E,
- 0x60270DF2, 0x0276E4B6, 0x94FD6574,
- 0x927985B2, 0x8276DBCB, 0x02778176,
- 0xF8AF918D, 0x4E48F79E, 0x8F616DDF,
- 0xE29D840E, 0x842F7D83, 0x340CE5C8,
- 0x96BBB682, 0x93B4B148, 0xEF303CAB,
- 0x984FAF28, 0x779FAF9B, 0x92DC560D,
- 0x224D1E20, 0x8437AA88, 0x7D29DC96,
- 0x2756D3DC, 0x8B907CEE, 0xB51FD240,
- 0xE7C07CE3, 0xE566B4A1, 0xC3E9615E,
- 0x3CF8209D, 0x6094D1E3, 0xCD9CA341,
- 0x5C76460E, 0x00EA983B, 0xD4D67881,
- 0xFD47572C, 0xF76CEDD9, 0xBDA8229C,
- 0x127DADAA, 0x438A074E, 0x1F97C090,
- 0x081BDB8A, 0x93A07EBE, 0xB938CA15,
- 0x97B03CFF, 0x3DC2C0F8, 0x8D1AB2EC,
- 0x64380E51, 0x68CC7BFB, 0xD90F2788,
- 0x12490181, 0x5DE5FFD4, 0xDD7EF86A,
- 0x76A2E214, 0xB9A40368, 0x925D958F,
- 0x4B39FFFA, 0xBA39AEE9, 0xA4FFD30B,
- 0xFAF7933B, 0x6D498623, 0x193CBCFA,
- 0x27627545, 0x825CF47A, 0x61BD8BA0,
- 0xD11E42D1, 0xCEAD04F4, 0x127EA392,
- 0x10428DB7, 0x8272A972, 0x9270C4A8,
- 0x127DE50B, 0x285BA1C8, 0x3C62F44F,
- 0x35C0EAA5, 0xE805D231, 0x428929FB,
- 0xB4FCDF82, 0x4FB66A53, 0x0E7DC15B,
- 0x1F081FAB, 0x108618AE, 0xFCFD086D,
- 0xF9FF2889, 0x694BCC11, 0x236A5CAE,
- 0x12DECA4D, 0x2C3F8CC5, 0xD2D02DFE,
- 0xF8EF5896, 0xE4CF52DA, 0x95155B67,
- 0x494A488C, 0xB9B6A80C, 0x5C8F82BC,
- 0x89D36B45, 0x3A609437, 0xEC00C9A9,
- 0x44715253, 0x0A874B49, 0xD773BC40,
- 0x7C34671C, 0x02717EF6, 0x4FEB5536,
- 0xA2D02FFF, 0xD2BF60C4, 0xD43F03C0,
- 0x50B4EF6D, 0x07478CD1, 0x006E1888,
- 0xA2E53F55, 0xB9E6D4BC, 0xA2048016,
- 0x97573833, 0xD7207D67, 0xDE0F8F3D,
- 0x72F87B33, 0xABCC4F33, 0x7688C55D,
- 0x7B00A6B0, 0x947B0001, 0x570075D2,
- 0xF9BB88F8, 0x8942019E, 0x4264A5FF,
- 0x856302E0, 0x72DBD92B, 0xEE971B69,
- 0x6EA22FDE, 0x5F08AE2B, 0xAF7A616D,
- 0xE5C98767, 0xCF1FEBD2, 0x61EFC8C2,
- 0xF1AC2571, 0xCC8239C2, 0x67214CB8,
- 0xB1E583D1, 0xB7DC3E62, 0x7F10BDCE,
- 0xF90A5C38, 0x0FF0443D, 0x606E6DC6,
- 0x60543A49, 0x5727C148, 0x2BE98A1D,
- 0x8AB41738, 0x20E1BE24, 0xAF96DA0F,
- 0x68458425, 0x99833BE5, 0x600D457D,
- 0x282F9350, 0x8334B362, 0xD91D1120,
- 0x2B6D8DA0, 0x642B1E31, 0x9C305A00,
- 0x52BCE688, 0x1B03588A, 0xF7BAEFD5,
- 0x4142ED9C, 0xA4315C11, 0x83323EC5,
- 0xDFEF4636, 0xA133C501, 0xE9D3531C,
- 0xEE353783 };
-
- private static final int[] S4 = { 0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF,
- 0xD273A298, 0x4A4F7BDB, 0x64AD8C57,
- 0x85510443, 0xFA020ED1, 0x7E287AFF,
- 0xE60FB663, 0x095F35A1, 0x79EBF120,
- 0xFD059D43, 0x6497B7B1, 0xF3641F63,
- 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD,
- 0xC9430040, 0x0CC32220, 0xFDD30B30,
- 0xC0A5374F, 0x1D2D00D9, 0x24147B15,
- 0xEE4D111A, 0x0FCA5167, 0x71FF904C,
- 0x2D195FFE, 0x1A05645F, 0x0C13FEFE,
- 0x081B08CA, 0x05170121, 0x80530100,
- 0xE83E5EFE, 0xAC9AF4F8, 0x7FE72701,
- 0xD2B8EE5F, 0x06DF4261, 0xBB9E9B8A,
- 0x7293EA25, 0xCE84FFDF, 0xF5718801,
- 0x3DD64B04, 0xA26F263B, 0x7ED48400,
- 0x547EEBE6, 0x446D4CA0, 0x6CF3D6F5,
- 0x2649ABDF, 0xAEA0C7F5, 0x36338CC1,
- 0x503F7E93, 0xD3772061, 0x11B638E1,
- 0x72500E03, 0xF80EB2BB, 0xABE0502E,
- 0xEC8D77DE, 0x57971E81, 0xE14F6746,
- 0xC9335400, 0x6920318F, 0x081DBB99,
- 0xFFC304A5, 0x4D351805, 0x7F3D5CE3,
- 0xA6C866C6, 0x5D5BCCA9, 0xDAEC6FEA,
- 0x9F926F91, 0x9F46222F, 0x3991467D,
- 0xA5BF6D8E, 0x1143C44F, 0x43958302,
- 0xD0214EEB, 0x022083B8, 0x3FB6180C,
- 0x18F8931E, 0x281658E6, 0x26486E3E,
- 0x8BD78A70, 0x7477E4C1, 0xB506E07C,
- 0xF32D0A25, 0x79098B02, 0xE4EABB81,
- 0x28123B23, 0x69DEAD38, 0x1574CA16,
- 0xDF871B62, 0x211C40B7, 0xA51A9EF9,
- 0x0014377B, 0x041E8AC8, 0x09114003,
- 0xBD59E4D2, 0xE3D156D5, 0x4FE876D5,
- 0x2F91A340, 0x557BE8DE, 0x00EAE4A7,
- 0x0CE5C2EC, 0x4DB4BBA6, 0xE756BDFF,
- 0xDD3369AC, 0xEC17B035, 0x06572327,
- 0x99AFC8B0, 0x56C8C391, 0x6B65811C,
- 0x5E146119, 0x6E85CB75, 0xBE07C002,
- 0xC2325577, 0x893FF4EC, 0x5BBFC92D,
- 0xD0EC3B25, 0xB7801AB7, 0x8D6D3B24,
- 0x20C763EF, 0xC366A5FC, 0x9C382880,
- 0x0ACE3205, 0xAAC9548A, 0xECA1D7C7,
- 0x041AFA32, 0x1D16625A, 0x6701902C,
- 0x9B757A54, 0x31D477F7, 0x9126B031,
- 0x36CC6FDB, 0xC70B8B46, 0xD9E66A48,
- 0x56E55A79, 0x026A4CEB, 0x52437EFF,
- 0x2F8F76B4, 0x0DF980A5, 0x8674CDE3,
- 0xEDDA04EB, 0x17A9BE04, 0x2C18F4DF,
- 0xB7747F9D, 0xAB2AF7B4, 0xEFC34D20,
- 0x2E096B7C, 0x1741A254, 0xE5B6A035,
- 0x213D42F6, 0x2C1C7C26, 0x61C2F50F,
- 0x6552DAF9, 0xD2C231F8, 0x25130F69,
- 0xD8167FA2, 0x0418F2C8, 0x001A96A6,
- 0x0D1526AB, 0x63315C21, 0x5E0A72EC,
- 0x49BAFEFD, 0x187908D9, 0x8D0DBD86,
- 0x311170A7, 0x3E9B640C, 0xCC3E10D7,
- 0xD5CAD3B6, 0x0CAEC388, 0xF73001E1,
- 0x6C728AFF, 0x71EAE2A1, 0x1F9AF36E,
- 0xCFCBD12F, 0xC1DE8417, 0xAC07BE6B,
- 0xCB44A1D8, 0x8B9B0F56, 0x013988C3,
- 0xB1C52FCA, 0xB4BE31CD, 0xD8782806,
- 0x12A3A4E2, 0x6F7DE532, 0x58FD7EB6,
- 0xD01EE900, 0x24ADFFC2, 0xF4990FC5,
- 0x9711AAC5, 0x001D7B95, 0x82E5E7D2,
- 0x109873F6, 0x00613096, 0xC32D9521,
- 0xADA121FF, 0x29908415, 0x7FBB977F,
- 0xAF9EB3DB, 0x29C9ED2A, 0x5CE2A465,
- 0xA730F32C, 0xD0AA3FE8, 0x8A5CC091,
- 0xD49E2CE7, 0x0CE454A9, 0xD60ACD86,
- 0x015F1919, 0x77079103, 0xDEA03AF6,
- 0x78A8565E, 0xDEE356DF, 0x21F05CBE,
- 0x8B75E387, 0xB3C50651, 0xB8A5C3EF,
- 0xD8EEB6D2, 0xE523BE77, 0xC2154529,
- 0x2F69EFDF, 0xAFE67AFB, 0xF470C4B2,
- 0xF3E0EB5B, 0xD6CC9876, 0x39E4460C,
- 0x1FDA8538, 0x1987832F, 0xCA007367,
- 0xA99144F8, 0x296B299E, 0x492FC295,
- 0x9266BEAB, 0xB5676E69, 0x9BD3DDDA,
- 0xDF7E052F, 0xDB25701C, 0x1B5E51EE,
- 0xF65324E6, 0x6AFCE36C, 0x0316CC04,
- 0x8644213E, 0xB7DC59D0, 0x7965291F,
- 0xCCD6FD43, 0x41823979, 0x932BCDF6,
- 0xB657C34D, 0x4EDFD282, 0x7AE5290C,
- 0x3CB9536B, 0x851E20FE, 0x9833557E,
- 0x13ECF0B0, 0xD3FFB372, 0x3F85C5C1,
- 0x0AEF7ED2 };
-
- private static final int[] S5 = { 0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF,
- 0xA6337911, 0xB86A7FFF, 0x1DD358F5,
- 0x44DD9D44, 0x1731167F, 0x08FBF1FA,
- 0xE7F511CC, 0xD2051B00, 0x735ABA00,
- 0x2AB722D8, 0x386381CB, 0xACF6243A,
- 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD,
- 0xC4494816, 0xCCF5C180, 0x38851640,
- 0x15B0A848, 0xE68B18CB, 0x4CAADEFF,
- 0x5F480A01, 0x0412B2AA, 0x259814FC,
- 0x41D0EFE2, 0x4E40B48D, 0x248EB6FB,
- 0x8DBA1CFE, 0x41A99B02, 0x1A550A04,
- 0xBA8F65CB, 0x7251F4E7, 0x95A51725,
- 0xC106ECD7, 0x97A5980A, 0xC539B9AA,
- 0x4D79FE6A, 0xF2F3F763, 0x68AF8040,
- 0xED0C9E56, 0x11B4958B, 0xE1EB5A88,
- 0x8709E6B0, 0xD7E07156, 0x4E29FEA7,
- 0x6366E52D, 0x02D1C000, 0xC4AC8E05,
- 0x9377F571, 0x0C05372A, 0x578535F2,
- 0x2261BE02, 0xD642A0C9, 0xDF13A280,
- 0x74B55BD2, 0x682199C0, 0xD421E5EC,
- 0x53FB3CE8, 0xC8ADEDB3, 0x28A87FC9,
- 0x3D959981, 0x5C1FF900, 0xFE38D399,
- 0x0C4EFF0B, 0x062407EA, 0xAA2F4FB1,
- 0x4FB96976, 0x90C79505, 0xB0A8A774,
- 0xEF55A1FF, 0xE59CA2C2, 0xA6B62D27,
- 0xE66A4263, 0xDF65001F, 0x0EC50966,
- 0xDFDD55BC, 0x29DE0655, 0x911E739A,
- 0x17AF8975, 0x32C7911C, 0x89F89468,
- 0x0D01E980, 0x524755F4, 0x03B63CC9,
- 0x0CC844B2, 0xBCF3F0AA, 0x87AC36E9,
- 0xE53A7426, 0x01B3D82B, 0x1A9E7449,
- 0x64EE2D7E, 0xCDDBB1DA, 0x01C94910,
- 0xB868BF80, 0x0D26F3FD, 0x9342EDE7,
- 0x04A5C284, 0x636737B6, 0x50F5B616,
- 0xF24766E3, 0x8ECA36C1, 0x136E05DB,
- 0xFEF18391, 0xFB887A37, 0xD6E7F7D4,
- 0xC7FB7DC9, 0x3063FCDF, 0xB6F589DE,
- 0xEC2941DA, 0x26E46695, 0xB7566419,
- 0xF654EFC5, 0xD08D58B7, 0x48925401,
- 0xC1BACB7F, 0xE5FF550F, 0xB6083049,
- 0x5BB5D0E8, 0x87D72E5A, 0xAB6A6EE1,
- 0x223A66CE, 0xC62BF3CD, 0x9E0885F9,
- 0x68CB3E47, 0x086C010F, 0xA21DE820,
- 0xD18B69DE, 0xF3F65777, 0xFA02C3F6,
- 0x407EDAC3, 0xCBB3D550, 0x1793084D,
- 0xB0D70EBA, 0x0AB378D5, 0xD951FB0C,
- 0xDED7DA56, 0x4124BBE4, 0x94CA0B56,
- 0x0F5755D1, 0xE0E1E56E, 0x6184B5BE,
- 0x580A249F, 0x94F74BC0, 0xE327888E,
- 0x9F7B5561, 0xC3DC0280, 0x05687715,
- 0x646C6BD7, 0x44904DB3, 0x66B4F0A3,
- 0xC0F1648A, 0x697ED5AF, 0x49E92FF6,
- 0x309E374F, 0x2CB6356A, 0x85808573,
- 0x4991F840, 0x76F0AE02, 0x083BE84D,
- 0x28421C9A, 0x44489406, 0x736E4CB8,
- 0xC1092910, 0x8BC95FC6, 0x7D869CF4,
- 0x134F616F, 0x2E77118D, 0xB31B2BE1,
- 0xAA90B472, 0x3CA5D717, 0x7D161BBA,
- 0x9CAD9010, 0xAF462BA2, 0x9FE459D2,
- 0x45D34559, 0xD9F2DA13, 0xDBC65487,
- 0xF3E4F94E, 0x176D486F, 0x097C13EA,
- 0x631DA5C7, 0x445F7382, 0x175683F4,
- 0xCDC66A97, 0x70BE0288, 0xB3CDCF72,
- 0x6E5DD2F3, 0x20936079, 0x459B80A5,
- 0xBE60E2DB, 0xA9C23101, 0xEBA5315C,
- 0x224E42F2, 0x1C5C1572, 0xF6721B2C,
- 0x1AD2FFF3, 0x8C25404E, 0x324ED72F,
- 0x4067B7FD, 0x0523138E, 0x5CA3BC78,
- 0xDC0FD66E, 0x75922283, 0x784D6B17,
- 0x58EBB16E, 0x44094F85, 0x3F481D87,
- 0xFCFEAE7B, 0x77B5FF76, 0x8C2302BF,
- 0xAAF47556, 0x5F46B02A, 0x2B092801,
- 0x3D38F5F7, 0x0CA81F36, 0x52AF4A8A,
- 0x66D5E7C0, 0xDF3B0874, 0x95055110,
- 0x1B5AD7A8, 0xF61ED5AD, 0x6CF6E479,
- 0x20758184, 0xD0CEFA65, 0x88F7BE58,
- 0x4A046826, 0x0FF6F8F3, 0xA09C7F70,
- 0x5346ABA0, 0x5CE96C28, 0xE176EDA3,
- 0x6BAC307F, 0x376829D2, 0x85360FA9,
- 0x17E3FE2A, 0x24B79767, 0xF5A96B20,
- 0xD6CD2595, 0x68FF1EBF, 0x7555442C,
- 0xF19F06BE, 0xF9E0659A, 0xEEB9491D,
- 0x34010718, 0xBB30CAB8, 0xE822FE15,
- 0x88570983, 0x750E6249, 0xDA627E55,
- 0x5E76FFA8, 0xB1534546, 0x6D47DE08,
- 0xEFE9E7D4 };
-
- private static final int[] S6 = { 0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867,
- 0xE2337F7C, 0x95DB08E7, 0x016843B4,
- 0xECED5CBC, 0x325553AC, 0xBF9F0960,
- 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9,
- 0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732,
- 0x8989B138, 0x33F14961, 0xC01937BD,
- 0xF506C6DA, 0xE4625E7E, 0xA308EA99,
- 0x4E23E33C, 0x79CBD7CC, 0x48A14367,
- 0xA3149619, 0xFEC94BD5, 0xA114174A,
- 0xEAA01866, 0xA084DB2D, 0x09A8486F,
- 0xA888614A, 0x2900AF98, 0x01665991,
- 0xE1992863, 0xC8F30C60, 0x2E78EF3C,
- 0xD0D51932, 0xCF0FEC14, 0xF7CA07D2,
- 0xD0A82072, 0xFD41197E, 0x9305A6B0,
- 0xE86BE3DA, 0x74BED3CD, 0x372DA53C,
- 0x4C7F4448, 0xDAB5D440, 0x6DBA0EC3,
- 0x083919A7, 0x9FBAEED9, 0x49DBCFB0,
- 0x4E670C53, 0x5C3D9C01, 0x64BDB941,
- 0x2C0E636A, 0xBA7DD9CD, 0xEA6F7388,
- 0xE70BC762, 0x35F29ADB, 0x5C4CDD8D,
- 0xF0D48D8C, 0xB88153E2, 0x08A19866,
- 0x1AE2EAC8, 0x284CAF89, 0xAA928223,
- 0x9334BE53, 0x3B3A21BF, 0x16434BE3,
- 0x9AEA3906, 0xEFE8C36E, 0xF890CDD9,
- 0x80226DAE, 0xC340A4A3, 0xDF7E9C09,
- 0xA694A807, 0x5B7C5ECC, 0x221DB3A6,
- 0x9A69A02F, 0x68818A54, 0xCEB2296F,
- 0x53C0843A, 0xFE893655, 0x25BFE68A,
- 0xB4628ABC, 0xCF222EBF, 0x25AC6F48,
- 0xA9A99387, 0x53BDDB65, 0xE76FFBE7,
- 0xE967FD78, 0x0BA93563, 0x8E342BC1,
- 0xE8A11BE9, 0x4980740D, 0xC8087DFC,
- 0x8DE4BF99, 0xA11101A0, 0x7FD37975,
- 0xDA5A26C0, 0xE81F994F, 0x9528CD89,
- 0xFD339FED, 0xB87834BF, 0x5F04456D,
- 0x22258698, 0xC9C4C83B, 0x2DC156BE,
- 0x4F628DAA, 0x57F55EC5, 0xE2220ABE,
- 0xD2916EBF, 0x4EC75B95, 0x24F2C3C0,
- 0x42D15D99, 0xCD0D7FA0, 0x7B6E27FF,
- 0xA8DC8AF0, 0x7345C106, 0xF41E232F,
- 0x35162386, 0xE6EA8926, 0x3333B094,
- 0x157EC6F2, 0x372B74AF, 0x692573E4,
- 0xE9A9D848, 0xF3160289, 0x3A62EF1D,
- 0xA787E238, 0xF3A5F676, 0x74364853,
- 0x20951063, 0x4576698D, 0xB6FAD407,
- 0x592AF950, 0x36F73523, 0x4CFB6E87,
- 0x7DA4CEC0, 0x6C152DAA, 0xCB0396A8,
- 0xC50DFE5D, 0xFCD707AB, 0x0921C42F,
- 0x89DFF0BB, 0x5FE2BE78, 0x448F4F33,
- 0x754613C9, 0x2B05D08D, 0x48B9D585,
- 0xDC049441, 0xC8098F9B, 0x7DEDE786,
- 0xC39A3373, 0x42410005, 0x6A091751,
- 0x0EF3C8A6, 0x890072D6, 0x28207682,
- 0xA9A9F7BE, 0xBF32679D, 0xD45B5B75,
- 0xB353FD00, 0xCBB0E358, 0x830F220A,
- 0x1F8FB214, 0xD372CF08, 0xCC3C4A13,
- 0x8CF63166, 0x061C87BE, 0x88C98F88,
- 0x6062E397, 0x47CF8E7A, 0xB6C85283,
- 0x3CC2ACFB, 0x3FC06976, 0x4E8F0252,
- 0x64D8314D, 0xDA3870E3, 0x1E665459,
- 0xC10908F0, 0x513021A5, 0x6C5B68B7,
- 0x822F8AA0, 0x3007CD3E, 0x74719EEF,
- 0xDC872681, 0x073340D4, 0x7E432FD9,
- 0x0C5EC241, 0x8809286C, 0xF592D891,
- 0x08A930F6, 0x957EF305, 0xB7FBFFBD,
- 0xC266E96F, 0x6FE4AC98, 0xB173ECC0,
- 0xBC60B42A, 0x953498DA, 0xFBA1AE12,
- 0x2D4BD736, 0x0F25FAAB, 0xA4F3FCEB,
- 0xE2969123, 0x257F0C3D, 0x9348AF49,
- 0x361400BC, 0xE8816F4A, 0x3814F200,
- 0xA3F94043, 0x9C7A54C2, 0xBC704F57,
- 0xDA41E7F9, 0xC25AD33A, 0x54F4A084,
- 0xB17F5505, 0x59357CBE, 0xEDBD15C8,
- 0x7F97C5AB, 0xBA5AC7B5, 0xB6F6DEAF,
- 0x3A479C3A, 0x5302DA25, 0x653D7E6A,
- 0x54268D49, 0x51A477EA, 0x5017D55B,
- 0xD7D25D88, 0x44136C76, 0x0404A8C8,
- 0xB8E5A121, 0xB81A928A, 0x60ED5869,
- 0x97C55B96, 0xEAEC991B, 0x29935913,
- 0x01FDB7F1, 0x088E8DFA, 0x9AB6F6F5,
- 0x3B4CBF9F, 0x4A5DE3AB, 0xE6051D35,
- 0xA0E1D855, 0xD36B4CF1, 0xF544EDEB,
- 0xB0E93524, 0xBEBB8FBD, 0xA2D762CF,
- 0x49C92F54, 0x38B5F331, 0x7128A454,
- 0x48392905, 0xA65B1DB8, 0x851C97BD,
- 0xD675CF2F };
-
- private static final int[] S7 = { 0x85E04019, 0x332BF567, 0x662DBFFF,
- 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912,
- 0xDE6008A1, 0x2028DA1F, 0x0227BCE7,
- 0x4D642916, 0x18FAC300, 0x50F18B82,
- 0x2CB2CB11, 0xB232E75C, 0x4B3695F2,
- 0xB28707DE, 0xA05FBCF6, 0xCD4181E9,
- 0xE150210C, 0xE24EF1BD, 0xB168C381,
- 0xFDE4E789, 0x5C79B0D8, 0x1E8BFD43,
- 0x4D495001, 0x38BE4341, 0x913CEE1D,
- 0x92A79C3F, 0x089766BE, 0xBAEEADF4,
- 0x1286BECF, 0xB6EACB19, 0x2660C200,
- 0x7565BDE4, 0x64241F7A, 0x8248DCA9,
- 0xC3B3AD66, 0x28136086, 0x0BD8DFA8,
- 0x356D1CF2, 0x107789BE, 0xB3B2E9CE,
- 0x0502AA8F, 0x0BC0351E, 0x166BF52A,
- 0xEB12FF82, 0xE3486911, 0xD34D7516,
- 0x4E7B3AFF, 0x5F43671B, 0x9CF6E037,
- 0x4981AC83, 0x334266CE, 0x8C9341B7,
- 0xD0D854C0, 0xCB3A6C88, 0x47BC2829,
- 0x4725BA37, 0xA66AD22B, 0x7AD61F1E,
- 0x0C5CBAFA, 0x4437F107, 0xB6E79962,
- 0x42D2D816, 0x0A961288, 0xE1A5C06E,
- 0x13749E67, 0x72FC081A, 0xB1D139F7,
- 0xF9583745, 0xCF19DF58, 0xBEC3F756,
- 0xC06EBA30, 0x07211B24, 0x45C28829,
- 0xC95E317F, 0xBC8EC511, 0x38BC46E9,
- 0xC6E6FA14, 0xBAE8584A, 0xAD4EBC46,
- 0x468F508B, 0x7829435F, 0xF124183B,
- 0x821DBA9F, 0xAFF60FF4, 0xEA2C4E6D,
- 0x16E39264, 0x92544A8B, 0x009B4FC3,
- 0xABA68CED, 0x9AC96F78, 0x06A5B79A,
- 0xB2856E6E, 0x1AEC3CA9, 0xBE838688,
- 0x0E0804E9, 0x55F1BE56, 0xE7E5363B,
- 0xB3A1F25D, 0xF7DEBB85, 0x61FE033C,
- 0x16746233, 0x3C034C28, 0xDA6D0C74,
- 0x79AAC56C, 0x3CE4E1AD, 0x51F0C802,
- 0x98F8F35A, 0x1626A49F, 0xEED82B29,
- 0x1D382FE3, 0x0C4FB99A, 0xBB325778,
- 0x3EC6D97B, 0x6E77A6A9, 0xCB658B5C,
- 0xD45230C7, 0x2BD1408B, 0x60C03EB7,
- 0xB9068D78, 0xA33754F4, 0xF430C87D,
- 0xC8A71302, 0xB96D8C32, 0xEBD4E7BE,
- 0xBE8B9D2D, 0x7979FB06, 0xE7225308,
- 0x8B75CF77, 0x11EF8DA4, 0xE083C858,
- 0x8D6B786F, 0x5A6317A6, 0xFA5CF7A0,
- 0x5DDA0033, 0xF28EBFB0, 0xF5B9C310,
- 0xA0EAC280, 0x08B9767A, 0xA3D9D2B0,
- 0x79D34217, 0x021A718D, 0x9AC6336A,
- 0x2711FD60, 0x438050E3, 0x069908A8,
- 0x3D7FEDC4, 0x826D2BEF, 0x4EEB8476,
- 0x488DCF25, 0x36C9D566, 0x28E74E41,
- 0xC2610ACA, 0x3D49A9CF, 0xBAE3B9DF,
- 0xB65F8DE6, 0x92AEAF64, 0x3AC7D5E6,
- 0x9EA80509, 0xF22B017D, 0xA4173F70,
- 0xDD1E16C3, 0x15E0D7F9, 0x50B1B887,
- 0x2B9F4FD5, 0x625ABA82, 0x6A017962,
- 0x2EC01B9C, 0x15488AA9, 0xD716E740,
- 0x40055A2C, 0x93D29A22, 0xE32DBF9A,
- 0x058745B9, 0x3453DC1E, 0xD699296E,
- 0x496CFF6F, 0x1C9F4986, 0xDFE2ED07,
- 0xB87242D1, 0x19DE7EAE, 0x053E561A,
- 0x15AD6F8C, 0x66626C1C, 0x7154C24C,
- 0xEA082B2A, 0x93EB2939, 0x17DCB0F0,
- 0x58D4F2AE, 0x9EA294FB, 0x52CF564C,
- 0x9883FE66, 0x2EC40581, 0x763953C3,
- 0x01D6692E, 0xD3A0C108, 0xA1E7160E,
- 0xE4F2DFA6, 0x693ED285, 0x74904698,
- 0x4C2B0EDD, 0x4F757656, 0x5D393378,
- 0xA132234F, 0x3D321C5D, 0xC3F5E194,
- 0x4B269301, 0xC79F022F, 0x3C997E7E,
- 0x5E4F9504, 0x3FFAFBBD, 0x76F7AD0E,
- 0x296693F4, 0x3D1FCE6F, 0xC61E45BE,
- 0xD3B5AB34, 0xF72BF9B7, 0x1B0434C0,
- 0x4E72B567, 0x5592A33D, 0xB5229301,
- 0xCFD2A87F, 0x60AEB767, 0x1814386B,
- 0x30BCC33D, 0x38A0C07D, 0xFD1606F2,
- 0xC363519B, 0x589DD390, 0x5479F8E6,
- 0x1CB8D647, 0x97FD61A9, 0xEA7759F4,
- 0x2D57539D, 0x569A58CF, 0xE84E63AD,
- 0x462E1B78, 0x6580F87E, 0xF3817914,
- 0x91DA55F4, 0x40A230F3, 0xD1988F35,
- 0xB6E318D2, 0x3FFA50BC, 0x3D40F021,
- 0xC3C0BDAE, 0x4958C24C, 0x518F36B2,
- 0x84B1D370, 0x0FEDCE83, 0x878DDADA,
- 0xF2A279C7, 0x94E01BE8, 0x90716F4B,
- 0x954B8AA3 };
-
- private static final int[] S8 = { 0xE216300D, 0xBBDDFFFC, 0xA7EBDABD,
- 0x35648095, 0x7789F8B7, 0xE6C1121B,
- 0x0E241600, 0x052CE8B5, 0x11A9CFB0,
- 0xE5952F11, 0xECE7990A, 0x9386D174,
- 0x2A42931C, 0x76E38111, 0xB12DEF3A,
- 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C,
- 0xBE197029, 0x84A00940, 0xBB243A0F,
- 0xB4D137CF, 0xB44E79F0, 0x049EEDFD,
- 0x0B15A15D, 0x480D3168, 0x8BBBDE5A,
- 0x669DED42, 0xC7ECE831, 0x3F8F95E7,
- 0x72DF191B, 0x7580330D, 0x94074251,
- 0x5C7DCDFA, 0xABBE6D63, 0xAA402164,
- 0xB301D40A, 0x02E7D1CA, 0x53571DAE,
- 0x7A3182A2, 0x12A8DDEC, 0xFDAA335D,
- 0x176F43E8, 0x71FB46D4, 0x38129022,
- 0xCE949AD4, 0xB84769AD, 0x965BD862,
- 0x82F3D055, 0x66FB9767, 0x15B80B4E,
- 0x1D5B47A0, 0x4CFDE06F, 0xC28EC4B8,
- 0x57E8726E, 0x647A78FC, 0x99865D44,
- 0x608BD593, 0x6C200E03, 0x39DC5FF6,
- 0x5D0B00A3, 0xAE63AFF2, 0x7E8BD632,
- 0x70108C0C, 0xBBD35049, 0x2998DF04,
- 0x980CF42A, 0x9B6DF491, 0x9E7EDD53,
- 0x06918548, 0x58CB7E07, 0x3B74EF2E,
- 0x522FFFB1, 0xD24708CC, 0x1C7E27CD,
- 0xA4EB215B, 0x3CF1D2E2, 0x19B47A38,
- 0x424F7618, 0x35856039, 0x9D17DEE7,
- 0x27EB35E6, 0xC9AFF67B, 0x36BAF5B8,
- 0x09C467CD, 0xC18910B1, 0xE11DBF7B,
- 0x06CD1AF8, 0x7170C608, 0x2D5E3354,
- 0xD4DE495A, 0x64C6D006, 0xBCC0C62C,
- 0x3DD00DB3, 0x708F8F34, 0x77D51B42,
- 0x264F620F, 0x24B8D2BF, 0x15C1B79E,
- 0x46A52564, 0xF8D7E54E, 0x3E378160,
- 0x7895CDA5, 0x859C15A5, 0xE6459788,
- 0xC37BC75F, 0xDB07BA0C, 0x0676A3AB,
- 0x7F229B1E, 0x31842E7B, 0x24259FD7,
- 0xF8BEF472, 0x835FFCB8, 0x6DF4C1F2,
- 0x96F5B195, 0xFD0AF0FC, 0xB0FE134C,
- 0xE2506D3D, 0x4F9B12EA, 0xF215F225,
- 0xA223736F, 0x9FB4C428, 0x25D04979,
- 0x34C713F8, 0xC4618187, 0xEA7A6E98,
- 0x7CD16EFC, 0x1436876C, 0xF1544107,
- 0xBEDEEE14, 0x56E9AF27, 0xA04AA441,
- 0x3CF7C899, 0x92ECBAE6, 0xDD67016D,
- 0x151682EB, 0xA842EEDF, 0xFDBA60B4,
- 0xF1907B75, 0x20E3030F, 0x24D8C29E,
- 0xE139673B, 0xEFA63FB8, 0x71873054,
- 0xB6F2CF3B, 0x9F326442, 0xCB15A4CC,
- 0xB01A4504, 0xF1E47D8D, 0x844A1BE5,
- 0xBAE7DFDC, 0x42CBDA70, 0xCD7DAE0A,
- 0x57E85B7A, 0xD53F5AF6, 0x20CF4D8C,
- 0xCEA4D428, 0x79D130A4, 0x3486EBFB,
- 0x33D3CDDC, 0x77853B53, 0x37EFFCB5,
- 0xC5068778, 0xE580B3E6, 0x4E68B8F4,
- 0xC5C8B37E, 0x0D809EA2, 0x398FEB7C,
- 0x132A4F94, 0x43B7950E, 0x2FEE7D1C,
- 0x223613BD, 0xDD06CAA2, 0x37DF932B,
- 0xC4248289, 0xACF3EBC3, 0x5715F6B7,
- 0xEF3478DD, 0xF267616F, 0xC148CBE4,
- 0x9052815E, 0x5E410FAB, 0xB48A2465,
- 0x2EDA7FA4, 0xE87B40E4, 0xE98EA084,
- 0x5889E9E1, 0xEFD390FC, 0xDD07D35B,
- 0xDB485694, 0x38D7E5B2, 0x57720101,
- 0x730EDEBC, 0x5B643113, 0x94917E4F,
- 0x503C2FBA, 0x646F1282, 0x7523D24A,
- 0xE0779695, 0xF9C17A8F, 0x7A5B2121,
- 0xD187B896, 0x29263A4D, 0xBA510CDF,
- 0x81F47C9F, 0xAD1163ED, 0xEA7B5965,
- 0x1A00726E, 0x11403092, 0x00DA6D77,
- 0x4A0CDD61, 0xAD1F4603, 0x605BDFB0,
- 0x9EEDC364, 0x22EBE6A8, 0xCEE7D28A,
- 0xA0E736A0, 0x5564A6B9, 0x10853209,
- 0xC7EB8F37, 0x2DE705CA, 0x8951570F,
- 0xDF09822B, 0xBD691A6C, 0xAA12E4F2,
- 0x87451C0F, 0xE0F6A27A, 0x3ADA4819,
- 0x4CF1764F, 0x0D771C2B, 0x67CDB156,
- 0x350D8384, 0x5938FA0F, 0x42399EF3,
- 0x36997B07, 0x0E84093D, 0x4AA93E61,
- 0x8360D87B, 0x1FA98B0C, 0x1149382C,
- 0xE97625A5, 0x0614D1B7, 0x0E25244B,
- 0x0C768347, 0x589E8D82, 0x0D2059D1,
- 0xA466BB1E, 0xF8DA0A82, 0x04F19130,
- 0xBA6E4EC0, 0x99265164, 0x1EE7230D,
- 0x50B2AD80, 0xEAEE6801, 0x8DB2A283,
- 0xEA8BF59E };
-
+ private static final int[] S1 = {
+ 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3,
+ 0x6003E540, 0xCF9FC949, 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675,
+ 0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E, 0x28683B6F, 0xC07FD059,
+ 0xFF2379C8, 0x775F50E2, 0x43C340D3, 0xDF2F8656, 0x887CA41A, 0xA2D2BD2D,
+ 0xA1C9E0D6, 0x346C4819, 0x61B76D87, 0x22540F2F, 0x2ABE32E1, 0xAA54166B,
+ 0x22568E3A, 0xA2D341D0, 0x66DB40C8, 0xA784392F, 0x004DFF2F, 0x2DB9D2DE,
+ 0x97943FAC, 0x4A97C1D8, 0x527644B7, 0xB5F437A7, 0xB82CBAEF, 0xD751D159,
+ 0x6FF7F0ED, 0x5A097A1F, 0x827B68D0, 0x90ECF52E, 0x22B0C054, 0xBC8E5935,
+ 0x4B6D2F7F, 0x50BB64A2, 0xD2664910, 0xBEE5812D, 0xB7332290, 0xE93B159F,
+ 0xB48EE411, 0x4BFF345D, 0xFD45C240, 0xAD31973F, 0xC4F6D02E, 0x55FC8165,
+ 0xD5B1CAAD, 0xA1AC2DAE, 0xA2D4B76D, 0xC19B0C50, 0x882240F2, 0x0C6E4F38,
+ 0xA4E4BFD7, 0x4F5BA272, 0x564C1D2F, 0xC59C5319, 0xB949E354, 0xB04669FE,
+ 0xB1B6AB8A, 0xC71358DD, 0x6385C545, 0x110F935D, 0x57538AD5, 0x6A390493,
+ 0xE63D37E0, 0x2A54F6B3, 0x3A787D5F, 0x6276A0B5, 0x19A6FCDF, 0x7A42206A,
+ 0x29F9D4D5, 0xF61B1891, 0xBB72275E, 0xAA508167, 0x38901091, 0xC6B505EB,
+ 0x84C7CB8C, 0x2AD75A0F, 0x874A1427, 0xA2D1936B, 0x2AD286AF, 0xAA56D291,
+ 0xD7894360, 0x425C750D, 0x93B39E26, 0x187184C9, 0x6C00B32D, 0x73E2BB14,
+ 0xA0BEBC3C, 0x54623779, 0x64459EAB, 0x3F328B82, 0x7718CF82, 0x59A2CEA6,
+ 0x04EE002E, 0x89FE78E6, 0x3FAB0950, 0x325FF6C2, 0x81383F05, 0x6963C5C8,
+ 0x76CB5AD6, 0xD49974C9, 0xCA180DCF, 0x380782D5, 0xC7FA5CF6, 0x8AC31511,
+ 0x35E79E13, 0x47DA91D0, 0xF40F9086, 0xA7E2419E, 0x31366241, 0x051EF495,
+ 0xAA573B04, 0x4A805D8D, 0x548300D0, 0x00322A3C, 0xBF64CDDF, 0xBA57A68E,
+ 0x75C6372B, 0x50AFD341, 0xA7C13275, 0x915A0BF5, 0x6B54BFAB, 0x2B0B1426,
+ 0xAB4CC9D7, 0x449CCD82, 0xF7FBF265, 0xAB85C5F3, 0x1B55DB94, 0xAAD4E324,
+ 0xCFA4BD3F, 0x2DEAA3E2, 0x9E204D02, 0xC8BD25AC, 0xEADF55B3, 0xD5BD9E98,
+ 0xE31231B2, 0x2AD5AD6C, 0x954329DE, 0xADBE4528, 0xD8710F69, 0xAA51C90F,
+ 0xAA786BF6, 0x22513F1E, 0xAA51A79B, 0x2AD344CC, 0x7B5A41F0, 0xD37CFBAD,
+ 0x1B069505, 0x41ECE491, 0xB4C332E6, 0x032268D4, 0xC9600ACC, 0xCE387E6D,
+ 0xBF6BB16C, 0x6A70FB78, 0x0D03D9C9, 0xD4DF39DE, 0xE01063DA, 0x4736F464,
+ 0x5AD328D8, 0xB347CC96, 0x75BB0FC3, 0x98511BFB, 0x4FFBCC35, 0xB58BCF6A,
+ 0xE11F0ABC, 0xBFC5FE4A, 0xA70AEC10, 0xAC39570A, 0x3F04442F, 0x6188B153,
+ 0xE0397A2E, 0x5727CB79, 0x9CEB418F, 0x1CACD68D, 0x2AD37C96, 0x0175CB9D,
+ 0xC69DFF09, 0xC75B65F0, 0xD9DB40D8, 0xEC0E7779, 0x4744EAD4, 0xB11C3274,
+ 0xDD24CB9E, 0x7E1C54BD, 0xF01144F9, 0xD2240EB1, 0x9675B3FD, 0xA3AC3755,
+ 0xD47C27AF, 0x51C85F4D, 0x56907596, 0xA5BB15E6, 0x580304F0, 0xCA042CF1,
+ 0x011A37EA, 0x8DBFAADB, 0x35BA3E4A, 0x3526FFA0, 0xC37B4D09, 0xBC306ED9,
+ 0x98A52666, 0x5648F725, 0xFF5E569D, 0x0CED63D0, 0x7C63B2CF, 0x700B45E1,
+ 0xD5EA50F1, 0x85A92872, 0xAF1FBDA7, 0xD4234870, 0xA7870BF3, 0x2D3B4D79,
+ 0x42E04198, 0x0CD0EDE7, 0x26470DB8, 0xF881814C, 0x474D6AD7, 0x7C0C5E5C,
+ 0xD1231959, 0x381B7298, 0xF5D2F4DB, 0xAB838653, 0x6E2F1E23, 0x83719C9E,
+ 0xBD91E046, 0x9A56456E, 0xDC39200C, 0x20C8C571, 0x962BDA1C, 0xE1E696FF,
+ 0xB141AB08, 0x7CCA89B9, 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D,
+ 0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF };
+ private static final int[] S2 = {
+ 0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380, 0xFE61CF7A, 0xEEC5207A,
+ 0x55889C94, 0x72FC0651, 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA,
+ 0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605,
+ 0xEE15B094, 0xE9FFD909, 0xDC440086, 0xEF944459, 0xBA83CCB3, 0xE0C3CDFB,
+ 0xD1DA4181, 0x3B092AB1, 0xF997F1C1, 0xA5E6CF7B, 0x01420DDB, 0xE4E7EF5B,
+ 0x25A1FF41, 0xE180F806, 0x1FC41080, 0x179BEE7A, 0xD37AC6A9, 0xFE5830A4,
+ 0x98DE8B7F, 0x77E83F4E, 0x79929269, 0x24FA9F7B, 0xE113C85B, 0xACC40083,
+ 0xD7503525, 0xF7EA615F, 0x62143154, 0x0D554B63, 0x5D681121, 0xC866C359,
+ 0x3D63CF73, 0xCEE234C0, 0xD4D87E87, 0x5C672B21, 0x071F6181, 0x39F7627F,
+ 0x361E3084, 0xE4EB573B, 0x602F64A4, 0xD63ACD9C, 0x1BBC4635, 0x9E81032D,
+ 0x2701F50C, 0x99847AB4, 0xA0E3DF79, 0xBA6CF38C, 0x10843094, 0x2537A95E,
+ 0xF46F6FFE, 0xA1FF3B1F, 0x208CFB6A, 0x8F458C74, 0xD9E0A227, 0x4EC73A34,
+ 0xFC884F69, 0x3E4DE8DF, 0xEF0E0088, 0x3559648D, 0x8A45388C, 0x1D804366,
+ 0x721D9BFD, 0xA58684BB, 0xE8256333, 0x844E8212, 0x128D8098, 0xFED33FB4,
+ 0xCE280AE1, 0x27E19BA5, 0xD5A6C252, 0xE49754BD, 0xC5D655DD, 0xEB667064,
+ 0x77840B4D, 0xA1B6A801, 0x84DB26A9, 0xE0B56714, 0x21F043B7, 0xE5D05860,
+ 0x54F03084, 0x066FF472, 0xA31AA153, 0xDADC4755, 0xB5625DBF, 0x68561BE6,
+ 0x83CA6B94, 0x2D6ED23B, 0xECCF01DB, 0xA6D3D0BA, 0xB6803D5C, 0xAF77A709,
+ 0x33B4A34C, 0x397BC8D6, 0x5EE22B95, 0x5F0E5304, 0x81ED6F61, 0x20E74364,
+ 0xB45E1378, 0xDE18639B, 0x881CA122, 0xB96726D1, 0x8049A7E8, 0x22B7DA7B,
+ 0x5E552D25, 0x5272D237, 0x79D2951C, 0xC60D894C, 0x488CB402, 0x1BA4FE5B,
+ 0xA4B09F6B, 0x1CA815CF, 0xA20C3005, 0x8871DF63, 0xB9DE2FCB, 0x0CC6C9E9,
+ 0x0BEEFF53, 0xE3214517, 0xB4542835, 0x9F63293C, 0xEE41E729, 0x6E1D2D7C,
+ 0x50045286, 0x1E6685F3, 0xF33401C6, 0x30A22C95, 0x31A70850, 0x60930F13,
+ 0x73F98417, 0xA1269859, 0xEC645C44, 0x52C877A9, 0xCDFF33A6, 0xA02B1741,
+ 0x7CBAD9A2, 0x2180036F, 0x50D99C08, 0xCB3F4861, 0xC26BD765, 0x64A3F6AB,
+ 0x80342676, 0x25A75E7B, 0xE4E6D1FC, 0x20C710E6, 0xCDF0B680, 0x17844D3B,
+ 0x31EEF84D, 0x7E0824E4, 0x2CCB49EB, 0x846A3BAE, 0x8FF77888, 0xEE5D60F6,
+ 0x7AF75673, 0x2FDD5CDB, 0xA11631C1, 0x30F66F43, 0xB3FAEC54, 0x157FD7FA,
+ 0xEF8579CC, 0xD152DE58, 0xDB2FFD5E, 0x8F32CE19, 0x306AF97A, 0x02F03EF8,
+ 0x99319AD5, 0xC242FA0F, 0xA7E3EBB0, 0xC68E4906, 0xB8DA230C, 0x80823028,
+ 0xDCDEF3C8, 0xD35FB171, 0x088A1BC8, 0xBEC0C560, 0x61A3C9E8, 0xBCA8F54D,
+ 0xC72FEFFA, 0x22822E99, 0x82C570B4, 0xD8D94E89, 0x8B1C34BC, 0x301E16E6,
+ 0x273BE979, 0xB0FFEAA6, 0x61D9B8C6, 0x00B24869, 0xB7FFCE3F, 0x08DC283B,
+ 0x43DAF65A, 0xF7E19798, 0x7619B72F, 0x8F1C9BA4, 0xDC8637A0, 0x16A7D3B1,
+ 0x9FC393B7, 0xA7136EEB, 0xC6BCC63E, 0x1A513742, 0xEF6828BC, 0x520365D6,
+ 0x2D6A77AB, 0x3527ED4B, 0x821FD216, 0x095C6E2E, 0xDB92F2FB, 0x5EEA29CB,
+ 0x145892F5, 0x91584F7F, 0x5483697B, 0x2667A8CC, 0x85196048, 0x8C4BACEA,
+ 0x833860D4, 0x0D23E0F9, 0x6C387E8A, 0x0AE6D249, 0xB284600C, 0xD835731D,
+ 0xDCB1C647, 0xAC4C56EA, 0x3EBD81B3, 0x230EABB0, 0x6438BC87, 0xF0B5B1FA,
+ 0x8F5EA2B3, 0xFC184642, 0x0A036B7A, 0x4FB089BD, 0x649DA589, 0xA345415E,
+ 0x5C038323, 0x3E5D3BB9, 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF,
+ 0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1 };
+ private static final int[] S3 = {
+ 0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907, 0x47607FFF, 0x369FE44B,
+ 0x8C1FC644, 0xAECECA90, 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE,
+ 0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5, 0x11107D9F, 0x07647DB9,
+ 0xB2E3E4D4, 0x3D4F285E, 0xB9AFA820, 0xFADE82E0, 0xA067268B, 0x8272792E,
+ 0x553FB2C0, 0x489AE22B, 0xD4EF9794, 0x125E3FBC, 0x21FFFCEE, 0x825B1BFD,
+ 0x9255C5ED, 0x1257A240, 0x4E1A8302, 0xBAE07FFF, 0x528246E7, 0x8E57140E,
+ 0x3373F7BF, 0x8C9F8188, 0xA6FC4EE8, 0xC982B5A5, 0xA8C01DB7, 0x579FC264,
+ 0x67094F31, 0xF2BD3F5F, 0x40FFF7C1, 0x1FB78DFC, 0x8E6BD2C1, 0x437BE59B,
+ 0x99B03DBF, 0xB5DBC64B, 0x638DC0E6, 0x55819D99, 0xA197C81C, 0x4A012D6E,
+ 0xC5884A28, 0xCCC36F71, 0xB843C213, 0x6C0743F1, 0x8309893C, 0x0FEDDD5F,
+ 0x2F7FE850, 0xD7C07F7E, 0x02507FBF, 0x5AFB9A04, 0xA747D2D0, 0x1651192E,
+ 0xAF70BF3E, 0x58C31380, 0x5F98302E, 0x727CC3C4, 0x0A0FB402, 0x0F7FEF82,
+ 0x8C96FDAD, 0x5D2C2AAE, 0x8EE99A49, 0x50DA88B8, 0x8427F4A0, 0x1EAC5790,
+ 0x796FB449, 0x8252DC15, 0xEFBD7D9B, 0xA672597D, 0xADA840D8, 0x45F54504,
+ 0xFA5D7403, 0xE83EC305, 0x4F91751A, 0x925669C2, 0x23EFE941, 0xA903F12E,
+ 0x60270DF2, 0x0276E4B6, 0x94FD6574, 0x927985B2, 0x8276DBCB, 0x02778176,
+ 0xF8AF918D, 0x4E48F79E, 0x8F616DDF, 0xE29D840E, 0x842F7D83, 0x340CE5C8,
+ 0x96BBB682, 0x93B4B148, 0xEF303CAB, 0x984FAF28, 0x779FAF9B, 0x92DC560D,
+ 0x224D1E20, 0x8437AA88, 0x7D29DC96, 0x2756D3DC, 0x8B907CEE, 0xB51FD240,
+ 0xE7C07CE3, 0xE566B4A1, 0xC3E9615E, 0x3CF8209D, 0x6094D1E3, 0xCD9CA341,
+ 0x5C76460E, 0x00EA983B, 0xD4D67881, 0xFD47572C, 0xF76CEDD9, 0xBDA8229C,
+ 0x127DADAA, 0x438A074E, 0x1F97C090, 0x081BDB8A, 0x93A07EBE, 0xB938CA15,
+ 0x97B03CFF, 0x3DC2C0F8, 0x8D1AB2EC, 0x64380E51, 0x68CC7BFB, 0xD90F2788,
+ 0x12490181, 0x5DE5FFD4, 0xDD7EF86A, 0x76A2E214, 0xB9A40368, 0x925D958F,
+ 0x4B39FFFA, 0xBA39AEE9, 0xA4FFD30B, 0xFAF7933B, 0x6D498623, 0x193CBCFA,
+ 0x27627545, 0x825CF47A, 0x61BD8BA0, 0xD11E42D1, 0xCEAD04F4, 0x127EA392,
+ 0x10428DB7, 0x8272A972, 0x9270C4A8, 0x127DE50B, 0x285BA1C8, 0x3C62F44F,
+ 0x35C0EAA5, 0xE805D231, 0x428929FB, 0xB4FCDF82, 0x4FB66A53, 0x0E7DC15B,
+ 0x1F081FAB, 0x108618AE, 0xFCFD086D, 0xF9FF2889, 0x694BCC11, 0x236A5CAE,
+ 0x12DECA4D, 0x2C3F8CC5, 0xD2D02DFE, 0xF8EF5896, 0xE4CF52DA, 0x95155B67,
+ 0x494A488C, 0xB9B6A80C, 0x5C8F82BC, 0x89D36B45, 0x3A609437, 0xEC00C9A9,
+ 0x44715253, 0x0A874B49, 0xD773BC40, 0x7C34671C, 0x02717EF6, 0x4FEB5536,
+ 0xA2D02FFF, 0xD2BF60C4, 0xD43F03C0, 0x50B4EF6D, 0x07478CD1, 0x006E1888,
+ 0xA2E53F55, 0xB9E6D4BC, 0xA2048016, 0x97573833, 0xD7207D67, 0xDE0F8F3D,
+ 0x72F87B33, 0xABCC4F33, 0x7688C55D, 0x7B00A6B0, 0x947B0001, 0x570075D2,
+ 0xF9BB88F8, 0x8942019E, 0x4264A5FF, 0x856302E0, 0x72DBD92B, 0xEE971B69,
+ 0x6EA22FDE, 0x5F08AE2B, 0xAF7A616D, 0xE5C98767, 0xCF1FEBD2, 0x61EFC8C2,
+ 0xF1AC2571, 0xCC8239C2, 0x67214CB8, 0xB1E583D1, 0xB7DC3E62, 0x7F10BDCE,
+ 0xF90A5C38, 0x0FF0443D, 0x606E6DC6, 0x60543A49, 0x5727C148, 0x2BE98A1D,
+ 0x8AB41738, 0x20E1BE24, 0xAF96DA0F, 0x68458425, 0x99833BE5, 0x600D457D,
+ 0x282F9350, 0x8334B362, 0xD91D1120, 0x2B6D8DA0, 0x642B1E31, 0x9C305A00,
+ 0x52BCE688, 0x1B03588A, 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5,
+ 0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783 };
+ private static final int[] S4 = {
+ 0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298, 0x4A4F7BDB, 0x64AD8C57,
+ 0x85510443, 0xFA020ED1, 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120,
+ 0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD,
+ 0xC9430040, 0x0CC32220, 0xFDD30B30, 0xC0A5374F, 0x1D2D00D9, 0x24147B15,
+ 0xEE4D111A, 0x0FCA5167, 0x71FF904C, 0x2D195FFE, 0x1A05645F, 0x0C13FEFE,
+ 0x081B08CA, 0x05170121, 0x80530100, 0xE83E5EFE, 0xAC9AF4F8, 0x7FE72701,
+ 0xD2B8EE5F, 0x06DF4261, 0xBB9E9B8A, 0x7293EA25, 0xCE84FFDF, 0xF5718801,
+ 0x3DD64B04, 0xA26F263B, 0x7ED48400, 0x547EEBE6, 0x446D4CA0, 0x6CF3D6F5,
+ 0x2649ABDF, 0xAEA0C7F5, 0x36338CC1, 0x503F7E93, 0xD3772061, 0x11B638E1,
+ 0x72500E03, 0xF80EB2BB, 0xABE0502E, 0xEC8D77DE, 0x57971E81, 0xE14F6746,
+ 0xC9335400, 0x6920318F, 0x081DBB99, 0xFFC304A5, 0x4D351805, 0x7F3D5CE3,
+ 0xA6C866C6, 0x5D5BCCA9, 0xDAEC6FEA, 0x9F926F91, 0x9F46222F, 0x3991467D,
+ 0xA5BF6D8E, 0x1143C44F, 0x43958302, 0xD0214EEB, 0x022083B8, 0x3FB6180C,
+ 0x18F8931E, 0x281658E6, 0x26486E3E, 0x8BD78A70, 0x7477E4C1, 0xB506E07C,
+ 0xF32D0A25, 0x79098B02, 0xE4EABB81, 0x28123B23, 0x69DEAD38, 0x1574CA16,
+ 0xDF871B62, 0x211C40B7, 0xA51A9EF9, 0x0014377B, 0x041E8AC8, 0x09114003,
+ 0xBD59E4D2, 0xE3D156D5, 0x4FE876D5, 0x2F91A340, 0x557BE8DE, 0x00EAE4A7,
+ 0x0CE5C2EC, 0x4DB4BBA6, 0xE756BDFF, 0xDD3369AC, 0xEC17B035, 0x06572327,
+ 0x99AFC8B0, 0x56C8C391, 0x6B65811C, 0x5E146119, 0x6E85CB75, 0xBE07C002,
+ 0xC2325577, 0x893FF4EC, 0x5BBFC92D, 0xD0EC3B25, 0xB7801AB7, 0x8D6D3B24,
+ 0x20C763EF, 0xC366A5FC, 0x9C382880, 0x0ACE3205, 0xAAC9548A, 0xECA1D7C7,
+ 0x041AFA32, 0x1D16625A, 0x6701902C, 0x9B757A54, 0x31D477F7, 0x9126B031,
+ 0x36CC6FDB, 0xC70B8B46, 0xD9E66A48, 0x56E55A79, 0x026A4CEB, 0x52437EFF,
+ 0x2F8F76B4, 0x0DF980A5, 0x8674CDE3, 0xEDDA04EB, 0x17A9BE04, 0x2C18F4DF,
+ 0xB7747F9D, 0xAB2AF7B4, 0xEFC34D20, 0x2E096B7C, 0x1741A254, 0xE5B6A035,
+ 0x213D42F6, 0x2C1C7C26, 0x61C2F50F, 0x6552DAF9, 0xD2C231F8, 0x25130F69,
+ 0xD8167FA2, 0x0418F2C8, 0x001A96A6, 0x0D1526AB, 0x63315C21, 0x5E0A72EC,
+ 0x49BAFEFD, 0x187908D9, 0x8D0DBD86, 0x311170A7, 0x3E9B640C, 0xCC3E10D7,
+ 0xD5CAD3B6, 0x0CAEC388, 0xF73001E1, 0x6C728AFF, 0x71EAE2A1, 0x1F9AF36E,
+ 0xCFCBD12F, 0xC1DE8417, 0xAC07BE6B, 0xCB44A1D8, 0x8B9B0F56, 0x013988C3,
+ 0xB1C52FCA, 0xB4BE31CD, 0xD8782806, 0x12A3A4E2, 0x6F7DE532, 0x58FD7EB6,
+ 0xD01EE900, 0x24ADFFC2, 0xF4990FC5, 0x9711AAC5, 0x001D7B95, 0x82E5E7D2,
+ 0x109873F6, 0x00613096, 0xC32D9521, 0xADA121FF, 0x29908415, 0x7FBB977F,
+ 0xAF9EB3DB, 0x29C9ED2A, 0x5CE2A465, 0xA730F32C, 0xD0AA3FE8, 0x8A5CC091,
+ 0xD49E2CE7, 0x0CE454A9, 0xD60ACD86, 0x015F1919, 0x77079103, 0xDEA03AF6,
+ 0x78A8565E, 0xDEE356DF, 0x21F05CBE, 0x8B75E387, 0xB3C50651, 0xB8A5C3EF,
+ 0xD8EEB6D2, 0xE523BE77, 0xC2154529, 0x2F69EFDF, 0xAFE67AFB, 0xF470C4B2,
+ 0xF3E0EB5B, 0xD6CC9876, 0x39E4460C, 0x1FDA8538, 0x1987832F, 0xCA007367,
+ 0xA99144F8, 0x296B299E, 0x492FC295, 0x9266BEAB, 0xB5676E69, 0x9BD3DDDA,
+ 0xDF7E052F, 0xDB25701C, 0x1B5E51EE, 0xF65324E6, 0x6AFCE36C, 0x0316CC04,
+ 0x8644213E, 0xB7DC59D0, 0x7965291F, 0xCCD6FD43, 0x41823979, 0x932BCDF6,
+ 0xB657C34D, 0x4EDFD282, 0x7AE5290C, 0x3CB9536B, 0x851E20FE, 0x9833557E,
+ 0x13ECF0B0, 0xD3FFB372, 0x3F85C5C1, 0x0AEF7ED2 };
+ private static final int[] S5 = {
+ 0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911, 0xB86A7FFF, 0x1DD358F5,
+ 0x44DD9D44, 0x1731167F, 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00,
+ 0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD,
+ 0xC4494816, 0xCCF5C180, 0x38851640, 0x15B0A848, 0xE68B18CB, 0x4CAADEFF,
+ 0x5F480A01, 0x0412B2AA, 0x259814FC, 0x41D0EFE2, 0x4E40B48D, 0x248EB6FB,
+ 0x8DBA1CFE, 0x41A99B02, 0x1A550A04, 0xBA8F65CB, 0x7251F4E7, 0x95A51725,
+ 0xC106ECD7, 0x97A5980A, 0xC539B9AA, 0x4D79FE6A, 0xF2F3F763, 0x68AF8040,
+ 0xED0C9E56, 0x11B4958B, 0xE1EB5A88, 0x8709E6B0, 0xD7E07156, 0x4E29FEA7,
+ 0x6366E52D, 0x02D1C000, 0xC4AC8E05, 0x9377F571, 0x0C05372A, 0x578535F2,
+ 0x2261BE02, 0xD642A0C9, 0xDF13A280, 0x74B55BD2, 0x682199C0, 0xD421E5EC,
+ 0x53FB3CE8, 0xC8ADEDB3, 0x28A87FC9, 0x3D959981, 0x5C1FF900, 0xFE38D399,
+ 0x0C4EFF0B, 0x062407EA, 0xAA2F4FB1, 0x4FB96976, 0x90C79505, 0xB0A8A774,
+ 0xEF55A1FF, 0xE59CA2C2, 0xA6B62D27, 0xE66A4263, 0xDF65001F, 0x0EC50966,
+ 0xDFDD55BC, 0x29DE0655, 0x911E739A, 0x17AF8975, 0x32C7911C, 0x89F89468,
+ 0x0D01E980, 0x524755F4, 0x03B63CC9, 0x0CC844B2, 0xBCF3F0AA, 0x87AC36E9,
+ 0xE53A7426, 0x01B3D82B, 0x1A9E7449, 0x64EE2D7E, 0xCDDBB1DA, 0x01C94910,
+ 0xB868BF80, 0x0D26F3FD, 0x9342EDE7, 0x04A5C284, 0x636737B6, 0x50F5B616,
+ 0xF24766E3, 0x8ECA36C1, 0x136E05DB, 0xFEF18391, 0xFB887A37, 0xD6E7F7D4,
+ 0xC7FB7DC9, 0x3063FCDF, 0xB6F589DE, 0xEC2941DA, 0x26E46695, 0xB7566419,
+ 0xF654EFC5, 0xD08D58B7, 0x48925401, 0xC1BACB7F, 0xE5FF550F, 0xB6083049,
+ 0x5BB5D0E8, 0x87D72E5A, 0xAB6A6EE1, 0x223A66CE, 0xC62BF3CD, 0x9E0885F9,
+ 0x68CB3E47, 0x086C010F, 0xA21DE820, 0xD18B69DE, 0xF3F65777, 0xFA02C3F6,
+ 0x407EDAC3, 0xCBB3D550, 0x1793084D, 0xB0D70EBA, 0x0AB378D5, 0xD951FB0C,
+ 0xDED7DA56, 0x4124BBE4, 0x94CA0B56, 0x0F5755D1, 0xE0E1E56E, 0x6184B5BE,
+ 0x580A249F, 0x94F74BC0, 0xE327888E, 0x9F7B5561, 0xC3DC0280, 0x05687715,
+ 0x646C6BD7, 0x44904DB3, 0x66B4F0A3, 0xC0F1648A, 0x697ED5AF, 0x49E92FF6,
+ 0x309E374F, 0x2CB6356A, 0x85808573, 0x4991F840, 0x76F0AE02, 0x083BE84D,
+ 0x28421C9A, 0x44489406, 0x736E4CB8, 0xC1092910, 0x8BC95FC6, 0x7D869CF4,
+ 0x134F616F, 0x2E77118D, 0xB31B2BE1, 0xAA90B472, 0x3CA5D717, 0x7D161BBA,
+ 0x9CAD9010, 0xAF462BA2, 0x9FE459D2, 0x45D34559, 0xD9F2DA13, 0xDBC65487,
+ 0xF3E4F94E, 0x176D486F, 0x097C13EA, 0x631DA5C7, 0x445F7382, 0x175683F4,
+ 0xCDC66A97, 0x70BE0288, 0xB3CDCF72, 0x6E5DD2F3, 0x20936079, 0x459B80A5,
+ 0xBE60E2DB, 0xA9C23101, 0xEBA5315C, 0x224E42F2, 0x1C5C1572, 0xF6721B2C,
+ 0x1AD2FFF3, 0x8C25404E, 0x324ED72F, 0x4067B7FD, 0x0523138E, 0x5CA3BC78,
+ 0xDC0FD66E, 0x75922283, 0x784D6B17, 0x58EBB16E, 0x44094F85, 0x3F481D87,
+ 0xFCFEAE7B, 0x77B5FF76, 0x8C2302BF, 0xAAF47556, 0x5F46B02A, 0x2B092801,
+ 0x3D38F5F7, 0x0CA81F36, 0x52AF4A8A, 0x66D5E7C0, 0xDF3B0874, 0x95055110,
+ 0x1B5AD7A8, 0xF61ED5AD, 0x6CF6E479, 0x20758184, 0xD0CEFA65, 0x88F7BE58,
+ 0x4A046826, 0x0FF6F8F3, 0xA09C7F70, 0x5346ABA0, 0x5CE96C28, 0xE176EDA3,
+ 0x6BAC307F, 0x376829D2, 0x85360FA9, 0x17E3FE2A, 0x24B79767, 0xF5A96B20,
+ 0xD6CD2595, 0x68FF1EBF, 0x7555442C, 0xF19F06BE, 0xF9E0659A, 0xEEB9491D,
+ 0x34010718, 0xBB30CAB8, 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55,
+ 0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4 };
+ private static final int[] S6 = {
+ 0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C, 0x95DB08E7, 0x016843B4,
+ 0xECED5CBC, 0x325553AC, 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9,
+ 0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138, 0x33F14961, 0xC01937BD,
+ 0xF506C6DA, 0xE4625E7E, 0xA308EA99, 0x4E23E33C, 0x79CBD7CC, 0x48A14367,
+ 0xA3149619, 0xFEC94BD5, 0xA114174A, 0xEAA01866, 0xA084DB2D, 0x09A8486F,
+ 0xA888614A, 0x2900AF98, 0x01665991, 0xE1992863, 0xC8F30C60, 0x2E78EF3C,
+ 0xD0D51932, 0xCF0FEC14, 0xF7CA07D2, 0xD0A82072, 0xFD41197E, 0x9305A6B0,
+ 0xE86BE3DA, 0x74BED3CD, 0x372DA53C, 0x4C7F4448, 0xDAB5D440, 0x6DBA0EC3,
+ 0x083919A7, 0x9FBAEED9, 0x49DBCFB0, 0x4E670C53, 0x5C3D9C01, 0x64BDB941,
+ 0x2C0E636A, 0xBA7DD9CD, 0xEA6F7388, 0xE70BC762, 0x35F29ADB, 0x5C4CDD8D,
+ 0xF0D48D8C, 0xB88153E2, 0x08A19866, 0x1AE2EAC8, 0x284CAF89, 0xAA928223,
+ 0x9334BE53, 0x3B3A21BF, 0x16434BE3, 0x9AEA3906, 0xEFE8C36E, 0xF890CDD9,
+ 0x80226DAE, 0xC340A4A3, 0xDF7E9C09, 0xA694A807, 0x5B7C5ECC, 0x221DB3A6,
+ 0x9A69A02F, 0x68818A54, 0xCEB2296F, 0x53C0843A, 0xFE893655, 0x25BFE68A,
+ 0xB4628ABC, 0xCF222EBF, 0x25AC6F48, 0xA9A99387, 0x53BDDB65, 0xE76FFBE7,
+ 0xE967FD78, 0x0BA93563, 0x8E342BC1, 0xE8A11BE9, 0x4980740D, 0xC8087DFC,
+ 0x8DE4BF99, 0xA11101A0, 0x7FD37975, 0xDA5A26C0, 0xE81F994F, 0x9528CD89,
+ 0xFD339FED, 0xB87834BF, 0x5F04456D, 0x22258698, 0xC9C4C83B, 0x2DC156BE,
+ 0x4F628DAA, 0x57F55EC5, 0xE2220ABE, 0xD2916EBF, 0x4EC75B95, 0x24F2C3C0,
+ 0x42D15D99, 0xCD0D7FA0, 0x7B6E27FF, 0xA8DC8AF0, 0x7345C106, 0xF41E232F,
+ 0x35162386, 0xE6EA8926, 0x3333B094, 0x157EC6F2, 0x372B74AF, 0x692573E4,
+ 0xE9A9D848, 0xF3160289, 0x3A62EF1D, 0xA787E238, 0xF3A5F676, 0x74364853,
+ 0x20951063, 0x4576698D, 0xB6FAD407, 0x592AF950, 0x36F73523, 0x4CFB6E87,
+ 0x7DA4CEC0, 0x6C152DAA, 0xCB0396A8, 0xC50DFE5D, 0xFCD707AB, 0x0921C42F,
+ 0x89DFF0BB, 0x5FE2BE78, 0x448F4F33, 0x754613C9, 0x2B05D08D, 0x48B9D585,
+ 0xDC049441, 0xC8098F9B, 0x7DEDE786, 0xC39A3373, 0x42410005, 0x6A091751,
+ 0x0EF3C8A6, 0x890072D6, 0x28207682, 0xA9A9F7BE, 0xBF32679D, 0xD45B5B75,
+ 0xB353FD00, 0xCBB0E358, 0x830F220A, 0x1F8FB214, 0xD372CF08, 0xCC3C4A13,
+ 0x8CF63166, 0x061C87BE, 0x88C98F88, 0x6062E397, 0x47CF8E7A, 0xB6C85283,
+ 0x3CC2ACFB, 0x3FC06976, 0x4E8F0252, 0x64D8314D, 0xDA3870E3, 0x1E665459,
+ 0xC10908F0, 0x513021A5, 0x6C5B68B7, 0x822F8AA0, 0x3007CD3E, 0x74719EEF,
+ 0xDC872681, 0x073340D4, 0x7E432FD9, 0x0C5EC241, 0x8809286C, 0xF592D891,
+ 0x08A930F6, 0x957EF305, 0xB7FBFFBD, 0xC266E96F, 0x6FE4AC98, 0xB173ECC0,
+ 0xBC60B42A, 0x953498DA, 0xFBA1AE12, 0x2D4BD736, 0x0F25FAAB, 0xA4F3FCEB,
+ 0xE2969123, 0x257F0C3D, 0x9348AF49, 0x361400BC, 0xE8816F4A, 0x3814F200,
+ 0xA3F94043, 0x9C7A54C2, 0xBC704F57, 0xDA41E7F9, 0xC25AD33A, 0x54F4A084,
+ 0xB17F5505, 0x59357CBE, 0xEDBD15C8, 0x7F97C5AB, 0xBA5AC7B5, 0xB6F6DEAF,
+ 0x3A479C3A, 0x5302DA25, 0x653D7E6A, 0x54268D49, 0x51A477EA, 0x5017D55B,
+ 0xD7D25D88, 0x44136C76, 0x0404A8C8, 0xB8E5A121, 0xB81A928A, 0x60ED5869,
+ 0x97C55B96, 0xEAEC991B, 0x29935913, 0x01FDB7F1, 0x088E8DFA, 0x9AB6F6F5,
+ 0x3B4CBF9F, 0x4A5DE3AB, 0xE6051D35, 0xA0E1D855, 0xD36B4CF1, 0xF544EDEB,
+ 0xB0E93524, 0xBEBB8FBD, 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454,
+ 0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F };
+ private static final int[] S7 = {
+ 0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912,
+ 0xDE6008A1, 0x2028DA1F, 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82,
+ 0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE, 0xA05FBCF6, 0xCD4181E9,
+ 0xE150210C, 0xE24EF1BD, 0xB168C381, 0xFDE4E789, 0x5C79B0D8, 0x1E8BFD43,
+ 0x4D495001, 0x38BE4341, 0x913CEE1D, 0x92A79C3F, 0x089766BE, 0xBAEEADF4,
+ 0x1286BECF, 0xB6EACB19, 0x2660C200, 0x7565BDE4, 0x64241F7A, 0x8248DCA9,
+ 0xC3B3AD66, 0x28136086, 0x0BD8DFA8, 0x356D1CF2, 0x107789BE, 0xB3B2E9CE,
+ 0x0502AA8F, 0x0BC0351E, 0x166BF52A, 0xEB12FF82, 0xE3486911, 0xD34D7516,
+ 0x4E7B3AFF, 0x5F43671B, 0x9CF6E037, 0x4981AC83, 0x334266CE, 0x8C9341B7,
+ 0xD0D854C0, 0xCB3A6C88, 0x47BC2829, 0x4725BA37, 0xA66AD22B, 0x7AD61F1E,
+ 0x0C5CBAFA, 0x4437F107, 0xB6E79962, 0x42D2D816, 0x0A961288, 0xE1A5C06E,
+ 0x13749E67, 0x72FC081A, 0xB1D139F7, 0xF9583745, 0xCF19DF58, 0xBEC3F756,
+ 0xC06EBA30, 0x07211B24, 0x45C28829, 0xC95E317F, 0xBC8EC511, 0x38BC46E9,
+ 0xC6E6FA14, 0xBAE8584A, 0xAD4EBC46, 0x468F508B, 0x7829435F, 0xF124183B,
+ 0x821DBA9F, 0xAFF60FF4, 0xEA2C4E6D, 0x16E39264, 0x92544A8B, 0x009B4FC3,
+ 0xABA68CED, 0x9AC96F78, 0x06A5B79A, 0xB2856E6E, 0x1AEC3CA9, 0xBE838688,
+ 0x0E0804E9, 0x55F1BE56, 0xE7E5363B, 0xB3A1F25D, 0xF7DEBB85, 0x61FE033C,
+ 0x16746233, 0x3C034C28, 0xDA6D0C74, 0x79AAC56C, 0x3CE4E1AD, 0x51F0C802,
+ 0x98F8F35A, 0x1626A49F, 0xEED82B29, 0x1D382FE3, 0x0C4FB99A, 0xBB325778,
+ 0x3EC6D97B, 0x6E77A6A9, 0xCB658B5C, 0xD45230C7, 0x2BD1408B, 0x60C03EB7,
+ 0xB9068D78, 0xA33754F4, 0xF430C87D, 0xC8A71302, 0xB96D8C32, 0xEBD4E7BE,
+ 0xBE8B9D2D, 0x7979FB06, 0xE7225308, 0x8B75CF77, 0x11EF8DA4, 0xE083C858,
+ 0x8D6B786F, 0x5A6317A6, 0xFA5CF7A0, 0x5DDA0033, 0xF28EBFB0, 0xF5B9C310,
+ 0xA0EAC280, 0x08B9767A, 0xA3D9D2B0, 0x79D34217, 0x021A718D, 0x9AC6336A,
+ 0x2711FD60, 0x438050E3, 0x069908A8, 0x3D7FEDC4, 0x826D2BEF, 0x4EEB8476,
+ 0x488DCF25, 0x36C9D566, 0x28E74E41, 0xC2610ACA, 0x3D49A9CF, 0xBAE3B9DF,
+ 0xB65F8DE6, 0x92AEAF64, 0x3AC7D5E6, 0x9EA80509, 0xF22B017D, 0xA4173F70,
+ 0xDD1E16C3, 0x15E0D7F9, 0x50B1B887, 0x2B9F4FD5, 0x625ABA82, 0x6A017962,
+ 0x2EC01B9C, 0x15488AA9, 0xD716E740, 0x40055A2C, 0x93D29A22, 0xE32DBF9A,
+ 0x058745B9, 0x3453DC1E, 0xD699296E, 0x496CFF6F, 0x1C9F4986, 0xDFE2ED07,
+ 0xB87242D1, 0x19DE7EAE, 0x053E561A, 0x15AD6F8C, 0x66626C1C, 0x7154C24C,
+ 0xEA082B2A, 0x93EB2939, 0x17DCB0F0, 0x58D4F2AE, 0x9EA294FB, 0x52CF564C,
+ 0x9883FE66, 0x2EC40581, 0x763953C3, 0x01D6692E, 0xD3A0C108, 0xA1E7160E,
+ 0xE4F2DFA6, 0x693ED285, 0x74904698, 0x4C2B0EDD, 0x4F757656, 0x5D393378,
+ 0xA132234F, 0x3D321C5D, 0xC3F5E194, 0x4B269301, 0xC79F022F, 0x3C997E7E,
+ 0x5E4F9504, 0x3FFAFBBD, 0x76F7AD0E, 0x296693F4, 0x3D1FCE6F, 0xC61E45BE,
+ 0xD3B5AB34, 0xF72BF9B7, 0x1B0434C0, 0x4E72B567, 0x5592A33D, 0xB5229301,
+ 0xCFD2A87F, 0x60AEB767, 0x1814386B, 0x30BCC33D, 0x38A0C07D, 0xFD1606F2,
+ 0xC363519B, 0x589DD390, 0x5479F8E6, 0x1CB8D647, 0x97FD61A9, 0xEA7759F4,
+ 0x2D57539D, 0x569A58CF, 0xE84E63AD, 0x462E1B78, 0x6580F87E, 0xF3817914,
+ 0x91DA55F4, 0x40A230F3, 0xD1988F35, 0xB6E318D2, 0x3FFA50BC, 0x3D40F021,
+ 0xC3C0BDAE, 0x4958C24C, 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA,
+ 0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3 };
+ private static final int[] S8 = {
+ 0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095, 0x7789F8B7, 0xE6C1121B,
+ 0x0E241600, 0x052CE8B5, 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174,
+ 0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C,
+ 0xBE197029, 0x84A00940, 0xBB243A0F, 0xB4D137CF, 0xB44E79F0, 0x049EEDFD,
+ 0x0B15A15D, 0x480D3168, 0x8BBBDE5A, 0x669DED42, 0xC7ECE831, 0x3F8F95E7,
+ 0x72DF191B, 0x7580330D, 0x94074251, 0x5C7DCDFA, 0xABBE6D63, 0xAA402164,
+ 0xB301D40A, 0x02E7D1CA, 0x53571DAE, 0x7A3182A2, 0x12A8DDEC, 0xFDAA335D,
+ 0x176F43E8, 0x71FB46D4, 0x38129022, 0xCE949AD4, 0xB84769AD, 0x965BD862,
+ 0x82F3D055, 0x66FB9767, 0x15B80B4E, 0x1D5B47A0, 0x4CFDE06F, 0xC28EC4B8,
+ 0x57E8726E, 0x647A78FC, 0x99865D44, 0x608BD593, 0x6C200E03, 0x39DC5FF6,
+ 0x5D0B00A3, 0xAE63AFF2, 0x7E8BD632, 0x70108C0C, 0xBBD35049, 0x2998DF04,
+ 0x980CF42A, 0x9B6DF491, 0x9E7EDD53, 0x06918548, 0x58CB7E07, 0x3B74EF2E,
+ 0x522FFFB1, 0xD24708CC, 0x1C7E27CD, 0xA4EB215B, 0x3CF1D2E2, 0x19B47A38,
+ 0x424F7618, 0x35856039, 0x9D17DEE7, 0x27EB35E6, 0xC9AFF67B, 0x36BAF5B8,
+ 0x09C467CD, 0xC18910B1, 0xE11DBF7B, 0x06CD1AF8, 0x7170C608, 0x2D5E3354,
+ 0xD4DE495A, 0x64C6D006, 0xBCC0C62C, 0x3DD00DB3, 0x708F8F34, 0x77D51B42,
+ 0x264F620F, 0x24B8D2BF, 0x15C1B79E, 0x46A52564, 0xF8D7E54E, 0x3E378160,
+ 0x7895CDA5, 0x859C15A5, 0xE6459788, 0xC37BC75F, 0xDB07BA0C, 0x0676A3AB,
+ 0x7F229B1E, 0x31842E7B, 0x24259FD7, 0xF8BEF472, 0x835FFCB8, 0x6DF4C1F2,
+ 0x96F5B195, 0xFD0AF0FC, 0xB0FE134C, 0xE2506D3D, 0x4F9B12EA, 0xF215F225,
+ 0xA223736F, 0x9FB4C428, 0x25D04979, 0x34C713F8, 0xC4618187, 0xEA7A6E98,
+ 0x7CD16EFC, 0x1436876C, 0xF1544107, 0xBEDEEE14, 0x56E9AF27, 0xA04AA441,
+ 0x3CF7C899, 0x92ECBAE6, 0xDD67016D, 0x151682EB, 0xA842EEDF, 0xFDBA60B4,
+ 0xF1907B75, 0x20E3030F, 0x24D8C29E, 0xE139673B, 0xEFA63FB8, 0x71873054,
+ 0xB6F2CF3B, 0x9F326442, 0xCB15A4CC, 0xB01A4504, 0xF1E47D8D, 0x844A1BE5,
+ 0xBAE7DFDC, 0x42CBDA70, 0xCD7DAE0A, 0x57E85B7A, 0xD53F5AF6, 0x20CF4D8C,
+ 0xCEA4D428, 0x79D130A4, 0x3486EBFB, 0x33D3CDDC, 0x77853B53, 0x37EFFCB5,
+ 0xC5068778, 0xE580B3E6, 0x4E68B8F4, 0xC5C8B37E, 0x0D809EA2, 0x398FEB7C,
+ 0x132A4F94, 0x43B7950E, 0x2FEE7D1C, 0x223613BD, 0xDD06CAA2, 0x37DF932B,
+ 0xC4248289, 0xACF3EBC3, 0x5715F6B7, 0xEF3478DD, 0xF267616F, 0xC148CBE4,
+ 0x9052815E, 0x5E410FAB, 0xB48A2465, 0x2EDA7FA4, 0xE87B40E4, 0xE98EA084,
+ 0x5889E9E1, 0xEFD390FC, 0xDD07D35B, 0xDB485694, 0x38D7E5B2, 0x57720101,
+ 0x730EDEBC, 0x5B643113, 0x94917E4F, 0x503C2FBA, 0x646F1282, 0x7523D24A,
+ 0xE0779695, 0xF9C17A8F, 0x7A5B2121, 0xD187B896, 0x29263A4D, 0xBA510CDF,
+ 0x81F47C9F, 0xAD1163ED, 0xEA7B5965, 0x1A00726E, 0x11403092, 0x00DA6D77,
+ 0x4A0CDD61, 0xAD1F4603, 0x605BDFB0, 0x9EEDC364, 0x22EBE6A8, 0xCEE7D28A,
+ 0xA0E736A0, 0x5564A6B9, 0x10853209, 0xC7EB8F37, 0x2DE705CA, 0x8951570F,
+ 0xDF09822B, 0xBD691A6C, 0xAA12E4F2, 0x87451C0F, 0xE0F6A27A, 0x3ADA4819,
+ 0x4CF1764F, 0x0D771C2B, 0x67CDB156, 0x350D8384, 0x5938FA0F, 0x42399EF3,
+ 0x36997B07, 0x0E84093D, 0x4AA93E61, 0x8360D87B, 0x1FA98B0C, 0x1149382C,
+ 0xE97625A5, 0x0614D1B7, 0x0E25244B, 0x0C768347, 0x589E8D82, 0x0D2059D1,
+ 0xA466BB1E, 0xF8DA0A82, 0x04F19130, 0xBA6E4EC0, 0x99265164, 0x1EE7230D,
+ 0x50B2AD80, 0xEAEE6801, 0x8DB2A283, 0xEA8BF59E };
private static final int _12_ROUNDS = 12;
-
private static final int _16_ROUNDS = 16;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Cast5()
{
super(Registry.CAST5_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
* Assuming the input is a 32-bit block organised as: b31b30b29...b0, this
* method returns an array of 4 Java ints, containing from position 0 onward
@@ -848,26 +485,17 @@ public class Cast5 extends BaseCipher
return new int[] { x >>> 24, (x >>> 16) & 0xFF, (x >>> 8) & 0xFF, x & 0xFF };
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Cast5 result = new Cast5();
result.currentBlockSize = this.currentBlockSize;
-
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_BLOCK_SIZE));
-
+ al.add(Integer.valueOf(DEFAULT_BLOCK_SIZE));
return Collections.unmodifiableList(al).iterator();
}
@@ -875,49 +503,43 @@ public class Cast5 extends BaseCipher
{
ArrayList al = new ArrayList();
for (int n = 5; n < 17; n++)
- {
- al.add(new Integer(n));
- }
-
+ al.add(Integer.valueOf(n));
return Collections.unmodifiableList(al).iterator();
}
public Object makeKey(byte[] uk, int bs) throws InvalidKeyException
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (uk == null)
- {
- throw new InvalidKeyException("Empty key");
- }
+ throw new InvalidKeyException("Empty key");
int len = uk.length;
if (len < 5 || len > 16)
- {
- throw new InvalidKeyException(
- "Key size (in bytes) is not in the range [5..16]");
- }
-
+ throw new InvalidKeyException("Key size (in bytes) is not in the range [5..16]");
Cast5Key result = new Cast5Key();
result.rounds = (len < 11) ? _12_ROUNDS : _16_ROUNDS;
byte[] kk = new byte[16];
System.arraycopy(uk, 0, kk, 0, len);
-
int z0z1z2z3, z4z5z6z7, z8z9zAzB, zCzDzEzF;
int z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, zA, zB, zC, zD, zE, zF;
int x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xA, xB, xC, xD, xE, xF;
int[] b;
-
- int x0x1x2x3 = kk[0] << 24 | (kk[1] & 0xFF) << 16 | (kk[2] & 0xFF) << 8
- | (kk[3] & 0xFF);
- int x4x5x6x7 = kk[4] << 24 | (kk[5] & 0xFF) << 16 | (kk[6] & 0xFF) << 8
- | (kk[7] & 0xFF);
- int x8x9xAxB = kk[8] << 24 | (kk[9] & 0xFF) << 16 | (kk[10] & 0xFF) << 8
- | (kk[11] & 0xFF);
- int xCxDxExF = kk[12] << 24 | (kk[13] & 0xFF) << 16 | (kk[14] & 0xFF) << 8
- | (kk[15] & 0xFF);
-
+ int x0x1x2x3 = kk[0 ] << 24
+ | (kk[1 ] & 0xFF) << 16
+ | (kk[2 ] & 0xFF) << 8
+ | (kk[3 ] & 0xFF);
+ int x4x5x6x7 = kk[4 ] << 24
+ | (kk[5 ] & 0xFF) << 16
+ | (kk[6 ] & 0xFF) << 8
+ | (kk[7 ] & 0xFF);
+ int x8x9xAxB = kk[8 ] << 24
+ | (kk[9 ] & 0xFF) << 16
+ | (kk[10] & 0xFF) << 8
+ | (kk[11] & 0xFF);
+ int xCxDxExF = kk[12] << 24
+ | (kk[13] & 0xFF) << 16
+ | (kk[14] & 0xFF) << 8
+ | (kk[15] & 0xFF);
b = unscramble(x0x1x2x3);
x0 = b[0];
x1 = b[1];
@@ -938,7 +560,6 @@ public class Cast5 extends BaseCipher
xD = b[1];
xE = b[2];
xF = b[3];
-
z0z1z2z3 = x0x1x2x3 ^ S5[xD] ^ S6[xF] ^ S7[xC] ^ S8[xE] ^ S7[x8];
b = unscramble(z0z1z2z3);
z0 = b[0];
@@ -963,12 +584,10 @@ public class Cast5 extends BaseCipher
zD = b[1];
zE = b[2];
zF = b[3];
-
result.Km0 = S5[z8] ^ S6[z9] ^ S7[z7] ^ S8[z6] ^ S5[z2];
result.Km1 = S5[zA] ^ S6[zB] ^ S7[z5] ^ S8[z4] ^ S6[z6];
result.Km2 = S5[zC] ^ S6[zD] ^ S7[z3] ^ S8[z2] ^ S7[z9];
result.Km3 = S5[zE] ^ S6[zF] ^ S7[z1] ^ S8[z0] ^ S8[zC];
-
x0x1x2x3 = z8z9zAzB ^ S5[z5] ^ S6[z7] ^ S7[z4] ^ S8[z6] ^ S7[z0];
b = unscramble(x0x1x2x3);
x0 = b[0];
@@ -993,12 +612,10 @@ public class Cast5 extends BaseCipher
xD = b[1];
xE = b[2];
xF = b[3];
-
result.Km4 = S5[x3] ^ S6[x2] ^ S7[xC] ^ S8[xD] ^ S5[x8];
result.Km5 = S5[x1] ^ S6[x0] ^ S7[xE] ^ S8[xF] ^ S6[xD];
result.Km6 = S5[x7] ^ S6[x6] ^ S7[x8] ^ S8[x9] ^ S7[x3];
result.Km7 = S5[x5] ^ S6[x4] ^ S7[xA] ^ S8[xB] ^ S8[x7];
-
z0z1z2z3 = x0x1x2x3 ^ S5[xD] ^ S6[xF] ^ S7[xC] ^ S8[xE] ^ S7[x8];
b = unscramble(z0z1z2z3);
z0 = b[0];
@@ -1023,12 +640,10 @@ public class Cast5 extends BaseCipher
zD = b[1];
zE = b[2];
zF = b[3];
-
result.Km8 = S5[z3] ^ S6[z2] ^ S7[zC] ^ S8[zD] ^ S5[z9];
result.Km9 = S5[z1] ^ S6[z0] ^ S7[zE] ^ S8[zF] ^ S6[zC];
result.Km10 = S5[z7] ^ S6[z6] ^ S7[z8] ^ S8[z9] ^ S7[z2];
result.Km11 = S5[z5] ^ S6[z4] ^ S7[zA] ^ S8[zB] ^ S8[z6];
-
x0x1x2x3 = z8z9zAzB ^ S5[z5] ^ S6[z7] ^ S7[z4] ^ S8[z6] ^ S7[z0];
b = unscramble(x0x1x2x3);
x0 = b[0];
@@ -1053,17 +668,14 @@ public class Cast5 extends BaseCipher
xD = b[1];
xE = b[2];
xF = b[3];
-
result.Km12 = S5[x8] ^ S6[x9] ^ S7[x7] ^ S8[x6] ^ S5[x3];
result.Km13 = S5[xA] ^ S6[xB] ^ S7[x5] ^ S8[x4] ^ S6[x7];
result.Km14 = S5[xC] ^ S6[xD] ^ S7[x3] ^ S8[x2] ^ S7[x8];
result.Km15 = S5[xE] ^ S6[xF] ^ S7[x1] ^ S8[x0] ^ S8[xD];
-
// The remaining half is identical to what is given above, carrying on
// from the last created x0..xF to generate keys K17 - K32. These keys
// will be used as the 'rotation' keys and as such only the five least
// significant bits are to be considered.
-
z0z1z2z3 = x0x1x2x3 ^ S5[xD] ^ S6[xF] ^ S7[xC] ^ S8[xE] ^ S7[x8];
b = unscramble(z0z1z2z3);
z0 = b[0];
@@ -1088,12 +700,10 @@ public class Cast5 extends BaseCipher
zD = b[1];
zE = b[2];
zF = b[3];
-
result.Kr0 = (S5[z8] ^ S6[z9] ^ S7[z7] ^ S8[z6] ^ S5[z2]) & 0x1F;
result.Kr1 = (S5[zA] ^ S6[zB] ^ S7[z5] ^ S8[z4] ^ S6[z6]) & 0x1F;
result.Kr2 = (S5[zC] ^ S6[zD] ^ S7[z3] ^ S8[z2] ^ S7[z9]) & 0x1F;
result.Kr3 = (S5[zE] ^ S6[zF] ^ S7[z1] ^ S8[z0] ^ S8[zC]) & 0x1F;
-
x0x1x2x3 = z8z9zAzB ^ S5[z5] ^ S6[z7] ^ S7[z4] ^ S8[z6] ^ S7[z0];
b = unscramble(x0x1x2x3);
x0 = b[0];
@@ -1118,12 +728,10 @@ public class Cast5 extends BaseCipher
xD = b[1];
xE = b[2];
xF = b[3];
-
result.Kr4 = (S5[x3] ^ S6[x2] ^ S7[xC] ^ S8[xD] ^ S5[x8]) & 0x1F;
result.Kr5 = (S5[x1] ^ S6[x0] ^ S7[xE] ^ S8[xF] ^ S6[xD]) & 0x1F;
result.Kr6 = (S5[x7] ^ S6[x6] ^ S7[x8] ^ S8[x9] ^ S7[x3]) & 0x1F;
result.Kr7 = (S5[x5] ^ S6[x4] ^ S7[xA] ^ S8[xB] ^ S8[x7]) & 0x1F;
-
z0z1z2z3 = x0x1x2x3 ^ S5[xD] ^ S6[xF] ^ S7[xC] ^ S8[xE] ^ S7[x8];
b = unscramble(z0z1z2z3);
z0 = b[0];
@@ -1148,12 +756,10 @@ public class Cast5 extends BaseCipher
zD = b[1];
zE = b[2];
zF = b[3];
-
result.Kr8 = (S5[z3] ^ S6[z2] ^ S7[zC] ^ S8[zD] ^ S5[z9]) & 0x1F;
result.Kr9 = (S5[z1] ^ S6[z0] ^ S7[zE] ^ S8[zF] ^ S6[zC]) & 0x1F;
result.Kr10 = (S5[z7] ^ S6[z6] ^ S7[z8] ^ S8[z9] ^ S7[z2]) & 0x1F;
result.Kr11 = (S5[z5] ^ S6[z4] ^ S7[zA] ^ S8[zB] ^ S8[z6]) & 0x1F;
-
x0x1x2x3 = z8z9zAzB ^ S5[z5] ^ S6[z7] ^ S7[z4] ^ S8[z6] ^ S7[z0];
b = unscramble(x0x1x2x3);
x0 = b[0];
@@ -1178,23 +784,19 @@ public class Cast5 extends BaseCipher
xD = b[1];
xE = b[2];
xF = b[3];
-
result.Kr12 = (S5[x8] ^ S6[x9] ^ S7[x7] ^ S8[x6] ^ S5[x3]) & 0x1F;
result.Kr13 = (S5[xA] ^ S6[xB] ^ S7[x5] ^ S8[x4] ^ S6[x7]) & 0x1F;
result.Kr14 = (S5[xC] ^ S6[xD] ^ S7[x3] ^ S8[x2] ^ S7[x8]) & 0x1F;
result.Kr15 = (S5[xE] ^ S6[xF] ^ S7[x1] ^ S8[x0] ^ S8[xD]) & 0x1F;
-
return result;
}
/**
- * <p>The full encryption algorithm is given in the following four steps.</p>
- *
+ * The full encryption algorithm is given in the following four steps.
* <pre>
* INPUT: plaintext m1...m64; key K = k1...k128.
* OUTPUT: ciphertext c1...c64.
* </pre>
- *
* <ol>
* <li>(key schedule) Compute 16 pairs of subkeys {Kmi, Kri} from a user
* key (see makeKey() method).</li>
@@ -1210,13 +812,12 @@ public class Cast5 extends BaseCipher
* <li>c1...c64 <-- (R16,L16). (Exchange final blocks L16, R16 and
* concatenate to form the ciphertext.)</li>
* </ol>
- *
- * <p>Decryption is identical to the encryption algorithm given above, except
+ * <p>
+ * Decryption is identical to the encryption algorithm given above, except
* that the rounds (and therefore the subkey pairs) are used in reverse order
- * to compute (L0,R0) from (R16,L16).</p>
- *
- * <p>Looking at the iterations/rounds in pairs we have:</p>
- *
+ * to compute (L0,R0) from (R16,L16).
+ * <p>
+ * Looking at the iterations/rounds in pairs we have:
* <pre>
* (1a) Li = Ri-1;
* (1b) Ri = Li-1 ^ Fi(Ri-1);
@@ -1249,16 +850,16 @@ public class Cast5 extends BaseCipher
public void encrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
Cast5Key K = (Cast5Key) k;
-
- int L = (in[i++] & 0xFF) << 24 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 8 | in[i++] & 0xFF;
- int R = (in[i++] & 0xFF) << 24 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 8 | in[i] & 0xFF;
-
+ int L = (in[i++] & 0xFF) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | in[i++] & 0xFF;
+ int R = (in[i++] & 0xFF) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | in[i ] & 0xFF;
L ^= f1(R, K.Km0, K.Kr0);
R ^= f2(L, K.Km1, K.Kr1); // round 2
L ^= f3(R, K.Km2, K.Kr2);
@@ -1278,30 +879,29 @@ public class Cast5 extends BaseCipher
L ^= f3(R, K.Km14, K.Kr14);
R ^= f1(L, K.Km15, K.Kr15); // round 16
}
-
- out[j++] = (byte) (R >>> 24);
- out[j++] = (byte) (R >>> 16);
- out[j++] = (byte) (R >>> 8);
+ out[j++] = (byte)(R >>> 24);
+ out[j++] = (byte)(R >>> 16);
+ out[j++] = (byte)(R >>> 8);
out[j++] = (byte) R;
- out[j++] = (byte) (L >>> 24);
- out[j++] = (byte) (L >>> 16);
- out[j++] = (byte) (L >>> 8);
- out[j] = (byte) L;
+ out[j++] = (byte)(L >>> 24);
+ out[j++] = (byte)(L >>> 16);
+ out[j++] = (byte)(L >>> 8);
+ out[j ] = (byte) L;
}
public void decrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
Cast5Key K = (Cast5Key) k;
-
- int L = (in[i++] & 0xFF) << 24 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 8 | in[i++] & 0xFF;
- int R = (in[i++] & 0xFF) << 24 | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 8 | in[i] & 0xFF;
-
+ int L = (in[i++] & 0xFF) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | in[i++] & 0xFF;
+ int R = (in[i++] & 0xFF) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | in[i ] & 0xFF;
if (K.rounds == _16_ROUNDS)
{
L ^= f1(R, K.Km15, K.Kr15);
@@ -1321,15 +921,14 @@ public class Cast5 extends BaseCipher
R ^= f3(L, K.Km2, K.Kr2);
L ^= f2(R, K.Km1, K.Kr1);
R ^= f1(L, K.Km0, K.Kr0);
-
- out[j++] = (byte) (R >>> 24);
- out[j++] = (byte) (R >>> 16);
- out[j++] = (byte) (R >>> 8);
+ out[j++] = (byte)(R >>> 24);
+ out[j++] = (byte)(R >>> 16);
+ out[j++] = (byte)(R >>> 8);
out[j++] = (byte) R;
- out[j++] = (byte) (L >>> 24);
- out[j++] = (byte) (L >>> 16);
- out[j++] = (byte) (L >>> 8);
- out[j] = (byte) L;
+ out[j++] = (byte)(L >>> 24);
+ out[j++] = (byte)(L >>> 16);
+ out[j++] = (byte)(L >>> 8);
+ out[j ] = (byte) L;
}
public boolean selfTest()
@@ -1338,54 +937,51 @@ public class Cast5 extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT, KAT_PT);
- }
+ result = testKat(KAT_KEY, KAT_CT, KAT_PT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
- // helper methods ----------------------------------------------------------
-
private final int f1(int I, int m, int r)
{
I = m + I;
I = I << r | I >>> (32 - r);
- return (((S1[(I >>> 24) & 0xFF]) ^ S2[(I >>> 16) & 0xFF]) - S3[(I >>> 8) & 0xFF])
- + S4[I & 0xFF];
+ return (((S1[(I >>> 24) & 0xFF])
+ ^ S2[(I >>> 16) & 0xFF])
+ - S3[(I >>> 8) & 0xFF])
+ + S4[ I & 0xFF];
}
private final int f2(int I, int m, int r)
{
I = m ^ I;
I = I << r | I >>> (32 - r);
- return (((S1[(I >>> 24) & 0xFF]) - S2[(I >>> 16) & 0xFF]) + S3[(I >>> 8) & 0xFF])
- ^ S4[I & 0xFF];
+ return (((S1[(I >>> 24) & 0xFF])
+ - S2[(I >>> 16) & 0xFF])
+ + S3[(I >>> 8) & 0xFF])
+ ^ S4[ I & 0xFF];
}
private final int f3(int I, int m, int r)
{
I = m - I;
I = I << r | I >>> (32 - r);
- return (((S1[(I >>> 24) & 0xFF]) + S2[(I >>> 16) & 0xFF]) ^ S3[(I >>> 8) & 0xFF])
- - S4[I & 0xFF];
+ return (((S1[(I >>> 24) & 0xFF])
+ + S2[(I >>> 16) & 0xFF])
+ ^ S3[(I >>> 8) & 0xFF])
+ - S4[ I & 0xFF];
}
- // Inner class(es)
- // =========================================================================
-
/** An opaque CAST5 key object. */
private class Cast5Key
{
int rounds;
-
/** Masking session keys. */
- int Km0, Km1, Km2, Km3, Km4, Km5, Km6, Km7, Km8, Km9, Km10, Km11, Km12,
- Km13, Km14, Km15;
-
+ int Km0, Km1, Km2, Km3, Km4, Km5, Km6, Km7,
+ Km8, Km9, Km10, Km11, Km12, Km13, Km14, Km15;
/** Rotation session keys. */
- int Kr0, Kr1, Kr2, Kr3, Kr4, Kr5, Kr6, Kr7, Kr8, Kr9, Kr10, Kr11, Kr12,
- Kr13, Kr14, Kr15;
+ int Kr0, Kr1, Kr2, Kr3, Kr4, Kr5, Kr6, Kr7,
+ Kr8, Kr9, Kr10, Kr11, Kr12, Kr13, Kr14, Kr15;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/CipherFactory.java b/libjava/classpath/gnu/javax/crypto/cipher/CipherFactory.java
index 082bfb8fa2d..d6bb42253b8 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/CipherFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/CipherFactory.java
@@ -45,105 +45,69 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>A <i>Factory</i> to instantiate symmetric block cipher instances.</p>
+ * A <i>Factory</i> to instantiate symmetric block cipher instances.
*/
-public class CipherFactory implements Registry
+public class CipherFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private CipherFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a block cipher given its name.</p>
- *
+ * Returns an instance of a block cipher given its name.
+ *
* @param name the case-insensitive name of the symmetric-key block cipher
- * algorithm.
+ * algorithm.
* @return an instance of the designated cipher algorithm, or
- * <code>null</code> if none is found.
- * @exception InternalError if the implementation does not pass its
- * self-test.
+ * <code>null</code> if none is found.
+ * @exception InternalError if the implementation does not pass its self-test.
*/
public static final IBlockCipher getInstance(String name)
{
if (name == null)
- {
- return null;
- }
-
+ return null;
name = name.trim();
IBlockCipher result = null;
if (name.equalsIgnoreCase(ANUBIS_CIPHER))
- {
- result = new Anubis();
- }
+ result = new Anubis();
else if (name.equalsIgnoreCase(BLOWFISH_CIPHER))
- {
- result = new Blowfish();
- }
+ result = new Blowfish();
else if (name.equalsIgnoreCase(DES_CIPHER))
- {
- result = new DES();
- }
+ result = new DES();
else if (name.equalsIgnoreCase(KHAZAD_CIPHER))
- {
- result = new Khazad();
- }
+ result = new Khazad();
else if (name.equalsIgnoreCase(RIJNDAEL_CIPHER)
|| name.equalsIgnoreCase(AES_CIPHER))
- {
- result = new Rijndael();
- }
+ result = new Rijndael();
else if (name.equalsIgnoreCase(SERPENT_CIPHER))
- {
- result = new Serpent();
- }
+ result = new Serpent();
else if (name.equalsIgnoreCase(SQUARE_CIPHER))
- {
- result = new Square();
- }
+ result = new Square();
else if (name.equalsIgnoreCase(TRIPLEDES_CIPHER)
|| name.equalsIgnoreCase(DESEDE_CIPHER))
- {
- result = new TripleDES();
- }
+ result = new TripleDES();
else if (name.equalsIgnoreCase(TWOFISH_CIPHER))
- {
- result = new Twofish();
- }
+ result = new Twofish();
else if (name.equalsIgnoreCase(CAST5_CIPHER)
- || (name.equalsIgnoreCase(CAST128_CIPHER) || (name.equalsIgnoreCase(CAST_128_CIPHER))))
- {
- result = new Cast5();
- }
+ || (name.equalsIgnoreCase(CAST128_CIPHER)
+ || (name.equalsIgnoreCase(CAST_128_CIPHER))))
+ result = new Cast5();
else if (name.equalsIgnoreCase(NULL_CIPHER))
- {
- result = new NullCipher();
- }
+ result = new NullCipher();
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link Set} of symmetric key block cipher implementation
- * names supported by this <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of symmetric key block cipher implementation names
+ * supported by this <i>Factory</i>.
+ *
* @return a {@link Set} of block cipher names (Strings).
*/
public static final Set getNames()
@@ -160,10 +124,6 @@ public class CipherFactory implements Registry
hs.add(TWOFISH_CIPHER);
hs.add(CAST5_CIPHER);
hs.add(NULL_CIPHER);
-
return Collections.unmodifiableSet(hs);
}
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/DES.java b/libjava/classpath/gnu/javax/crypto/cipher/DES.java
index 8b7627ceaf8..3ced62c3f40 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/DES.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/DES.java
@@ -48,353 +48,169 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * <p>The Data Encryption Standard. DES is a 64-bit block cipher with a 56-bit
+ * The Data Encryption Standard. DES is a 64-bit block cipher with a 56-bit
* key, developed by IBM in the 1970's for the standardization process begun by
- * the National Bureau of Standards (now NIST).</p>
- *
- * <p>New applications should not use DES except for compatibility.</p>
- *
- * <p>This version is based upon the description and sample implementation in
- * [1].</p>
- *
- * <p>References:</p>
+ * the National Bureau of Standards (now NIST).
+ * <p>
+ * New applications should not use DES except for compatibility.
+ * <p>
+ * This version is based upon the description and sample implementation in
+ * [1].
+ * <p>
+ * References:
* <ol>
* <li>Bruce Schneier, <i>Applied Cryptography: Protocols, Algorithms, and
* Source Code in C, Second Edition</i>. (1996 John Wiley and Sons) ISBN
* 0-471-11709-9. Pages 265--301, 623--632.</li>
* </ol>
*/
-public class DES extends BaseCipher
+public class DES
+ extends BaseCipher
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** DES operates on 64 bit blocks. */
public static final int BLOCK_SIZE = 8;
-
/** DES uses 56 bits of a 64 bit parity-adjusted key. */
public static final int KEY_SIZE = 8;
-
// S-Boxes 1 through 8.
- private static final int[] SP1 = new int[] { 0x01010400, 0x00000000,
- 0x00010000, 0x01010404,
- 0x01010004, 0x00010404,
- 0x00000004, 0x00010000,
- 0x00000400, 0x01010400,
- 0x01010404, 0x00000400,
- 0x01000404, 0x01010004,
- 0x01000000, 0x00000004,
- 0x00000404, 0x01000400,
- 0x01000400, 0x00010400,
- 0x00010400, 0x01010000,
- 0x01010000, 0x01000404,
- 0x00010004, 0x01000004,
- 0x01000004, 0x00010004,
- 0x00000000, 0x00000404,
- 0x00010404, 0x01000000,
- 0x00010000, 0x01010404,
- 0x00000004, 0x01010000,
- 0x01010400, 0x01000000,
- 0x01000000, 0x00000400,
- 0x01010004, 0x00010000,
- 0x00010400, 0x01000004,
- 0x00000400, 0x00000004,
- 0x01000404, 0x00010404,
- 0x01010404, 0x00010004,
- 0x01010000, 0x01000404,
- 0x01000004, 0x00000404,
- 0x00010404, 0x01010400,
- 0x00000404, 0x01000400,
- 0x01000400, 0x00000000,
- 0x00010004, 0x00010400,
- 0x00000000, 0x01010004 };
-
- private static final int[] SP2 = new int[] { 0x80108020, 0x80008000,
- 0x00008000, 0x00108020,
- 0x00100000, 0x00000020,
- 0x80100020, 0x80008020,
- 0x80000020, 0x80108020,
- 0x80108000, 0x80000000,
- 0x80008000, 0x00100000,
- 0x00000020, 0x80100020,
- 0x00108000, 0x00100020,
- 0x80008020, 0x00000000,
- 0x80000000, 0x00008000,
- 0x00108020, 0x80100000,
- 0x00100020, 0x80000020,
- 0x00000000, 0x00108000,
- 0x00008020, 0x80108000,
- 0x80100000, 0x00008020,
- 0x00000000, 0x00108020,
- 0x80100020, 0x00100000,
- 0x80008020, 0x80100000,
- 0x80108000, 0x00008000,
- 0x80100000, 0x80008000,
- 0x00000020, 0x80108020,
- 0x00108020, 0x00000020,
- 0x00008000, 0x80000000,
- 0x00008020, 0x80108000,
- 0x00100000, 0x80000020,
- 0x00100020, 0x80008020,
- 0x80000020, 0x00100020,
- 0x00108000, 0x00000000,
- 0x80008000, 0x00008020,
- 0x80000000, 0x80100020,
- 0x80108020, 0x00108000 };
-
- private static final int[] SP3 = new int[] { 0x00000208, 0x08020200,
- 0x00000000, 0x08020008,
- 0x08000200, 0x00000000,
- 0x00020208, 0x08000200,
- 0x00020008, 0x08000008,
- 0x08000008, 0x00020000,
- 0x08020208, 0x00020008,
- 0x08020000, 0x00000208,
- 0x08000000, 0x00000008,
- 0x08020200, 0x00000200,
- 0x00020200, 0x08020000,
- 0x08020008, 0x00020208,
- 0x08000208, 0x00020200,
- 0x00020000, 0x08000208,
- 0x00000008, 0x08020208,
- 0x00000200, 0x08000000,
- 0x08020200, 0x08000000,
- 0x00020008, 0x00000208,
- 0x00020000, 0x08020200,
- 0x08000200, 0x00000000,
- 0x00000200, 0x00020008,
- 0x08020208, 0x08000200,
- 0x08000008, 0x00000200,
- 0x00000000, 0x08020008,
- 0x08000208, 0x00020000,
- 0x08000000, 0x08020208,
- 0x00000008, 0x00020208,
- 0x00020200, 0x08000008,
- 0x08020000, 0x08000208,
- 0x00000208, 0x08020000,
- 0x00020208, 0x00000008,
- 0x08020008, 0x00020200 };
-
- private static final int[] SP4 = new int[] { 0x00802001, 0x00002081,
- 0x00002081, 0x00000080,
- 0x00802080, 0x00800081,
- 0x00800001, 0x00002001,
- 0x00000000, 0x00802000,
- 0x00802000, 0x00802081,
- 0x00000081, 0x00000000,
- 0x00800080, 0x00800001,
- 0x00000001, 0x00002000,
- 0x00800000, 0x00802001,
- 0x00000080, 0x00800000,
- 0x00002001, 0x00002080,
- 0x00800081, 0x00000001,
- 0x00002080, 0x00800080,
- 0x00002000, 0x00802080,
- 0x00802081, 0x00000081,
- 0x00800080, 0x00800001,
- 0x00802000, 0x00802081,
- 0x00000081, 0x00000000,
- 0x00000000, 0x00802000,
- 0x00002080, 0x00800080,
- 0x00800081, 0x00000001,
- 0x00802001, 0x00002081,
- 0x00002081, 0x00000080,
- 0x00802081, 0x00000081,
- 0x00000001, 0x00002000,
- 0x00800001, 0x00002001,
- 0x00802080, 0x00800081,
- 0x00002001, 0x00002080,
- 0x00800000, 0x00802001,
- 0x00000080, 0x00800000,
- 0x00002000, 0x00802080 };
-
- private static final int[] SP5 = new int[] { 0x00000100, 0x02080100,
- 0x02080000, 0x42000100,
- 0x00080000, 0x00000100,
- 0x40000000, 0x02080000,
- 0x40080100, 0x00080000,
- 0x02000100, 0x40080100,
- 0x42000100, 0x42080000,
- 0x00080100, 0x40000000,
- 0x02000000, 0x40080000,
- 0x40080000, 0x00000000,
- 0x40000100, 0x42080100,
- 0x42080100, 0x02000100,
- 0x42080000, 0x40000100,
- 0x00000000, 0x42000000,
- 0x02080100, 0x02000000,
- 0x42000000, 0x00080100,
- 0x00080000, 0x42000100,
- 0x00000100, 0x02000000,
- 0x40000000, 0x02080000,
- 0x42000100, 0x40080100,
- 0x02000100, 0x40000000,
- 0x42080000, 0x02080100,
- 0x40080100, 0x00000100,
- 0x02000000, 0x42080000,
- 0x42080100, 0x00080100,
- 0x42000000, 0x42080100,
- 0x02080000, 0x00000000,
- 0x40080000, 0x42000000,
- 0x00080100, 0x02000100,
- 0x40000100, 0x00080000,
- 0x00000000, 0x40080000,
- 0x02080100, 0x40000100 };
-
- private static final int[] SP6 = new int[] { 0x20000010, 0x20400000,
- 0x00004000, 0x20404010,
- 0x20400000, 0x00000010,
- 0x20404010, 0x00400000,
- 0x20004000, 0x00404010,
- 0x00400000, 0x20000010,
- 0x00400010, 0x20004000,
- 0x20000000, 0x00004010,
- 0x00000000, 0x00400010,
- 0x20004010, 0x00004000,
- 0x00404000, 0x20004010,
- 0x00000010, 0x20400010,
- 0x20400010, 0x00000000,
- 0x00404010, 0x20404000,
- 0x00004010, 0x00404000,
- 0x20404000, 0x20000000,
- 0x20004000, 0x00000010,
- 0x20400010, 0x00404000,
- 0x20404010, 0x00400000,
- 0x00004010, 0x20000010,
- 0x00400000, 0x20004000,
- 0x20000000, 0x00004010,
- 0x20000010, 0x20404010,
- 0x00404000, 0x20400000,
- 0x00404010, 0x20404000,
- 0x00000000, 0x20400010,
- 0x00000010, 0x00004000,
- 0x20400000, 0x00404010,
- 0x00004000, 0x00400010,
- 0x20004010, 0x00000000,
- 0x20404000, 0x20000000,
- 0x00400010, 0x20004010 };
-
- private static final int[] SP7 = new int[] { 0x00200000, 0x04200002,
- 0x04000802, 0x00000000,
- 0x00000800, 0x04000802,
- 0x00200802, 0x04200800,
- 0x04200802, 0x00200000,
- 0x00000000, 0x04000002,
- 0x00000002, 0x04000000,
- 0x04200002, 0x00000802,
- 0x04000800, 0x00200802,
- 0x00200002, 0x04000800,
- 0x04000002, 0x04200000,
- 0x04200800, 0x00200002,
- 0x04200000, 0x00000800,
- 0x00000802, 0x04200802,
- 0x00200800, 0x00000002,
- 0x04000000, 0x00200800,
- 0x04000000, 0x00200800,
- 0x00200000, 0x04000802,
- 0x04000802, 0x04200002,
- 0x04200002, 0x00000002,
- 0x00200002, 0x04000000,
- 0x04000800, 0x00200000,
- 0x04200800, 0x00000802,
- 0x00200802, 0x04200800,
- 0x00000802, 0x04000002,
- 0x04200802, 0x04200000,
- 0x00200800, 0x00000000,
- 0x00000002, 0x04200802,
- 0x00000000, 0x00200802,
- 0x04200000, 0x00000800,
- 0x04000002, 0x04000800,
- 0x00000800, 0x00200002 };
-
- private static final int[] SP8 = new int[] { 0x10001040, 0x00001000,
- 0x00040000, 0x10041040,
- 0x10000000, 0x10001040,
- 0x00000040, 0x10000000,
- 0x00040040, 0x10040000,
- 0x10041040, 0x00041000,
- 0x10041000, 0x00041040,
- 0x00001000, 0x00000040,
- 0x10040000, 0x10000040,
- 0x10001000, 0x00001040,
- 0x00041000, 0x00040040,
- 0x10040040, 0x10041000,
- 0x00001040, 0x00000000,
- 0x00000000, 0x10040040,
- 0x10000040, 0x10001000,
- 0x00041040, 0x00040000,
- 0x00041040, 0x00040000,
- 0x10041000, 0x00001000,
- 0x00000040, 0x10040040,
- 0x00001000, 0x00041040,
- 0x10001000, 0x00000040,
- 0x10000040, 0x10040000,
- 0x10040040, 0x10000000,
- 0x00040000, 0x10001040,
- 0x00000000, 0x10041040,
- 0x00040040, 0x10000040,
- 0x10040000, 0x10001000,
- 0x10001040, 0x00000000,
- 0x10041040, 0x00041000,
- 0x00041000, 0x00001040,
- 0x00001040, 0x00040040,
- 0x10000000, 0x10041000 };
-
+ private static final int[] SP1 = new int[] {
+ 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404,
+ 0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400,
+ 0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400,
+ 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404,
+ 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404,
+ 0x00010404, 0x01000000, 0x00010000, 0x01010404, 0x00000004, 0x01010000,
+ 0x01010400, 0x01000000, 0x01000000, 0x00000400, 0x01010004, 0x00010000,
+ 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404,
+ 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404,
+ 0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000,
+ 0x00010004, 0x00010400, 0x00000000, 0x01010004 };
+ private static final int[] SP2 = new int[] {
+ 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020,
+ 0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000,
+ 0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020,
+ 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000,
+ 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000,
+ 0x80100000, 0x00008020, 0x00000000, 0x00108020, 0x80100020, 0x00100000,
+ 0x80008020, 0x80100000, 0x80108000, 0x00008000, 0x80100000, 0x80008000,
+ 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000,
+ 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020,
+ 0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020,
+ 0x80000000, 0x80100020, 0x80108020, 0x00108000 };
+ private static final int[] SP3 = new int[] {
+ 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000,
+ 0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000,
+ 0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008,
+ 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208,
+ 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208,
+ 0x00000200, 0x08000000, 0x08020200, 0x08000000, 0x00020008, 0x00000208,
+ 0x00020000, 0x08020200, 0x08000200, 0x00000000, 0x00000200, 0x00020008,
+ 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008,
+ 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208,
+ 0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000,
+ 0x00020208, 0x00000008, 0x08020008, 0x00020200 };
+ private static final int[] SP4 = new int[] {
+ 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081,
+ 0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081,
+ 0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000,
+ 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080,
+ 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080,
+ 0x00802081, 0x00000081, 0x00800080, 0x00800001, 0x00802000, 0x00802081,
+ 0x00000081, 0x00000000, 0x00000000, 0x00802000, 0x00002080, 0x00800080,
+ 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080,
+ 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001,
+ 0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001,
+ 0x00000080, 0x00800000, 0x00002000, 0x00802080 };
+ private static final int[] SP5 = new int[] {
+ 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100,
+ 0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100,
+ 0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000,
+ 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100,
+ 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000,
+ 0x42000000, 0x00080100, 0x00080000, 0x42000100, 0x00000100, 0x02000000,
+ 0x40000000, 0x02080000, 0x42000100, 0x40080100, 0x02000100, 0x40000000,
+ 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000,
+ 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000,
+ 0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000,
+ 0x00000000, 0x40080000, 0x02080100, 0x40000100 };
+ private static final int[] SP6 = new int[] {
+ 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010,
+ 0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010,
+ 0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010,
+ 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010,
+ 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000,
+ 0x20404000, 0x20000000, 0x20004000, 0x00000010, 0x20400010, 0x00404000,
+ 0x20404010, 0x00400000, 0x00004010, 0x20000010, 0x00400000, 0x20004000,
+ 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000,
+ 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000,
+ 0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000,
+ 0x20404000, 0x20000000, 0x00400010, 0x20004010 };
+ private static final int[] SP7 = new int[] {
+ 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802,
+ 0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002,
+ 0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802,
+ 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002,
+ 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002,
+ 0x04000000, 0x00200800, 0x04000000, 0x00200800, 0x00200000, 0x04000802,
+ 0x04000802, 0x04200002, 0x04200002, 0x00000002, 0x00200002, 0x04000000,
+ 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800,
+ 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000,
+ 0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800,
+ 0x04000002, 0x04000800, 0x00000800, 0x00200002 };
+ private static final int[] SP8 = new int[] {
+ 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040,
+ 0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000,
+ 0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040,
+ 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000,
+ 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000,
+ 0x00041040, 0x00040000, 0x00041040, 0x00040000, 0x10041000, 0x00001000,
+ 0x00000040, 0x10040040, 0x00001000, 0x00041040, 0x10001000, 0x00000040,
+ 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040,
+ 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000,
+ 0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040,
+ 0x00001040, 0x00040040, 0x10000000, 0x10041000 };
/**
* Constants that help in determining whether or not a byte array is parity
* adjusted.
*/
- private static final byte[] PARITY = { 8, 1, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8,
- 0, 2, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8, 0,
- 0, 8, 0, 8, 8, 3, 0, 8, 8, 0, 8, 0, 0,
- 8, 8, 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8,
- 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8, 0,
- 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8,
- 8, 0, 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8,
- 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
- 0, 8, 8, 0, 8, 0, 0, 8, 0, 8, 8, 0, 8,
- 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0, 0, 8,
- 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8,
- 0, 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0,
- 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0, 0,
- 8, 8, 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 0,
- 0, 8, 8, 0, 0, 8, 0, 8, 8, 0, 8, 0, 0,
- 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
- 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0,
- 8, 8, 0, 4, 8, 8, 0, 8, 0, 0, 8, 8, 0,
- 0, 8, 0, 8, 8, 0, 8, 5, 0, 8, 0, 8, 8,
- 0, 0, 8, 8, 0, 8, 0, 6, 8 };
-
+ private static final byte[] PARITY = {
+ 8, 1, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 2, 8,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 3,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 8, 0, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 0, 8,
+ 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 4, 8, 8, 0, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8, 8, 0,
+ 8, 5, 0, 8, 0, 8, 8, 0, 0, 8, 8, 0, 8, 0, 6, 8 };
// Key schedule constants.
-
- private static final byte[] ROTARS = { 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19,
- 21, 23, 25, 27, 28 };
-
- private static final byte[] PC1 = { 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41,
- 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
- 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30,
- 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5,
- 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11,
- 3 };
-
- private static final byte[] PC2 = { 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20,
- 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19,
- 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50,
- 44, 32, 47, 43, 48, 38, 55, 33, 52, 45,
- 41, 49, 35, 28, 31 };
-
+ private static final byte[] ROTARS = {
+ 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 };
+ private static final byte[] PC1 = {
+ 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1,
+ 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38,
+ 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36,
+ 28, 20, 12, 4, 27, 19, 11, 3 };
+ private static final byte[] PC2 = {
+ 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3,
+ 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39,
+ 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
/**
* Weak keys (parity adjusted): If all the bits in each half are either 0
* or 1, then the key used for any cycle of the algorithm is the same as
* all other cycles.
*/
public static final byte[][] WEAK_KEYS = {
- Util.toBytesFromString("0101010101010101"),
- Util.toBytesFromString("01010101FEFEFEFE"),
- Util.toBytesFromString("FEFEFEFE01010101"),
- Util.toBytesFromString("FEFEFEFEFEFEFEFE") };
-
+ Util.toBytesFromString("0101010101010101"),
+ Util.toBytesFromString("01010101FEFEFEFE"),
+ Util.toBytesFromString("FEFEFEFE01010101"),
+ Util.toBytesFromString("FEFEFEFEFEFEFEFE") };
/**
* Semi-weak keys (parity adjusted): Some pairs of keys encrypt plain text
* to identical cipher text. In other words, one key in the pair can decrypt
@@ -403,73 +219,69 @@ public class DES extends BaseCipher
* generated, these semi-weak keys produce only two different sub-keys.
*/
public static final byte[][] SEMIWEAK_KEYS = {
- Util.toBytesFromString("01FE01FE01FE01FE"),
- Util.toBytesFromString("FE01FE01FE01FE01"),
- Util.toBytesFromString("1FE01FE00EF10EF1"),
- Util.toBytesFromString("E01FE01FF10EF10E"),
- Util.toBytesFromString("01E001E001F101F1"),
- Util.toBytesFromString("E001E001F101F101"),
- Util.toBytesFromString("1FFE1FFE0EFE0EFE"),
- Util.toBytesFromString("FE1FFE1FFE0EFE0E"),
- Util.toBytesFromString("011F011F010E010E"),
- Util.toBytesFromString("1F011F010E010E01"),
- Util.toBytesFromString("E0FEE0FEF1FEF1FE"),
- Util.toBytesFromString("FEE0FEE0FEF1FEF1") };
-
+ Util.toBytesFromString("01FE01FE01FE01FE"),
+ Util.toBytesFromString("FE01FE01FE01FE01"),
+ Util.toBytesFromString("1FE01FE00EF10EF1"),
+ Util.toBytesFromString("E01FE01FF10EF10E"),
+ Util.toBytesFromString("01E001E001F101F1"),
+ Util.toBytesFromString("E001E001F101F101"),
+ Util.toBytesFromString("1FFE1FFE0EFE0EFE"),
+ Util.toBytesFromString("FE1FFE1FFE0EFE0E"),
+ Util.toBytesFromString("011F011F010E010E"),
+ Util.toBytesFromString("1F011F010E010E01"),
+ Util.toBytesFromString("E0FEE0FEF1FEF1FE"),
+ Util.toBytesFromString("FEE0FEE0FEF1FEF1") };
/** Possible weak keys (parity adjusted) --produce 4 instead of 16 subkeys. */
public static final byte[][] POSSIBLE_WEAK_KEYS = {
- Util.toBytesFromString("1F1F01010E0E0101"),
- Util.toBytesFromString("011F1F01010E0E01"),
- Util.toBytesFromString("1F01011F0E01010E"),
- Util.toBytesFromString("01011F1F01010E0E"),
- Util.toBytesFromString("E0E00101F1F10101"),
- Util.toBytesFromString("FEFE0101FEFE0101"),
- Util.toBytesFromString("FEE01F01FEF10E01"),
- Util.toBytesFromString("E0FE1F01F1FE0E01"),
- Util.toBytesFromString("FEE0011FFEF1010E"),
- Util.toBytesFromString("E0FE011FF1FE010E"),
- Util.toBytesFromString("E0E01F1FF1F10E0E"),
- Util.toBytesFromString("FEFE1F1FFEFE0E0E"),
- Util.toBytesFromString("1F1F01010E0E0101"),
- Util.toBytesFromString("011F1F01010E0E01"),
- Util.toBytesFromString("1F01011F0E01010E"),
- Util.toBytesFromString("01011F1F01010E0E"),
- Util.toBytesFromString("01E0E00101F1F101"),
- Util.toBytesFromString("1FFEE0010EFEF001"),
- Util.toBytesFromString("1FE0FE010EF1FE01"),
- Util.toBytesFromString("01FEFE0101FEFE01"),
- Util.toBytesFromString("1FE0E01F0EF1F10E"),
- Util.toBytesFromString("01FEE01F01FEF10E"),
- Util.toBytesFromString("01E0FE1F01F1FE0E"),
- Util.toBytesFromString("1FFEFE1F0EFEFE0E"),
-
- Util.toBytesFromString("E00101E0F10101F1"),
- Util.toBytesFromString("FE1F01E0FE0E0EF1"),
- Util.toBytesFromString("FE011FE0FE010EF1"),
- Util.toBytesFromString("E01F1FE0F10E0EF1"),
- Util.toBytesFromString("FE0101FEFE0101FE"),
- Util.toBytesFromString("E01F01FEF10E01FE"),
- Util.toBytesFromString("E0011FFEF1010EFE"),
- Util.toBytesFromString("FE1F1FFEFE0E0EFE"),
- Util.toBytesFromString("1FFE01E00EFE01F1"),
- Util.toBytesFromString("01FE1FE001FE0EF1"),
- Util.toBytesFromString("1FE001FE0EF101FE"),
- Util.toBytesFromString("01E01FFE01F10EFE"),
- Util.toBytesFromString("0101E0E00101F1F1"),
- Util.toBytesFromString("1F1FE0E00E0EF1F1"),
- Util.toBytesFromString("1F01FEE00E01FEF1"),
- Util.toBytesFromString("011FFEE0010EFEF1"),
- Util.toBytesFromString("1F01E0FE0E01F1FE"),
- Util.toBytesFromString("011FE0FE010EF1FE"),
- Util.toBytesFromString("0101FEFE0001FEFE"),
- Util.toBytesFromString("1F1FFEFE0E0EFEFE"),
- Util.toBytesFromString("FEFEE0E0FEFEF1F1"),
- Util.toBytesFromString("E0FEFEE0F1FEFEF1"),
- Util.toBytesFromString("FEE0E0FEFEF1F1FE"),
- Util.toBytesFromString("E0E0FEFEF1F1FEFE") };
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ Util.toBytesFromString("1F1F01010E0E0101"),
+ Util.toBytesFromString("011F1F01010E0E01"),
+ Util.toBytesFromString("1F01011F0E01010E"),
+ Util.toBytesFromString("01011F1F01010E0E"),
+ Util.toBytesFromString("E0E00101F1F10101"),
+ Util.toBytesFromString("FEFE0101FEFE0101"),
+ Util.toBytesFromString("FEE01F01FEF10E01"),
+ Util.toBytesFromString("E0FE1F01F1FE0E01"),
+ Util.toBytesFromString("FEE0011FFEF1010E"),
+ Util.toBytesFromString("E0FE011FF1FE010E"),
+ Util.toBytesFromString("E0E01F1FF1F10E0E"),
+ Util.toBytesFromString("FEFE1F1FFEFE0E0E"),
+ Util.toBytesFromString("1F1F01010E0E0101"),
+ Util.toBytesFromString("011F1F01010E0E01"),
+ Util.toBytesFromString("1F01011F0E01010E"),
+ Util.toBytesFromString("01011F1F01010E0E"),
+ Util.toBytesFromString("01E0E00101F1F101"),
+ Util.toBytesFromString("1FFEE0010EFEF001"),
+ Util.toBytesFromString("1FE0FE010EF1FE01"),
+ Util.toBytesFromString("01FEFE0101FEFE01"),
+ Util.toBytesFromString("1FE0E01F0EF1F10E"),
+ Util.toBytesFromString("01FEE01F01FEF10E"),
+ Util.toBytesFromString("01E0FE1F01F1FE0E"),
+ Util.toBytesFromString("1FFEFE1F0EFEFE0E"),
+
+ Util.toBytesFromString("E00101E0F10101F1"),
+ Util.toBytesFromString("FE1F01E0FE0E0EF1"),
+ Util.toBytesFromString("FE011FE0FE010EF1"),
+ Util.toBytesFromString("E01F1FE0F10E0EF1"),
+ Util.toBytesFromString("FE0101FEFE0101FE"),
+ Util.toBytesFromString("E01F01FEF10E01FE"),
+ Util.toBytesFromString("E0011FFEF1010EFE"),
+ Util.toBytesFromString("FE1F1FFEFE0E0EFE"),
+ Util.toBytesFromString("1FFE01E00EFE01F1"),
+ Util.toBytesFromString("01FE1FE001FE0EF1"),
+ Util.toBytesFromString("1FE001FE0EF101FE"),
+ Util.toBytesFromString("01E01FFE01F10EFE"),
+ Util.toBytesFromString("0101E0E00101F1F1"),
+ Util.toBytesFromString("1F1FE0E00E0EF1F1"),
+ Util.toBytesFromString("1F01FEE00E01FEF1"),
+ Util.toBytesFromString("011FFEE0010EFEF1"),
+ Util.toBytesFromString("1F01E0FE0E01F1FE"),
+ Util.toBytesFromString("011FE0FE010EF1FE"),
+ Util.toBytesFromString("0101FEFE0001FEFE"),
+ Util.toBytesFromString("1F1FFEFE0E0EFEFE"),
+ Util.toBytesFromString("FEFEE0E0FEFEF1F1"),
+ Util.toBytesFromString("E0FEFEE0F1FEFEF1"),
+ Util.toBytesFromString("FEE0E0FEFEF1F1FE"),
+ Util.toBytesFromString("E0E0FEFEF1F1FEFE") };
/** Default 0-argument constructor. */
public DES()
@@ -477,28 +289,23 @@ public class DES extends BaseCipher
super(Registry.DES_CIPHER, BLOCK_SIZE, KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Adjust the parity for a raw key array. This essentially means that each
+ * Adjust the parity for a raw key array. This essentially means that each
* byte in the array will have an odd number of '1' bits (the last bit in
- * each byte is unused.</p>
+ * each byte is unused.
*
* @param kb The key array, to be parity-adjusted.
* @param offset The starting index into the key bytes.
*/
public static void adjustParity(byte[] kb, int offset)
{
- for (int i = offset; i < KEY_SIZE; i++)
- {
- kb[i] ^= (PARITY[kb[i] & 0xff] == 8) ? 1 : 0;
- }
+ for (int i = offset; i < offset + KEY_SIZE; i++)
+ kb[i] ^= (PARITY[kb[i] & 0xff] == 8) ? 1 : 0;
}
/**
- * <p>Test if a byte array, which must be at least 8 bytes long, is parity
- * adjusted.</p>
+ * Test if a byte array, which must be at least 8 bytes long, is parity
+ * adjusted.
*
* @param kb The key bytes.
* @param offset The starting index into the key bytes.
@@ -527,59 +334,35 @@ public class DES extends BaseCipher
}
/**
- * <p>Test if a key is a weak key.</p>
+ * Test if a key is a weak key.
*
* @param kb The key to test.
* @return <code>true</code> if the key is weak.
*/
public static boolean isWeak(byte[] kb)
{
- // return Arrays.equals(kb, WEAK_KEYS[0]) || Arrays.equals(kb, WEAK_KEYS[1])
- // || Arrays.equals(kb, WEAK_KEYS[2]) || Arrays.equals(kb, WEAK_KEYS[3])
- // || Arrays.equals(kb, WEAK_KEYS[4]) || Arrays.equals(kb, WEAK_KEYS[5])
- // || Arrays.equals(kb, WEAK_KEYS[6]) || Arrays.equals(kb, WEAK_KEYS[7]);
for (int i = 0; i < WEAK_KEYS.length; i++)
- {
- if (Arrays.equals(WEAK_KEYS[i], kb))
- {
- return true;
- }
- }
+ if (Arrays.equals(WEAK_KEYS[i], kb))
+ return true;
return false;
}
/**
- * <p>Test if a key is a semi-weak key.</p>
+ * Test if a key is a semi-weak key.
*
* @param kb The key to test.
* @return <code>true</code> if this key is semi-weak.
*/
public static boolean isSemiWeak(byte[] kb)
{
- // return Arrays.equals(kb, SEMIWEAK_KEYS[0])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[1])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[2])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[3])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[4])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[5])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[6])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[7])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[8])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[9])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[10])
- // || Arrays.equals(kb, SEMIWEAK_KEYS[11]);
for (int i = 0; i < SEMIWEAK_KEYS.length; i++)
- {
- if (Arrays.equals(SEMIWEAK_KEYS[i], kb))
- {
- return true;
- }
- }
+ if (Arrays.equals(SEMIWEAK_KEYS[i], kb))
+ return true;
return false;
}
/**
- * <p>Test if the designated byte array represents a possibly weak key.</p>
+ * Test if the designated byte array represents a possibly weak key.
*
* @param kb the byte array to test.
* @return <code>true</code> if <code>kb</code>represents a possibly weak key.
@@ -588,18 +371,14 @@ public class DES extends BaseCipher
public static boolean isPossibleWeak(byte[] kb)
{
for (int i = 0; i < POSSIBLE_WEAK_KEYS.length; i++)
- {
- if (Arrays.equals(POSSIBLE_WEAK_KEYS[i], kb))
- {
- return true;
- }
- }
+ if (Arrays.equals(POSSIBLE_WEAK_KEYS[i], kb))
+ return true;
return false;
}
/**
- * <p>The core DES function. This is used for both encryption and decryption,
- * the only difference being the key.</p>
+ * The core DES function. This is used for both encryption and decryption,
+ * the only difference being the key.
*
* @param in The input bytes.
* @param i The starting offset into the input bytes.
@@ -610,13 +389,15 @@ public class DES extends BaseCipher
private static void desFunc(byte[] in, int i, byte[] out, int o, int[] key)
{
int right, left, work;
-
// Load.
- left = (in[i++] & 0xff) << 24 | (in[i++] & 0xff) << 16
- | (in[i++] & 0xff) << 8 | in[i++] & 0xff;
- right = (in[i++] & 0xff) << 24 | (in[i++] & 0xff) << 16
- | (in[i++] & 0xff) << 8 | in[i] & 0xff;
-
+ left = (in[i++] & 0xff) << 24
+ | (in[i++] & 0xff) << 16
+ | (in[i++] & 0xff) << 8
+ | in[i++] & 0xff;
+ right = (in[i++] & 0xff) << 24
+ | (in[i++] & 0xff) << 16
+ | (in[i++] & 0xff) << 8
+ | in[i ] & 0xff;
// Initial permutation.
work = ((left >>> 4) ^ right) & 0x0F0F0F0F;
left ^= work << 4;
@@ -681,7 +462,6 @@ public class DES extends BaseCipher
t |= SP2[work & 0x3F];
right ^= t;
}
-
// The final permutation.
right = (right << 31) | (right >>> 1);
work = (left ^ right) & 0xAAAAAAAA;
@@ -705,19 +485,16 @@ public class DES extends BaseCipher
right ^= work << 4;
left ^= work;
- out[o++] = (byte) (right >>> 24);
- out[o++] = (byte) (right >>> 16);
- out[o++] = (byte) (right >>> 8);
+ out[o++] = (byte)(right >>> 24);
+ out[o++] = (byte)(right >>> 16);
+ out[o++] = (byte)(right >>> 8);
out[o++] = (byte) right;
- out[o++] = (byte) (left >>> 24);
- out[o++] = (byte) (left >>> 16);
- out[o++] = (byte) (left >>> 8);
- out[o] = (byte) left;
+ out[o++] = (byte)(left >>> 24);
+ out[o++] = (byte)(left >>> 16);
+ out[o++] = (byte)(left >>> 8);
+ out[o ] = (byte) left;
}
- // Instance methods implementing BaseCipher
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new DES();
@@ -725,12 +502,12 @@ public class DES extends BaseCipher
public Iterator blockSizes()
{
- return Collections.singleton(new Integer(BLOCK_SIZE)).iterator();
+ return Collections.singleton(Integer.valueOf(BLOCK_SIZE)).iterator();
}
public Iterator keySizes()
{
- return Collections.singleton(new Integer(KEY_SIZE)).iterator();
+ return Collections.singleton(Integer.valueOf(KEY_SIZE)).iterator();
}
public Object makeKey(byte[] kb, int bs) throws InvalidKeyException
@@ -740,9 +517,7 @@ public class DES extends BaseCipher
if (Properties.checkForWeakKeys()
&& (isWeak(kb) || isSemiWeak(kb) || isPossibleWeak(kb)))
- {
- throw new WeakKeyException();
- }
+ throw new WeakKeyException();
int i, j, l, m, n;
long pc1m = 0, pcr = 0;
@@ -751,11 +526,9 @@ public class DES extends BaseCipher
{
l = PC1[i];
pc1m |= ((kb[l >>> 3] & (0x80 >>> (l & 7))) != 0) ? (1L << (55 - i))
- : 0;
+ : 0;
}
-
Context ctx = new Context();
-
// Encryption key first.
for (i = 0; i < 16; i++)
{
@@ -769,7 +542,7 @@ public class DES extends BaseCipher
pcr |= ((pc1m & 1L << (55 - l)) != 0) ? (1L << (55 - j)) : 0;
else
pcr |= ((pc1m & 1L << (55 - (l - 28))) != 0) ? (1L << (55 - j))
- : 0;
+ : 0;
}
for (j = 28; j < 56; j++)
{
@@ -778,7 +551,7 @@ public class DES extends BaseCipher
pcr |= ((pc1m & 1L << (55 - l)) != 0) ? (1L << (55 - j)) : 0;
else
pcr |= ((pc1m & 1L << (55 - (l - 28))) != 0) ? (1L << (55 - j))
- : 0;
+ : 0;
}
for (j = 0; j < 24; j++)
{
@@ -788,36 +561,37 @@ public class DES extends BaseCipher
ctx.ek[n] |= 1 << (23 - j);
}
}
-
// The decryption key is the same, but in reversed order.
for (i = 0; i < Context.EXPANDED_KEY_SIZE; i += 2)
{
ctx.dk[30 - i] = ctx.ek[i];
ctx.dk[31 - i] = ctx.ek[i + 1];
}
-
// "Cook" the keys.
for (i = 0; i < 32; i += 2)
{
int x, y;
-
x = ctx.ek[i];
y = ctx.ek[i + 1];
-
- ctx.ek[i] = ((x & 0x00FC0000) << 6) | ((x & 0x00000FC0) << 10)
- | ((y & 0x00FC0000) >>> 10) | ((y & 0x00000FC0) >>> 6);
- ctx.ek[i + 1] = ((x & 0x0003F000) << 12) | ((x & 0x0000003F) << 16)
- | ((y & 0x0003F000) >>> 4) | (y & 0x0000003F);
-
+ ctx.ek[i ] = ((x & 0x00FC0000) << 6)
+ | ((x & 0x00000FC0) << 10)
+ | ((y & 0x00FC0000) >>> 10)
+ | ((y & 0x00000FC0) >>> 6);
+ ctx.ek[i + 1] = ((x & 0x0003F000) << 12)
+ | ((x & 0x0000003F) << 16)
+ | ((y & 0x0003F000) >>> 4)
+ | (y & 0x0000003F);
x = ctx.dk[i];
y = ctx.dk[i + 1];
-
- ctx.dk[i] = ((x & 0x00FC0000) << 6) | ((x & 0x00000FC0) << 10)
- | ((y & 0x00FC0000) >>> 10) | ((y & 0x00000FC0) >>> 6);
- ctx.dk[i + 1] = ((x & 0x0003F000) << 12) | ((x & 0x0000003F) << 16)
- | ((y & 0x0003F000) >>> 4) | (y & 0x0000003F);
+ ctx.dk[i ] = ((x & 0x00FC0000) << 6)
+ | ((x & 0x00000FC0) << 10)
+ | ((y & 0x00FC0000) >>> 10)
+ | ((y & 0x00000FC0) >>> 6);
+ ctx.dk[i + 1] = ((x & 0x0003F000) << 12)
+ | ((x & 0x0000003F) << 16)
+ | ((y & 0x0003F000) >>> 4)
+ | (y & 0x0000003F);
}
-
return ctx;
}
@@ -831,19 +605,12 @@ public class DES extends BaseCipher
desFunc(in, i, out, o, ((Context) K).dk);
}
- // Inner classe(s)
- // =========================================================================
-
/**
* Simple wrapper class around the session keys. Package-private so TripleDES
* can see it.
*/
final class Context
{
-
- // Constants and variables
- // ----------------------------------------------------------------------
-
private static final int EXPANDED_KEY_SIZE = 32;
/** The encryption key. */
@@ -852,9 +619,6 @@ public class DES extends BaseCipher
/** The decryption key. */
int[] dk;
- // Constructor(s)
- // ----------------------------------------------------------------------
-
/** Default 0-arguments constructor. */
Context()
{
@@ -862,12 +626,6 @@ public class DES extends BaseCipher
dk = new int[EXPANDED_KEY_SIZE];
}
- // Class methods
- // ----------------------------------------------------------------------
-
- // Instance methods
- // ----------------------------------------------------------------------
-
byte[] getEncryptionKeyBytes()
{
return toByteArray(ek);
@@ -883,12 +641,12 @@ public class DES extends BaseCipher
byte[] result = new byte[4 * k.length];
for (int i = 0, j = 0; i < k.length; i++)
{
- result[j++] = (byte) (k[i] >>> 24);
- result[j++] = (byte) (k[i] >>> 16);
- result[j++] = (byte) (k[i] >>> 8);
+ result[j++] = (byte)(k[i] >>> 24);
+ result[j++] = (byte)(k[i] >>> 16);
+ result[j++] = (byte)(k[i] >>> 8);
result[j++] = (byte) k[i];
}
return result;
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipher.java b/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipher.java
index 238ee280f83..d1e32ef6599 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipher.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipher.java
@@ -43,109 +43,99 @@ import java.util.Iterator;
import java.util.Map;
/**
- * <p>The basic visible methods of any symmetric key block cipher.</p>
- *
- * <p>A symmetric key block cipher is a function that maps n-bit plaintext
- * blocks to n-bit ciphertext blocks; n being the cipher's <i>block size</i>.
- * This encryption function is parameterised by a k-bit key, and is invertible.
- * Its inverse is the decryption function.</p>
- *
- * <p>Possible initialisation values for an instance of this type are:</p>
- *
+ * The basic visible methods of any symmetric key block cipher.
+ * <p>
+ * A symmetric key block cipher is a function that maps n-bit plaintext blocks
+ * to n-bit ciphertext blocks; n being the cipher's <i>block size</i>. This
+ * encryption function is parameterised by a k-bit key, and is invertible. Its
+ * inverse is the decryption function.
+ * <p>
+ * Possible initialisation values for an instance of this type are:
* <ul>
- * <li>The block size in which to operate this block cipher instance. This
- * value is <b>optional</b>, if unspecified, the block cipher's default
- * block size shall be used.</li>
- *
- * <li>The byte array containing the user supplied key material to use for
- * generating the cipher's session key(s). This value is <b>mandatory</b>
- * and should be included in the initialisation parameters. If it isn't,
- * an {@link IllegalStateException} will be thrown if any method, other than
- * <code>reset()</code> is invoked on the instance. Furthermore, the size of
- * this key material shall be taken as an indication on the key size in which
- * to operate this instance.</li>
+ * <li>The block size in which to operate this block cipher instance. This
+ * value is <b>optional</b>, if unspecified, the block cipher's default block
+ * size shall be used.</li>
+ * <li>The byte array containing the user supplied key material to use for
+ * generating the cipher's session key(s). This value is <b>mandatory</b> and
+ * should be included in the initialisation parameters. If it isn't, an
+ * {@link IllegalStateException} will be thrown if any method, other than
+ * <code>reset()</code> is invoked on the instance. Furthermore, the size of
+ * this key material shall be taken as an indication on the key size in which to
+ * operate this instance.</li>
* </ul>
- *
- * <p><b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
+ * <p>
+ * <b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
* package implement the {@link Cloneable} interface, it is important to note
* here that such an operation <b>DOES NOT</b> clone any session key material
* that may have been used in initialising the source cipher (the instance to be
* cloned). Instead a clone of an already initialised cipher is another instance
* that operates with the <b>same block size</b> but without any knowledge of
- * neither key material nor key size.</p>
+ * neither key material nor key size.
*/
-public interface IBlockCipher extends Cloneable
+public interface IBlockCipher
+ extends Cloneable
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/**
- * <p>Property name of the block size in which to operate a block cipher.
- * The value associated with this property name is taken to be an
- * {@link Integer}.</p>
+ * Property name of the block size in which to operate a block cipher. The
+ * value associated with this property name is taken to be an {@link Integer}.
*/
String CIPHER_BLOCK_SIZE = "gnu.crypto.cipher.block.size";
-
/**
- * <p>Property name of the user-supplied key material. The value associated
- * to this property name is taken to be a byte array.</p>
+ * Property name of the user-supplied key material. The value associated to
+ * this property name is taken to be a byte array.
*/
String KEY_MATERIAL = "gnu.crypto.cipher.key.material";
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of this instance.</p>
- *
+ * Returns the canonical name of this instance.
+ *
* @return the canonical name of this instance.
*/
String name();
/**
- * <p>Returns the default value, in bytes, of the algorithm's block size.</p>
- *
+ * Returns the default value, in bytes, of the algorithm's block size.
+ *
* @return the default value, in bytes, of the algorithm's block size.
*/
int defaultBlockSize();
/**
- * <p>Returns the default value, in bytes, of the algorithm's key size.</p>
- *
+ * Returns the default value, in bytes, of the algorithm's key size.
+ *
* @return the default value, in bytes, of the algorithm's key size.
*/
int defaultKeySize();
/**
- * <p>Returns an {@link Iterator} over the supported block sizes. Each
- * element returned by this object is an {@link Integer}.</p>
- *
+ * Returns an {@link Iterator} over the supported block sizes. Each element
+ * returned by this object is an {@link Integer}.
+ *
* @return an {@link Iterator} over the supported block sizes.
*/
Iterator blockSizes();
/**
- * <p>Returns an {@link Iterator} over the supported key sizes. Each element
- * returned by this object is an {@link Integer}.</p>
- *
+ * Returns an {@link Iterator} over the supported key sizes. Each element
+ * returned by this object is an {@link Integer}.
+ *
* @return an {@link Iterator} over the supported key sizes.
*/
Iterator keySizes();
/**
- * <p>Returns a clone of this instance.</p>
- *
+ * Returns a clone of this instance.
+ *
* @return a clone copy of this instance.
*/
Object clone();
/**
- * <p>Initialises the algorithm with designated attributes. Permissible names
- * and values are described in the class documentation above.</p>
- *
+ * Initialises the algorithm with designated attributes. Permissible names and
+ * values are described in the class documentation above.
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @exception InvalidKeyException if the key data is invalid.
* @exception IllegalStateException if the instance is already initialised.
* @see #KEY_MATERIAL
@@ -154,25 +144,25 @@ public interface IBlockCipher extends Cloneable
void init(Map attributes) throws InvalidKeyException, IllegalStateException;
/**
- * <p>Returns the currently set block size for this instance.</p>
- *
+ * Returns the currently set block size for this instance.
+ *
* @return the current block size for this instance.
* @exception IllegalStateException if the instance is not initialised.
*/
int currentBlockSize() throws IllegalStateException;
/**
- * <p>Resets the algorithm instance for re-initialisation and use with other
- * characteristics. This method always succeeds.</p>
+ * Resets the algorithm instance for re-initialisation and use with other
+ * characteristics. This method always succeeds.
*/
void reset();
/**
- * <p>Encrypts exactly one block of plaintext.</p>
- *
+ * Encrypts exactly one block of plaintext.
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
* @param outOffset index of <code>out</code> from which to store result.
* @exception IllegalStateException if the instance is not initialised.
@@ -181,11 +171,11 @@ public interface IBlockCipher extends Cloneable
throws IllegalStateException;
/**
- * <p>Decrypts exactly one block of ciphertext.</p>
- *
+ * Decrypts exactly one block of ciphertext.
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
* @param outOffset index of <code>out</code> from which to store result.
* @exception IllegalStateException if the instance is not initialised.
@@ -194,12 +184,12 @@ public interface IBlockCipher extends Cloneable
throws IllegalStateException;
/**
- * <p>A <i>correctness</i> test that consists of basic symmetric encryption /
+ * A <i>correctness</i> test that consists of basic symmetric encryption /
* decryption test(s) for all supported block and key sizes, as well as one
- * (1) variable key Known Answer Test (KAT).</p>
- *
+ * (1) variable key Known Answer Test (KAT).
+ *
* @return <code>true</code> if the implementation passes simple
- * <i>correctness</i> tests. Returns <code>false</code> otherwise.
+ * <i>correctness</i> tests. Returns <code>false</code> otherwise.
*/
boolean selfTest();
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipherSpi.java b/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipherSpi.java
index 6fe07ca7f50..1023b12d812 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipherSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/IBlockCipherSpi.java
@@ -42,38 +42,32 @@ import java.security.InvalidKeyException;
import java.util.Iterator;
/**
- * <p>Package-private interface exposing mandatory methods to be implemented by
- * concrete {@link gnu.crypto.cipher.BaseCipher} sub-classes.</p>
+ * Package-private interface exposing mandatory methods to be implemented by
+ * concrete {@link BaseCipher} sub-classes.
*/
-interface IBlockCipherSpi extends Cloneable
+interface IBlockCipherSpi
+ extends Cloneable
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an {@link java.util.Iterator} over the supported block sizes.
- * Each element returned by this object is a {@link java.lang.Integer}.</p>
- *
+ * Returns an {@link Iterator} over the supported block sizes. Each element
+ * returned by this object is a {@link java.lang.Integer}.
+ *
* @return an <code>Iterator</code> over the supported block sizes.
*/
Iterator blockSizes();
/**
- * <p>Returns an {@link java.util.Iterator} over the supported key sizes.
- * Each element returned by this object is a {@link java.lang.Integer}.</p>
- *
+ * Returns an {@link Iterator} over the supported key sizes. Each element
+ * returned by this object is a {@link java.lang.Integer}.
+ *
* @return an <code>Iterator</code> over the supported key sizes.
*/
Iterator keySizes();
/**
- * <p>Expands a user-supplied key material into a session key for a
- * designated <i>block size</i>.</p>
- *
+ * Expands a user-supplied key material into a session key for a designated
+ * <i>block size</i>.
+ *
* @param k the user-supplied key material.
* @param bs the desired block size in bytes.
* @return an Object encapsulating the session key.
@@ -83,46 +77,48 @@ interface IBlockCipherSpi extends Cloneable
Object makeKey(byte[] k, int bs) throws InvalidKeyException;
/**
- * <p>Encrypts exactly one block of plaintext.</p>
- *
+ * Encrypts exactly one block of plaintext.
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
- * @param outOffset index of <code>out</code> from which to store the result.
+ * @param outOffset index of <code>out</code> from which to store the
+ * result.
* @param k the session key to use.
* @param bs the block size to use.
* @exception IllegalArgumentException if the block size is invalid.
* @exception ArrayIndexOutOfBoundsException if there is not enough room in
- * either the plaintext or ciphertext buffers.
+ * either the plaintext or ciphertext buffers.
*/
void encrypt(byte[] in, int inOffset, byte[] out, int outOffset, Object k,
int bs);
/**
- * <p>Decrypts exactly one block of ciphertext.</p>
- *
+ * Decrypts exactly one block of ciphertext.
+ *
* @param in the ciphertext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the plaintext.
- * @param outOffset index of <code>out</code> from which to store the result.
+ * @param outOffset index of <code>out</code> from which to store the
+ * result.
* @param k the session key to use.
* @param bs the block size to use.
* @exception IllegalArgumentException if the block size is invalid.
* @exception ArrayIndexOutOfBoundsException if there is not enough room in
- * either the plaintext or ciphertext buffers.
+ * either the plaintext or ciphertext buffers.
*/
void decrypt(byte[] in, int inOffset, byte[] out, int outOffset, Object k,
int bs);
/**
- * <p>A <i>correctness</i> test that consists of basic symmetric encryption /
+ * A <i>correctness</i> test that consists of basic symmetric encryption /
* decryption test(s) for all supported block and key sizes, as well as one
- * (1) variable key Known Answer Test (KAT).</p>
- *
+ * (1) variable key Known Answer Test (KAT).
+ *
* @return <code>true</code> if the implementation passes simple
- * <i>correctness</i> tests. Returns <code>false</code> otherwise.
+ * <i>correctness</i> tests. Returns <code>false</code> otherwise.
*/
boolean selfTest();
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java b/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
index 3a95874da98..491301f5aad 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
@@ -38,113 +38,79 @@ exception statement from your version. */
package gnu.javax.crypto.cipher;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-//import java.io.PrintWriter;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.logging.Logger;
/**
- * <p>Khazad is a 64-bit (legacy-level) block cipher that accepts a 128-bit key.
+ * Khazad is a 64-bit (legacy-level) block cipher that accepts a 128-bit key.
* The cipher is a uniform substitution-permutation network whose inverse only
* differs from the forward operation in the key schedule. The overall cipher
* design follows the Wide Trail strategy, favours component reuse, and permits
- * a wide variety of implementation trade-offs.</p>
- *
- * <p>References:</p>
- *
+ * a wide variety of implementation trade-offs.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://planeta.terra.com.br/informatica/paulobarreto/KhazadPage.html">The
- * Khazad Block Cipher</a>.<br>
- * <a href="mailto:paulo.barreto@terra.com.br">Paulo S.L.M. Barreto</a> and
- * <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
+ * <li><a
+ * href="http://planeta.terra.com.br/informatica/paulobarreto/KhazadPage.html">The
+ * Khazad Block Cipher</a>.<br>
+ * <a href="mailto:paulo.barreto@terra.com.br">Paulo S.L.M. Barreto</a> and <a
+ * href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
* </ol>
*/
-public final class Khazad extends BaseCipher
+public final class Khazad
+ extends BaseCipher
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- // private static final String NAME = "khazad";
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- // private static final PrintWriter err = new PrintWriter(System.out, true);
- // private static void debug(String s) {
- // err.println(">>> "+NAME+": "+s);
- // }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Khazad.class.getName());
private static final int DEFAULT_BLOCK_SIZE = 8; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 16; // in bytes
-
private static final int R = 8; // standard number of rounds; para. 3.7
-
private static final String Sd = // p. 20 [KHAZAD]
- "\uBA54\u2F74\u53D3\uD24D\u50AC\u8DBF\u7052\u9A4C"
- + "\uEAD5\u97D1\u3351\u5BA6\uDE48\uA899\uDB32\uB7FC"
- + "\uE39E\u919B\uE2BB\u416E\uA5CB\u6B95\uA1F3\uB102"
- + "\uCCC4\u1D14\uC363\uDA5D\u5FDC\u7DCD\u7F5A\u6C5C"
- + "\uF726\uFFED\uE89D\u6F8E\u19A0\uF089\u0F07\uAFFB"
- + "\u0815\u0D04\u0164\uDF76\u79DD\u3D16\u3F37\u6D38"
- + "\uB973\uE935\u5571\u7B8C\u7288\uF62A\u3E5E\u2746"
- + "\u0C65\u6861\u03C1\u57D6\uD958\uD866\uD73A\uC83C"
- + "\uFA96\uA798\uECB8\uC7AE\u694B\uABA9\u670A\u47F2"
- + "\uB522\uE5EE\uBE2B\u8112\u831B\u0E23\uF545\u21CE"
- + "\u492C\uF9E6\uB628\u1782\u1A8B\uFE8A\u09C9\u874E"
- + "\uE12E\uE4E0\uEB90\uA41E\u8560\u0025\uF4F1\u940B"
- + "\uE775\uEF34\u31D4\uD086\u7EAD\uFD29\u303B\u9FF8"
- + "\uC613\u0605\uC511\u777C\u7A78\u361C\u3959\u1856"
- + "\uB3B0\u2420\uB292\uA3C0\u4462\u10B4\u8443\u93C2"
- + "\u4ABD\u8F2D\uBC9C\u6A40\uCFA2\u804F\u1FCA\uAA42";
-
+ "\uBA54\u2F74\u53D3\uD24D\u50AC\u8DBF\u7052\u9A4C"
+ + "\uEAD5\u97D1\u3351\u5BA6\uDE48\uA899\uDB32\uB7FC"
+ + "\uE39E\u919B\uE2BB\u416E\uA5CB\u6B95\uA1F3\uB102"
+ + "\uCCC4\u1D14\uC363\uDA5D\u5FDC\u7DCD\u7F5A\u6C5C"
+ + "\uF726\uFFED\uE89D\u6F8E\u19A0\uF089\u0F07\uAFFB"
+ + "\u0815\u0D04\u0164\uDF76\u79DD\u3D16\u3F37\u6D38"
+ + "\uB973\uE935\u5571\u7B8C\u7288\uF62A\u3E5E\u2746"
+ + "\u0C65\u6861\u03C1\u57D6\uD958\uD866\uD73A\uC83C"
+ + "\uFA96\uA798\uECB8\uC7AE\u694B\uABA9\u670A\u47F2"
+ + "\uB522\uE5EE\uBE2B\u8112\u831B\u0E23\uF545\u21CE"
+ + "\u492C\uF9E6\uB628\u1782\u1A8B\uFE8A\u09C9\u874E"
+ + "\uE12E\uE4E0\uEB90\uA41E\u8560\u0025\uF4F1\u940B"
+ + "\uE775\uEF34\u31D4\uD086\u7EAD\uFD29\u303B\u9FF8"
+ + "\uC613\u0605\uC511\u777C\u7A78\u361C\u3959\u1856"
+ + "\uB3B0\u2420\uB292\uA3C0\u4462\u10B4\u8443\u93C2"
+ + "\u4ABD\u8F2D\uBC9C\u6A40\uCFA2\u804F\u1FCA\uAA42";
private static final byte[] S = new byte[256];
-
private static final int[] T0 = new int[256];
-
private static final int[] T1 = new int[256];
-
private static final int[] T2 = new int[256];
-
private static final int[] T3 = new int[256];
-
private static final int[] T4 = new int[256];
-
private static final int[] T5 = new int[256];
-
private static final int[] T6 = new int[256];
-
private static final int[] T7 = new int[256];
-
private static final int[][] rc = new int[R + 1][2]; // round constants
-
/**
- * KAT vector (from ecb_vk):
- * I=120
- * KEY=00000000000000000000000000000100
+ * KAT vector (from ecb_vk): I=120 KEY=00000000000000000000000000000100
* CT=A0C86A1BBE2CBF4C
*/
- private static final byte[] KAT_KEY = Util.toBytesFromString("00000000000000000000000000000100");
-
+ private static final byte[] KAT_KEY =
+ Util.toBytesFromString("00000000000000000000000000000100");
private static final byte[] KAT_CT = Util.toBytesFromString("A0C86A1BBE2CBF4C");
-
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
- // Static code - to intialise lookup tables --------------------------------
-
static
{
long time = System.currentTimeMillis();
-
long ROOT = 0x11d; // para. 2.1 [KHAZAD]
int i, j;
int s, s2, s3, s4, s5, s6, s7, s8, sb;
@@ -154,198 +120,177 @@ public final class Khazad extends BaseCipher
c = Sd.charAt(i >>> 1);
s = ((i & 1) == 0 ? c >>> 8 : c) & 0xFF;
S[i] = (byte) s;
-
s2 = s << 1;
if (s2 > 0xFF)
s2 ^= ROOT;
-
s3 = s2 ^ s;
s4 = s2 << 1;
if (s4 > 0xFF)
s4 ^= ROOT;
-
s5 = s4 ^ s;
s6 = s4 ^ s2;
s7 = s6 ^ s;
s8 = s4 << 1;
if (s8 > 0xFF)
s8 ^= ROOT;
-
sb = s8 ^ s2 ^ s;
-
- T0[i] = s << 24 | s3 << 16 | s4 << 8 | s5;
- T1[i] = s3 << 24 | s << 16 | s5 << 8 | s4;
- T2[i] = s4 << 24 | s5 << 16 | s << 8 | s3;
+ T0[i] = s << 24 | s3 << 16 | s4 << 8 | s5;
+ T1[i] = s3 << 24 | s << 16 | s5 << 8 | s4;
+ T2[i] = s4 << 24 | s5 << 16 | s << 8 | s3;
T3[i] = s5 << 24 | s4 << 16 | s3 << 8 | s;
T4[i] = s6 << 24 | s8 << 16 | sb << 8 | s7;
T5[i] = s8 << 24 | s6 << 16 | s7 << 8 | sb;
T6[i] = sb << 24 | s7 << 16 | s6 << 8 | s8;
T7[i] = s7 << 24 | sb << 16 | s8 << 8 | s6;
}
-
- for (i = 0, j = 0; i < R + 1; i++)
+ for (i = 0, j = 0; i < R + 1; i++) // compute round constant
{
- // compute round constant
- rc[i][0] = S[j++] << 24 | (S[j++] & 0xFF) << 16
- | (S[j++] & 0xFF) << 8 | (S[j++] & 0xFF);
- rc[i][1] = S[j++] << 24 | (S[j++] & 0xFF) << 16
- | (S[j++] & 0xFF) << 8 | (S[j++] & 0xFF);
+ rc[i][0] = S[j++] << 24
+ | (S[j++] & 0xFF) << 16
+ | (S[j++] & 0xFF) << 8
+ | (S[j++] & 0xFF);
+ rc[i][1] = S[j++] << 24
+ | (S[j++] & 0xFF) << 16
+ | (S[j++] & 0xFF) << 8
+ | (S[j++] & 0xFF);
}
-
time = System.currentTimeMillis() - time;
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println("==========");
- System.out.println();
- System.out.println("Static data");
- System.out.println();
-
- System.out.println();
- System.out.println("T0[]:");
+ log.fine("Static data");
+ log.fine("T0[]:");
+ StringBuilder b;
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T0[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T0[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T1[]:");
+ log.fine("T1[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T1[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T1[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T2[]:");
+ log.fine("T2[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T2[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T2[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T3[]:");
+ log.fine("T3[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T3[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T3[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T4[]:");
+ log.fine("T4[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T4[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T4[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T5[]:");
+ log.fine("T5[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T5[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T6[]:");
+ log.fine("T6[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T6[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T6[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("T7[]:");
+ log.fine("T7[]:");
for (i = 0; i < 64; i++)
{
+ b = new StringBuilder();
for (j = 0; j < 4; j++)
- System.out.print("0x" + Util.toString(T7[i * 4 + j]) + ", ");
- System.out.println();
+ b.append("0x").append(Util.toString(T7[i * 4 + j])).append(", ");
+ log.fine(b.toString());
}
- System.out.println();
- System.out.println("rc[]:");
+ log.fine("rc[]:");
for (i = 0; i < R + 1; i++)
- System.out.print("0x" + Util.toString(rc[i][0])
- + Util.toString(rc[i][1]));
- System.out.println();
-
- System.out.println("Total initialization time: " + time + " ms.");
- System.out.println();
+ log.fine("0x" + Util.toString(rc[i][0]) + Util.toString(rc[i][1]));
+ log.fine("Total initialization time: " + time + " ms.");
}
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Khazad()
{
super(Registry.KHAZAD_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
private static void khazad(byte[] in, int i, byte[] out, int j, int[][] K)
{
// sigma(K[0])
int k0 = K[0][0];
int k1 = K[0][1];
- int a0 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ k0;
- int a1 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i] & 0xFF))
- ^ k1;
-
+ int a0 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ k0;
+ int a1 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i ] & 0xFF) ) ^ k1;
int b0, b1;
// round function
for (int r = 1; r < R; r++)
{
k0 = K[r][0];
k1 = K[r][1];
- b0 = T0[a0 >>> 24] ^ T1[(a0 >>> 16) & 0xFF] ^ T2[(a0 >>> 8) & 0xFF]
- ^ T3[a0 & 0xFF] ^ T4[a1 >>> 24] ^ T5[(a1 >>> 16) & 0xFF]
- ^ T6[(a1 >>> 8) & 0xFF] ^ T7[a1 & 0xFF] ^ k0;
- b1 = T0[a1 >>> 24] ^ T1[(a1 >>> 16) & 0xFF] ^ T2[(a1 >>> 8) & 0xFF]
- ^ T3[a1 & 0xFF] ^ T4[a0 >>> 24] ^ T5[(a0 >>> 16) & 0xFF]
- ^ T6[(a0 >>> 8) & 0xFF] ^ T7[a0 & 0xFF] ^ k1;
+ b0 = T0[ a0 >>> 24 ]
+ ^ T1[(a0 >>> 16) & 0xFF]
+ ^ T2[(a0 >>> 8) & 0xFF]
+ ^ T3[ a0 & 0xFF]
+ ^ T4[ a1 >>> 24 ]
+ ^ T5[(a1 >>> 16) & 0xFF]
+ ^ T6[(a1 >>> 8) & 0xFF]
+ ^ T7[ a1 & 0xFF] ^ k0;
+ b1 = T0[ a1 >>> 24 ]
+ ^ T1[(a1 >>> 16) & 0xFF]
+ ^ T2[(a1 >>> 8) & 0xFF]
+ ^ T3[ a1 & 0xFF]
+ ^ T4[ a0 >>> 24 ]
+ ^ T5[(a0 >>> 16) & 0xFF]
+ ^ T6[(a0 >>> 8) & 0xFF]
+ ^ T7[ a0 & 0xFF] ^ k1;
a0 = b0;
a1 = b1;
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("T" + r + "=" + Util.toString(a0)
- + Util.toString(a1));
- }
+ if (Configuration.DEBUG)
+ log.fine("T" + r + "=" + Util.toString(a0) + Util.toString(a1));
}
-
// sigma(K[R]) o gamma applied to previous output
k0 = K[R][0];
k1 = K[R][1];
-
- out[j++] = (byte) (S[a0 >>> 24] ^ (k0 >>> 24));
- out[j++] = (byte) (S[(a0 >>> 16) & 0xFF] ^ (k0 >>> 16));
- out[j++] = (byte) (S[(a0 >>> 8) & 0xFF] ^ (k0 >>> 8));
- out[j++] = (byte) (S[a0 & 0xFF] ^ k0);
- out[j++] = (byte) (S[a1 >>> 24] ^ (k1 >>> 24));
- out[j++] = (byte) (S[(a1 >>> 16) & 0xFF] ^ (k1 >>> 16));
- out[j++] = (byte) (S[(a1 >>> 8) & 0xFF] ^ (k1 >>> 8));
- out[j] = (byte) (S[a1 & 0xFF] ^ k1);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("T=" + Util.toString(out, j - 7, 8));
- System.out.println();
- }
+ out[j++] = (byte)(S[ a0 >>> 24 ] ^ (k0 >>> 24));
+ out[j++] = (byte)(S[(a0 >>> 16) & 0xFF] ^ (k0 >>> 16));
+ out[j++] = (byte)(S[(a0 >>> 8) & 0xFF] ^ (k0 >>> 8));
+ out[j++] = (byte)(S[ a0 & 0xFF] ^ k0 );
+ out[j++] = (byte)(S[ a1 >>> 24 ] ^ (k1 >>> 24));
+ out[j++] = (byte)(S[(a1 >>> 16) & 0xFF] ^ (k1 >>> 16));
+ out[j++] = (byte)(S[(a1 >>> 8) & 0xFF] ^ (k1 >>> 8));
+ out[j ] = (byte)(S[ a1 & 0xFF] ^ k1 );
+ if (Configuration.DEBUG)
+ log.fine("T=" + Util.toString(out, j - 7, 8) + "\n");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Khazad result = new Khazad();
@@ -354,12 +299,10 @@ public final class Khazad extends BaseCipher
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_BLOCK_SIZE));
+ al.add(Integer.valueOf(DEFAULT_BLOCK_SIZE));
return Collections.unmodifiableList(al).iterator();
}
@@ -367,15 +310,14 @@ public final class Khazad extends BaseCipher
public Iterator keySizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_KEY_SIZE));
-
+ al.add(Integer.valueOf(DEFAULT_KEY_SIZE));
return Collections.unmodifiableList(al).iterator();
}
/**
- * <p>Expands a user-supplied key material into a session key for a
- * designated <i>block size</i>.</p>
- *
+ * Expands a user-supplied key material into a session key for a designated
+ * <i>block size</i>.
+ *
* @param uk the 128-bit user-supplied key material.
* @param bs the desired block size in bytes.
* @return an Object encapsulating the session key.
@@ -385,54 +327,58 @@ public final class Khazad extends BaseCipher
public Object makeKey(byte[] uk, int bs) throws InvalidKeyException
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (uk == null)
- {
- throw new InvalidKeyException("Empty key");
- }
+ throw new InvalidKeyException("Empty key");
if (uk.length != 16)
- {
- throw new InvalidKeyException("Key is not 128-bit.");
- }
+ throw new InvalidKeyException("Key is not 128-bit.");
int[][] Ke = new int[R + 1][2]; // encryption round keys
int[][] Kd = new int[R + 1][2]; // decryption round keys
-
int r, i;
int k20, k21, k10, k11, rc0, rc1, kr0, kr1;
-
i = 0;
- k20 = uk[i++] << 24 | (uk[i++] & 0xFF) << 16 | (uk[i++] & 0xFF) << 8
- | (uk[i++] & 0xFF);
- k21 = uk[i++] << 24 | (uk[i++] & 0xFF) << 16 | (uk[i++] & 0xFF) << 8
- | (uk[i++] & 0xFF);
- k10 = uk[i++] << 24 | (uk[i++] & 0xFF) << 16 | (uk[i++] & 0xFF) << 8
- | (uk[i++] & 0xFF);
- k11 = uk[i++] << 24 | (uk[i++] & 0xFF) << 16 | (uk[i++] & 0xFF) << 8
- | (uk[i++] & 0xFF);
-
+ k20 = uk[i++] << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
+ k21 = uk[i++] << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
+ k10 = uk[i++] << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
+ k11 = uk[i++] << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
for (r = 0, i = 0; r <= R; r++)
{
rc0 = rc[r][0];
rc1 = rc[r][1];
-
- kr0 = T0[k10 >>> 24] ^ T1[(k10 >>> 16) & 0xFF] ^ T2[(k10 >>> 8) & 0xFF]
- ^ T3[k10 & 0xFF] ^ T4[(k11 >>> 24) & 0xFF]
- ^ T5[(k11 >>> 16) & 0xFF] ^ T6[(k11 >>> 8) & 0xFF]
- ^ T7[k11 & 0xFF] ^ rc0 ^ k20;
- kr1 = T0[k11 >>> 24] ^ T1[(k11 >>> 16) & 0xFF] ^ T2[(k11 >>> 8) & 0xFF]
- ^ T3[k11 & 0xFF] ^ T4[(k10 >>> 24) & 0xFF]
- ^ T5[(k10 >>> 16) & 0xFF] ^ T6[(k10 >>> 8) & 0xFF]
- ^ T7[k10 & 0xFF] ^ rc1 ^ k21;
-
+ kr0 = T0[ k10 >>> 24 ]
+ ^ T1[(k10 >>> 16) & 0xFF]
+ ^ T2[(k10 >>> 8) & 0xFF]
+ ^ T3[ k10 & 0xFF]
+ ^ T4[(k11 >>> 24) & 0xFF]
+ ^ T5[(k11 >>> 16) & 0xFF]
+ ^ T6[(k11 >>> 8) & 0xFF]
+ ^ T7[ k11 & 0xFF] ^ rc0 ^ k20;
+ kr1 = T0[ k11 >>> 24 ]
+ ^ T1[(k11 >>> 16) & 0xFF]
+ ^ T2[(k11 >>> 8) & 0xFF]
+ ^ T3[ k11 & 0xFF]
+ ^ T4[(k10 >>> 24) & 0xFF]
+ ^ T5[(k10 >>> 16) & 0xFF]
+ ^ T6[(k10 >>> 8) & 0xFF]
+ ^ T7[ k10 & 0xFF] ^ rc1 ^ k21;
Ke[r][0] = kr0;
Ke[r][1] = kr1;
k20 = k10;
k21 = k11;
k10 = kr0;
k11 = kr1;
-
if (r == 0 || r == R)
{
Kd[R - r][0] = kr0;
@@ -440,68 +386,52 @@ public final class Khazad extends BaseCipher
}
else
{
- Kd[R - r][0] = T0[S[kr0 >>> 24] & 0xFF]
- ^ T1[S[(kr0 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(kr0 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[kr0 & 0xFF] & 0xFF]
- ^ T4[S[kr1 >>> 24] & 0xFF]
- ^ T5[S[(kr1 >>> 16) & 0xFF] & 0xFF]
- ^ T6[S[(kr1 >>> 8) & 0xFF] & 0xFF]
- ^ T7[S[kr1 & 0xFF] & 0xFF];
- Kd[R - r][1] = T0[S[kr1 >>> 24] & 0xFF]
- ^ T1[S[(kr1 >>> 16) & 0xFF] & 0xFF]
- ^ T2[S[(kr1 >>> 8) & 0xFF] & 0xFF]
- ^ T3[S[kr1 & 0xFF] & 0xFF]
- ^ T4[S[kr0 >>> 24] & 0xFF]
- ^ T5[S[(kr0 >>> 16) & 0xFF] & 0xFF]
- ^ T6[S[(kr0 >>> 8) & 0xFF] & 0xFF]
- ^ T7[S[kr0 & 0xFF] & 0xFF];
+ Kd[R - r][0] = T0[S[ kr0 >>> 24 ] & 0xFF]
+ ^ T1[S[(kr0 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(kr0 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ kr0 & 0xFF] & 0xFF]
+ ^ T4[S[ kr1 >>> 24 ] & 0xFF]
+ ^ T5[S[(kr1 >>> 16) & 0xFF] & 0xFF]
+ ^ T6[S[(kr1 >>> 8) & 0xFF] & 0xFF]
+ ^ T7[S[ kr1 & 0xFF] & 0xFF];
+ Kd[R - r][1] = T0[S[ kr1 >>> 24 ] & 0xFF]
+ ^ T1[S[(kr1 >>> 16) & 0xFF] & 0xFF]
+ ^ T2[S[(kr1 >>> 8) & 0xFF] & 0xFF]
+ ^ T3[S[ kr1 & 0xFF] & 0xFF]
+ ^ T4[S[ kr0 >>> 24 ] & 0xFF]
+ ^ T5[S[(kr0 >>> 16) & 0xFF] & 0xFF]
+ ^ T6[S[(kr0 >>> 8) & 0xFF] & 0xFF]
+ ^ T7[S[ kr0 & 0xFF] & 0xFF];
}
}
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println();
- System.out.println("Key schedule");
- System.out.println();
- System.out.println("Ke[]:");
+ log.fine("Key schedule");
+ log.fine("Ke[]:");
for (r = 0; r < R + 1; r++)
- {
- System.out.println("#" + r + ": 0x" + Util.toString(Ke[r][0])
- + Util.toString(Ke[r][1]));
- }
- System.out.println();
- System.out.println("Kd[]:");
+ log.fine("#" + r + ": 0x" + Util.toString(Ke[r][0])
+ + Util.toString(Ke[r][1]));
+ log.fine("Kd[]:");
for (r = 0; r < R + 1; r++)
- {
- System.out.println("#" + r + ": 0x" + Util.toString(Kd[r][0])
- + Util.toString(Kd[r][1]));
- }
- System.out.println();
+ log.fine("#" + r + ": 0x" + Util.toString(Kd[r][0])
+ + Util.toString(Kd[r][1]));
}
-
return new Object[] { Ke, Kd };
}
public void encrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[0];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[0];
khazad(in, i, out, j, K);
}
public void decrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[1];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[1];
khazad(in, i, out, j, K);
}
@@ -511,11 +441,9 @@ public final class Khazad extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/NullCipher.java b/libjava/classpath/gnu/javax/crypto/cipher/NullCipher.java
index 09252db9063..4515559549b 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/NullCipher.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/NullCipher.java
@@ -46,53 +46,35 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * <p>The implementation of a Null block cipher.</p>
- *
- * <p>This cipher does not alter its input at all, claims to process block sizes
+ * The implementation of a Null block cipher.
+ * <p>
+ * This cipher does not alter its input at all, claims to process block sizes
* 128-, 192- and 256-bit long, and key sizes from 64- to 512-bit in 8-bit
- * increments.</p>
+ * increments.
*/
-public final class NullCipher extends BaseCipher
+public final class NullCipher
+ extends BaseCipher
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public NullCipher()
{
super(Registry.NULL_CIPHER, 16, 16);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
NullCipher result = new NullCipher();
result.currentBlockSize = this.currentBlockSize;
-
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(64 / 8));
- al.add(new Integer(128 / 8));
- al.add(new Integer(192 / 8));
- al.add(new Integer(256 / 8));
-
+ al.add(Integer.valueOf(64 / 8));
+ al.add(Integer.valueOf(128 / 8));
+ al.add(Integer.valueOf(192 / 8));
+ al.add(Integer.valueOf(256 / 8));
return Collections.unmodifiableList(al).iterator();
}
@@ -100,10 +82,7 @@ public final class NullCipher extends BaseCipher
{
ArrayList al = new ArrayList();
for (int n = 8; n < 64; n++)
- {
- al.add(new Integer(n));
- }
-
+ al.add(Integer.valueOf(n));
return Collections.unmodifiableList(al).iterator();
}
@@ -126,4 +105,4 @@ public final class NullCipher extends BaseCipher
{
return true;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java b/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
index bcd1872fc1b..d1bc958c323 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
@@ -38,372 +38,274 @@ exception statement from your version. */
package gnu.javax.crypto.cipher;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-//import java.io.PrintWriter;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.logging.Logger;
/**
- * <p>Rijndael --pronounced Reindaal-- is the AES. It is a variable block-size
+ * Rijndael --pronounced Reindaal-- is the AES. It is a variable block-size
* (128-, 192- and 256-bit), variable key-size (128-, 192- and 256-bit)
- * symmetric key block cipher.</p>
- *
- * <p>References:</p>
- *
+ * symmetric key block cipher.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.esat.kuleuven.ac.be/~rijmen/rijndael/">The
- * Rijndael Block Cipher - AES Proposal</a>.<br>
- * <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a> and
- * <a href="mailto:daemen.j@protonworld.com">Joan Daemen</a>.</li>
+ * <li><a href="http://www.esat.kuleuven.ac.be/~rijmen/rijndael/">The Rijndael
+ * Block Cipher - AES Proposal</a>.<br>
+ * <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a> and
+ * <a href="mailto:daemen.j@protonworld.com">Joan Daemen</a>.</li>
* </ol>
*/
-public final class Rijndael extends BaseCipher
+public final class Rijndael
+ extends BaseCipher
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- // private static final String NAME = "rijndael";
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- // private static final PrintWriter err = new PrintWriter(System.out, true);
- // private static void debug(String s) {
- // err.println(">>> "+NAME+": "+s);
- // }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Rijndael.class.getName());
private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 16; // in bytes
-
- private static final String SS = "\u637C\u777B\uF26B\u6FC5\u3001\u672B\uFED7\uAB76"
- + "\uCA82\uC97D\uFA59\u47F0\uADD4\uA2AF\u9CA4\u72C0"
- + "\uB7FD\u9326\u363F\uF7CC\u34A5\uE5F1\u71D8\u3115"
- + "\u04C7\u23C3\u1896\u059A\u0712\u80E2\uEB27\uB275"
- + "\u0983\u2C1A\u1B6E\u5AA0\u523B\uD6B3\u29E3\u2F84"
- + "\u53D1\u00ED\u20FC\uB15B\u6ACB\uBE39\u4A4C\u58CF"
- + "\uD0EF\uAAFB\u434D\u3385\u45F9\u027F\u503C\u9FA8"
- + "\u51A3\u408F\u929D\u38F5\uBCB6\uDA21\u10FF\uF3D2"
- + "\uCD0C\u13EC\u5F97\u4417\uC4A7\u7E3D\u645D\u1973"
- + "\u6081\u4FDC\u222A\u9088\u46EE\uB814\uDE5E\u0BDB"
- + "\uE032\u3A0A\u4906\u245C\uC2D3\uAC62\u9195\uE479"
- + "\uE7C8\u376D\u8DD5\u4EA9\u6C56\uF4EA\u657A\uAE08"
- + "\uBA78\u252E\u1CA6\uB4C6\uE8DD\u741F\u4BBD\u8B8A"
- + "\u703E\uB566\u4803\uF60E\u6135\u57B9\u86C1\u1D9E"
- + "\uE1F8\u9811\u69D9\u8E94\u9B1E\u87E9\uCE55\u28DF"
- + "\u8CA1\u890D\uBFE6\u4268\u4199\u2D0F\uB054\uBB16";
-
+ private static final String SS =
+ "\u637C\u777B\uF26B\u6FC5\u3001\u672B\uFED7\uAB76"
+ + "\uCA82\uC97D\uFA59\u47F0\uADD4\uA2AF\u9CA4\u72C0"
+ + "\uB7FD\u9326\u363F\uF7CC\u34A5\uE5F1\u71D8\u3115"
+ + "\u04C7\u23C3\u1896\u059A\u0712\u80E2\uEB27\uB275"
+ + "\u0983\u2C1A\u1B6E\u5AA0\u523B\uD6B3\u29E3\u2F84"
+ + "\u53D1\u00ED\u20FC\uB15B\u6ACB\uBE39\u4A4C\u58CF"
+ + "\uD0EF\uAAFB\u434D\u3385\u45F9\u027F\u503C\u9FA8"
+ + "\u51A3\u408F\u929D\u38F5\uBCB6\uDA21\u10FF\uF3D2"
+ + "\uCD0C\u13EC\u5F97\u4417\uC4A7\u7E3D\u645D\u1973"
+ + "\u6081\u4FDC\u222A\u9088\u46EE\uB814\uDE5E\u0BDB"
+ + "\uE032\u3A0A\u4906\u245C\uC2D3\uAC62\u9195\uE479"
+ + "\uE7C8\u376D\u8DD5\u4EA9\u6C56\uF4EA\u657A\uAE08"
+ + "\uBA78\u252E\u1CA6\uB4C6\uE8DD\u741F\u4BBD\u8B8A"
+ + "\u703E\uB566\u4803\uF60E\u6135\u57B9\u86C1\u1D9E"
+ + "\uE1F8\u9811\u69D9\u8E94\u9B1E\u87E9\uCE55\u28DF"
+ + "\u8CA1\u890D\uBFE6\u4268\u4199\u2D0F\uB054\uBB16";
private static final byte[] S = new byte[256];
-
private static final byte[] Si = new byte[256];
-
private static final int[] T1 = new int[256];
-
private static final int[] T2 = new int[256];
-
private static final int[] T3 = new int[256];
-
private static final int[] T4 = new int[256];
-
private static final int[] T5 = new int[256];
-
private static final int[] T6 = new int[256];
-
private static final int[] T7 = new int[256];
-
private static final int[] T8 = new int[256];
-
private static final int[] U1 = new int[256];
-
private static final int[] U2 = new int[256];
-
private static final int[] U3 = new int[256];
-
private static final int[] U4 = new int[256];
-
private static final byte[] rcon = new byte[30];
-
private static final int[][][] shifts = new int[][][] {
- { { 0, 0 }, { 1, 3 },
- { 2, 2 }, { 3, 1 } },
- { { 0, 0 }, { 1, 5 },
- { 2, 4 }, { 3, 3 } },
- { { 0, 0 }, { 1, 7 },
- { 3, 5 }, { 4, 4 } } };
-
+ { { 0, 0 }, { 1, 3 }, { 2, 2 }, { 3, 1 } },
+ { { 0, 0 }, { 1, 5 }, { 2, 4 }, { 3, 3 } },
+ { { 0, 0 }, { 1, 7 }, { 3, 5 }, { 4, 4 } } };
/**
- * KAT vector (from ecb_vk):
- * I=96
+ * KAT vector (from ecb_vk): I=96
* KEY=0000000000000000000000010000000000000000000000000000000000000000
* CT=E44429474D6FC3084EB2A6B8B46AF754
*/
- private static final byte[] KAT_KEY = Util.toBytesFromString("0000000000000000000000010000000000000000000000000000000000000000");
-
- private static final byte[] KAT_CT = Util.toBytesFromString("E44429474D6FC3084EB2A6B8B46AF754");
-
+ private static final byte[] KAT_KEY = Util.toBytesFromString(
+ "0000000000000000000000010000000000000000000000000000000000000000");
+ private static final byte[] KAT_CT = Util.toBytesFromString(
+ "E44429474D6FC3084EB2A6B8B46AF754");
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
- // Static code - to intialise lookup tables --------------------------------
-
static
{
long time = System.currentTimeMillis();
-
int ROOT = 0x11B;
int i, j = 0;
-
// S-box, inverse S-box, T-boxes, U-boxes
int s, s2, s3, i2, i4, i8, i9, ib, id, ie, t;
char c;
for (i = 0; i < 256; i++)
{
c = SS.charAt(i >>> 1);
- S[i] = (byte) (((i & 1) == 0) ? c >>> 8 : c & 0xFF);
+ S[i] = (byte)(((i & 1) == 0) ? c >>> 8 : c & 0xFF);
s = S[i] & 0xFF;
Si[s] = (byte) i;
s2 = s << 1;
if (s2 >= 0x100)
- {
- s2 ^= ROOT;
- }
+ s2 ^= ROOT;
s3 = s2 ^ s;
i2 = i << 1;
if (i2 >= 0x100)
- {
- i2 ^= ROOT;
- }
+ i2 ^= ROOT;
i4 = i2 << 1;
if (i4 >= 0x100)
- {
- i4 ^= ROOT;
- }
+ i4 ^= ROOT;
i8 = i4 << 1;
if (i8 >= 0x100)
- {
- i8 ^= ROOT;
- }
+ i8 ^= ROOT;
i9 = i8 ^ i;
ib = i9 ^ i2;
id = i9 ^ i4;
ie = i8 ^ i4 ^ i2;
-
T1[i] = t = (s2 << 24) | (s << 16) | (s << 8) | s3;
- T2[i] = (t >>> 8) | (t << 24);
+ T2[i] = (t >>> 8) | (t << 24);
T3[i] = (t >>> 16) | (t << 16);
- T4[i] = (t >>> 24) | (t << 8);
-
+ T4[i] = (t >>> 24) | (t << 8);
T5[s] = U1[i] = t = (ie << 24) | (i9 << 16) | (id << 8) | ib;
- T6[s] = U2[i] = (t >>> 8) | (t << 24);
+ T6[s] = U2[i] = (t >>> 8) | (t << 24);
T7[s] = U3[i] = (t >>> 16) | (t << 16);
- T8[s] = U4[i] = (t >>> 24) | (t << 8);
+ T8[s] = U4[i] = (t >>> 24) | (t << 8);
}
- //
// round constants
- //
int r = 1;
rcon[0] = 1;
for (i = 1; i < 30; i++)
{
r <<= 1;
if (r >= 0x100)
- {
- r ^= ROOT;
- }
+ r ^= ROOT;
rcon[i] = (byte) r;
}
-
time = System.currentTimeMillis() - time;
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println("==========");
- System.out.println();
- System.out.println("Static Data");
- System.out.println();
- System.out.println("S[]:");
+ log.fine("Static Data");
+ log.fine("S[]:");
+ StringBuilder sb;
for (i = 0; i < 16; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 16; j++)
- {
- System.out.print("0x" + Util.toString(S[i * 16 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(S[i * 16 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("Si[]:");
+ log.fine("Si[]:");
for (i = 0; i < 16; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 16; j++)
- {
- System.out.print("0x" + Util.toString(Si[i * 16 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(Si[i * 16 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T1[]:");
+ log.fine("T1[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T1[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T1[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T2[]:");
+ log.fine("T2[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T2[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T2[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T3[]:");
+ log.fine("T3[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T3[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T3[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T4[]:");
+ log.fine("T4[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T4[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T4[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T5[]:");
+ log.fine("T5[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T6[]:");
+ log.fine("T6[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T6[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T6[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T7[]:");
+ log.fine("T7[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T7[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T7[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("T8[]:");
+ log.fine("T8[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(T8[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(T8[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("U1[]:");
+ log.fine("U1[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(U1[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(U1[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("U2[]:");
+ log.fine("U2[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(U2[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(U2[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("U3[]:");
+ log.fine("U3[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(U3[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(U3[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("U4[]:");
+ log.fine("U4[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.println("0x" + Util.toString(U4[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(U4[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("rcon[]:");
+ log.fine("rcon[]:");
for (i = 0; i < 5; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 6; j++)
- {
- System.out.print("0x" + Util.toString(rcon[i * 6 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(rcon[i * 6 + j])).append(", ");
+ log.fine(sb.toString());
}
-
- System.out.println();
- System.out.println("Total initialization time: " + time + " ms.");
- System.out.println();
+ log.fine("Total initialization time: " + time + " ms.");
}
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Rijndael()
{
super(Registry.RIJNDAEL_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the number of rounds for a given Rijndael's key and block
- * sizes.</p>
- *
+ * Returns the number of rounds for a given Rijndael's key and block sizes.
+ *
* @param ks the size of the user key material in bytes.
* @param bs the desired block size in bytes.
* @return the number of rounds for a given Rijndael's key and block sizes.
@@ -426,7 +328,6 @@ public final class Rijndael extends BaseCipher
{
Object[] sKey = (Object[]) sessionKey; // extract encryption round keys
int[][] Ke = (int[][]) sKey[0];
-
int BC = bs / 4;
int ROUNDS = Ke.length - 1;
int SC = BC == 4 ? 0 : (BC == 6 ? 1 : 2);
@@ -436,45 +337,32 @@ public final class Rijndael extends BaseCipher
int[] a = new int[BC];
int[] t = new int[BC]; // temporary work array
int i, tt;
-
- for (i = 0; i < BC; i++)
- { // plaintext to ints + key
- t[i] = (in[inOffset++] << 24 | (in[inOffset++] & 0xFF) << 16
- | (in[inOffset++] & 0xFF) << 8 | (in[inOffset++] & 0xFF))
- ^ Ke[0][i];
- }
-
- for (int r = 1; r < ROUNDS; r++)
- { // apply round transforms
+ for (i = 0; i < BC; i++) // plaintext to ints + key
+ t[i] = (in[inOffset++] << 24
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) ) ^ Ke[0][i];
+ for (int r = 1; r < ROUNDS; r++) // apply round transforms
+ {
for (i = 0; i < BC; i++)
- {
- a[i] = (T1[(t[i] >>> 24)] ^ T2[(t[(i + s1) % BC] >>> 16) & 0xFF]
- ^ T3[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ T4[t[(i + s3) % BC] & 0xFF])
- ^ Ke[r][i];
- }
-
+ a[i] = (T1[(t[ i ] >>> 24) ]
+ ^ T2[(t[(i + s1) % BC] >>> 16) & 0xFF]
+ ^ T3[(t[(i + s2) % BC] >>> 8) & 0xFF]
+ ^ T4[ t[(i + s3) % BC] & 0xFF]) ^ Ke[r][i];
System.arraycopy(a, 0, t, 0, BC);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT" + r + "=" + Util.toString(t));
- }
+ if (Configuration.DEBUG)
+ log.fine("CT" + r + "=" + Util.toString(t));
}
-
- for (i = 0; i < BC; i++)
- { // last round is special
- tt = Ke[ROUNDS][i];
- out[outOffset++] = (byte) (S[(t[i] >>> 24)] ^ (tt >>> 24));
- out[outOffset++] = (byte) (S[(t[(i + s1) % BC] >>> 16) & 0xFF] ^ (tt >>> 16));
- out[outOffset++] = (byte) (S[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt >>> 8));
- out[outOffset++] = (byte) (S[t[(i + s3) % BC] & 0xFF] ^ tt);
- }
-
- if (DEBUG && debuglevel > 6)
+ for (i = 0; i < BC; i++) // last round is special
{
- System.out.println("CT=" + Util.toString(out, outOffset - bs + 1, bs));
- System.out.println();
+ tt = Ke[ROUNDS][i];
+ out[outOffset++] = (byte)(S[(t[ i ] >>> 24) ] ^ (tt >>> 24));
+ out[outOffset++] = (byte)(S[(t[(i + s1) % BC] >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[outOffset++] = (byte)(S[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[outOffset++] = (byte)(S[ t[(i + s3) % BC] & 0xFF] ^ tt );
}
+ if (Configuration.DEBUG)
+ log.fine("CT=" + Util.toString(out, outOffset - bs, bs));
}
private static void rijndaelDecrypt(byte[] in, int inOffset, byte[] out,
@@ -482,7 +370,6 @@ public final class Rijndael extends BaseCipher
{
Object[] sKey = (Object[]) sessionKey; // extract decryption round keys
int[][] Kd = (int[][]) sKey[1];
-
int BC = bs / 4;
int ROUNDS = Kd.length - 1;
int SC = BC == 4 ? 0 : (BC == 6 ? 1 : 2);
@@ -492,194 +379,187 @@ public final class Rijndael extends BaseCipher
int[] a = new int[BC];
int[] t = new int[BC]; // temporary work array
int i, tt;
-
- for (i = 0; i < BC; i++)
- { // ciphertext to ints + key
- t[i] = (in[inOffset++] << 24 | (in[inOffset++] & 0xFF) << 16
- | (in[inOffset++] & 0xFF) << 8 | (in[inOffset++] & 0xFF))
- ^ Kd[0][i];
- }
-
- for (int r = 1; r < ROUNDS; r++)
- { // apply round transforms
+ for (i = 0; i < BC; i++) // ciphertext to ints + key
+ t[i] = (in[inOffset++] << 24
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) ) ^ Kd[0][i];
+ for (int r = 1; r < ROUNDS; r++) // apply round transforms
+ {
for (i = 0; i < BC; i++)
- {
- a[i] = (T5[(t[i] >>> 24)] ^ T6[(t[(i + s1) % BC] >>> 16) & 0xFF]
- ^ T7[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ T8[t[(i + s3) % BC] & 0xFF])
- ^ Kd[r][i];
- }
-
+ a[i] = (T5[(t[ i ] >>> 24) ]
+ ^ T6[(t[(i + s1) % BC] >>> 16) & 0xFF]
+ ^ T7[(t[(i + s2) % BC] >>> 8) & 0xFF]
+ ^ T8[ t[(i + s3) % BC] & 0xFF]) ^ Kd[r][i];
System.arraycopy(a, 0, t, 0, BC);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT" + r + "=" + Util.toString(t));
- }
- }
-
- for (i = 0; i < BC; i++)
- { // last round is special
- tt = Kd[ROUNDS][i];
- out[outOffset++] = (byte) (Si[(t[i] >>> 24)] ^ (tt >>> 24));
- out[outOffset++] = (byte) (Si[(t[(i + s1) % BC] >>> 16) & 0xFF] ^ (tt >>> 16));
- out[outOffset++] = (byte) (Si[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt >>> 8));
- out[outOffset++] = (byte) (Si[t[(i + s3) % BC] & 0xFF] ^ tt);
+ if (Configuration.DEBUG)
+ log.fine("PT" + r + "=" + Util.toString(t));
}
-
- if (DEBUG && debuglevel > 6)
+ for (i = 0; i < BC; i++) // last round is special
{
- System.out.println("PT=" + Util.toString(out, outOffset - bs + 1, bs));
- System.out.println();
+ tt = Kd[ROUNDS][i];
+ out[outOffset++] = (byte)(Si[(t[ i ] >>> 24) ] ^ (tt >>> 24));
+ out[outOffset++] = (byte)(Si[(t[(i + s1) % BC] >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[outOffset++] = (byte)(Si[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[outOffset++] = (byte)(Si[ t[(i + s3) % BC] & 0xFF] ^ tt );
}
+ if (Configuration.DEBUG)
+ log.fine("PT=" + Util.toString(out, outOffset - bs, bs));
}
private static void aesEncrypt(byte[] in, int i, byte[] out, int j, Object key)
{
- int[][] Ke = (int[][]) ((Object[]) key)[0]; // extract encryption round keys
+ int[][] Ke = (int[][])((Object[]) key)[0]; // extract encryption round keys
int ROUNDS = Ke.length - 1;
int[] Ker = Ke[0];
-
// plaintext to ints + key
- int t0 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[0];
- int t1 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[1];
- int t2 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[2];
- int t3 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Ker[3];
-
+ int t0 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[0];
+ int t1 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[1];
+ int t2 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[2];
+ int t3 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Ker[3];
int a0, a1, a2, a3;
- for (int r = 1; r < ROUNDS; r++)
- { // apply round transforms
+ for (int r = 1; r < ROUNDS; r++) // apply round transforms
+ {
Ker = Ke[r];
- a0 = (T1[(t0 >>> 24)] ^ T2[(t1 >>> 16) & 0xFF] ^ T3[(t2 >>> 8) & 0xFF] ^ T4[t3 & 0xFF])
- ^ Ker[0];
- a1 = (T1[(t1 >>> 24)] ^ T2[(t2 >>> 16) & 0xFF] ^ T3[(t3 >>> 8) & 0xFF] ^ T4[t0 & 0xFF])
- ^ Ker[1];
- a2 = (T1[(t2 >>> 24)] ^ T2[(t3 >>> 16) & 0xFF] ^ T3[(t0 >>> 8) & 0xFF] ^ T4[t1 & 0xFF])
- ^ Ker[2];
- a3 = (T1[(t3 >>> 24)] ^ T2[(t0 >>> 16) & 0xFF] ^ T3[(t1 >>> 8) & 0xFF] ^ T4[t2 & 0xFF])
- ^ Ker[3];
+ a0 = (T1[(t0 >>> 24) ]
+ ^ T2[(t1 >>> 16) & 0xFF]
+ ^ T3[(t2 >>> 8) & 0xFF]
+ ^ T4[ t3 & 0xFF]) ^ Ker[0];
+ a1 = (T1[(t1 >>> 24) ]
+ ^ T2[(t2 >>> 16) & 0xFF]
+ ^ T3[(t3 >>> 8) & 0xFF]
+ ^ T4[ t0 & 0xFF]) ^ Ker[1];
+ a2 = (T1[(t2 >>> 24) ]
+ ^ T2[(t3 >>> 16) & 0xFF]
+ ^ T3[(t0 >>> 8) & 0xFF]
+ ^ T4[ t1 & 0xFF]) ^ Ker[2];
+ a3 = (T1[(t3 >>> 24) ]
+ ^ T2[(t0 >>> 16) & 0xFF]
+ ^ T3[(t1 >>> 8) & 0xFF]
+ ^ T4[ t2 & 0xFF]) ^ Ker[3];
t0 = a0;
t1 = a1;
t2 = a2;
t3 = a3;
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT" + r + "=" + Util.toString(t0)
- + Util.toString(t1) + Util.toString(t2)
- + Util.toString(t3));
- }
+ if (Configuration.DEBUG)
+ log.fine("CT" + r + "=" + Util.toString(t0) + Util.toString(t1)
+ + Util.toString(t2) + Util.toString(t3));
}
-
// last round is special
Ker = Ke[ROUNDS];
int tt = Ker[0];
- out[j++] = (byte) (S[(t0 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (S[(t1 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(t2 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[t3 & 0xFF] ^ tt);
+ out[j++] = (byte)(S[(t0 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(t1 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(t2 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[ t3 & 0xFF] ^ tt );
tt = Ker[1];
- out[j++] = (byte) (S[(t1 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (S[(t2 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(t3 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[t0 & 0xFF] ^ tt);
+ out[j++] = (byte)(S[(t1 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(t2 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(t3 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[ t0 & 0xFF] ^ tt );
tt = Ker[2];
- out[j++] = (byte) (S[(t2 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (S[(t3 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(t0 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[t1 & 0xFF] ^ tt);
+ out[j++] = (byte)(S[(t2 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(t3 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(t0 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[ t1 & 0xFF] ^ tt );
tt = Ker[3];
- out[j++] = (byte) (S[(t3 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (S[(t0 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (S[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (S[t2 & 0xFF] ^ tt);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT=" + Util.toString(out, j - 15, 16));
- System.out.println();
- }
+ out[j++] = (byte)(S[(t3 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(S[(t0 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(S[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(S[ t2 & 0xFF] ^ tt );
+ if (Configuration.DEBUG)
+ log.fine("CT=" + Util.toString(out, j - 16, 16));
}
private static void aesDecrypt(byte[] in, int i, byte[] out, int j, Object key)
{
- int[][] Kd = (int[][]) ((Object[]) key)[1]; // extract decryption round keys
+ int[][] Kd = (int[][])((Object[]) key)[1]; // extract decryption round keys
int ROUNDS = Kd.length - 1;
int[] Kdr = Kd[0];
-
// ciphertext to ints + key
- int t0 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Kdr[0];
- int t1 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Kdr[1];
- int t2 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Kdr[2];
- int t3 = (in[i++] << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ Kdr[3];
+ int t0 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Kdr[0];
+ int t1 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Kdr[1];
+ int t2 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Kdr[2];
+ int t3 = (in[i++] << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ Kdr[3];
int a0, a1, a2, a3;
- for (int r = 1; r < ROUNDS; r++)
- { // apply round transforms
+ for (int r = 1; r < ROUNDS; r++) // apply round transforms
+ {
Kdr = Kd[r];
- a0 = (T5[(t0 >>> 24)] ^ T6[(t3 >>> 16) & 0xFF] ^ T7[(t2 >>> 8) & 0xFF] ^ T8[t1 & 0xFF])
- ^ Kdr[0];
- a1 = (T5[(t1 >>> 24)] ^ T6[(t0 >>> 16) & 0xFF] ^ T7[(t3 >>> 8) & 0xFF] ^ T8[t2 & 0xFF])
- ^ Kdr[1];
- a2 = (T5[(t2 >>> 24)] ^ T6[(t1 >>> 16) & 0xFF] ^ T7[(t0 >>> 8) & 0xFF] ^ T8[t3 & 0xFF])
- ^ Kdr[2];
- a3 = (T5[(t3 >>> 24)] ^ T6[(t2 >>> 16) & 0xFF] ^ T7[(t1 >>> 8) & 0xFF] ^ T8[t0 & 0xFF])
- ^ Kdr[3];
+ a0 = (T5[(t0 >>> 24) ]
+ ^ T6[(t3 >>> 16) & 0xFF]
+ ^ T7[(t2 >>> 8) & 0xFF]
+ ^ T8[ t1 & 0xFF]) ^ Kdr[0];
+ a1 = (T5[(t1 >>> 24) ]
+ ^ T6[(t0 >>> 16) & 0xFF]
+ ^ T7[(t3 >>> 8) & 0xFF]
+ ^ T8[ t2 & 0xFF]) ^ Kdr[1];
+ a2 = (T5[(t2 >>> 24) ]
+ ^ T6[(t1 >>> 16) & 0xFF]
+ ^ T7[(t0 >>> 8) & 0xFF]
+ ^ T8[ t3 & 0xFF]) ^ Kdr[2];
+ a3 = (T5[(t3 >>> 24) ]
+ ^ T6[(t2 >>> 16) & 0xFF]
+ ^ T7[(t1 >>> 8) & 0xFF]
+ ^ T8[ t0 & 0xFF]) ^ Kdr[3];
t0 = a0;
t1 = a1;
t2 = a2;
t3 = a3;
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT" + r + "=" + Util.toString(t0)
- + Util.toString(t1) + Util.toString(t2)
- + Util.toString(t3));
- }
+ if (Configuration.DEBUG)
+ log.fine("PT" + r + "=" + Util.toString(t0) + Util.toString(t1)
+ + Util.toString(t2) + Util.toString(t3));
}
-
// last round is special
Kdr = Kd[ROUNDS];
int tt = Kdr[0];
- out[j++] = (byte) (Si[(t0 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (Si[(t3 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (Si[(t2 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (Si[t1 & 0xFF] ^ tt);
+ out[j++] = (byte)(Si[(t0 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(Si[(t3 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(Si[(t2 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(Si[ t1 & 0xFF] ^ tt );
tt = Kdr[1];
- out[j++] = (byte) (Si[(t1 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (Si[(t0 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (Si[(t3 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (Si[t2 & 0xFF] ^ tt);
+ out[j++] = (byte)(Si[(t1 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(Si[(t0 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(Si[(t3 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(Si[ t2 & 0xFF] ^ tt );
tt = Kdr[2];
- out[j++] = (byte) (Si[(t2 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (Si[(t1 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (Si[(t0 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (Si[t3 & 0xFF] ^ tt);
+ out[j++] = (byte)(Si[(t2 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(Si[(t1 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(Si[(t0 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(Si[ t3 & 0xFF] ^ tt );
tt = Kdr[3];
- out[j++] = (byte) (Si[(t3 >>> 24)] ^ (tt >>> 24));
- out[j++] = (byte) (Si[(t2 >>> 16) & 0xFF] ^ (tt >>> 16));
- out[j++] = (byte) (Si[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
- out[j++] = (byte) (Si[t0 & 0xFF] ^ tt);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT=" + Util.toString(out, j - 15, 16));
- System.out.println();
- }
+ out[j++] = (byte)(Si[(t3 >>> 24) ] ^ (tt >>> 24));
+ out[j++] = (byte)(Si[(t2 >>> 16) & 0xFF] ^ (tt >>> 16));
+ out[j++] = (byte)(Si[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
+ out[j++] = (byte)(Si[ t0 & 0xFF] ^ tt );
+ if (Configuration.DEBUG)
+ log.fine("PT=" + Util.toString(out, j - 16, 16));
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Rijndael result = new Rijndael();
@@ -688,14 +568,12 @@ public final class Rijndael extends BaseCipher
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(128 / 8));
- al.add(new Integer(192 / 8));
- al.add(new Integer(256 / 8));
+ al.add(Integer.valueOf(128 / 8));
+ al.add(Integer.valueOf(192 / 8));
+ al.add(Integer.valueOf(256 / 8));
return Collections.unmodifiableList(al).iterator();
}
@@ -703,9 +581,9 @@ public final class Rijndael extends BaseCipher
public Iterator keySizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(128 / 8));
- al.add(new Integer(192 / 8));
- al.add(new Integer(256 / 8));
+ al.add(Integer.valueOf(128 / 8));
+ al.add(Integer.valueOf(192 / 8));
+ al.add(Integer.valueOf(256 / 8));
return Collections.unmodifiableList(al).iterator();
}
@@ -713,7 +591,7 @@ public final class Rijndael extends BaseCipher
/**
* Expands a user-supplied key material into a session key for a designated
* <i>block size</i>.
- *
+ *
* @param k the 128/192/256-bit user-key to use.
* @param bs the block size in bytes of this Rijndael.
* @return an Object encapsulating the session key.
@@ -723,18 +601,11 @@ public final class Rijndael extends BaseCipher
public Object makeKey(byte[] k, int bs) throws InvalidKeyException
{
if (k == null)
- {
- throw new InvalidKeyException("Empty key");
- }
- if (!(k.length == 16 || k.length == 24 || k.length == 32))
- {
- throw new InvalidKeyException("Incorrect key length");
- }
- if (!(bs == 16 || bs == 24 || bs == 32))
- {
- throw new IllegalArgumentException();
- }
-
+ throw new InvalidKeyException("Empty key");
+ if (! (k.length == 16 || k.length == 24 || k.length == 32))
+ throw new InvalidKeyException("Incorrect key length");
+ if (! (bs == 16 || bs == 24 || bs == 32))
+ throw new IllegalArgumentException();
int ROUNDS = getRounds(k.length, bs);
int BC = bs / 4;
int[][] Ke = new int[ROUNDS + 1][BC]; // encryption round keys
@@ -743,13 +614,12 @@ public final class Rijndael extends BaseCipher
int KC = k.length / 4;
int[] tk = new int[KC];
int i, j;
-
// copy user material bytes into temporary ints
for (i = 0, j = 0; i < KC;)
- {
- tk[i++] = k[j++] << 24 | (k[j++] & 0xFF) << 16 | (k[j++] & 0xFF) << 8
- | (k[j++] & 0xFF);
- }
+ tk[i++] = k[j++] << 24
+ | (k[j++] & 0xFF) << 16
+ | (k[j++] & 0xFF) << 8
+ | (k[j++] & 0xFF);
// copy values into round key arrays
int t = 0;
for (j = 0; (j < KC) && (t < ROUND_KEY_COUNT); j++, t++)
@@ -763,31 +633,23 @@ public final class Rijndael extends BaseCipher
// extrapolate using phi (the round key evolution function)
tt = tk[KC - 1];
tk[0] ^= (S[(tt >>> 16) & 0xFF] & 0xFF) << 24
- ^ (S[(tt >>> 8) & 0xFF] & 0xFF) << 16
- ^ (S[tt & 0xFF] & 0xFF) << 8 ^ (S[(tt >>> 24)] & 0xFF)
- ^ rcon[rconpointer++] << 24;
+ ^ (S[(tt >>> 8) & 0xFF] & 0xFF) << 16
+ ^ (S[ tt & 0xFF] & 0xFF) << 8
+ ^ (S[(tt >>> 24) ] & 0xFF) ^ rcon[rconpointer++] << 24;
if (KC != 8)
- {
- for (i = 1, j = 0; i < KC;)
- {
- tk[i++] ^= tk[j++];
- }
- }
+ for (i = 1, j = 0; i < KC;)
+ tk[i++] ^= tk[j++];
else
{
for (i = 1, j = 0; i < KC / 2;)
- {
- tk[i++] ^= tk[j++];
- }
+ tk[i++] ^= tk[j++];
tt = tk[KC / 2 - 1];
- tk[KC / 2] ^= (S[tt & 0xFF] & 0xFF)
- ^ (S[(tt >>> 8) & 0xFF] & 0xFF) << 8
- ^ (S[(tt >>> 16) & 0xFF] & 0xFF) << 16
- ^ S[(tt >>> 24) & 0xFF] << 24;
+ tk[KC / 2] ^= (S[ tt & 0xFF] & 0xFF)
+ ^ (S[(tt >>> 8) & 0xFF] & 0xFF) << 8
+ ^ (S[(tt >>> 16) & 0xFF] & 0xFF) << 16
+ ^ S[(tt >>> 24) & 0xFF] << 24;
for (j = KC / 2, i = j + 1; i < KC;)
- {
- tk[i++] ^= tk[j++];
- }
+ tk[i++] ^= tk[j++];
}
// copy values into round key arrays
for (j = 0; (j < KC) && (t < ROUND_KEY_COUNT); j++, t++)
@@ -796,51 +658,36 @@ public final class Rijndael extends BaseCipher
Kd[ROUNDS - (t / BC)][t % BC] = tk[j];
}
}
- for (int r = 1; r < ROUNDS; r++)
- { // inverse MixColumn where needed
- for (j = 0; j < BC; j++)
- {
- tt = Kd[r][j];
- Kd[r][j] = U1[(tt >>> 24)] ^ U2[(tt >>> 16) & 0xFF]
- ^ U3[(tt >>> 8) & 0xFF] ^ U4[tt & 0xFF];
- }
- }
-
+ for (int r = 1; r < ROUNDS; r++) // inverse MixColumn where needed
+ for (j = 0; j < BC; j++)
+ {
+ tt = Kd[r][j];
+ Kd[r][j] = U1[(tt >>> 24) ]
+ ^ U2[(tt >>> 16) & 0xFF]
+ ^ U3[(tt >>> 8) & 0xFF]
+ ^ U4[ tt & 0xFF];
+ }
return new Object[] { Ke, Kd };
}
public void encrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
- if (!(bs == 16 || bs == 24 || bs == 32))
- {
- throw new IllegalArgumentException();
- }
-
+ if (! (bs == 16 || bs == 24 || bs == 32))
+ throw new IllegalArgumentException();
if (bs == DEFAULT_BLOCK_SIZE)
- {
- aesEncrypt(in, i, out, j, k);
- }
+ aesEncrypt(in, i, out, j, k);
else
- {
- rijndaelEncrypt(in, i, out, j, k, bs);
- }
+ rijndaelEncrypt(in, i, out, j, k, bs);
}
public void decrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
- if (!(bs == 16 || bs == 24 || bs == 32))
- {
- throw new IllegalArgumentException();
- }
-
+ if (! (bs == 16 || bs == 24 || bs == 32))
+ throw new IllegalArgumentException();
if (bs == DEFAULT_BLOCK_SIZE)
- {
- aesDecrypt(in, i, out, j, k);
- }
+ aesDecrypt(in, i, out, j, k);
else
- {
- rijndaelDecrypt(in, i, out, j, k, bs);
- }
+ rijndaelDecrypt(in, i, out, j, k, bs);
}
public boolean selfTest()
@@ -849,11 +696,9 @@ public final class Rijndael extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java b/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
index 2ed1e4b5593..636e311e7ee 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
@@ -47,78 +47,57 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * <p>Serpent is a 32-round substitution-permutation network block cipher,
+ * Serpent is a 32-round substitution-permutation network block cipher,
* operating on 128-bit blocks and accepting keys of 128, 192, and 256 bits in
* length. At each round the plaintext is XORed with a 128 bit portion of the
* session key -- a 4224 bit key computed from the input key -- then one of
* eight S-boxes are applied, and finally a simple linear transformation is
* done. Decryption does the exact same thing in reverse order, and using the
- * eight inverses of the S-boxes.</p>
- *
- * <p>Serpent was designed by Ross Anderson, Eli Biham, and Lars Knudsen as a
- * proposed cipher for the Advanced Encryption Standard.</p>
- *
- * <p>Serpent can be sped up greatly by replacing S-box substitution with a
- * sequence of binary operations, and the optimal implementation depends
- * upon finding the fastest sequence of binary operations that reproduce this
- * substitution. This implementation uses the S-boxes discovered by
- * <a href="http://www.ii.uib.no/~osvik/">Dag Arne Osvik</a>, which are
- * optimized for the Pentium family of processors.</p>
- *
- * <p>References:</p>
- *
+ * eight inverses of the S-boxes.
+ * <p>
+ * Serpent was designed by Ross Anderson, Eli Biham, and Lars Knudsen as a
+ * proposed cipher for the Advanced Encryption Standard.
+ * <p>
+ * Serpent can be sped up greatly by replacing S-box substitution with a
+ * sequence of binary operations, and the optimal implementation depends upon
+ * finding the fastest sequence of binary operations that reproduce this
+ * substitution. This implementation uses the S-boxes discovered by <a
+ * href="http://www.ii.uib.no/~osvik/">Dag Arne Osvik</a>, which are optimized
+ * for the Pentium family of processors.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.cl.cam.ac.uk/~rja14/serpent.html">Serpent: A
- * Candidate Block Cipher for the Advanced Encryption Standard.</a></li>
+ * <li><a href="http://www.cl.cam.ac.uk/~rja14/serpent.html">Serpent: A
+ * Candidate Block Cipher for the Advanced Encryption Standard.</a></li>
* </ol>
*/
-public class Serpent extends BaseCipher
+public class Serpent
+ extends BaseCipher
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int DEFAULT_KEY_SIZE = 16;
-
private static final int DEFAULT_BLOCK_SIZE = 16;
-
private static final int ROUNDS = 32;
-
/** The fractional part of the golden ratio, (sqrt(5)+1)/2. */
private static final int PHI = 0x9e3779b9;
-
/**
- * KAT vector (from ecb_vk):
- * I=9
+ * KAT vector (from ecb_vk): I=9
* KEY=008000000000000000000000000000000000000000000000
* CT=5587B5BCB9EE5A28BA2BACC418005240
*/
- private static final byte[] KAT_KEY = Util.toReversedBytesFromString("008000000000000000000000000000000000000000000000");
-
- private static final byte[] KAT_CT = Util.toReversedBytesFromString("5587B5BCB9EE5A28BA2BACC418005240");
-
+ private static final byte[] KAT_KEY = Util.toReversedBytesFromString(
+ "008000000000000000000000000000000000000000000000");
+ private static final byte[] KAT_CT =
+ Util.toReversedBytesFromString("5587B5BCB9EE5A28BA2BACC418005240");
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
private int x0, x1, x2, x3, x4;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial zero-argument constructor. */
public Serpent()
{
super(Registry.SERPENT_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Serpent result = new Serpent();
@@ -126,20 +105,17 @@ public class Serpent extends BaseCipher
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
- return Collections.singleton(new Integer(DEFAULT_BLOCK_SIZE)).iterator();
+ return Collections.singleton(Integer.valueOf(DEFAULT_BLOCK_SIZE)).iterator();
}
public Iterator keySizes()
{
ArrayList keySizes = new ArrayList();
- keySizes.add(new Integer(16));
- keySizes.add(new Integer(24));
- keySizes.add(new Integer(32));
-
+ keySizes.add(Integer.valueOf(16));
+ keySizes.add(Integer.valueOf(24));
+ keySizes.add(Integer.valueOf(32));
return Collections.unmodifiableList(keySizes).iterator();
}
@@ -148,24 +124,19 @@ public class Serpent extends BaseCipher
// Not strictly true, but here to conform with the AES proposal.
// This restriction can be removed if deemed necessary.
if (kb.length != 16 && kb.length != 24 && kb.length != 32)
- {
- throw new InvalidKeyException("Key length is not 16, 24, or 32 bytes");
- }
+ throw new InvalidKeyException("Key length is not 16, 24, or 32 bytes");
Key key = new Key();
-
// Here w is our "pre-key".
int[] w = new int[4 * (ROUNDS + 1)];
int i, j;
for (i = 0, j = 0; i < 8 && j < kb.length; i++)
- {
- w[i] = (kb[j++] & 0xff) | (kb[j++] & 0xff) << 8
- | (kb[j++] & 0xff) << 16 | (kb[j++] & 0xff) << 24;
- }
+ w[i] = (kb[j++] & 0xff)
+ | (kb[j++] & 0xff) << 8
+ | (kb[j++] & 0xff) << 16
+ | (kb[j++] & 0xff) << 24;
// Pad key if < 256 bits.
if (i != 8)
- {
- w[i] = 1;
- }
+ w[i] = 1;
// Transform using w_i-8 ... w_i-1
for (i = 8, j = 0; i < 16; i++)
{
@@ -174,16 +145,13 @@ public class Serpent extends BaseCipher
}
// Translate by 8.
for (i = 0; i < 8; i++)
- {
- w[i] = w[i + 8];
- }
+ w[i] = w[i + 8];
// Transform the rest of the key.
for (; i < w.length; i++)
{
int t = w[i - 8] ^ w[i - 5] ^ w[i - 3] ^ w[i - 1] ^ PHI ^ i;
w[i] = t << 11 | t >>> 21;
}
-
// After these s-boxes the pre-key (w, above) will become the
// session key (key, below).
sbox3(w[0], w[1], w[2], w[3]);
@@ -351,7 +319,6 @@ public class Serpent extends BaseCipher
key.k129 = x1;
key.k130 = x2;
key.k131 = x3;
-
return key;
}
@@ -359,16 +326,22 @@ public class Serpent extends BaseCipher
Object K, int bs)
{
Key key = (Key) K;
-
- x0 = (in[i] & 0xff) | (in[i + 1] & 0xff) << 8 | (in[i + 2] & 0xff) << 16
- | (in[i + 3] & 0xff) << 24;
- x1 = (in[i + 4] & 0xff) | (in[i + 5] & 0xff) << 8
- | (in[i + 6] & 0xff) << 16 | (in[i + 7] & 0xff) << 24;
- x2 = (in[i + 8] & 0xff) | (in[i + 9] & 0xff) << 8
- | (in[i + 10] & 0xff) << 16 | (in[i + 11] & 0xff) << 24;
- x3 = (in[i + 12] & 0xff) | (in[i + 13] & 0xff) << 8
- | (in[i + 14] & 0xff) << 16 | (in[i + 15] & 0xff) << 24;
-
+ x0 = (in[i ] & 0xff)
+ | (in[i + 1] & 0xff) << 8
+ | (in[i + 2] & 0xff) << 16
+ | (in[i + 3] & 0xff) << 24;
+ x1 = (in[i + 4] & 0xff)
+ | (in[i + 5] & 0xff) << 8
+ | (in[i + 6] & 0xff) << 16
+ | (in[i + 7] & 0xff) << 24;
+ x2 = (in[i + 8] & 0xff)
+ | (in[i + 9] & 0xff) << 8
+ | (in[i + 10] & 0xff) << 16
+ | (in[i + 11] & 0xff) << 24;
+ x3 = (in[i + 12] & 0xff)
+ | (in[i + 13] & 0xff) << 8
+ | (in[i + 14] & 0xff) << 16
+ | (in[i + 15] & 0xff) << 24;
x0 ^= key.k0;
x1 ^= key.k1;
x2 ^= key.k2;
@@ -412,7 +385,6 @@ public class Serpent extends BaseCipher
x0 = x3;
x3 = x2;
x2 = x4;
-
x0 ^= key.k32;
x1 ^= key.k33;
x2 ^= key.k34;
@@ -456,7 +428,6 @@ public class Serpent extends BaseCipher
x0 = x3;
x3 = x2;
x2 = x4;
-
x0 ^= key.k64;
x1 ^= key.k65;
x2 ^= key.k66;
@@ -500,7 +471,6 @@ public class Serpent extends BaseCipher
x0 = x3;
x3 = x2;
x2 = x4;
-
x0 ^= key.k96;
x1 ^= key.k97;
x2 ^= key.k98;
@@ -548,39 +518,44 @@ public class Serpent extends BaseCipher
x1 ^= key.k129;
x2 ^= key.k130;
x3 ^= key.k131;
-
- out[o] = (byte) x0;
- out[o + 1] = (byte) (x0 >>> 8);
- out[o + 2] = (byte) (x0 >>> 16);
- out[o + 3] = (byte) (x0 >>> 24);
- out[o + 4] = (byte) x1;
- out[o + 5] = (byte) (x1 >>> 8);
- out[o + 6] = (byte) (x1 >>> 16);
- out[o + 7] = (byte) (x1 >>> 24);
- out[o + 8] = (byte) x2;
- out[o + 9] = (byte) (x2 >>> 8);
- out[o + 10] = (byte) (x2 >>> 16);
- out[o + 11] = (byte) (x2 >>> 24);
+ out[o ] = (byte) x0;
+ out[o + 1] = (byte)(x0 >>> 8);
+ out[o + 2] = (byte)(x0 >>> 16);
+ out[o + 3] = (byte)(x0 >>> 24);
+ out[o + 4] = (byte) x1;
+ out[o + 5] = (byte)(x1 >>> 8);
+ out[o + 6] = (byte)(x1 >>> 16);
+ out[o + 7] = (byte)(x1 >>> 24);
+ out[o + 8] = (byte) x2;
+ out[o + 9] = (byte)(x2 >>> 8);
+ out[o + 10] = (byte)(x2 >>> 16);
+ out[o + 11] = (byte)(x2 >>> 24);
out[o + 12] = (byte) x3;
- out[o + 13] = (byte) (x3 >>> 8);
- out[o + 14] = (byte) (x3 >>> 16);
- out[o + 15] = (byte) (x3 >>> 24);
+ out[o + 13] = (byte)(x3 >>> 8);
+ out[o + 14] = (byte)(x3 >>> 16);
+ out[o + 15] = (byte)(x3 >>> 24);
}
public synchronized void decrypt(byte[] in, int i, byte[] out, int o,
Object K, int bs)
{
Key key = (Key) K;
-
- x0 = (in[i] & 0xff) | (in[i + 1] & 0xff) << 8 | (in[i + 2] & 0xff) << 16
- | (in[i + 3] & 0xff) << 24;
- x1 = (in[i + 4] & 0xff) | (in[i + 5] & 0xff) << 8
- | (in[i + 6] & 0xff) << 16 | (in[i + 7] & 0xff) << 24;
- x2 = (in[i + 8] & 0xff) | (in[i + 9] & 0xff) << 8
- | (in[i + 10] & 0xff) << 16 | (in[i + 11] & 0xff) << 24;
- x3 = (in[i + 12] & 0xff) | (in[i + 13] & 0xff) << 8
- | (in[i + 14] & 0xff) << 16 | (in[i + 15] & 0xff) << 24;
-
+ x0 = (in[i ] & 0xff)
+ | (in[i + 1] & 0xff) << 8
+ | (in[i + 2] & 0xff) << 16
+ | (in[i + 3] & 0xff) << 24;
+ x1 = (in[i + 4] & 0xff)
+ | (in[i + 5] & 0xff) << 8
+ | (in[i + 6] & 0xff) << 16
+ | (in[i + 7] & 0xff) << 24;
+ x2 = (in[i + 8] & 0xff)
+ | (in[i + 9] & 0xff) << 8
+ | (in[i + 10] & 0xff) << 16
+ | (in[i + 11] & 0xff) << 24;
+ x3 = (in[i + 12] & 0xff)
+ | (in[i + 13] & 0xff) << 8
+ | (in[i + 14] & 0xff) << 16
+ | (in[i + 15] & 0xff) << 24;
x0 ^= key.k128;
x1 ^= key.k129;
x2 ^= key.k130;
@@ -629,7 +604,6 @@ public class Serpent extends BaseCipher
x1 = x3;
x3 = x4;
x4 = x2;
-
x3 ^= key.k92;
x0 ^= key.k93;
x1 ^= key.k94;
@@ -673,7 +647,6 @@ public class Serpent extends BaseCipher
x1 = x3;
x3 = x4;
x4 = x2;
-
x3 ^= key.k60;
x0 ^= key.k61;
x1 ^= key.k62;
@@ -717,7 +690,6 @@ public class Serpent extends BaseCipher
x1 = x3;
x3 = x4;
x4 = x2;
-
x3 ^= key.k28;
x0 ^= key.k29;
x1 ^= key.k30;
@@ -756,28 +728,26 @@ public class Serpent extends BaseCipher
x2 = x1;
x1 = x3;
x3 = x4;
-
x0 ^= key.k0;
x1 ^= key.k1;
x2 ^= key.k2;
x3 ^= key.k3;
-
- out[o] = (byte) x0;
- out[o + 1] = (byte) (x0 >>> 8);
- out[o + 2] = (byte) (x0 >>> 16);
- out[o + 3] = (byte) (x0 >>> 24);
- out[o + 4] = (byte) x1;
- out[o + 5] = (byte) (x1 >>> 8);
- out[o + 6] = (byte) (x1 >>> 16);
- out[o + 7] = (byte) (x1 >>> 24);
- out[o + 8] = (byte) x2;
- out[o + 9] = (byte) (x2 >>> 8);
- out[o + 10] = (byte) (x2 >>> 16);
- out[o + 11] = (byte) (x2 >>> 24);
+ out[o ] = (byte) x0;
+ out[o + 1] = (byte)(x0 >>> 8);
+ out[o + 2] = (byte)(x0 >>> 16);
+ out[o + 3] = (byte)(x0 >>> 24);
+ out[o + 4] = (byte) x1;
+ out[o + 5] = (byte)(x1 >>> 8);
+ out[o + 6] = (byte)(x1 >>> 16);
+ out[o + 7] = (byte)(x1 >>> 24);
+ out[o + 8] = (byte) x2;
+ out[o + 9] = (byte)(x2 >>> 8);
+ out[o + 10] = (byte)(x2 >>> 16);
+ out[o + 11] = (byte)(x2 >>> 24);
out[o + 12] = (byte) x3;
- out[o + 13] = (byte) (x3 >>> 8);
- out[o + 14] = (byte) (x3 >>> 16);
- out[o + 15] = (byte) (x3 >>> 24);
+ out[o + 13] = (byte)(x3 >>> 8);
+ out[o + 14] = (byte)(x3 >>> 16);
+ out[o + 15] = (byte)(x3 >>> 24);
}
public boolean selfTest()
@@ -786,19 +756,14 @@ public class Serpent extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
- // Own methods. ----------------------------------------------------------
-
// These first few S-boxes operate directly on the "registers",
// x0..x4, and perform the linear transform.
-
private void sbox0()
{
x3 ^= x0;
@@ -1492,8 +1457,6 @@ public class Serpent extends BaseCipher
x2 ^= x1;
}
- // These S-Box functions are used in the key setup.
-
/** S-Box 0. */
private void sbox0(int r0, int r1, int r2, int r3)
{
@@ -1654,15 +1617,9 @@ public class Serpent extends BaseCipher
x3 = r0;
}
- // Inner classes.
- // -----------------------------------------------------------------------
-
- private class Key implements Cloneable
+ private class Key
+ implements Cloneable
{
-
- // Constants and variables.
- // --------------------------------------------------------------------
-
int k0, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15,
k16, k17, k18, k19, k20, k21, k22, k23, k24, k25, k26, k27, k28, k29,
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k40, k41, k42, k43,
@@ -1674,9 +1631,6 @@ public class Serpent extends BaseCipher
k112, k113, k114, k115, k116, k117, k118, k119, k120, k121, k122, k123,
k124, k125, k126, k127, k128, k129, k130, k131;
- // Constructors.
- // --------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
Key()
{
@@ -1819,12 +1773,9 @@ public class Serpent extends BaseCipher
this.k131 = that.k131;
}
- // Cloneable interface implementation.
- // --------------------------------------------------------------------
-
public Object clone()
{
return new Key(this);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Square.java b/libjava/classpath/gnu/javax/crypto/cipher/Square.java
index a73116eb422..af738da043a 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Square.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Square.java
@@ -47,145 +47,74 @@ import java.util.Collections;
import java.util.Iterator;
/**
- * <p>Square is a 128-bit key, 128-bit block cipher algorithm developed by Joan
- * Daemen, Lars Knudsen and Vincent Rijmen.</p>
- *
- * <p>References:</p>
- *
+ * Square is a 128-bit key, 128-bit block cipher algorithm developed by Joan
+ * Daemen, Lars Knudsen and Vincent Rijmen.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.esat.kuleuven.ac.be/~rijmen/square/">The block
- * cipher Square</a>.<br>
- * <a href="mailto:daemen.j@protonworld.com">Joan Daemen</a>,
- * <a href="mailto:lars.knudsen@esat.kuleuven.ac.be">Lars Knudsen</a> and
- * <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
+ * <li><a href="http://www.esat.kuleuven.ac.be/~rijmen/square/">The block
+ * cipher Square</a>.<br>
+ * <a href="mailto:daemen.j@protonworld.com">Joan Daemen</a>, <a
+ * href="mailto:lars.knudsen@esat.kuleuven.ac.be">Lars Knudsen</a> and <a
+ * href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
* </ol>
*/
-public final class Square extends BaseCipher
+public final class Square
+ extends BaseCipher
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 16; // in bytes
-
private static final int ROUNDS = 8;
-
private static final int ROOT = 0x1F5; // for generating GF(2**8)
-
private static final int[] OFFSET = new int[ROUNDS];
-
- private static final String Sdata = "\uB1CE\uC395\u5AAD\uE702\u4D44\uFB91\u0C87\uA150"
- + "\uCB67\u54DD\u468F\uE14E\uF0FD\uFCEB\uF9C4\u1A6E"
- + "\u5EF5\uCC8D\u1C56\u43FE\u0761\uF875\u59FF\u0322"
- + "\u8AD1\u13EE\u8800\u0E34\u1580\u94E3\uEDB5\u5323"
- + "\u4B47\u17A7\u9035\uABD8\uB8DF\u4F57\u9A92\uDB1B"
- + "\u3CC8\u9904\u8EE0\uD77D\u85BB\u402C\u3A45\uF142"
- + "\u6520\u4118\u7225\u9370\u3605\uF20B\uA379\uEC08"
- + "\u2731\u32B6\u7CB0\u0A73\u5B7B\uB781\uD20D\u6A26"
- + "\u9E58\u9C83\u74B3\uAC30\u7A69\u770F\uAE21\uDED0"
- + "\u2E97\u10A4\u98A8\uD468\u2D62\u296D\u1649\u76C7"
- + "\uE8C1\u9637\uE5CA\uF4E9\u6312\uC2A6\u14BC\uD328"
- + "\uAF2F\uE624\u52C6\uA009\uBD8C\uCF5D\u115F\u01C5"
- + "\u9F3D\uA29B\uC93B\uBE51\u191F\u3F5C\uB2EF\u4ACD"
- + "\uBFBA\u6F64\uD9F3\u3EB4\uAADC\uD506\uC07E\uF666"
- + "\u6C84\u7138\uB91D\u7F9D\u488B\u2ADA\uA533\u8239"
- + "\uD678\u86FA\uE42B\uA91E\u8960\u6BEA\u554C\uF7E2";
-
+ private static final String Sdata =
+ "\uB1CE\uC395\u5AAD\uE702\u4D44\uFB91\u0C87\uA150"
+ + "\uCB67\u54DD\u468F\uE14E\uF0FD\uFCEB\uF9C4\u1A6E"
+ + "\u5EF5\uCC8D\u1C56\u43FE\u0761\uF875\u59FF\u0322"
+ + "\u8AD1\u13EE\u8800\u0E34\u1580\u94E3\uEDB5\u5323"
+ + "\u4B47\u17A7\u9035\uABD8\uB8DF\u4F57\u9A92\uDB1B"
+ + "\u3CC8\u9904\u8EE0\uD77D\u85BB\u402C\u3A45\uF142"
+ + "\u6520\u4118\u7225\u9370\u3605\uF20B\uA379\uEC08"
+ + "\u2731\u32B6\u7CB0\u0A73\u5B7B\uB781\uD20D\u6A26"
+ + "\u9E58\u9C83\u74B3\uAC30\u7A69\u770F\uAE21\uDED0"
+ + "\u2E97\u10A4\u98A8\uD468\u2D62\u296D\u1649\u76C7"
+ + "\uE8C1\u9637\uE5CA\uF4E9\u6312\uC2A6\u14BC\uD328"
+ + "\uAF2F\uE624\u52C6\uA009\uBD8C\uCF5D\u115F\u01C5"
+ + "\u9F3D\uA29B\uC93B\uBE51\u191F\u3F5C\uB2EF\u4ACD"
+ + "\uBFBA\u6F64\uD9F3\u3EB4\uAADC\uD506\uC07E\uF666"
+ + "\u6C84\u7138\uB91D\u7F9D\u488B\u2ADA\uA533\u8239"
+ + "\uD678\u86FA\uE42B\uA91E\u8960\u6BEA\u554C\uF7E2";
/** Substitution boxes for encryption and decryption. */
private static final byte[] Se = new byte[256];
-
private static final byte[] Sd = new byte[256];
-
/** Transposition boxes for encryption and decryption. */
private static final int[] Te = new int[256];
-
private static final int[] Td = new int[256];
-
/**
- * KAT vector (from ecb_vk):
- * I=87
- * KEY=00000000000000000000020000000000
+ * KAT vector (from ecb_vk): I=87 KEY=00000000000000000000020000000000
* CT=A9DF031B4E25E89F527EFFF89CB0BEBA
*/
- private static final byte[] KAT_KEY = Util.toBytesFromString("00000000000000000000020000000000");
-
- private static final byte[] KAT_CT = Util.toBytesFromString("A9DF031B4E25E89F527EFFF89CB0BEBA");
-
+ private static final byte[] KAT_KEY =
+ Util.toBytesFromString("00000000000000000000020000000000");
+ private static final byte[] KAT_CT =
+ Util.toBytesFromString("A9DF031B4E25E89F527EFFF89CB0BEBA");
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
- // Static code - to intialise lookup tables
- // -------------------------------------------------------------------------
-
static
{
int i, j;
- /*
- // Generate exp and log tables used in multiplication over GF(2 ** m)
- byte[] exp = new byte[256];
- byte[] log = new byte[256];
-
- exp[0] = 1;
- for (i = 1; i < 256; i++) {
- j = exp[i - 1] << 1;
- if ((j & 0x100) != 0) {
- j ^= ROOT; // reduce j (mod ROOT)
- }
-
- exp[i] = (byte) j;
- log[j & 0xFF] = (byte) i;
- }
-
- // Compute the substitution box Se[] and its inverse Sd[] based on
- // F(x) = x**{-1} plus affine transform of the output.
- Se[0] = 0;
- Se[1] = 1;
- for (i = 2; i < 256; i++) {
- Se[i] = exp[(255 - log[i]) & 0xFF];
- }
-
- // Let Se[i] be represented as an 8-row vector V over GF(2); the affine
- // transformation is A * V + T, where the rows of the 8 x 8 matrix A are
- // contained in trans[0]...trans[7] and the 8-row vector T is contained
- // in 0xB1.
- int[] trans = new int[] {0x01, 0x03, 0x05, 0x0F, 0x1F, 0x3D, 0x7B, 0xD6};
- int u, v;
- for (i = 0; i < 256; i++) {
- v = 0xB1; // affine part of the transform
- for (j = 0; j < 8; j++) {
- u = Se[i] & trans[j] & 0xFF; // column-wise mult. over GF(2)
- u ^= u >>> 4; // sum of all bits of u over GF(2)
- u ^= u >>> 2;
- u ^= u >>> 1;
- u &= 1;
- v ^= u << j; // row alignment of the result
- }
- Se[i] = (byte) v;
- Sd[v] = (byte) i; // inverse substitution box
- }
-
- System.out.println("Se="+Util.toUnicodeString(Se));
- System.out.println("Sd="+Util.toUnicodeString(Sd));
- */
- /**/
// re-construct Se box values
int limit = Sdata.length();
char c1;
for (i = 0, j = 0; i < limit; i++)
{
c1 = Sdata.charAt(i);
- Se[j++] = (byte) (c1 >>> 8);
+ Se[j++] = (byte)(c1 >>> 8);
Se[j++] = (byte) c1;
}
-
// compute Sd box values
for (i = 0; i < 256; i++)
- {
- Sd[Se[i] & 0xFF] = (byte) i;
- }
-
+ Sd[Se[i] & 0xFF] = (byte) i;
// generate OFFSET values
OFFSET[0] = 1;
for (i = 1; i < ROUNDS; i++)
@@ -193,9 +122,7 @@ public final class Square extends BaseCipher
OFFSET[i] = mul(OFFSET[i - 1], 2);
OFFSET[i - 1] <<= 24;
}
-
OFFSET[ROUNDS - 1] <<= 24;
-
// generate Te and Td boxes if we're not reading their values
// Notes:
// (1) The function mul() computes the product of two elements of GF(2**8)
@@ -207,111 +134,122 @@ public final class Square extends BaseCipher
for (i = 0; i < 256; i++)
{
j = Se[i] & 0xFF;
- Te[i] = (Se[i & 3] == 0) ? 0 : mul(j, 2) << 24 | j << 16 | j << 8
- | mul(j, 3);
-
+ Te[i] = (Se[i & 3] == 0) ? 0
+ : mul(j, 2) << 24
+ | j << 16
+ | j << 8
+ | mul(j, 3);
j = Sd[i] & 0xFF;
- Td[i] = (Sd[i & 3] == 0) ? 0 : mul(j, 14) << 24 | mul(j, 9) << 16
- | mul(j, 13) << 8 | mul(j, 11);
+ Td[i] = (Sd[i & 3] == 0) ? 0
+ : mul(j, 14) << 24
+ | mul(j, 9) << 16
+ | mul(j, 13) << 8
+ | mul(j, 11);
}
- /**/
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Square()
{
super(Registry.SQUARE_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
private static void square(byte[] in, int i, byte[] out, int j, int[][] K,
int[] T, byte[] S)
{
- int a = ((in[i++]) << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ K[0][0];
- int b = ((in[i++]) << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ K[0][1];
- int c = ((in[i++]) << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i++] & 0xFF))
- ^ K[0][2];
- int d = ((in[i++]) << 24 | (in[i++] & 0xFF) << 16 | (in[i++] & 0xFF) << 8 | (in[i] & 0xFF))
- ^ K[0][3];
-
+ int a = ((in[i++]) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ K[0][0];
+ int b = ((in[i++]) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ K[0][1];
+ int c = ((in[i++]) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i++] & 0xFF) ) ^ K[0][2];
+ int d = ((in[i++]) << 24
+ | (in[i++] & 0xFF) << 16
+ | (in[i++] & 0xFF) << 8
+ | (in[i ] & 0xFF) ) ^ K[0][3];
int r, aa, bb, cc, dd;
for (r = 1; r < ROUNDS; r++)
{ // R - 1 full rounds
- aa = T[(a >>> 24)] ^ rot32R(T[(b >>> 24)], 8)
- ^ rot32R(T[(c >>> 24)], 16) ^ rot32R(T[(d >>> 24)], 24) ^ K[r][0];
- bb = T[(a >>> 16) & 0xFF] ^ rot32R(T[(b >>> 16) & 0xFF], 8)
- ^ rot32R(T[(c >>> 16) & 0xFF], 16)
- ^ rot32R(T[(d >>> 16) & 0xFF], 24) ^ K[r][1];
- cc = T[(a >>> 8) & 0xFF] ^ rot32R(T[(b >>> 8) & 0xFF], 8)
- ^ rot32R(T[(c >>> 8) & 0xFF], 16)
- ^ rot32R(T[(d >>> 8) & 0xFF], 24) ^ K[r][2];
- dd = T[a & 0xFF] ^ rot32R(T[b & 0xFF], 8) ^ rot32R(T[c & 0xFF], 16)
- ^ rot32R(T[d & 0xFF], 24) ^ K[r][3];
-
+ aa = T[(a >>> 24) ]
+ ^ rot32R(T[(b >>> 24) ], 8)
+ ^ rot32R(T[(c >>> 24) ], 16)
+ ^ rot32R(T[(d >>> 24) ], 24) ^ K[r][0];
+ bb = T[(a >>> 16) & 0xFF]
+ ^ rot32R(T[(b >>> 16) & 0xFF], 8)
+ ^ rot32R(T[(c >>> 16) & 0xFF], 16)
+ ^ rot32R(T[(d >>> 16) & 0xFF], 24) ^ K[r][1];
+ cc = T[(a >>> 8) & 0xFF]
+ ^ rot32R(T[(b >>> 8) & 0xFF], 8)
+ ^ rot32R(T[(c >>> 8) & 0xFF], 16)
+ ^ rot32R(T[(d >>> 8) & 0xFF], 24) ^ K[r][2];
+ dd = T[ a & 0xFF]
+ ^ rot32R(T[ b & 0xFF], 8)
+ ^ rot32R(T[ c & 0xFF], 16)
+ ^ rot32R(T[ d & 0xFF], 24) ^ K[r][3];
a = aa;
b = bb;
c = cc;
d = dd;
}
-
// last round (diffusion becomes only transposition)
- aa = ((S[(a >>> 24)]) << 24 | (S[(b >>> 24)] & 0xFF) << 16
- | (S[(c >>> 24)] & 0xFF) << 8 | (S[(d >>> 24)] & 0xFF))
- ^ K[r][0];
- bb = ((S[(a >>> 16) & 0xFF]) << 24 | (S[(b >>> 16) & 0xFF] & 0xFF) << 16
- | (S[(c >>> 16) & 0xFF] & 0xFF) << 8 | (S[(d >>> 16) & 0xFF] & 0xFF))
- ^ K[r][1];
- cc = ((S[(a >>> 8) & 0xFF]) << 24 | (S[(b >>> 8) & 0xFF] & 0xFF) << 16
- | (S[(c >>> 8) & 0xFF] & 0xFF) << 8 | (S[(d >>> 8) & 0xFF] & 0xFF))
- ^ K[r][2];
- dd = ((S[a & 0xFF]) << 24 | (S[b & 0xFF] & 0xFF) << 16
- | (S[c & 0xFF] & 0xFF) << 8 | (S[d & 0xFF] & 0xFF))
- ^ K[r][3];
-
- out[j++] = (byte) (aa >>> 24);
- out[j++] = (byte) (aa >>> 16);
- out[j++] = (byte) (aa >>> 8);
+ aa = ((S[(a >>> 24) ] ) << 24
+ | (S[(b >>> 24) ] & 0xFF) << 16
+ | (S[(c >>> 24) ] & 0xFF) << 8
+ | (S[(d >>> 24) ] & 0xFF) ) ^ K[r][0];
+ bb = ((S[(a >>> 16) & 0xFF] ) << 24
+ | (S[(b >>> 16) & 0xFF] & 0xFF) << 16
+ | (S[(c >>> 16) & 0xFF] & 0xFF) << 8
+ | (S[(d >>> 16) & 0xFF] & 0xFF) ) ^ K[r][1];
+ cc = ((S[(a >>> 8) & 0xFF] ) << 24
+ | (S[(b >>> 8) & 0xFF] & 0xFF) << 16
+ | (S[(c >>> 8) & 0xFF] & 0xFF) << 8
+ | (S[(d >>> 8) & 0xFF] & 0xFF) ) ^ K[r][2];
+ dd = ((S[ a & 0xFF] ) << 24
+ | (S[ b & 0xFF] & 0xFF) << 16
+ | (S[ c & 0xFF] & 0xFF) << 8
+ | (S[ d & 0xFF] & 0xFF) ) ^ K[r][3];
+ out[j++] = (byte)(aa >>> 24);
+ out[j++] = (byte)(aa >>> 16);
+ out[j++] = (byte)(aa >>> 8);
out[j++] = (byte) aa;
- out[j++] = (byte) (bb >>> 24);
- out[j++] = (byte) (bb >>> 16);
- out[j++] = (byte) (bb >>> 8);
+ out[j++] = (byte)(bb >>> 24);
+ out[j++] = (byte)(bb >>> 16);
+ out[j++] = (byte)(bb >>> 8);
out[j++] = (byte) bb;
- out[j++] = (byte) (cc >>> 24);
- out[j++] = (byte) (cc >>> 16);
- out[j++] = (byte) (cc >>> 8);
+ out[j++] = (byte)(cc >>> 24);
+ out[j++] = (byte)(cc >>> 16);
+ out[j++] = (byte)(cc >>> 8);
out[j++] = (byte) cc;
- out[j++] = (byte) (dd >>> 24);
- out[j++] = (byte) (dd >>> 16);
- out[j++] = (byte) (dd >>> 8);
- out[j] = (byte) dd;
+ out[j++] = (byte)(dd >>> 24);
+ out[j++] = (byte)(dd >>> 16);
+ out[j++] = (byte)(dd >>> 8);
+ out[j ] = (byte) dd;
}
/**
- * <p>Applies the Theta function to an input <i>in</i> in order to produce in
- * <i>out</i> an internal session sub-key.</p>
- *
- * <p>Both <i>in</i> and <i>out</i> are arrays of four ints.</p>
- *
- * <p>Pseudo-code is:</p>
- *
+ * Applies the Theta function to an input <i>in</i> in order to produce in
+ * <i>out</i> an internal session sub-key.
+ * <p>
+ * Both <i>in</i> and <i>out</i> are arrays of four ints.
+ * <p>
+ * Pseudo-code is:
* <pre>
- * for (i = 0; i < 4; i++) {
- * out[i] = 0;
- * for (j = 0, n = 24; j < 4; j++, n -= 8) {
- * k = mul(in[i] >>> 24, G[0][j]) ^
- * mul(in[i] >>> 16, G[1][j]) ^
- * mul(in[i] >>> 8, G[2][j]) ^
- * mul(in[i] , G[3][j]);
- * out[i] ^= k << n;
+ * for (i = 0; i &lt; 4; i++)
+ * {
+ * out[i] = 0;
+ * for (j = 0, n = 24; j &lt; 4; j++, n -= 8)
+ * {
+ * k = mul(in[i] &gt;&gt;&gt; 24, G[0][j]) &circ; mul(in[i] &gt;&gt;&gt; 16, G[1][j])
+ * &circ; mul(in[i] &gt;&gt;&gt; 8, G[2][j]) &circ; mul(in[i], G[3][j]);
+ * out[i] &circ;= k &lt;&lt; n;
* }
- * }
+ * }
* </pre>
*/
private static void transform(int[] in, int[] out)
@@ -332,8 +270,8 @@ public final class Square extends BaseCipher
}
/**
- * <p>Left rotate a 32-bit chunk.</p>
- *
+ * Left rotate a 32-bit chunk.
+ *
* @param x the 32-bit data to rotate
* @param s number of places to left-rotate by
* @return the newly permutated value.
@@ -344,8 +282,8 @@ public final class Square extends BaseCipher
}
/**
- * <p>Right rotate a 32-bit chunk.</p>
- *
+ * Right rotate a 32-bit chunk.
+ *
* @param x the 32-bit data to rotate
* @param s number of places to right-rotate by
* @return the newly permutated value.
@@ -356,12 +294,12 @@ public final class Square extends BaseCipher
}
/**
- * <p>Returns the product of two binary numbers a and b, using the generator
- * ROOT as the modulus: p = (a * b) mod ROOT. ROOT Generates a suitable
- * Galois Field in GF(2**8).</p>
- *
- * <p>For best performance call it with abs(b) &lt; abs(a).</p>
- *
+ * Returns the product of two binary numbers a and b, using the generator ROOT
+ * as the modulus: p = (a * b) mod ROOT. ROOT Generates a suitable Galois
+ * Field in GF(2**8).
+ * <p>
+ * For best performance call it with abs(b) &lt; abs(a).
+ *
* @param a operand for multiply.
* @param b operand for multiply.
* @return the result of (a * b) % ROOT.
@@ -369,35 +307,22 @@ public final class Square extends BaseCipher
private static final int mul(int a, int b)
{
if (a == 0)
- {
- return 0;
- }
-
+ return 0;
a &= 0xFF;
b &= 0xFF;
int result = 0;
while (b != 0)
{
if ((b & 0x01) != 0)
- {
- result ^= a;
- }
-
+ result ^= a;
b >>>= 1;
a <<= 1;
if (a > 0xFF)
- {
- a ^= ROOT;
- }
+ a ^= ROOT;
}
return result & 0xFF;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Square result = new Square();
@@ -406,12 +331,10 @@ public final class Square extends BaseCipher
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_BLOCK_SIZE));
+ al.add(Integer.valueOf(DEFAULT_BLOCK_SIZE));
return Collections.unmodifiableList(al).iterator();
}
@@ -419,7 +342,7 @@ public final class Square extends BaseCipher
public Iterator keySizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_KEY_SIZE));
+ al.add(Integer.valueOf(DEFAULT_KEY_SIZE));
return Collections.unmodifiableList(al).iterator();
}
@@ -427,36 +350,35 @@ public final class Square extends BaseCipher
public Object makeKey(byte[] uk, int bs) throws InvalidKeyException
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (uk == null)
- {
- throw new InvalidKeyException("Empty key");
- }
+ throw new InvalidKeyException("Empty key");
if (uk.length != DEFAULT_KEY_SIZE)
- {
- throw new InvalidKeyException("Key is not 128-bit.");
- }
-
+ throw new InvalidKeyException("Key is not 128-bit.");
int[][] Ke = new int[ROUNDS + 1][4];
int[][] Kd = new int[ROUNDS + 1][4];
int[][] tK = new int[ROUNDS + 1][4];
int i = 0;
-
- Ke[0][0] = (uk[i++] & 0xFF) << 24 | (uk[i++] & 0xFF) << 16
- | (uk[i++] & 0xFF) << 8 | (uk[i++] & 0xFF);
+ Ke[0][0] = (uk[i++] & 0xFF) << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
tK[0][0] = Ke[0][0];
- Ke[0][1] = (uk[i++] & 0xFF) << 24 | (uk[i++] & 0xFF) << 16
- | (uk[i++] & 0xFF) << 8 | (uk[i++] & 0xFF);
+ Ke[0][1] = (uk[i++] & 0xFF) << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
tK[0][1] = Ke[0][1];
- Ke[0][2] = (uk[i++] & 0xFF) << 24 | (uk[i++] & 0xFF) << 16
- | (uk[i++] & 0xFF) << 8 | (uk[i++] & 0xFF);
+ Ke[0][2] = (uk[i++] & 0xFF) << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i++] & 0xFF);
tK[0][2] = Ke[0][2];
- Ke[0][3] = (uk[i++] & 0xFF) << 24 | (uk[i++] & 0xFF) << 16
- | (uk[i++] & 0xFF) << 8 | (uk[i] & 0xFF);
+ Ke[0][3] = (uk[i++] & 0xFF) << 24
+ | (uk[i++] & 0xFF) << 16
+ | (uk[i++] & 0xFF) << 8
+ | (uk[i ] & 0xFF);
tK[0][3] = Ke[0][3];
-
int j;
for (i = 1, j = 0; i < ROUNDS + 1; i++, j++)
{
@@ -464,41 +386,28 @@ public final class Square extends BaseCipher
tK[i][1] = tK[j][1] ^ tK[i][0];
tK[i][2] = tK[j][2] ^ tK[i][1];
tK[i][3] = tK[j][3] ^ tK[i][2];
-
System.arraycopy(tK[i], 0, Ke[i], 0, 4);
-
transform(Ke[j], Ke[j]);
}
-
for (i = 0; i < ROUNDS; i++)
- {
- System.arraycopy(tK[ROUNDS - i], 0, Kd[i], 0, 4);
- }
-
+ System.arraycopy(tK[ROUNDS - i], 0, Kd[i], 0, 4);
transform(tK[0], Kd[ROUNDS]);
-
return new Object[] { Ke, Kd };
}
public void encrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[0];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[0];
square(in, i, out, j, K, Te, Se);
}
public void decrypt(byte[] in, int i, byte[] out, int j, Object k, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
- int[][] K = (int[][]) ((Object[]) k)[1];
+ throw new IllegalArgumentException();
+ int[][] K = (int[][])((Object[]) k)[1];
square(in, i, out, j, K, Td, Sd);
}
@@ -508,9 +417,7 @@ public final class Square extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/TripleDES.java b/libjava/classpath/gnu/javax/crypto/cipher/TripleDES.java
index 9b44c9ca7fb..1e98bfc8342 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/TripleDES.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/TripleDES.java
@@ -40,54 +40,50 @@ package gnu.javax.crypto.cipher;
import gnu.java.security.Registry;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.security.InvalidKeyException;
/**
- * Triple-DES, 3DES, or DESede is a <i>combined cipher</i> that uses
- * three iterations of the Data Encryption Standard cipher to improve
- * the security (at the cost of speed) of plain DES.
- *
- * <p>Triple-DES runs the DES algorithm three times with three
- * independent 56 bit keys. To encrypt:</p>
- *
- * <blockquote><i>C<sub>i</sub> =
- * E<sub>k3</sub> ( E<sub>k2</sub><sup>-1</sup> ( E<sub>k1</sub> ( P<sub>i</sub> )))</i></blockquote>
- *
- * <p>And to decrypt:</p>
- *
- * <blockquote><i>P<sub>i</sub> =
- * E<sub>k1</sub><sup>-1</sup> ( E<sub>k2</sub> ( E<sub>k3</sub><sup>-1</sup> ( C<sub>i</sub> )))</i></blockquote>
- *
- * <p>(The "ede" comes from the encryption operation, which runs
- * Encrypt-Decrypt-Encrypt)</p>
- *
- * <p>References:</p>
+ * Triple-DES, 3DES, or DESede is a <i>combined cipher</i> that uses three
+ * iterations of the Data Encryption Standard cipher to theoretically improve
+ * the security of plain DES, at the cost of speed.
+ * <p>
+ * Triple-DES runs the DES algorithm three times with one, two or three
+ * independent 56-bit (DES) keys. When used with one DES key, the cipher behaves
+ * exactly like a (slower) DES.
+ * <p>
+ * To encrypt:
+ * <blockquote><i>C<sub>i</sub> = E<sub>k3</sub> ( E<sub>k2</sub><sup>-1</sup> (
+ * E<sub>k1</sub> ( P<sub>i</sub> )))</i>
+ * </blockquote>
+ * <p>
+ * And to decrypt:
+ * <blockquote><i>P<sub>i</sub> = E<sub>k1</sub><sup>-1</sup> (
+ * E<sub>k2</sub> ( E<sub>k3</sub><sup>-1</sup> ( C<sub>i</sub> )))</i>
+ * </blockquote>
+ * <p>
+ * (The "ede" comes from the encryption operation, which runs
+ * Encrypt-Decrypt-Encrypt)
+ * <p>
+ * References:
* <ol>
- * <li>Bruce Schneier, <i>Applied Cryptography: Protocols, Algorithms,
- * and Source Code in C, Second Edition</i>. (1996 John Wiley and Sons)
- * ISBN 0-471-11709-9. Page 294--295.</li>
+ * <li>Bruce Schneier, <i>Applied Cryptography: Protocols, Algorithms, and
+ * Source Code in C, Second Edition</i>. (1996 John Wiley and Sons) ISBN
+ * 0-471-11709-9. Page 294--295.</li>
* </ol>
*/
-public class TripleDES extends BaseCipher
+public class TripleDES
+ extends BaseCipher
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
/** Triple-DES only operates on 64 bit blocks. */
public static final int BLOCK_SIZE = 8;
-
- /** Triple-DES uses 168 bits of a parity-adjusted 192 bit key. */
+ /** By default, Triple-DES uses 168 bits of a parity-adjusted 192 bit key. */
public static final int KEY_SIZE = 24;
-
/** The underlying DES instance. */
private DES des;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Default 0-arguments constructor.
*/
@@ -97,27 +93,48 @@ public class TripleDES extends BaseCipher
des = new DES();
}
- // Class methods.
- // -----------------------------------------------------------------------
-
/**
- * Transform a key so it will be parity adjusted.
- *
- * @param kb The key bytes to adjust.
+ * Convenience method which calls the method with same name and three
+ * arguments, passing <code>3</code> as the value of the first parameter.
+ *
+ * @param kb The key bytes to adjust.
* @param offset The starting offset into the key bytes.
- * @see DES#adjustParity(byte[],int)
*/
public static void adjustParity(byte[] kb, int offset)
{
+ adjustParity(3, kb, offset);
+ }
+
+ /**
+ * Adjusts, in-situ, the parity of the designated bytes, so they can be used
+ * as DES keys for a 3-DES 1-, 2- or 3-key cipher.
+ *
+ * @param keyCount the number of independent DES keys. Can be either
+ * <code>1</code>, <code>2</code> or <code>3</code>. Any other value
+ * will cause an {@link IllegalArgumentException} to be raised.
+ * @param kb the array containing the key bytes to adjust. MUST have at least
+ * <code>8 * keyCount</code> bytes starting at offset position
+ * <code>offset</code>, otherwise an
+ * {@link ArrayIndexOutOfBoundsException} will be raised.
+ * @param offset the starting offset into the array.
+ * @see DES#adjustParity(byte[],int)
+ */
+ public static void adjustParity(int keyCount, byte[] kb, int offset)
+ {
+ if (keyCount < 1 || keyCount > 3)
+ throw new IllegalArgumentException("Invalid keyCount value: " + keyCount);
DES.adjustParity(kb, offset);
- DES.adjustParity(kb, offset + 8);
- DES.adjustParity(kb, offset + 16);
+ if (keyCount > 1)
+ DES.adjustParity(kb, offset + 8);
+ if (keyCount > 2)
+ DES.adjustParity(kb, offset + 16);
}
/**
- * Tests if a byte array has already been parity adjusted.
- *
- * @param kb The key bytes to test.
+ * Convenience method which calls the method with same name and three
+ * arguments, passing <code>3</code> as the value of the first parameter.
+ *
+ * @param kb The key bytes to test.
* @param offset The starting offset into the key bytes.
* @return <code>true</code> if the bytes in <i>kb</i> starting at
* <i>offset</i> are parity adjusted.
@@ -126,13 +143,38 @@ public class TripleDES extends BaseCipher
*/
public static boolean isParityAdjusted(byte[] kb, int offset)
{
- return DES.isParityAdjusted(kb, offset)
- && DES.isParityAdjusted(kb, offset + 8)
- && DES.isParityAdjusted(kb, offset + 16);
+ return isParityAdjusted(3, kb, offset);
}
- // Methods implementing BaseCipher.
- // -----------------------------------------------------------------------
+ /**
+ * Tests if enough bytes, expected to be used as DES keys for a 3-DES 1-, 2-
+ * or 3-key cipher, located in a designated byte array, has already been
+ * parity adjusted.
+ *
+ * @param keyCount the number of independent DES keys. Can be either
+ * <code>1</code>, <code>2</code> or <code>3</code>. Any other value
+ * will cause an {@link IllegalArgumentException} to be raised.
+ * @param kb the array containing the key bytes to test. MUST have at least
+ * <code>8 * keyCount</code> bytes starting at offset position
+ * <code>offset</code>, otherwise an
+ * {@link ArrayIndexOutOfBoundsException} will be raised.
+ * @param offset the starting offset into the array.
+ * @return <code>true</code> if the bytes in <i>kb</i> starting at
+ * <i>offset</i> are parity adjusted.
+ * @see DES#isParityAdjusted(byte[],int)
+ * @see #adjustParity(int,byte[],int)
+ */
+ public static boolean isParityAdjusted(int keyCount, byte[] kb, int offset)
+ {
+ if (keyCount < 1 || keyCount > 3)
+ throw new IllegalArgumentException("Invalid keyCount value: " + keyCount);
+ boolean result = DES.isParityAdjusted(kb, offset);
+ if (keyCount > 1)
+ result = result && DES.isParityAdjusted(kb, offset + 8);
+ if (keyCount > 2)
+ result = result && DES.isParityAdjusted(kb, offset + 16);
+ return result;
+ }
public Object clone()
{
@@ -141,32 +183,54 @@ public class TripleDES extends BaseCipher
public Iterator blockSizes()
{
- return Collections.singleton(new Integer(BLOCK_SIZE)).iterator();
+ return Collections.singleton(Integer.valueOf(BLOCK_SIZE)).iterator();
}
public Iterator keySizes()
{
- return Collections.singleton(new Integer(KEY_SIZE)).iterator();
+ ArrayList al = new ArrayList();
+ al.add(Integer.valueOf(8));
+ al.add(Integer.valueOf(16));
+ al.add(Integer.valueOf(24));
+ return Collections.unmodifiableList(al).iterator();
}
public Object makeKey(byte[] kb, int bs) throws InvalidKeyException
{
- if (kb.length != KEY_SIZE)
- throw new InvalidKeyException("TripleDES key must be 24 bytes");
-
- if (!isParityAdjusted(kb, 0))
- adjustParity(kb, 0);
-
- byte[] k1 = new byte[DES.KEY_SIZE], k2 = new byte[DES.KEY_SIZE], k3 = new byte[DES.KEY_SIZE];
- System.arraycopy(kb, 0, k1, 0, DES.KEY_SIZE);
- System.arraycopy(kb, DES.KEY_SIZE, k2, 0, DES.KEY_SIZE);
- System.arraycopy(kb, 2 * DES.KEY_SIZE, k3, 0, DES.KEY_SIZE);
+ if (kb.length != 8 && kb.length != 16 && kb.length != 24)
+ throw new InvalidKeyException("TripleDES key must be 8, 16 or 24 bytes: "
+ + kb.length);
Context ctx = new Context();
-
+ byte[] k1 = new byte[DES.KEY_SIZE];
+ System.arraycopy(kb, 0, k1, 0, DES.KEY_SIZE);
+ if (! DES.isParityAdjusted(k1, 0))
+ DES.adjustParity(k1, 0);
ctx.k1 = (DES.Context) des.makeKey(k1, bs);
- ctx.k2 = (DES.Context) des.makeKey(k2, bs);
- ctx.k3 = (DES.Context) des.makeKey(k3, bs);
+ if (kb.length == 8)
+ {
+ ctx.k2 = (DES.Context) des.makeKey(k1, bs);
+ ctx.k3 = (DES.Context) des.makeKey(k1, bs);
+ }
+ else
+ {
+ byte[] k2 = new byte[DES.KEY_SIZE];
+ System.arraycopy(kb, DES.KEY_SIZE, k2, 0, DES.KEY_SIZE);
+ if (! DES.isParityAdjusted(k2, 0))
+ DES.adjustParity(k2, 0);
+ ctx.k2 = (DES.Context) des.makeKey(k2, bs);
+
+ byte[] k3 = new byte[DES.KEY_SIZE];
+ if (kb.length == 16)
+ ctx.k3 = (DES.Context) des.makeKey(k1, bs);
+ else
+ {
+ System.arraycopy(kb, 2 * DES.KEY_SIZE, k3, 0, DES.KEY_SIZE);
+ if (! DES.isParityAdjusted(k3, 0))
+ DES.adjustParity(k3, 0);
+ ctx.k3 = (DES.Context) des.makeKey(k3, bs);
+ }
+ }
return ctx;
}
@@ -186,11 +250,8 @@ public class TripleDES extends BaseCipher
des.decrypt(temp, 0, out, o, ((Context) K).k1, bs);
}
- // Inner classes.
- // -----------------------------------------------------------------------
-
private final class Context
{
DES.Context k1, k2, k3;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java b/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
index f5565d4b46f..b6932442897 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
@@ -38,204 +38,142 @@ exception statement from your version. */
package gnu.javax.crypto.cipher;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-//import java.io.PrintWriter;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.logging.Logger;
/**
- * <p>Twofish is a balanced 128-bit Feistel cipher, consisting of 16 rounds. In
+ * Twofish is a balanced 128-bit Feistel cipher, consisting of 16 rounds. In
* each round, a 64-bit S-box value is computed from 64 bits of the block, and
* this value is xored into the other half of the block. The two half-blocks are
* then exchanged, and the next round begins. Before the first round, all input
* bits are xored with key-dependent "whitening" subkeys, and after the final
* round the output bits are xored with other key-dependent whitening subkeys;
- * these subkeys are not used anywhere else in the algorithm.</p>
- *
- * <p>Twofish is designed by Bruce Schneier, Doug Whiting, John Kelsey, Chris
- * Hall, David Wagner and Niels Ferguson.</p>
- *
- * <p>References:</p>
- *
+ * these subkeys are not used anywhere else in the algorithm.
+ * <p>
+ * Twofish is designed by Bruce Schneier, Doug Whiting, John Kelsey, Chris
+ * Hall, David Wagner and Niels Ferguson.
+ * <p>
+ * References:
* <ol>
* <li><a href="http://www.counterpane.com/twofish-paper.html">Twofish: A
* 128-bit Block Cipher</a>.</li>
* </ol>
*/
-public final class Twofish extends BaseCipher
+public final class Twofish
+ extends BaseCipher
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- // private static final String NAME = "twofish";
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- // private static final PrintWriter err = new PrintWriter(System.out, true);
- // private static void debug(String s) {
- // err.println(">>> "+NAME+": "+s);
- // }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Twofish.class.getName());
private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
-
private static final int DEFAULT_KEY_SIZE = 16; // in bytes
-
private static final int MAX_ROUNDS = 16; // max # rounds (for allocating subkeys)
-
private static final int ROUNDS = MAX_ROUNDS;
-
// subkey array indices
private static final int INPUT_WHITEN = 0;
-
- private static final int OUTPUT_WHITEN = INPUT_WHITEN + DEFAULT_BLOCK_SIZE
- / 4;
-
- private static final int ROUND_SUBKEYS = OUTPUT_WHITEN + DEFAULT_BLOCK_SIZE
- / 4;
-
- // private static final int TOTAL_SUBKEYS = ROUND_SUBKEYS + 2*MAX_ROUNDS;
-
+ private static final int OUTPUT_WHITEN = INPUT_WHITEN + DEFAULT_BLOCK_SIZE / 4;
+ private static final int ROUND_SUBKEYS = OUTPUT_WHITEN + DEFAULT_BLOCK_SIZE / 4;
private static final int SK_STEP = 0x02020202;
-
private static final int SK_BUMP = 0x01010101;
-
private static final int SK_ROTL = 9;
-
private static final String[] Pm = new String[] {
- // p0
- "\uA967\uB3E8\u04FD\uA376\u9A92\u8078\uE4DD\uD138"
- + "\u0DC6\u3598\u18F7\uEC6C\u4375\u3726\uFA13\u9448"
- + "\uF2D0\u8B30\u8454\uDF23\u195B\u3D59\uF3AE\uA282"
- + "\u6301\u832E\uD951\u9B7C\uA6EB\uA5BE\u160C\uE361"
- + "\uC08C\u3AF5\u732C\u250B\uBB4E\u896B\u536A\uB4F1"
- + "\uE1E6\uBD45\uE2F4\uB666\uCC95\u0356\uD41C\u1ED7"
- + "\uFBC3\u8EB5\uE9CF\uBFBA\uEA77\u39AF\u33C9\u6271"
- + "\u8179\u09AD\u24CD\uF9D8\uE5C5\uB94D\u4408\u86E7"
- + "\uA11D\uAAED\u0670\uB2D2\u417B\uA011\u31C2\u2790"
- + "\u20F6\u60FF\u965C\uB1AB\u9E9C\u521B\u5F93\u0AEF"
- + "\u9185\u49EE\u2D4F\u8F3B\u4787\u6D46\uD63E\u6964"
- + "\u2ACE\uCB2F\uFC97\u057A\uAC7F\uD51A\u4B0E\uA75A"
- + "\u2814\u3F29\u883C\u4C02\uB8DA\uB017\u551F\u8A7D"
- + "\u57C7\u8D74\uB7C4\u9F72\u7E15\u2212\u5807\u9934"
- + "\u6E50\uDE68\u65BC\uDBF8\uC8A8\u2B40\uDCFE\u32A4"
- + "\uCA10\u21F0\uD35D\u0F00\u6F9D\u3642\u4A5E\uC1E0",
- // p1
- "\u75F3\uC6F4\uDB7B\uFBC8\u4AD3\uE66B\u457D\uE84B"
- + "\uD632\uD8FD\u3771\uF1E1\u300F\uF81B\u87FA\u063F"
- + "\u5EBA\uAE5B\u8A00\uBC9D\u6DC1\uB10E\u805D\uD2D5"
- + "\uA084\u0714\uB590\u2CA3\uB273\u4C54\u9274\u3651"
- + "\u38B0\uBD5A\uFC60\u6296\u6C42\uF710\u7C28\u278C"
- + "\u1395\u9CC7\u2446\u3B70\uCAE3\u85CB\u11D0\u93B8"
- + "\uA683\u20FF\u9F77\uC3CC\u036F\u08BF\u40E7\u2BE2"
- + "\u790C\uAA82\u413A\uEAB9\uE49A\uA497\u7EDA\u7A17"
- + "\u6694\uA11D\u3DF0\uDEB3\u0B72\uA71C\uEFD1\u533E"
- + "\u8F33\u265F\uEC76\u2A49\u8188\uEE21\uC41A\uEBD9"
- + "\uC539\u99CD\uAD31\u8B01\u1823\uDD1F\u4E2D\uF948"
- + "\u4FF2\u658E\u785C\u5819\u8DE5\u9857\u677F\u0564"
- + "\uAF63\uB6FE\uF5B7\u3CA5\uCEE9\u6844\uE04D\u4369"
- + "\u292E\uAC15\u59A8\u0A9E\u6E47\uDF34\u356A\uCFDC"
- + "\u22C9\uC09B\u89D4\uEDAB\u12A2\u0D52\uBB02\u2FA9"
- + "\uD761\u1EB4\u5004\uF6C2\u1625\u8656\u5509\uBE91" };
-
+ // p0
+ "\uA967\uB3E8\u04FD\uA376\u9A92\u8078\uE4DD\uD138"
+ + "\u0DC6\u3598\u18F7\uEC6C\u4375\u3726\uFA13\u9448"
+ + "\uF2D0\u8B30\u8454\uDF23\u195B\u3D59\uF3AE\uA282"
+ + "\u6301\u832E\uD951\u9B7C\uA6EB\uA5BE\u160C\uE361"
+ + "\uC08C\u3AF5\u732C\u250B\uBB4E\u896B\u536A\uB4F1"
+ + "\uE1E6\uBD45\uE2F4\uB666\uCC95\u0356\uD41C\u1ED7"
+ + "\uFBC3\u8EB5\uE9CF\uBFBA\uEA77\u39AF\u33C9\u6271"
+ + "\u8179\u09AD\u24CD\uF9D8\uE5C5\uB94D\u4408\u86E7"
+ + "\uA11D\uAAED\u0670\uB2D2\u417B\uA011\u31C2\u2790"
+ + "\u20F6\u60FF\u965C\uB1AB\u9E9C\u521B\u5F93\u0AEF"
+ + "\u9185\u49EE\u2D4F\u8F3B\u4787\u6D46\uD63E\u6964"
+ + "\u2ACE\uCB2F\uFC97\u057A\uAC7F\uD51A\u4B0E\uA75A"
+ + "\u2814\u3F29\u883C\u4C02\uB8DA\uB017\u551F\u8A7D"
+ + "\u57C7\u8D74\uB7C4\u9F72\u7E15\u2212\u5807\u9934"
+ + "\u6E50\uDE68\u65BC\uDBF8\uC8A8\u2B40\uDCFE\u32A4"
+ + "\uCA10\u21F0\uD35D\u0F00\u6F9D\u3642\u4A5E\uC1E0",
+ // p1
+ "\u75F3\uC6F4\uDB7B\uFBC8\u4AD3\uE66B\u457D\uE84B"
+ + "\uD632\uD8FD\u3771\uF1E1\u300F\uF81B\u87FA\u063F"
+ + "\u5EBA\uAE5B\u8A00\uBC9D\u6DC1\uB10E\u805D\uD2D5"
+ + "\uA084\u0714\uB590\u2CA3\uB273\u4C54\u9274\u3651"
+ + "\u38B0\uBD5A\uFC60\u6296\u6C42\uF710\u7C28\u278C"
+ + "\u1395\u9CC7\u2446\u3B70\uCAE3\u85CB\u11D0\u93B8"
+ + "\uA683\u20FF\u9F77\uC3CC\u036F\u08BF\u40E7\u2BE2"
+ + "\u790C\uAA82\u413A\uEAB9\uE49A\uA497\u7EDA\u7A17"
+ + "\u6694\uA11D\u3DF0\uDEB3\u0B72\uA71C\uEFD1\u533E"
+ + "\u8F33\u265F\uEC76\u2A49\u8188\uEE21\uC41A\uEBD9"
+ + "\uC539\u99CD\uAD31\u8B01\u1823\uDD1F\u4E2D\uF948"
+ + "\u4FF2\u658E\u785C\u5819\u8DE5\u9857\u677F\u0564"
+ + "\uAF63\uB6FE\uF5B7\u3CA5\uCEE9\u6844\uE04D\u4369"
+ + "\u292E\uAC15\u59A8\u0A9E\u6E47\uDF34\u356A\uCFDC"
+ + "\u22C9\uC09B\u89D4\uEDAB\u12A2\u0D52\uBB02\u2FA9"
+ + "\uD761\u1EB4\u5004\uF6C2\u1625\u8656\u5509\uBE91" };
/** Fixed 8x8 permutation S-boxes */
private static final byte[][] P = new byte[2][256]; // blank final
-
/**
* Define the fixed p0/p1 permutations used in keyed S-box lookup. By
* changing the following constant definitions, the S-boxes will
* automatically get changed in the Twofish engine.
*/
private static final int P_00 = 1;
-
private static final int P_01 = 0;
-
private static final int P_02 = 0;
-
private static final int P_03 = P_01 ^ 1;
-
private static final int P_04 = 1;
-
private static final int P_10 = 0;
-
private static final int P_11 = 0;
-
private static final int P_12 = 1;
-
private static final int P_13 = P_11 ^ 1;
-
private static final int P_14 = 0;
-
private static final int P_20 = 1;
-
private static final int P_21 = 1;
-
private static final int P_22 = 0;
-
private static final int P_23 = P_21 ^ 1;
-
private static final int P_24 = 0;
-
private static final int P_30 = 0;
-
private static final int P_31 = 1;
-
private static final int P_32 = 1;
-
private static final int P_33 = P_31 ^ 1;
-
private static final int P_34 = 1;
-
/** Primitive polynomial for GF(256) */
- // private static final int GF256_FDBK = 0x169;
private static final int GF256_FDBK_2 = 0x169 / 2;
-
private static final int GF256_FDBK_4 = 0x169 / 4;
-
/** MDS matrix */
private static final int[][] MDS = new int[4][256]; // blank final
-
private static final int RS_GF_FDBK = 0x14D; // field generator
-
/**
* KAT vector (from ecb_vk):
* I=183
* KEY=0000000000000000000000000000000000000000000002000000000000000000
* CT=F51410475B33FBD3DB2117B5C17C82D4
*/
- private static final byte[] KAT_KEY = Util.toBytesFromString("0000000000000000000000000000000000000000000002000000000000000000");
-
- private static final byte[] KAT_CT = Util.toBytesFromString("F51410475B33FBD3DB2117B5C17C82D4");
-
+ private static final byte[] KAT_KEY = Util.toBytesFromString(
+ "0000000000000000000000000000000000000000000002000000000000000000");
+ private static final byte[] KAT_CT =
+ Util.toBytesFromString("F51410475B33FBD3DB2117B5C17C82D4");
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
- // Static code - to intialise the MDS matrix and lookup tables -------------
-
static
{
long time = System.currentTimeMillis();
-
// expand the P arrays
int i;
char c;
for (i = 0; i < 256; i++)
{
c = Pm[0].charAt(i >>> 1);
- P[0][i] = (byte) ((i & 1) == 0 ? c >>> 8 : c);
-
+ P[0][i] = (byte)((i & 1) == 0 ? c >>> 8 : c);
c = Pm[1].charAt(i >>> 1);
- P[1][i] = (byte) ((i & 1) == 0 ? c >>> 8 : c);
+ P[1][i] = (byte)((i & 1) == 0 ? c >>> 8 : c);
}
-
// precompute the MDS matrix
int[] m1 = new int[2];
int[] mX = new int[2];
@@ -247,80 +185,65 @@ public final class Twofish extends BaseCipher
m1[0] = j;
mX[0] = Mx_X(j) & 0xFF;
mY[0] = Mx_Y(j) & 0xFF;
-
j = P[1][i] & 0xFF;
m1[1] = j;
mX[1] = Mx_X(j) & 0xFF;
mY[1] = Mx_Y(j) & 0xFF;
-
- MDS[0][i] = m1[P_00] << 0 | // fill matrix w/ above elements
- mX[P_00] << 8 | mY[P_00] << 16 | mY[P_00] << 24;
- MDS[1][i] = mY[P_10] << 0 | mY[P_10] << 8 | mX[P_10] << 16
- | m1[P_10] << 24;
- MDS[2][i] = mX[P_20] << 0 | mY[P_20] << 8 | m1[P_20] << 16
- | mY[P_20] << 24;
- MDS[3][i] = mX[P_30] << 0 | m1[P_30] << 8 | mY[P_30] << 16
- | mX[P_30] << 24;
+ MDS[0][i] = m1[P_00] << 0
+ | mX[P_00] << 8
+ | mY[P_00] << 16
+ | mY[P_00] << 24;
+ MDS[1][i] = mY[P_10] << 0
+ | mY[P_10] << 8
+ | mX[P_10] << 16
+ | m1[P_10] << 24;
+ MDS[2][i] = mX[P_20] << 0
+ | mY[P_20] << 8
+ | m1[P_20] << 16
+ | mY[P_20] << 24;
+ MDS[3][i] = mX[P_30] << 0
+ | m1[P_30] << 8
+ | mY[P_30] << 16
+ | mX[P_30] << 24;
}
-
time = System.currentTimeMillis() - time;
-
- if (DEBUG && debuglevel > 8)
+ if (Configuration.DEBUG)
{
- System.out.println("==========");
- System.out.println();
- System.out.println("Static Data");
- System.out.println();
- System.out.println("MDS[0][]:");
+ log.fine("Static Data");
+ log.fine("MDS[0][]:");
+ StringBuilder sb;
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(MDS[0][i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(MDS[0][i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
-
- System.out.println();
- System.out.println("MDS[1][]:");
+ log.fine("MDS[1][]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(MDS[1][i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(MDS[1][i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
-
- System.out.println();
- System.out.println("MDS[2][]:");
+ log.fine("MDS[2][]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(MDS[2][i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(MDS[2][i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
-
- System.out.println();
- System.out.println("MDS[3][]:");
+ log.fine("MDS[3][]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(MDS[3][i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(MDS[3][i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
-
- System.out.println();
- System.out.println("Total initialization time: " + time + " ms.");
- System.out.println();
+ log.fine("Total initialization time: " + time + " ms.");
}
}
@@ -331,14 +254,11 @@ public final class Twofish extends BaseCipher
private static final int LFSR2(int x)
{
- return (x >> 2) ^ ((x & 0x02) != 0 ? GF256_FDBK_2 : 0)
- ^ ((x & 0x01) != 0 ? GF256_FDBK_4 : 0);
+ return (x >> 2)
+ ^ ((x & 0x02) != 0 ? GF256_FDBK_2 : 0)
+ ^ ((x & 0x01) != 0 ? GF256_FDBK_4 : 0);
}
- // private static final int Mx_1(int x) {
- // return x;
- // }
-
private static final int Mx_X(int x)
{ // 5B
return x ^ LFSR2(x);
@@ -349,18 +269,12 @@ public final class Twofish extends BaseCipher
return x ^ LFSR1(x) ^ LFSR2(x);
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public Twofish()
{
super(Registry.TWOFISH_CIPHER, DEFAULT_BLOCK_SIZE, DEFAULT_KEY_SIZE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
private static final int b0(int x)
{
return x & 0xFF;
@@ -393,15 +307,11 @@ public final class Twofish extends BaseCipher
{
int r = k1;
int i;
- for (i = 0; i < 4; i++)
- { // shift 1 byte at a time
- r = RS_rem(r);
- }
+ for (i = 0; i < 4; i++) // shift 1 byte at a time
+ r = RS_rem(r);
r ^= k0;
for (i = 0; i < 4; i++)
- {
- r = RS_rem(r);
- }
+ r = RS_rem(r);
return r;
}
@@ -431,15 +341,14 @@ public final class Twofish extends BaseCipher
int k1 = k32[1];
int k2 = k32[2];
int k3 = k32[3];
-
int result = 0;
switch (k64Cnt & 3)
{
case 1:
result = MDS[0][(P[P_01][b0] & 0xFF) ^ b0(k0)]
- ^ MDS[1][(P[P_11][b1] & 0xFF) ^ b1(k0)]
- ^ MDS[2][(P[P_21][b2] & 0xFF) ^ b2(k0)]
- ^ MDS[3][(P[P_31][b3] & 0xFF) ^ b3(k0)];
+ ^ MDS[1][(P[P_11][b1] & 0xFF) ^ b1(k0)]
+ ^ MDS[2][(P[P_21][b2] & 0xFF) ^ b2(k0)]
+ ^ MDS[3][(P[P_31][b3] & 0xFF) ^ b3(k0)];
break;
case 0: // same as 4
b0 = (P[P_04][b0] & 0xFF) ^ b0(k3);
@@ -452,14 +361,10 @@ public final class Twofish extends BaseCipher
b2 = (P[P_23][b2] & 0xFF) ^ b2(k2);
b3 = (P[P_33][b3] & 0xFF) ^ b3(k2);
case 2: // 128-bit keys (optimize for this case)
- result = MDS[0][(P[P_01][(P[P_02][b0] & 0xFF) ^ b0(k1)] & 0xFF)
- ^ b0(k0)]
- ^ MDS[1][(P[P_11][(P[P_12][b1] & 0xFF) ^ b1(k1)] & 0xFF)
- ^ b1(k0)]
- ^ MDS[2][(P[P_21][(P[P_22][b2] & 0xFF) ^ b2(k1)] & 0xFF)
- ^ b2(k0)]
- ^ MDS[3][(P[P_31][(P[P_32][b3] & 0xFF) ^ b3(k1)] & 0xFF)
- ^ b3(k0)];
+ result = MDS[0][(P[P_01][(P[P_02][b0] & 0xFF) ^ b0(k1)] & 0xFF) ^ b0(k0)]
+ ^ MDS[1][(P[P_11][(P[P_12][b1] & 0xFF) ^ b1(k1)] & 0xFF) ^ b1(k0)]
+ ^ MDS[2][(P[P_21][(P[P_22][b2] & 0xFF) ^ b2(k1)] & 0xFF) ^ b2(k0)]
+ ^ MDS[3][(P[P_31][(P[P_32][b3] & 0xFF) ^ b3(k1)] & 0xFF) ^ b3(k0)];
break;
}
return result;
@@ -467,23 +372,14 @@ public final class Twofish extends BaseCipher
private static final int Fe32(int[] sBox, int x, int R)
{
- return sBox[2 * _b(x, R)] ^ sBox[2 * _b(x, R + 1) + 1]
- ^ sBox[0x200 + 2 * _b(x, R + 2)]
- ^ sBox[0x200 + 2 * _b(x, R + 3) + 1];
+ return sBox[ 2 * _b(x, R ) ]
+ ^ sBox[ 2 * _b(x, R + 1) + 1]
+ ^ sBox[0x200 + 2 * _b(x, R + 2) ]
+ ^ sBox[0x200 + 2 * _b(x, R + 3) + 1];
}
private static final int _b(int x, int N)
{
- // int result = 0;
- // switch (N%4) {
- // case 0: result = b0(x); break;
- // case 1: result = b1(x); break;
- // case 2: result = b2(x); break;
- // case 3: result = b3(x); break;
- // }
- // return result;
- // profiling shows that the code spends too long in this method.
- // following constructs seem to improve, albeit marginally, performance
switch (N % 4)
{
case 0:
@@ -497,43 +393,33 @@ public final class Twofish extends BaseCipher
}
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
Twofish result = new Twofish();
result.currentBlockSize = this.currentBlockSize;
-
return result;
}
- // IBlockCipherSpi interface implementation --------------------------------
-
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(DEFAULT_BLOCK_SIZE));
-
+ al.add(Integer.valueOf(DEFAULT_BLOCK_SIZE));
return Collections.unmodifiableList(al).iterator();
}
public Iterator keySizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(8)); // 64-bit
- al.add(new Integer(16)); // 128-bit
- al.add(new Integer(24)); // 192-bit
- al.add(new Integer(32)); // 256-bit
-
+ al.add(Integer.valueOf(8)); // 64-bit
+ al.add(Integer.valueOf(16)); // 128-bit
+ al.add(Integer.valueOf(24)); // 192-bit
+ al.add(Integer.valueOf(32)); // 256-bit
return Collections.unmodifiableList(al).iterator();
}
/**
- * <p>Expands a user-supplied key material into a session key for a designated
- * <i>block size</i>.</p>
+ * Expands a user-supplied key material into a session key for a designated
+ * <i>block size</i>.
*
* @param k the 64/128/192/256-bit user-key to use.
* @param bs the desired block size in bytes.
@@ -544,35 +430,30 @@ public final class Twofish extends BaseCipher
public Object makeKey(byte[] k, int bs) throws InvalidKeyException
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
if (k == null)
- {
- throw new InvalidKeyException("Empty key");
- }
+ throw new InvalidKeyException("Empty key");
int length = k.length;
- if (!(length == 8 || length == 16 || length == 24 || length == 32))
- {
- throw new InvalidKeyException("Incorrect key length");
- }
-
+ if (! (length == 8 || length == 16 || length == 24 || length == 32))
+ throw new InvalidKeyException("Incorrect key length");
int k64Cnt = length / 8;
int subkeyCnt = ROUND_SUBKEYS + 2 * ROUNDS;
int[] k32e = new int[4]; // even 32-bit entities
int[] k32o = new int[4]; // odd 32-bit entities
int[] sBoxKey = new int[4];
- //
// split user key material into even and odd 32-bit entities and
// compute S-box keys using (12, 8) Reed-Solomon code over GF(256)
- //
int i, j, offset = 0;
for (i = 0, j = k64Cnt - 1; i < 4 && offset < length; i++, j--)
{
- k32e[i] = (k[offset++] & 0xFF) | (k[offset++] & 0xFF) << 8
- | (k[offset++] & 0xFF) << 16 | (k[offset++] & 0xFF) << 24;
- k32o[i] = (k[offset++] & 0xFF) | (k[offset++] & 0xFF) << 8
- | (k[offset++] & 0xFF) << 16 | (k[offset++] & 0xFF) << 24;
+ k32e[i] = (k[offset++] & 0xFF)
+ | (k[offset++] & 0xFF) << 8
+ | (k[offset++] & 0xFF) << 16
+ | (k[offset++] & 0xFF) << 24;
+ k32o[i] = (k[offset++] & 0xFF)
+ | (k[offset++] & 0xFF) << 8
+ | (k[offset++] & 0xFF) << 16
+ | (k[offset++] & 0xFF) << 24;
sBoxKey[j] = RS_MDS_Encode(k32e[i], k32o[i]); // reverse order
}
// compute the round decryption subkeys for PHT. these same subkeys
@@ -589,7 +470,6 @@ public final class Twofish extends BaseCipher
A += B;
subKeys[2 * i + 1] = A << SK_ROTL | A >>> (32 - SK_ROTL);
}
-
// fully expand the table for speed
int k0 = sBoxKey[0];
int k1 = sBoxKey[1];
@@ -603,9 +483,9 @@ public final class Twofish extends BaseCipher
switch (k64Cnt & 3)
{
case 1:
- sBox[2 * i] = MDS[0][(P[P_01][b0] & 0xFF) ^ b0(k0)];
- sBox[2 * i + 1] = MDS[1][(P[P_11][b1] & 0xFF) ^ b1(k0)];
- sBox[0x200 + 2 * i] = MDS[2][(P[P_21][b2] & 0xFF) ^ b2(k0)];
+ sBox[ 2 * i ] = MDS[0][(P[P_01][b0] & 0xFF) ^ b0(k0)];
+ sBox[ 2 * i + 1] = MDS[1][(P[P_11][b1] & 0xFF) ^ b1(k0)];
+ sBox[0x200 + 2 * i ] = MDS[2][(P[P_21][b2] & 0xFF) ^ b2(k0)];
sBox[0x200 + 2 * i + 1] = MDS[3][(P[P_31][b3] & 0xFF) ^ b3(k0)];
break;
case 0: // same as 4
@@ -619,77 +499,61 @@ public final class Twofish extends BaseCipher
b2 = (P[P_23][b2] & 0xFF) ^ b2(k2);
b3 = (P[P_33][b3] & 0xFF) ^ b3(k2);
case 2: // 128-bit keys
- sBox[2 * i] = MDS[0][(P[P_01][(P[P_02][b0] & 0xFF) ^ b0(k1)] & 0xFF)
- ^ b0(k0)];
- sBox[2 * i + 1] = MDS[1][(P[P_11][(P[P_12][b1] & 0xFF) ^ b1(k1)] & 0xFF)
- ^ b1(k0)];
- sBox[0x200 + 2 * i] = MDS[2][(P[P_21][(P[P_22][b2] & 0xFF) ^ b2(k1)] & 0xFF)
- ^ b2(k0)];
+ sBox[ 2 * i ] = MDS[0][(P[P_01][(P[P_02][b0] & 0xFF)
+ ^ b0(k1)] & 0xFF) ^ b0(k0)];
+ sBox[ 2 * i + 1] = MDS[1][(P[P_11][(P[P_12][b1] & 0xFF)
+ ^ b1(k1)] & 0xFF) ^ b1(k0)];
+ sBox[0x200 + 2 * i ] = MDS[2][(P[P_21][(P[P_22][b2] & 0xFF)
+ ^ b2(k1)] & 0xFF) ^ b2(k0)];
sBox[0x200 + 2 * i + 1] = MDS[3][(P[P_31][(P[P_32][b3] & 0xFF)
- ^ b3(k1)] & 0xFF)
- ^ b3(k0)];
+ ^ b3(k1)] & 0xFF) ^ b3(k0)];
}
}
-
- if (DEBUG && debuglevel > 7)
+ if (Configuration.DEBUG)
{
- System.out.println("S-box[]:");
+ StringBuilder sb;
+ log.fine("S-box[]:");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(sBox[i * 4 + j]) + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(sBox[i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
+ log.fine("");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(sBox[256 + i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(sBox[256 + i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
+ log.fine("");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(sBox[512 + i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(sBox[512 + i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
+ log.fine("");
for (i = 0; i < 64; i++)
{
+ sb = new StringBuilder();
for (j = 0; j < 4; j++)
- {
- System.out.print("0x" + Util.toString(sBox[768 + i * 4 + j])
- + ", ");
- }
- System.out.println();
+ sb.append("0x").append(Util.toString(sBox[768 + i * 4 + j])).append(", ");
+ log.fine(sb.toString());
}
- System.out.println();
- System.out.println("User (odd, even) keys --> S-Box keys:");
+ log.fine("User (odd, even) keys --> S-Box keys:");
for (i = 0; i < k64Cnt; i++)
- {
- System.out.println("0x" + Util.toString(k32o[i]) + " 0x"
- + Util.toString(k32e[i]) + " --> 0x"
- + Util.toString(sBoxKey[k64Cnt - 1 - i]));
- }
- System.out.println();
- System.out.println("Round keys:");
+ log.fine("0x" + Util.toString(k32o[i])
+ + " 0x" + Util.toString(k32e[i])
+ + " --> 0x" + Util.toString(sBoxKey[k64Cnt - 1 - i]));
+ log.fine("Round keys:");
for (i = 0; i < ROUND_SUBKEYS + 2 * ROUNDS; i += 2)
- {
- System.out.println("0x" + Util.toString(subKeys[i]) + " 0x"
- + Util.toString(subKeys[i + 1]));
- }
- System.out.println();
+ log.fine("0x" + Util.toString(subKeys[i])
+ + " 0x" + Util.toString(subKeys[i + 1]));
}
-
return new Object[] { sBox, subKeys };
}
@@ -697,38 +561,35 @@ public final class Twofish extends BaseCipher
Object sessionKey, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
+ throw new IllegalArgumentException();
Object[] sk = (Object[]) sessionKey; // extract S-box and session key
int[] sBox = (int[]) sk[0];
int[] sKey = (int[]) sk[1];
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT=" + Util.toString(in, inOffset, bs));
- }
-
- int x0 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x1 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x2 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x3 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
-
+ if (Configuration.DEBUG)
+ log.fine("PT=" + Util.toString(in, inOffset, bs));
+ int x0 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x1 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x2 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x3 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
x0 ^= sKey[INPUT_WHITEN];
x1 ^= sKey[INPUT_WHITEN + 1];
x2 ^= sKey[INPUT_WHITEN + 2];
x3 ^= sKey[INPUT_WHITEN + 3];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PTw=" + Util.toString(x0) + Util.toString(x1)
- + Util.toString(x2) + Util.toString(x3));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("PTw=" + Util.toString(x0) + Util.toString(x1)
+ + Util.toString(x2) + Util.toString(x3));
int t0, t1;
int k = ROUND_SUBKEYS;
for (int R = 0; R < ROUNDS; R += 2)
@@ -739,96 +600,79 @@ public final class Twofish extends BaseCipher
x2 = x2 >>> 1 | x2 << 31;
x3 = x3 << 1 | x3 >>> 31;
x3 ^= t0 + 2 * t1 + sKey[k++];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT" + (R) + "=" + Util.toString(x0)
- + Util.toString(x1) + Util.toString(x2)
- + Util.toString(x3));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("CT" + (R) + "=" + Util.toString(x0) + Util.toString(x1)
+ + Util.toString(x2) + Util.toString(x3));
t0 = Fe32(sBox, x2, 0);
t1 = Fe32(sBox, x3, 3);
x0 ^= t0 + t1 + sKey[k++];
x0 = x0 >>> 1 | x0 << 31;
x1 = x1 << 1 | x1 >>> 31;
x1 ^= t0 + 2 * t1 + sKey[k++];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT" + (R + 1) + "=" + Util.toString(x0)
- + Util.toString(x1) + Util.toString(x2)
- + Util.toString(x3));
- }
+ if (Configuration.DEBUG)
+ log.fine("CT" + (R + 1) + "=" + Util.toString(x0) + Util.toString(x1)
+ + Util.toString(x2) + Util.toString(x3));
}
x2 ^= sKey[OUTPUT_WHITEN];
x3 ^= sKey[OUTPUT_WHITEN + 1];
x0 ^= sKey[OUTPUT_WHITEN + 2];
x1 ^= sKey[OUTPUT_WHITEN + 3];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CTw=" + Util.toString(x0) + Util.toString(x1)
- + Util.toString(x2) + Util.toString(x3));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("CTw=" + Util.toString(x0) + Util.toString(x1)
+ + Util.toString(x2) + Util.toString(x3));
out[outOffset++] = (byte) x2;
- out[outOffset++] = (byte) (x2 >>> 8);
- out[outOffset++] = (byte) (x2 >>> 16);
- out[outOffset++] = (byte) (x2 >>> 24);
+ out[outOffset++] = (byte)(x2 >>> 8);
+ out[outOffset++] = (byte)(x2 >>> 16);
+ out[outOffset++] = (byte)(x2 >>> 24);
out[outOffset++] = (byte) x3;
- out[outOffset++] = (byte) (x3 >>> 8);
- out[outOffset++] = (byte) (x3 >>> 16);
- out[outOffset++] = (byte) (x3 >>> 24);
+ out[outOffset++] = (byte)(x3 >>> 8);
+ out[outOffset++] = (byte)(x3 >>> 16);
+ out[outOffset++] = (byte)(x3 >>> 24);
out[outOffset++] = (byte) x0;
- out[outOffset++] = (byte) (x0 >>> 8);
- out[outOffset++] = (byte) (x0 >>> 16);
- out[outOffset++] = (byte) (x0 >>> 24);
+ out[outOffset++] = (byte)(x0 >>> 8);
+ out[outOffset++] = (byte)(x0 >>> 16);
+ out[outOffset++] = (byte)(x0 >>> 24);
out[outOffset++] = (byte) x1;
- out[outOffset++] = (byte) (x1 >>> 8);
- out[outOffset++] = (byte) (x1 >>> 16);
- out[outOffset] = (byte) (x1 >>> 24);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT=" + Util.toString(out, outOffset - 15, 16));
- System.out.println();
- }
+ out[outOffset++] = (byte)(x1 >>> 8);
+ out[outOffset++] = (byte)(x1 >>> 16);
+ out[outOffset ] = (byte)(x1 >>> 24);
+ if (Configuration.DEBUG)
+ log.fine("CT=" + Util.toString(out, outOffset - 15, 16) + "\n");
}
public void decrypt(byte[] in, int inOffset, byte[] out, int outOffset,
Object sessionKey, int bs)
{
if (bs != DEFAULT_BLOCK_SIZE)
- {
- throw new IllegalArgumentException();
- }
-
+ throw new IllegalArgumentException();
Object[] sk = (Object[]) sessionKey; // extract S-box and session key
int[] sBox = (int[]) sk[0];
int[] sKey = (int[]) sk[1];
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CT=" + Util.toString(in, inOffset, bs));
- }
-
- int x2 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x3 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x0 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
- int x1 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
- | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
-
+ if (Configuration.DEBUG)
+ log.fine("CT=" + Util.toString(in, inOffset, bs));
+ int x2 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x3 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x0 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
+ int x1 = (in[inOffset++] & 0xFF)
+ | (in[inOffset++] & 0xFF) << 8
+ | (in[inOffset++] & 0xFF) << 16
+ | (in[inOffset++] & 0xFF) << 24;
x2 ^= sKey[OUTPUT_WHITEN];
x3 ^= sKey[OUTPUT_WHITEN + 1];
x0 ^= sKey[OUTPUT_WHITEN + 2];
x1 ^= sKey[OUTPUT_WHITEN + 3];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("CTw=" + Util.toString(x2) + Util.toString(x3)
- + Util.toString(x0) + Util.toString(x1));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("CTw=" + Util.toString(x2) + Util.toString(x3)
+ + Util.toString(x0) + Util.toString(x1));
int k = ROUND_SUBKEYS + 2 * ROUNDS - 1;
int t0, t1;
for (int R = 0; R < ROUNDS; R += 2)
@@ -839,58 +683,44 @@ public final class Twofish extends BaseCipher
x1 = x1 >>> 1 | x1 << 31;
x0 = x0 << 1 | x0 >>> 31;
x0 ^= t0 + t1 + sKey[k--];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT" + (ROUNDS - R) + "=" + Util.toString(x2)
- + Util.toString(x3) + Util.toString(x0)
- + Util.toString(x1));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("PT" + (ROUNDS - R) + "=" + Util.toString(x2)
+ + Util.toString(x3) + Util.toString(x0) + Util.toString(x1));
t0 = Fe32(sBox, x0, 0);
t1 = Fe32(sBox, x1, 3);
x3 ^= t0 + 2 * t1 + sKey[k--];
x3 = x3 >>> 1 | x3 << 31;
x2 = x2 << 1 | x2 >>> 31;
x2 ^= t0 + t1 + sKey[k--];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT" + (ROUNDS - R - 1) + "="
- + Util.toString(x2) + Util.toString(x3)
- + Util.toString(x0) + Util.toString(x1));
- }
+ if (Configuration.DEBUG)
+ log.fine("PT" + (ROUNDS - R - 1) + "=" + Util.toString(x2)
+ + Util.toString(x3) + Util.toString(x0) + Util.toString(x1));
}
x0 ^= sKey[INPUT_WHITEN];
x1 ^= sKey[INPUT_WHITEN + 1];
x2 ^= sKey[INPUT_WHITEN + 2];
x3 ^= sKey[INPUT_WHITEN + 3];
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PTw=" + Util.toString(x2) + Util.toString(x3)
- + Util.toString(x0) + Util.toString(x1));
- }
-
+ if (Configuration.DEBUG)
+ log.fine("PTw=" + Util.toString(x2) + Util.toString(x3)
+ + Util.toString(x0) + Util.toString(x1));
out[outOffset++] = (byte) x0;
- out[outOffset++] = (byte) (x0 >>> 8);
- out[outOffset++] = (byte) (x0 >>> 16);
- out[outOffset++] = (byte) (x0 >>> 24);
+ out[outOffset++] = (byte)(x0 >>> 8);
+ out[outOffset++] = (byte)(x0 >>> 16);
+ out[outOffset++] = (byte)(x0 >>> 24);
out[outOffset++] = (byte) x1;
- out[outOffset++] = (byte) (x1 >>> 8);
- out[outOffset++] = (byte) (x1 >>> 16);
- out[outOffset++] = (byte) (x1 >>> 24);
+ out[outOffset++] = (byte)(x1 >>> 8);
+ out[outOffset++] = (byte)(x1 >>> 16);
+ out[outOffset++] = (byte)(x1 >>> 24);
out[outOffset++] = (byte) x2;
- out[outOffset++] = (byte) (x2 >>> 8);
- out[outOffset++] = (byte) (x2 >>> 16);
- out[outOffset++] = (byte) (x2 >>> 24);
+ out[outOffset++] = (byte)(x2 >>> 8);
+ out[outOffset++] = (byte)(x2 >>> 16);
+ out[outOffset++] = (byte)(x2 >>> 24);
out[outOffset++] = (byte) x3;
- out[outOffset++] = (byte) (x3 >>> 8);
- out[outOffset++] = (byte) (x3 >>> 16);
- out[outOffset] = (byte) (x3 >>> 24);
-
- if (DEBUG && debuglevel > 6)
- {
- System.out.println("PT=" + Util.toString(out, outOffset - 15, 16));
- System.out.println();
- }
+ out[outOffset++] = (byte)(x3 >>> 8);
+ out[outOffset++] = (byte)(x3 >>> 16);
+ out[outOffset ] = (byte)(x3 >>> 24);
+ if (Configuration.DEBUG)
+ log.fine("PT=" + Util.toString(out, outOffset - 15, 16) + "\n");
}
public boolean selfTest()
@@ -899,11 +729,9 @@ public final class Twofish extends BaseCipher
{
boolean result = super.selfTest(); // do symmetry tests
if (result)
- {
- result = testKat(KAT_KEY, KAT_CT);
- }
+ result = testKat(KAT_KEY, KAT_CT);
valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/WeakKeyException.java b/libjava/classpath/gnu/javax/crypto/cipher/WeakKeyException.java
index 4454e0e4502..f89ff54d1ca 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/WeakKeyException.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/WeakKeyException.java
@@ -41,18 +41,12 @@ package gnu.javax.crypto.cipher;
import java.security.InvalidKeyException;
/**
- * <p>Checked exception thrown to indicate that a weak key has been generated
- * and or specified instead of a valid non-weak value.</p>
+ * Checked exception thrown to indicate that a weak key has been generated and
+ * or specified instead of a valid non-weak value.
*/
-public class WeakKeyException extends InvalidKeyException
+public class WeakKeyException
+ extends InvalidKeyException
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public WeakKeyException()
{
super();
@@ -62,10 +56,4 @@ public class WeakKeyException extends InvalidKeyException
{
super(msg);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/DiffieHellmanImpl.java b/libjava/classpath/gnu/javax/crypto/jce/DiffieHellmanImpl.java
index 02761477a69..4f4d5e47908 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/DiffieHellmanImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/DiffieHellmanImpl.java
@@ -46,6 +46,7 @@ import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.KeyAgreementSpi;
import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
import javax.crypto.interfaces.DHPrivateKey;
import javax.crypto.interfaces.DHPublicKey;
import javax.crypto.spec.DHParameterSpec;
@@ -63,7 +64,7 @@ public final class DiffieHellmanImpl
private DHPrivateKey key;
/** The current result. */
- private BigInteger result;
+ private byte[] result;
/** True if the caller told us we are done. */
private boolean last_phase_done;
@@ -96,43 +97,49 @@ public final class DiffieHellmanImpl
if (! s1.getG().equals(s2.getG()) || ! s1.getP().equals(s2.getP())
|| s1.getL() != s2.getL())
throw new InvalidKeyException("Incompatible key");
-
- result = pub.getY().modPow(key.getX(), s1.getP());
if (! lastPhase)
- throw new IllegalArgumentException("This key-agreement MUST be concluded in one step only");
-
+ throw new IllegalArgumentException(
+ "This key-agreement MUST be concluded in one step only");
+ BigInteger resultBI = pub.getY().modPow(key.getX(), s1.getP());
+ result = resultBI.toByteArray();
+ if (result[0] == 0x00)
+ {
+ byte[] buf = new byte[result.length - 1];
+ System.arraycopy(result, 1, buf, 0, buf.length);
+ result = buf;
+ }
last_phase_done = true;
return null;
}
protected byte[] engineGenerateSecret()
{
- if (result == null || ! last_phase_done)
- throw new IllegalStateException("Not finished");
-
- byte[] buf = result.toByteArray();
- if (buf[0] == 0x00)
- {
- byte[] buf2 = new byte[buf.length - 1];
- System.arraycopy(buf, 1, buf2, 0, buf2.length);
- buf = buf2;
- }
-
- return buf;
+ checkState();
+ byte[] res = (byte[]) result.clone();
+ reset();
+ return res;
}
protected int engineGenerateSecret(byte[] secret, int offset)
+ throws ShortBufferException
{
- byte[] s = engineGenerateSecret();
- System.arraycopy(s, 0, secret, offset, s.length);
- return s.length;
+ checkState();
+ if (result.length > secret.length - offset)
+ throw new ShortBufferException();
+ System.arraycopy(result, 0, secret, offset, result.length);
+ int res = result.length;
+ reset();
+ return res;
}
protected SecretKey engineGenerateSecret(String algorithm)
throws InvalidKeyException
{
- byte[] s = engineGenerateSecret();
- return new SecretKeySpec(s, algorithm);
+ checkState();
+ byte[] s = (byte[]) result.clone();
+ SecretKey res = new SecretKeySpec(s, algorithm);
+ reset();
+ return res;
}
protected void engineInit(Key key, SecureRandom random)
@@ -140,10 +147,8 @@ public final class DiffieHellmanImpl
{
if (! (key instanceof DHPrivateKey))
throw new InvalidKeyException("Key MUST be a DHPrivateKey");
-
this.key = (DHPrivateKey) key;
- result = null;
- last_phase_done = false;
+ reset();
}
protected void engineInit(Key key, AlgorithmParameterSpec params,
@@ -152,4 +157,16 @@ public final class DiffieHellmanImpl
{
engineInit(key, random);
}
+
+ private void reset()
+ {
+ result = null;
+ last_phase_done = false;
+ }
+
+ private void checkState()
+ {
+ if (result == null || ! last_phase_done)
+ throw new IllegalStateException("Not finished");
+ }
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/GnuCrypto.java b/libjava/classpath/gnu/javax/crypto/jce/GnuCrypto.java
index b0e73b13256..8099fd13da9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/GnuCrypto.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/GnuCrypto.java
@@ -49,24 +49,14 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>The GNU Crypto implementation of the Java Cryptographic Extension (JCE)
- * Provider.</p>
- *
+ * The additional GNU algorithm implementation as a Java Cryptographic Extension
+ * (JCE) Provider.
+ *
* @see java.security.Provider
*/
-public final class GnuCrypto extends Provider
+public final class GnuCrypto
+ extends Provider
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- /**
- * <p>The <a href="http://www.gnu.org/software/gnu-crypto/">GNU Crypto</a>
- * Provider.</p>
- */
public GnuCrypto()
{
super(Registry.GNU_CRYPTO, 2.1, "GNU Crypto JCE Provider");
@@ -120,8 +110,7 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.AES.class.getName());
put("Cipher.PBEWithHMacHavalAndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacHavalAndBlowfish",
+ put("Cipher.PBEWithHMacHavalAndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Blowfish.class.getName());
put("Cipher.PBEWithHMacHavalAndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Cast5.class.getName());
@@ -133,8 +122,7 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Serpent.class.getName());
put("Cipher.PBEWithHMacHavalAndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Square.class.getName());
- put(
- "Cipher.PBEWithHMacHavalAndTripleDES",
+ put("Cipher.PBEWithHMacHavalAndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.TripleDES.class.getName());
put("Cipher.PBEWithHMacHavalAndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacHaval.Twofish.class.getName());
@@ -228,8 +216,7 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.AES.class.getName());
put("Cipher.PBEWithHMacSHA256AndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacSHA256AndBlowfish",
+ put("Cipher.PBEWithHMacSHA256AndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Blowfish.class.getName());
put("Cipher.PBEWithHMacSHA256AndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Cast5.class.getName());
@@ -237,24 +224,20 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.DES.class.getName());
put("Cipher.PBEWithHMacSHA256AndKhazad",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Khazad.class.getName());
- put(
- "Cipher.PBEWithHMacSHA256AndSerpent",
+ put("Cipher.PBEWithHMacSHA256AndSerpent",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Serpent.class.getName());
put("Cipher.PBEWithHMacSHA256AndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Square.class.getName());
- put(
- "Cipher.PBEWithHMacSHA256AndTripleDES",
+ put("Cipher.PBEWithHMacSHA256AndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.TripleDES.class.getName());
- put(
- "Cipher.PBEWithHMacSHA256AndTwofish",
+ put("Cipher.PBEWithHMacSHA256AndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA256.Twofish.class.getName());
put("Cipher.PBEWithHMacSHA384AndAES",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.AES.class.getName());
put("Cipher.PBEWithHMacSHA384AndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacSHA384AndBlowfish",
+ put("Cipher.PBEWithHMacSHA384AndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Blowfish.class.getName());
put("Cipher.PBEWithHMacSHA384AndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Cast5.class.getName());
@@ -262,24 +245,20 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.DES.class.getName());
put("Cipher.PBEWithHMacSHA384AndKhazad",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Khazad.class.getName());
- put(
- "Cipher.PBEWithHMacSHA384AndSerpent",
+ put("Cipher.PBEWithHMacSHA384AndSerpent",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Serpent.class.getName());
put("Cipher.PBEWithHMacSHA384AndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Square.class.getName());
- put(
- "Cipher.PBEWithHMacSHA384AndTripleDES",
+ put("Cipher.PBEWithHMacSHA384AndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.TripleDES.class.getName());
- put(
- "Cipher.PBEWithHMacSHA384AndTwofish",
+ put("Cipher.PBEWithHMacSHA384AndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA384.Twofish.class.getName());
put("Cipher.PBEWithHMacSHA512AndAES",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.AES.class.getName());
put("Cipher.PBEWithHMacSHA512AndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacSHA512AndBlowfish",
+ put("Cipher.PBEWithHMacSHA512AndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Blowfish.class.getName());
put("Cipher.PBEWithHMacSHA512AndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Cast5.class.getName());
@@ -287,24 +266,20 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.DES.class.getName());
put("Cipher.PBEWithHMacSHA512AndKhazad",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Khazad.class.getName());
- put(
- "Cipher.PBEWithHMacSHA512AndSerpent",
+ put("Cipher.PBEWithHMacSHA512AndSerpent",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Serpent.class.getName());
put("Cipher.PBEWithHMacSHA512AndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Square.class.getName());
- put(
- "Cipher.PBEWithHMacSHA512AndTripleDES",
+ put("Cipher.PBEWithHMacSHA512AndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.TripleDES.class.getName());
- put(
- "Cipher.PBEWithHMacSHA512AndTwofish",
+ put("Cipher.PBEWithHMacSHA512AndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacSHA512.Twofish.class.getName());
put("Cipher.PBEWithHMacTigerAndAES",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.AES.class.getName());
put("Cipher.PBEWithHMacTigerAndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacTigerAndBlowfish",
+ put("Cipher.PBEWithHMacTigerAndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Blowfish.class.getName());
put("Cipher.PBEWithHMacTigerAndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Cast5.class.getName());
@@ -316,44 +291,44 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Serpent.class.getName());
put("Cipher.PBEWithHMacTigerAndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Square.class.getName());
- put(
- "Cipher.PBEWithHMacTigerAndTripleDES",
+ put("Cipher.PBEWithHMacTigerAndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.TripleDES.class.getName());
put("Cipher.PBEWithHMacTigerAndTwofish",
gnu.javax.crypto.jce.cipher.PBES2.HMacTiger.Twofish.class.getName());
put("Cipher.PBEWithHMacWhirlpoolAndAES",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.AES.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndAnubis",
+ put("Cipher.PBEWithHMacWhirlpoolAndAnubis",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Anubis.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndBlowfish",
+ put("Cipher.PBEWithHMacWhirlpoolAndBlowfish",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Blowfish.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndCast5",
+ put("Cipher.PBEWithHMacWhirlpoolAndCast5",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Cast5.class.getName());
put("Cipher.PBEWithHMacWhirlpoolAndDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.DES.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndKhazad",
+ put("Cipher.PBEWithHMacWhirlpoolAndKhazad",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Khazad.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndSerpent",
+ put("Cipher.PBEWithHMacWhirlpoolAndSerpent",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Serpent.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndSquare",
+ put("Cipher.PBEWithHMacWhirlpoolAndSquare",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.Square.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndTripleDES",
+ put("Cipher.PBEWithHMacWhirlpoolAndTripleDES",
gnu.javax.crypto.jce.cipher.PBES2.HMacWhirlpool.TripleDES.class.getName());
- put(
- "Cipher.PBEWithHMacWhirlpoolAndTwofish",
+ 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",
+ put("SecretKeyFactory.PBKDF2WithHMacHaval",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacHaval.class.getName());
put("SecretKeyFactory.PBKDF2WithHMacMD2",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacMD2.class.getName());
@@ -361,30 +336,23 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacMD4.class.getName());
put("SecretKeyFactory.PBKDF2WithHMacMD5",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacMD5.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacSHA1",
+ put("SecretKeyFactory.PBKDF2WithHMacSHA1",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacSHA1.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacSHA256",
+ put("SecretKeyFactory.PBKDF2WithHMacSHA256",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacSHA256.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacSHA384",
+ put("SecretKeyFactory.PBKDF2WithHMacSHA384",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacSHA384.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacSHA512",
+ put("SecretKeyFactory.PBKDF2WithHMacSHA512",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacSHA512.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacTiger",
+ put("SecretKeyFactory.PBKDF2WithHMacTiger",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacTiger.class.getName());
- put(
- "SecretKeyFactory.PBKDF2WithHMacWhirlpool",
+ put("SecretKeyFactory.PBKDF2WithHMacWhirlpool",
gnu.javax.crypto.jce.PBKDF2SecretKeyFactory.HMacWhirlpool.class.getName());
// Simple SecretKeyFactory implementations.
put("SecretKeyFactory.Anubis",
gnu.javax.crypto.jce.key.AnubisSecretKeyFactoryImpl.class.getName());
- put(
- "SecretKeyFactory.Blowfish",
+ put("SecretKeyFactory.Blowfish",
gnu.javax.crypto.jce.key.BlowfishSecretKeyFactoryImpl.class.getName());
put("SecretKeyFactory.Cast5",
gnu.javax.crypto.jce.key.Cast5SecretKeyFactoryImpl.class.getName());
@@ -392,11 +360,9 @@ public final class GnuCrypto extends Provider
gnu.javax.crypto.jce.key.DESSecretKeyFactoryImpl.class.getName());
put("SecretKeyFactory.Khazad",
gnu.javax.crypto.jce.key.KhazadSecretKeyFactoryImpl.class.getName());
- put(
- "SecretKeyFactory.Rijndael",
+ put("SecretKeyFactory.Rijndael",
gnu.javax.crypto.jce.key.RijndaelSecretKeyFactoryImpl.class.getName());
- put(
- "SecretKeyFactory.Serpent",
+ put("SecretKeyFactory.Serpent",
gnu.javax.crypto.jce.key.SerpentSecretKeyFactoryImpl.class.getName());
put("SecretKeyFactory.Square",
gnu.javax.crypto.jce.key.SquareSecretKeyFactoryImpl.class.getName());
@@ -409,7 +375,19 @@ public final class GnuCrypto extends Provider
put("AlgorithmParameters.BlockCipherParameters",
gnu.javax.crypto.jce.params.BlockCipherParameters.class.getName());
-
+ put("Alg.Alias.AlgorithmParameters.Anubis", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Blowfish", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Cast5", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.DES", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Khazad", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Rijndael", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.AES", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Serpent", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.Square", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.TripleDES", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.DESede", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.3-DES", "BlockCipherParameters");
+ put("Alg.Alias.AlgorithmParameters.3DES", "BlockCipherParameters");
// KeyGenerator Adapter implementations
put("KeyGenerator.Anubis",
@@ -541,19 +519,25 @@ public final class GnuCrypto extends Provider
put("Alg.Alias.Cipher.RSA", "RSAES-PKCS1-v1_5");
// SecureRandom
- put("SecureRandom.ARCFOUR", gnu.javax.crypto.jce.prng.ARCFourRandomSpi.class.getName());
+ put("SecureRandom.ARCFOUR",
+ gnu.javax.crypto.jce.prng.ARCFourRandomSpi.class.getName());
put("SecureRandom.ARCFOUR ImplementedIn", "Software");
- put("SecureRandom.CSPRNG", gnu.javax.crypto.jce.prng.CSPRNGSpi.class.getName());
+ put("SecureRandom.CSPRNG",
+ gnu.javax.crypto.jce.prng.CSPRNGSpi.class.getName());
put("SecureRandom.CSPRNG ImplementedIn", "Software");
- put("SecureRandom.ICM", gnu.javax.crypto.jce.prng.ICMRandomSpi.class.getName());
+ put("SecureRandom.ICM",
+ gnu.javax.crypto.jce.prng.ICMRandomSpi.class.getName());
put("SecureRandom.ICM ImplementedIn", "Software");
- put("SecureRandom.UMAC-KDF", gnu.javax.crypto.jce.prng.UMacRandomSpi.class.getName());
+ put("SecureRandom.UMAC-KDF",
+ gnu.javax.crypto.jce.prng.UMacRandomSpi.class.getName());
put("SecureRandom.UMAC-KDF ImplementedIn", "Software");
- put("SecureRandom.Fortuna", gnu.javax.crypto.jce.prng.FortunaImpl.class.getName ());
+ put("SecureRandom.Fortuna",
+ gnu.javax.crypto.jce.prng.FortunaImpl.class.getName());
put("SecureRandom.Fortuna ImplementedIn", "Software");
// KeyStore
- put("KeyStore.GKR", gnu.javax.crypto.jce.keyring.GnuKeyring.class.getName());
+ put("KeyStore.GKR",
+ gnu.javax.crypto.jce.keyring.GnuKeyring.class.getName());
put("Alg.Alias.KeyStore.GnuKeyring", "GKR");
// KeyPairGenerator ---------------------------------------------------
@@ -587,13 +571,10 @@ public final class GnuCrypto extends Provider
});
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a {@link Set} of names of symmetric key block cipher algorithms
- * available from this {@link Provider}.</p>
- *
+ * Returns a {@link Set} of names of symmetric key block cipher algorithms
+ * available from this {@link Provider}.
+ *
* @return a {@link Set} of cipher names (Strings).
*/
public static final Set getCipherNames()
@@ -605,16 +586,13 @@ public final class GnuCrypto extends Provider
}
/**
- * <p>Returns a {@link Set} of names of MAC algorithms available from
- * this {@link Provider}.</p>
- *
+ * Returns a {@link Set} of names of MAC algorithms available from this
+ * {@link Provider}.
+ *
* @return a {@link Set} of MAC names (Strings).
*/
public static final Set getMacNames()
{
return MacFactory.getNames();
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/GnuSasl.java b/libjava/classpath/gnu/javax/crypto/jce/GnuSasl.java
index 6ee86ae19d5..923b40a5f92 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/GnuSasl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/GnuSasl.java
@@ -47,53 +47,63 @@ import java.security.PrivilegedAction;
import java.security.Provider;
import java.util.Set;
-public final class GnuSasl extends Provider
+public final class GnuSasl
+ extends Provider
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public GnuSasl()
{
- super (Registry.GNU_SASL, 2.1, "GNU Crypto SASL Provider");
+ super(Registry.GNU_SASL, 2.1, "GNU SASL Provider");
- AccessController.doPrivileged (new PrivilegedAction()
+ AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
{
- public Object run()
- {
- // SASL Client and Server mechanisms
- put("SaslClientFactory.ANONYMOUS", gnu.javax.crypto.sasl.ClientFactory.class.getName());
- put("SaslClientFactory.PLAIN", gnu.javax.crypto.sasl.ClientFactory.class.getName());
- put("SaslClientFactory.CRAM-MD5", gnu.javax.crypto.sasl.ClientFactory.class.getName());
- put("SaslClientFactory.SRP", gnu.javax.crypto.sasl.ClientFactory.class.getName());
-
- put("SaslServerFactory.ANONYMOUS", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.PLAIN", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.CRAM-MD5", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-MD5", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-SHA-160", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-RIPEMD128", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-RIPEMD160", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-TIGER", gnu.javax.crypto.sasl.ServerFactory.class.getName());
- put("SaslServerFactory.SRP-WHIRLPOOL", gnu.javax.crypto.sasl.ServerFactory.class.getName());
-
- put("Alg.Alias.SaslServerFactory.SRP-SHS", "SRP-SHA-160");
- put("Alg.Alias.SaslServerFactory.SRP-SHA", "SRP-SHA-160");
- put("Alg.Alias.SaslServerFactory.SRP-SHA1", "SRP-SHA-160");
- put("Alg.Alias.SaslServerFactory.SRP-SHA-1", "SRP-SHA-160");
- put("Alg.Alias.SaslServerFactory.SRP-SHA160", "SRP-SHA-160");
- put("Alg.Alias.SaslServerFactory.SRP-RIPEMD-128", "SRP-RIPEMD128");
- put("Alg.Alias.SaslServerFactory.SRP-RIPEMD-160", "SRP-RIPEMD160");
-
- return null;
- }
- });
+ // SASL Client and Server mechanisms
+ put("SaslClientFactory.ANONYMOUS",
+ gnu.javax.crypto.sasl.ClientFactory.class.getName());
+ put("SaslClientFactory.PLAIN",
+ gnu.javax.crypto.sasl.ClientFactory.class.getName());
+ put("SaslClientFactory.CRAM-MD5",
+ gnu.javax.crypto.sasl.ClientFactory.class.getName());
+ put("SaslClientFactory.SRP",
+ gnu.javax.crypto.sasl.ClientFactory.class.getName());
+
+ put("SaslServerFactory.ANONYMOUS",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.PLAIN",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.CRAM-MD5",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-MD5",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-SHA-160",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-RIPEMD128",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-RIPEMD160",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-TIGER",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+ put("SaslServerFactory.SRP-WHIRLPOOL",
+ gnu.javax.crypto.sasl.ServerFactory.class.getName());
+
+ put("Alg.Alias.SaslServerFactory.SRP-SHS", "SRP-SHA-160");
+ put("Alg.Alias.SaslServerFactory.SRP-SHA", "SRP-SHA-160");
+ put("Alg.Alias.SaslServerFactory.SRP-SHA1", "SRP-SHA-160");
+ put("Alg.Alias.SaslServerFactory.SRP-SHA-1", "SRP-SHA-160");
+ put("Alg.Alias.SaslServerFactory.SRP-SHA160", "SRP-SHA-160");
+ put("Alg.Alias.SaslServerFactory.SRP-RIPEMD-128", "SRP-RIPEMD128");
+ put("Alg.Alias.SaslServerFactory.SRP-RIPEMD-160", "SRP-RIPEMD160");
+
+ return null;
+ }
+ });
}
/**
- * <p>Returns a {@link Set} of names of SASL Client mechanisms available from
- * this {@link Provider}.</p>
- *
+ * Returns a {@link Set} of names of SASL Client mechanisms available from
+ * this {@link Provider}.
+ *
* @return a {@link Set} of SASL Client mechanisms (Strings).
*/
public static final Set getSaslClientMechanismNames()
@@ -102,9 +112,9 @@ public final class GnuSasl extends Provider
}
/**
- * <p>Returns a {@link Set} of names of SASL Server mechanisms available from
- * this {@link Provider}.</p>
- *
+ * Returns a {@link Set} of names of SASL Server mechanisms available from
+ * this {@link Provider}.
+ *
* @return a {@link Set} of SASL Server mechanisms (Strings).
*/
public static final Set getSaslServerMechanismNames()
diff --git a/libjava/classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java b/libjava/classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java
index 59231c6c71d..be7fb18b0d5 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/PBKDF2SecretKeyFactory.java
@@ -53,57 +53,38 @@ import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
import gnu.javax.crypto.prng.PRNGFactory;
-public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
+public abstract class PBKDF2SecretKeyFactory
+ extends SecretKeyFactorySpi
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
protected String macName;
-
private static final int DEFAULT_ITERATION_COUNT = 1000;
-
private static final int DEFAULT_KEY_LEN = 32;
- // Constructor.
- // ------------------------------------------------------------------------
-
protected PBKDF2SecretKeyFactory(String macName)
{
this.macName = macName;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
protected SecretKey engineGenerateSecret(KeySpec spec)
throws InvalidKeySpecException
{
- if (!(spec instanceof PBEKeySpec))
- {
- throw new InvalidKeySpecException("not a PBEKeySpec");
- }
+ if (! (spec instanceof PBEKeySpec))
+ throw new InvalidKeySpecException("not a PBEKeySpec");
IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName);
HashMap attr = new HashMap();
attr.put(IPBE.PASSWORD, ((PBEKeySpec) spec).getPassword());
byte[] salt = ((PBEKeySpec) spec).getSalt();
if (salt == null)
- {
- salt = new byte[0];
- }
+ salt = new byte[0];
attr.put(IPBE.SALT, salt);
int ic = ((PBEKeySpec) spec).getIterationCount();
if (ic <= 0)
- {
- ic = DEFAULT_ITERATION_COUNT;
- }
- attr.put(IPBE.ITERATION_COUNT, new Integer(ic));
+ ic = DEFAULT_ITERATION_COUNT;
+ attr.put(IPBE.ITERATION_COUNT, Integer.valueOf(ic));
kdf.init(attr);
int len = ((PBEKeySpec) spec).getKeyLength();
if (len <= 0)
- {
- len = DEFAULT_KEY_LEN;
- }
+ len = DEFAULT_KEY_LEN;
byte[] dk = new byte[len];
try
{
@@ -113,7 +94,6 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
{
throw new IllegalArgumentException(lre.toString());
}
-
return new SecretKeySpec(dk, "PBKDF2");
}
@@ -128,10 +108,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
return new SecretKeySpec(key.getEncoded(), key.getAlgorithm());
}
- // Inner classes.
- // ------------------------------------------------------------------------
-
- public static class HMacHaval extends PBKDF2SecretKeyFactory
+ public static class HMacHaval
+ extends PBKDF2SecretKeyFactory
{
public HMacHaval()
{
@@ -139,7 +117,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacMD2 extends PBKDF2SecretKeyFactory
+ public static class HMacMD2
+ extends PBKDF2SecretKeyFactory
{
public HMacMD2()
{
@@ -147,7 +126,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacMD4 extends PBKDF2SecretKeyFactory
+ public static class HMacMD4
+ extends PBKDF2SecretKeyFactory
{
public HMacMD4()
{
@@ -155,7 +135,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacMD5 extends PBKDF2SecretKeyFactory
+ public static class HMacMD5
+ extends PBKDF2SecretKeyFactory
{
public HMacMD5()
{
@@ -163,7 +144,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacRipeMD128 extends PBKDF2SecretKeyFactory
+ public static class HMacRipeMD128
+ extends PBKDF2SecretKeyFactory
{
public HMacRipeMD128()
{
@@ -171,7 +153,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacRipeMD160 extends PBKDF2SecretKeyFactory
+ public static class HMacRipeMD160
+ extends PBKDF2SecretKeyFactory
{
public HMacRipeMD160()
{
@@ -179,7 +162,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacSHA1 extends PBKDF2SecretKeyFactory
+ public static class HMacSHA1
+ extends PBKDF2SecretKeyFactory
{
public HMacSHA1()
{
@@ -187,7 +171,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacSHA256 extends PBKDF2SecretKeyFactory
+ public static class HMacSHA256
+ extends PBKDF2SecretKeyFactory
{
public HMacSHA256()
{
@@ -195,7 +180,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacSHA384 extends PBKDF2SecretKeyFactory
+ public static class HMacSHA384
+ extends PBKDF2SecretKeyFactory
{
public HMacSHA384()
{
@@ -203,7 +189,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacSHA512 extends PBKDF2SecretKeyFactory
+ public static class HMacSHA512
+ extends PBKDF2SecretKeyFactory
{
public HMacSHA512()
{
@@ -211,7 +198,8 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacTiger extends PBKDF2SecretKeyFactory
+ public static class HMacTiger
+ extends PBKDF2SecretKeyFactory
{
public HMacTiger()
{
@@ -219,11 +207,12 @@ public abstract class PBKDF2SecretKeyFactory extends SecretKeyFactorySpi
}
}
- public static class HMacWhirlpool extends PBKDF2SecretKeyFactory
+ public static class HMacWhirlpool
+ extends PBKDF2SecretKeyFactory
{
public HMacWhirlpool()
{
super("HMAC-WHIRLPOOL");
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java
new file mode 100644
index 00000000000..14ce480ae6f
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java
new file mode 100644
index 00000000000..784fc5a1516
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java
new file mode 100644
index 00000000000..dd7357b0e09
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java
new file mode 100644
index 00000000000..973f5890bb4
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
index 33de6895613..1322e5e8a1a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
@@ -50,23 +50,17 @@ import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
/**
- * The implementation of the AES <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.
+ * The implementation of the AES <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter.
*/
-public final class AESSpi extends CipherAdapter
+public final class AESSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public AESSpi()
{
super(Registry.AES_CIPHER, 16);
}
- // Methods from CipherAdapter
- // -----------------------------------------------------------------------
-
protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException,
InvalidAlgorithmParameterException
@@ -74,10 +68,8 @@ public final class AESSpi extends CipherAdapter
if (params instanceof BlockCipherParameterSpec)
{
if (((BlockCipherParameterSpec) params).getBlockSize() != 16)
- {
- throw new InvalidAlgorithmParameterException(
- "AES block size must be 16 bytes");
- }
+ throw new InvalidAlgorithmParameterException(
+ "AES block size must be 16 bytes");
}
super.engineInit(opmode, key, params, random);
}
@@ -90,9 +82,7 @@ public final class AESSpi extends CipherAdapter
try
{
if (params != null)
- {
- spec = params.getParameterSpec(BlockCipherParameterSpec.class);
- }
+ spec = params.getParameterSpec(BlockCipherParameterSpec.class);
}
catch (InvalidParameterSpecException ipse)
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
index 963fa1c0081..abcb486b59b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
@@ -62,29 +62,20 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
/**
- * The <i>Service Provider Interface</i> (<b>SPI</b>) for the ARCFOUR
- * stream cipher.
+ * The <i>Service Provider Interface</i> (<b>SPI</b>) for the ARCFOUR stream
+ * cipher.
*/
-public class ARCFourSpi extends CipherSpi
+public class ARCFourSpi
+ extends CipherSpi
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
private IRandom keystream;
- // Constructors.
- // -----------------------------------------------------------------------
-
public ARCFourSpi()
{
super();
keystream = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG);
}
- // Methods implementing CipherSpi.
- // -----------------------------------------------------------------------
-
protected int engineGetBlockSize()
{
return 0; // stream cipher.
@@ -119,14 +110,10 @@ public class ARCFourSpi extends CipherSpi
throws InvalidKeyException
{
if (mode != Cipher.ENCRYPT_MODE && mode != Cipher.DECRYPT_MODE)
- {
- throw new IllegalArgumentException(
- "arcfour is for encryption or decryption only");
- }
- if (key == null || !key.getFormat().equalsIgnoreCase("RAW"))
- {
- throw new InvalidKeyException("key must be non-null raw bytes");
- }
+ throw new IllegalArgumentException(
+ "arcfour is for encryption or decryption only");
+ if (key == null || ! key.getFormat().equalsIgnoreCase("RAW"))
+ throw new InvalidKeyException("key must be non-null raw bytes");
HashMap attrib = new HashMap();
attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key.getEncoded());
keystream.init(attrib);
@@ -149,16 +136,12 @@ public class ARCFourSpi extends CipherSpi
protected byte[] engineUpdate(byte[] in, int offset, int length)
{
if (length < 0 || offset < 0 || length + offset > in.length)
- {
- throw new ArrayIndexOutOfBoundsException();
- }
+ throw new ArrayIndexOutOfBoundsException();
byte[] result = new byte[length];
try
{
for (int i = 0; i < length; i++)
- {
- result[i] = (byte) (in[i + offset] ^ keystream.nextByte());
- }
+ result[i] = (byte)(in[i + offset] ^ keystream.nextByte());
}
catch (LimitReachedException wontHappen)
{
@@ -171,19 +154,13 @@ public class ARCFourSpi extends CipherSpi
{
if (length < 0 || inOffset < 0 || length + inOffset > in.length
|| outOffset < 0)
- {
- throw new ArrayIndexOutOfBoundsException();
- }
+ throw new ArrayIndexOutOfBoundsException();
if (outOffset + length > out.length)
- {
- throw new ShortBufferException();
- }
+ throw new ShortBufferException();
try
{
for (int i = 0; i < length; i++)
- {
- out[i + outOffset] = (byte) (in[i + inOffset] ^ keystream.nextByte());
- }
+ out[i + outOffset] = (byte)(in[i + inOffset] ^ keystream.nextByte());
}
catch (LimitReachedException wontHappen)
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
index 0fca3b49104..e35e4e724ac 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Anubis <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class AnubisSpi extends CipherAdapter
+public final class AnubisSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public AnubisSpi()
{
super(Registry.ANUBIS_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
index d31d7e19390..fec200ca6c9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Blowfish <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class BlowfishSpi extends CipherAdapter
+public final class BlowfishSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public BlowfishSpi()
{
super(Registry.BLOWFISH_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java
index b1d4cf70374..bf080340001 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java
@@ -43,26 +43,12 @@ import gnu.java.security.Registry;
/**
* The implementation of the <code>CAST5</code> (a.k.a. CAST-128) <i>Service
* Provider Interface</i> (<b>SPI</b>) Adapter.
- *
- * @version Revision: $
*/
-public class Cast5Spi extends CipherAdapter
+public class Cast5Spi
+ extends CipherAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public Cast5Spi()
{
super(Registry.CAST5_CIPHER);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
index 5eaa31b779b..b7cd755f5b4 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
@@ -38,8 +38,9 @@ exception statement from your version. */
package gnu.javax.crypto.jce.cipher;
-import gnu.javax.crypto.cipher.IBlockCipher;
+import gnu.java.security.Registry;
import gnu.javax.crypto.cipher.CipherFactory;
+import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.jce.spec.BlockCipherParameterSpec;
import gnu.javax.crypto.mode.IMode;
import gnu.javax.crypto.mode.ModeFactory;
@@ -56,6 +57,7 @@ import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.crypto.BadPaddingException;
@@ -67,61 +69,48 @@ import javax.crypto.ShortBufferException;
import javax.crypto.spec.IvParameterSpec;
/**
- * <p>The implementation of a generic {@link Cipher} <i>Adapter</i> class to
- * wrap GNU Crypto cipher instances.</p>
- *
- * <p>This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * The implementation of a generic {@link Cipher} <i>Adapter</i> class to wrap
+ * GNU cipher instances.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link Cipher} class, which provides the functionality of symmetric-key
- * block ciphers, such as the AES.<p>
- *
- * <p>This base class defines all of the abstract methods in {@link CipherSpi},
+ * block ciphers, such as the AES.
+ * <p>
+ * This base class defines all of the abstract methods in {@link CipherSpi},
* but does not define the (non-abstract) key wrapping functions that extended
* the base cipher SPI, and these methods thus immediately throw an
* {@link UnsupportedOperationException}. If a cipher implementation provides
* this functionality, or if it in fact accepts parameters other than the key
* and the initialization vector, the subclass should override those methods.
* Otherwise a subclass need only call the {@link #CipherAdapter(String)}
- * constructor with the name of the cipher.</p>
+ * constructor with the name of the cipher.
*/
-class CipherAdapter extends CipherSpi
+class CipherAdapter
+ extends CipherSpi
{
-
- // Constants and variables.
- // -------------------------------------------------------------------------
-
/** Our cipher instance. */
protected IBlockCipher cipher;
-
/** Our mode instance. */
protected IMode mode;
-
/** Our padding instance. */
protected IPad pad;
-
/** The current key size. */
protected int keyLen;
-
/** Our attributes map. */
protected Map attributes;
-
/** An incomplete block. */
protected byte[] partBlock;
-
/** The number of bytes in {@link #partBlock}. */
protected int partLen;
-
/** The length of blocks we are processing. */
protected int blockLen;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Protected constructor to be called by subclasses. The cipher name
- * argument should be the appropriate one listed in {@link gnu.crypto.Registry}.
- * The basic cipher instance is created, along with an instance of the
- * {@link gnu.crypto.mode.ECB} mode and no padding.</p>
- *
+ * Protected constructor to be called by subclasses. The cipher name argument
+ * should be the appropriate one listed in {@link Registry}. The basic cipher
+ * instance is created, along with an instance of the
+ * {@link gnu.javax.crypto.mode.ECB} mode and no padding.
+ *
* @param cipherName The cipher to instantiate.
* @param blockLen The block length to use.
*/
@@ -131,12 +120,12 @@ class CipherAdapter extends CipherSpi
attributes = new HashMap();
this.blockLen = blockLen;
mode = ModeFactory.getInstance("ECB", cipher, blockLen);
- attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen));
+ attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(blockLen));
}
/**
- * <p>Creates a new cipher adapter with the default block size.</p>
- *
+ * Creates a new cipher adapter with the default block size.
+ *
* @param cipherName The cipher to instantiate.
*/
protected CipherAdapter(String cipherName)
@@ -145,12 +134,9 @@ class CipherAdapter extends CipherSpi
blockLen = cipher.defaultBlockSize();
attributes = new HashMap();
mode = ModeFactory.getInstance("ECB", cipher, blockLen);
- attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen));
+ attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(blockLen));
}
- // Instance methods implementing javax.crypto.CipherSpi.
- // -------------------------------------------------------------------------
-
protected void engineSetMode(String modeName) throws NoSuchAlgorithmException
{
if (modeName.length() >= 3
@@ -161,7 +147,7 @@ class CipherAdapter extends CipherSpi
try
{
int bs = Integer.parseInt(modeName.substring(3));
- attributes.put(IMode.MODE_BLOCK_SIZE, new Integer(bs / 8));
+ attributes.put(IMode.MODE_BLOCK_SIZE, Integer.valueOf(bs / 8));
}
catch (NumberFormatException nfe)
{
@@ -171,14 +157,10 @@ class CipherAdapter extends CipherSpi
}
}
else
- {
- attributes.remove(IMode.MODE_BLOCK_SIZE);
- }
+ attributes.remove(IMode.MODE_BLOCK_SIZE);
mode = ModeFactory.getInstance(modeName, cipher, blockLen);
if (mode == null)
- {
- throw new NoSuchAlgorithmException(modeName);
- }
+ throw new NoSuchAlgorithmException(modeName);
}
protected void engineSetPadding(String padName) throws NoSuchPaddingException
@@ -190,17 +172,13 @@ class CipherAdapter extends CipherSpi
}
pad = PadFactory.getInstance(padName);
if (pad == null)
- {
- throw new NoSuchPaddingException(padName);
- }
+ throw new NoSuchPaddingException(padName);
}
protected int engineGetBlockSize()
{
if (cipher != null)
- {
- return blockLen;
- }
+ return blockLen;
return 0;
}
@@ -214,17 +192,16 @@ class CipherAdapter extends CipherSpi
{
byte[] iv = (byte[]) attributes.get(IMode.IV);
if (iv == null)
- {
- return null;
- }
+ return null;
return (byte[]) iv.clone();
}
protected AlgorithmParameters engineGetParameters()
{
- BlockCipherParameterSpec spec = new BlockCipherParameterSpec(
- (byte[]) attributes.get(IMode.IV),
- cipher.currentBlockSize(),
+ byte[] iv = (byte[]) attributes.get(IMode.IV);
+ int cipherBlockSize = cipher.currentBlockSize();
+ BlockCipherParameterSpec spec = new BlockCipherParameterSpec(iv,
+ cipherBlockSize,
keyLen);
AlgorithmParameters params;
try
@@ -246,25 +223,75 @@ class CipherAdapter extends CipherSpi
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException
{
+ try
+ {
+ engineInit(opmode, key, (AlgorithmParameterSpec) null, random);
+ }
+ catch (InvalidAlgorithmParameterException e)
+ {
+ throw new InvalidKeyException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Executes initialization logic after all parameters have been handled by the
+ * engineInit()s.
+ *
+ * @param opmode the desired mode of operation for this instance.
+ * @param key the key material to use for initialization.
+ * @param random a source of randmoness to use if/when needed.
+ * @throws InvalidKeyException if <code>key</code> is invalid or the cipher
+ * needs extra parameters which can not be derived from
+ * <code>key</code>; e.g. an IV.
+ */
+ private void engineInitHandler(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException
+ {
switch (opmode)
{
case Cipher.ENCRYPT_MODE:
- attributes.put(IMode.STATE, new Integer(IMode.ENCRYPTION));
+ attributes.put(IMode.STATE, Integer.valueOf(IMode.ENCRYPTION));
break;
case Cipher.DECRYPT_MODE:
- attributes.put(IMode.STATE, new Integer(IMode.DECRYPTION));
+ attributes.put(IMode.STATE, Integer.valueOf(IMode.DECRYPTION));
break;
}
- if (!key.getFormat().equalsIgnoreCase("RAW"))
- {
- throw new InvalidKeyException("bad key format " + key.getFormat());
- }
+ if (! key.getFormat().equalsIgnoreCase("RAW"))
+ throw new InvalidKeyException("bad key format " + key.getFormat());
byte[] kb = key.getEncoded();
+ int kbLength = kb.length;
if (keyLen == 0)
{
- keyLen = kb.length;
+ // no key-size given; instead key-material is provided in kb --which
+ // can be more than what we need. if we don't cull this down to what
+ // the cipher likes/wants we may get an InvalidKeyException.
+ //
+ // try to find the largest key-size value that is less than or equal
+ // to kbLength
+ for (Iterator it = cipher.keySizes(); it.hasNext();)
+ {
+ int aKeySize = ((Integer) it.next()).intValue();
+ if (aKeySize == kbLength)
+ {
+ keyLen = aKeySize;
+ break;
+ }
+ else if (aKeySize < kbLength)
+ keyLen = aKeySize;
+ else // all remaining key-sizes are longer than kb.length
+ break;
+ }
}
- else if (keyLen < kb.length)
+ if (keyLen == 0)
+ {
+ // we were unable to find a key-size, among those advertised by the
+ // cipher, that is less than or equal to the length of the kb array.
+ // set keyLen to kbLength. either the cipher implementation will throw
+ // an InvalidKeyException, or it is implemented in a way which can deal
+ // with an unsupported key-size.
+ keyLen = kbLength;
+ }
+ if (keyLen < kbLength)
{
byte[] kbb = kb;
kb = new byte[keyLen];
@@ -280,31 +307,54 @@ class CipherAdapter extends CipherSpi
{
if (params == null)
{
- byte[] iv = new byte[blockLen];
- random.nextBytes(iv);
- attributes.put(IMode.IV, iv);
+ // All cipher modes require parameters (like an IV) except ECB. When
+ // these cant be derived from the given key then it must be generated
+ // randomly if in ENCRYPT or WRAP mode. Parameters that have defaults
+ // for our cipher must be set to these defaults.
+ if (! mode.name().toLowerCase().startsWith(Registry.ECB_MODE + "("))
+ {
+ switch (opmode)
+ {
+ case Cipher.ENCRYPT_MODE:
+ case Cipher.WRAP_MODE:
+ byte[] iv = new byte[blockLen];
+ random.nextBytes(iv);
+ attributes.put(IMode.IV, iv);
+ break;
+ default:
+ throw new InvalidAlgorithmParameterException(
+ "Required algorithm parameters are missing for mode: "
+ + mode.name());
+ }
+ }
+ // Add default for block length etc.
blockLen = cipher.defaultBlockSize();
- attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(blockLen));
+ attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE,
+ Integer.valueOf(blockLen));
keyLen = 0;
}
else if (params instanceof BlockCipherParameterSpec)
{
- attributes.put(
- IBlockCipher.CIPHER_BLOCK_SIZE,
- new Integer(
- ((BlockCipherParameterSpec) params).getBlockSize()));
- attributes.put(IMode.IV, ((BlockCipherParameterSpec) params).getIV());
- keyLen = ((BlockCipherParameterSpec) params).getKeySize();
- blockLen = ((BlockCipherParameterSpec) params).getBlockSize();
+ BlockCipherParameterSpec bcps = (BlockCipherParameterSpec) params;
+ blockLen = bcps.getBlockSize();
+ attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(blockLen));
+ attributes.put(IMode.IV, bcps.getIV());
+ keyLen = bcps.getKeySize();
}
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, new Integer(blockLen));
+ attributes.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(blockLen));
keyLen = 0;
}
- engineInit(opmode, key, random);
+ engineInitHandler(opmode, key, random);
}
protected void engineInit(int opmode, Key key, AlgorithmParameters params,
@@ -315,9 +365,7 @@ class CipherAdapter extends CipherSpi
try
{
if (params != null)
- {
- spec = params.getParameterSpec(BlockCipherParameterSpec.class);
- }
+ spec = params.getParameterSpec(BlockCipherParameterSpec.class);
}
catch (InvalidParameterSpecException ignored)
{
@@ -334,91 +382,50 @@ class CipherAdapter extends CipherSpi
{
engineUpdate(input, off, len, out, 0);
}
- catch (ShortBufferException x)
- { // should not happen
+ catch (ShortBufferException x) // should not happen
+ {
x.printStackTrace(System.err);
}
return out;
}
- // protected int
- // engineUpdate(byte[] in, int inOff, int inLen, byte[] out, int outOff)
- // throws ShortBufferException
- // {
- // int blockSize = mode.currentBlockSize();
- // int count = (partLen + inLen) / blockSize;
- // if (count * blockSize > out.length - outOff) {
- // throw new ShortBufferException();
- // }
- // byte[] buf;
- // if (partLen > 0 && count > 0) {
- // buf = new byte[partLen + inLen];
- // System.arraycopy(partBlock, 0, buf, 0, partLen);
- // if (in != null && inLen > 0) {
- // System.arraycopy(in, inOff, buf, partLen, inLen);
- // }
- // partLen = 0;
- // inOff = 0;
- // } else {
- // buf = in;
- // }
- // for (int i = 0; i < count; i++) {
- // mode.update(buf, i * blockSize + inOff, out, i * blockSize + outOff);
- // }
- // if (inOff + inLen > count * blockSize) {
- // partLen = (inOff + inLen) - (count * blockSize);
- // System.arraycopy(in, count * blockSize, partBlock, 0, partLen);
- // }
- // return count * blockSize;
- // }
-
protected int engineUpdate(byte[] in, int inOff, int inLen, byte[] out,
int outOff) throws ShortBufferException
{
- if (inLen == 0)
- { // nothing to process
- return 0;
- }
+ if (inLen == 0) // nothing to process
+ return 0;
final int blockSize = mode.currentBlockSize();
final int blockCount = (partLen + inLen) / blockSize;
final int result = blockCount * blockSize;
if (result > out.length - outOff)
+ throw new ShortBufferException();
+ if (blockCount == 0) // not enough bytes for even 1 block
{
- throw new ShortBufferException();
- }
- if (blockCount == 0)
- { // not enough bytes for even 1 block
System.arraycopy(in, inOff, partBlock, partLen, inLen);
partLen += inLen;
return 0;
}
final byte[] buf;
// we have enough bytes for at least 1 block
- if (partLen == 0)
- { // if no cached bytes use input
- buf = in;
- }
- else
- { // prefix input with cached bytes
+ if (partLen == 0) // if no cached bytes use input
+ buf = in;
+ else // prefix input with cached bytes
+ {
buf = new byte[partLen + inLen];
System.arraycopy(partBlock, 0, buf, 0, partLen);
if (in != null && inLen > 0)
- {
- System.arraycopy(in, inOff, buf, partLen, inLen);
- }
+ System.arraycopy(in, inOff, buf, partLen, inLen);
inOff = 0;
}
- for (int i = 0; i < blockCount; i++)
- { // update blockCount * blockSize
+ for (int i = 0; i < blockCount; i++) // update blockCount * blockSize
+ {
mode.update(buf, inOff, out, outOff);
inOff += blockSize;
outOff += blockSize;
}
partLen += inLen - result;
- if (partLen > 0)
- { // cache remaining bytes from buf
- System.arraycopy(buf, inOff, partBlock, 0, partLen);
- }
+ if (partLen > 0) // cache remaining bytes from buf
+ System.arraycopy(buf, inOff, partBlock, 0, partLen);
return result;
}
@@ -458,9 +465,7 @@ class CipherAdapter extends CipherSpi
else
{
if (partLen > 0)
- {
- throw new IllegalBlockSizeException(partLen + " trailing bytes");
- }
+ throw new IllegalBlockSizeException(partLen + " trailing bytes");
result = buf;
}
@@ -483,9 +488,7 @@ class CipherAdapter extends CipherSpi
{
byte[] buf = engineDoFinal(in, inOff, inLen);
if (out.length + outOff < buf.length)
- {
- throw new ShortBufferException();
- }
+ throw new ShortBufferException();
System.arraycopy(buf, 0, out, outOff, buf.length);
return buf.length;
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
index ff86071c4ee..21f62b4f046 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
@@ -41,15 +41,12 @@ package gnu.javax.crypto.jce.cipher;
import gnu.java.security.Registry;
/**
- * The implementation of the DES <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.
+ * The implementation of the DES <i>Service Provider Interface</i> (<b>SPI</b>)
+ * adapter.
*/
-public final class DESSpi extends CipherAdapter
+public final class DESSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public DESSpi()
{
super(Registry.DES_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java
new file mode 100644
index 00000000000..03356a236f7
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
index 397c27d2ed7..6e744a2f2d9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Khazad <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class KhazadSpi extends CipherAdapter
+public final class KhazadSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public KhazadSpi()
{
super(Registry.KHAZAD_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
index e6d78ef393e..e50e00c8eae 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Null cipher <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class NullCipherSpi extends CipherAdapter
+public final class NullCipherSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public NullCipherSpi()
{
super(Registry.NULL_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
index 9889ab9fc86..26a6a2c2db9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
@@ -55,20 +55,13 @@ import javax.crypto.interfaces.PBEKey;
import javax.crypto.spec.SecretKeySpec;
/**
- * <p>.</p>
*/
-public abstract class PBES2 extends CipherAdapter
+public abstract class PBES2
+ extends CipherAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The HMac (PRF) algorithm name. */
protected String macName;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected PBES2(String cipherName, int blockLen, String macName)
{
super(cipherName, blockLen);
@@ -81,15 +74,11 @@ public abstract class PBES2 extends CipherAdapter
this.macName = macName;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException
{
- if (!(key instanceof PBEKey))
+ if (! (key instanceof PBEKey))
throw new InvalidKeyException("not a PBE key");
-
super.engineInit(opmode, genkey((PBEKey) key), random);
}
@@ -97,9 +86,8 @@ public abstract class PBES2 extends CipherAdapter
SecureRandom random) throws InvalidKeyException,
InvalidAlgorithmParameterException
{
- if (!(key instanceof PBEKey))
+ if (! (key instanceof PBEKey))
throw new InvalidKeyException("not a PBE key");
-
super.engineInit(opmode, genkey((PBEKey) key), params, random);
}
@@ -107,9 +95,8 @@ public abstract class PBES2 extends CipherAdapter
SecureRandom random) throws InvalidKeyException,
InvalidAlgorithmParameterException
{
- if (!(key instanceof PBEKey))
+ if (! (key instanceof PBEKey))
throw new InvalidKeyException("not a PBE key");
-
super.engineInit(opmode, genkey((PBEKey) key), params, random);
}
@@ -117,11 +104,9 @@ public abstract class PBES2 extends CipherAdapter
{
IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName);
if (kdf == null)
- {
- throw new IllegalArgumentException("no such KDF: PBKDF2-" + macName);
- }
+ throw new IllegalArgumentException("no such KDF: PBKDF2-" + macName);
HashMap attrib = new HashMap();
- attrib.put(IPBE.ITERATION_COUNT, new Integer(key.getIterationCount()));
+ attrib.put(IPBE.ITERATION_COUNT, Integer.valueOf(key.getIterationCount()));
attrib.put(IPBE.PASSWORD, key.getPassword());
attrib.put(IPBE.SALT, key.getSalt());
try
@@ -139,21 +124,14 @@ public abstract class PBES2 extends CipherAdapter
}
catch (LimitReachedException shouldNotHappen)
{
- // throw new Error(shouldNotHappen);
throw new Error(String.valueOf(shouldNotHappen));
}
return new SecretKeySpec(dk, cipher.name());
}
- // Inner classe(s)
- // =========================================================================
-
- public static class HMacSHA1 extends PBES2
+ public static class HMacSHA1
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacSHA1(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-SHA1");
@@ -164,10 +142,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-SHA1");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacSHA1
+ public static class AES
+ extends HMacSHA1
{
public AES()
{
@@ -175,7 +151,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacSHA1
+ public static class Anubis
+ extends HMacSHA1
{
public Anubis()
{
@@ -183,7 +160,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacSHA1
+ public static class Blowfish
+ extends HMacSHA1
{
public Blowfish()
{
@@ -191,7 +169,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacSHA1
+ public static class Cast5
+ extends HMacSHA1
{
public Cast5()
{
@@ -199,7 +178,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacSHA1
+ public static class DES
+ extends HMacSHA1
{
public DES()
{
@@ -207,7 +187,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacSHA1
+ public static class Khazad
+ extends HMacSHA1
{
public Khazad()
{
@@ -215,7 +196,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacSHA1
+ public static class Serpent
+ extends HMacSHA1
{
public Serpent()
{
@@ -223,7 +205,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacSHA1
+ public static class Square
+ extends HMacSHA1
{
public Square()
{
@@ -231,7 +214,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacSHA1
+ public static class TripleDES
+ extends HMacSHA1
{
public TripleDES()
{
@@ -239,7 +223,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacSHA1
+ public static class Twofish
+ extends HMacSHA1
{
public Twofish()
{
@@ -248,12 +233,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacMD5 extends PBES2
+ public static class HMacMD5
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacMD5(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-MD5");
@@ -264,10 +246,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-MD5");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacMD5
+ public static class AES
+ extends HMacMD5
{
public AES()
{
@@ -275,7 +255,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacMD5
+ public static class Anubis
+ extends HMacMD5
{
public Anubis()
{
@@ -283,7 +264,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacMD5
+ public static class Blowfish
+ extends HMacMD5
{
public Blowfish()
{
@@ -291,7 +273,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacMD5
+ public static class Cast5
+ extends HMacMD5
{
public Cast5()
{
@@ -299,7 +282,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacMD5
+ public static class DES
+ extends HMacMD5
{
public DES()
{
@@ -307,7 +291,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacMD5
+ public static class Khazad
+ extends HMacMD5
{
public Khazad()
{
@@ -315,7 +300,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacMD5
+ public static class Serpent
+ extends HMacMD5
{
public Serpent()
{
@@ -323,7 +309,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacMD5
+ public static class Square
+ extends HMacMD5
{
public Square()
{
@@ -331,7 +318,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacMD5
+ public static class TripleDES
+ extends HMacMD5
{
public TripleDES()
{
@@ -339,7 +327,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacMD5
+ public static class Twofish
+ extends HMacMD5
{
public Twofish()
{
@@ -348,12 +337,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacMD2 extends PBES2
+ public static class HMacMD2
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacMD2(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-MD2");
@@ -364,10 +350,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-MD2");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacMD2
+ public static class AES
+ extends HMacMD2
{
public AES()
{
@@ -375,7 +359,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacMD2
+ public static class Anubis
+ extends HMacMD2
{
public Anubis()
{
@@ -383,7 +368,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacMD2
+ public static class Blowfish
+ extends HMacMD2
{
public Blowfish()
{
@@ -391,7 +377,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacMD2
+ public static class Cast5
+ extends HMacMD2
{
public Cast5()
{
@@ -399,7 +386,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacMD2
+ public static class DES
+ extends HMacMD2
{
public DES()
{
@@ -407,7 +395,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacMD2
+ public static class Khazad
+ extends HMacMD2
{
public Khazad()
{
@@ -415,7 +404,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacMD2
+ public static class Serpent
+ extends HMacMD2
{
public Serpent()
{
@@ -423,7 +413,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacMD2
+ public static class Square
+ extends HMacMD2
{
public Square()
{
@@ -431,7 +422,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacMD2
+ public static class TripleDES
+ extends HMacMD2
{
public TripleDES()
{
@@ -439,7 +431,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacMD2
+ public static class Twofish
+ extends HMacMD2
{
public Twofish()
{
@@ -448,12 +441,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacMD4 extends PBES2
+ public static class HMacMD4
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacMD4(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-MD4");
@@ -464,10 +454,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-MD4");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacMD4
+ public static class AES
+ extends HMacMD4
{
public AES()
{
@@ -475,7 +463,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacMD4
+ public static class Anubis
+ extends HMacMD4
{
public Anubis()
{
@@ -483,7 +472,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacMD4
+ public static class Blowfish
+ extends HMacMD4
{
public Blowfish()
{
@@ -491,7 +481,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacMD4
+ public static class Cast5
+ extends HMacMD4
{
public Cast5()
{
@@ -499,7 +490,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacMD4
+ public static class DES
+ extends HMacMD4
{
public DES()
{
@@ -507,7 +499,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacMD4
+ public static class Khazad
+ extends HMacMD4
{
public Khazad()
{
@@ -515,7 +508,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacMD4
+ public static class Serpent
+ extends HMacMD4
{
public Serpent()
{
@@ -523,7 +517,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacMD4
+ public static class Square
+ extends HMacMD4
{
public Square()
{
@@ -531,7 +526,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacMD4
+ public static class TripleDES
+ extends HMacMD4
{
public TripleDES()
{
@@ -539,7 +535,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacMD4
+ public static class Twofish
+ extends HMacMD4
{
public Twofish()
{
@@ -548,12 +545,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacHaval extends PBES2
+ public static class HMacHaval
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacHaval(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-HAVAL");
@@ -564,10 +558,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-HAVAL");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacHaval
+ public static class AES
+ extends HMacHaval
{
public AES()
{
@@ -575,7 +567,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacHaval
+ public static class Anubis
+ extends HMacHaval
{
public Anubis()
{
@@ -583,7 +576,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacHaval
+ public static class Blowfish
+ extends HMacHaval
{
public Blowfish()
{
@@ -591,7 +585,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacHaval
+ public static class Cast5
+ extends HMacHaval
{
public Cast5()
{
@@ -599,7 +594,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacHaval
+ public static class DES
+ extends HMacHaval
{
public DES()
{
@@ -607,7 +603,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacHaval
+ public static class Khazad
+ extends HMacHaval
{
public Khazad()
{
@@ -615,7 +612,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacHaval
+ public static class Serpent
+ extends HMacHaval
{
public Serpent()
{
@@ -623,7 +621,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacHaval
+ public static class Square
+ extends HMacHaval
{
public Square()
{
@@ -631,7 +630,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacHaval
+ public static class TripleDES
+ extends HMacHaval
{
public TripleDES()
{
@@ -639,7 +639,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacHaval
+ public static class Twofish
+ extends HMacHaval
{
public Twofish()
{
@@ -648,12 +649,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacRipeMD128 extends PBES2
+ public static class HMacRipeMD128
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacRipeMD128(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-RIPEMD128");
@@ -664,10 +662,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-RIPEMD128");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacRipeMD128
+ public static class AES
+ extends HMacRipeMD128
{
public AES()
{
@@ -675,7 +671,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacRipeMD128
+ public static class Anubis
+ extends HMacRipeMD128
{
public Anubis()
{
@@ -683,7 +680,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacRipeMD128
+ public static class Blowfish
+ extends HMacRipeMD128
{
public Blowfish()
{
@@ -691,7 +689,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacRipeMD128
+ public static class Cast5
+ extends HMacRipeMD128
{
public Cast5()
{
@@ -699,7 +698,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacRipeMD128
+ public static class DES
+ extends HMacRipeMD128
{
public DES()
{
@@ -707,7 +707,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacRipeMD128
+ public static class Khazad
+ extends HMacRipeMD128
{
public Khazad()
{
@@ -715,7 +716,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacRipeMD128
+ public static class Serpent
+ extends HMacRipeMD128
{
public Serpent()
{
@@ -723,7 +725,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacRipeMD128
+ public static class Square
+ extends HMacRipeMD128
{
public Square()
{
@@ -731,7 +734,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacRipeMD128
+ public static class TripleDES
+ extends HMacRipeMD128
{
public TripleDES()
{
@@ -739,7 +743,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacRipeMD128
+ public static class Twofish
+ extends HMacRipeMD128
{
public Twofish()
{
@@ -748,12 +753,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacRipeMD160 extends PBES2
+ public static class HMacRipeMD160
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacRipeMD160(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-RIPEMD160");
@@ -764,10 +766,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-RIPEMD160");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacRipeMD160
+ public static class AES
+ extends HMacRipeMD160
{
public AES()
{
@@ -775,7 +775,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacRipeMD160
+ public static class Anubis
+ extends HMacRipeMD160
{
public Anubis()
{
@@ -783,7 +784,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacRipeMD160
+ public static class Blowfish
+ extends HMacRipeMD160
{
public Blowfish()
{
@@ -791,7 +793,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacRipeMD160
+ public static class Cast5
+ extends HMacRipeMD160
{
public Cast5()
{
@@ -799,7 +802,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacRipeMD160
+ public static class DES
+ extends HMacRipeMD160
{
public DES()
{
@@ -807,7 +811,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacRipeMD160
+ public static class Khazad
+ extends HMacRipeMD160
{
public Khazad()
{
@@ -815,7 +820,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacRipeMD160
+ public static class Serpent
+ extends HMacRipeMD160
{
public Serpent()
{
@@ -823,7 +829,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacRipeMD160
+ public static class Square
+ extends HMacRipeMD160
{
public Square()
{
@@ -831,7 +838,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacRipeMD160
+ public static class TripleDES
+ extends HMacRipeMD160
{
public TripleDES()
{
@@ -839,7 +847,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacRipeMD160
+ public static class Twofish
+ extends HMacRipeMD160
{
public Twofish()
{
@@ -848,12 +857,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacSHA256 extends PBES2
+ public static class HMacSHA256
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacSHA256(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-SHA-256");
@@ -864,10 +870,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-SHA-256");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacSHA256
+ public static class AES
+ extends HMacSHA256
{
public AES()
{
@@ -875,7 +879,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacSHA256
+ public static class Anubis
+ extends HMacSHA256
{
public Anubis()
{
@@ -883,7 +888,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacSHA256
+ public static class Blowfish
+ extends HMacSHA256
{
public Blowfish()
{
@@ -891,7 +897,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacSHA256
+ public static class Cast5
+ extends HMacSHA256
{
public Cast5()
{
@@ -899,7 +906,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacSHA256
+ public static class DES
+ extends HMacSHA256
{
public DES()
{
@@ -907,7 +915,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacSHA256
+ public static class Khazad
+ extends HMacSHA256
{
public Khazad()
{
@@ -915,7 +924,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacSHA256
+ public static class Serpent
+ extends HMacSHA256
{
public Serpent()
{
@@ -923,7 +933,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacSHA256
+ public static class Square
+ extends HMacSHA256
{
public Square()
{
@@ -931,7 +942,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacSHA256
+ public static class TripleDES
+ extends HMacSHA256
{
public TripleDES()
{
@@ -939,7 +951,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacSHA256
+ public static class Twofish
+ extends HMacSHA256
{
public Twofish()
{
@@ -948,12 +961,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacSHA384 extends PBES2
+ public static class HMacSHA384
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacSHA384(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-SHA-384");
@@ -964,10 +974,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-SHA-384");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacSHA384
+ public static class AES
+ extends HMacSHA384
{
public AES()
{
@@ -975,7 +983,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacSHA384
+ public static class Anubis
+ extends HMacSHA384
{
public Anubis()
{
@@ -983,7 +992,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacSHA384
+ public static class Blowfish
+ extends HMacSHA384
{
public Blowfish()
{
@@ -991,7 +1001,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacSHA384
+ public static class Cast5
+ extends HMacSHA384
{
public Cast5()
{
@@ -999,7 +1010,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacSHA384
+ public static class DES
+ extends HMacSHA384
{
public DES()
{
@@ -1007,7 +1019,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacSHA384
+ public static class Khazad
+ extends HMacSHA384
{
public Khazad()
{
@@ -1015,7 +1028,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacSHA384
+ public static class Serpent
+ extends HMacSHA384
{
public Serpent()
{
@@ -1023,7 +1037,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacSHA384
+ public static class Square
+ extends HMacSHA384
{
public Square()
{
@@ -1031,7 +1046,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacSHA384
+ public static class TripleDES
+ extends HMacSHA384
{
public TripleDES()
{
@@ -1039,7 +1055,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacSHA384
+ public static class Twofish
+ extends HMacSHA384
{
public Twofish()
{
@@ -1048,12 +1065,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacSHA512 extends PBES2
+ public static class HMacSHA512
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacSHA512(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-SHA-512");
@@ -1064,10 +1078,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-SHA-512");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacSHA512
+ public static class AES
+ extends HMacSHA512
{
public AES()
{
@@ -1075,7 +1087,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacSHA512
+ public static class Anubis
+ extends HMacSHA512
{
public Anubis()
{
@@ -1083,7 +1096,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacSHA512
+ public static class Blowfish
+ extends HMacSHA512
{
public Blowfish()
{
@@ -1091,7 +1105,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacSHA512
+ public static class Cast5
+ extends HMacSHA512
{
public Cast5()
{
@@ -1099,7 +1114,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacSHA512
+ public static class DES
+ extends HMacSHA512
{
public DES()
{
@@ -1107,7 +1123,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacSHA512
+ public static class Khazad
+ extends HMacSHA512
{
public Khazad()
{
@@ -1115,7 +1132,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacSHA512
+ public static class Serpent
+ extends HMacSHA512
{
public Serpent()
{
@@ -1123,7 +1141,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacSHA512
+ public static class Square
+ extends HMacSHA512
{
public Square()
{
@@ -1131,7 +1150,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacSHA512
+ public static class TripleDES
+ extends HMacSHA512
{
public TripleDES()
{
@@ -1139,7 +1159,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacSHA512
+ public static class Twofish
+ extends HMacSHA512
{
public Twofish()
{
@@ -1148,12 +1169,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacTiger extends PBES2
+ public static class HMacTiger
+ extends PBES2
{
-
- // Constructor(s)
- // ---------------------------------------------------------------------
-
public HMacTiger(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-TIGER");
@@ -1164,10 +1182,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-TIGER");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacTiger
+ public static class AES
+ extends HMacTiger
{
public AES()
{
@@ -1175,7 +1191,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacTiger
+ public static class Anubis
+ extends HMacTiger
{
public Anubis()
{
@@ -1183,7 +1200,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacTiger
+ public static class Blowfish
+ extends HMacTiger
{
public Blowfish()
{
@@ -1191,7 +1209,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacTiger
+ public static class Cast5
+ extends HMacTiger
{
public Cast5()
{
@@ -1199,7 +1218,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacTiger
+ public static class DES
+ extends HMacTiger
{
public DES()
{
@@ -1207,7 +1227,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacTiger
+ public static class Khazad
+ extends HMacTiger
{
public Khazad()
{
@@ -1215,7 +1236,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacTiger
+ public static class Serpent
+ extends HMacTiger
{
public Serpent()
{
@@ -1223,7 +1245,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacTiger
+ public static class Square
+ extends HMacTiger
{
public Square()
{
@@ -1231,7 +1254,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacTiger
+ public static class TripleDES
+ extends HMacTiger
{
public TripleDES()
{
@@ -1239,7 +1263,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacTiger
+ public static class Twofish
+ extends HMacTiger
{
public Twofish()
{
@@ -1248,12 +1273,9 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class HMacWhirlpool extends PBES2
+ public static class HMacWhirlpool
+ extends PBES2
{
-
- // Constructor(s)
- // ----------------------------------------------------------------------
-
public HMacWhirlpool(String cipher, int blockLen)
{
super(cipher, blockLen, "HMAC-WHIRLPOOL");
@@ -1264,10 +1286,8 @@ public abstract class PBES2 extends CipherAdapter
super(cipher, "HMAC-WHIRLPOOL");
}
- // Inner classe(s)
- // ======================================================================
-
- public static class AES extends HMacWhirlpool
+ public static class AES
+ extends HMacWhirlpool
{
public AES()
{
@@ -1275,7 +1295,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Anubis extends HMacWhirlpool
+ public static class Anubis
+ extends HMacWhirlpool
{
public Anubis()
{
@@ -1283,7 +1304,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Blowfish extends HMacWhirlpool
+ public static class Blowfish
+ extends HMacWhirlpool
{
public Blowfish()
{
@@ -1291,7 +1313,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Cast5 extends HMacWhirlpool
+ public static class Cast5
+ extends HMacWhirlpool
{
public Cast5()
{
@@ -1299,7 +1322,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class DES extends HMacWhirlpool
+ public static class DES
+ extends HMacWhirlpool
{
public DES()
{
@@ -1307,7 +1331,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Khazad extends HMacWhirlpool
+ public static class Khazad
+ extends HMacWhirlpool
{
public Khazad()
{
@@ -1315,7 +1340,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Serpent extends HMacWhirlpool
+ public static class Serpent
+ extends HMacWhirlpool
{
public Serpent()
{
@@ -1323,7 +1349,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Square extends HMacWhirlpool
+ public static class Square
+ extends HMacWhirlpool
{
public Square()
{
@@ -1331,7 +1358,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class TripleDES extends HMacWhirlpool
+ public static class TripleDES
+ extends HMacWhirlpool
{
public TripleDES()
{
@@ -1339,7 +1367,8 @@ public abstract class PBES2 extends CipherAdapter
}
}
- public static class Twofish extends HMacWhirlpool
+ public static class Twofish
+ extends HMacWhirlpool
{
public Twofish()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
index 137db2c3fa4..ad61bca599d 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Rijndael <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class RijndaelSpi extends CipherAdapter
+public final class RijndaelSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public RijndaelSpi()
{
super(Registry.RIJNDAEL_CIPHER, 16);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
index 9df9685cc38..fa65d34a9be 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Serpent <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class SerpentSpi extends CipherAdapter
+public final class SerpentSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public SerpentSpi()
{
super(Registry.SERPENT_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
index 96e5dee38b1..bdc656eaedb 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Square <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class SquareSpi extends CipherAdapter
+public final class SquareSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public SquareSpi()
{
super(Registry.SQUARE_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java
new file mode 100644
index 00000000000..55087755e21
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
index 5c58ea5515e..b9ec12b5110 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Triple-DES <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class TripleDESSpi extends CipherAdapter
+public final class TripleDESSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public TripleDESSpi()
{
super(Registry.TRIPLEDES_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
index 31df5ea4068..206e0d9f877 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Twofish <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class TwofishSpi extends CipherAdapter
+public final class TwofishSpi
+ extends CipherAdapter
{
-
- // Constructors.
- // --------------------------------------------------------------------
-
public TwofishSpi()
{
super(Registry.TWOFISH_CIPHER);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java
index e8d7788e8b7..a1cc8fd7f84 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/AnubisKeyGeneratorImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.key;
import gnu.java.security.Registry;
-public class AnubisKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class AnubisKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public AnubisKeyGeneratorImpl ()
+ public AnubisKeyGeneratorImpl()
{
- super (Registry.ANUBIS_CIPHER);
+ super(Registry.ANUBIS_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
index f9725eae033..bea65a6c63e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
@@ -38,14 +38,8 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
-public class AnubisSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class AnubisSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public AnubisSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java
index a0e687acdf8..2297980fb47 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishKeyGeneratorImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.key;
import gnu.java.security.Registry;
-public class BlowfishKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class BlowfishKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public BlowfishKeyGeneratorImpl ()
+ public BlowfishKeyGeneratorImpl()
{
- super (Registry.BLOWFISH_CIPHER);
+ super(Registry.BLOWFISH_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
index 4b3620bc17d..53fe8b0b49b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
@@ -38,14 +38,8 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
-public class BlowfishSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class BlowfishSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public BlowfishSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java
index 18d26e67fdb..b328e48b37a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/Cast5KeyGeneratorImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.key;
import gnu.java.security.Registry;
-public class Cast5KeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class Cast5KeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public Cast5KeyGeneratorImpl ()
+ public Cast5KeyGeneratorImpl()
{
- super (Registry.CAST5_CIPHER);
+ super(Registry.CAST5_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
index 4bd31711eea..fcebb528e70 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
@@ -38,14 +38,8 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
-public class Cast5SecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class Cast5SecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public Cast5SecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java
index 19c54653a07..2cd29a67f61 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/DESKeyGeneratorImpl.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package gnu.javax.crypto.jce.key;
import gnu.java.security.Registry;
@@ -43,31 +44,25 @@ import gnu.javax.crypto.cipher.DES;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-public class DESKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class DESKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public DESKeyGeneratorImpl ()
+ public DESKeyGeneratorImpl()
{
- super (Registry.DES_CIPHER);
+ super(Registry.DES_CIPHER);
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
- protected SecretKey engineGenerateKey ()
+ protected SecretKey engineGenerateKey()
{
- if (!init)
- throw new IllegalStateException ("not initialized");
- byte[] buf = new byte [currentKeySize];
+ if (! init)
+ throw new IllegalStateException("not initialized");
+ byte[] buf = new byte[currentKeySize];
do
{
- random.nextBytes (buf);
+ random.nextBytes(buf);
}
- while (DES.isWeak (buf) || DES.isSemiWeak (buf));
- DES.adjustParity (buf, 0);
- return new SecretKeySpec (buf, algorithm);
+ while (DES.isWeak(buf) || DES.isSemiWeak(buf));
+ DES.adjustParity(buf, 0);
+ return new SecretKeySpec(buf, algorithm);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java
index e0f1c586096..a138e290228 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/DESSecretKeyFactoryImpl.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package gnu.javax.crypto.jce.key;
import java.security.InvalidKeyException;
@@ -45,36 +46,37 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.SecretKeySpec;
-public class DESSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class DESSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public DESSecretKeyFactoryImpl()
{
}
- protected SecretKey engineGenerateSecret (KeySpec spec)
- throws InvalidKeySpecException
+ protected SecretKey engineGenerateSecret(KeySpec spec)
+ throws InvalidKeySpecException
{
if (spec instanceof DESKeySpec)
- return new SecretKeySpec (((DESKeySpec) spec).getKey(), "DES");
- return super.engineGenerateSecret (spec);
+ return new SecretKeySpec(((DESKeySpec) spec).getKey(), "DES");
+ return super.engineGenerateSecret(spec);
}
- protected KeySpec engineGetKeySpec (SecretKey key, Class spec)
- throws InvalidKeySpecException
+ protected KeySpec engineGetKeySpec(SecretKey key, Class spec)
+ throws InvalidKeySpecException
{
- if (spec.isAssignableFrom (DESKeySpec.class))
+ if (spec.isAssignableFrom(DESKeySpec.class))
try
{
- return new DESKeySpec (key.getEncoded());
+ return new DESKeySpec(key.getEncoded());
}
catch (InvalidKeyException ike)
{
- InvalidKeySpecException ikse = new InvalidKeySpecException
- ("can't create DES key spec");
- ikse.initCause (ike);
+ InvalidKeySpecException ikse = new InvalidKeySpecException(
+ "can't create DES key spec");
+ ikse.initCause(ike);
throw ikse;
}
- return super.engineGetKeySpec (key, spec);
+ return super.engineGetKeySpec(key, spec);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java
index 15e10994020..f380603e44e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/DESedeSecretKeyFactoryImpl.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package gnu.javax.crypto.jce.key;
import java.security.InvalidKeyException;
@@ -45,36 +46,37 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.SecretKeySpec;
-public class DESedeSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class DESedeSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public DESedeSecretKeyFactoryImpl()
{
}
- protected SecretKey engineGenerateSecret (KeySpec spec)
- throws InvalidKeySpecException
+ protected SecretKey engineGenerateSecret(KeySpec spec)
+ throws InvalidKeySpecException
{
if (spec instanceof DESedeKeySpec)
- return new SecretKeySpec (((DESedeKeySpec) spec).getKey(), "DESede");
- return super.engineGenerateSecret (spec);
+ return new SecretKeySpec(((DESedeKeySpec) spec).getKey(), "DESede");
+ return super.engineGenerateSecret(spec);
}
- protected KeySpec engineGetKeySpec (SecretKey key, Class spec)
- throws InvalidKeySpecException
+ protected KeySpec engineGetKeySpec(SecretKey key, Class spec)
+ throws InvalidKeySpecException
{
- if (spec.equals (DESedeKeySpec.class))
+ if (spec.equals(DESedeKeySpec.class))
try
{
- return new DESedeKeySpec (key.getEncoded());
+ return new DESedeKeySpec(key.getEncoded());
}
catch (InvalidKeyException ike)
{
- InvalidKeySpecException ikse = new InvalidKeySpecException
- ("can't create DESede key spec");
- ikse.initCause (ike);
+ InvalidKeySpecException ikse = new InvalidKeySpecException(
+ "can't create DESede key spec");
+ ikse.initCause(ike);
throw ikse;
}
- return super.engineGetKeySpec (key, spec);
+ return super.engineGetKeySpec(key, spec);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java
index c01391e4486..21ae627ebac 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/KhazadKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class KhazadKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class KhazadKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public KhazadKeyGeneratorImpl ()
+ public KhazadKeyGeneratorImpl()
{
- super (Registry.KHAZAD_CIPHER);
+ super(Registry.KHAZAD_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
index c86e01110c5..19315d22ec3 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
@@ -35,16 +35,11 @@ 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.key;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
+package gnu.javax.crypto.jce.key;
-public class KhazadSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class KhazadSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public KhazadSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java
index 535e573ad8e..b60f7d6d02c 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class RijndaelKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class RijndaelKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public RijndaelKeyGeneratorImpl ()
+ public RijndaelKeyGeneratorImpl()
{
- super (Registry.RIJNDAEL_CIPHER);
+ super(Registry.RIJNDAEL_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
index 4aab584a2cc..f88b077520b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
@@ -35,16 +35,11 @@ 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.key;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
+package gnu.javax.crypto.jce.key;
-public class RijndaelSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class RijndaelSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public RijndaelSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java
index 72defe1d7f2..4bba171f9c1 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyFactoryImpl.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package gnu.javax.crypto.jce.key;
import java.security.InvalidKeyException;
@@ -45,43 +46,42 @@ import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactorySpi;
import javax.crypto.spec.SecretKeySpec;
-public abstract class SecretKeyFactoryImpl extends SecretKeyFactorySpi
+public abstract class SecretKeyFactoryImpl
+ extends SecretKeyFactorySpi
{
protected SecretKeyFactoryImpl()
{
}
- protected SecretKey engineGenerateSecret (KeySpec spec)
- throws InvalidKeySpecException
+ protected SecretKey engineGenerateSecret(KeySpec spec)
+ throws InvalidKeySpecException
{
if (spec instanceof SecretKeySpec)
return (SecretKey) spec;
- throw new InvalidKeySpecException ("unknown key spec: " +
- spec.getClass().getName());
+ throw new InvalidKeySpecException("unknown key spec: "
+ + spec.getClass().getName());
}
- protected KeySpec engineGetKeySpec (SecretKey key, Class spec)
- throws InvalidKeySpecException
+ protected KeySpec engineGetKeySpec(SecretKey key, Class spec)
+ throws InvalidKeySpecException
{
- if (spec.equals (SecretKeySpec.class))
+ if (spec.equals(SecretKeySpec.class))
{
if (key instanceof SecretKeySpec)
return (KeySpec) key;
else
- return new SecretKeySpec (key.getEncoded(), key.getAlgorithm());
+ return new SecretKeySpec(key.getEncoded(), key.getAlgorithm());
}
- throw new InvalidKeySpecException ("unsupported key spec: " +
- spec.getName());
+ throw new InvalidKeySpecException("unsupported key spec: " + spec.getName());
}
- protected SecretKey engineTranslateKey (SecretKey key)
- throws InvalidKeyException
+ protected SecretKey engineTranslateKey(SecretKey key)
+ throws InvalidKeyException
{
- if (!"RAW".equals (key.getFormat()))
- throw new InvalidKeyException ("only raw keys are supported");
-
+ if (! "RAW".equals(key.getFormat()))
+ throw new InvalidKeyException("only raw keys are supported");
// SecretKeySpec is good enough for our purposes.
- return new SecretKeySpec (key.getEncoded(), key.getAlgorithm());
+ return new SecretKeySpec(key.getEncoded(), key.getAlgorithm());
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java
index 0a62655734c..319b0eaebe8 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package gnu.javax.crypto.jce.key;
import gnu.javax.crypto.cipher.CipherFactory;
@@ -53,12 +54,9 @@ import javax.crypto.KeyGeneratorSpi;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-public class SecretKeyGeneratorImpl extends KeyGeneratorSpi
+public class SecretKeyGeneratorImpl
+ extends KeyGeneratorSpi
{
-
- // Fields.
- // -------------------------------------------------------------------------
-
protected final int defaultKeySize;
protected final List keySizes;
protected final String algorithm;
@@ -66,55 +64,47 @@ public class SecretKeyGeneratorImpl extends KeyGeneratorSpi
protected int currentKeySize;
protected SecureRandom random;
- // Constructors.
- // -------------------------------------------------------------------------
-
- protected SecretKeyGeneratorImpl (final String algorithm)
+ protected SecretKeyGeneratorImpl(final String algorithm)
{
this.algorithm = algorithm;
- IBlockCipher cipher = CipherFactory.getInstance (algorithm);
+ IBlockCipher cipher = CipherFactory.getInstance(algorithm);
if (cipher == null)
- throw new IllegalArgumentException ("no such cipher: "+algorithm);
- defaultKeySize = cipher.defaultKeySize ();
+ throw new IllegalArgumentException("no such cipher: " + algorithm);
+ defaultKeySize = cipher.defaultKeySize();
keySizes = new LinkedList();
- for (Iterator it = cipher.keySizes (); it.hasNext (); )
- {
- keySizes.add (it.next ());
- }
+ for (Iterator it = cipher.keySizes(); it.hasNext();)
+ keySizes.add(it.next());
init = false;
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
- protected SecretKey engineGenerateKey ()
+ protected SecretKey engineGenerateKey()
{
- if (!init)
- throw new IllegalStateException ("not initialized");
- byte[] buf = new byte [currentKeySize];
- random.nextBytes (buf);
- return new SecretKeySpec (buf, algorithm);
+ if (! init)
+ throw new IllegalStateException("not initialized");
+ byte[] buf = new byte[currentKeySize];
+ random.nextBytes(buf);
+ return new SecretKeySpec(buf, algorithm);
}
- protected void engineInit (AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException
+ protected void engineInit(AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidAlgorithmParameterException
{
- throw new InvalidAlgorithmParameterException (algorithm +
- " does not support algorithm paramaters");
+ throw new InvalidAlgorithmParameterException(
+ algorithm + " does not support algorithm paramaters");
}
- protected void engineInit (int keySize, SecureRandom random)
+ protected void engineInit(int keySize, SecureRandom random)
{
keySize >>>= 3; // Use bytes.
- if (!keySizes.contains (new Integer (keySize)))
- throw new InvalidParameterException ("unsupported key size: " + keySize);
+ if (! keySizes.contains(Integer.valueOf(keySize)))
+ throw new InvalidParameterException("unsupported key size: " + keySize);
currentKeySize = keySize;
this.random = random;
init = true;
}
- protected void engineInit (SecureRandom random)
+ protected void engineInit(SecureRandom random)
{
- engineInit (defaultKeySize << 3, random);
+ engineInit(defaultKeySize << 3, random);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java
index 766860a96b0..c5319051414 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SerpentKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class SerpentKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class SerpentKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public SerpentKeyGeneratorImpl ()
+ public SerpentKeyGeneratorImpl()
{
- super (Registry.SERPENT_CIPHER);
+ super(Registry.SERPENT_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
index 6e80671fac7..5d5ac88dfe7 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
@@ -35,16 +35,11 @@ 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.key;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
+package gnu.javax.crypto.jce.key;
-public class SerpentSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class SerpentSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public SerpentSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java
index 4bfbeb66833..3d496e8a984 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SquareKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class SquareKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class SquareKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public SquareKeyGeneratorImpl ()
+ public SquareKeyGeneratorImpl()
{
- super (Registry.SQUARE_CIPHER);
+ super(Registry.SQUARE_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
index d1d5d551432..f35835912b8 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
@@ -35,16 +35,11 @@ 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.key;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
+package gnu.javax.crypto.jce.key;
-public class SquareSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class SquareSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public SquareSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java
index eb423fcd19c..6fd557ccbcf 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/TripleDESKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class TripleDESKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class TripleDESKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public TripleDESKeyGeneratorImpl ()
+ public TripleDESKeyGeneratorImpl()
{
- super (Registry.TRIPLEDES_CIPHER);
+ super(Registry.TRIPLEDES_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java
index ae7e22feec3..9dd5a8f30e6 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/TwofishKeyGeneratorImpl.java
@@ -35,18 +35,16 @@ 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.key;
import gnu.java.security.Registry;
-public class TwofishKeyGeneratorImpl extends SecretKeyGeneratorImpl
+public class TwofishKeyGeneratorImpl
+ extends SecretKeyGeneratorImpl
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public TwofishKeyGeneratorImpl ()
+ public TwofishKeyGeneratorImpl()
{
- super (Registry.TWOFISH_CIPHER);
+ super(Registry.TWOFISH_CIPHER);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java b/libjava/classpath/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
index e6ca80b6363..0767d4cacdc 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
@@ -35,16 +35,11 @@ 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.key;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
+package gnu.javax.crypto.jce.key;
-public class TwofishSecretKeyFactoryImpl extends SecretKeyFactoryImpl
+public class TwofishSecretKeyFactoryImpl
+ extends SecretKeyFactoryImpl
{
public TwofishSecretKeyFactoryImpl()
{
diff --git a/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java b/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
index d2501f89374..4fcf2fde78b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.jce.keyring;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.javax.crypto.keyring.GnuPrivateKeyring;
import gnu.javax.crypto.keyring.GnuPublicKeyring;
@@ -90,79 +91,100 @@ public class GnuKeyring
public Enumeration engineAliases()
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineAliases");
ensureLoaded();
Enumeration result;
if (privateKR == null)
result = Collections.enumeration(Collections.EMPTY_SET);
- else
- {
- Set aliases = new HashSet();
- for (Enumeration e = privateKR.aliases(); e.hasMoreElements();)
- {
- String alias = (String) e.nextElement();
- if (alias != null)
- aliases.add(alias);
- }
-
- for (Enumeration e = publicKR.aliases(); e.hasMoreElements();)
- {
- String alias = (String) e.nextElement();
- if (alias != null)
- aliases.add(alias);
- }
-
- result = Collections.enumeration(aliases);
- }
-
+ else
+ {
+ Set aliases = new HashSet();
+ for (Enumeration e = privateKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ {
+ alias = alias.trim();
+ if (alias.length() > 0)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Adding alias (from private keyring): " + alias);
+ aliases.add(alias);
+ }
+ }
+ }
+ for (Enumeration e = publicKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ {
+ alias = alias.trim();
+ if (alias.length() > 0)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Adding alias (from public keyring): " + alias);
+ aliases.add(alias);
+ }
+ }
+ }
+ if (Configuration.DEBUG)
+ log.fine("Will enumerate: " + aliases);
+ result = Collections.enumeration(aliases);
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineAliases");
return result;
}
public boolean engineContainsAlias(String alias)
{
- log.entering(this.getClass().getName(), "engineContainsAlias", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineContainsAlias", alias);
ensureLoaded();
boolean inPrivateKR = privateKR.containsAlias(alias);
- log.finest("inPrivateKR=" + inPrivateKR);
+ if (Configuration.DEBUG)
+ log.fine("inPrivateKR=" + inPrivateKR);
boolean inPublicKR = publicKR.containsAlias(alias);
- log.finest("inPublicKR=" + inPublicKR);
+ if (Configuration.DEBUG)
+ log.fine("inPublicKR=" + inPublicKR);
boolean result = inPrivateKR || inPublicKR;
-
- log.exiting(this.getClass().getName(), "engineContainsAlias",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineContainsAlias",
+ Boolean.valueOf(result));
return result;
}
public void engineDeleteEntry(String alias)
{
- log.entering(this.getClass().getName(), "engineDeleteEntry", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineDeleteEntry", alias);
ensureLoaded();
if (privateKR.containsAlias(alias))
privateKR.remove(alias);
else if (publicKR.containsAlias(alias))
publicKR.remove(alias);
- else
- log.finer("Unknwon alias: " + alias);
-
- log.exiting(this.getClass().getName(), "engineDeleteEntry");
+ else if (Configuration.DEBUG)
+ log.fine("Unknwon alias: " + alias);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineDeleteEntry");
}
public Certificate engineGetCertificate(String alias)
{
- log.entering(this.getClass().getName(), "engineGetCertificate", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGetCertificate", alias);
ensureLoaded();
Certificate result = publicKR.getCertificate(alias);
-
- log.exiting(this.getClass().getName(), "engineGetCertificate", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGetCertificate", result);
return result;
}
public String engineGetCertificateAlias(Certificate cert)
{
- log.entering(this.getClass().getName(), "engineGetCertificateAlias", cert);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGetCertificateAlias", cert);
ensureLoaded();
String result = null;
for (Enumeration aliases = publicKR.aliases(); aliases.hasMoreElements();)
@@ -175,52 +197,64 @@ public class GnuKeyring
break;
}
}
-
- log.exiting(this.getClass().getName(), "engineGetCertificateAlias", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGetCertificateAlias", result);
return result;
}
public void engineSetCertificateEntry(String alias, Certificate cert)
+ throws KeyStoreException
{
- log.entering(this.getClass().getName(), "engineSetCertificateEntry",
- new Object[] { alias, cert });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineSetCertificateEntry",
+ new Object[] { alias, cert });
ensureLoaded();
+ if (privateKR.containsAlias(alias))
+ throw new KeyStoreException("Alias [" + alias
+ + "] already exists and DOES NOT identify a "
+ + "Trusted Certificate Entry");
+ if (publicKR.containsCertificate(alias))
+ {
+ if (Configuration.DEBUG)
+ log.fine("Public keyring already contains Alias [" + alias
+ + "]. Will remove it");
+ publicKR.remove(alias);
+ }
publicKR.putCertificate(alias, cert);
-
- log.exiting(this.getClass().getName(), "engineSetCertificateEntry");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineSetCertificateEntry");
}
public Certificate[] engineGetCertificateChain(String alias)
{
- log.entering(this.getClass().getName(), "engineGetCertificateChain", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGetCertificateChain", alias);
ensureLoaded();
Certificate[] result = privateKR.getCertPath(alias);
-
- log.exiting(this.getClass().getName(), "engineGetCertificateChain", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGetCertificateChain", result);
return result;
}
public Date engineGetCreationDate(String alias)
{
- log.entering(this.getClass().getName(), "engineGetCreationDate", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGetCreationDate", alias);
ensureLoaded();
Date result = getCreationDate(alias, privateKR);
if (result == null)
result = getCreationDate(alias, publicKR);
- log.exiting(this.getClass().getName(), "engineGetCreationDate", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGetCreationDate", result);
return result;
}
public Key engineGetKey(String alias, char[] password)
throws UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "engineGetKey",
- String.valueOf(password));
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGetKey", alias);
ensureLoaded();
Key result = null;
if (password == null)
@@ -231,7 +265,9 @@ public class GnuKeyring
else if (privateKR.containsPrivateKey(alias))
result = privateKR.getPrivateKey(alias, password);
- log.exiting(this.getClass().getName(), "engineGetKey", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGetKey",
+ result == null ? "null" : result.getClass().getName());
return result;
}
@@ -239,60 +275,73 @@ public class GnuKeyring
Certificate[] chain)
throws KeyStoreException
{
- log.entering(this.getClass().getName(), "engineSetKeyEntry",
- new Object[] { alias, key, password, chain });
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineSetKeyEntry",
+ new Object[] { alias, key.getClass().getName(), chain });
ensureLoaded();
+ if (publicKR.containsAlias(alias))
+ throw new KeyStoreException("Alias [" + alias
+ + "] already exists and DOES NOT identify a "
+ + "Key Entry");
if (key instanceof PublicKey)
- privateKR.putPublicKey(alias, (PublicKey) key);
+ {
+ privateKR.remove(alias);
+ PublicKey pk = (PublicKey) key;
+ privateKR.putPublicKey(alias, pk);
+ }
else
{
if (! (key instanceof PrivateKey) && ! (key instanceof SecretKey))
throw new KeyStoreException("cannot store keys of type "
+ key.getClass().getName());
+ privateKR.remove(alias);
privateKR.putCertPath(alias, chain);
- log.finest("About to put private key in keyring...");
+ if (Configuration.DEBUG)
+ log.fine("About to put private key in keyring...");
privateKR.putPrivateKey(alias, key, password);
}
-
- log.exiting(this.getClass().getName(), "engineSetKeyEntry");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineSetKeyEntry");
}
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
throws KeyStoreException
{
KeyStoreException x = new KeyStoreException("method not supported");
- log.throwing(this.getClass().getName(), "engineSetKeyEntry(3)", x);
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "engineSetKeyEntry(3)", x);
throw x;
}
public boolean engineIsCertificateEntry(String alias)
{
- log.entering(this.getClass().getName(), "engineIsCertificateEntry", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineIsCertificateEntry", alias);
ensureLoaded();
boolean result = publicKR.containsCertificate(alias);
-
- log.exiting(this.getClass().getName(), "engineIsCertificateEntry",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineIsCertificateEntry",
+ Boolean.valueOf(result));
return result;
}
public boolean engineIsKeyEntry(String alias)
{
- log.entering(this.getClass().getName(), "engineIsKeyEntry", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineIsKeyEntry", alias);
ensureLoaded();
boolean result = privateKR.containsPublicKey(alias)
|| privateKR.containsPrivateKey(alias);
-
- log.exiting(this.getClass().getName(), "engineIsKeyEntry",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineIsKeyEntry",
+ Boolean.valueOf(result));
return result;
}
public void engineLoad(InputStream in, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "engineLoad", String.valueOf(password));
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineLoad");
if (in != null)
{
if (! in.markSupported())
@@ -305,14 +354,14 @@ public class GnuKeyring
createNewKeyrings();
loaded = true;
-
- log.exiting(this.getClass().getName(), "engineLoad");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineLoad");
}
public void engineStore(OutputStream out, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "engineStore", String.valueOf(password));
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineStore");
ensureLoaded();
HashMap attr = new HashMap();
attr.put(IKeyring.KEYRING_DATA_OUT, out);
@@ -320,14 +369,21 @@ public class GnuKeyring
privateKR.store(attr);
publicKR.store(attr);
-
- log.exiting(this.getClass().getName(), "engineStore");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineStore");
}
public int engineSize()
{
- ensureLoaded();
- return privateKR.size() + publicKR.size();
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineSize");
+ int result = 0;
+ for (Enumeration e = engineAliases(); e.hasMoreElements(); result++)
+ e.nextElement();
+
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineSize", Integer.valueOf(result));
+ return result;
}
/**
@@ -353,8 +409,8 @@ public class GnuKeyring
private void loadPrivateKeyring(InputStream in, char[] password)
throws MalformedKeyringException, IOException
{
- log.entering(this.getClass().getName(), "loadPrivateKeyring");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "loadPrivateKeyring");
in.mark(5);
for (int i = 0; i < 4; i++)
if (in.read() != Registry.GKR_MAGIC[i])
@@ -363,15 +419,16 @@ public class GnuKeyring
int usage = in.read();
in.reset();
if (usage != GnuPrivateKeyring.USAGE)
- throw new MalformedKeyringException("Was expecting a private keyring but got a wrong USAGE: "
- + Integer.toBinaryString(usage));
+ throw new MalformedKeyringException(
+ "Was expecting a private keyring but got a wrong USAGE: "
+ + Integer.toBinaryString(usage));
HashMap attr = new HashMap();
attr.put(IKeyring.KEYRING_DATA_IN, in);
attr.put(IKeyring.KEYRING_PASSWORD, password);
privateKR = new GnuPrivateKeyring();
privateKR.load(attr);
-
- log.exiting(this.getClass().getName(), "loadPrivateKeyring");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "loadPrivateKeyring");
}
/**
@@ -385,8 +442,8 @@ public class GnuKeyring
private void loadPublicKeyring(InputStream in, char[] password)
throws MalformedKeyringException, IOException
{
- log.entering(this.getClass().getName(), "loadPublicKeyring");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "loadPublicKeyring");
in.mark(5);
for (int i = 0; i < 4; i++)
if (in.read() != Registry.GKR_MAGIC[i])
@@ -395,15 +452,16 @@ public class GnuKeyring
int usage = in.read();
in.reset();
if (usage != GnuPublicKeyring.USAGE)
- throw new MalformedKeyringException("Was expecting a public keyring but got a wrong USAGE: "
- + Integer.toBinaryString(usage));
+ throw new MalformedKeyringException(
+ "Was expecting a public keyring but got a wrong USAGE: "
+ + Integer.toBinaryString(usage));
HashMap attr = new HashMap();
attr.put(IKeyring.KEYRING_DATA_IN, in);
attr.put(IKeyring.KEYRING_PASSWORD, password);
publicKR = new GnuPublicKeyring();
publicKR.load(attr);
-
- log.exiting(this.getClass().getName(), "loadPublicKeyring");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "loadPublicKeyring");
}
/**
@@ -417,9 +475,9 @@ public class GnuKeyring
*/
private Date getCreationDate(String alias, IKeyring keyring)
{
- log.entering(this.getClass().getName(), "getCreationDate",
- new Object[] { alias, keyring });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getCreationDate",
+ new Object[] { alias, keyring });
Date result = null;
if (keyring != null)
for (Iterator it = keyring.get(alias).iterator(); it.hasNext();)
@@ -431,19 +489,19 @@ public class GnuKeyring
break;
}
}
-
- log.exiting(this.getClass().getName(), "getCreationDate", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getCreationDate", result);
return result;
}
/** Create empty keyrings. */
private void createNewKeyrings()
{
- log.entering(this.getClass().getName(), "createNewKeyrings");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "createNewKeyrings");
privateKR = new GnuPrivateKeyring("HMAC-SHA-1", 20, "AES", "OFB", 16);
publicKR = new GnuPublicKeyring("HMAC-SHA-1", 20);
-
- log.exiting(this.getClass().getName(), "createNewKeyrings");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "createNewKeyrings");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacHavalSpi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacHavalSpi.java
index df1319cbfdb..2967ee900ce 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacHavalSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacHavalSpi.java
@@ -37,31 +37,18 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
+
import gnu.java.security.Registry;
/**
* The implementation of the HMAC-HAVAL <i>Service Provider Interface</i>
* (<b>SPI</b>) Adapter.
- *
- * @version Revision: $
*/
-public class HMacHavalSpi extends MacAdapter
+public class HMacHavalSpi
+ extends MacAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public HMacHavalSpi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.HAVAL_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
index dd489639f29..dd648586657 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-MD2 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacMD2Spi extends MacAdapter
+public final class HMacMD2Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacMD2Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD2_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
index 6fadf02621b..939851ff537 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-MD4 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacMD4Spi extends MacAdapter
+public final class HMacMD4Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacMD4Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD4_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
index 2ef43974f82..e89fbfdbac9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-MD5 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacMD5Spi extends MacAdapter
+public final class HMacMD5Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacMD5Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD5_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
index ad7a2340eed..834ec849a71 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-RIPEMD-128 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacRipeMD128Spi extends MacAdapter
+public final class HMacRipeMD128Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacRipeMD128Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.RIPEMD128_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
index c14e3b3bf24..b973ea18678 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-RIPEMD-160 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacRipeMD160Spi extends MacAdapter
+public final class HMacRipeMD160Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacRipeMD160Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.RIPEMD160_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
index f102c9ebcde..524aa823386 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-SHA-160 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacSHA160Spi extends MacAdapter
+public final class HMacSHA160Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacSHA160Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.SHA160_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
index cadad1cf5fa..4b0493bc63b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
@@ -37,29 +37,18 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
+
import gnu.java.security.Registry;
/**
- * <p>The implementation of the HMAC-SHA-256 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the HMAC-SHA-256 <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public final class HMacSHA256Spi extends MacAdapter
+public final class HMacSHA256Spi
+ extends MacAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -----------------------------------------------------------------------
-
public HMacSHA256Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.SHA256_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
index 69ef38e50f6..92a5c9d2c69 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
@@ -37,29 +37,18 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
+
import gnu.java.security.Registry;
/**
- * <p>The implementation of the HMAC-SHA-384 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the HMAC-SHA-384 <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class HMacSHA384Spi extends MacAdapter
+public class HMacSHA384Spi
+ extends MacAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -----------------------------------------------------------------------
-
public HMacSHA384Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.SHA384_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
index abceb4a92c9..f1ecd02e5a7 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
@@ -37,29 +37,18 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
+
import gnu.java.security.Registry;
/**
- * <p>The implementation of the HMAC-SHA-512 <i>Service Provider Interface</i>
- * (<b>SPI</b>) adapter.</p>
+ * The implementation of the HMAC-SHA-512 <i>Service Provider Interface</i>
+ * (<b>SPI</b>) adapter.
*/
-public class HMacSHA512Spi extends MacAdapter
+public class HMacSHA512Spi
+ extends MacAdapter
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -----------------------------------------------------------------------
-
public HMacSHA512Spi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.SHA512_HASH);
}
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
index 511993ea413..2d417ef4c58 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the Tiger <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacTigerSpi extends MacAdapter
+public final class HMacTigerSpi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacTigerSpi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.TIGER_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
index 706e0cd5a6b..1b936d71a2e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the HMAC-Whirlpool <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class HMacWhirlpoolSpi extends MacAdapter
+public final class HMacWhirlpoolSpi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public HMacWhirlpoolSpi()
{
super(Registry.HMAC_NAME_PREFIX + Registry.WHIRLPOOL_HASH);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
index dc019ca20f4..d8c800ac728 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
@@ -50,32 +50,26 @@ import java.util.Map;
import javax.crypto.MacSpi;
/**
- * <p>The implementation of a generic {@link javax.crypto.Mac} adapter class
- * to wrap GNU Crypto MAC instances.</p>
- *
- * <p>This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * The implementation of a generic {@link javax.crypto.Mac} adapter class to
+ * wrap GNU MAC instances.
+ * <p>
+ * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link javax.crypto.Mac} class, which provides the functionality of a
* message authentication code algorithm, such as the <i>Hashed Message
- * Authentication Code</i> (<b>HMAC</b>) algorithms.</p>
+ * Authentication Code</i> (<b>HMAC</b>) algorithms.
*/
-class MacAdapter extends MacSpi implements Cloneable
+class MacAdapter
+ extends MacSpi
+ implements Cloneable
{
-
- // Constants and variables
- // -----------------------------------------------------------------------
-
/** Our MAC instance. */
protected IMac mac;
-
/** Our MAC attributes. */
protected Map attributes;
- // Constructor(s)
- // -----------------------------------------------------------------------
-
/**
- * <p>Creates a new Mac instance for the given name.</p>
- *
+ * Creates a new Mac instance for the given name.
+ *
* @param name The name of the mac to create.
*/
protected MacAdapter(String name)
@@ -88,7 +82,7 @@ class MacAdapter extends MacSpi implements Cloneable
* Private constructor for cloning purposes.
*
* @param mac a clone of the internal {@link IMac} instance.
- * @param attributes a clone of the current {@link Map} of attributes.
+ * @param attributes a clone of the current {@link Map} of attributes.
*/
private MacAdapter(IMac mac, Map attributes)
{
@@ -98,21 +92,11 @@ class MacAdapter extends MacSpi implements Cloneable
this.attributes = attributes;
}
- // Class methods
- // -----------------------------------------------------------------------
-
- // Instance methods
- // -----------------------------------------------------------------------
-
- // Cloneable interface implementation ------------------------------------
-
public Object clone() throws CloneNotSupportedException
{
return new MacAdapter((IMac) mac.clone(), new HashMap(attributes));
}
- // Instance methods implementing javax.crypto.MacSpi ---------------------
-
protected byte[] engineDoFinal()
{
byte[] result = mac.digest();
@@ -128,10 +112,8 @@ class MacAdapter extends MacSpi implements Cloneable
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException
{
- if (!key.getFormat().equalsIgnoreCase("RAW"))
- {
- throw new InvalidKeyException("unknown key format " + key.getFormat());
- }
+ if (! key.getFormat().equalsIgnoreCase("RAW"))
+ throw new InvalidKeyException("unknown key format " + key.getFormat());
attributes.put(IMac.MAC_KEY_MATERIAL, key.getEncoded());
mac.reset();
mac.init(attributes);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacAnubisImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacAnubisImpl.java
index 4bfda4fd6cc..566e56fd1d1 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacAnubisImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacAnubisImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacAnubisImpl extends MacAdapter
+public class OMacAnubisImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacAnubisImpl()
{
super(Registry.OMAC_PREFIX + Registry.ANUBIS_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java
index 8d168e57be5..55768166f8a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacBlowfishImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacBlowfishImpl extends MacAdapter
+public class OMacBlowfishImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacBlowfishImpl()
{
super(Registry.OMAC_PREFIX + Registry.BLOWFISH_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacCast5Impl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacCast5Impl.java
index 3385d116bc4..535352c3908 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacCast5Impl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacCast5Impl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacCast5Impl extends MacAdapter
+public class OMacCast5Impl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacCast5Impl()
{
super(Registry.OMAC_PREFIX + Registry.CAST5_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacDESImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacDESImpl.java
index 3fb23bdefde..a01c0ac872a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacDESImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacDESImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacDESImpl extends MacAdapter
+public class OMacDESImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacDESImpl()
{
super(Registry.OMAC_PREFIX + Registry.DES_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacImpl.java
index f91902ae543..960c68aaf07 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacImpl.java
@@ -39,23 +39,17 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-import javax.crypto.MacSpi;
-public abstract class OMacImpl extends MacAdapter
+public abstract class OMacImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
protected OMacImpl(String name)
{
super(Registry.OMAC_PREFIX + name);
}
- // Inner classes.
- // -------------------------------------------------------------------------
-
- public class Anubis extends OMacImpl
+ public class Anubis
+ extends OMacImpl
{
public Anubis()
{
@@ -63,7 +57,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Blowfish extends OMacImpl
+ public class Blowfish
+ extends OMacImpl
{
public Blowfish()
{
@@ -71,7 +66,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Cast5 extends OMacImpl
+ public class Cast5
+ extends OMacImpl
{
public Cast5()
{
@@ -79,7 +75,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class DES extends OMacImpl
+ public class DES
+ extends OMacImpl
{
public DES()
{
@@ -87,7 +84,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Khazad extends OMacImpl
+ public class Khazad
+ extends OMacImpl
{
public Khazad()
{
@@ -95,7 +93,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Rijndael extends OMacImpl
+ public class Rijndael
+ extends OMacImpl
{
public Rijndael()
{
@@ -103,7 +102,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Serpent extends OMacImpl
+ public class Serpent
+ extends OMacImpl
{
public Serpent()
{
@@ -111,7 +111,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Square extends OMacImpl
+ public class Square
+ extends OMacImpl
{
public Square()
{
@@ -119,7 +120,8 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class TripleDES extends OMacImpl
+ public class TripleDES
+ extends OMacImpl
{
public TripleDES()
{
@@ -127,11 +129,12 @@ public abstract class OMacImpl extends MacAdapter
}
}
- public class Twofish extends OMacImpl
+ public class Twofish
+ extends OMacImpl
{
public Twofish()
{
super(Registry.TWOFISH_CIPHER);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacKhazadImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacKhazadImpl.java
index 82c047c25a3..c349f9f5e0d 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacKhazadImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacKhazadImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacKhazadImpl extends MacAdapter
+public class OMacKhazadImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacKhazadImpl()
{
super(Registry.OMAC_PREFIX + Registry.KHAZAD_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java
index 47d3f6aae70..d63b777a32a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacRijndaelImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacRijndaelImpl extends MacAdapter
+public class OMacRijndaelImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacRijndaelImpl()
{
super(Registry.OMAC_PREFIX + Registry.RIJNDAEL_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSerpentImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSerpentImpl.java
index bec2c1f5c74..5c1b8a9b99e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSerpentImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSerpentImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacSerpentImpl extends MacAdapter
+public class OMacSerpentImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacSerpentImpl()
{
super(Registry.OMAC_PREFIX + Registry.SERPENT_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSquareImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSquareImpl.java
index 0442b7caf25..c9d1b1aca07 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSquareImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacSquareImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacSquareImpl extends MacAdapter
+public class OMacSquareImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacSquareImpl()
{
super(Registry.OMAC_PREFIX + Registry.SQUARE_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java
index 0defdd1fd36..4f58723d3f7 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTripleDESImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacTripleDESImpl extends MacAdapter
+public class OMacTripleDESImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacTripleDESImpl()
{
super(Registry.OMAC_PREFIX + Registry.TRIPLEDES_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTwofishImpl.java b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTwofishImpl.java
index a12f9f30e85..4c816a09658 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTwofishImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/OMacTwofishImpl.java
@@ -40,14 +40,11 @@ package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-public class OMacTwofishImpl extends MacAdapter
+public class OMacTwofishImpl
+ extends MacAdapter
{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
public OMacTwofishImpl()
{
super(Registry.OMAC_PREFIX + Registry.TWOFISH_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
index 1734e1e695b..8a40f6e7082 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
@@ -51,27 +51,19 @@ import java.security.spec.AlgorithmParameterSpec;
* The implementation of the TMMH16 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class TMMH16Spi extends MacAdapter
+public final class TMMH16Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public TMMH16Spi()
{
super(Registry.TMMH16);
}
- // Instance methods overriding MacAdapter.
- // -----------------------------------------------------------------------
-
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException
{
- if (!(params instanceof TMMHParameterSpec))
- {
- throw new InvalidAlgorithmParameterException();
- }
+ if (! (params instanceof TMMHParameterSpec))
+ throw new InvalidAlgorithmParameterException();
TMMHParameterSpec spec = (TMMHParameterSpec) params;
attributes.put(TMMH16.TAG_LENGTH, spec.getTagLength());
attributes.put(TMMH16.KEYSTREAM, spec.getKeystream());
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
index af678c0fa8a..825edc1739c 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
@@ -44,12 +44,9 @@ import gnu.java.security.Registry;
* The implementation of the UHash-32 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class UHash32Spi extends MacAdapter
+public final class UHash32Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public UHash32Spi()
{
super(Registry.UHASH32);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
index 4e90468b10c..fc05e532106 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
@@ -51,32 +51,22 @@ import java.security.spec.AlgorithmParameterSpec;
* The implementation of the UMAC-32 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
-public final class UMac32Spi extends MacAdapter
+public final class UMac32Spi
+ extends MacAdapter
{
-
- // Constructors.
- // -----------------------------------------------------------------------
-
public UMac32Spi()
{
super(Registry.UMAC32);
}
- // Instance methods overriding MacAdapter.
- // -----------------------------------------------------------------------
-
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException
{
- if (!(params instanceof UMac32ParameterSpec))
- {
- throw new InvalidAlgorithmParameterException();
- }
+ if (! (params instanceof UMac32ParameterSpec))
+ throw new InvalidAlgorithmParameterException();
if (params != null)
- {
- attributes.put(UMac32.NONCE_MATERIAL,
- ((UMac32ParameterSpec) params).getNonce());
- }
+ attributes.put(UMac32.NONCE_MATERIAL,
+ ((UMac32ParameterSpec) params).getNonce());
try
{
super.engineInit(key, null);
diff --git a/libjava/classpath/gnu/javax/crypto/jce/params/BlockCipherParameters.java b/libjava/classpath/gnu/javax/crypto/jce/params/BlockCipherParameters.java
index bae7cbf88f4..a85c962235e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/params/BlockCipherParameters.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/params/BlockCipherParameters.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.jce.params;
+import gnu.java.security.Configuration;
import gnu.javax.crypto.jce.spec.BlockCipherParameterSpec;
import java.io.IOException;
@@ -46,40 +47,34 @@ import java.math.BigInteger;
import java.security.AlgorithmParametersSpi;
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 Crypto block
- * ciphers. This encompasses the cipher's block size, its key size, and
- * an optional initialization vector (IV).
+ * An implementation of algorithm parameters for the GNU block ciphers. This
+ * encompasses the cipher's block size, its key size, and an optional
+ * initialization vector (IV).
*/
-public class BlockCipherParameters extends AlgorithmParametersSpi
+public class BlockCipherParameters
+ extends AlgorithmParametersSpi
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
- /**
- * The underlying block cipher specification.
- */
+ private static final Logger log = Logger.getLogger(BlockCipherParameters.class.getName());
+ /** The underlying block cipher specification. */
protected BlockCipherParameterSpec cipherSpec;
-
private static final String DEFAULT_FORMAT = "ASN.1";
- // Instance methods implementing AlgorithmParametersSpi.
- // -----------------------------------------------------------------------
-
/**
* Return these parameters encoded in ASN.1 (DER).
- *
- * <p>For GNU Crypto block ciphers we will define these parameters as
- *
- * <blockquote>
- * <pre>BlockCipherParameters ::= SEQUENCE {
- * blockSize INTEGER,
- * keySize INTEGER,
- * initializationVector OCTET STRING OPTIONAL }</pre>
- * </blockquote>
- *
+ * <p>
+ * For GNU block ciphers we will define these parameters as
+ * <pre>
+ * BlockCipherParameters ::= SEQUENCE {
+ * blockSize INTEGER,
+ * keySize INTEGER,
+ * initializationVector OCTET STRING OPTIONAL }
+ * </pre>
+ *
* @return The parameters, encoded an an ASN.1 DER sequence.
* @throws java.io.IOException If encoding these parameters fails.
*/
@@ -90,114 +85,59 @@ public class BlockCipherParameters extends AlgorithmParametersSpi
protected byte[] engineGetEncoded(String format) throws IOException
{
- if (!format.equalsIgnoreCase(DEFAULT_FORMAT)
- && !format.equalsIgnoreCase("asn1"))
- {
- throw new IOException("unknown format \"" + format + "\"");
- }
- // This is probably a bad idea.
- /*
- int len = 12 + ((cipherSpec.getIV() != null)
- ? cipherSpec.getIV().length + 2 : 0);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- out.write(0x30);
- out.write(len);
- out.write(0x02);
- out.write(4);
- out.write(cipherSpec.getBlockSize() >>> 24 & 0xff);
- out.write(cipherSpec.getBlockSize() >>> 16 & 0xff);
- out.write(cipherSpec.getBlockSize() >>> 8 & 0xff);
- out.write(cipherSpec.getBlockSize() & 0xff);
- out.write(0x02);
- out.write(4);
- out.write(cipherSpec.getKeySize() >>> 24 & 0xff);
- out.write(cipherSpec.getKeySize() >>> 16 & 0xff);
- out.write(cipherSpec.getKeySize() >>> 8 & 0xff);
- out.write(cipherSpec.getKeySize() & 0xff);
- if (cipherSpec.getIV() != null) {
- out.write(0x04);
- len = cipherSpec.getIV().length;
- out.write(len & 0xff);
- out.write(cipherSpec.getIV());
- }
- out.write(0); out.write(0);
- return out.toByteArray();*/
+ if (! format.equalsIgnoreCase(DEFAULT_FORMAT)
+ && ! format.equalsIgnoreCase("asn1"))
+ throw new IOException("unknown format \"" + format + "\"");
DERWriter writer = new DERWriter();
+ int cipherBlockSize = cipherSpec.getBlockSize();
+ int cipherKeySize = cipherSpec.getKeySize();
+ byte[] iv = cipherSpec.getIV();
return writer.joinarrays(
- writer.writeBigInteger(BigInteger.valueOf(cipherSpec.getBlockSize())),
- writer.writeBigInteger(BigInteger.valueOf(cipherSpec.getKeySize())),
- (cipherSpec.getIV() != null) ? writer.writeBigInteger(new BigInteger(
- cipherSpec.getIV()))
- : new byte[0]);
+ writer.writeBigInteger(BigInteger.valueOf(cipherBlockSize)),
+ writer.writeBigInteger(BigInteger.valueOf(cipherKeySize)),
+ (iv != null) ? writer.writeBigInteger(new BigInteger(iv))
+ : new byte[0]);
}
protected void engineInit(AlgorithmParameterSpec spec)
throws InvalidParameterSpecException
{
if (spec instanceof BlockCipherParameterSpec)
- {
- cipherSpec = (BlockCipherParameterSpec) spec;
- }
+ cipherSpec = (BlockCipherParameterSpec) spec;
else
- {
- throw new InvalidParameterSpecException();
- }
+ throw new InvalidParameterSpecException();
}
protected void engineInit(byte[] encoded, String format) throws IOException
{
- if (!format.equalsIgnoreCase(DEFAULT_FORMAT)
- && !format.equalsIgnoreCase("ASN1"))
- {
- throw new IOException("invalid format: only accepts ASN.1");
- }
+ if (! format.equalsIgnoreCase(DEFAULT_FORMAT)
+ && ! format.equalsIgnoreCase("ASN1"))
+ throw new IOException("invalid format: only accepts ASN.1");
engineInit(encoded);
}
protected void engineInit(byte[] encoded) throws IOException
{
- // This is probably an equally bad idea.
- /*if (encoded[0] != 0x30) {
- throw new IOException("malformed ASN.1 sequence");
- }
- if (encoded[2] != 0x02 || encoded[3] != 4) {
- throw new IOException("malformed ASN.1 sequence");
- }
- int blockSize = encoded[4] << 24 | encoded[5] << 16
- | encoded[6] << 8 | encoded[7];
- if (encoded[8] != 0x02 || encoded[9] != 4) {
- throw new IOException("malformed ASN.1 sequence");
- }
- int keySize = encoded[10] << 24 | encoded[11] << 16
- | encoded[12] << 8 | encoded[13];
- if (encoded[14] == 0x04) {
- int len = encoded[15] & 0xff;
- byte[] iv = new byte[len];
- System.arraycopy(encoded, 16, iv, 0, len);
- cipherSpec = new BlockCipherParameterSpec(iv, blockSize, keySize);
- } else if (encoded[14] == 0) {
- cipherSpec = new BlockCipherParameterSpec(blockSize, keySize);
- } else {
- throw new IOException("malformed ASN.1 sequence");
- }*/
DERReader reader = new DERReader(encoded);
int bs = reader.getBigInteger().intValue();
int ks = reader.getBigInteger().intValue();
byte[] iv = null;
if (reader.hasMorePrimitives())
- {
- iv = reader.getBigInteger().toByteArray();
- }
+ iv = reader.getBigInteger().toByteArray();
cipherSpec = new BlockCipherParameterSpec(iv, bs, ks);
- System.out.println(cipherSpec);
+ if (Configuration.DEBUG)
+ log.fine("cipherSpec: " + cipherSpec);
}
protected AlgorithmParameterSpec engineGetParameterSpec(Class c)
throws InvalidParameterSpecException
{
if (c.isInstance(cipherSpec))
+ return cipherSpec;
+ if (IvParameterSpec.class.isAssignableFrom(c))
{
- return cipherSpec;
+ IvParameterSpec result = new IvParameterSpec(cipherSpec.getIV());
+ return result;
}
throw new InvalidParameterSpecException();
}
@@ -206,4 +146,4 @@ public class BlockCipherParameters extends AlgorithmParametersSpi
{
return cipherSpec.toString();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/params/DEREncodingException.java b/libjava/classpath/gnu/javax/crypto/jce/params/DEREncodingException.java
index ddfa6e1dee7..b89ceda9fa2 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/params/DEREncodingException.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/params/DEREncodingException.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package gnu.javax.crypto.jce.params;
-class DEREncodingException extends java.io.IOException
+class DEREncodingException
+ extends java.io.IOException
{
public DEREncodingException()
@@ -50,4 +51,4 @@ class DEREncodingException extends java.io.IOException
{
super(msg);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/params/DERReader.java b/libjava/classpath/gnu/javax/crypto/jce/params/DERReader.java
index f61423255fc..68c68027966 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/params/DERReader.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/params/DERReader.java
@@ -43,15 +43,10 @@ import java.math.BigInteger;
class DERReader
{
byte source[];
-
int pos;
-
static final int UNIVERSAL = 1;
-
static final int APPLICATION = 2;
-
static final int CONTEXT_SPECIFIC = 3;
-
static final int PRIVATE = 4;
public DERReader()
@@ -86,53 +81,37 @@ class DERReader
return new BigInteger(getPrimitive());
}
- //Reads Primitive, definite-length method
+ // Reads Primitive, definite-length method
private byte[] getPrimitive() throws DEREncodingException
{
int tmp = pos;
-
- //Read Identifier
+ // Read Identifier
byte identifier = source[tmp++];
if ((0x20 & identifier) != 0)
throw new DEREncodingException();
int type = translateLeadIdentifierByte(identifier);
- //System.out.println("Type: " + type);
-
- //get tag
+ // get tag
int tag = (0x1f & identifier);
- //if( tag == 0x1f)
- // tag = getIdentifier(tmp);
- //System.out.println("Tag: " + tag);
-
- //get length
- byte len = source[tmp]; //may be length of length parameter
+ // get length
+ byte len = source[tmp]; // may be length of length parameter
long length = 0x7f & len;
int i;
if ((0x80 & len) != 0)
{
- //System.out.println("Extra Long Length");
len &= 0x7f;
- //System.out.println("Length of Length: " + len);
- //get length here
+ // get length here
length = 0;
for (i = 0; i < len; i++)
{
tmp++;
length <<= 8;
length += (source[tmp] < 0) ? (256 + source[tmp]) : source[tmp];
- //System.out.println("Length of Length: " + length);
}
tmp++;
}
else
tmp++;
- /*System.out.println("Position: " + tmp);
- System.out.println("Length: " + length);
- for( i = 0; i < 10; i++)
- System.out.print(source[tmp + i] + " ");
- System.out.println();*/
-
byte tmpb[] = new byte[(int) length];
System.arraycopy(source, tmp, tmpb, 0, (int) length);
pos = (int) (tmp + length);
@@ -157,4 +136,4 @@ class DERReader
tpos++;
return tpos;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/params/DERWriter.java b/libjava/classpath/gnu/javax/crypto/jce/params/DERWriter.java
index 876c2cd6caa..7bdea10c5f4 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/params/DERWriter.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/params/DERWriter.java
@@ -43,11 +43,8 @@ import java.math.BigInteger;
class DERWriter
{
static final int UNIVERSAL = 1;
-
static final int APPLICATION = 2;
-
static final int CONTEXT_SPECIFIC = 3;
-
static final int PRIVATE = 4;
public DERWriter()
@@ -56,7 +53,8 @@ class DERWriter
public byte[] writeBigInteger(BigInteger i)
{
- return writePrimitive(0x02, UNIVERSAL,
+ return writePrimitive(0x02,
+ UNIVERSAL,
(int) Math.ceil((double) i.bitLength() / 8),
i.toByteArray());
}
@@ -71,7 +69,7 @@ class DERWriter
public byte[] joinarrays(byte a[], byte b[])
{
byte d[] = new byte[a.length + b.length];
- System.arraycopy(a, 0, d, 0, a.length);
+ System.arraycopy(a, 0, d, 0, a.length);
System.arraycopy(b, 0, d, a.length, b.length);
return d;
}
@@ -92,7 +90,7 @@ class DERWriter
{
int count = (int) (Math.log(identifier) / Math.log(256));
b = new byte[count + 1];
- b[0] = (byte) (translateLeadIdentifierByte(identifierencoding) | 0x1f);
+ b[0] = (byte)(translateLeadIdentifierByte(identifierencoding) | 0x1f);
int i;
for (i = 1; i < (count + 1); i++)
{
@@ -100,14 +98,13 @@ class DERWriter
b[i] |= 0x80;
}
b[i - 1] ^= 0x80;
- //System.out.println("Identifier1: " + b[0]);
return b;
}
else
{
b = new byte[1];
- b[0] = (byte) ((translateLeadIdentifierByte(identifierencoding) | (byte) (identifier & 0x1f)) & 0xdf);
- //System.out.println("Identifier2: " + b[0]);
+ b[0] = (byte)((translateLeadIdentifierByte(identifierencoding)
+ | (byte)(identifier & 0x1f)) & 0xdf);
return b;
}
}
@@ -130,25 +127,17 @@ class DERWriter
if (length > 127)
{
int count = (int) Math.ceil(Math.log(length) / Math.log(256));
- //System.out.println("Length byte count: " + count);
b = new byte[count + 1];
- b[0] = (byte) ((count & 0x7f) | 0x80);
+ b[0] = (byte)((count & 0x7f) | 0x80);
for (int i = 1; i < (count + 1); i++)
- {
- b[i] = (byte) (length >>> (8 * (count - i)));
- //System.out.println("Length1 byte1: " + (length >>> (8 * ( count - i) )));
- //System.out.println("Length1 byte2: " + b[i]);
- }
-
- //System.out.println("Length1: " + length);
+ b[i] = (byte) (length >>> (8 * (count - i)));
return b;
}
else
{
b = new byte[1];
b[0] = (byte) (length & 0x7f);
- //System.out.println("Length2: " + length);
return b;
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java b/libjava/classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java
index 0c071561b6f..652793b04ff 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java
@@ -48,24 +48,17 @@ import java.security.SecureRandomSpi;
import java.util.HashMap;
/**
- * Implementation of the <i>Service Provider Interface</i> (<b>SPI</b>)
- * for the ARCFOUR keystream generator.
+ * Implementation of the <i>Service Provider Interface</i> (<b>SPI</b>) for
+ * the ARCFOUR keystream generator.
*/
-public class ARCFourRandomSpi extends SecureRandomSpi
+public class ARCFourRandomSpi
+ extends SecureRandomSpi
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Our underlying prng instance. */
private IRandom adaptee;
-
/** Have we been initialized? */
private boolean virgin;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Default 0-arguments constructor.
*/
@@ -76,20 +69,10 @@ public class ARCFourRandomSpi extends SecureRandomSpi
virgin = true;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.SecureRandomSpi interface implementation ------------------
-
public byte[] engineGenerateSeed(int numBytes)
{
if (numBytes < 1)
- {
- return new byte[0];
- }
+ return new byte[0];
byte[] result = new byte[numBytes];
this.engineNextBytes(result);
return result;
@@ -98,9 +81,7 @@ public class ARCFourRandomSpi extends SecureRandomSpi
public void engineNextBytes(byte[] bytes)
{
if (virgin)
- {
- this.engineSetSeed(new byte[0]);
- }
+ this.engineSetSeed(new byte[0]);
try
{
adaptee.nextBytes(bytes, 0, bytes.length);
@@ -117,4 +98,4 @@ public class ARCFourRandomSpi extends SecureRandomSpi
adaptee.init(attributes);
virgin = false;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java b/libjava/classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
index c0aa015b065..6ded636aaf3 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
@@ -38,29 +38,22 @@ exception statement from your version. */
package gnu.javax.crypto.jce.prng;
-import gnu.java.security.Registry;
-import gnu.javax.crypto.prng.CSPRNG;
import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
+import gnu.javax.crypto.prng.CSPRNG;
import java.net.MalformedURLException;
import java.security.SecureRandomSpi;
/**
- * The implementation of the continuously-seeded SecureRandom
- * <i>Service Provider Interface</i> (<b>SPI</b>) adapter.<p>
+ * The implementation of the continuously-seeded SecureRandom <i>Service
+ * Provider Interface</i> (<b>SPI</b>) adapter.
*/
-public class CSPRNGSpi extends SecureRandomSpi
+public class CSPRNGSpi
+ extends SecureRandomSpi
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private final IRandom adaptee;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public CSPRNGSpi() throws ClassNotFoundException, MalformedURLException,
NumberFormatException
{
@@ -69,20 +62,13 @@ public class CSPRNGSpi extends SecureRandomSpi
adaptee = CSPRNG.getSystemInstance();
}
- // Instance methods
- // -------------------------------------------------------------------------
-
protected byte[] engineGenerateSeed(final int count)
{
if (count < 0)
- {
- throw new IllegalArgumentException("count must be nonnegative");
- }
+ throw new IllegalArgumentException("count must be nonnegative");
byte[] buf = new byte[count];
if (count == 0)
- {
- return buf;
- }
+ return buf;
engineNextBytes(buf);
return buf;
}
@@ -90,9 +76,7 @@ public class CSPRNGSpi extends SecureRandomSpi
protected void engineNextBytes(final byte[] buffer)
{
if (buffer == null)
- {
- throw new NullPointerException();
- }
+ throw new NullPointerException();
try
{
adaptee.nextBytes(buffer, 0, buffer.length);
@@ -106,9 +90,7 @@ public class CSPRNGSpi extends SecureRandomSpi
protected void engineSetSeed(final byte[] seed)
{
if (seed == null)
- {
- throw new NullPointerException();
- }
+ throw new NullPointerException();
adaptee.addRandomBytes(seed, 0, seed.length);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java b/libjava/classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java
index 7006bbbaddc..8e3782ef055 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java
@@ -40,24 +40,26 @@ package gnu.javax.crypto.jce.prng;
import gnu.java.security.prng.LimitReachedException;
import gnu.javax.crypto.prng.Fortuna;
+
import java.security.SecureRandomSpi;
import java.util.Collections;
-public final class FortunaImpl extends SecureRandomSpi
+public final class FortunaImpl
+ extends SecureRandomSpi
{
private final Fortuna adaptee;
- public FortunaImpl ()
+ public FortunaImpl()
{
- adaptee = new Fortuna ();
- adaptee.init (Collections.singletonMap (Fortuna.SEED, new byte[0]));
+ adaptee = new Fortuna();
+ adaptee.init(Collections.singletonMap(Fortuna.SEED, new byte[0]));
}
-
- protected void engineSetSeed (byte[] seed)
+
+ protected void engineSetSeed(byte[] seed)
{
synchronized (adaptee)
{
- adaptee.addRandomBytes (seed);
+ adaptee.addRandomBytes(seed);
}
}
@@ -67,19 +69,19 @@ public final class FortunaImpl extends SecureRandomSpi
{
try
{
- adaptee.nextBytes (buffer);
+ adaptee.nextBytes(buffer);
}
catch (LimitReachedException shouldNotHappen)
{
- throw new Error (shouldNotHappen);
+ throw new Error(shouldNotHappen);
}
}
}
- protected byte[] engineGenerateSeed (int numbytes)
+ protected byte[] engineGenerateSeed(int numbytes)
{
byte[] seed = new byte[numbytes];
- engineNextBytes (seed);
+ engineNextBytes(seed);
return seed;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java b/libjava/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java
index d04b782f9f5..9855f95bd98 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java
@@ -38,44 +38,27 @@ exception statement from your version. */
package gnu.javax.crypto.jce.prng;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
+import gnu.java.security.prng.LimitReachedException;
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.prng.ICMGenerator;
-import gnu.java.security.prng.LimitReachedException;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.SecureRandomSpi;
import java.util.HashMap;
import java.util.Random;
+import java.util.logging.Logger;
/**
- * <p>An <em>Adapter</em> class around {@link ICMGenerator} to allow using this
- * algorithm as a JCE {@link java.security.SecureRandom}.</p>
+ * An <em>Adapter</em> class around {@link ICMGenerator} to allow using this
+ * algorithm as a JCE {@link java.security.SecureRandom}.
*/
-public class ICMRandomSpi extends SecureRandomSpi
+public class ICMRandomSpi
+ extends SecureRandomSpi
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "ICMRandomSpi";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 0;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- /** Class-wide prng to generate random material for the underlying prng.*/
+ private static final Logger log = Logger.getLogger(ICMRandomSpi.class.getName());
+ /** Class-wide prng to generate random material for the underlying prng. */
private static final ICMGenerator prng; // blank final
static
{
@@ -86,28 +69,18 @@ public class ICMRandomSpi extends SecureRandomSpi
// error messages
private static final String MSG = "Exception while setting up an "
+ Registry.ICM_PRNG + " SPI: ";
-
private static final String RETRY = "Retry...";
-
private static final String LIMIT_REACHED_MSG = "Limit reached: ";
-
private static final String RESEED = "Re-seed...";
-
/** Our underlying prng instance. */
private ICMGenerator adaptee = new ICMGenerator();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
private static void resetLocalPRNG()
{
- if (DEBUG && debuglevel > 8)
- debug(">>> resetLocalPRNG()");
+ if (Configuration.DEBUG)
+ log.entering(ICMRandomSpi.class.getName(), "resetLocalPRNG");
HashMap attributes = new HashMap();
attributes.put(ICMGenerator.CIPHER, Registry.AES_CIPHER);
byte[] key = new byte[128 / 8]; // AES default key size
@@ -122,50 +95,39 @@ public class ICMRandomSpi extends SecureRandomSpi
// choose a random value between 1 and aesBlockSize / 2
int limit = aesBlockSize / 2;
while (ndxLen < 1 || ndxLen > limit)
- {
- ndxLen = rand.nextInt(limit + 1);
- }
- attributes.put(ICMGenerator.SEGMENT_INDEX_LENGTH, new Integer(ndxLen));
+ ndxLen = rand.nextInt(limit + 1);
+ attributes.put(ICMGenerator.SEGMENT_INDEX_LENGTH, Integer.valueOf(ndxLen));
byte[] index = new byte[ndxLen];
rand.nextBytes(index);
attributes.put(ICMGenerator.SEGMENT_INDEX, new BigInteger(1, index));
-
prng.setup(attributes);
- if (DEBUG && debuglevel > 8)
- debug("<<< resetLocalPRNG()");
+ if (Configuration.DEBUG)
+ log.exiting(ICMRandomSpi.class.getName(), "resetLocalPRNG");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.SecureRandomSpi interface implementation ------------------
-
public byte[] engineGenerateSeed(int numBytes)
{
- if (DEBUG && debuglevel > 8)
- debug(">>> engineGenerateSeed()");
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineGenerateSeed");
if (numBytes < 1)
{
- if (DEBUG && debuglevel > 8)
- debug("<<< engineGenerateSeed()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGenerateSeed");
return new byte[0];
}
byte[] result = new byte[numBytes];
this.engineNextBytes(result);
- if (DEBUG && debuglevel > 8)
- debug("<<< engineGenerateSeed()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineGenerateSeed");
return result;
}
public void engineNextBytes(byte[] bytes)
{
- if (DEBUG && debuglevel > 8)
- debug(">>> engineNextBytes()");
- if (!adaptee.isInitialised())
- {
- this.engineSetSeed(new byte[0]);
- }
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineNextBytes");
+ if (! adaptee.isInitialised())
+ this.engineSetSeed(new byte[0]);
while (true)
{
try
@@ -175,30 +137,28 @@ public class ICMRandomSpi extends SecureRandomSpi
}
catch (LimitReachedException x)
{ // reseed the generator
- if (DEBUG)
+ if (Configuration.DEBUG)
{
- debug(LIMIT_REACHED_MSG + String.valueOf(x));
- x.printStackTrace(err);
- debug(RESEED);
+ log.fine(LIMIT_REACHED_MSG + String.valueOf(x));
+ log.fine(RESEED);
}
resetLocalPRNG();
}
}
- if (DEBUG && debuglevel > 8)
- debug("<<< engineNextBytes()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineNextBytes");
}
public void engineSetSeed(byte[] seed)
{
- if (DEBUG && debuglevel > 8)
- debug(">>> engineSetSeed()");
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineSetSeed");
// compute the total number of random bytes required to setup adaptee
int materialLength = 0;
materialLength += 16; // key material size
materialLength += 16; // offset size
materialLength += 8; // index size == half of an AES block
byte[] material = new byte[materialLength];
-
// use as much as possible bytes from the seed
int materialOffset = 0;
int materialLeft = material.length;
@@ -209,8 +169,8 @@ public class ICMRandomSpi extends SecureRandomSpi
materialOffset += lenToCopy;
materialLeft -= lenToCopy;
}
- if (materialOffset > 0)
- { // generate the rest
+ if (materialOffset > 0) // generate the rest
+ {
while (true)
{
try
@@ -224,22 +184,20 @@ public class ICMRandomSpi extends SecureRandomSpi
}
catch (LimitReachedException x)
{
- if (DEBUG)
+ if (Configuration.DEBUG)
{
- debug(MSG + String.valueOf(x));
- debug(RETRY);
+ log.fine(MSG + String.valueOf(x));
+ log.fine(RETRY);
}
}
}
}
-
// setup the underlying adaptee instance
HashMap attributes = new HashMap();
-
// use AES cipher with 128-bit block size
attributes.put(ICMGenerator.CIPHER, Registry.AES_CIPHER);
// use an index the size of quarter of an AES block
- attributes.put(ICMGenerator.SEGMENT_INDEX_LENGTH, new Integer(4));
+ attributes.put(ICMGenerator.SEGMENT_INDEX_LENGTH, Integer.valueOf(4));
// specify the key
byte[] key = new byte[16];
System.arraycopy(material, 0, key, 0, 16);
@@ -252,9 +210,8 @@ public class ICMRandomSpi extends SecureRandomSpi
byte[] index = new byte[8];
System.arraycopy(material, 32, index, 0, 8);
attributes.put(ICMGenerator.SEGMENT_INDEX, new BigInteger(1, index));
-
adaptee.init(attributes);
- if (DEBUG && debuglevel > 8)
- debug("<<< engineSetSeed()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineSetSeed");
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java b/libjava/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java
index 7dad68b2f95..f6949dd8d71 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java
@@ -38,65 +38,41 @@ exception statement from your version. */
package gnu.javax.crypto.jce.prng;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
-import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.java.security.prng.LimitReachedException;
+import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.prng.UMacGenerator;
-import java.io.PrintWriter;
import java.security.SecureRandomSpi;
import java.util.HashMap;
import java.util.Random;
+import java.util.logging.Logger;
/**
- * <p>An <em>Adapter</em> class around {@link UMacGenerator} to allow using this
- * algorithm as a JCE {@link java.security.SecureRandom}.</p>
+ * An <em>Adapter</em> class around {@link UMacGenerator} to allow using this
+ * algorithm as a JCE {@link java.security.SecureRandom}.
*/
-public class UMacRandomSpi extends SecureRandomSpi
+public class UMacRandomSpi
+ extends SecureRandomSpi
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "UMacRandomSpi";
-
- private static final boolean DEBUG = false;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- /** Class-wide prng to generate random material for the underlying prng.*/
+ private static final Logger log = Logger.getLogger(UMacRandomSpi.class.getName());
+ /** Class-wide prng to generate random material for the underlying prng. */
private static final UMacGenerator prng; // blank final
static
{
prng = new UMacGenerator();
resetLocalPRNG();
}
-
// error messages
private static final String MSG = "Exception while setting up a "
+ Registry.UMAC_PRNG + " SPI: ";
-
private static final String RETRY = "Retry...";
-
/** Our underlying prng instance. */
private UMacGenerator adaptee = new UMacGenerator();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
private static void resetLocalPRNG()
{
HashMap attributes = new HashMap();
@@ -106,22 +82,14 @@ public class UMacRandomSpi extends SecureRandomSpi
rand.nextBytes(key);
attributes.put(IBlockCipher.KEY_MATERIAL, key);
int index = rand.nextInt() & 0xFF;
- attributes.put(UMacGenerator.INDEX, new Integer(index));
-
+ attributes.put(UMacGenerator.INDEX, Integer.valueOf(index));
prng.setup(attributes);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.SecureRandomSpi interface implementation ------------------
-
public byte[] engineGenerateSeed(int numBytes)
{
if (numBytes < 1)
- {
- return new byte[0];
- }
+ return new byte[0];
byte[] result = new byte[numBytes];
this.engineNextBytes(result);
return result;
@@ -129,11 +97,8 @@ public class UMacRandomSpi extends SecureRandomSpi
public void engineNextBytes(byte[] bytes)
{
- if (!adaptee.isInitialised())
- {
- this.engineSetSeed(new byte[0]);
- }
-
+ if (! adaptee.isInitialised())
+ this.engineSetSeed(new byte[0]);
while (true)
{
try
@@ -155,7 +120,6 @@ public class UMacRandomSpi extends SecureRandomSpi
materialLength += 16; // key material size
materialLength++; // index size
byte[] material = new byte[materialLength];
-
// use as much as possible bytes from the seed
int materialOffset = 0;
int materialLeft = material.length;
@@ -166,8 +130,8 @@ public class UMacRandomSpi extends SecureRandomSpi
materialOffset += lenToCopy;
materialLeft -= lenToCopy;
}
- if (materialOffset > 0)
- { // generate the rest
+ if (materialOffset > 0) // generate the rest
+ {
while (true)
{
try
@@ -175,24 +139,22 @@ public class UMacRandomSpi extends SecureRandomSpi
prng.nextBytes(material, materialOffset, materialLeft);
break;
}
- catch (IllegalStateException x)
- { // should not happen
+ catch (IllegalStateException x) // should not happen
+ {
throw new InternalError(MSG + String.valueOf(x));
}
catch (LimitReachedException x)
{
- if (DEBUG)
+ if (Configuration.DEBUG)
{
- debug(MSG + String.valueOf(x));
- debug(RETRY);
+ log.fine(MSG + String.valueOf(x));
+ log.fine(RETRY);
}
}
}
}
-
// setup the underlying adaptee instance
HashMap attributes = new HashMap();
-
// use AES cipher with 128-bit block size
attributes.put(UMacGenerator.CIPHER, Registry.AES_CIPHER);
// specify the key
@@ -200,8 +162,7 @@ public class UMacRandomSpi extends SecureRandomSpi
System.arraycopy(material, 0, key, 0, 16);
attributes.put(IBlockCipher.KEY_MATERIAL, key);
// use a 1-byte index
- attributes.put(UMacGenerator.INDEX, new Integer(material[16] & 0xFF));
-
+ attributes.put(UMacGenerator.INDEX, Integer.valueOf(material[16] & 0xFF));
adaptee.init(attributes);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyFactory.java b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyFactory.java
index 701191adc34..98b265dd36c 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyFactory.java
@@ -79,7 +79,6 @@ public class DHKeyFactory
BigInteger y = spec.getY();
return new GnuDHPublicKey(Registry.X509_ENCODING_ID, null, p, g, y);
}
-
if (keySpec instanceof X509EncodedKeySpec)
{
X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
@@ -97,7 +96,6 @@ public class DHKeyFactory
throw y;
}
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
@@ -112,7 +110,6 @@ public class DHKeyFactory
BigInteger x = spec.getX();
return new GnuDHPrivateKey(Registry.PKCS8_ENCODING_ID, null, p, g, x);
}
-
if (keySpec instanceof PKCS8EncodedKeySpec)
{
PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
@@ -130,7 +127,6 @@ public class DHKeyFactory
throw y;
}
}
-
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
@@ -147,7 +143,6 @@ public class DHKeyFactory
BigInteger y = dssKey.getY();
return new DHPublicKeySpec(y, p, g);
}
-
if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
{
if (key instanceof GnuDHPublicKey)
@@ -156,19 +151,16 @@ public class DHKeyFactory
byte[] encoded = dhKey.getEncoded(Registry.X509_ENCODING_ID);
return new X509EncodedKeySpec(encoded);
}
-
if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new X509EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (public) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (public) key specification");
}
-
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
-
if (key instanceof DHPrivateKey)
{
if (keySpec.isAssignableFrom(DHPrivateKeySpec.class))
@@ -179,7 +171,6 @@ public class DHKeyFactory
BigInteger x = dhKey.getX();
return new DHPrivateKeySpec(x, p, g);
}
-
if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
{
if (key instanceof GnuDHPrivateKey)
@@ -188,27 +179,25 @@ public class DHKeyFactory
byte[] encoded = dhKey.getEncoded(Registry.PKCS8_ENCODING_ID);
return new PKCS8EncodedKeySpec(encoded);
}
-
if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new PKCS8EncodedKeySpec(encoded);
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported (private) key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported (private) key specification");
}
-
- throw new InvalidKeySpecException("Unsupported (private) key specification");
+ throw new InvalidKeySpecException(
+ "Unsupported (private) key specification");
}
-
- throw new InvalidKeySpecException("Wrong key type or unsupported key specification");
+ throw new InvalidKeySpecException(
+ "Wrong key type or unsupported key specification");
}
protected Key engineTranslateKey(Key key) throws InvalidKeyException
{
if ((key instanceof GnuDHPublicKey) || (key instanceof GnuDHPrivateKey))
return key;
-
if (key instanceof DHPublicKey)
{
DHPublicKey dsaKey = (DHPublicKey) key;
@@ -217,7 +206,6 @@ public class DHKeyFactory
BigInteger y = dsaKey.getY();
return new GnuDHPublicKey(Registry.X509_ENCODING_ID, null, p, g, y);
}
-
if (key instanceof DHPrivateKey)
{
DHPrivateKey dsaKey = (DHPrivateKey) key;
@@ -226,7 +214,6 @@ public class DHKeyFactory
BigInteger x = dsaKey.getX();
return new GnuDHPrivateKey(Registry.PKCS8_ENCODING_ID, null, p, g, x);
}
-
throw new InvalidKeyException("Wrong key type");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
index 0d09d5cef2c..e26f0712479 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
@@ -61,12 +61,12 @@ public class DHKeyPairGeneratorSpi
public void initialize(int keysize, SecureRandom random)
{
HashMap attributes = new HashMap();
- attributes.put(GnuDHKeyPairGenerator.PRIME_SIZE, new Integer(keysize));
+ attributes.put(GnuDHKeyPairGenerator.PRIME_SIZE, Integer.valueOf(keysize));
if (random != null)
attributes.put(GnuDHKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(GnuDHKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
@@ -87,7 +87,7 @@ public class DHKeyPairGeneratorSpi
attributes.put(GnuDHKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(GnuDHKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- new Integer(Registry.ASN1_ENCODING_ID));
+ Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java b/libjava/classpath/gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java
index 63e7740ec02..321b4779597 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/spec/BlockCipherParameterSpec.java
@@ -43,40 +43,26 @@ import gnu.java.security.util.Util;
import java.security.spec.AlgorithmParameterSpec;
/**
- * Block cipher parameters in GNU Crypto are the cipher's name, its block
- * and key sizes, and an optional initialization vector.
+ * Block cipher parameters in GNU are the cipher's name, its block and key
+ * sizes, and an optional initialization vector.
*/
-public class BlockCipherParameterSpec implements AlgorithmParameterSpec
+public class BlockCipherParameterSpec
+ implements AlgorithmParameterSpec
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
- /**
- * The initialization vector.
- */
+ /** The initialization vector. */
protected byte[] iv;
-
- /**
- * The cipher's block size, in bytes.
- */
+ /** The cipher's block size, in bytes. */
protected int blockSize;
-
- /**
- * The cipher's key size, in bytes.
- */
+ /** The cipher's key size, in bytes. */
protected int keySize;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Create a new parameter specification.
- *
- * @param iv The initialization vector, or <code>null</code> if
- * there is no IV.
+ *
+ * @param iv The initialization vector, or <code>null</code> if there is no
+ * IV.
* @param blockSize The cipher's block size, in bytes.
- * @param keySize The cipher's key size, in bytes.
+ * @param keySize The cipher's key size, in bytes.
*/
public BlockCipherParameterSpec(byte[] iv, int blockSize, int keySize)
{
@@ -87,22 +73,19 @@ public class BlockCipherParameterSpec implements AlgorithmParameterSpec
/**
* Create a new parameter specification with no IV.
- *
+ *
* @param blockSize The cipher's block size, in bytes.
- * @param keySize The cipher's key size, in bytes.
+ * @param keySize The cipher's key size, in bytes.
*/
public BlockCipherParameterSpec(int blockSize, int keySize)
{
this(null, blockSize, keySize);
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
/**
- * Get the initialization vector for the cipher, or <code>null</code>
- * if there is no IV.
- *
+ * Get the initialization vector for the cipher, or <code>null</code> if
+ * there is no IV.
+ *
* @return The IV.
*/
public byte[] getIV()
@@ -112,7 +95,7 @@ public class BlockCipherParameterSpec implements AlgorithmParameterSpec
/**
* Get the block size of the cipher these parameters are for.
- *
+ *
* @return The block size.
*/
public int getBlockSize()
@@ -122,7 +105,7 @@ public class BlockCipherParameterSpec implements AlgorithmParameterSpec
/**
* Get the key size of the cipher these parameters are for.
- *
+ *
* @return The block size.
*/
public int getKeySize()
@@ -133,7 +116,7 @@ public class BlockCipherParameterSpec implements AlgorithmParameterSpec
public String toString()
{
return getClass().getName() + " { "
- + ((iv != null) ? ("IV=" + Util.toString(iv)) + ", " : "") + "BS="
- + blockSize + ", KS=" + keySize + " }";
+ + ((iv != null) ? ("IV=" + Util.toString(iv)) + ", " : "")
+ + "BS=" + blockSize + ", KS=" + keySize + " }";
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java b/libjava/classpath/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
index 0ebec099107..35643728873 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
@@ -45,35 +45,27 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* This class represents the algorithm parameters for the Truncated
* Multi-Modular Hash function for use with JCE-derived instances of
- * {@link gnu.crypto.mac.TMMH16}.
- *
- * <p>This class is little more than a container for the key stream, tag
- * length, and prefix parameters for the TMMH algorithm.
+ * {@link gnu.javax.crypto.mac.TMMH16}.
+ * <p>
+ * This class is little more than a container for the key stream, tag length,
+ * and prefix parameters for the TMMH algorithm.
*/
-public class TMMHParameterSpec implements AlgorithmParameterSpec
+public class TMMHParameterSpec
+ implements AlgorithmParameterSpec
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
/** The keystream. */
protected IRandom keystream;
-
/** The tag length. */
protected Integer tagLength;
-
/** The prefix. */
protected byte[] prefix;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Create a new parameter specification.
- *
+ *
* @param keystream The (PRNG) key stream.
* @param tagLength The tag length.
- * @param prefix The prefix.
+ * @param prefix The prefix.
*/
public TMMHParameterSpec(IRandom keystream, Integer tagLength, byte[] prefix)
{
@@ -84,7 +76,7 @@ public class TMMHParameterSpec implements AlgorithmParameterSpec
/**
* Create a new parameter specification with no prefix.
- *
+ *
* @param keystream The (PRNG) key stream.
* @param tagLength The tag length.
*/
@@ -93,12 +85,9 @@ public class TMMHParameterSpec implements AlgorithmParameterSpec
this(keystream, tagLength, null);
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
/**
* Return the key stream this specification was initialized with.
- *
+ *
* @return The key stream.
*/
public IRandom getKeystream()
@@ -108,7 +97,7 @@ public class TMMHParameterSpec implements AlgorithmParameterSpec
/**
* Return the tag length this specification was initialized with.
- *
+ *
* @return The tag length.
*/
public Integer getTagLength()
@@ -117,13 +106,12 @@ public class TMMHParameterSpec implements AlgorithmParameterSpec
}
/**
- * Return the prefix, or <code>null</code> if no prefix was
- * specified.
- *
+ * Return the prefix, or <code>null</code> if no prefix was specified.
+ *
* @return The prefix.
*/
public byte[] getPrefix()
{
return prefix;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java b/libjava/classpath/gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java
index 47d807d4970..0990cc6d477 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/spec/UMac32ParameterSpec.java
@@ -41,25 +41,19 @@ package gnu.javax.crypto.jce.spec;
import java.security.spec.AlgorithmParameterSpec;
/**
- * This class represents the parameters for the UMAC-32 message
- * authentication code algorithm. In practice this means the
- * <i>Nonce</i> material used to initialize the algorithm.
+ * This class represents the parameters for the UMAC-32 message authentication
+ * code algorithm. In practice this means the <i>Nonce</i> material used to
+ * initialize the algorithm.
*/
-public class UMac32ParameterSpec implements AlgorithmParameterSpec
+public class UMac32ParameterSpec
+ implements AlgorithmParameterSpec
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
/** The <i>Nonce</i> material. */
protected byte[] nonce;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Create a new parameter instance.
- *
+ *
* @param nonce The nonce material.
*/
public UMac32ParameterSpec(byte[] nonce)
@@ -67,16 +61,13 @@ public class UMac32ParameterSpec implements AlgorithmParameterSpec
this.nonce = nonce;
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
/**
* Return the nonce material.
- *
+ *
* @return The nonce material.
*/
public byte[] getNonce()
{
return nonce;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/BaseKeyAgreementParty.java b/libjava/classpath/gnu/javax/crypto/key/BaseKeyAgreementParty.java
index bfd9378d2fc..fc5ddb7145f 100644
--- a/libjava/classpath/gnu/javax/crypto/key/BaseKeyAgreementParty.java
+++ b/libjava/classpath/gnu/javax/crypto/key/BaseKeyAgreementParty.java
@@ -47,41 +47,28 @@ import java.security.SecureRandom;
import java.util.Map;
/**
- * <p>A base abstract class to facilitate implementations of concrete key
- * agreement protocol handlers.</p>
+ * A base abstract class to facilitate implementations of concrete key agreement
+ * protocol handlers.
*/
-public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
+public abstract class BaseKeyAgreementParty
+ implements IKeyAgreementParty
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
protected static final BigInteger TWO = BigInteger.valueOf(2L);
-
/** The canonical name of the protocol. */
protected String name;
-
/** Whether the instance is initialised or not. */
protected boolean initialised = false;
-
/** The current step index of the protocol exchange. */
protected int step = -1;
-
/** Whether the exchange has concluded or not. */
protected boolean complete = false;
-
/** The optional {@link SecureRandom} instance to use. */
protected SecureRandom rnd = null;
-
/** The optional {@link IRandom} instance to use. */
protected IRandom irnd = null;
-
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected BaseKeyAgreementParty(String name)
{
super();
@@ -89,12 +76,6 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
this.name = name;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public String name()
{
return name;
@@ -103,12 +84,8 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
public void init(Map attributes) throws KeyAgreementException
{
if (initialised)
- {
- throw new IllegalStateException("already initialised");
- }
-
+ throw new IllegalStateException("already initialised");
this.engineInit(attributes);
-
initialised = true;
this.step = -1;
this.complete = false;
@@ -117,15 +94,10 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
public OutgoingMessage processMessage(IncomingMessage in)
throws KeyAgreementException
{
- if (!initialised)
- {
- throw new IllegalStateException("not initialised");
- }
+ if (! initialised)
+ throw new IllegalStateException("not initialised");
if (complete)
- {
- throw new IllegalStateException("exchange has already concluded");
- }
-
+ throw new IllegalStateException("exchange has already concluded");
step++;
return this.engineProcessMessage(in);
}
@@ -137,14 +109,10 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
public byte[] getSharedSecret() throws KeyAgreementException
{
- if (!initialised)
- {
- throw new KeyAgreementException("not yet initialised");
- }
- if (!isComplete())
- {
- throw new KeyAgreementException("not yet computed");
- }
+ if (! initialised)
+ throw new KeyAgreementException("not yet initialised");
+ if (! isComplete())
+ throw new KeyAgreementException("not yet computed");
return engineSharedSecret();
}
@@ -157,8 +125,6 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
}
}
- // abstract methods to be implemented by concrete subclasses ---------------
-
protected abstract void engineInit(Map attributes)
throws KeyAgreementException;
@@ -169,31 +135,25 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
protected abstract void engineReset();
- // helper methods ----------------------------------------------------------
-
/**
* Fills the designated byte array with random data.
- *
+ *
* @param buffer the byte array to fill with random data.
*/
protected void nextRandomBytes(byte[] buffer)
{
if (rnd != null)
- {
- rnd.nextBytes(buffer);
- }
+ rnd.nextBytes(buffer);
else if (irnd != null)
- {
- try
- {
- irnd.nextBytes(buffer, 0, buffer.length);
- }
- catch (LimitReachedException lre)
- {
- irnd = null;
- getDefaultPRNG().nextBytes(buffer);
- }
- }
+ try
+ {
+ irnd.nextBytes(buffer, 0, buffer.length);
+ }
+ catch (LimitReachedException lre)
+ {
+ irnd = null;
+ getDefaultPRNG().nextBytes(buffer);
+ }
else
getDefaultPRNG().nextBytes(buffer);
}
@@ -205,4 +165,4 @@ public abstract class BaseKeyAgreementParty implements IKeyAgreementParty
return prng;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/GnuSecretKey.java b/libjava/classpath/gnu/javax/crypto/key/GnuSecretKey.java
index 93b21a67cc3..3063fe406d1 100644
--- a/libjava/classpath/gnu/javax/crypto/key/GnuSecretKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/GnuSecretKey.java
@@ -42,27 +42,20 @@ import gnu.java.security.util.Util;
import java.security.Key;
/**
- * A secret key composed of a sequence of raw, unformatted octets. This class
- * is analogous to the {@link javax.crypto.spec.SecretKeySpec} class, but is
+ * A secret key composed of a sequence of raw, unformatted octets. This class is
+ * analogous to the {@link javax.crypto.spec.SecretKeySpec} class, but is
* provided for platforms that do not or cannot contain that class.
*/
-public class GnuSecretKey implements Key
+public class GnuSecretKey
+ implements Key
{
-
- // Field.
- // ------------------------------------------------------------------------
-
private final byte[] key;
-
private final String algorithm;
- // Constructors.
- // ------------------------------------------------------------------------
-
/**
* Creates a new secret key. The supplied byte array is copied by this
* constructor.
- *
+ *
* @param key The raw, secret key.
* @param algorithm The algorithm name, which can be null or empty.
*/
@@ -73,7 +66,7 @@ public class GnuSecretKey implements Key
/**
* Creates a new secret key from a portion of a byte array.
- *
+ *
* @param key The raw, secret key.
* @param offset The offset at which the key begins.
* @param length The number of bytes that comprise the key.
@@ -86,12 +79,9 @@ public class GnuSecretKey implements Key
this.algorithm = algorithm;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Returns the algorithm name, if any.
- *
+ *
* @return The algorithm name.
*/
public String getAlgorithm()
@@ -103,7 +93,7 @@ public class GnuSecretKey implements Key
* Returns the encoded key, which is merely the byte array this class was
* created with. A reference to the internal byte array is returned, so the
* caller can delete this key from memory by modifying the returned array.
- *
+ *
* @return The raw key.
*/
public byte[] getEncoded()
@@ -113,7 +103,7 @@ public class GnuSecretKey implements Key
/**
* Returns the string "RAW".
- *
+ *
* @return The string "RAW".
*/
public String getFormat()
@@ -123,22 +113,14 @@ public class GnuSecretKey implements Key
public boolean equals(Object o)
{
- if (!(o instanceof GnuSecretKey))
- {
- return false;
- }
+ if (! (o instanceof GnuSecretKey))
+ return false;
if (key.length != ((GnuSecretKey) o).key.length)
- {
- return false;
- }
+ return false;
byte[] key2 = ((GnuSecretKey) o).key;
for (int i = 0; i < key.length; i++)
- {
- if (key[i] != key2[i])
- {
- return false;
- }
- }
+ if (key[i] != key2[i])
+ return false;
return true;
}
@@ -146,4 +128,4 @@ public class GnuSecretKey implements Key
{
return "GnuSecretKey [ " + algorithm + " " + Util.toString(key) + " ]";
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/IKeyAgreementParty.java b/libjava/classpath/gnu/javax/crypto/key/IKeyAgreementParty.java
index 05aef5e51d7..280f3f33d97 100644
--- a/libjava/classpath/gnu/javax/crypto/key/IKeyAgreementParty.java
+++ b/libjava/classpath/gnu/javax/crypto/key/IKeyAgreementParty.java
@@ -41,65 +41,60 @@ package gnu.javax.crypto.key;
import java.util.Map;
/**
- * <p>The visible methods of an key agreement protocol participating party.</p>
+ * The visible methods of an key agreement protocol participating party.
*/
public interface IKeyAgreementParty
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of the key agreement protocol.</p>
- *
+ * Returns the canonical name of the key agreement protocol.
+ *
* @return the canonical name of the key agreement protocol.
*/
String name();
/**
- * <p>Sets up the instance to operate with specific attributes.</p>
- *
+ * Sets up the instance to operate with specific attributes.
+ *
* @param attributes a map of name-values used by concrete implementations.
* @throws KeyAgreementException if an exception occurs during the setup.
*/
void init(Map attributes) throws KeyAgreementException;
/**
- * <p>Processes an incoming message at one end, generating a message that
- * will be processed by the other party(ies).</p>
- *
+ * Processes an incoming message at one end, generating a message that will be
+ * processed by the other party(ies).
+ *
* @param in the incoming message.
* @return an outgoing message, or <code>null</code> if this is an
- * intermediary step that does not cause any output.
+ * intermediary step that does not cause any output.
* @throws KeyAgreementException if an exception occurs during the processing
- * of the incoming message, or during the generation of the outgoing message.
+ * of the incoming message, or during the generation of the outgoing
+ * message.
*/
OutgoingMessage processMessage(IncomingMessage in)
throws KeyAgreementException;
/**
- * <p>Returns <code>true</code> if the party in the key agreement protocol
+ * Returns <code>true</code> if the party in the key agreement protocol
* exchange has completed its part of the exchange. If this is the case an
* {@link IllegalStateException} is thrown for any method invocation except
* <code>init()</code> or <code>reset()</code>.
+ *
* @return <code>true</code> if this party has completed its part of the key
- * agreement protocol exchange; <code>false</code> otherwise.
+ * agreement protocol exchange; <code>false</code> otherwise.
*/
boolean isComplete();
/**
- * <p>Returns the byte array containing the shared secret as generated by
- * this party.</p>
- *
+ * Returns the byte array containing the shared secret as generated by this
+ * party.
+ *
* @return the generated shared secret.
* @throws KeyAgreementException if the key agreement is not yet initialised,
- * or is initialised but the exchange is still in progress.
+ * or is initialised but the exchange is still in progress.
*/
byte[] getSharedSecret() throws KeyAgreementException;
/** Resets this instance for re-use with another set of attributes. */
void reset();
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/IncomingMessage.java b/libjava/classpath/gnu/javax/crypto/key/IncomingMessage.java
index e04c85399fc..9701d80a79d 100644
--- a/libjava/classpath/gnu/javax/crypto/key/IncomingMessage.java
+++ b/libjava/classpath/gnu/javax/crypto/key/IncomingMessage.java
@@ -58,30 +58,22 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>An implementation of an incoming message for use with key agreement
- * protocols.</p>
+ * An implementation of an incoming message for use with key agreement
+ * protocols.
*/
public class IncomingMessage
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The internal buffer stream containing the message's contents. */
protected ByteArrayInputStream in;
-
/** The length of the message contents, according to its 4-byte header. */
protected int length;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Constructs an incoming message given the message's encoded form,
- * including its header bytes.</p>
- *
+ * Constructs an incoming message given the message's encoded form, including
+ * its header bytes.
+ *
* @param b the encoded form, including the header bytes, of an incoming
- * message.
+ * message.
* @throws KeyAgreementException if the buffer is malformed.
*/
public IncomingMessage(byte[] b) throws KeyAgreementException
@@ -89,15 +81,13 @@ public class IncomingMessage
this();
if (b.length < 4)
- {
- throw new KeyAgreementException("message header too short");
- }
- length = b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8
- | (b[3] & 0xFF);
+ throw new KeyAgreementException("message header too short");
+ length = b[0] << 24
+ | (b[1] & 0xFF) << 16
+ | (b[2] & 0xFF) << 8
+ | (b[3] & 0xFF);
if (length > Registry.SASL_BUFFER_MAX_LIMIT || length < 0)
- {
- throw new KeyAgreementException("message size limit exceeded");
- }
+ throw new KeyAgreementException("message size limit exceeded");
in = new ByteArrayInputStream(b, 4, length);
}
@@ -107,16 +97,13 @@ public class IncomingMessage
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a message given its encoded contents, excluding
- * the message's header bytes.</p>
- *
- * <p>Calls the method with the same name and three arguments as:
+ * Returns an instance of a message given its encoded contents, excluding the
+ * message's header bytes.
+ * <p>
+ * Calls the method with the same name and three arguments as:
* <code>getInstance(raw, 0, raw.length)</code>.
- *
+ *
* @param raw the encoded form, excluding the header bytes.
* @return a new instance of <code>IncomingMessage</code>.
*/
@@ -126,9 +113,9 @@ public class IncomingMessage
}
/**
- * <p>Returns an instance of a message given its encoded contents, excluding
- * the message's header bytes.</p>
- *
+ * Returns an instance of a message given its encoded contents, excluding the
+ * message's header bytes.
+ *
* @param raw the encoded form, excluding the header bytes.
* @param offset offset where to start using raw bytes from.
* @param len number of bytes to use.
@@ -142,8 +129,8 @@ public class IncomingMessage
}
/**
- * <p>Converts two octets into the number that they represent.</p>
- *
+ * Converts two octets into the number that they represent.
+ *
* @param b the two octets.
* @return the length.
*/
@@ -151,32 +138,27 @@ public class IncomingMessage
{
int result = (b[0] & 0xFF) << 8 | (b[1] & 0xFF);
if (result > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new KeyAgreementException("encoded MPI size limit exceeded");
- }
+ throw new KeyAgreementException("encoded MPI size limit exceeded");
return result;
}
/**
- * <p>Converts four octets into the number that they represent.</p>
- *
+ * Converts four octets into the number that they represent.
+ *
* @param b the four octets.
* @return the length.
*/
public static int fourBytesToLength(byte[] b) throws KeyAgreementException
{
- int result = b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8
- | (b[3] & 0xFF);
+ int result = b[0] << 24
+ | (b[1] & 0xFF) << 16
+ | (b[2] & 0xFF) << 8
+ | (b[3] & 0xFF);
if (result > Registry.SASL_FOUR_BYTE_MAX_LIMIT || result < 0)
- {
- throw new KeyAgreementException("encoded entity size limit exceeded");
- }
+ throw new KeyAgreementException("encoded entity size limit exceeded");
return result;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public boolean hasMoreElements()
{
return (in.available() > 0);
@@ -195,18 +177,15 @@ public class IncomingMessage
{
if (in.available() < 5)
throw new KeyAgreementException("not enough bytes for a public key in message");
-
byte[] elementLengthBytes = new byte[4];
in.read(elementLengthBytes, 0, 4);
int elementLength = fourBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
throw new KeyAgreementException("illegal public key encoding");
-
int keyTypeAndFormatID = in.read() & 0xFF;
elementLength--;
byte[] kb = new byte[elementLength];
in.read(kb, 0, elementLength);
-
// instantiate the right codec and decode
IKeyPairCodec kpc = getKeyPairCodec(keyTypeAndFormatID);
return kpc.decodePublicKey(kb);
@@ -225,66 +204,50 @@ public class IncomingMessage
{
if (in.available() < 5)
throw new KeyAgreementException("not enough bytes for a private key in message");
-
byte[] elementLengthBytes = new byte[4];
in.read(elementLengthBytes, 0, 4);
int elementLength = fourBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
throw new KeyAgreementException("illegal private key encoding");
-
int keyTypeAndFormatID = in.read() & 0xFF;
elementLength--;
byte[] kb = new byte[elementLength];
in.read(kb, 0, elementLength);
-
// instantiate the right codec and decode
IKeyPairCodec kpc = getKeyPairCodec(keyTypeAndFormatID);
return kpc.decodePrivateKey(kb);
}
/**
- * <p>Decodes an MPI from the current message's contents.</p>
- *
+ * Decodes an MPI from the current message's contents.
+ *
* @return a native representation of an MPI.
* @throws KeyAgreementException if an encoding exception occurs during the
- * operation.
+ * operation.
*/
public BigInteger readMPI() throws KeyAgreementException
{
if (in.available() < 2)
- {
- throw new KeyAgreementException(
- "not enough bytes for an MPI in message");
- }
+ throw new KeyAgreementException("not enough bytes for an MPI in message");
byte[] elementLengthBytes = new byte[2];
in.read(elementLengthBytes, 0, 2);
int elementLength = twoBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
- {
- throw new KeyAgreementException("illegal MPI encoding");
- }
-
+ throw new KeyAgreementException("illegal MPI encoding");
byte[] element = new byte[elementLength];
in.read(element, 0, element.length);
-
return new BigInteger(1, element);
}
public String readString() throws KeyAgreementException
{
if (in.available() < 2)
- {
- throw new KeyAgreementException(
- "not enough bytes for a text in message");
- }
+ throw new KeyAgreementException("not enough bytes for a text in message");
byte[] elementLengthBytes = new byte[2];
in.read(elementLengthBytes, 0, 2);
int elementLength = twoBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
- {
- throw new KeyAgreementException("illegal text encoding");
- }
-
+ throw new KeyAgreementException("illegal text encoding");
byte[] element = new byte[elementLength];
in.read(element, 0, element.length);
String result = null;
@@ -296,7 +259,6 @@ public class IncomingMessage
{
throw new KeyAgreementException("unxupported UTF8 encoding", x);
}
-
return result;
}
@@ -353,4 +315,4 @@ public class IncomingMessage
+ formatID);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/KeyAgreementException.java b/libjava/classpath/gnu/javax/crypto/key/KeyAgreementException.java
index c2fa434a224..f0fb1bb83f9 100644
--- a/libjava/classpath/gnu/javax/crypto/key/KeyAgreementException.java
+++ b/libjava/classpath/gnu/javax/crypto/key/KeyAgreementException.java
@@ -44,26 +44,19 @@ import java.io.Serializable;
import java.security.KeyManagementException;
/**
- * A generic exception indicating that an unexpected condition has
- * been detected during the setup and/or processing of a key agreement
- * protocol exchange.
+ * A generic exception indicating that an unexpected condition has been detected
+ * during the setup and/or processing of a key agreement protocol exchange.
*/
-public class KeyAgreementException extends KeyManagementException implements
- Serializable
+public class KeyAgreementException
+ extends KeyManagementException
+ implements Serializable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** @serial The possibly <code>null</code> <i>root</i> cause exception. */
private Throwable cause = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Constructs a new instance of <code>KeyAgreementException</code>. The
- * root exception and the detailed message are <code>null</code>.</p>
+ * Constructs a new instance of <code>KeyAgreementException</code>. The
+ * root exception and the detailed message are <code>null</code>.
*/
public KeyAgreementException()
{
@@ -71,11 +64,11 @@ public class KeyAgreementException extends KeyManagementException implements
}
/**
- * <p>Constructs a new instance of <code>KeyAgreementException</code> with a
- * detailed message. The <i>root</i> exception is <code>null</code>.</p>
- *
+ * Constructs a new instance of <code>KeyAgreementException</code> with a
+ * detailed message. The <i>root</i> exception is <code>null</code>.
+ *
* @param detail a possibly <code>null</code> string containing details of
- * the exception.
+ * the exception.
* @see Throwable#getMessage()
*/
public KeyAgreementException(String detail)
@@ -84,13 +77,13 @@ public class KeyAgreementException extends KeyManagementException implements
}
/**
- * <p>Constructs a new instance of <code>KeyAgreementException</code> with a
- * detailed message and a <i>root</i> exception.</p>
- *
+ * Constructs a new instance of <code>KeyAgreementException</code> with a
+ * detailed message and a <i>root</i> exception.
+ *
* @param detail a possibly <code>null</code> string containing details of
- * the exception.
+ * the exception.
* @param cause a possibly <code>null</code> root exception that caused this
- * exception.
+ * exception.
* @see Throwable#getMessage()
* @see #getCause()
*/
@@ -100,17 +93,11 @@ public class KeyAgreementException extends KeyManagementException implements
this.cause = cause;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the cause of this throwable or <code>null</code> if the cause
- * is nonexistent or unknown. The <i>cause</i> is the throwable that caused
- * this exception to be thrown.</p>
- *
+ * Returns the cause of this throwable or <code>null</code> if the cause is
+ * nonexistent or unknown. The <i>cause</i> is the throwable that caused this
+ * exception to be thrown.
+ *
* @return the possibly <code>null</code> exception that caused this one.
*/
public Throwable getCause()
@@ -119,69 +106,61 @@ public class KeyAgreementException extends KeyManagementException implements
}
/**
- * <p>Prints this exception's stack trace to <code>System.err</code>. If this
+ * Prints this exception's stack trace to <code>System.err</code>. If this
* exception has a <i>root</i> exception; the stack trace of the <i>root</i>
- * exception is also printed to <code>System.err</code>.</p>
+ * exception is also printed to <code>System.err</code>.
*/
public void printStackTrace()
{
super.printStackTrace();
if (cause != null)
- {
- cause.printStackTrace();
- }
+ cause.printStackTrace();
}
/**
- * <p>Prints this exception's stack trace to a print stream. If this
- * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
- * exception is also printed to the print stream.</p>
- *
+ * Prints this exception's stack trace to a print stream. If this exception
+ * has a <i>root</i> exception; the stack trace of the <i>root</i> exception
+ * is also printed to the print stream.
+ *
* @param ps the non-null print stream to which to print.
*/
public void printStackTrace(PrintStream ps)
{
super.printStackTrace(ps);
if (cause != null)
- {
- cause.printStackTrace(ps);
- }
+ cause.printStackTrace(ps);
}
/**
- * <p>Prints this exception's stack trace to a print writer. If this
- * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
- * exception is also printed to the print writer.</p>
- *
+ * Prints this exception's stack trace to a print writer. If this exception
+ * has a <i>root</i> exception; the stack trace of the <i>root</i> exception
+ * is also printed to the print writer.
+ *
* @param pw the non-null print writer to use for output.
*/
public void printStackTrace(PrintWriter pw)
{
super.printStackTrace(pw);
if (cause != null)
- {
- cause.printStackTrace(pw);
- }
+ cause.printStackTrace(pw);
}
/**
- * <p>Returns the string representation of this exception. The string
- * representation contains this exception's class name, its detailed
- * messsage, and if it has a <i>root</i> exception, the string representation
- * of the root exception. This string representation is meant for debugging
- * and is not meant to be interpreted programmatically.</p>
- *
+ * Returns the string representation of this exception. The string
+ * representation contains this exception's class name, its detailed messsage,
+ * and if it has a <i>root</i> exception, the string representation of the
+ * root exception. This string representation is meant for debugging and is
+ * not meant to be interpreted programmatically.
+ *
* @return the non-null string representation of this exception.
* @see Throwable#getMessage()
*/
public String toString()
{
- StringBuffer sb = new StringBuffer(this.getClass().getName()).append(": ").append(
- super.toString());
+ StringBuffer sb = new StringBuffer(this.getClass().getName()).append(": ")
+ .append(super.toString());
if (cause != null)
- {
- sb.append("; caused by: ").append(cause.toString());
- }
+ sb.append("; caused by: ").append(cause.toString());
return sb.toString();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/KeyAgreementFactory.java b/libjava/classpath/gnu/javax/crypto/key/KeyAgreementFactory.java
index e2a7faba18a..ae9bf36ff3a 100644
--- a/libjava/classpath/gnu/javax/crypto/key/KeyAgreementFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/key/KeyAgreementFactory.java
@@ -56,115 +56,77 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>A <i>Factory</i> class to generate key agreement protocol handlers.</p>
+ * A <i>Factory</i> class to generate key agreement protocol handlers.
*/
public class KeyAgreementFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
private KeyAgreementFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a key agreeent protocol handler, for party
+ * Returns an instance of a key agreeent protocol handler, for party
* <code>A</code> in a two-party <code>A..B</code> exchange, given the
* canonical name of this protocol. Party <code>A</code> is usually the
- * initiator of the exchange.</p>
- *
+ * initiator of the exchange.
+ *
* @param name the case-insensitive key agreement protocol name.
* @return an instance of the key agreement protocol handler for party
- * <code>A</code>, or <code>null</code> if none found.
+ * <code>A</code>, or <code>null</code> if none found.
*/
public static IKeyAgreementParty getPartyAInstance(String name)
{
if (name == null)
- {
- return null;
- }
-
+ return null;
name = name.trim();
IKeyAgreementParty result = null;
if (name.equalsIgnoreCase(Registry.DH_KA))
- {
- result = new DiffieHellmanSender();
- }
+ result = new DiffieHellmanSender();
else if (name.equalsIgnoreCase(Registry.ELGAMAL_KA))
- {
- result = new ElGamalSender();
- }
+ result = new ElGamalSender();
else if (name.equalsIgnoreCase(Registry.SRP6_KA))
- {
- result = new SRP6User();
- }
+ result = new SRP6User();
else if (name.equalsIgnoreCase(Registry.SRP_SASL_KA))
- {
- result = new SRP6SaslClient();
- }
+ result = new SRP6SaslClient();
else if (name.equalsIgnoreCase(Registry.SRP_TLS_KA))
- {
- result = new SRP6TLSClient();
- }
-
+ result = new SRP6TLSClient();
return result;
}
/**
- * <p>Returns an instance of a key agreeent protocol handler, for party
+ * Returns an instance of a key agreeent protocol handler, for party
* <code>B</code> in a two-party <code>A..B</code> exchange, given the
- * canonical name of this protocol.</p>
- *
+ * canonical name of this protocol.
+ *
* @param name the case-insensitive key agreement protocol name.
* @return an instance of the key agreement protocol handler for party
- * <code>B</code>, or <code>null</code> if none found.
+ * <code>B</code>, or <code>null</code> if none found.
*/
public static IKeyAgreementParty getPartyBInstance(String name)
{
if (name == null)
- {
- return null;
- }
-
+ return null;
name = name.trim();
IKeyAgreementParty result = null;
if (name.equalsIgnoreCase(Registry.DH_KA))
- {
- result = new DiffieHellmanReceiver();
- }
+ result = new DiffieHellmanReceiver();
else if (name.equalsIgnoreCase(Registry.ELGAMAL_KA))
- {
- result = new ElGamalReceiver();
- }
+ result = new ElGamalReceiver();
else if (name.equalsIgnoreCase(Registry.SRP6_KA))
- {
- result = new SRP6Host();
- }
+ result = new SRP6Host();
else if (name.equalsIgnoreCase(Registry.SRP_SASL_KA))
- {
- result = new SRP6SaslServer();
- }
+ result = new SRP6SaslServer();
else if (name.equalsIgnoreCase(Registry.SRP_TLS_KA))
- {
- result = new SRP6TLSServer();
- }
-
+ result = new SRP6TLSServer();
return result;
}
/**
- * <p>Returns a {@link Set} of key agreement protocol names supported by this
- * <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of key agreement protocol names supported by this
+ * <i>Factory</i>.
+ *
* @return a {@link Set} of key agreement protocol names (Strings).
*/
public static final Set getNames()
@@ -178,4 +140,4 @@ public class KeyAgreementFactory
return Collections.unmodifiableSet(hs);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/OutgoingMessage.java b/libjava/classpath/gnu/javax/crypto/key/OutgoingMessage.java
index 588012120ce..563b3ef5ae6 100644
--- a/libjava/classpath/gnu/javax/crypto/key/OutgoingMessage.java
+++ b/libjava/classpath/gnu/javax/crypto/key/OutgoingMessage.java
@@ -53,21 +53,13 @@ import java.security.PublicKey;
import java.math.BigInteger;
/**
- * <p>An implementation of outgoing messages for use with key agreement
- * protocols.</p>
+ * An implementation of outgoing messages for use with key agreement protocols.
*/
public class OutgoingMessage
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The internal output stream. */
private ByteArrayOutputStream out;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public OutgoingMessage()
{
super();
@@ -75,16 +67,10 @@ public class OutgoingMessage
out = new ByteArrayOutputStream();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the encoded form of the current message including the 4-byte
- * length header.</p>
- *
+ * Returns the encoded form of the current message including the 4-byte length
+ * header.
+ *
* @throws KeyAgreementException if an encoding size constraint is violated.
*/
public byte[] toByteArray() throws KeyAgreementException
@@ -92,28 +78,25 @@ public class OutgoingMessage
byte[] buffer = wrap();
int length = buffer.length;
byte[] result = new byte[length + 4];
- result[0] = (byte) (length >>> 24);
- result[1] = (byte) (length >>> 16);
- result[2] = (byte) (length >>> 8);
+ result[0] = (byte)(length >>> 24);
+ result[1] = (byte)(length >>> 16);
+ result[2] = (byte)(length >>> 8);
result[3] = (byte) length;
System.arraycopy(buffer, 0, result, 4, length);
-
return result;
}
/**
- * <p>Returns the encoded form of the current message excluding the 4-byte
- * length header.</p>
- *
+ * Returns the encoded form of the current message excluding the 4-byte length
+ * header.
+ *
* @throws KeyAgreementException if an encoding size constraint is violated.
*/
public byte[] wrap() throws KeyAgreementException
{
int length = out.size();
if (length > Registry.SASL_BUFFER_MAX_LIMIT || length < 0)
- {
- throw new KeyAgreementException("message content is too long");
- }
+ throw new KeyAgreementException("message content is too long");
return out.toByteArray();
}
@@ -128,9 +111,8 @@ public class OutgoingMessage
* representing the total length, excluding these 4 bytes, of the bytes
* representing the encoded key and the one-byte representing the key-type and
* format; i.e.
- *
* <pre>
- * key --&gt; 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
+ * key --&gt; 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
* </pre>
*
* @param k the public key to encode.
@@ -152,9 +134,8 @@ public class OutgoingMessage
* representing the total length, excluding these 4 bytes, of the bytes
* representing the encoded key and the one-byte representing the key-type and
* format; i.e.
- *
* <pre>
- * key --&gt; 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
+ * key --&gt; 4-byte-length || 1-byte-type-and-format || encoded-key-bytes
* </pre>
*
* @param k the private key to encode.
@@ -166,8 +147,8 @@ public class OutgoingMessage
}
/**
- * <p>Encodes an MPI into the message.</p>
- *
+ * Encodes an MPI into the message.
+ *
* @param val the MPI to encode.
* @throws KeyAgreementException if an encoding size constraint is violated.
*/
@@ -176,20 +157,18 @@ public class OutgoingMessage
byte[] b = val.toByteArray();
int length = b.length;
if (length > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new KeyAgreementException("MPI is too long");
- }
- byte[] lengthBytes = { (byte) (length >>> 8), (byte) length };
+ throw new KeyAgreementException("MPI is too long");
+ byte[] lengthBytes = { (byte)(length >>> 8), (byte) length };
out.write(lengthBytes, 0, 2);
out.write(b, 0, b.length);
}
/**
- * <p>Encodes a string into the message.</p>
- *
+ * Encodes a string into the message.
+ *
* @param s the string to encode.
- * @throws KeyAgreementException if the UTF8 encoding is not supported on
- * this platform, or if an encoding size constraint is violated.
+ * @throws KeyAgreementException if the UTF8 encoding is not supported on this
+ * platform, or if an encoding size constraint is violated.
*/
public void writeString(String s) throws KeyAgreementException
{
@@ -204,10 +183,8 @@ public class OutgoingMessage
}
int length = b.length;
if (length > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new KeyAgreementException("text too long");
- }
- byte[] lengthBytes = { (byte) (length >>> 8), (byte) length };
+ throw new KeyAgreementException("text too long");
+ byte[] lengthBytes = { (byte)(length >>> 8), (byte) length };
out.write(lengthBytes, 0, 2);
out.write(b, 0, b.length);
}
@@ -224,9 +201,11 @@ public class OutgoingMessage
int length = b.length + 1;
if (length > Registry.SASL_FOUR_BYTE_MAX_LIMIT)
throw new KeyAgreementException("Encoded key is too long");
-
- byte[] lengthBytes = { (byte) (length >>> 24), (byte) (length >>> 16),
- (byte) (length >>> 8), (byte) length };
+ byte[] lengthBytes = {
+ (byte)(length >>> 24),
+ (byte)(length >>> 16),
+ (byte)(length >>> 8),
+ (byte) length };
out.write(lengthBytes, 0, 4);
out.write(((keyType & 0x0F) << 4) | (formatID & 0x0F));
out.write(b, 0, b.length);
@@ -252,4 +231,4 @@ public class OutgoingMessage
throw new KeyAgreementException("Unknown or unsupported key type: "
+ k.getClass().getName());
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java
index 34fb007066b..98ea4765375 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java
@@ -98,6 +98,13 @@ public class DHKeyPairPKCS8Codec
* q INTEGER -- factor of p-1
* }
* </pre>
+ * <p>
+ * <b>IMPORTANT</b>: with RI's {@link javax.crypto.spec.DHGenParameterSpec}
+ * and {@link javax.crypto.spec.DHParameterSpec} classes, we may end up with
+ * Diffie-Hellman keys that have a <code>null</code> for the <code>q</code>
+ * parameter. RFC-2631 DOES NOT allow for an <i>optional</i> value for that
+ * parameter, hence we replace such null values with <code>0</code>, and do
+ * the reverse in the corresponding decode method.
*
* @return the DER encoded form of the ASN.1 representation of the
* <i>PrivateKeyInfo</i> field in an X.509 certificate.
@@ -117,6 +124,8 @@ public class DHKeyPairPKCS8Codec
BigInteger p = pk.getParams().getP();
BigInteger g = pk.getParams().getG();
BigInteger q = pk.getQ();
+ if (q == null)
+ q = BigInteger.ZERO;
BigInteger x = pk.getX();
ArrayList params = new ArrayList(3);
@@ -212,6 +221,8 @@ public class DHKeyPairPKCS8Codec
val = der.read();
DerUtil.checkIsBigInteger(val, "Wrong Q field");
q = (BigInteger) val.getValue();
+ if (q.compareTo(BigInteger.ZERO) == 0)
+ q = null;
val = der.read();
byte[] xBytes = (byte[]) val.getValue();
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java
index c0ff82bea52..aefcd5ff4fb 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairRawCodec.java
@@ -47,62 +47,49 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>An object that implements the {@link IKeyPairCodec} operations for the
- * <i>Raw</i> format to use with Diffie-Hellman keypairs.</p>
+ * An object that implements the {@link IKeyPairCodec} operations for the
+ * <i>Raw</i> format to use with Diffie-Hellman keypairs.
*/
-public class DHKeyPairRawCodec implements IKeyPairCodec
+public class DHKeyPairRawCodec
+ implements IKeyPairCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- // implicit 0-arguments ctor
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.keys.IKeyPairCodec interface implementation -------------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated Diffie-Hellman public key
- * according to the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for a DH public key, in this implementation, is
- * a byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated Diffie-Hellman public key
+ * according to the <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for a DH public key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DH_PUBLIC_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>q</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>q</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>p</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>p</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>y</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>y</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_DH_PUBLIC_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>q</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>q</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>p</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>p</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>y</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>y</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not a DH one.
@@ -110,59 +97,49 @@ public class DHKeyPairRawCodec implements IKeyPairCodec
*/
public byte[] encodePublicKey(PublicKey key)
{
- if (!(key instanceof GnuDHPublicKey))
- {
- throw new IllegalArgumentException("key");
- }
-
+ if (! (key instanceof GnuDHPublicKey))
+ throw new IllegalArgumentException("key");
GnuDHPublicKey dhKey = (GnuDHPublicKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_DH_PUBLIC_KEY[0]);
baos.write(Registry.MAGIC_RAW_DH_PUBLIC_KEY[1]);
baos.write(Registry.MAGIC_RAW_DH_PUBLIC_KEY[2]);
baos.write(Registry.MAGIC_RAW_DH_PUBLIC_KEY[3]);
-
// version
baos.write(0x01);
-
// q
byte[] buffer = dhKey.getQ().toByteArray();
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// p
buffer = dhKey.getParams().getP().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = dhKey.getParams().getG().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// y
buffer = dhKey.getY().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -173,83 +150,84 @@ public class DHKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_DH_PUBLIC_KEY[1]
|| k[2] != Registry.MAGIC_RAW_DH_PUBLIC_KEY[2]
|| k[3] != Registry.MAGIC_RAW_DH_PUBLIC_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
+ throw new IllegalArgumentException("version");
int i = 5;
int l;
byte[] buffer;
-
// q
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger q = new BigInteger(1, buffer);
-
// p
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger p = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// y
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger y = new BigInteger(1, buffer);
-
return new GnuDHPublicKey(q, p, g, y);
}
/**
- * <p>Returns the encoded form of the designated Diffie-Hellman private key
- * according to the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for a DH private key, in this implementation, is
- * a byte sequence consisting of the following:</p>
- *
+ * Returns the encoded form of the designated Diffie-Hellman private key
+ * according to the <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for a DH private key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DH_PRIVATE_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>q</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>q</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>p</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>p</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the DH parameter
- * <code>x</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the DH parameter <code>x</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_DH_PRIVATE_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>q</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>q</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>p</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>p</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the DH parameter
+ * <code>x</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the DH parameter <code>x</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not a DH one.
@@ -257,59 +235,49 @@ public class DHKeyPairRawCodec implements IKeyPairCodec
*/
public byte[] encodePrivateKey(PrivateKey key)
{
- if (!(key instanceof GnuDHPrivateKey))
- {
- throw new IllegalArgumentException("key");
- }
-
+ if (! (key instanceof GnuDHPrivateKey))
+ throw new IllegalArgumentException("key");
GnuDHPrivateKey dhKey = (GnuDHPrivateKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_DH_PRIVATE_KEY[0]);
baos.write(Registry.MAGIC_RAW_DH_PRIVATE_KEY[1]);
baos.write(Registry.MAGIC_RAW_DH_PRIVATE_KEY[2]);
baos.write(Registry.MAGIC_RAW_DH_PRIVATE_KEY[3]);
-
// version
baos.write(0x01);
-
// q
byte[] buffer = dhKey.getQ().toByteArray();
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// p
buffer = dhKey.getParams().getP().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = dhKey.getParams().getG().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// x
buffer = dhKey.getX().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -320,51 +288,49 @@ public class DHKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_DH_PRIVATE_KEY[1]
|| k[2] != Registry.MAGIC_RAW_DH_PRIVATE_KEY[2]
|| k[3] != Registry.MAGIC_RAW_DH_PRIVATE_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
+ throw new IllegalArgumentException("version");
int i = 5;
int l;
byte[] buffer;
-
// q
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger q = new BigInteger(1, buffer);
-
// p
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger p = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// x
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger x = new BigInteger(1, buffer);
-
return new GnuDHPrivateKey(q, p, g, x);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java
index 7e8688bd3a4..5da396a1da6 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java
@@ -97,6 +97,13 @@ public class DHKeyPairX509Codec
* <pre>
* DHPublicKey ::= INTEGER -- public key, y = g^x mod p
* </pre>
+ * <p>
+ * <b>IMPORTANT</b>: with RI's {@link javax.crypto.spec.DHGenParameterSpec}
+ * and {@link javax.crypto.spec.DHParameterSpec} classes, we may end up with
+ * Diffie-Hellman keys that have a <code>null</code> for the <code>q</code>
+ * parameter. RFC-2631 DOES NOT allow for an <i>optional</i> value for that
+ * parameter, hence we replace such null values with <code>0</code>, and do
+ * the reverse in the corresponding decode method.
*
* @param key the {@link PublicKey} instance to encode. MUST be an instance of
* {@link GnuDHPublicKey}.
@@ -117,6 +124,8 @@ public class DHKeyPairX509Codec
BigInteger p = dhKey.getParams().getP();
BigInteger g = dhKey.getParams().getG();
BigInteger q = dhKey.getQ();
+ if (q == null)
+ q = BigInteger.ZERO;
BigInteger y = dhKey.getY();
DERValue derP = new DERValue(DER.INTEGER, p);
@@ -212,6 +221,8 @@ public class DHKeyPairX509Codec
val = der.read();
DerUtil.checkIsBigInteger(val, "Wrong Q field");
q = (BigInteger) val.getValue();
+ if (q.compareTo(BigInteger.ZERO) == 0)
+ q = null;
val = der.read();
if (! (val.getValue() instanceof BitString))
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java
index 5b1caa7d1b5..2443950549a 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanKeyAgreement.java
@@ -49,78 +49,63 @@ import java.math.BigInteger;
import javax.crypto.interfaces.DHPrivateKey;
/**
- * <p>The basic version of the Diffie-Hellman key agreement is described in the
- * Handbook of Applied Cryptography [HAC] as follows:</p>
+ * The basic version of the Diffie-Hellman key agreement is described in the
+ * Handbook of Applied Cryptography [HAC] as follows:
* <ul>
- * <li>An appropriate prime p and generator g of Z<sub>p</sub><sup>*</sup>
- * (2 &lt;= g &lt;= p-2) are selected and published.</li>
- * <li>A and B each send the other one message over an open channel; as a
- * result, they both can then compute a shared secret key K which they can
- * use to protect their future communication.</li>
- * <li>A chooses a random secret x, 1 &lt;= x &lt;= p-2, and sends B message
- * (1) which is g^x mod p.</li>
- * <li>B chooses a random secret y, 1 &lt;= y &lt;= p-2, and sends A message
- * (2) which is g^y mod p.</li>
- * <li>B receives message (1) and computes the shared key as K = (g^x)^y mod
- * p.</li>
- * <li>A receives message (2) and computes the shared key as K = (g^y)^x mod
- * p.</li>
+ * <li>An appropriate prime p and generator g of Z<sub>p</sub><sup>*</sup>
+ * (2 &lt;= g &lt;= p-2) are selected and published.</li>
+ * <li>A and B each send the other one message over an open channel; as a
+ * result, they both can then compute a shared secret key K which they can use
+ * to protect their future communication.</li>
+ * <li>A chooses a random secret x, 1 &lt;= x &lt;= p-2, and sends B message
+ * (1) which is g^x mod p.</li>
+ * <li>B chooses a random secret y, 1 &lt;= y &lt;= p-2, and sends A message
+ * (2) which is g^y mod p.</li>
+ * <li>B receives message (1) and computes the shared key as K = (g^x)^y mod p.
+ * </li>
+ * <li>A receives message (2) and computes the shared key as K = (g^y)^x mod p.
+ * </li>
* </ul>
- *
- * <p>RFC-2631 describes a <i>Static-Static Mode</i> of operations with
- * Diffie-Hellman keypairs as follows:</p>
+ * <p>
+ * RFC-2631 describes a <i>Static-Static Mode</i> of operations with
+ * Diffie-Hellman keypairs as follows:
* <pre>
- * "In Static-Static mode, both the sender and the recipient have a
- static (and certified) key pair. Since the sender's and recipient's
- keys are therefore the same for each message, ZZ will be the same for
- each message. Thus, partyAInfo MUST be used (and different for each
- message) in order to ensure that different messages use different
- KEKs. Implementations MAY implement Static-Static mode."
+ * &quot;In Static-Static mode, both the sender and the recipient have a
+ * static (and certified) key pair. Since the sender's and recipient's
+ * keys are therefore the same for each message, ZZ will be the same for
+ * each message. Thus, partyAInfo MUST be used (and different for each
+ * message) in order to ensure that different messages use different
+ * KEKs. Implementations MAY implement Static-Static mode.&quot;
* </pre>
- *
- * <p>Reference:</p>
+ *
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
- * Applied Cryptography.<br>
- * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
- * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
+ * Applied Cryptography.<br>
+ * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
+ * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
*/
-public abstract class DiffieHellmanKeyAgreement extends BaseKeyAgreementParty
+public abstract class DiffieHellmanKeyAgreement
+ extends BaseKeyAgreementParty
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.dh.ka.prng";
-
- public static final String KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY = "gnu.crypto.dh.ka.owner.private.key";
-
+ public static final String KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY =
+ "gnu.crypto.dh.ka.owner.private.key";
/** The key agreement party's private key. */
protected DHPrivateKey ownerKey;
-
/** The shared secret key. */
protected BigInteger ZZ;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected DiffieHellmanKeyAgreement()
{
super(Registry.DH_KA);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of common abstract methods in BaseKeyAGreementParty ------
-
protected byte[] engineSharedSecret() throws KeyAgreementException
{
return Util.trim(ZZ);
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java
index 4a3664d6a8d..ab1023ad3b5 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanReceiver.java
@@ -51,50 +51,30 @@ import java.util.Map;
import javax.crypto.interfaces.DHPrivateKey;
/**
- * <p>This implementation is the receiver's part of the basic version of the
- * Diffie-Hellman key agreement exchange (B in [HAC]).</p>
- *
+ * This implementation is the receiver's part of the basic version of the
+ * Diffie-Hellman key agreement exchange (B in [HAC]).
+ *
* @see DiffieHellmanKeyAgreement
*/
-public class DiffieHellmanReceiver extends DiffieHellmanKeyAgreement
+public class DiffieHellmanReceiver
+ extends DiffieHellmanKeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private BigInteger y; // the receiver's random secret
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(Map attributes) throws KeyAgreementException
{
Object random = attributes.get(SOURCE_OF_RANDOMNESS);
rnd = null;
irnd = null;
if (random instanceof SecureRandom)
- {
- rnd = (SecureRandom) random;
- }
+ rnd = (SecureRandom) random;
else if (random instanceof IRandom)
- {
- irnd = (IRandom) random;
- }
+ irnd = (IRandom) random;
ownerKey = (DHPrivateKey) attributes.get(KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY);
if (ownerKey == null)
- {
- throw new KeyAgreementException("missing owner's private key");
- }
+ throw new KeyAgreementException("missing owner's private key");
}
protected OutgoingMessage engineProcessMessage(IncomingMessage in)
@@ -109,20 +89,14 @@ public class DiffieHellmanReceiver extends DiffieHellmanKeyAgreement
}
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage computeSharedSecret(IncomingMessage in)
throws KeyAgreementException
{
BigInteger m1 = in.readMPI();
if (m1 == null)
- {
- throw new KeyAgreementException("missing message (1)");
- }
-
+ throw new KeyAgreementException("missing message (1)");
BigInteger p = ownerKey.getParams().getP();
BigInteger g = ownerKey.getParams().getG();
-
// B chooses a random integer y, 1 <= y <= p-2
// rfc-2631 restricts y to only be in [2, p-1]
BigInteger p_minus_2 = p.subtract(TWO);
@@ -132,16 +106,12 @@ public class DiffieHellmanReceiver extends DiffieHellmanKeyAgreement
nextRandomBytes(xBytes);
y = new BigInteger(1, xBytes);
}
- while (!(y.compareTo(TWO) >= 0 && y.compareTo(p_minus_2) <= 0));
-
+ while (! (y.compareTo(TWO) >= 0 && y.compareTo(p_minus_2) <= 0));
ZZ = m1.modPow(y, p); // ZZ = (yb ^ xa) mod p
-
complete = true;
-
// B sends A the message: g^y mod p
OutgoingMessage result = new OutgoingMessage();
result.writeMPI(g.modPow(y, p)); // message (2)
-
return result;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
index 0be82bfb492..52a030d678c 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
@@ -51,50 +51,30 @@ import java.util.Map;
import javax.crypto.interfaces.DHPrivateKey;
/**
- * <p>This implementation is the sender's part of the basic version of the
- * Diffie-Hellman key agreement exchange (A in [HAC]).</p>
- *
+ * This implementation is the sender's part of the basic version of the
+ * Diffie-Hellman key agreement exchange (A in [HAC]).
+ *
* @see DiffieHellmanKeyAgreement
*/
-public class DiffieHellmanSender extends DiffieHellmanKeyAgreement
+public class DiffieHellmanSender
+ extends DiffieHellmanKeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private BigInteger x; // the sender's random secret
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(Map attributes) throws KeyAgreementException
{
Object random = attributes.get(SOURCE_OF_RANDOMNESS);
rnd = null;
irnd = null;
if (random instanceof SecureRandom)
- {
- rnd = (SecureRandom) random;
- }
+ rnd = (SecureRandom) random;
else if (random instanceof IRandom)
- {
- irnd = (IRandom) random;
- }
+ irnd = (IRandom) random;
ownerKey = (DHPrivateKey) attributes.get(KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY);
if (ownerKey == null)
- {
- throw new KeyAgreementException("missing owner's private key");
- }
+ throw new KeyAgreementException("missing owner's private key");
}
protected OutgoingMessage engineProcessMessage(IncomingMessage in)
@@ -111,14 +91,11 @@ public class DiffieHellmanSender extends DiffieHellmanKeyAgreement
}
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage sendRandomSecret(IncomingMessage in)
throws KeyAgreementException
{
BigInteger p = ownerKey.getParams().getP();
BigInteger g = ownerKey.getParams().getG();
-
// A chooses a random integer x, 1 <= x <= p-2
// rfc-2631 restricts x to only be in [2, p-1]
BigInteger p_minus_2 = p.subtract(TWO);
@@ -128,12 +105,10 @@ public class DiffieHellmanSender extends DiffieHellmanKeyAgreement
nextRandomBytes(xBytes);
x = new BigInteger(1, xBytes);
}
- while (!(x.compareTo(TWO) >= 0 && x.compareTo(p_minus_2) <= 0));
-
+ while (! (x.compareTo(TWO) >= 0 && x.compareTo(p_minus_2) <= 0));
// A sends B the message: g^x mod p
OutgoingMessage result = new OutgoingMessage();
result.writeMPI(g.modPow(x, p));
-
return result;
}
@@ -142,13 +117,9 @@ public class DiffieHellmanSender extends DiffieHellmanKeyAgreement
{
BigInteger m1 = in.readMPI();
if (m1 == null)
- {
- throw new KeyAgreementException("missing message (2)");
- }
-
+ throw new KeyAgreementException("missing message (2)");
BigInteger p = ownerKey.getParams().getP();
- ZZ = m1.modPow(x, p); // ZZ = (yb ^ xa) mod p
-
+ ZZ = m1.modPow(x, p); // ZZ = (yb ^ xa) mod p
complete = true;
return null;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java
index 1c4e11ce26b..967eda3f508 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalKeyAgreement.java
@@ -47,77 +47,62 @@ import gnu.javax.crypto.key.KeyAgreementException;
import java.math.BigInteger;
/**
- * <p>The ElGamal key agreement, also known as the half-certified Diffie-Hellman
+ * The ElGamal key agreement, also known as the half-certified Diffie-Hellman
* key agreement, is described in the Handbook of Applied Cryptography [HAC] as
- * follows:</p>
+ * follows:
* <ul>
- * <li>A sends to B a single message allowing one-pass key agreement.</li>
- * <li>A obtains an authentic copy of B's public key (p, g, yb), where
- * yb = g**xb.</li>
- * <li>A chooses a random integer x, 1 &lt;= x &lt;= p-2, and sends B the
- * message g**x. A computes the shared secret key K as yb**x.</li>
- * <li>B computes the same key K on receipt of the previous message as
- * (g**x)**xb.</li>
+ * <li>A sends to B a single message allowing one-pass key agreement.</li>
+ * <li>A obtains an authentic copy of B's public key (p, g, yb), where yb =
+ * g**xb.</li>
+ * <li>A chooses a random integer x, 1 &lt;= x &lt;= p-2, and sends B the
+ * message g**x. A computes the shared secret key K as yb**x.</li>
+ * <li>B computes the same key K on receipt of the previous message as
+ * (g**x)**xb.</li>
* </ul>
- *
- * <p>RFC-2631 describes an <i>Ephemeral-Static Mode</i> of operations with
- * Diffie-Hellman keypairs as follows:</p>
+ * <p>
+ * RFC-2631 describes an <i>Ephemeral-Static Mode</i> of operations with
+ * Diffie-Hellman keypairs as follows:
* <pre>
- * "In Ephemeral-Static mode, the recipient has a static (and certified)
- * key pair, but the sender generates a new key pair for each message
- * and sends it using the originatorKey production. If the sender's key
- * is freshly generated for each message, the shared secret ZZ will be
- * similarly different for each message and partyAInfo MAY be omitted,
- * since it serves merely to decouple multiple KEKs generated by the
- * same set of pairwise keys. If, however, the same ephemeral sender key
- * is used for multiple messages (e.g. it is cached as a performance
- * optimization) then a separate partyAInfo MUST be used for each
- * message. All implementations of this standard MUST implement
- * Ephemeral-Static mode."
+ * &quot;In Ephemeral-Static mode, the recipient has a static (and certified)
+ * key pair, but the sender generates a new key pair for each message
+ * and sends it using the originatorKey production. If the sender's key
+ * is freshly generated for each message, the shared secret ZZ will be
+ * similarly different for each message and partyAInfo MAY be omitted,
+ * since it serves merely to decouple multiple KEKs generated by the
+ * same set of pairwise keys. If, however, the same ephemeral sender key
+ * is used for multiple messages (e.g. it is cached as a performance
+ * optimization) then a separate partyAInfo MUST be used for each
+ * message. All implementations of this standard MUST implement
+ * Ephemeral-Static mode.&quot;
* </pre>
- *
- * <p>Reference:</p>
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
- * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
- * Applied Cryptography.<br>
- * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
- * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
+ * <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
+ * Applied Cryptography.<br>
+ * CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
+ * Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
*/
-public abstract class ElGamalKeyAgreement extends BaseKeyAgreementParty
+public abstract class ElGamalKeyAgreement
+ extends BaseKeyAgreementParty
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.elgamal.ka.prng";
-
- public static final String KA_ELGAMAL_RECIPIENT_PRIVATE_KEY = "gnu.crypto.elgamal.ka.recipient.private.key";
-
- public static final String KA_ELGAMAL_RECIPIENT_PUBLIC_KEY = "gnu.crypto.elgamal.ka.recipient.public.key";
-
+ public static final String KA_ELGAMAL_RECIPIENT_PRIVATE_KEY =
+ "gnu.crypto.elgamal.ka.recipient.private.key";
+ public static final String KA_ELGAMAL_RECIPIENT_PUBLIC_KEY =
+ "gnu.crypto.elgamal.ka.recipient.public.key";
/** The shared secret key. */
protected BigInteger ZZ;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected ElGamalKeyAgreement()
{
super(Registry.ELGAMAL_KA);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of common abstract methods in BaseKeyAGreementParty ------
-
protected byte[] engineSharedSecret() throws KeyAgreementException
{
return Util.trim(ZZ);
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalReceiver.java b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalReceiver.java
index 24776cba174..bf9b4fb1f0f 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalReceiver.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalReceiver.java
@@ -49,33 +49,19 @@ import java.util.Map;
import javax.crypto.interfaces.DHPrivateKey;
/**
- * <p>This implementation is the receiver's part of the ElGamal key agreement
- * exchange (B in [HAC]).</p>
- *
+ * This implementation is the receiver's part of the ElGamal key agreement
+ * exchange (B in [HAC]).
+ *
* @see ElGamalKeyAgreement
*/
-public class ElGamalReceiver extends ElGamalKeyAgreement
+public class ElGamalReceiver
+ extends ElGamalKeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The recipient's private key. */
private DHPrivateKey B;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
@@ -83,9 +69,7 @@ public class ElGamalReceiver extends ElGamalKeyAgreement
// a keypair and publishes its public key
B = (DHPrivateKey) attributes.get(KA_ELGAMAL_RECIPIENT_PRIVATE_KEY);
if (B == null)
- {
- throw new KeyAgreementException("missing recipient private key");
- }
+ throw new KeyAgreementException("missing recipient private key");
}
protected OutgoingMessage engineProcessMessage(IncomingMessage in)
@@ -100,8 +84,6 @@ public class ElGamalReceiver extends ElGamalKeyAgreement
}
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage computeSharedSecret(IncomingMessage in)
throws KeyAgreementException
{
@@ -109,12 +91,8 @@ public class ElGamalReceiver extends ElGamalKeyAgreement
// K = (g^x)^xb mod p
BigInteger m1 = in.readMPI();
if (m1 == null)
- {
- throw new KeyAgreementException("missing message (1)");
- }
-
+ throw new KeyAgreementException("missing message (1)");
ZZ = m1.modPow(B.getX(), B.getParams().getP()); // ZZ = (ya ^ xb) mod p
-
complete = true;
return null;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalSender.java b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalSender.java
index a2de80a6766..cdd1ef0dac0 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalSender.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/ElGamalSender.java
@@ -49,33 +49,19 @@ import java.util.Map;
import javax.crypto.interfaces.DHPublicKey;
/**
- * <p>This implementation is the sender's part of the ElGamal key agreement
- * exchange (A in [HAC]).</p>
- *
+ * This implementation is the sender's part of the ElGamal key agreement
+ * exchange (A in [HAC]).
+ *
* @see ElGamalKeyAgreement
*/
-public class ElGamalSender extends ElGamalKeyAgreement
+public class ElGamalSender
+ extends ElGamalKeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The recipient's public key. */
private DHPublicKey B;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
@@ -83,9 +69,7 @@ public class ElGamalSender extends ElGamalKeyAgreement
// a keypair and publishes its public key
B = (DHPublicKey) attributes.get(KA_ELGAMAL_RECIPIENT_PUBLIC_KEY);
if (B == null)
- {
- throw new KeyAgreementException("missing recipient public key");
- }
+ throw new KeyAgreementException("missing recipient public key");
}
protected OutgoingMessage engineProcessMessage(IncomingMessage in)
@@ -100,15 +84,12 @@ public class ElGamalSender extends ElGamalKeyAgreement
}
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage computeSharedSecret(IncomingMessage in)
throws KeyAgreementException
{
BigInteger p = B.getParams().getP();
BigInteger g = B.getParams().getG();
BigInteger yb = B.getY();
-
// A chooses a random integer x, 1 <= x <= p-2
// rfc-2631 restricts x to only be in [2, p-1]
BigInteger p_minus_2 = p.subtract(TWO);
@@ -120,14 +101,11 @@ public class ElGamalSender extends ElGamalKeyAgreement
x = new BigInteger(1, xBytes);
}
while (x.compareTo(TWO) >= 0 && x.compareTo(p_minus_2) <= 0);
-
// A sends B the message: g^x mod p
OutgoingMessage result = new OutgoingMessage();
result.writeMPI(g.modPow(x, p));
-
// A computes the key as K = (yb)^x mod p
ZZ = yb.modPow(x, p); // ZZ = (yb ^ xa) mod p
-
complete = true;
return result;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java
index f1e42d93a3e..1066830c322 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java
@@ -39,55 +39,50 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
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;
import javax.crypto.spec.DHParameterSpec;
/**
- * <p>A base asbtract class for both public and private Diffie-Hellman keys. It
- * encapsulates the two DH numbers: <code>p</code>, and <code>g</code>.</p>
- *
- * <p>According to the JDK, cryptographic <i>Keys</i> all have a <i>format</i>.
+ * A base asbtract class for both public and private Diffie-Hellman keys. It
+ * encapsulates the two DH numbers: <code>p</code>, and <code>g</code>.
+ * <p>
+ * According to the JDK, cryptographic <i>Keys</i> all have a <i>format</i>.
* The format used in this implementation is called <i>Raw</i>, and basically
* consists of the raw byte sequences of algorithm parameters. The exact order
- * of the byte sequences and the implementation details are given in each of
- * the relevant <code>getEncoded()</code> methods of each of the private and
- * public keys.</p>
- *
- * <p>Reference:</p>
+ * of the byte sequences and the implementation details are given in each of the
+ * relevant <code>getEncoded()</code> methods of each of the private and
+ * public keys.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
* </ol>
*/
-public abstract class GnuDHKey implements Key, DHKey
+public abstract class GnuDHKey
+ implements Key, DHKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The public prime q. A prime divisor of p-1. */
protected BigInteger q;
-
/** The public prime p. */
protected BigInteger p;
-
/** The generator g. */
protected BigInteger g;
-
/**
- * Identifier of the default encoding format to use when externalizing the
- * key material.
+ * Identifier of the default encoding format to use when externalizing the key
+ * material.
*/
protected final int defaultFormat;
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ /** String representation of this key. Cached for speed. */
+ private transient String str;
/**
* Trivial protected constructor.
@@ -109,28 +104,13 @@ public abstract class GnuDHKey implements Key, DHKey
this.g = g;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // javax.crypto.interfaces.DHKey interface implementation ------------------
-
public DHParameterSpec getParams()
{
if (q == null)
- {
- return new DHParameterSpec(p, g);
- }
- else
- {
- return new DHParameterSpec(p, g, q.bitLength());
- }
+ return new DHParameterSpec(p, g);
+ return new DHParameterSpec(p, g, q.bitLength());
}
- // java.security.Key interface implementation ------------------------------
-
public String getAlgorithm()
{
return Registry.DH_KPG;
@@ -147,38 +127,48 @@ public abstract class GnuDHKey implements Key, DHKey
return FormatUtil.getEncodingShortName(defaultFormat);
}
- // Other instance methods --------------------------------------------------
-
public BigInteger getQ()
{
return q;
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * {@link DHKey} and has the same Diffie-Hellman parameter values as this
- * one.</p>
- *
+ * Returns <code>true</code> if the designated object is an instance of
+ * {@link DHKey} and has the same Diffie-Hellman parameter values as this one.
+ *
* @param obj the other non-null DH key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof DHKey))
- {
- return false;
- }
+ return false;
+ if (! (obj instanceof DHKey))
+ return false;
DHKey that = (DHKey) obj;
return p.equals(that.getParams().getP())
&& g.equals(that.getParams().getG());
}
- // abstract methods to be implemented by subclasses ------------------------
+ public String toString()
+ {
+ if (str == null)
+ {
+ String ls = (String) AccessController.doPrivileged
+ (new GetPropertyAction("line.separator"));
+ StringBuilder sb = new StringBuilder(ls)
+ .append("defaultFormat=").append(defaultFormat).append(",").append(ls);
+ if (q == null)
+ sb.append("q=null,");
+ else
+ sb.append("q=0x").append(q.toString(16)).append(",");
+ sb.append(ls).append("p=0x").append(p.toString(16)).append(",").append(ls)
+ .append("g=0x").append(g.toString(16));
+ str = sb.toString();
+ }
+ return str;
+ }
public abstract byte[] getEncoded(int format);
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
index 5626a2979a8..13cfd9014a9 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
@@ -38,132 +38,84 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.hash.Sha160;
import gnu.java.security.key.IKeyPairGenerator;
import gnu.java.security.util.PRNG;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.util.Map;
+import java.util.logging.Logger;
import javax.crypto.spec.DHGenParameterSpec;
import javax.crypto.spec.DHParameterSpec;
/**
- * <p>An implementation of a Diffie-Hellman keypair generator.</p>
- *
- * <p>Reference:</p>
+ * An implementation of a Diffie-Hellman keypair generator.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
* </ol>
*/
-public class GnuDHKeyPairGenerator implements IKeyPairGenerator
+public class GnuDHKeyPairGenerator
+ implements IKeyPairGenerator
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "dh";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 5;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(GnuDHKeyPairGenerator.class.getName());
/**
* Property name of an optional {@link SecureRandom} instance to use. The
* default is to use a classloader singleton from {@link PRNG}.
*/
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.dh.prng";
-
/**
* Property name of an optional {@link DHGenParameterSpec} or
* {@link DHParameterSpec} instance to use for this generator.
*/
public static final String DH_PARAMETERS = "gnu.crypto.dh.params";
-
/** Property name of the size in bits (Integer) of the public prime (p). */
public static final String PRIME_SIZE = "gnu.crypto.dh.L";
-
/** Property name of the size in bits (Integer) of the private exponent (x). */
public static final String EXPONENT_SIZE = "gnu.crypto.dh.m";
-
/**
* Property name of the preferred encoding format to use when externalizing
* generated instance of key-pairs from this generator. The property is taken
* to be an {@link Integer} that encapsulates an encoding format identifier.
*/
public static final String PREFERRED_ENCODING_FORMAT = "gnu.crypto.dh.encoding";
-
/** Default value for the size in bits of the public prime (p). */
- // private static final int DEFAULT_PRIME_SIZE = 1024;
public static final int DEFAULT_PRIME_SIZE = 512;
-
/** Default value for the size in bits of the private exponent (x). */
public static final int DEFAULT_EXPONENT_SIZE = 160;
-
/** Default encoding format to use when none was specified. */
private static final int DEFAULT_ENCODING_FORMAT = Registry.RAW_ENCODING_ID;
-
/** The SHA instance to use. */
private Sha160 sha = new Sha160();
-
/** The optional {@link SecureRandom} instance to use. */
private SecureRandom rnd = null;
-
/** The desired size in bits of the public prime (p). */
private int l;
-
/** The desired size in bits of the private exponent (x). */
private int m;
-
private BigInteger seed;
-
private BigInteger counter;
-
private BigInteger q;
-
private BigInteger p;
-
private BigInteger j;
-
private BigInteger g;
-
/** Our default source of randomness. */
private PRNG prng = null;
-
/** Preferred encoding format of generated keys. */
private int preferredFormat;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.keys.IKeyPairGenerator interface implementation ---------------
-
public String name()
{
return Registry.DH_KPG;
@@ -173,11 +125,9 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
{
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
// are we given a set of Diffie-Hellman generation parameters or we shall
// use our own?
Object params = attributes.get(DH_PARAMETERS);
-
// find out the desired sizes
if (params instanceof DHGenParameterSpec)
{
@@ -195,7 +145,6 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
g = jceSpec.getG();
l = p.bitLength();
m = jceSpec.getL();
-
// If no exponent size was given, generate an exponent as
// large as the prime.
if (m == 0)
@@ -208,21 +157,12 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
bi = (Integer) attributes.get(EXPONENT_SIZE);
m = (bi == null ? DEFAULT_EXPONENT_SIZE : bi.intValue());
}
-
- // if ((L % 256) != 0 || L < 1024) {
if ((l % 256) != 0 || l < DEFAULT_PRIME_SIZE)
- {
- throw new IllegalArgumentException("invalid modulus size");
- }
+ throw new IllegalArgumentException("invalid modulus size");
if ((m % 8) != 0 || m < DEFAULT_EXPONENT_SIZE)
- {
- throw new IllegalArgumentException("invalid exponent size");
- }
+ throw new IllegalArgumentException("invalid exponent size");
if (m > l)
- {
- throw new IllegalArgumentException("exponent size > modulus size");
- }
-
+ throw new IllegalArgumentException("exponent size > modulus size");
// what is the preferred encoding format
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
@@ -240,22 +180,20 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
p = params[RFC2631.DH_PARAMS_P];
j = params[RFC2631.DH_PARAMS_J];
g = params[RFC2631.DH_PARAMS_G];
- if (DEBUG && debuglevel > 0)
+ if (Configuration.DEBUG)
{
- debug("seed: 0x" + seed.toString(16));
- debug("counter: " + counter.intValue());
- debug("q: 0x" + q.toString(16));
- debug("p: 0x" + p.toString(16));
- debug("j: 0x" + j.toString(16));
- debug("g: 0x" + g.toString(16));
+ log.fine("seed: 0x" + seed.toString(16));
+ log.fine("counter: " + counter.intValue());
+ log.fine("q: 0x" + q.toString(16));
+ log.fine("p: 0x" + p.toString(16));
+ log.fine("j: 0x" + j.toString(16));
+ log.fine("g: 0x" + g.toString(16));
}
}
-
// generate a private number x of length m such as: 1 < x < q - 1
BigInteger q_minus_1 = null;
if (q != null)
q_minus_1 = q.subtract(BigInteger.ONE);
-
// We already check if m is modulo 8 in `setup.' This could just
// be m >>> 3.
byte[] mag = new byte[(m + 7) / 8];
@@ -266,31 +204,23 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
x = new BigInteger(1, mag);
if (x.bitLength() == m && x.compareTo(BigInteger.ONE) > 0
&& (q_minus_1 == null || x.compareTo(q_minus_1) < 0))
- {
- break;
- }
+ break;
}
BigInteger y = g.modPow(x, p);
-
PrivateKey secK = new GnuDHPrivateKey(preferredFormat, q, p, g, x);
PublicKey pubK = new GnuDHPublicKey(preferredFormat, q, p, g, y);
-
return new KeyPair(pubK, secK);
}
- // other methods -----------------------------------------------------------
-
/**
- * <p>Fills the designated byte array with random data.</p>
- *
+ * 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);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
index 0e71623b9f7..d8150dcdf02 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
@@ -38,34 +38,34 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
+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;
/**
- * <p>An implementation of the Diffie-Hellman private key.</p>
- *
- * <p>Reference:</p>
+ * An implementation of the Diffie-Hellman private key.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
* </ol>
*/
-public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
+public class GnuDHPrivateKey
+ extends GnuDHKey
+ implements DHPrivateKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The private exponent. */
private final BigInteger x;
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ /** String representation of this key. Cached for speed. */
+ private transient String str;
/**
* Convenience constructor. Calls the constructor with five arguments passing
@@ -92,31 +92,27 @@ public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
* @param g the generator of the group.
* @param x the private value x.
*/
- public GnuDHPrivateKey(int preferredFormat,
- BigInteger q, BigInteger p, BigInteger g, BigInteger x)
+ public GnuDHPrivateKey(int preferredFormat, BigInteger q, BigInteger p,
+ BigInteger g, BigInteger x)
{
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
: preferredFormat,
q, p, g);
-
this.x = x;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A class method that takes the output of the <code>encodePrivateKey()</code>
+ * A class method that takes the output of the <code>encodePrivateKey()</code>
* method of a DH keypair codec object (an instance implementing
* {@link IKeyPairCodec} for DH keys, and re-constructs an instance of this
- * object.</p>
- *
+ * object.
+ *
* @param k the contents of a previously encoded instance of this object.
- * @exception ArrayIndexOutOfBoundsException if there is not enough bytes,
- * in <code>k</code>, to represent a valid encoding of an instance of
- * this object.
- * @exception IllegalArgumentException if the byte sequence does not
- * represent a valid encoding of an instance of this object.
+ * @exception ArrayIndexOutOfBoundsException if there is not enough bytes, in
+ * <code>k</code>, to represent a valid encoding of an
+ * instance of this object.
+ * @exception IllegalArgumentException if the byte sequence does not represent
+ * a valid encoding of an instance of this object.
*/
public static GnuDHPrivateKey valueOf(byte[] k)
{
@@ -129,32 +125,24 @@ public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
catch (IllegalArgumentException ignored)
{
}
-
// try PKCS#8 codec
return (GnuDHPrivateKey) new DHKeyPairPKCS8Codec().decodePrivateKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // javax.crypto.interfaces.DHPrivateKey interface implementation -----------
-
public BigInteger getX()
{
return x;
}
- // other methods -----------------------------------------------------------
-
/**
- * <p>Returns the encoded form of this private key according to the
- * designated format.</p>
- *
+ * Returns the encoded form of this private key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @exception IllegalArgumentException if the format is not supported.
- * @see gnu.crypto.key.dh.DHKeyPairRawCodec
+ * @see DHKeyPairRawCodec
*/
public byte[] getEncoded(int format)
{
@@ -193,4 +181,20 @@ public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
DHPrivateKey that = (DHPrivateKey) obj;
return super.equals(that) && x.equals(that.getX());
}
+
+ public String toString()
+ {
+ if (str == null)
+ {
+ 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)
+ : "**...*").append(ls)
+ .append(")")
+ .toString();
+ }
+ return str;
+ }
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
index 56516c9d0ea..5fb31f38364 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java
@@ -39,32 +39,31 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
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;
/**
- * <p>An implementation of the Diffie-Hellman public key.</p>
- *
- * <p>Reference:</p>
+ * An implementation of the Diffie-Hellman public key.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
* </ol>
*/
-public class GnuDHPublicKey extends GnuDHKey implements DHPublicKey
+public class GnuDHPublicKey
+ extends GnuDHKey
+ implements DHPublicKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private BigInteger y;
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ /** String representation of this key. Cached for speed. */
+ private transient String str;
/**
* Convenience constructor. Calls the constructor with five arguments passing
@@ -91,31 +90,27 @@ public class GnuDHPublicKey extends GnuDHKey implements DHPublicKey
* @param g the generator of the group.
* @param y the public value y.
*/
- public GnuDHPublicKey(int preferredFormat,
- BigInteger q, BigInteger p, BigInteger g, BigInteger y)
+ public GnuDHPublicKey(int preferredFormat, BigInteger q, BigInteger p,
+ BigInteger g, BigInteger y)
{
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.X509_ENCODING_ID
: preferredFormat,
q, p, g);
-
this.y = y;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A class method that takes the output of the <code>encodePublicKey()</code>
+ * A class method that takes the output of the <code>encodePublicKey()</code>
* method of a DH keypair codec object (an instance implementing
* {@link IKeyPairCodec} for DSS keys, and re-constructs an instance of this
- * object.</p>
- *
- * @param k the contents of a previously encoded instance of this object.
- * @exception ArrayIndexOutOfBoundsException if there is not enough bytes,
- * in <code>k</code>, to represent a valid encoding of an instance of this
* object.
- * @exception IllegalArgumentException if the byte sequence does not
- * represent a valid encoding of an instance of this object.
+ *
+ * @param k the contents of a previously encoded instance of this object.
+ * @exception ArrayIndexOutOfBoundsException if there is not enough bytes, in
+ * <code>k</code>, to represent a valid encoding of an
+ * instance of this object.
+ * @exception IllegalArgumentException if the byte sequence does not represent
+ * a valid encoding of an instance of this object.
*/
public static GnuDHPublicKey valueOf(byte[] k)
{
@@ -128,30 +123,22 @@ public class GnuDHPublicKey extends GnuDHKey implements DHPublicKey
catch (IllegalArgumentException ignored)
{
}
-
// try X.509 codec
return (GnuDHPublicKey) new DHKeyPairX509Codec().decodePublicKey(k);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // javax.crypto.interfaces.DHPublicKey interface implementation ------------
-
public BigInteger getY()
{
return y;
}
- // other methods -----------------------------------------------------------
-
/**
- * <p>Returns the encoded form of this public key according to the designated
- * format.</p>
- *
+ * Returns the encoded form of this public key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @exception IllegalArgumentException if the format is not supported.
*/
public byte[] getEncoded(int format)
@@ -191,4 +178,19 @@ public class GnuDHPublicKey extends GnuDHKey implements DHPublicKey
DHPublicKey that = (DHPublicKey) obj;
return super.equals(that) && y.equals(that.getY());
}
+
+ public String toString()
+ {
+ if (str == null)
+ {
+ 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)
+ .append(")")
+ .toString();
+ }
+ return str;
+ }
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/RFC2631.java b/libjava/classpath/gnu/javax/crypto/key/dh/RFC2631.java
index d6e30b4bc52..673e44864b5 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/RFC2631.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/RFC2631.java
@@ -40,60 +40,41 @@ package gnu.javax.crypto.key.dh;
import gnu.java.security.hash.Sha160;
import gnu.java.security.util.PRNG;
-import gnu.java.security.util.Prime2;
import java.math.BigInteger;
import java.security.SecureRandom;
/**
- * <p>An implementation of the Diffie-Hellman parameter generation as defined in
- * RFC-2631.</p>
- *
- * <p>Reference:</p>
+ * An implementation of the Diffie-Hellman parameter generation as defined in
+ * RFC-2631.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
- * Agreement Method</a><br>
- * Eric Rescorla.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc2631.txt">Diffie-Hellman Key
+ * Agreement Method</a><br>
+ * Eric Rescorla.</li>
* </ol>
*/
public class RFC2631
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final int DH_PARAMS_SEED = 0;
-
public static final int DH_PARAMS_COUNTER = 1;
-
public static final int DH_PARAMS_Q = 2;
-
public static final int DH_PARAMS_P = 3;
-
public static final int DH_PARAMS_J = 4;
-
public static final int DH_PARAMS_G = 5;
-
private static final BigInteger TWO = BigInteger.valueOf(2L);
-
/** The SHA instance to use. */
private Sha160 sha = new Sha160();
-
/** Length of private modulus and of q. */
private int m;
-
/** Length of public modulus p. */
private int L;
-
/** The optional {@link SecureRandom} instance to use. */
private SecureRandom rnd = null;
-
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public RFC2631(int m, int L, SecureRandom rnd)
{
super();
@@ -103,12 +84,6 @@ public class RFC2631
this.rnd = rnd;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public BigInteger[] generateParameters()
{
int i, j, counter;
@@ -127,15 +102,16 @@ public class RFC2631
{
step4: while (true)
{
- // 4. Select an arbitrary bit string SEED such that length of SEED >= m
+ // 4. Select an arbitrary bit string SEED such that length of
+ // SEED >= m
nextRandomBytes(seedBytes);
SEED = new BigInteger(1, seedBytes).setBit(m - 1).setBit(0);
// 5. Set U = 0
U = BigInteger.ZERO;
// 6. For i = 0 to m' - 1
- // U = U + (SHA1[SEED + i] XOR SHA1[(SEED + m' + i)) * 2^(160 * i)
- // Note that for m=160, this reduces to the algorithm of [FIPS-186]
- // U = SHA1[SEED] XOR SHA1[(SEED+1) mod 2^160 ].
+ // U = U + (SHA1[SEED + i] XOR SHA1[(SEED + m' + i)) * 2^(160 * i)
+ // Note that for m=160, this reduces to the algorithm of FIPS-186
+ // U = SHA1[SEED] XOR SHA1[(SEED+1) mod 2^160 ].
for (i = 0; i < m_; i++)
{
u1 = SEED.add(BigInteger.valueOf(i)).toByteArray();
@@ -145,31 +121,27 @@ public class RFC2631
sha.update(u2, 0, u2.length);
u2 = sha.digest();
for (j = 0; j < u1.length; j++)
- {
- u1[j] ^= u2[j];
- }
+ u1[j] ^= u2[j];
U = U.add(new BigInteger(1, u1).multiply(TWO.pow(160 * i)));
}
// 5. Form q from U by computing U mod (2^m) and setting the most
- // significant bit (the 2^(m-1) bit) and the least significant bit to
- // 1. In terms of boolean operations, q = U OR 2^(m-1) OR 1. Note
- // that 2^(m-1) < q < 2^m
+ // significant bit (the 2^(m-1) bit) and the least significant
+ // bit to 1. In terms of boolean operations, q = U OR 2^(m-1) OR
+ // 1. Note that 2^(m-1) < q < 2^m
q = U.setBit(m - 1).setBit(0);
// 6. Use a robust primality algorithm to test whether q is prime.
// 7. If q is not prime then go to 4.
- if (Prime2.isProbablePrime(q))
- {
- break step4;
- }
+ if (q.isProbablePrime(80))
+ break step4;
}
// 8. Let counter = 0
counter = 0;
step9: while (true)
{
// 9. Set R = seed + 2*m' + (L' * counter)
- R = SEED.add(BigInteger.valueOf(2 * m_)).add(
- BigInteger.valueOf(L_
- * counter));
+ R = SEED
+ .add(BigInteger.valueOf(2 * m_))
+ .add(BigInteger.valueOf(L_ * counter));
// 10. Set V = 0
V = BigInteger.ZERO;
// 12. For i = 0 to L'-1 do: V = V + SHA1(R + i) * 2^(160 * i)
@@ -187,10 +159,10 @@ public class RFC2631
X = W.setBit(L - 1);
// 15. Set p = X - (X mod (2*q)) + 1
p = X.add(BigInteger.ONE).subtract(X.mod(TWO.multiply(q)));
- // 16. If p > 2^(L-1) use a robust primality test to test whether p is
- // prime. Else go to 18.
- //17. If p is prime output p, q, seed, counter and stop.
- if (Prime2.isProbablePrime(p))
+ // 16. If p > 2^(L-1) use a robust primality test to test whether p
+ // is prime. Else go to 18.
+ // 17. If p is prime output p, q, seed, counter and stop.
+ if (p.isProbablePrime(80))
{
break algorithm;
}
@@ -199,12 +171,9 @@ public class RFC2631
// 19. If counter < (4096 * N) then go to 8.
// 20. Output "failure"
if (counter >= 4096 * N_)
- {
- continue algorithm;
- }
+ continue algorithm;
}
}
-
// compute g. from FIPS-186, Appendix 4:
// 1. Generate p and q as specified in Appendix 2.
// 2. Let e = (p - 1) / q
@@ -219,28 +188,21 @@ public class RFC2631
// 4. Set g = h**e mod p
g = h.modPow(e, p);
// 5. If g = 1, go to step 3
- if (!g.equals(BigInteger.ONE))
- {
- break;
- }
+ if (! g.equals(BigInteger.ONE))
+ break;
}
-
return new BigInteger[] { SEED, BigInteger.valueOf(counter), q, p, e, g };
}
- // helper methods ----------------------------------------------------------
-
/**
- * <p>Fills the designated byte array with random data.</p>
+ * 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);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6Host.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6Host.java
index 192e877b7ed..44f99467319 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6Host.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6Host.java
@@ -56,65 +56,41 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>The implementation of the Host in the SRP-6 key agreement protocol.</p>
- *
- * <p>Reference:</p>
+ * The implementation of the Host in the SRP-6 key agreement protocol.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRP6Host extends SRP6KeyAgreement
+public class SRP6Host
+ extends SRP6KeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The user's ephemeral key pair. */
private KeyPair hostKeyPair;
/** The SRP password database. */
private SRPAuthInfoProvider passwordDB;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(final Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
N = (BigInteger) attributes.get(SHARED_MODULUS);
if (N == null)
- {
- throw new KeyAgreementException("missing shared modulus");
- }
+ throw new KeyAgreementException("missing shared modulus");
g = (BigInteger) attributes.get(GENERATOR);
if (g == null)
- {
- throw new KeyAgreementException("missing generator");
- }
-
+ throw new KeyAgreementException("missing generator");
final String md = (String) attributes.get(HASH_FUNCTION);
- if (md == null || "".equals(md.trim()))
- {
- throw new KeyAgreementException("missing hash function");
- }
+ if (md == null || md.trim().length() == 0)
+ throw new KeyAgreementException("missing hash function");
srp = SRP.instance(md);
-
passwordDB = (SRPAuthInfoProvider) attributes.get(HOST_PASSWORD_DB);
if (passwordDB == null)
- {
- throw new KeyAgreementException("missing SRP password database");
- }
+ throw new KeyAgreementException("missing SRP password database");
}
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
@@ -135,14 +111,11 @@ public class SRP6Host extends SRP6KeyAgreement
super.engineReset();
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage computeSharedSecret(final IncomingMessage in)
throws KeyAgreementException
{
final String I = in.readString();
final BigInteger A = in.readMPI();
-
// get s and v for user identified by I
// ----------------------------------------------------------------------
final Map credentials;
@@ -157,56 +130,31 @@ public class SRP6Host extends SRP6KeyAgreement
{
throw new KeyAgreementException("computeSharedSecret()", x);
}
-
final BigInteger s = new BigInteger(
- 1,
- Util.fromBase64((String) credentials.get(SRPRegistry.SALT_FIELD)));
+ 1,Util.fromBase64((String) credentials.get(SRPRegistry.SALT_FIELD)));
final BigInteger v = new BigInteger(
- 1,
- Util.fromBase64((String) credentials.get(SRPRegistry.USER_VERIFIER_FIELD)));
-
- // Map configuration = null;
- // try {
- // String mode = (String) credentials.get(SRPRegistry.CONFIG_NDX_FIELD);
- // configuration = passwordDB.getConfiguration(mode);
- // } catch (IOException x) {
- // throw new KeyAgreementException("computeSharedSecret()", x);
- // }
- //
- // BigInteger N = new BigInteger(1, Util.fromBase64(
- // (String) configuration.get(SRPRegistry.SHARED_MODULUS)));
- // BigInteger g = new BigInteger(1, Util.fromBase64(
- // (String) configuration.get(SRPRegistry.FIELD_GENERATOR)));
- // ----------------------------------------------------------------------
-
+ 1, Util.fromBase64((String) credentials.get(SRPRegistry.USER_VERIFIER_FIELD)));
final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
final Map attributes = new HashMap();
if (rnd != null)
- {
- attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
- }
+ attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
attributes.put(SRPKeyPairGenerator.GENERATOR, g);
attributes.put(SRPKeyPairGenerator.USER_VERIFIER, v);
kpg.setup(attributes);
hostKeyPair = kpg.generate();
-
final BigInteger B = ((SRPPublicKey) hostKeyPair.getPublic()).getY();
final BigInteger u = uValue(A, B); // u = H(A | B)
-
// compute S = (Av^u) ^ b
final BigInteger b = ((SRPPrivateKey) hostKeyPair.getPrivate()).getX();
final BigInteger S = A.multiply(v.modPow(u, N)).modPow(b, N);
-
final byte[] sBytes = Util.trim(S);
final IMessageDigest hash = srp.newDigest();
hash.update(sBytes, 0, sBytes.length);
K = new BigInteger(1, hash.digest());
-
final OutgoingMessage result = new OutgoingMessage();
result.writeMPI(s);
result.writeMPI(B);
-
complete = true;
return result;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java
index 63c981d80ef..b4264184e5e 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6KeyAgreement.java
@@ -49,98 +49,72 @@ import gnu.javax.crypto.sasl.srp.SRP;
import java.math.BigInteger;
/**
- * <p>The Secure Remote Password (SRP) key agreement protocol, also known as
- * SRP-6, is designed by Thomas J. Wu (see references). The protocol, and its
- * elements are described as follows:</p>
- *
+ * The Secure Remote Password (SRP) key agreement protocol, also known as SRP-6,
+ * is designed by Thomas J. Wu (see references). The protocol, and its elements
+ * are described as follows:
* <pre>
- * N A large safe prime (N = 2q+1, where q is prime)
- * All arithmetic is done modulo N.
- * g A generator modulo N
- * s User's salt
- * I Username
- * p Cleartext Password
- * H() One-way hash function
- * ^ (Modular) Exponentiation
- * u Random scrambling parameter
- * a,b Secret ephemeral values
- * A,B Public ephemeral values
- * x Private key (derived from p and s)
- * v Password verifier
- *
- * The host stores passwords using the following formula:
- * x = H(s | H(I ":" p)) (s is chosen randomly)
- * v = g^x (computes password verifier)
- *
- * The host then keeps {I, s, v} in its password database.
- *
- * The authentication protocol itself goes as follows:
- * User -> Host: I, A = g^a (identifies self, a = random number)
- * Host -> User: s, B = 3v + g^b (sends salt, b = random number)
- *
- * Both: u = H(A, B)
- *
- * User: x = H(s, p) (user enters password)
- * User: S = (B - 3g^x) ^ (a + ux) (computes session key)
- * User: K = H(S)
- *
- * Host: S = (Av^u) ^ b (computes session key)
- * Host: K = H(S)
+ * N A large safe prime (N = 2q+1, where q is prime)
+ * All arithmetic is done modulo N.
+ * g A generator modulo N
+ * s User's salt
+ * I Username
+ * p Cleartext Password
+ * H() One-way hash function
+ * &circ; (Modular) Exponentiation
+ * u Random scrambling parameter
+ * a,b Secret ephemeral values
+ * A,B Public ephemeral values
+ * x Private key (derived from p and s)
+ * v Password verifier
+ *
+ * The host stores passwords using the following formula:
+ * x = H(s | H(I &quot;:&quot; p)) (s is chosen randomly)
+ * v = g&circ;x (computes password verifier)
+ *
+ * The host then keeps {I, s, v} in its password database.
+ *
+ * The authentication protocol itself goes as follows:
+ * User -&gt; Host: I, A = g&circ;a (identifies self, a = random number)
+ * Host -&gt; User: s, B = 3v + g&circ;b (sends salt, b = random number)
+ *
+ * Both: u = H(A, B)
+ *
+ * User: x = H(s, p) (user enters password)
+ * User: S = (B - 3g&circ;x) &circ; (a + ux) (computes session key)
+ * User: K = H(S)
+ *
+ * Host: S = (Av&circ;u) &circ; b (computes session key)
+ * Host: K = H(S)
* </pre>
- *
- * <p>Reference:</p>
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public abstract class SRP6KeyAgreement extends BaseKeyAgreementParty
+public abstract class SRP6KeyAgreement
+ extends BaseKeyAgreementParty
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.srp6.ka.prng";
-
public static final String SHARED_MODULUS = "gnu.crypto.srp6.ka.N";
-
public static final String GENERATOR = "gnu.crypto.srp6.ka.g";
-
public static final String HASH_FUNCTION = "gnu.crypto.srp6.ka.H";
-
public static final String USER_IDENTITY = "gnu.crypto.srp6.ka.I";
-
public static final String USER_PASSWORD = "gnu.crypto.srp6.ka.p";
-
public static final String HOST_PASSWORD_DB = "gnu.crypto.srp6.ka.password.db";
-
protected static final BigInteger THREE = BigInteger.valueOf(3L);
-
protected SRP srp;
-
protected BigInteger N;
-
protected BigInteger g;
-
/** The shared secret key. */
protected BigInteger K;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected SRP6KeyAgreement()
{
super(Registry.SRP6_KA);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of common abstract methods in BaseKeyAGreementParty ------
-
protected byte[] engineSharedSecret() throws KeyAgreementException
{
return Util.trim(K);
@@ -148,25 +122,20 @@ public abstract class SRP6KeyAgreement extends BaseKeyAgreementParty
protected void engineReset()
{
- // mda = null;
srp = null;
N = null;
g = null;
K = null;
}
- // helper methods ----------------------------------------------------------
-
protected BigInteger uValue(final BigInteger A, final BigInteger B)
{
- // IMessageDigest hash = (IMessageDigest) mda.clone();
final IMessageDigest hash = srp.newDigest();
byte[] b;
b = Util.trim(A);
hash.update(b, 0, b.length);
b = Util.trim(B);
hash.update(b, 0, b.length);
-
return new BigInteger(1, hash.digest());
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslClient.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslClient.java
index ef460b13bc7..f5969f0c195 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslClient.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslClient.java
@@ -48,54 +48,43 @@ import gnu.javax.crypto.key.OutgoingMessage;
import java.math.BigInteger;
/**
- * <p>A variation of the SRP-6 protocol as used in the SASL-SRP mechanism, for
- * the User (client side).</p>
- *
- * <p>In this alternative, the exchange goes as follows:</p>
+ * A variation of the SRP-6 protocol as used in the SASL-SRP mechanism, for the
+ * User (client side).
+ * <p>
+ * In this alternative, the exchange goes as follows:
+ *
* <pre>
- * C -> S: I (identifies self)
- * S -> C: N, g, s, B = 3v + g^b (sends salt, b = random number)
- * C -> S: A = g^a (a = random number)
+ * C -&gt; S: I (identifies self)
+ * S -&gt; C: N, g, s, B = 3v + g&circ;b (sends salt, b = random number)
+ * C -&gt; S: A = g&circ;a (a = random number)
* </pre>
- *
- * <p>All elements are computed the same way as in the standard version.</p>
- *
- * <p>Reference:</p>
+ *
+ * <p>
+ * All elements are computed the same way as in the standard version.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
- * Secure Remote Password Authentication Mechanism</a><br>
- * K. Burdis, R. Naffah.</li>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
+ * Secure Remote Password Authentication Mechanism</a><br>
+ * K. Burdis, R. Naffah.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRP6SaslClient extends SRP6TLSClient
+public class SRP6SaslClient
+ extends SRP6TLSClient
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
throws KeyAgreementException
{
final OutgoingMessage result = super.computeSharedSecret(in);
-
final byte[] sBytes = Util.trim(K);
final IMessageDigest hash = srp.newDigest();
hash.update(sBytes, 0, sBytes.length);
K = new BigInteger(1, hash.digest());
-
return result;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslServer.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslServer.java
index 5e759964e08..7e68c99c437 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslServer.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6SaslServer.java
@@ -48,54 +48,43 @@ import gnu.javax.crypto.key.OutgoingMessage;
import java.math.BigInteger;
/**
- * <p>A variation of the SRP-6 protocol as used in the SASL-SRP mechanism, for
- * the Host (server side).</p>
- *
- * <p>In this alternative, the exchange goes as follows:</p>
+ * A variation of the SRP-6 protocol as used in the SASL-SRP mechanism, for the
+ * Host (server side).
+ * <p>
+ * In this alternative, the exchange goes as follows:
+ *
* <pre>
- * C -> S: I (identifies self)
- * S -> C: N, g, s, B = 3v + g^b (sends salt, b = random number)
- * C -> S: A = g^a (a = random number)
+ * C -&gt; S: I (identifies self)
+ * S -&gt; C: N, g, s, B = 3v + g&circ;b (sends salt, b = random number)
+ * C -&gt; S: A = g&circ;a (a = random number)
* </pre>
- *
- * <p>All elements are computed the same way as in the standard version.</p>
- *
- * <p>Reference:</p>
+ *
+ * <p>
+ * All elements are computed the same way as in the standard version.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
- * Secure Remote Password Authentication Mechanism</a><br>
- * K. Burdis, R. Naffah.</li>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
+ * Secure Remote Password Authentication Mechanism</a><br>
+ * K. Burdis, R. Naffah.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRP6SaslServer extends SRP6TLSServer
+public class SRP6SaslServer
+ extends SRP6TLSServer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
throws KeyAgreementException
{
super.computeSharedSecret(in);
-
final byte[] sBytes = Util.trim(K);
final IMessageDigest hash = srp.newDigest();
hash.update(sBytes, 0, sBytes.length);
K = new BigInteger(1, hash.digest());
-
return null;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSClient.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSClient.java
index 5474a1e8eb9..af0be02dfe0 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSClient.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSClient.java
@@ -51,62 +51,38 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>A variation of the SRP6 key agreement protocol, for the client-side as
- * proposed in
- * <a href="http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-05.txt">Using
+ * A variation of the SRP6 key agreement protocol, for the client-side as
+ * proposed in <a
+ * href="http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-05.txt">Using
* SRP for TLS Authentication</a>. The only difference between it and the SASL
* variant is that the shared secret is the entity <code>S</code> and not
- * <code>H(S)</code>.</p>
+ * <code>H(S)</code>.
*/
-public class SRP6TLSClient extends SRP6KeyAgreement
+public class SRP6TLSClient
+ extends SRP6KeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The user's identity. */
private String I;
-
/** The user's cleartext password. */
private byte[] p;
-
/** The user's ephemeral key pair. */
private KeyPair userKeyPair;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(final Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
final String md = (String) attributes.get(HASH_FUNCTION);
- if (md == null || "".equals(md.trim()))
- {
- throw new KeyAgreementException("missing hash function");
- }
+ if (md == null || md.trim().length() == 0)
+ throw new KeyAgreementException("missing hash function");
srp = SRP.instance(md);
-
I = (String) attributes.get(USER_IDENTITY);
if (I == null)
- {
- throw new KeyAgreementException("missing user identity");
- }
+ throw new KeyAgreementException("missing user identity");
p = (byte[]) attributes.get(USER_PASSWORD);
if (p == null)
- {
- throw new KeyAgreementException("missing user password");
- }
+ throw new KeyAgreementException("missing user password");
}
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
@@ -131,14 +107,11 @@ public class SRP6TLSClient extends SRP6KeyAgreement
super.engineReset();
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage sendIdentity(final IncomingMessage in)
throws KeyAgreementException
{
final OutgoingMessage result = new OutgoingMessage();
result.writeString(I);
-
return result;
}
@@ -149,19 +122,15 @@ public class SRP6TLSClient extends SRP6KeyAgreement
g = in.readMPI();
final BigInteger s = in.readMPI();
final BigInteger B = in.readMPI();
-
// generate an ephemeral keypair
final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
final Map attributes = new HashMap();
if (rnd != null)
- {
- attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
- }
+ attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
attributes.put(SRPKeyPairGenerator.GENERATOR, g);
kpg.setup(attributes);
userKeyPair = kpg.generate();
-
final BigInteger A = ((SRPPublicKey) userKeyPair.getPublic()).getY();
final BigInteger u = uValue(A, B); // u = H(A | B)
final BigInteger x;
@@ -173,18 +142,13 @@ public class SRP6TLSClient extends SRP6KeyAgreement
{
throw new KeyAgreementException("computeSharedSecret()", e);
}
-
// compute S = (B - 3g^x) ^ (a + ux)
final BigInteger a = ((SRPPrivateKey) userKeyPair.getPrivate()).getX();
- final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N))).modPow(
- a.add(u.multiply(x)),
- N);
-
+ final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N)))
+ .modPow(a.add(u.multiply(x)), N);
K = S;
-
final OutgoingMessage result = new OutgoingMessage();
result.writeMPI(A);
-
complete = true;
return result;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
index ecbe36f62b1..f91cffd00f6 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
@@ -55,54 +55,33 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>A variation of the SRP6 key agreement protocol, for the server-side as
- * proposed in
- * <a href="http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-05.txt">Using
+ * A variation of the SRP6 key agreement protocol, for the server-side as
+ * proposed in <a
+ * href="http://www.ietf.org/internet-drafts/draft-ietf-tls-srp-05.txt">Using
* SRP for TLS Authentication</a>. The only difference between it and the SASL
* variant is that the shared secret is the entity <code>S</code> and not
- * <code>H(S)</code>.</p>
+ * <code>H(S)</code>.
*/
-public class SRP6TLSServer extends SRP6KeyAgreement
+public class SRP6TLSServer
+ extends SRP6KeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The user's ephemeral key pair. */
private KeyPair hostKeyPair;
-
/** The SRP password database. */
private SRPAuthInfoProvider passwordDB;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(final Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
final String md = (String) attributes.get(HASH_FUNCTION);
- if (md == null || "".equals(md.trim()))
- {
- throw new KeyAgreementException("missing hash function");
- }
+ if (md == null || md.trim().length() == 0)
+ throw new KeyAgreementException("missing hash function");
srp = SRP.instance(md);
-
passwordDB = (SRPAuthInfoProvider) attributes.get(HOST_PASSWORD_DB);
if (passwordDB == null)
- {
- throw new KeyAgreementException("missing SRP password database");
- }
+ throw new KeyAgreementException("missing SRP password database");
}
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
@@ -125,13 +104,10 @@ public class SRP6TLSServer extends SRP6KeyAgreement
super.engineReset();
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage sendParameters(final IncomingMessage in)
throws KeyAgreementException
{
final String I = in.readString();
-
// get s and v for user identified by I
// ----------------------------------------------------------------------
final Map credentials;
@@ -148,12 +124,9 @@ public class SRP6TLSServer extends SRP6KeyAgreement
}
final BigInteger s = new BigInteger(
- 1,
- Util.fromBase64((String) credentials.get(SRPRegistry.SALT_FIELD)));
+ 1, Util.fromBase64((String) credentials.get(SRPRegistry.SALT_FIELD)));
final BigInteger v = new BigInteger(
- 1,
- Util.fromBase64((String) credentials.get(SRPRegistry.USER_VERIFIER_FIELD)));
-
+ 1, Util.fromBase64((String) credentials.get(SRPRegistry.USER_VERIFIER_FIELD)));
final Map configuration;
try
{
@@ -164,36 +137,26 @@ public class SRP6TLSServer extends SRP6KeyAgreement
{
throw new KeyAgreementException("computeSharedSecret()", x);
}
-
N = new BigInteger(
- 1,
- Util.fromBase64((String) configuration.get(SRPRegistry.SHARED_MODULUS)));
+ 1, Util.fromBase64((String) configuration.get(SRPRegistry.SHARED_MODULUS)));
g = new BigInteger(
- 1,
- Util.fromBase64((String) configuration.get(SRPRegistry.FIELD_GENERATOR)));
- // ----------------------------------------------------------------------
-
+ 1, Util.fromBase64((String) configuration.get(SRPRegistry.FIELD_GENERATOR)));
// generate an ephemeral keypair
final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
final Map attributes = new HashMap();
if (rnd != null)
- {
- attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
- }
+ attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
attributes.put(SRPKeyPairGenerator.GENERATOR, g);
attributes.put(SRPKeyPairGenerator.USER_VERIFIER, v);
kpg.setup(attributes);
hostKeyPair = kpg.generate();
-
final BigInteger B = ((SRPPublicKey) hostKeyPair.getPublic()).getY();
-
final OutgoingMessage result = new OutgoingMessage();
result.writeMPI(N);
result.writeMPI(g);
result.writeMPI(s);
result.writeMPI(B);
-
return result;
}
@@ -201,17 +164,13 @@ public class SRP6TLSServer extends SRP6KeyAgreement
throws KeyAgreementException
{
final BigInteger A = in.readMPI();
-
final BigInteger B = ((SRPPublicKey) hostKeyPair.getPublic()).getY();
final BigInteger u = uValue(A, B); // u = H(A | B)
-
// compute S = (Av^u) ^ b
final BigInteger b = ((SRPPrivateKey) hostKeyPair.getPrivate()).getX();
final BigInteger v = ((SRPPrivateKey) hostKeyPair.getPrivate()).getV();
final BigInteger S = A.multiply(v.modPow(u, N)).modPow(b, N);
-
K = S;
-
complete = true;
return null;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6User.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6User.java
index d300d6f7664..7c97e76976e 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6User.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6User.java
@@ -52,73 +52,45 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>The implementation of the User in the SRP-6 protocol.</p>
- *
- * <p>Reference:</p>
+ * The implementation of the User in the SRP-6 protocol.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRP6User extends SRP6KeyAgreement
+public class SRP6User
+ extends SRP6KeyAgreement
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The user's identity. */
private String I;
-
/** The user's cleartext password. */
private byte[] p;
-
/** The user's ephemeral key pair. */
private KeyPair userKeyPair;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // implementation of abstract methods in base class ------------------------
-
protected void engineInit(final Map attributes) throws KeyAgreementException
{
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
N = (BigInteger) attributes.get(SHARED_MODULUS);
if (N == null)
- {
- throw new KeyAgreementException("missing shared modulus");
- }
+ throw new KeyAgreementException("missing shared modulus");
g = (BigInteger) attributes.get(GENERATOR);
if (g == null)
- {
- throw new KeyAgreementException("missing generator");
- }
-
+ throw new KeyAgreementException("missing generator");
final String md = (String) attributes.get(HASH_FUNCTION);
- if (md == null || "".equals(md.trim()))
- {
- throw new KeyAgreementException("missing hash function");
- }
+ if (md == null || md.trim().length() == 0)
+ throw new KeyAgreementException("missing hash function");
srp = SRP.instance(md);
-
I = (String) attributes.get(USER_IDENTITY);
if (I == null)
- {
- throw new KeyAgreementException("missing user identity");
- }
+ throw new KeyAgreementException("missing user identity");
p = (byte[]) attributes.get(USER_PASSWORD);
if (p == null)
- {
- throw new KeyAgreementException("missing user password");
- }
+ throw new KeyAgreementException("missing user password");
}
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
@@ -143,8 +115,6 @@ public class SRP6User extends SRP6KeyAgreement
super.engineReset();
}
- // own methods -------------------------------------------------------------
-
private OutgoingMessage sendIdentity(final IncomingMessage in)
throws KeyAgreementException
{
@@ -152,18 +122,14 @@ public class SRP6User extends SRP6KeyAgreement
final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
final Map attributes = new HashMap();
if (rnd != null)
- {
- attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
- }
+ attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
attributes.put(SRPKeyPairGenerator.GENERATOR, g);
kpg.setup(attributes);
userKeyPair = kpg.generate();
-
final OutgoingMessage result = new OutgoingMessage();
result.writeString(I);
result.writeMPI(((SRPPublicKey) userKeyPair.getPublic()).getY());
-
return result;
}
@@ -172,10 +138,8 @@ public class SRP6User extends SRP6KeyAgreement
{
final BigInteger s = in.readMPI();
final BigInteger B = in.readMPI();
-
final BigInteger A = ((SRPPublicKey) userKeyPair.getPublic()).getY();
final BigInteger u = uValue(A, B); // u = H(A | B)
-
final BigInteger x;
try
{
@@ -185,18 +149,14 @@ public class SRP6User extends SRP6KeyAgreement
{
throw new KeyAgreementException("computeSharedSecret()", e);
}
-
// compute S = (B - 3g^x) ^ (a + ux)
final BigInteger a = ((SRPPrivateKey) userKeyPair.getPrivate()).getX();
- final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N))).modPow(
- a.add(u.multiply(x)),
- N);
-
+ final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N)))
+ .modPow(a.add(u.multiply(x)), N);
final byte[] sBytes = Util.trim(S);
final IMessageDigest hash = srp.newDigest();
hash.update(sBytes, 0, sBytes.length);
K = new BigInteger(1, hash.digest());
-
complete = true;
return null;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPAlgorithm.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPAlgorithm.java
index b068863ed0a..85b3b1139dc 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPAlgorithm.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPAlgorithm.java
@@ -38,15 +38,14 @@ exception statement from your version. */
package gnu.javax.crypto.key.srp6;
-import gnu.java.security.util.Prime2;
import gnu.javax.crypto.sasl.srp.SRPRegistry;
import java.math.BigInteger;
/**
- * <p>Utilities for use with SRP-6 based methods and protocols.</p>
- *
- * <p>Reference:</p>
+ * Utilities for use with SRP-6 based methods and protocols.
+ * <p>
+ * Reference:
* <ol>
* <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
* Thomas J. Wu.</li>
@@ -54,122 +53,79 @@ import java.math.BigInteger;
*/
public class SRPAlgorithm
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
// lifted from draft-burdis-cat-srp-sasl-09
public static final BigInteger N_2048 = new BigInteger(
- "AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050"
- + "A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50"
- + "E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B8"
- + "55F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773B"
- + "CA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748"
- + "544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6"
- + "AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB6"
- + "94B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73",
- 16);
-
+ "AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050"
+ + "A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50"
+ + "E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B8"
+ + "55F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773B"
+ + "CA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748"
+ + "544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6"
+ + "AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB6"
+ + "94B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73", 16);
public static final BigInteger N_1536 = new BigInteger(
- "9DEF3CAFB939277AB1F12A8617A47BBBDBA51DF499AC4C80BEEEA9614B19CC4D"
- + "5F4F5F556E27CBDE51C6A94BE4607A291558903BA0D0F84380B655BB9A22E8DC"
- + "DF028A7CEC67F0D08134B1C8B97989149B609E0BE3BAB63D47548381DBC5B1FC"
- + "764E3F4B53DD9DA1158BFD3E2B9C8CF56EDF019539349627DB2FD53D24B7C486"
- + "65772E437D6C7F8CE442734AF7CCB7AE837C264AE3A9BEB87F8A2FE9B8B5292E"
- + "5A021FFF5E91479E8CE7A28C2442C6F315180F93499A234DCF76E3FED135F9BB",
- 16);
-
+ "9DEF3CAFB939277AB1F12A8617A47BBBDBA51DF499AC4C80BEEEA9614B19CC4D"
+ + "5F4F5F556E27CBDE51C6A94BE4607A291558903BA0D0F84380B655BB9A22E8DC"
+ + "DF028A7CEC67F0D08134B1C8B97989149B609E0BE3BAB63D47548381DBC5B1FC"
+ + "764E3F4B53DD9DA1158BFD3E2B9C8CF56EDF019539349627DB2FD53D24B7C486"
+ + "65772E437D6C7F8CE442734AF7CCB7AE837C264AE3A9BEB87F8A2FE9B8B5292E"
+ + "5A021FFF5E91479E8CE7A28C2442C6F315180F93499A234DCF76E3FED135F9BB", 16);
public static final BigInteger N_1280 = new BigInteger(
- "D77946826E811914B39401D56A0A7843A8E7575D738C672A090AB1187D690DC4"
- + "3872FC06A7B6A43F3B95BEAEC7DF04B9D242EBDC481111283216CE816E004B78"
- + "6C5FCE856780D41837D95AD787A50BBE90BD3A9C98AC0F5FC0DE744B1CDE1891"
- + "690894BC1F65E00DE15B4B2AA6D87100C9ECC2527E45EB849DEB14BB2049B163"
- + "EA04187FD27C1BD9C7958CD40CE7067A9C024F9B7C5A0B4F5003686161F0605B",
- 16);
-
+ "D77946826E811914B39401D56A0A7843A8E7575D738C672A090AB1187D690DC4"
+ + "3872FC06A7B6A43F3B95BEAEC7DF04B9D242EBDC481111283216CE816E004B78"
+ + "6C5FCE856780D41837D95AD787A50BBE90BD3A9C98AC0F5FC0DE744B1CDE1891"
+ + "690894BC1F65E00DE15B4B2AA6D87100C9ECC2527E45EB849DEB14BB2049B163"
+ + "EA04187FD27C1BD9C7958CD40CE7067A9C024F9B7C5A0B4F5003686161F0605B", 16);
public static final BigInteger N_1024 = new BigInteger(
- "EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576"
- + "D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD1"
- + "5DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC"
- + "68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3",
- 16);
-
+ "EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576"
+ + "D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD1"
+ + "5DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC"
+ + "68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3", 16);
public static final BigInteger N_768 = new BigInteger(
- "B344C7C4F8C495031BB4E04FF8F84EE95008163940B9558276744D91F7CC9F40"
- + "2653BE7147F00F576B93754BCDDF71B636F2099E6FFF90E79575F3D0DE694AFF"
- + "737D9BE9713CEF8D837ADA6380B1093E94B6A529A8C6C2BE33E0867C60C3262B",
- 16);
-
+ "B344C7C4F8C495031BB4E04FF8F84EE95008163940B9558276744D91F7CC9F40"
+ + "2653BE7147F00F576B93754BCDDF71B636F2099E6FFF90E79575F3D0DE694AFF"
+ + "737D9BE9713CEF8D837ADA6380B1093E94B6A529A8C6C2BE33E0867C60C3262B", 16);
public static final BigInteger N_640 = new BigInteger(
- "C94D67EB5B1A2346E8AB422FC6A0EDAEDA8C7F894C9EEEC42F9ED250FD7F0046"
- + "E5AF2CF73D6B2FA26BB08033DA4DE322E144E7A8E9B12A0E4637F6371F34A207"
- + "1C4B3836CBEEAB15034460FAA7ADF483",
- 16);
-
+ "C94D67EB5B1A2346E8AB422FC6A0EDAEDA8C7F894C9EEEC42F9ED250FD7F0046"
+ + "E5AF2CF73D6B2FA26BB08033DA4DE322E144E7A8E9B12A0E4637F6371F34A207"
+ + "1C4B3836CBEEAB15034460FAA7ADF483", 16);
public static final BigInteger N_512 = new BigInteger(
- "D4C7F8A2B32C11B8FBA9581EC4BA4F1B04215642EF7355E37C0FC0443EF756EA"
- + "2C6B8EEB755A1C723027663CAA265EF785B8FF6A9B35227A52D86633DBDFCA43",
- 16);
-
+ "D4C7F8A2B32C11B8FBA9581EC4BA4F1B04215642EF7355E37C0FC0443EF756EA"
+ + "2C6B8EEB755A1C723027663CAA265EF785B8FF6A9B35227A52D86633DBDFCA43", 16);
public static final BigInteger N_384 = new BigInteger(
- "8025363296FB943FCE54BE717E0E2958A02A9672EF561953B2BAA3BAACC3ED57"
- + "54EB764C7AB7184578C57D5949CCB41B",
- 16);
-
+ "8025363296FB943FCE54BE717E0E2958A02A9672EF561953B2BAA3BAACC3ED57"
+ + "54EB764C7AB7184578C57D5949CCB41B", 16);
public static final BigInteger N_264 = new BigInteger(
- "115B8B692E0E045692CF280B436735C77A5A9E8A9E7ED56C965F87DB5B2A2ECE3",
- 16);
-
+ "115B8B692E0E045692CF280B436735C77A5A9E8A9E7ED56C965F87DB5B2A2ECE3", 16);
private static final BigInteger ZERO = BigInteger.ZERO;
-
private static final BigInteger ONE = BigInteger.ONE;
-
private static final BigInteger TWO = BigInteger.valueOf(2L);
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce usage through class methods. */
private SRPAlgorithm()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static void checkParams(final BigInteger N, final BigInteger g)
{
// 1. N should be at least 512-bit long
final int blen = N.bitLength();
if (blen < SRPRegistry.MINIMUM_MODULUS_BITLENGTH)
- {
- throw new IllegalArgumentException(
- "Bit length of N ("
- + blen
- + ") is too low. Should be at least "
- + SRPRegistry.MINIMUM_MODULUS_BITLENGTH);
- }
+ throw new IllegalArgumentException("Bit length of N ("
+ + blen
+ + ") is too low. Should be at least "
+ + SRPRegistry.MINIMUM_MODULUS_BITLENGTH);
// 2. N should be a prime
- if (!Prime2.passEulerCriterion(N))
- {
- throw new IllegalArgumentException("N should be prime but isn't");
- }
+ if (! N.isProbablePrime(80))
+ throw new IllegalArgumentException("N should be prime but isn't");
// 3. N should be of the form 2*q + 1, where q is prime
final BigInteger q = N.subtract(ONE).divide(TWO);
- if (!Prime2.passEulerCriterion(q))
- {
- throw new IllegalArgumentException("(N-1)/2 should be prime but isn't");
- }
+ if (! q.isProbablePrime(80))
+ throw new IllegalArgumentException("(N-1)/2 should be prime but isn't");
// 4. g**q should be -1 mod N
final BigInteger gq = g.modPow(q, N).add(ONE).mod(N);
if (gq.compareTo(ZERO) != 0)
- {
- throw new IllegalArgumentException(
- "g**q should be -1 (mod N) but isn't");
- }
+ throw new IllegalArgumentException("g**q should be -1 (mod N) but isn't");
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKey.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKey.java
index 202ef33b7e2..06ba47a9fb3 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKey.java
@@ -46,37 +46,30 @@ import java.math.BigInteger;
import java.security.Key;
/**
- * <p>An abstract representation of a base SRP ephemeral key.</p>
- *
- * <p>This object encapsulates the two numbers:</p>
+ * An abstract representation of a base SRP ephemeral key.
+ * <p>
+ * This object encapsulates the two numbers:
* <ul>
- * <li><b>N</b>: A large safe prime (N = 2q+1, where q is prime).</li>
- * <li><b>g</b>: A generator modulo N.</li>
+ * <li><b>N</b>: A large safe prime (N = 2q+1, where q is prime).</li>
+ * <li><b>g</b>: A generator modulo N.</li>
* </ul>
- *
- * <p>Note that in SRP, all arithmetic is done modulo N.</p>
- *
- * <p>Reference:</p>
+ * <p>
+ * Note that in SRP, all arithmetic is done modulo N.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public abstract class SRPKey implements Key, Serializable
+public abstract class SRPKey
+ implements Key, Serializable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The public, Germaine prime, shared modulus. */
protected final BigInteger N;
-
/** The generator. */
protected final BigInteger g;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected SRPKey(BigInteger N, BigInteger g)
{
super();
@@ -85,17 +78,9 @@ public abstract class SRPKey implements Key, Serializable
this.g = g;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.security.Key interface implementation ------------------------------
-
/**
- * <p>Returns the standard algorithm name for this key.</p>
- *
+ * Returns the standard algorithm name for this key.
+ *
* @return the standard algorithm name for this key.
*/
public String getAlgorithm()
@@ -112,7 +97,7 @@ public abstract class SRPKey implements Key, Serializable
/**
* Returns {@link Registry#RAW_ENCODING_SHORT_NAME} which is the sole format
* supported for this type of keys.
- *
+ *
* @return {@link Registry#RAW_ENCODING_SHORT_NAME} ALWAYS.
*/
public String getFormat()
@@ -120,11 +105,9 @@ public abstract class SRPKey implements Key, Serializable
return Registry.RAW_ENCODING_SHORT_NAME;
}
- // other methods -----------------------------------------------------------
-
/**
- * <p>Returns the public shared modulus.</p>
- *
+ * Returns the public shared modulus.
+ *
* @return <code>N</code>.
*/
public BigInteger getN()
@@ -133,8 +116,8 @@ public abstract class SRPKey implements Key, Serializable
}
/**
- * <p>Returns the generator.</p>
- *
+ * Returns the generator.
+ *
* @return <code>g</code>.
*/
public BigInteger getG()
@@ -143,28 +126,22 @@ public abstract class SRPKey implements Key, Serializable
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * <code>SRPKey</code> and has the same SRP parameter values as this one.</p>
- *
+ * Returns <code>true</code> if the designated object is an instance of
+ * <code>SRPKey</code> and has the same SRP parameter values as this one.
+ *
* @param obj the other non-null SRP key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof SRPKey))
- {
- return false;
- }
+ return false;
+ if (! (obj instanceof SRPKey))
+ return false;
SRPKey that = (SRPKey) obj;
return N.equals(that.getN()) && g.equals(that.getG());
}
- // abstract methods to be implemented by subclasses ------------------------
-
public abstract byte[] getEncoded(int format);
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java
index 2957fc3c855..8d50c9b71cb 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java
@@ -38,111 +38,64 @@ exception statement from your version. */
package gnu.javax.crypto.key.srp6;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairGenerator;
import gnu.java.security.util.PRNG;
-import gnu.java.security.util.Prime2;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.SecureRandom;
import java.util.Map;
+import java.util.logging.Logger;
/**
- *
- *
- * <p>Reference:</p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRPKeyPairGenerator implements IKeyPairGenerator
+public class SRPKeyPairGenerator
+ implements IKeyPairGenerator
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "srp";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 5;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(SRPKeyPairGenerator.class.getName());
private static final BigInteger ZERO = BigInteger.ZERO;
-
private static final BigInteger ONE = BigInteger.ONE;
-
private static final BigInteger TWO = BigInteger.valueOf(2L);
-
private static final BigInteger THREE = BigInteger.valueOf(3L);
-
/** Property name of the length (Integer) of the modulus (N) of an SRP key. */
public static final String MODULUS_LENGTH = "gnu.crypto.srp.L";
-
/** Property name of the Boolean indicating wether or not to use defaults. */
public static final String USE_DEFAULTS = "gnu.crypto.srp.use.defaults";
-
/** Property name of the modulus (N) of an SRP key. */
public static final String SHARED_MODULUS = "gnu.crypto.srp.N";
-
/** Property name of the generator (g) of an SRP key. */
public static final String GENERATOR = "gnu.crypto.srp.g";
-
/** Property name of the user's verifier (v) for a Server SRP key. */
public static final String USER_VERIFIER = "gnu.crypto.srp.v";
-
/**
* Property name of an optional {@link SecureRandom} instance to use. The
* default is to use a classloader singleton from {@link PRNG}.
*/
public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.srp.prng";
-
/** Default value for the modulus length. */
private static final int DEFAULT_MODULUS_LENGTH = 1024;
-
/** The optional {@link SecureRandom} instance to use. */
private SecureRandom rnd = null;
-
/** Bit length of the shared modulus. */
private int l;
-
/** The shared public modulus. */
private BigInteger N;
-
/** The Field generator. */
private BigInteger g;
-
/** The user's verifier MPI. */
private BigInteger v;
-
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.key.IKeyPairGenerator interface implementation ---------------
-
public String name()
{
return Registry.SRP_KPG;
@@ -152,25 +105,20 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
{
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
-
N = (BigInteger) attributes.get(SHARED_MODULUS);
if (N != null)
{
l = N.bitLength();
g = (BigInteger) attributes.get(GENERATOR);
if (g == null)
- {
- g = TWO;
- }
+ g = TWO;
SRPAlgorithm.checkParams(N, g);
}
else
{ // generate or use default values for N and g
Boolean useDefaults = (Boolean) attributes.get(USE_DEFAULTS);
if (useDefaults == null)
- {
- useDefaults = Boolean.TRUE;
- }
+ useDefaults = Boolean.TRUE;
Integer L = (Integer) attributes.get(MODULUS_LENGTH);
l = DEFAULT_MODULUS_LENGTH;
if (useDefaults.equals(Boolean.TRUE))
@@ -203,26 +151,23 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
break;
default:
throw new IllegalArgumentException(
- "unknown default shared modulus bit length");
+ "unknown default shared modulus bit length");
}
g = TWO;
l = N.bitLength();
}
}
- else
- { // generate new N and g
+ else // generate new N and g
+ {
if (L != null)
{
l = L.intValue();
if ((l % 256) != 0 || l < 512 || l > 2048)
- {
- throw new IllegalArgumentException(
- "invalid shared modulus bit length");
- }
+ throw new IllegalArgumentException(
+ "invalid shared modulus bit length");
}
}
}
-
// are we using this generator on the server side, or the client side?
v = (BigInteger) attributes.get(USER_VERIFIER);
}
@@ -235,23 +180,20 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
BigInteger q = params[0];
N = params[1];
g = params[2];
- if (DEBUG && debuglevel > 0)
+ if (Configuration.DEBUG)
{
- debug("q: " + q.toString(16));
- debug("N: " + N.toString(16));
- debug("g: " + g.toString(16));
+ log.fine("q: " + q.toString(16));
+ log.fine("N: " + N.toString(16));
+ log.fine("g: " + g.toString(16));
}
}
-
return (v != null ? hostKeyPair() : userKeyPair());
}
- // helper methods ----------------------------------------------------------
-
private synchronized BigInteger[] generateParameters()
{
- // N A large safe prime (N = 2q+1, where q is prime)
- // g A generator modulo N
+ // N A large safe prime (N = 2q+1, where q is prime)
+ // g A generator modulo N
BigInteger q, p, g;
byte[] qBytes = new byte[l / 8];
do
@@ -262,11 +204,10 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
q = new BigInteger(1, qBytes);
q = q.setBit(0).setBit(l - 2).clearBit(l - 1);
}
- while (!Prime2.isProbablePrime(q));
+ while (! q.isProbablePrime(80));
p = q.multiply(TWO).add(ONE);
}
- while (p.bitLength() != l || !Prime2.isProbablePrime(p));
-
+ while (p.bitLength() != l || ! p.isProbablePrime(80));
// compute g. from FIPS-186, Appendix 4: e == 2
BigInteger p_minus_1 = p.subtract(ONE);
g = TWO;
@@ -277,12 +218,9 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
// Set g = h**2 mod p
g = h.modPow(TWO, p);
// If g = 1, go to step 3
- if (!g.equals(ONE))
- {
- break;
- }
+ if (! g.equals(ONE))
+ break;
}
-
return new BigInteger[] { q, p, g };
}
@@ -301,11 +239,8 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
B = THREE.multiply(v).add(g.modPow(b, N)).mod(N);
}
while (B.compareTo(ZERO) == 0 || B.compareTo(N) >= 0);
-
- KeyPair result = new KeyPair(
- new SRPPublicKey(new BigInteger[] { N, g, B }),
- new SRPPrivateKey(new BigInteger[] { N, g, b,
- v }));
+ KeyPair result = new KeyPair(new SRPPublicKey(new BigInteger[] { N, g, B }),
+ new SRPPrivateKey(new BigInteger[] { N, g, b, v }));
return result;
}
@@ -324,9 +259,7 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
A = g.modPow(a, N);
}
while (A.compareTo(ZERO) == 0 || A.compareTo(N) >= 0);
-
- KeyPair result = new KeyPair(
- new SRPPublicKey(new BigInteger[] { N, g, A }),
+ KeyPair result = new KeyPair(new SRPPublicKey(new BigInteger[] { N, g, A }),
new SRPPrivateKey(new BigInteger[] { N, g, a }));
return result;
}
@@ -334,9 +267,7 @@ public class SRPKeyPairGenerator implements IKeyPairGenerator
private void nextRandomBytes(byte[] buffer)
{
if (rnd != null)
- {
- rnd.nextBytes(buffer);
- }
+ rnd.nextBytes(buffer);
else
getDefaultPRNG().nextBytes(buffer);
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java
index 39234b6271f..555dc23cf1a 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairRawCodec.java
@@ -47,116 +47,93 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * <p>An object that implements the {@link IKeyPairCodec} operations for the
- * <i>Raw</i> format to use with SRP keypairs.</p>
- *
- * <p>Reference:</p>
+ * An object that implements the {@link IKeyPairCodec} operations for the
+ * <i>Raw</i> format to use with SRP keypairs.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRPKeyPairRawCodec implements IKeyPairCodec
+public class SRPKeyPairRawCodec
+ implements IKeyPairCodec
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.keys.IKeyPairCodec interface implementation ------------------
-
public int getFormatID()
{
return RAW_FORMAT;
}
/**
- * <p>Returns the encoded form of the designated SRP public key according to
- * the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for an SRP public key, in this implementation, is
- * a byte sequence consisting of the following:</p>
+ * Returns the encoded form of the designated SRP public key according to the
+ * <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for an SRP public key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_SRP_PUBLIC_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>N</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>N</code>,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>y</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>y</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_SRP_PUBLIC_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>N</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>N</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>y</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>y</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not an SRP one.
*/
public byte[] encodePublicKey(PublicKey key)
{
- if (!(key instanceof SRPPublicKey))
- {
- throw new IllegalArgumentException("key");
- }
-
+ if (! (key instanceof SRPPublicKey))
+ throw new IllegalArgumentException("key");
SRPPublicKey srpKey = (SRPPublicKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_SRP_PUBLIC_KEY[0]);
baos.write(Registry.MAGIC_RAW_SRP_PUBLIC_KEY[1]);
baos.write(Registry.MAGIC_RAW_SRP_PUBLIC_KEY[2]);
baos.write(Registry.MAGIC_RAW_SRP_PUBLIC_KEY[3]);
-
// version
baos.write(0x01);
-
// N
byte[] buffer = srpKey.getN().toByteArray();
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = srpKey.getG().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// y
buffer = srpKey.getY().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
return baos.toByteArray();
}
@@ -167,150 +144,133 @@ public class SRPKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_SRP_PUBLIC_KEY[1]
|| k[2] != Registry.MAGIC_RAW_SRP_PUBLIC_KEY[2]
|| k[3] != Registry.MAGIC_RAW_SRP_PUBLIC_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
+ throw new IllegalArgumentException("version");
int i = 5;
-
int l;
byte[] buffer;
-
// N
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger N = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// y
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger y = new BigInteger(1, buffer);
-
return new SRPPublicKey(N, g, y);
}
/**
- * <p>Returns the encoded form of the designated SRP private key according to
- * the <i>Raw</i> format supported by this library.</p>
- *
- * <p>The <i>Raw</i> format for an SRP private key, in this implementation,
- * is a byte sequence consisting of the following:</p>
+ * Returns the encoded form of the designated SRP private key according to the
+ * <i>Raw</i> format supported by this library.
+ * <p>
+ * The <i>Raw</i> format for an SRP private key, in this implementation, is a
+ * byte sequence consisting of the following:
* <ol>
- * <li>4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_SRP_PRIVATE_KEY},<li>
- * <li>1-byte version consisting of the constant: 0x01,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>N</code> in internet order,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>N</code>,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>g</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>g</code>,</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>x</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>x</code>,</li>
- * <li>one byte which indicates whether the SRP parameter <code>v</code>
- * is included in this encoding (value <code>0x01</code>) or not
- * (value <code>0x00</code>).</li>
- * <li>4-byte count of following bytes representing the SRP parameter
- * <code>v</code>,</li>
- * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
- * the <code>toByteArray()</code> method on the SRP parameter
- * <code>v</code>,</li>
+ * <li>4-byte magic consisting of the value of the literal
+ * {@link Registry#MAGIC_RAW_SRP_PRIVATE_KEY},</li>
+ * <li>1-byte version consisting of the constant: 0x01,</li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>N</code> in internet order,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>N</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>g</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>g</code>,
+ * </li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>x</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>x</code>,
+ * </li>
+ * <li>one byte which indicates whether the SRP parameter <code>v</code> is
+ * included in this encoding (value <code>0x01</code>) or not (value
+ * <code>0x00</code>).</li>
+ * <li>4-byte count of following bytes representing the SRP parameter
+ * <code>v</code>,</li>
+ * <li>n-bytes representation of a {@link BigInteger} obtained by invoking
+ * the <code>toByteArray()</code> method on the SRP parameter <code>v</code>,
+ * </li>
* </ol>
- *
+ *
* @param key the key to encode.
* @return the <i>Raw</i> format encoding of the designated key.
* @throws IllegalArgumentException if the designated key is not an SRP one.
*/
public byte[] encodePrivateKey(PrivateKey key)
{
- if (!(key instanceof SRPPrivateKey))
- {
- throw new IllegalArgumentException("key");
- }
-
+ if (! (key instanceof SRPPrivateKey))
+ throw new IllegalArgumentException("key");
SRPPrivateKey srpKey = (SRPPrivateKey) key;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
// magic
baos.write(Registry.MAGIC_RAW_SRP_PRIVATE_KEY[0]);
baos.write(Registry.MAGIC_RAW_SRP_PRIVATE_KEY[1]);
baos.write(Registry.MAGIC_RAW_SRP_PRIVATE_KEY[2]);
baos.write(Registry.MAGIC_RAW_SRP_PRIVATE_KEY[3]);
-
// version
baos.write(0x01);
-
// N
byte[] buffer = srpKey.getN().toByteArray();
int length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// g
buffer = srpKey.getG().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// x
buffer = srpKey.getX().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
-
// v
if (srpKey.getV() != null)
{
baos.write(0x01);
-
buffer = srpKey.getV().toByteArray();
length = buffer.length;
- baos.write(length >>> 24);
+ baos.write( length >>> 24);
baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
+ baos.write((length >>> 8) & 0xFF);
+ baos.write( length & 0xFF);
baos.write(buffer, 0, length);
}
else
- {
- baos.write(0x00);
- }
-
+ baos.write(0x00);
return baos.toByteArray();
}
@@ -321,60 +281,54 @@ public class SRPKeyPairRawCodec implements IKeyPairCodec
|| k[1] != Registry.MAGIC_RAW_SRP_PRIVATE_KEY[1]
|| k[2] != Registry.MAGIC_RAW_SRP_PRIVATE_KEY[2]
|| k[3] != Registry.MAGIC_RAW_SRP_PRIVATE_KEY[3])
- {
- throw new IllegalArgumentException("magic");
- }
-
+ throw new IllegalArgumentException("magic");
// version
if (k[4] != 0x01)
- {
- throw new IllegalArgumentException("version");
- }
+ throw new IllegalArgumentException("version");
int i = 5;
-
int l;
byte[] buffer;
-
// N
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger N = new BigInteger(1, buffer);
-
// g
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger g = new BigInteger(1, buffer);
-
// x
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger x = new BigInteger(1, buffer);
-
// v
l = k[i++];
if (l == 0x01)
{
- l = k[i++] << 24 | (k[i++] & 0xFF) << 16 | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
+ l = k[i++] << 24
+ | (k[i++] & 0xFF) << 16
+ | (k[i++] & 0xFF) << 8
+ | (k[i++] & 0xFF);
buffer = new byte[l];
System.arraycopy(k, i, buffer, 0, l);
i += l;
BigInteger v = new BigInteger(1, buffer);
-
return new SRPPrivateKey(N, g, x, v);
}
- else
- {
- return new SRPPrivateKey(N, g, x);
- }
+ return new SRPPrivateKey(N, g, x);
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPrivateKey.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPrivateKey.java
index d9f7a19a6cf..d5ade07d765 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPrivateKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPrivateKey.java
@@ -45,39 +45,33 @@ import java.math.BigInteger;
import java.security.PrivateKey;
/**
- * <p>A representation of an SRP ephemeral private key.</p>
- *
- * <p>Reference:</p>
+ * A representation of an SRP ephemeral private key.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRPPrivateKey extends SRPKey implements PrivateKey
+public class SRPPrivateKey
+ extends SRPKey
+ implements PrivateKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * The private exponent for either the server or the client engaged in the
- * SRP protocol exchange.
+ * The private exponent for either the server or the client engaged in the SRP
+ * protocol exchange.
*/
private final BigInteger X;
-
/**
- * The user's verifier (v) --for the server-- also computed at the client
- * side as g.modPow(x, N), where x is the hashed output of the user name and
+ * The user's verifier (v) --for the server-- also computed at the client side
+ * as g.modPow(x, N), where x is the hashed output of the user name and
* password .
*/
private final BigInteger v;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Public constructor for use from outside this package.</p>
- *
+ * Public constructor for use from outside this package.
+ *
* @param N the public shared modulus.
* @param g the generator.
* @param x the private exponent of the ephemeral key.
@@ -88,8 +82,8 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
}
/**
- * <p>Public constructor for use from outside this package.</p>
- *
+ * Public constructor for use from outside this package.
+ *
* @param N the public shared modulus.
* @param g the generator.
* @param x the private exponent of the ephemeral key.
@@ -105,15 +99,16 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
}
/**
- * <p>Default constructor. Assumes N and g are already validated.</p>
- *
+ * Default constructor. Assumes N and g are already validated.
+ *
* @param params an array of either 3 or 4 values representing N, g, and
- * either v and X for the server, or just X for the client. Those values
- * represent the following:
- * <ol>
- * <li>v (server side): the user's verifier.</li>
- * <li>X (both sides): the server's or client's ephemeral private exponent.</li>
- * </ol>
+ * either v and X for the server, or just X for the client. Those
+ * values represent the following:
+ * <ol>
+ * <li>v (server side): the user's verifier.</li>
+ * <li>X (both sides): the server's or client's ephemeral private
+ * exponent.</li>
+ * </ol>
*/
SRPPrivateKey(BigInteger[] params)
{
@@ -130,31 +125,27 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
v = params[3];
}
else
- {
- throw new IllegalArgumentException("invalid number of SRP parameters");
- }
+ throw new IllegalArgumentException("invalid number of SRP parameters");
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A class method that takes the output of the <code>encodePrivateKey()</code>
+ * A class method that takes the output of the <code>encodePrivateKey()</code>
* method of an SRP keypair codec object (an instance implementing
* {@link IKeyPairCodec} for DSS keys, and re-constructs an instance of this
- * object.</p>
- *
+ * object.
+ *
* @param k the contents of a previously encoded instance of this object.
* @throws ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * <code>k</code>, to represent a valid encoding of an instance of this object.
+ * <code>k</code>, to represent a valid encoding of an instance
+ * of this object.
* @throws IllegalArgumentException if the byte sequence does not represent a
- * valid encoding of an instance of this object.
+ * valid encoding of an instance of this object.
*/
public static SRPPrivateKey valueOf(byte[] k)
{
// check magic...
// we should parse here enough bytes to know which codec to use, and
- // direct the byte array to the appropriate codec. since we only have one
+ // direct the byte array to the appropriate codec. since we only have one
// codec, we could have immediately tried it; nevertheless since testing
// one byte is cheaper than instatiating a codec that will fail we test
// the first byte before we carry on.
@@ -164,18 +155,12 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
IKeyPairCodec codec = new SRPKeyPairRawCodec();
return (SRPPrivateKey) codec.decodePrivateKey(k);
}
- else
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the private exponent of the key as a {@link BigInteger}.</p>
- *
+ * Returns the private exponent of the key as a {@link BigInteger}.
+ *
* @return the private exponent of the key as a {@link BigInteger}.
*/
public BigInteger getX()
@@ -184,26 +169,24 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
}
/**
- * <p>Returns the user's verifier as a {@link BigInteger}.</p>
- *
+ * Returns the user's verifier as a {@link BigInteger}.
+ *
* @return the user's verifier as a {@link BigInteger} if this is an SRP
- * private key of a Host, or <code>null</code> if this is a private SRP key
- * for a User.
+ * private key of a Host, or <code>null</code> if this is a private
+ * SRP key for a User.
*/
public BigInteger getV()
{
return v;
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the encoded form of this private key according to the
- * designated format.</p>
- *
+ * Returns the encoded form of this private key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @throws IllegalArgumentException if the format is not supported.
*/
public byte[] getEncoded(int format)
@@ -221,30 +204,24 @@ public class SRPPrivateKey extends SRPKey implements PrivateKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
+ * Returns <code>true</code> if the designated object is an instance of
* <code>SRPPrivateKey</code> and has the same SRP parameter values as this
- * one.</p>
- *
+ * one.
+ *
* @param obj the other non-null SRP key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof SRPPrivateKey))
- {
- return false;
- }
+ return false;
+ if (! (obj instanceof SRPPrivateKey))
+ return false;
SRPPrivateKey that = (SRPPrivateKey) obj;
boolean result = super.equals(that) && X.equals(that.getX());
if (v != null)
- {
- result = result && v.equals(that.getV());
- }
+ result = result && v.equals(that.getV());
return result;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPublicKey.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPublicKey.java
index 7283fd3dae2..04a949211b9 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPublicKey.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRPPublicKey.java
@@ -45,32 +45,27 @@ import java.math.BigInteger;
import java.security.PublicKey;
/**
- * <p>A representation of an SRP ephemeral public key.</p>
- *
- * <p>Reference:</p>
+ * A representation of an SRP ephemeral public key.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
-public class SRPPublicKey extends SRPKey implements PublicKey
+public class SRPPublicKey
+ extends SRPKey
+ implements PublicKey
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * The public exponent for either the server or the client engaged in the
- * SRP protocol exchange.
+ * The public exponent for either the server or the client engaged in the SRP
+ * protocol exchange.
*/
private final BigInteger Y;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Public constructor for use from outside this package.</p>
- *
+ * Public constructor for use from outside this package.
+ *
* @param N the public shared modulus.
* @param g the generator.
* @param Y the public exponent of the ephemeral key.
@@ -84,10 +79,10 @@ public class SRPPublicKey extends SRPKey implements PublicKey
}
/**
- * <p>Default constructor. Assumes that N and g are already validated.</p>
- *
+ * Default constructor. Assumes that N and g are already validated.
+ *
* @param params an array of 3 values representing N, g and Y; the latter
- * being the client's or server's public exponent.
+ * being the client's or server's public exponent.
*/
SRPPublicKey(BigInteger[] params)
{
@@ -96,26 +91,24 @@ public class SRPPublicKey extends SRPKey implements PublicKey
this.Y = params[2];
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A class method that takes the output of the <code>encodePublicKey()</code>
+ * A class method that takes the output of the <code>encodePublicKey()</code>
* method of an SRP keypair codec object (an instance implementing
* {@link IKeyPairCodec} for SRP keys, and re-constructs an instance of this
- * object.</p>
- *
+ * object.
+ *
* @param k the contents of a previously encoded instance of this object.
* @throws ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * <code>k</code>, to represent a valid encoding of an instance of this object.
+ * <code>k</code>, to represent a valid encoding of an instance
+ * of this object.
* @throws IllegalArgumentException if the byte sequence does not represent a
- * valid encoding of an instance of this object.
+ * valid encoding of an instance of this object.
*/
public static SRPPublicKey valueOf(byte[] k)
{
// check magic...
// we should parse here enough bytes to know which codec to use, and
- // direct the byte array to the appropriate codec. since we only have one
+ // direct the byte array to the appropriate codec. since we only have one
// codec, we could have immediately tried it; nevertheless since testing
// one byte is cheaper than instatiating a codec that will fail we test
// the first byte before we carry on.
@@ -125,18 +118,12 @@ public class SRPPublicKey extends SRPKey implements PublicKey
IKeyPairCodec codec = new SRPKeyPairRawCodec();
return (SRPPublicKey) codec.decodePublicKey(k);
}
- else
- {
- throw new IllegalArgumentException("magic");
- }
+ throw new IllegalArgumentException("magic");
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the public exponent of the key as a {@link BigInteger}.</p>
- *
+ * Returns the public exponent of the key as a {@link BigInteger}.
+ *
* @return the public exponent of the key as a {@link BigInteger}.
*/
public BigInteger getY()
@@ -144,15 +131,13 @@ public class SRPPublicKey extends SRPKey implements PublicKey
return Y;
}
- // Other instance methods --------------------------------------------------
-
/**
- * <p>Returns the encoded form of this public key according to the designated
- * format.</p>
- *
+ * Returns the encoded form of this public key according to the designated
+ * format.
+ *
* @param format the desired format identifier of the resulting encoding.
* @return the byte sequence encoding this key according to the designated
- * format.
+ * format.
* @throws IllegalArgumentException if the format is not supported.
*/
public byte[] getEncoded(int format)
@@ -170,24 +155,20 @@ public class SRPPublicKey extends SRPKey implements PublicKey
}
/**
- * <p>Returns <code>true</code> if the designated object is an instance of
- * <code>SRPPublicKey</code>and has the same SRP parameter values as this one.
- * </p>
- *
+ * Returns <code>true</code> if the designated object is an instance of
+ * <code>SRPPublicKey</code>and has the same SRP parameter values as this
+ * one.
+ *
* @param obj the other non-null SRP key to compare to.
- * @return <code>true</code> if the designated object is of the same type and
- * value as this one.
+ * @return <code>true</code> if the designated object is of the same type
+ * and value as this one.
*/
public boolean equals(Object obj)
{
if (obj == null)
- {
- return false;
- }
- if (!(obj instanceof SRPPublicKey))
- {
- return false;
- }
+ return false;
+ if (! (obj instanceof SRPPublicKey))
+ return false;
SRPPublicKey that = (SRPPublicKey) obj;
return super.equals(that) && Y.equals(that.getY());
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/AuthenticatedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/AuthenticatedEntry.java
index 22b42b3ea0b..cd2e5868db9 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/AuthenticatedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/AuthenticatedEntry.java
@@ -38,46 +38,32 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Registry;
+import gnu.javax.crypto.mac.IMac;
+import gnu.javax.crypto.mac.MacFactory;
+import gnu.javax.crypto.mac.MacOutputStream;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
import java.security.InvalidKeyException;
-
import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
import java.util.HashMap;
-import java.util.List;
-
-import gnu.java.security.Registry;
-import gnu.javax.crypto.mac.IMac;
-import gnu.javax.crypto.mac.MacFactory;
-import gnu.javax.crypto.mac.MacInputStream;
-import gnu.javax.crypto.mac.MacOutputStream;
+import java.util.Iterator;
-public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
- Registry
+public final class AuthenticatedEntry
+ extends MaskableEnvelopeEntry
+ implements Registry
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
public static final int TYPE = 2;
- // Constructor.
- // ------------------------------------------------------------------------
-
public AuthenticatedEntry(String mac, int macLen, Properties properties)
{
super(TYPE, properties);
-
if (macLen <= 0)
- {
- throw new IllegalArgumentException("invalid mac length");
- }
+ throw new IllegalArgumentException("invalid mac length");
this.properties.put("mac", mac);
this.properties.put("maclen", String.valueOf(macLen));
setMasked(false);
@@ -89,32 +75,22 @@ public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
setMasked(true);
}
- // Class methods.
- // ------------------------------------------------------------------------
-
public static AuthenticatedEntry decode(DataInputStream in)
throws IOException
{
AuthenticatedEntry entry = new AuthenticatedEntry();
entry.properties.decode(in);
- if (!entry.properties.containsKey("mac"))
- {
- throw new MalformedKeyringException("no mac specified");
- }
- if (!entry.properties.containsKey("maclen"))
- {
- throw new MalformedKeyringException("no mac length specified");
- }
+ if (! entry.properties.containsKey("mac"))
+ throw new MalformedKeyringException("no mac specified");
+ if (! entry.properties.containsKey("maclen"))
+ throw new MalformedKeyringException("no mac length specified");
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Computes the mac over this envelope's data. This method <b>must</b> be
* called before this entry in encoded.
- *
+ *
* @param key The key to authenticate with.
* @throws IOException If encoding fails.
* @throws InvalidKeyException If the supplied key is bad.
@@ -122,11 +98,8 @@ public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
public void authenticate(byte[] key) throws IOException, InvalidKeyException
{
if (isMasked())
- {
- throw new IllegalStateException("entry is masked");
- }
+ throw new IllegalStateException("entry is masked");
IMac m = getMac(key);
-
ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
MacOutputStream macout = new MacOutputStream(bout, m);
DataOutputStream out2 = new DataOutputStream(macout);
@@ -140,36 +113,28 @@ public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
}
/**
- * Verifies this entry's payload. This method will unmask this entry,
- * thus it must be called before accessing its contents.
- *
+ * Verifies this entry's payload. This method will unmask this entry, thus it
+ * must be called before accessing its contents.
+ *
* @param key The key to use to authenticate.
* @throws InvalidKeyException If the given key is improper.
*/
public void verify(byte[] key) throws InvalidKeyException
{
- if (!isMasked() || payload == null)
- {
- return;
- }
+ if (! isMasked() || payload == null)
+ return;
IMac m = getMac(key);
-
m.update(payload, 0, payload.length - m.macSize());
byte[] macValue = new byte[m.macSize()];
System.arraycopy(payload, payload.length - macValue.length, macValue, 0,
macValue.length);
- if (!Arrays.equals(macValue, m.digest()))
- {
- throw new IllegalArgumentException("MAC verification failed");
- }
+ if (! Arrays.equals(macValue, m.digest()))
+ throw new IllegalArgumentException("MAC verification failed");
try
{
- DataInputStream in = new DataInputStream(
- new ByteArrayInputStream(
- payload,
- 0,
- payload.length
- - m.macSize()));
+ int len = payload.length - m.macSize();
+ ByteArrayInputStream bais = new ByteArrayInputStream(payload, 0, len);
+ DataInputStream in = new DataInputStream(bais);
decodeEnvelope(in);
}
catch (IOException ioe)
@@ -183,27 +148,17 @@ public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
protected void encodePayload() throws IOException
{
if (payload == null)
- {
- throw new IllegalStateException("not authenticated");
- }
+ throw new IllegalStateException("not authenticated");
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private IMac getMac(byte[] key) throws InvalidKeyException
{
IMac mac = MacFactory.getInstance(properties.get("mac"));
if (mac == null)
- {
- throw new IllegalArgumentException("no such mac: "
- + properties.get("mac"));
- }
+ throw new IllegalArgumentException("no such mac: " + properties.get("mac"));
int maclen = 0;
- if (!properties.containsKey("maclen"))
- {
- throw new IllegalArgumentException("no MAC length");
- }
+ if (! properties.containsKey("maclen"))
+ throw new IllegalArgumentException("no MAC length");
try
{
maclen = Integer.parseInt(properties.get("maclen"));
@@ -212,10 +167,9 @@ public final class AuthenticatedEntry extends MaskableEnvelopeEntry implements
{
throw new IllegalArgumentException("bad MAC length");
}
-
HashMap macAttr = new HashMap();
macAttr.put(IMac.MAC_KEY_MATERIAL, key);
- macAttr.put(IMac.TRUNCATED_SIZE, new Integer(maclen));
+ macAttr.put(IMac.TRUNCATED_SIZE, Integer.valueOf(maclen));
mac.init(macAttr);
return mac;
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/BaseKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/BaseKeyring.java
index 5fe7dbf4deb..369507d4c73 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/BaseKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/BaseKeyring.java
@@ -38,86 +38,58 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
-import java.io.InputStream;
+import gnu.java.security.Registry;
+
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import gnu.java.security.Registry;
-
-public abstract class BaseKeyring implements IKeyring
+public abstract class BaseKeyring
+ implements IKeyring
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /**
- * The top-level keyring data.
- */
+ /** The top-level keyring data. */
protected PasswordAuthenticatedEntry keyring;
-
protected CompressedEntry keyring2;
- // Constructors.
- // ------------------------------------------------------------------------
-
public BaseKeyring()
{
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public void load(Map attributes) throws IOException
{
InputStream in = (InputStream) attributes.get(KEYRING_DATA_IN);
if (in == null)
- {
- throw new IllegalArgumentException("no input stream");
- }
+ throw new IllegalArgumentException("no input stream");
char[] password = (char[]) attributes.get(KEYRING_PASSWORD);
if (password == null)
- {
- password = new char[0];
- }
+ password = new char[0];
if (in.read() != Registry.GKR_MAGIC[0]
|| in.read() != Registry.GKR_MAGIC[1]
|| in.read() != Registry.GKR_MAGIC[2]
|| in.read() != Registry.GKR_MAGIC[3])
- {
- throw new MalformedKeyringException("magic");
- }
+ throw new MalformedKeyringException("magic");
load(in, password);
-
List l = keyring.getEntries();
if (l.size() == 1 && (l.get(0) instanceof CompressedEntry))
- {
- keyring2 = (CompressedEntry) l.get(0);
- }
+ keyring2 = (CompressedEntry) l.get(0);
}
public void store(Map attributes) throws IOException
{
OutputStream out = (OutputStream) attributes.get(KEYRING_DATA_OUT);
if (out == null)
- {
- throw new IllegalArgumentException("no output stream");
- }
+ throw new IllegalArgumentException("no output stream");
char[] password = (char[]) attributes.get(KEYRING_PASSWORD);
if (password == null)
- {
- password = new char[0];
- }
+ password = new char[0];
if (keyring == null)
- {
- throw new IllegalStateException("empty keyring");
- }
+ throw new IllegalStateException("empty keyring");
out.write(Registry.GKR_MAGIC);
store(out, password);
@@ -131,45 +103,35 @@ public abstract class BaseKeyring implements IKeyring
public int size()
{
if (keyring == null)
- {
- throw new IllegalStateException ("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
return ((StringTokenizer) aliases()).countTokens();
}
public Enumeration aliases()
{
if (keyring == null)
- {
- throw new IllegalStateException ("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
return new StringTokenizer(keyring.getAliasList(), ";");
}
public boolean containsAlias(String alias)
{
if (keyring == null)
- {
- throw new IllegalStateException("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
return keyring.containsAlias(alias);
}
public List get(String alias)
{
if (keyring == null)
- {
- throw new IllegalStateException("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
return keyring.get(alias);
}
public void add(Entry entry)
{
if (keyring == null)
- {
- throw new IllegalStateException("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
if (keyring2 != null)
keyring2.add(entry);
else
@@ -179,9 +141,7 @@ public abstract class BaseKeyring implements IKeyring
public void remove(String alias)
{
if (keyring == null)
- {
- throw new IllegalStateException("keyring not loaded");
- }
+ throw new IllegalStateException("keyring not loaded");
keyring.remove(alias);
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/BinaryDataEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/BinaryDataEntry.java
index 2dcd5454fb6..e694487e141 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/BinaryDataEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/BinaryDataEntry.java
@@ -40,29 +40,22 @@ package gnu.javax.crypto.keyring;
import java.io.DataInputStream;
import java.io.IOException;
-
import java.util.Date;
/**
- * A binary data entry is a primitive entry that simply contains some amount
- * of arbitrary binary data and an optional content type.
+ * A binary data entry is a primitive entry that simply contains some amount of
+ * arbitrary binary data and an optional content type.
*/
-public class BinaryDataEntry extends PrimitiveEntry
+public class BinaryDataEntry
+ extends PrimitiveEntry
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
public static final int TYPE = 9;
- // Constructors.
- // ------------------------------------------------------------------------
-
/**
* Creates a new binary data entry.
- *
- * @param contentType The content type of this entry. This parameter can
- * be <code>null</code> if no content type is needed.
+ *
+ * @param contentType The content type of this entry. This parameter can be
+ * <code>null</code> if no content type is needed.
* @param data The data.
* @param creationDate The creation date.
* @param properties This entry's properties.
@@ -72,14 +65,10 @@ public class BinaryDataEntry extends PrimitiveEntry
{
super(TYPE, creationDate, properties);
if (data == null)
- {
- throw new IllegalArgumentException("no data");
- }
+ throw new IllegalArgumentException("no data");
payload = (byte[]) data.clone();
if (contentType != null)
- {
- this.properties.put("content-type", contentType);
- }
+ this.properties.put("content-type", contentType);
}
private BinaryDataEntry()
@@ -87,9 +76,6 @@ public class BinaryDataEntry extends PrimitiveEntry
super(TYPE);
}
- // Class methods.
- // ------------------------------------------------------------------------
-
public static BinaryDataEntry decode(DataInputStream in) throws IOException
{
BinaryDataEntry entry = new BinaryDataEntry();
@@ -97,13 +83,10 @@ public class BinaryDataEntry extends PrimitiveEntry
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Returns the content type of this entry, or <code>null</code> if this
* property is not set.
- *
+ *
* @return The content type.
*/
public String getContentType()
@@ -113,7 +96,7 @@ public class BinaryDataEntry extends PrimitiveEntry
/**
* Returns this object's data field.
- *
+ *
* @return The data.
*/
public byte[] getData()
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/CertPathEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/CertPathEntry.java
index ef62347ec9d..32b86084f31 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/CertPathEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/CertPathEntry.java
@@ -40,40 +40,28 @@ package gnu.javax.crypto.keyring;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
-
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
-
import java.util.Date;
/**
* A primitive entry that contains a path of X.509 certificates.
*/
-public final class CertPathEntry extends PrimitiveEntry
+public final class CertPathEntry
+ extends PrimitiveEntry
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
public static final int TYPE = 8;
-
private Certificate[] path;
- // Constructor.
- // ------------------------------------------------------------------------
-
public CertPathEntry(Certificate[] path, Date creationDate,
Properties properties)
{
super(TYPE, creationDate, properties);
if (path == null || path.length == 0)
- {
- throw new IllegalArgumentException("no certificate path");
- }
+ throw new IllegalArgumentException("no certificate path");
this.path = (Certificate[]) path.clone();
}
@@ -82,9 +70,6 @@ public final class CertPathEntry extends PrimitiveEntry
super(TYPE);
}
- // Class method.
- // ------------------------------------------------------------------------
-
public static CertPathEntry decode(DataInputStream in) throws IOException
{
CertPathEntry entry = new CertPathEntry();
@@ -95,8 +80,7 @@ public final class CertPathEntry extends PrimitiveEntry
try
{
CertificateFactory fact = CertificateFactory.getInstance("X.509");
- entry.path = (Certificate[]) fact.generateCertificates(in2).toArray(
- new Certificate[0]);
+ entry.path = (Certificate[]) fact.generateCertificates(in2).toArray(new Certificate[0]);
}
catch (CertificateException ce)
{
@@ -105,9 +89,6 @@ public final class CertPathEntry extends PrimitiveEntry
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public Certificate[] getCertPath()
{
return path;
@@ -120,9 +101,7 @@ public final class CertPathEntry extends PrimitiveEntry
try
{
for (int i = 0; i < path.length; i++)
- {
- bout.write(path[i].getEncoded());
- }
+ bout.write(path[i].getEncoded());
}
catch (CertificateEncodingException cee)
{
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/CertificateEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/CertificateEntry.java
index 95a708ac53f..661758442cc 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/CertificateEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/CertificateEntry.java
@@ -39,50 +39,38 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
import java.util.Date;
/**
- * <p>An immutable class representing a trusted certificate entry.</p>
+ * An immutable class representing a trusted certificate entry.
*/
-public final class CertificateEntry extends PrimitiveEntry
+public final class CertificateEntry
+ extends PrimitiveEntry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final int TYPE = 5;
-
/** The certificate. */
private Certificate certificate;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
* Creates a new certificate entry.
- *
+ *
* @param certificate The certificate.
* @param creationDate The creation date.
* @param properties The alias.
* @throws IllegalArgumentException If any argument is null, or if the alias
- * is empty.
+ * is empty.
*/
public CertificateEntry(Certificate certificate, Date creationDate,
Properties properties)
{
super(TYPE, creationDate, properties);
-
if (certificate == null)
- {
- throw new IllegalArgumentException("no certificate");
- }
+ throw new IllegalArgumentException("no certificate");
this.certificate = certificate;
this.properties.put("type", certificate.getType());
}
@@ -92,9 +80,6 @@ public final class CertificateEntry extends PrimitiveEntry
super(TYPE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static CertificateEntry decode(DataInputStream in) throws IOException
{
CertificateEntry entry = new CertificateEntry();
@@ -102,9 +87,7 @@ public final class CertificateEntry extends PrimitiveEntry
entry.makeCreationDate();
String type = entry.properties.get("type");
if (type == null)
- {
- throw new MalformedKeyringException("no certificate type");
- }
+ throw new MalformedKeyringException("no certificate type");
int len = in.readInt();
MeteredInputStream in2 = new MeteredInputStream(in, len);
try
@@ -116,19 +99,14 @@ public final class CertificateEntry extends PrimitiveEntry
{
throw new MalformedKeyringException(ce.toString());
}
- if (!in2.limitReached())
- {
- throw new MalformedKeyringException("extra data at end of payload");
- }
+ if (! in2.limitReached())
+ throw new MalformedKeyringException("extra data at end of payload");
return entry;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
* Returns this entry's certificate.
- *
+ *
* @return The certificate.
*/
public Certificate getCertificate()
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/CompressedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/CompressedEntry.java
index cce930d739d..b24c6715ab7 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/CompressedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/CompressedEntry.java
@@ -42,22 +42,15 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
import java.util.Iterator;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
-public class CompressedEntry extends EnvelopeEntry
+public class CompressedEntry
+ extends EnvelopeEntry
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
public static final int TYPE = 4;
- // Constructor.
- // ------------------------------------------------------------------------
-
public CompressedEntry(Properties properties)
{
super(TYPE, properties);
@@ -69,24 +62,16 @@ public class CompressedEntry extends EnvelopeEntry
this(new Properties());
}
- // Class methods.
- // ------------------------------------------------------------------------
-
public static CompressedEntry decode(DataInputStream in) throws IOException
{
CompressedEntry entry = new CompressedEntry();
entry.properties.decode(in);
String alg = entry.properties.get("algorithm");
if (alg == null)
- {
- throw new MalformedKeyringException("no compression algorithm");
- }
- if (!alg.equalsIgnoreCase("DEFLATE"))
- {
- throw new MalformedKeyringException(
- "unsupported compression algorithm: "
- + alg);
- }
+ throw new MalformedKeyringException("no compression algorithm");
+ if (! alg.equalsIgnoreCase("DEFLATE"))
+ throw new MalformedKeyringException("unsupported compression algorithm: "
+ + alg);
int len = in.readInt();
MeteredInputStream min = new MeteredInputStream(in, len);
InflaterInputStream infin = new InflaterInputStream(min);
@@ -95,18 +80,13 @@ public class CompressedEntry extends EnvelopeEntry
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
protected void encodePayload() throws IOException
{
ByteArrayOutputStream buf = new ByteArrayOutputStream(1024);
DeflaterOutputStream dout = new DeflaterOutputStream(buf);
DataOutputStream out2 = new DataOutputStream(dout);
for (Iterator it = entries.iterator(); it.hasNext();)
- {
- ((Entry) it.next()).encode(out2);
- }
+ ((Entry) it.next()).encode(out2);
dout.finish();
payload = buf.toByteArray();
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/EncryptedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/EncryptedEntry.java
index fad5f54b236..f0693cc91d2 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/EncryptedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/EncryptedEntry.java
@@ -38,21 +38,6 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import java.security.InvalidKeyException;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.List;
-
import gnu.java.security.Registry;
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
@@ -62,25 +47,24 @@ import gnu.javax.crypto.pad.IPad;
import gnu.javax.crypto.pad.PadFactory;
import gnu.javax.crypto.pad.WrongPaddingException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.util.HashMap;
+import java.util.Iterator;
+
public class EncryptedEntry extends MaskableEnvelopeEntry implements Registry
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
public static final int TYPE = 0;
- // Constructor.
- // ------------------------------------------------------------------------
-
public EncryptedEntry(String cipher, String mode, Properties properties)
{
super(TYPE, properties);
if (cipher == null || mode == null)
- {
- throw new IllegalArgumentException(
- "neither cipher nor mode can be null");
- }
+ throw new IllegalArgumentException("neither cipher nor mode can be null");
properties.put("cipher", cipher);
properties.put("mode", mode);
setMasked(false);
@@ -92,34 +76,22 @@ public class EncryptedEntry extends MaskableEnvelopeEntry implements Registry
setMasked(true);
}
- // Class methods.
- // ------------------------------------------------------------------------
-
public static EncryptedEntry decode(DataInputStream in) throws IOException
{
EncryptedEntry entry = new EncryptedEntry();
entry.defaultDecode(in);
- if (!entry.properties.containsKey("cipher"))
- {
- throw new MalformedKeyringException("no cipher");
- }
- if (!entry.properties.containsKey("cipher"))
- {
- throw new MalformedKeyringException("no cipher");
- }
+ if (! entry.properties.containsKey("cipher"))
+ throw new MalformedKeyringException("no cipher");
+ if (! entry.properties.containsKey("cipher"))
+ throw new MalformedKeyringException("no cipher");
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public void decrypt(byte[] key, byte[] iv) throws IllegalArgumentException,
WrongPaddingException
{
- if (!isMasked() || payload == null)
- {
- return;
- }
+ if (! isMasked() || payload == null)
+ return;
IMode mode = getMode(key, iv, IMode.DECRYPTION);
IPad padding = null;
padding = PadFactory.getInstance("PKCS7");
@@ -132,12 +104,8 @@ public class EncryptedEntry extends MaskableEnvelopeEntry implements Registry
count += mode.currentBlockSize();
}
int padlen = padding.unpad(buf, 0, buf.length);
- DataInputStream in = new DataInputStream(
- new ByteArrayInputStream(
- buf,
- 0,
- buf.length
- - padlen));
+ int len = buf.length - padlen;
+ DataInputStream in = new DataInputStream(new ByteArrayInputStream(buf, 0, len));
try
{
decodeEnvelope(in);
@@ -181,22 +149,14 @@ public class EncryptedEntry extends MaskableEnvelopeEntry implements Registry
public void encodePayload() throws IOException
{
if (payload == null)
- {
- throw new IOException("not encrypted");
- }
+ throw new IOException("not encrypted");
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private IMode getMode(byte[] key, byte[] iv, int state)
{
IBlockCipher cipher = CipherFactory.getInstance(properties.get("cipher"));
if (cipher == null)
- {
- throw new IllegalArgumentException("no such cipher: "
- + properties.get("cipher"));
- }
+ throw new IllegalArgumentException("no such cipher: " + properties.get("cipher"));
int blockSize = cipher.defaultBlockSize();
if (properties.containsKey("block-size"))
{
@@ -210,17 +170,13 @@ public class EncryptedEntry extends MaskableEnvelopeEntry implements Registry
+ nfe.getMessage());
}
}
- IMode mode = ModeFactory.getInstance(properties.get("mode"), cipher,
- blockSize);
+ IMode mode = ModeFactory.getInstance(properties.get("mode"), cipher, blockSize);
if (mode == null)
- {
- throw new IllegalArgumentException("no such mode: "
- + properties.get("mode"));
- }
+ throw new IllegalArgumentException("no such mode: " + properties.get("mode"));
HashMap modeAttr = new HashMap();
modeAttr.put(IMode.KEY_MATERIAL, key);
- modeAttr.put(IMode.STATE, new Integer(state));
+ modeAttr.put(IMode.STATE, Integer.valueOf(state));
modeAttr.put(IMode.IV, iv);
try
{
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/Entry.java b/libjava/classpath/gnu/javax/crypto/keyring/Entry.java
index fa7f496798b..ef225db95e6 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/Entry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/Entry.java
@@ -38,49 +38,51 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.logging.Logger;
/**
* An immutable class representing a single entry in a keyring.
*/
public abstract class Entry
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(Entry.class.getName());
+ private static final String[] TYPES = new String[] {
+ "Encrypted",
+ "PasswordEncrypted",
+ "Authenticated",
+ "PasswordAuthenticated",
+ "Compressed",
+ "Certificate",
+ "PublicKey",
+ "PrivateKey",
+ "CertPath",
+ "BinaryData" };
/** This entry's type identifier. */
protected int type;
-
/** This entry's property set. */
protected Properties properties;
-
/** This entry's payload. */
protected byte[] payload;
- // Constructor.
- // ------------------------------------------------------------------------
-
/**
* Creates a new Entry.
- *
+ *
* @param type This entry's type.
* @param properties This entry's properties.
- * @throws IllegalArgumentException If the properties argument is null,
- * or if the type is out of range.
+ * @throws IllegalArgumentException If the properties argument is null, or if
+ * the type is out of range.
*/
protected Entry(int type, Properties properties)
{
if (type < 0 || type > 255)
- {
- throw new IllegalArgumentException("invalid packet type");
- }
+ throw new IllegalArgumentException("invalid packet type");
if (properties == null)
- {
- throw new IllegalArgumentException("no properties");
- }
+ throw new IllegalArgumentException("no properties");
this.type = type;
this.properties = (Properties) properties.clone();
}
@@ -91,20 +93,15 @@ public abstract class Entry
protected Entry(final int type)
{
if (type < 0 || type > 255)
- {
- throw new IllegalArgumentException("invalid packet type");
- }
+ throw new IllegalArgumentException("invalid packet type");
this.type = type;
properties = new Properties();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Returns this entry's properties object. The properties are cloned before
* being returned.
- *
+ *
* @return The properties.
*/
public Properties getProperties()
@@ -123,28 +120,35 @@ public abstract class Entry
}
/**
- * This method is called when this entry needs to be written to an
- * output stream.
- *
+ * This method is called when this entry needs to be written to an output
+ * stream.
+ *
* @param out The stream to write to.
* @throws IOException If an I/O exception occurs.
*/
public void encode(DataOutputStream out) throws IOException
{
if (payload == null)
- {
- encodePayload();
- }
+ encodePayload();
if (out == null)
- {
- return;
- }
+ return;
out.write(type);
properties.encode(out);
out.writeInt(payload.length);
out.write(payload);
}
+ public String toString()
+ {
+ return new StringBuilder("Entry{")
+ .append("type=").append(TYPES[type])
+ .append(", properties=").append(properties)
+ .append(", payload=")
+ .append(payload == null ? "-" : "byte[" + payload.length + "]")
+ .append( "}")
+ .toString();
+ }
+
/**
* Generic decoding method, which simply decodes the properties field
* and reads the payload field.
@@ -158,16 +162,13 @@ public abstract class Entry
properties.decode(in);
int len = in.readInt();
if (len < 0)
- {
- throw new IOException("corrupt length");
- }
+ throw new IOException("corrupt length");
+ if (Configuration.DEBUG)
+ log.fine("About to instantiate new payload byte array for " + this);
payload = new byte[len];
in.readFully(payload);
}
- // Abstract methods.
- // ------------------------------------------------------------------------
-
/**
* This method is called of subclasses when the payload data needs to be
* created.
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java
index 25b1dc2a04d..fe39091b05c 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java
@@ -38,45 +38,38 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
+
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
+import java.util.logging.Logger;
/**
- * An envelope entry is a generic container for some number of primitive
- * and other envelope entries.
+ * An envelope entry is a generic container for some number of primitive and
+ * other envelope entries.
*/
-public abstract class EnvelopeEntry extends Entry
+public abstract class EnvelopeEntry
+ extends Entry
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(EnvelopeEntry.class.getName());
/** The envelope that contains this one (if any). */
protected EnvelopeEntry containingEnvelope;
-
/** The contained entries. */
protected List entries;
- // Constructor.
- // ------------------------------------------------------------------------
-
public EnvelopeEntry(int type, Properties properties)
{
super(type, properties);
entries = new LinkedList();
if (this.properties.get("alias-list") != null)
- {
- this.properties.remove("alias-list");
- }
+ this.properties.remove("alias-list");
}
protected EnvelopeEntry(int type)
@@ -85,84 +78,85 @@ public abstract class EnvelopeEntry extends Entry
entries = new LinkedList();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Adds an entry to this envelope.
- *
+ *
* @param entry The entry to add.
*/
public void add(Entry entry)
{
- if (!containsEntry(entry))
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "add", entry);
+ if (! containsEntry(entry))
{
if (entry instanceof EnvelopeEntry)
- {
- ((EnvelopeEntry) entry).setContainingEnvelope(this);
- }
+ ((EnvelopeEntry) entry).setContainingEnvelope(this);
entries.add(entry);
- payload = null;
+ if (Configuration.DEBUG)
+ log.fine("Payload is " + (payload == null ? "" : "not ") + "null");
makeAliasList();
}
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "add");
}
/**
- * Tests if this envelope contains a primitive entry with the
- * given alias.
- *
+ * Tests if this envelope contains a primitive entry with the given alias.
+ *
* @param alias The alias to test.
- * @return True if this envelope (or one of the contained envelopes)
- * contains a primitive entry with the given alias.
+ * @return True if this envelope (or one of the contained envelopes) contains
+ * a primitive entry with the given alias.
*/
public boolean containsAlias(String alias)
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "containsAlias", alias);
String aliases = getAliasList();
- if (aliases == null)
+ if (Configuration.DEBUG)
+ log.fine("aliases = [" + aliases + "]");
+ boolean result = false;
+ if (aliases != null)
{
- return false;
+ StringTokenizer tok = new StringTokenizer(aliases, ";");
+ while (tok.hasMoreTokens())
+ if (tok.nextToken().equals(alias))
+ {
+ result = true;
+ break;
+ }
}
- StringTokenizer tok = new StringTokenizer(aliases, ";");
- while (tok.hasMoreTokens())
- {
- if (tok.nextToken().equals(alias))
- {
- return true;
- }
- }
- return false;
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "containsAlias",
+ Boolean.valueOf(result));
+ return result;
}
/**
* Tests if this envelope contains the given entry.
- *
+ *
* @param entry The entry to test.
* @return True if this envelope contains the given entry.
*/
public boolean containsEntry(Entry entry)
{
if (entry instanceof EnvelopeEntry)
- {
- return entries.contains(entry);
- }
- else if (entry instanceof PrimitiveEntry)
- {
- for (Iterator it = entries.iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e.equals(entry))
- return true;
- if ((e instanceof EnvelopeEntry)
- && ((EnvelopeEntry) e).containsEntry(entry))
- return true;
- }
- }
+ return entries.contains(entry);
+ if (entry instanceof PrimitiveEntry)
+ for (Iterator it = entries.iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e.equals(entry))
+ return true;
+ if ((e instanceof EnvelopeEntry)
+ && ((EnvelopeEntry) e).containsEntry(entry))
+ return true;
+ }
return false;
}
/**
* Returns a copy of all entries this envelope contains.
- *
+ *
* @return All contained entries.
*/
public List getEntries()
@@ -171,73 +165,77 @@ public abstract class EnvelopeEntry extends Entry
}
/**
- * Gets all primitive entries that have the given alias. If there
- * are any masked entries that contain the given alias, they will
- * be returned as well.
- *
+ * Gets all primitive entries that have the given alias. If there are any
+ * masked entries that contain the given alias, they will be returned as well.
+ *
* @param alias The alias of the entries to get.
* @return A list of all primitive entries that have the given alias.
*/
public List get(String alias)
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "get", alias);
List result = new LinkedList();
for (Iterator it = entries.iterator(); it.hasNext();)
{
Entry e = (Entry) it.next();
if (e instanceof EnvelopeEntry)
{
- if (!((EnvelopeEntry) e).containsAlias(alias))
- {
- continue;
- }
- if (e instanceof MaskableEnvelopeEntry)
+ EnvelopeEntry ee = (EnvelopeEntry) e;
+ if (! ee.containsAlias(alias))
+ continue;
+ if (ee instanceof MaskableEnvelopeEntry)
{
- if (((MaskableEnvelopeEntry) e).isMasked())
+ MaskableEnvelopeEntry mee = (MaskableEnvelopeEntry) ee;
+ if (mee.isMasked())
{
- result.add(e);
+ if (Configuration.DEBUG)
+ log.fine("Processing masked entry: " + mee);
+ result.add(mee);
continue;
}
}
- result.addAll(((EnvelopeEntry) e).get(alias));
+ if (Configuration.DEBUG)
+ log.fine("Processing unmasked entry: " + ee);
+ result.addAll(ee.get(alias));
}
else if (e instanceof PrimitiveEntry)
{
- if (((PrimitiveEntry) e).getAlias().equals(alias))
- {
- result.add(e);
- }
+ PrimitiveEntry pe = (PrimitiveEntry) e;
+ if (pe.getAlias().equals(alias))
+ result.add(e);
}
}
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "get", result);
return result;
}
/**
- * Returns the list of all aliases contained by this envelope,
- * separated by a semicolon (';').
- *
+ * Returns the list of all aliases contained by this envelope, separated by a
+ * semicolon (';').
+ *
* @return The list of aliases.
*/
public String getAliasList()
{
String list = properties.get("alias-list");
if (list == null)
- {
- return "";
- }
+ return "";
else
- {
- return list;
- }
+ return list;
}
/**
* Removes the specified entry.
- *
+ *
* @param entry The entry.
* @return True if an entry was removed.
*/
public boolean remove(Entry entry)
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "remove", entry);
boolean ret = false;
for (Iterator it = entries.iterator(); it.hasNext();)
{
@@ -268,36 +266,71 @@ public abstract class EnvelopeEntry extends Entry
}
if (ret)
{
+ if (Configuration.DEBUG)
+ log.fine("State before: " + this);
payload = null;
makeAliasList();
+ if (Configuration.DEBUG)
+ log.fine("State after: " + this);
}
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "remove", Boolean.valueOf(ret));
return ret;
}
/**
* Removes all primitive entries that have the specified alias.
- *
+ *
* @param alias The alias of the entries to remove.
+ * @return <code>true</code> if <code>alias</code> was present and was
+ * successfully trmoved. Returns <code>false</code> if
+ * <code>alias</code> was not present in the list of aliases in this
+ * envelope.
*/
- public void remove(String alias)
+ public boolean remove(String alias)
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "remove", alias);
+ boolean result = false;
for (Iterator it = entries.iterator(); it.hasNext();)
{
Entry e = (Entry) it.next();
if (e instanceof EnvelopeEntry)
{
- ((EnvelopeEntry) e).remove(alias);
+ EnvelopeEntry ee = (EnvelopeEntry) e;
+ result = ee.remove(alias) || result;
}
else if (e instanceof PrimitiveEntry)
{
- if (((PrimitiveEntry) e).getAlias().equals(alias))
+ PrimitiveEntry pe = (PrimitiveEntry) e;
+ if (pe.getAlias().equals(alias))
{
it.remove();
+ result = true;
}
}
}
- payload = null;
- makeAliasList();
+ if (result)
+ {
+ if (Configuration.DEBUG)
+ log.fine("State before: " + this);
+ payload = null;
+ makeAliasList();
+ if (Configuration.DEBUG)
+ log.fine("State after: " + this);
+ }
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "remove", Boolean.valueOf(result));
+ return result;
+ }
+
+ public String toString()
+ {
+ return new StringBuilder("Envelope{")
+ .append(super.toString())
+ .append(", entries=").append(entries)
+ .append("}")
+ .toString();
}
// Protected methods.
@@ -308,22 +341,19 @@ public abstract class EnvelopeEntry extends Entry
ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
DataOutputStream out = new DataOutputStream(bout);
for (Iterator it = entries.iterator(); it.hasNext();)
- {
- ((Entry) it.next()).encode(out);
- }
+ ((Entry) it.next()).encode(out);
}
protected void setContainingEnvelope(EnvelopeEntry e)
{
if (containingEnvelope != null)
- {
- throw new IllegalArgumentException("envelopes may not be shared");
- }
+ throw new IllegalArgumentException("envelopes may not be shared");
containingEnvelope = e;
}
protected void decodeEnvelope(DataInputStream in) throws IOException
{
+ this.entries.clear();
while (true)
{
int type = in.read();
@@ -367,32 +397,43 @@ public abstract class EnvelopeEntry extends Entry
}
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private void makeAliasList()
{
- if (entries.isEmpty())
- return;
- StringBuffer buf = new StringBuffer();
- for (Iterator it = entries.iterator(); it.hasNext();)
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "makeAliasList");
+ if (! entries.isEmpty())
{
- Entry entry = (Entry) it.next();
- if (entry instanceof EnvelopeEntry)
- {
- buf.append(((EnvelopeEntry) entry).getAliasList());
- }
- else if (entry instanceof PrimitiveEntry)
+ StringBuilder buf = new StringBuilder();
+ String aliasOrList;
+ for (Iterator it = entries.iterator(); it.hasNext();)
{
- buf.append(((PrimitiveEntry) entry).getAlias());
+ Entry entry = (Entry) it.next();
+ aliasOrList = null;
+ if (entry instanceof EnvelopeEntry)
+ aliasOrList = ((EnvelopeEntry) entry).getAliasList();
+ else if (entry instanceof PrimitiveEntry)
+ aliasOrList = ((PrimitiveEntry) entry).getAlias();
+ else if (Configuration.DEBUG)
+ log.fine("Entry with no Alias. Ignored: " + entry);
+ if (aliasOrList != null)
+ {
+ aliasOrList = aliasOrList.trim();
+ if (aliasOrList.trim().length() > 0)
+ {
+ buf.append(aliasOrList);
+ if (it.hasNext())
+ buf.append(';');
+ }
+ }
}
- if (it.hasNext())
- buf.append(';');
- }
- properties.put("alias-list", buf.toString());
- if (containingEnvelope != null)
- {
- containingEnvelope.makeAliasList();
+ String aliasList = buf.toString();
+ properties.put("alias-list", aliasList);
+ if (Configuration.DEBUG)
+ log.fine("alias-list=[" + aliasList + "]");
+ if (containingEnvelope != null)
+ containingEnvelope.makeAliasList();
}
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "makeAliasList");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
index c1fe30e677b..2ccdad6b3e3 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import java.io.DataInputStream;
@@ -55,30 +56,21 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * <p>.</p>
+ *
*/
-public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
+public class GnuPrivateKeyring
+ extends BaseKeyring
+ implements IPrivateKeyring
{
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final Logger log = Logger.getLogger(GnuPrivateKeyring.class.getName());
public static final int USAGE = Registry.GKR_PRIVATE_KEYS
| Registry.GKR_PUBLIC_CREDENTIALS;
-
protected String mac;
-
protected int maclen;
-
protected String cipher;
-
protected String mode;
-
protected int keylen;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public GnuPrivateKeyring(String mac, int maclen, String cipher, String mode,
int keylen)
{
@@ -97,16 +89,10 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
this("HMAC-SHA-1", 20, "AES", "OFB", 16);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public boolean containsPrivateKey(String alias)
{
- log.entering(this.getClass().getName(), "containsPrivateKey", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "containsPrivateKey", alias);
boolean result = false;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -115,33 +101,34 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
result = true;
break;
}
-
- log.exiting(this.getClass().getName(), "containsPrivateKey",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "containsPrivateKey",
+ Boolean.valueOf(result));
return result;
}
public Key getPrivateKey(String alias, char[] password)
throws UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "getPrivateKey",
- new Object[] { alias, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getPrivateKey", alias);
Key result = null;
if (containsAlias(alias))
{
PasswordAuthenticatedEntry e1 = null;
- PasswordEncryptedEntry e2 = null;
for (Iterator it = get(alias).iterator(); it.hasNext();)
{
Entry e = (Entry) it.next();
+ if (Configuration.DEBUG)
+ log.finest("Entry: " + e);
if (e instanceof PasswordAuthenticatedEntry)
{
e1 = (PasswordAuthenticatedEntry) e;
break;
}
}
-
+ if (Configuration.DEBUG)
+ log.fine("e1 = " + e1);
if (e1 != null)
{
try
@@ -150,9 +137,11 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
}
catch (Exception e)
{
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "getPrivateKey", e);
throw new UnrecoverableKeyException("authentication failed");
}
-
+ PasswordEncryptedEntry e2 = null;
for (Iterator it = e1.getEntries().iterator(); it.hasNext();)
{
Entry e = (Entry) it.next();
@@ -162,7 +151,6 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
break;
}
}
-
if (e2 != null)
{
try
@@ -171,9 +159,9 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
}
catch (Exception e)
{
+ log.throwing(this.getClass().getName(), "getPrivateKey", e);
throw new UnrecoverableKeyException("decryption failed");
}
-
for (Iterator it = e2.get(alias).iterator(); it.hasNext();)
{
Entry e = (Entry) it.next();
@@ -186,66 +174,67 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
}
}
}
-
- log.exiting(this.getClass().getName(), "getPrivateKey", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getPrivateKey",
+ result == null ? "null" : result.getClass().getName());
return result;
}
public void putPrivateKey(String alias, Key key, char[] password)
{
- log.entering(this.getClass().getName(), "putPrivateKey",
- new Object[] { alias, key, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "putPrivateKey",
+ new Object[] { alias, key.getClass().getName() });
if (! containsPrivateKey(alias))
{
alias = fixAlias(alias);
Properties p = new Properties();
p.put("alias", alias);
PrivateKeyEntry pke = new PrivateKeyEntry(key, new Date(), p);
+ if (Configuration.DEBUG)
+ log.fine("About to encrypt the key...");
PasswordEncryptedEntry enc;
enc = new PasswordEncryptedEntry(cipher, mode, keylen, new Properties());
enc.add(pke);
-
- PasswordAuthenticatedEntry auth;
- auth = new PasswordAuthenticatedEntry(mac, maclen, new Properties());
- auth.add(enc);
-
- log.finest("About to encrypt the key...");
try
{
enc.encode(null, password);
}
catch (IOException x)
{
- log.log(Level.FINER, "Exception while encrypting the key. "
- + "Rethrow as IllegalArgumentException", x);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception while encrypting the key. "
+ + "Rethrow as IllegalArgumentException", x);
throw new IllegalArgumentException(x.toString());
}
-
- log.finest("About to authenticate the encrypted key...");
+ if (Configuration.DEBUG)
+ log.fine("About to authenticate the encrypted key...");
+ PasswordAuthenticatedEntry auth;
+ auth = new PasswordAuthenticatedEntry(mac, maclen, new Properties());
+ auth.add(enc);
try
{
auth.encode(null, password);
}
catch (IOException x)
{
- log.log(Level.FINER, "Exception while authenticating the encrypted "
- + "key. Rethrow as IllegalArgumentException", x);
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception while authenticating the encrypted "
+ + "key. Rethrow as IllegalArgumentException", x);
throw new IllegalArgumentException(x.toString());
}
-
keyring.add(auth);
}
- else
- log.finer("Keyring already contains alias: " + alias);
-
- log.exiting(this.getClass().getName(), "putPrivateKey");
+ else if (Configuration.DEBUG)
+ log.fine("Keyring already contains alias: " + alias);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "putPrivateKey");
}
public boolean containsPublicKey(String alias)
{
- log.entering(this.getClass().getName(), "containsPublicKey", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "containsPublicKey", alias);
boolean result = false;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -254,16 +243,16 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
result = true;
break;
}
-
- log.exiting(this.getClass().getName(), "containsPublicKey",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "containsPublicKey",
+ Boolean.valueOf(result));
return result;
}
public PublicKey getPublicKey(String alias)
{
- log.entering(this.getClass().getName(), "getPublicKey", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getPublicKey", alias);
PublicKey result = null;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -275,32 +264,33 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
break;
}
}
-
- log.exiting(this.getClass().getName(), "getPublicKey", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getPublicKey",
+ result == null ? "null" : result.getClass().getName());
return result;
}
public void putPublicKey(String alias, PublicKey key)
{
- log.entering(this.getClass().getName(), "putPublicKey",
- new Object[] { alias, key });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "putPublicKey",
+ new Object[] { alias, key.getClass().getName() });
if (! containsPublicKey(alias))
{
Properties p = new Properties();
p.put("alias", fixAlias(alias));
add(new PublicKeyEntry(key, new Date(), p));
}
- else
- log.finer("Keyring already contains alias: " + alias);
-
- log.exiting(this.getClass().getName(), "putPublicKey");
+ else if (Configuration.DEBUG)
+ log.fine("Keyring already contains alias: " + alias);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "putPublicKey");
}
public boolean containsCertPath(String alias)
{
- log.entering(this.getClass().getName(), "containsCertPath", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "containsCertPath", alias);
boolean result = false;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -309,16 +299,16 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
result = true;
break;
}
-
- log.exiting(this.getClass().getName(), "containsCertPath",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "containsCertPath",
+ Boolean.valueOf(result));
return result;
}
public Certificate[] getCertPath(String alias)
{
- log.entering(this.getClass().getName(), "getCertPath", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getCertPath", alias);
Certificate[] result = null;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -330,52 +320,49 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
break;
}
}
-
- log.exiting(this.getClass().getName(), "getCertPath", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getCertPath", result);
return result;
}
public void putCertPath(String alias, Certificate[] path)
{
- log.entering(this.getClass().getName(), "putCertPath",
- new Object[] { alias, path });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "putCertPath",
+ new Object[] { alias, path });
if (! containsCertPath(alias))
{
Properties p = new Properties();
p.put("alias", fixAlias(alias));
add(new CertPathEntry(path, new Date(), p));
}
- else
- log.finer("Keyring already contains alias: " + alias);
-
- log.exiting(this.getClass().getName(), "putCertPath");
+ else if (Configuration.DEBUG)
+ log.fine("Keyring already contains alias: " + alias);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "putCertPath");
}
protected void load(InputStream in, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "load",
- new Object[] { in, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "load");
if (in.read() != USAGE)
throw new MalformedKeyringException("incompatible keyring usage");
-
if (in.read() != PasswordAuthenticatedEntry.TYPE)
- throw new MalformedKeyringException("expecting password-authenticated entry tag");
-
+ throw new MalformedKeyringException(
+ "expecting password-authenticated entry tag");
keyring = PasswordAuthenticatedEntry.decode(new DataInputStream(in), password);
-
- log.exiting(this.getClass().getName(), "load");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "load");
}
protected void store(OutputStream out, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "store",
- new Object[] { out, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "store");
out.write(USAGE);
keyring.encode(new DataOutputStream(out), password);
-
- log.exiting(this.getClass().getName(), "store");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "store");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
index 490eb4458fa..5243919c3c9 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import java.io.DataInputStream;
@@ -50,17 +51,13 @@ import java.util.Date;
import java.util.Iterator;
import java.util.logging.Logger;
-public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
+public class GnuPublicKeyring
+ extends BaseKeyring
+ implements IPublicKeyring
{
- // Fields.
- // ------------------------------------------------------------------------
-
private static final Logger log = Logger.getLogger(GnuPublicKeyring.class.getName());
public static final int USAGE = Registry.GKR_CERTIFICATES;
- // Constructors.
- // ------------------------------------------------------------------------
-
public GnuPublicKeyring(String mac, int macLen)
{
keyring = new PasswordAuthenticatedEntry(mac, macLen, new Properties());
@@ -72,13 +69,10 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
{
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public boolean containsCertificate(String alias)
{
- log.entering(this.getClass().getName(), "containsCertificate", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "containsCertificate", alias);
boolean result = false;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -87,16 +81,16 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
result = true;
break;
}
-
- log.exiting(this.getClass().getName(), "containsCertificate",
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "containsCertificate",
+ Boolean.valueOf(result));
return result;
}
public Certificate getCertificate(String alias)
{
- log.entering(this.getClass().getName(), "getCertificate", alias);
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getCertificate", alias);
Certificate result = null;
if (containsAlias(alias))
for (Iterator it = get(alias).iterator(); it.hasNext();)
@@ -108,53 +102,50 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
break;
}
}
-
- log.exiting(this.getClass().getName(), "getCertificate", result);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getCertificate", result);
return result;
}
public void putCertificate(String alias, Certificate cert)
{
- log.entering(this.getClass().getName(), "putCertificate",
- new Object[] { alias, cert });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "putCertificate",
+ new Object[] { alias, cert });
if (! containsCertificate(alias))
{
Properties p = new Properties();
p.put("alias", fixAlias(alias));
add(new CertificateEntry(cert, new Date(), p));
}
- else
- log.finer("Keyring already contains alias: " + alias);
-
- log.exiting(this.getClass().getName(), "putCertificate");
+ else if (Configuration.DEBUG)
+ log.fine("Keyring already contains alias: " + alias);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "putCertificate");
}
protected void load(InputStream in, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "load",
- new Object[] { in, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "load");
if (in.read() != USAGE)
throw new MalformedKeyringException("incompatible keyring usage");
-
if (in.read() != PasswordAuthenticatedEntry.TYPE)
- throw new MalformedKeyringException("expecting password-authenticated entry tag");
-
+ throw new MalformedKeyringException(
+ "expecting password-authenticated entry tag");
DataInputStream dis = new DataInputStream(in);
keyring = PasswordAuthenticatedEntry.decode(dis, password);
-
- log.exiting(this.getClass().getName(), "load");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "load");
}
protected void store(OutputStream out, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "store",
- new Object[] { out, String.valueOf(password) });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "store");
out.write(USAGE);
keyring.encode(new DataOutputStream(out), password);
-
- log.exiting(this.getClass().getName(), "store");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "store");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/IKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/IKeyring.java
index 56f467df26e..44d5377008a 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/IKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/IKeyring.java
@@ -44,120 +44,118 @@ import java.util.List;
import java.util.Map;
/**
- * <p>The top-level interface to a <i>keyring:</i> a file that is used to
- * store and protect public and private cryptographic keys.</p>
- *
- * <p>A <i>keyring</i> is modelled as a mapping of one <i>alias</i> to one or
- * more <i>entries</i> (optionally of different types).</p>
- *
- * <p>See also the sub-interfaces {@link IPublicKeyring} and
- * {@link IPrivateKeyring} for special types of <i>keyrings</i> --the difference
- * being in the type of entries they contain.</p>
+ * The top-level interface to a <i>keyring:</i> a file that is used to store
+ * and protect public and private cryptographic keys.
+ * <p>
+ * A <i>keyring</i> is modelled as a mapping of one <i>alias</i> to one or
+ * more <i>entries</i> (optionally of different types).
+ * <p>
+ * See also the sub-interfaces {@link IPublicKeyring} and
+ * {@link IPrivateKeyring} for special types of <i>keyrings</i> --the
+ * difference being in the type of entries they contain.
*/
public interface IKeyring
{
-
/**
- * <p>Property name for the source of data to load the keyring from. The
- * value mapped must be a {@link java.io.InputStream}.</p>
+ * Property name for the source of data to load the keyring from. The value
+ * mapped must be a {@link java.io.InputStream}.
*/
public static final String KEYRING_DATA_IN = "gnu.crypto.keyring.data.in";
/**
- * <p>Property name for the data sink to store the keyring to. The value
- * mapped must be a {@link java.io.OutputStream}.</p>
+ * Property name for the data sink to store the keyring to. The value mapped
+ * must be a {@link java.io.OutputStream}.
*/
public static final String KEYRING_DATA_OUT = "gun.crypto.keyring.data.out";
/**
- * <p>Property name for the keyring's top-level password, used to
- * authenticate and/or transform the store itself. The mapped value must be a
- * char array.</p>
+ * Property name for the keyring's top-level password, used to authenticate
+ * and/or transform the store itself. The mapped value must be a char array.
*/
public static final String KEYRING_PASSWORD = "gnu.crypto.keyring.password";
/**
- * <p>Loads a keyring into memory.</p>
- *
- * <p>What happens to the current contents of this keyring? are the new ones
- * merged with the current ones or do they simply replace them?</p>
- *
+ * Loads a keyring into memory.
+ * <p>
+ * What happens to the current contents of this keyring? are the new ones
+ * merged with the current ones or do they simply replace them?
+ *
* @param attributes The attributes that designate the source where the store
- * is to be loaded from. What happens
+ * is to be loaded from. What happens
* @throws IllegalArgumentException If the attributes are inappropriate.
* @throws IOException If the keyring file cannot be read.
* @throws SecurityException If the given password is incorrect, or if the
- * top-level authentication or decryption fails.
+ * top-level authentication or decryption fails.
*/
void load(Map attributes) throws IOException;
/**
- * <p>Stores the contents of this keyring to persistent storage as specified
- * by the designated <code>attributes</code>.</p>
- *
+ * Stores the contents of this keyring to persistent storage as specified by
+ * the designated <code>attributes</code>.
+ *
* @param attributes the attributes that define where the contents of this
- * keyring will be stored.
+ * keyring will be stored.
* @throws IOException if an exception occurs during the process.
*/
void store(Map attributes) throws IOException;
/**
- * <p>Resets this keyring, clearing all sensitive data. This method always
- * suceeds.</p>
+ * Resets this keyring, clearing all sensitive data. This method always
+ * suceeds.
*/
void reset();
/**
- * <p>Returns the number of entries in this keyring.</p>
- *
+ * Returns the number of entries in this keyring.
+ *
* @return The number of current entries in this keyring.
*/
int size();
/**
- * <p>Returns an {@link Enumeration} of all aliases (instances of
- * {@link String}) in this keyring.</p>
- *
- * @return The enumeration of {@link String}s each representing an
- * <i>alias</i> found in this keyring.
+ * Returns an {@link Enumeration} of all aliases (instances of {@link String})
+ * in this keyring.
+ *
+ * @return The enumeration of {@link String}s each representing an <i>alias</i>
+ * found in this keyring.
*/
Enumeration aliases();
/**
* Tests whether or not this keyring contains the given alias.
- *
+ *
* @param alias The alias to check.
* @return true if this keyring contains the alias.
*/
boolean containsAlias(String alias);
/**
- * <p>Returns a {@link List} of entries (instances of {@link Entry}) for the
+ * Returns a {@link List} of entries (instances of {@link Entry}) for the
* given <code>alias</code>, or <code>null</code> if there no such entry
- * exists.</p>
- *
+ * exists.
+ *
* @param alias The alias of the entry(ies) to return.
* @return A list of all entries (instances of {@link Entry} that have the
- * given <code>alias</code>, or <code>null</code> if no one {@link Entry} can
- * be found with the designated <code>alias</code>.
+ * given <code>alias</code>, or <code>null</code> if no one
+ * {@link Entry} can be found with the designated <code>alias</code>.
*/
List get(String alias);
/**
- * <p>Adds a designated {@link Entry} to this keyring.</p>
- *
- * <p>What happens if there is already an entry with the same alias?</p>
- *
+ * Adds a designated {@link Entry} to this keyring.
+ * <p>
+ * What happens if there is already an entry with the same alias?
+ *
* @param entry The entry to put in this keyring.
*/
void add(Entry entry);
/**
- * <p>Removes an entry with the designated <code>alias</code> from this
- * keyring. Does nothing if there was no such entry.</p>
- *
- * <p>What happens if there are more than one?</p>
- *
+ * Removes an entry with the designated <code>alias</code> from this
+ * keyring. Does nothing if there was no such entry.
+ * <p>
+ * What happens if there are more than one?
+ *
* @param alias The alias of the entry to remove.
*/
void remove(String alias);
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/IPrivateKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/IPrivateKeyring.java
index 66bbd84f568..9e2ceab9b95 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/IPrivateKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/IPrivateKeyring.java
@@ -44,41 +44,41 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
/**
- * <p>An interface to private, or "personal", keyrings, which contain private
+ * An interface to private, or "personal", keyrings, which contain private
* credentials. The contract is that each such entry is known by a unique
- * <i>alias</i>.</p>
- *
- * <p>What about public keys? and certificate-path?</p>
+ * <i>alias</i>.
+ * <p>
+ * What about public keys? and certificate-path?
*/
-public interface IPrivateKeyring extends IKeyring
+public interface IPrivateKeyring
+ extends IKeyring
{
-
/**
- * <p>Tests if this keyring contains a private key entry with the given
- * <code>alias</code>.</p>
- *
+ * Tests if this keyring contains a private key entry with the given
+ * <code>alias</code>.
+ *
* @param alias The alias to check.
* @return <code>true</code> if this keyring contains a private key with the
- * given <code>alias</code>; <code>false</code> otherwise.</p>
+ * given <code>alias</code>; <code>false</code> otherwise.
*/
boolean containsPrivateKey(String alias);
/**
- * <p>Returns the private key with the given <code>alias</code>.</p>
- *
+ * Returns the private key with the given <code>alias</code>.
+ *
* @param alias The alias of the private key to find.
* @param password The password of the private key.
* @return The private, or secret, key if one is found; <code>null</code> if
- * none were found.
+ * none were found.
* @throws UnrecoverableKeyException If the private key could not be
- * recovered, possibly due to a bad password.
+ * recovered, possibly due to a bad password.
*/
Key getPrivateKey(String alias, char[] password)
throws UnrecoverableKeyException;
/**
- * <p>Adds a private key to this keyring.</p>
- *
+ * Adds a private key to this keyring.
+ *
* @param alias The alias of the private key.
* @param key The private key.
* @param password The password used to protect this private key.
@@ -86,55 +86,57 @@ public interface IPrivateKeyring extends IKeyring
void putPrivateKey(String alias, Key key, char[] password);
/**
- * <p>Checks if this keyring contains a public key with the given
- * <code>alias</code>.</p>
- *
+ * Checks if this keyring contains a public key with the given
+ * <code>alias</code>.
+ *
* @param alias The alias to test.
- * @return <code>true</code> if this keyring contains a public key entry with
- * the given <code>alias</code>; <code>false</code> otherwise.
+ * @return <code>true</code> if this keyring contains a public key entry
+ * with the given <code>alias</code>; <code>false</code>
+ * otherwise.
*/
boolean containsPublicKey(String alias);
/**
- * <p>Returns the public key with the given <code>alias</code>, or
- * <code>null</code> if there is no such entry.</p>
- *
+ * Returns the public key with the given <code>alias</code>, or
+ * <code>null</code> if there is no such entry.
+ *
* @param alias The alias of the public key to find.
* @return The public key; or <code>null</code> if none were found.
*/
PublicKey getPublicKey(String alias);
/**
- * <p>Sets a public key entry.</p>
- *
+ * Sets a public key entry.
+ *
* @param alias The alias for this public key.
* @param key The public key.
*/
void putPublicKey(String alias, PublicKey key);
/**
- * <p>Checks if this keyring contains a certificate path with the given
- * <code>alias</code>.</p>
- *
+ * Checks if this keyring contains a certificate path with the given
+ * <code>alias</code>.
+ *
* @param alias The alias to check.
- * @return <code>true</code> if this keyring contains a certificate path with
- * the given <code>alias</code>; <code>false</code> otherwise.
+ * @return <code>true</code> if this keyring contains a certificate path
+ * with the given <code>alias</code>; <code>false</code>
+ * otherwise.
*/
boolean containsCertPath(String alias);
/**
- * <p>Returns the certificate path with the given <code>alias</code>, or
- * <code>null</code> if there is no such entry.</p>
- *
+ * Returns the certificate path with the given <code>alias</code>, or
+ * <code>null</code> if there is no such entry.
+ *
* @param alias The alias of the certificate path to find.
* @return The certificate path for the designated <code>alias</code>; or
- * <code>null</code> if none were found.
+ * <code>null</code> if none were found.
*/
Certificate[] getCertPath(String alias);
/**
- * <p>Sets a certificate path entry.</p>
- *
+ * Sets a certificate path entry.
+ *
* @param alias The alias for this certificate path.
* @param path The certificate path.
*/
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/IPublicKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/IPublicKeyring.java
index ccf9ca73b55..efe568f185b 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/IPublicKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/IPublicKeyring.java
@@ -41,39 +41,40 @@ package gnu.javax.crypto.keyring;
import java.security.cert.Certificate;
/**
- * <p>An interface for keyrings that contain trusted (by the owner) public
- * credentials (incl. certificates).</p>
- *
+ * An interface for keyrings that contain trusted (by the owner) public
+ * credentials (incl. certificates).
+ *
* @see IKeyring
*/
-public interface IPublicKeyring extends IKeyring
+public interface IPublicKeyring
+ extends IKeyring
{
-
/**
- * <p>Tests if this keyring contains a certificate entry with the specified
- * <code>alias</code>.</p>
- *
+ * Tests if this keyring contains a certificate entry with the specified
+ * <code>alias</code>.
+ *
* @param alias The alias of the certificate to check.
* @return <code>true</code> if this keyring contains a certificate entry
- * that has the given <code>alias</code>; <code>false</code> otherwise.
+ * that has the given <code>alias</code>; <code>false</code>
+ * otherwise.
*/
boolean containsCertificate(String alias);
/**
- * <p>Returns a certificate that has the given <code>alias</code>, or
- * <code>null</code> if this keyring has no such entry.</p>
- *
+ * Returns a certificate that has the given <code>alias</code>, or
+ * <code>null</code> if this keyring has no such entry.
+ *
* @param alias The alias of the certificate to find.
* @return The certificate with the designated <code>alias</code>, or
- * <code>null</code> if none found.
+ * <code>null</code> if none found.
*/
Certificate getCertificate(String alias);
/**
- * <p>Adds a certificate in this keyring, with the given <code>alias</code>.</p>
- *
- * <p>What happens if there is already a certificate entry with this alias?</p>
- *
+ * Adds a certificate in this keyring, with the given <code>alias</code>.
+ * <p>
+ * What happens if there is already a certificate entry with this alias?
+ *
* @param alias The alias of this certificate entry.
* @param cert The certificate.
*/
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/MalformedKeyringException.java b/libjava/classpath/gnu/javax/crypto/keyring/MalformedKeyringException.java
index 44c953946d4..0dab3a764c6 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/MalformedKeyringException.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/MalformedKeyringException.java
@@ -40,12 +40,9 @@ package gnu.javax.crypto.keyring;
import java.io.IOException;
-public class MalformedKeyringException extends IOException
+public class MalformedKeyringException
+ extends IOException
{
-
- // Constructors.
- // ------------------------------------------------------------------------
-
public MalformedKeyringException()
{
super();
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java
index 7fed7c40c15..5206a5e071e 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/MaskableEnvelopeEntry.java
@@ -43,21 +43,15 @@ import java.util.List;
/**
* An envelope entry that can be "masked" -- placed in a state where the
- * envelope's contents cannot be accessed, due to the envelope not being
- * fully decoded, for example.
+ * envelope's contents cannot be accessed, due to the envelope not being fully
+ * decoded, for example.
*/
-public abstract class MaskableEnvelopeEntry extends EnvelopeEntry
+public abstract class MaskableEnvelopeEntry
+ extends EnvelopeEntry
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
/** The masked state. */
protected boolean masked;
- // Constructors.
- // ------------------------------------------------------------------------
-
public MaskableEnvelopeEntry(int type, Properties properties)
{
super(type, properties);
@@ -68,12 +62,9 @@ public abstract class MaskableEnvelopeEntry extends EnvelopeEntry
super(type);
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Sets the masked state to the specified value.
- *
+ *
* @param masked The new masked state.
*/
protected final void setMasked(boolean masked)
@@ -84,7 +75,7 @@ public abstract class MaskableEnvelopeEntry extends EnvelopeEntry
/**
* Gets the masked state of this object. Certain operations on this object
* will fail if it is masked.
- *
+ *
* @return The current masked state.
*/
public boolean isMasked()
@@ -95,54 +86,50 @@ public abstract class MaskableEnvelopeEntry extends EnvelopeEntry
public void add(Entry entry)
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
+ throw new IllegalStateException("masked envelope");
super.add(entry);
}
public boolean containsEntry(Entry entry)
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
+ throw new IllegalStateException("masked envelope");
return super.containsEntry(entry);
}
public List getEntries()
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
+ throw new IllegalStateException("masked envelope");
return new ArrayList(entries);
}
public List get(String alias)
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
+ throw new IllegalStateException("masked envelope");
return super.get(alias);
}
public boolean remove(Entry entry)
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
+ throw new IllegalStateException("masked envelope");
return super.remove(entry);
}
- public void remove(String alias)
+ public boolean remove(String alias)
{
if (isMasked())
- {
- throw new IllegalStateException("masked envelope");
- }
- super.remove(alias);
+ throw new IllegalStateException("masked envelope");
+ return super.remove(alias);
+ }
+
+ public String toString()
+ {
+ return new StringBuilder("MaskableEnvelope{")
+ .append(super.toString())
+ .append(", masked=").append(masked)
+ .append("}").toString();
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/MeteredInputStream.java b/libjava/classpath/gnu/javax/crypto/keyring/MeteredInputStream.java
index fcf2be746c9..330e4b20fb5 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/MeteredInputStream.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/MeteredInputStream.java
@@ -39,22 +39,15 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
import java.io.FilterInputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
-final class MeteredInputStream extends FilterInputStream
+final class MeteredInputStream
+ extends FilterInputStream
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
private int count;
-
private final int limit;
- // Constructor.
- // ------------------------------------------------------------------------
-
MeteredInputStream(InputStream in, int limit)
{
super(in);
@@ -64,12 +57,9 @@ final class MeteredInputStream extends FilterInputStream
count = 0;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Tests if the number of bytes read has reached the limit.
- *
+ *
* @return True if the limit has been reached.
*/
public boolean limitReached()
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java
index 2e3a0d145c8..be10029c8bc 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java
@@ -38,9 +38,11 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
+import gnu.java.security.util.PRNG;
import gnu.java.security.util.Util;
import gnu.javax.crypto.mac.IMac;
import gnu.javax.crypto.mac.MacFactory;
@@ -55,35 +57,27 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
-import java.security.SecureRandom;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.logging.Logger;
/**
- * <p>An entry authenticated with a password-based MAC.</p>
+ * An entry authenticated with a password-based MAC.
*/
-public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
+public final class PasswordAuthenticatedEntry
+ extends MaskableEnvelopeEntry
implements PasswordProtectedEntry, Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(PasswordAuthenticatedEntry.class.getName());
public static final int TYPE = 3;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public PasswordAuthenticatedEntry(String mac, int maclen,
Properties properties)
{
super(TYPE, properties);
-
if (mac == null || mac.length() == 0)
- {
- throw new IllegalArgumentException("no MAC specified");
- }
+ throw new IllegalArgumentException("no MAC specified");
this.properties.put("mac", mac);
this.properties.put("maclen", String.valueOf(maclen));
setMasked(false);
@@ -95,9 +89,6 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
setMasked(true);
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static PasswordAuthenticatedEntry decode(DataInputStream in,
char[] password)
throws IOException
@@ -113,10 +104,8 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
entry.decodeEnvelope(in2);
byte[] macValue = new byte[mac.macSize()];
in.readFully(macValue);
- if (!Arrays.equals(macValue, mac.digest()))
- {
- throw new MalformedKeyringException("MAC verification failed");
- }
+ if (! Arrays.equals(macValue, mac.digest()))
+ throw new MalformedKeyringException("MAC verification failed");
return entry;
}
@@ -125,74 +114,76 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
{
PasswordAuthenticatedEntry entry = new PasswordAuthenticatedEntry();
entry.defaultDecode(in);
- if (!entry.properties.containsKey("mac"))
- {
- throw new MalformedKeyringException("no MAC");
- }
- if (!entry.properties.containsKey("maclen"))
- {
- throw new MalformedKeyringException("no MAC length");
- }
- if (!entry.properties.containsKey("salt"))
- {
- throw new MalformedKeyringException("no salt");
- }
+ if (! entry.properties.containsKey("mac"))
+ throw new MalformedKeyringException("no MAC");
+ if (! entry.properties.containsKey("maclen"))
+ throw new MalformedKeyringException("no MAC length");
+ if (! entry.properties.containsKey("salt"))
+ throw new MalformedKeyringException("no salt");
return entry;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public void verify(char[] password)
{
- if (!isMasked() || payload == null)
- {
- return;
- }
- IMac m = null;
- try
- {
- m = getMac(password);
- }
- catch (Exception x)
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "verify");
+ if (isMasked() && payload != null)
{
- throw new IllegalArgumentException(x.toString());
+ if (Configuration.DEBUG)
+ log.fine("payload to verify: " + Util.dumpString(payload));
+ long tt = -System.currentTimeMillis();
+ IMac m = null;
+ try
+ {
+ m = getMac(password);
+ }
+ catch (Exception x)
+ {
+ throw new IllegalArgumentException(x.toString(), x);
+ }
+ int limit = payload.length - m.macSize();
+ m.update(payload, 0, limit);
+ byte[] macValue = new byte[m.macSize()];
+ System.arraycopy(payload, payload.length - macValue.length, macValue,
+ 0, macValue.length);
+ if (! Arrays.equals(macValue, m.digest()))
+ throw new IllegalArgumentException("MAC verification failed");
+ setMasked(false);
+ ByteArrayInputStream bais;
+ try
+ {
+ bais = new ByteArrayInputStream(payload, 0, limit);
+ DataInputStream in = new DataInputStream(bais);
+ decodeEnvelope(in);
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalArgumentException("malformed keyring fragment");
+ }
+ tt += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ log.fine("Verified in " + tt + "ms.");
}
-
- m.update(payload, 0, payload.length - m.macSize());
- byte[] macValue = new byte[m.macSize()];
- System.arraycopy(payload, payload.length - macValue.length, macValue, 0,
- macValue.length);
- if (!Arrays.equals(macValue, m.digest()))
- {
- throw new IllegalArgumentException("MAC verification failed");
- }
- try
- {
- DataInputStream in = new DataInputStream(
- new ByteArrayInputStream(
- payload,
- 0,
- payload.length
- - m.macSize()));
- decodeEnvelope(in);
- }
- catch (IOException ioe)
- {
- throw new IllegalArgumentException("malformed keyring fragment");
- }
- setMasked(false);
- payload = null;
+ else if (Configuration.DEBUG)
+ log.fine("Skip verification; "
+ + (isMasked() ? "null payload" : "unmasked"));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "verify");
}
public void authenticate(char[] password) throws IOException
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "authenticate");
+ long tt = -System.currentTimeMillis();
+ long t1 = -System.currentTimeMillis();
if (isMasked())
- {
- throw new IllegalStateException("entry is masked");
- }
+ throw new IllegalStateException("entry is masked");
byte[] salt = new byte[8];
- new SecureRandom ().nextBytes (salt);
+ PRNG.getInstance().nextBytes(salt);
+ t1 += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ log.fine("-- Generated salt in " + t1 + "ms.");
properties.put("salt", Util.toString(salt));
IMac m = getMac(password);
ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
@@ -201,10 +192,25 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
for (Iterator it = entries.iterator(); it.hasNext();)
{
Entry entry = (Entry) it.next();
+ if (Configuration.DEBUG)
+ log.fine("-- About to authenticate one " + entry);
+ t1 = -System.currentTimeMillis();
entry.encode(out2);
+ t1 += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ log.fine("-- Authenticated an Entry in " + t1 + "ms.");
}
bout.write(m.digest());
payload = bout.toByteArray();
+ if (Configuration.DEBUG)
+ log.fine("authenticated payload: " + Util.dumpString(payload));
+ setMasked(true);
+ tt += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ {
+ log.fine("Authenticated in " + tt + "ms.");
+ log.exiting(this.getClass().getName(), "authenticate");
+ }
}
public void encode(DataOutputStream out, char[] password) throws IOException
@@ -217,48 +223,42 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
{
if (payload == null)
{
+ log.fine("Null payload: " + this);
throw new IllegalStateException("mac not computed");
}
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private IMac getMac(char[] password) throws MalformedKeyringException
{
- if (!properties.containsKey("salt"))
- {
- throw new MalformedKeyringException("no salt");
- }
- byte[] salt = Util.toBytesFromString(properties.get("salt"));
- IMac mac = MacFactory.getInstance(properties.get("mac"));
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getMac");
+ String saltString = properties.get("salt");
+ if (saltString == null)
+ throw new MalformedKeyringException("no salt");
+ byte[] salt = Util.toBytesFromString(saltString);
+ String macAlgorithm = properties.get("mac");
+ IMac mac = MacFactory.getInstance(macAlgorithm);
if (mac == null)
- {
- throw new MalformedKeyringException("no such mac: "
- + properties.get("mac"));
- }
- int keylen = mac.macSize();
- int maclen = 0;
- if (!properties.containsKey("maclen"))
- {
- throw new MalformedKeyringException("no MAC length");
- }
+ throw new MalformedKeyringException("no such mac: " + macAlgorithm);
+ String macLenString = properties.get("maclen");
+ if (macLenString == null)
+ throw new MalformedKeyringException("no MAC length");
+ int maclen;
try
{
- maclen = Integer.parseInt(properties.get("maclen"));
+ maclen = Integer.parseInt(macLenString);
}
catch (NumberFormatException nfe)
{
throw new MalformedKeyringException("bad MAC length");
}
-
HashMap pbAttr = new HashMap();
pbAttr.put(IPBE.PASSWORD, password);
pbAttr.put(IPBE.SALT, salt);
pbAttr.put(IPBE.ITERATION_COUNT, ITERATION_COUNT);
IRandom kdf = PRNGFactory.getInstance("PBKDF2-HMAC-SHA");
kdf.init(pbAttr);
-
+ int keylen = mac.macSize();
byte[] dk = new byte[keylen];
try
{
@@ -268,10 +268,9 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
{
throw new Error(shouldNotHappen.toString());
}
-
HashMap macAttr = new HashMap();
macAttr.put(IMac.MAC_KEY_MATERIAL, dk);
- macAttr.put(IMac.TRUNCATED_SIZE, new Integer(maclen));
+ macAttr.put(IMac.TRUNCATED_SIZE, Integer.valueOf(maclen));
try
{
mac.init(macAttr);
@@ -280,6 +279,8 @@ public final class PasswordAuthenticatedEntry extends MaskableEnvelopeEntry
{
throw new Error(shouldNotHappen.toString());
}
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getMac");
return mac;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java
index 26b4032bdfb..00031cbf1bb 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
+import gnu.java.security.util.PRNG;
import gnu.java.security.util.Util;
-
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.mode.IMode;
@@ -58,41 +59,28 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
import java.security.InvalidKeyException;
-import java.security.SecureRandom;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
import java.util.HashMap;
-import java.util.List;
+import java.util.Iterator;
+import java.util.logging.Logger;
/**
* An envelope that is encrypted with a password-derived key.
*/
-public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
- PasswordProtectedEntry, Registry
+public class PasswordEncryptedEntry
+ extends MaskableEnvelopeEntry
+ implements PasswordProtectedEntry, Registry
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(PasswordEncryptedEntry.class.getName());
public static final int TYPE = 1;
- // Constructors.
- // ------------------------------------------------------------------------
-
public PasswordEncryptedEntry(String cipher, String mode, int keylen,
Properties properties)
{
super(TYPE, properties);
if ((cipher == null || cipher.length() == 0)
|| (mode == null || mode.length() == 0))
- {
- throw new IllegalArgumentException("cipher nor mode can be empty");
- }
+ throw new IllegalArgumentException("cipher nor mode can be empty");
this.properties.put("cipher", cipher);
this.properties.put("mode", mode);
this.properties.put("keylen", String.valueOf(keylen));
@@ -105,9 +93,6 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
setMasked(true);
}
- // Class methods.
- // ------------------------------------------------------------------------
-
public static PasswordEncryptedEntry decode(DataInputStream in,
char[] password)
throws IOException
@@ -132,49 +117,57 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public void decrypt(char[] password) throws IllegalArgumentException,
WrongPaddingException
{
- if (!isMasked() || payload == null)
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "decrypt");
+ if (isMasked() && payload != null)
{
- return;
- }
- IMode mode = getMode(password, IMode.DECRYPTION);
- IPad padding = PadFactory.getInstance("PKCS7");
- padding.init(mode.currentBlockSize());
- byte[] buf = new byte[payload.length];
- int count = 0;
- for (int i = 0; i < payload.length; i++)
- {
- mode.update(payload, count, buf, count);
- count += mode.currentBlockSize();
- }
- int padlen = padding.unpad(buf, 0, buf.length);
- DataInputStream in = new DataInputStream(
- new ByteArrayInputStream(
- buf,
- 0,
- buf.length
- - padlen));
- try
- {
- decodeEnvelope(in);
- }
- catch (IOException ioe)
- {
- throw new IllegalArgumentException("decryption failed");
+ long tt = -System.currentTimeMillis();
+ IMode mode = getMode(password, IMode.DECRYPTION);
+ IPad padding = PadFactory.getInstance("PKCS7");
+ padding.init(mode.currentBlockSize());
+ byte[] buf = new byte[payload.length];
+ int count = 0;
+ while (count + mode.currentBlockSize() <= payload.length)
+ {
+ mode.update(payload, count, buf, count);
+ count += mode.currentBlockSize();
+ }
+ int padlen = padding.unpad(buf, 0, buf.length);
+ setMasked(false);
+ int len = buf.length - padlen;
+ ByteArrayInputStream baos = new ByteArrayInputStream(buf, 0, len);
+ DataInputStream in = new DataInputStream(baos);
+ try
+ {
+ decodeEnvelope(in);
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalArgumentException("decryption failed");
+ }
+ tt += System.currentTimeMillis();
+ log.fine("Decrypted in " + tt + "ms.");
}
- setMasked(false);
- payload = null;
+ else if (Configuration.DEBUG)
+ log.fine("Skip decryption; " + (isMasked() ? "null payload" : "unmasked"));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "decrypt");
}
public void encrypt(char[] password) throws IOException
{
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "encrypt", String.valueOf(password));
+ long tt = -System.currentTimeMillis();
+ long t1 = -System.currentTimeMillis();
byte[] salt = new byte[8];
- new SecureRandom ().nextBytes (salt);
+ PRNG.getInstance().nextBytes(salt);
+ t1 += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ log.fine("-- Generated salt in " + t1 + "ms.");
properties.put("salt", Util.toString(salt));
IMode mode = getMode(password, IMode.ENCRYPTION);
IPad pad = PadFactory.getInstance("PKCS7");
@@ -184,7 +177,13 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
for (Iterator it = entries.iterator(); it.hasNext();)
{
Entry entry = (Entry) it.next();
+ if (Configuration.DEBUG)
+ log.fine("-- About to encode one " + entry);
+ t1 = -System.currentTimeMillis();
entry.encode(out2);
+ t1 += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ log.fine("-- Encoded an Entry in " + t1 + "ms.");
}
byte[] plaintext = bout.toByteArray();
byte[] padding = pad.pad(plaintext, 0, plaintext.length);
@@ -200,6 +199,13 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
count += mode.currentBlockSize();
}
mode.update(lastBlock, 0, payload, count);
+ setMasked(true);
+ tt += System.currentTimeMillis();
+ if (Configuration.DEBUG)
+ {
+ log.fine("Encrypted in " + tt + "ms.");
+ log.exiting(this.getClass().getName(), "encrypt");
+ }
}
public void encode(DataOutputStream out, char[] password) throws IOException
@@ -212,60 +218,46 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
{
if (payload == null)
{
+ if (Configuration.DEBUG)
+ log.fine("Null payload: " + this);
throw new IllegalStateException("not encrypted");
}
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private IMode getMode(char[] password, int state)
{
String s = properties.get("salt");
if (s == null)
- {
- throw new IllegalArgumentException("no salt");
- }
+ throw new IllegalArgumentException("no salt");
byte[] salt = Util.toBytesFromString(s);
IBlockCipher cipher = CipherFactory.getInstance(properties.get("cipher"));
if (cipher == null)
- {
- throw new IllegalArgumentException("no such cipher: "
- + properties.get("cipher"));
- }
+ throw new IllegalArgumentException("no such cipher: "
+ + properties.get("cipher"));
int blockSize = cipher.defaultBlockSize();
if (properties.containsKey("block-size"))
- {
- try
- {
- blockSize = Integer.parseInt(properties.get("block-size"));
- }
- catch (NumberFormatException nfe)
- {
- throw new IllegalArgumentException("bad block size: "
- + nfe.getMessage());
- }
- }
- IMode mode = ModeFactory.getInstance(properties.get("mode"), cipher,
- blockSize);
+ try
+ {
+ blockSize = Integer.parseInt(properties.get("block-size"));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new IllegalArgumentException("bad block size: "
+ + nfe.getMessage());
+ }
+ String modeName = properties.get("mode");
+ IMode mode = ModeFactory.getInstance(modeName, cipher, blockSize);
if (mode == null)
- {
- throw new IllegalArgumentException("no such mode: "
- + properties.get("mode"));
- }
-
+ throw new IllegalArgumentException("no such mode: " + modeName);
HashMap pbAttr = new HashMap();
pbAttr.put(IPBE.PASSWORD, password);
pbAttr.put(IPBE.SALT, salt);
pbAttr.put(IPBE.ITERATION_COUNT, ITERATION_COUNT);
IRandom kdf = PRNGFactory.getInstance("PBKDF2-HMAC-SHA");
kdf.init(pbAttr);
-
int keylen = 0;
- if (!properties.containsKey("keylen"))
- {
- throw new IllegalArgumentException("no key length");
- }
+ if (! properties.containsKey("keylen"))
+ throw new IllegalArgumentException("no key length");
try
{
keylen = Integer.parseInt(properties.get("keylen"));
@@ -286,7 +278,7 @@ public class PasswordEncryptedEntry extends MaskableEnvelopeEntry implements
}
HashMap modeAttr = new HashMap();
modeAttr.put(IMode.KEY_MATERIAL, dk);
- modeAttr.put(IMode.STATE, new Integer(state));
+ modeAttr.put(IMode.STATE, Integer.valueOf(state));
modeAttr.put(IMode.IV, iv);
try
{
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PasswordProtectedEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PasswordProtectedEntry.java
index 0dcf73eb8d2..5eff637927a 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PasswordProtectedEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PasswordProtectedEntry.java
@@ -43,21 +43,12 @@ import java.io.IOException;
public interface PasswordProtectedEntry
{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /**
- * The iteration count for password-based KDFs.
- */
- Integer ITERATION_COUNT = new Integer(1000);
-
- // Method.
- // ------------------------------------------------------------------------
+ /** The iteration count for password-based KDFs. */
+ Integer ITERATION_COUNT = Integer.valueOf(1000);
/**
* Encodes this entry, protected by a password.
- *
+ *
* @param out The output stream to encode to.
* @param password The password.
* @throws IOException If an I/O error occurs.
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PrimitiveEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PrimitiveEntry.java
index 4c9ff0ff1d9..194fe9eeec1 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PrimitiveEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PrimitiveEntry.java
@@ -43,36 +43,24 @@ import java.util.Date;
/**
* A primitive entry is an entry that contains a single cryptographic entity.
*/
-public abstract class PrimitiveEntry extends Entry
+public abstract class PrimitiveEntry
+ extends Entry
{
-
- // Fields.
- // ------------------------------------------------------------------------
-
/** The creation date. */
protected Date creationDate;
- // Constructor.
- // ------------------------------------------------------------------------
-
protected PrimitiveEntry(int type, Date creationDate, Properties properties)
{
super(type, properties);
if (creationDate == null)
- {
- this.creationDate = new Date();
- }
+ this.creationDate = new Date();
else
- {
- this.creationDate = (Date) creationDate.clone();
- }
- if (!this.properties.containsKey("alias")
+ this.creationDate = (Date) creationDate.clone();
+ if (! this.properties.containsKey("alias")
|| this.properties.get("alias").length() == 0)
- {
- throw new IllegalArgumentException(
- "primitive entries MUST have an alias");
- }
- this.properties.put("creation-date", String.valueOf(creationDate.getTime()));
+ throw new IllegalArgumentException("primitive entries MUST have an alias");
+ this.properties.put("creation-date",
+ String.valueOf(this.creationDate.getTime()));
}
protected PrimitiveEntry(int type)
@@ -80,12 +68,9 @@ public abstract class PrimitiveEntry extends Entry
super(type);
}
- // Instance method.
- // ------------------------------------------------------------------------
-
/**
* Returns the alias of this primitive entry.
- *
+ *
* @return The alias.
*/
public String getAlias()
@@ -95,7 +80,7 @@ public abstract class PrimitiveEntry extends Entry
/**
* Returns the creation date of this primitive entry.
- *
+ *
* @return The creation date.
*/
public Date getCreationDate()
@@ -105,7 +90,7 @@ public abstract class PrimitiveEntry extends Entry
public boolean equals(Object object)
{
- if (!getClass().equals(object.getClass()))
+ if (! getClass().equals(object.getClass()))
return false;
return getAlias().equals(((PrimitiveEntry) object).getAlias());
}
@@ -114,9 +99,7 @@ public abstract class PrimitiveEntry extends Entry
{
String s = properties.get("creation-date");
if (s == null)
- {
- throw new MalformedKeyringException("no creation date");
- }
+ throw new MalformedKeyringException("no creation date");
try
{
creationDate = new Date(Long.parseLong(s));
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
index 88249563341..23244afee8d 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
@@ -42,12 +42,10 @@ import gnu.java.security.key.IKeyPairCodec;
import gnu.java.security.key.KeyPairCodecFactory;
import gnu.java.security.key.dss.DSSPrivateKey;
import gnu.java.security.key.rsa.GnuRSAPrivateKey;
-
import gnu.javax.crypto.key.GnuSecretKey;
import gnu.javax.crypto.key.dh.GnuDHPrivateKey;
import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.security.Key;
import java.security.KeyFactory;
@@ -56,25 +54,18 @@ import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Date;
/**
- * <p>An immutable class representing a private or secret key entry.</p>
+ * An immutable class representing a private or secret key entry.
*/
-public final class PrivateKeyEntry extends PrimitiveEntry
+public final class PrivateKeyEntry
+ extends PrimitiveEntry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final int TYPE = 7;
-
/** The key. */
private Key key;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Creates a new key entry.</p>
- *
+ * Creates a new key entry.
+ *
* @param key The key.
* @param creationDate The entry creation date.
* @param properties The entry properties.
@@ -83,15 +74,10 @@ public final class PrivateKeyEntry extends PrimitiveEntry
public PrivateKeyEntry(Key key, Date creationDate, Properties properties)
{
super(TYPE, creationDate, properties);
-
if (key == null)
- {
- throw new IllegalArgumentException("no private key");
- }
- if (!(key instanceof PrivateKey) && !(key instanceof GnuSecretKey))
- {
- throw new IllegalArgumentException("not a private or secret key");
- }
+ throw new IllegalArgumentException("no private key");
+ if (! (key instanceof PrivateKey) && ! (key instanceof GnuSecretKey))
+ throw new IllegalArgumentException("not a private or secret key");
this.key = key;
}
@@ -100,18 +86,13 @@ public final class PrivateKeyEntry extends PrimitiveEntry
super(TYPE);
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static PrivateKeyEntry decode(DataInputStream in) throws IOException
{
PrivateKeyEntry entry = new PrivateKeyEntry();
entry.defaultDecode(in);
String type = entry.properties.get("type");
if (type == null)
- {
- throw new MalformedKeyringException("no key type");
- }
+ throw new MalformedKeyringException("no key type");
if (type.equalsIgnoreCase("RAW-DSS"))
{
IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dss");
@@ -128,18 +109,16 @@ public final class PrivateKeyEntry extends PrimitiveEntry
entry.key = coder.decodePrivateKey(entry.payload);
}
else if (type.equalsIgnoreCase("RAW"))
- {
- entry.key = new GnuSecretKey(entry.payload, null);
- }
+ entry.key = new GnuSecretKey(entry.payload, null);
else if (type.equalsIgnoreCase("PKCS8"))
{
try
{
KeyFactory kf = KeyFactory.getInstance("RSA");
- entry.key = kf.generatePrivate(new PKCS8EncodedKeySpec(
- entry.payload));
+ PKCS8EncodedKeySpec ks = new PKCS8EncodedKeySpec(entry.payload);
+ entry.key = kf.generatePrivate(ks);
}
- catch (Exception x)
+ catch (Exception ignored)
{
}
if (entry.key == null)
@@ -147,32 +126,24 @@ public final class PrivateKeyEntry extends PrimitiveEntry
try
{
KeyFactory kf = KeyFactory.getInstance("DSA");
- entry.key = kf.generatePrivate(new PKCS8EncodedKeySpec(
- entry.payload));
+ PKCS8EncodedKeySpec ks = new PKCS8EncodedKeySpec(entry.payload);
+ entry.key = kf.generatePrivate(ks);
}
- catch (Exception x)
+ catch (Exception ignored)
{
}
if (entry.key == null)
- {
- throw new MalformedKeyringException(
- "could not decode PKCS#8 key");
- }
+ throw new MalformedKeyringException("could not decode PKCS#8 key");
}
}
else
- {
- throw new MalformedKeyringException("unsupported key type " + type);
- }
+ throw new MalformedKeyringException("unsupported key type " + type);
return entry;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns this entry's key.</p>
- *
+ * Returns this entry's key.
+ *
* @return The key.
*/
public Key getKey()
@@ -212,8 +183,12 @@ public final class PrivateKeyEntry extends PrimitiveEntry
payload = key.getEncoded();
}
else
- {
- throw new IllegalArgumentException("unsupported private key");
- }
+ throw new IllegalArgumentException("unsupported private key");
+ }
+
+ public String toString()
+ {
+ return "PrivateKeyEntry{key="
+ + (key == null ? "-" : key.getClass().getName()) + "}";
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/Properties.java b/libjava/classpath/gnu/javax/crypto/keyring/Properties.java
index 646b5711df2..b833a74aeab 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/Properties.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/Properties.java
@@ -42,27 +42,20 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* A set of <code>(name =&gt; value)</code> pairs used in keyring entries.
- * Keys and values are simple strings, with the key never being empty and
- * always treated case-insensitively.
+ * Keys and values are simple strings, with the key never being empty and always
+ * treated case-insensitively.
*/
-public class Properties implements Cloneable
+public class Properties
+ implements Cloneable
{
-
- // Field.
- // ------------------------------------------------------------------------
-
private HashMap props;
- // Constructor.
- // ------------------------------------------------------------------------
-
/**
* Creates a new properties object.
*/
@@ -71,9 +64,6 @@ public class Properties implements Cloneable
props = new HashMap();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Removes all properties from this object.
*/
@@ -84,7 +74,7 @@ public class Properties implements Cloneable
/**
* Creates a copy of this properties object.
- *
+ *
* @return The copy.
*/
public Object clone()
@@ -96,86 +86,75 @@ public class Properties implements Cloneable
/**
* Tests if this object contains a given property name.
- *
+ *
* @param key The key to test.
* @return True if this object contains the given key.
*/
public boolean containsKey(String key)
{
if (key == null || key.length() == 0)
- {
- return false;
- }
+ return false;
return props.containsKey(canonicalize(key));
}
/**
* Tests if this object contains a given property value.
- *
+ *
* @param value The value to test.
* @return True if this object contains the given value.
*/
public boolean containsValue(String value)
{
if (value == null)
- {
- return false;
- }
+ return false;
return props.containsValue(value);
}
/**
* Adds a new property to this object.
- *
+ *
* @param key The key, which can neither be null nor empty.
* @param value The value, which cannot be null.
* @return The old value mapped by the key, if any.
- * @throws IllegalArgumentException If either the key or value parameter
-
- * is null, or if the key is empty.
+ * @throws IllegalArgumentException If either the key or value parameter is
+ * null, or if the key is empty.
*/
public String put(String key, String value)
{
if (key == null || value == null || key.length() == 0)
- {
- throw new IllegalArgumentException("key nor value can be null");
- }
+ throw new IllegalArgumentException("key nor value can be null");
return (String) props.put(canonicalize(key), value);
}
/**
- * Returns the value mapped by the given key, or null if there is no
- * such mapping.
- *
+ * Returns the value mapped by the given key, or null if there is no such
+ * mapping.
+ *
* @param key
*/
public String get(String key)
{
if (key == null || key.length() == 0)
- {
- return null;
- }
+ return null;
return (String) props.get(canonicalize(key));
}
/**
* Removes a key and its value from this object.
- *
+ *
* @param key The key of the property to remove.
* @return The old value mapped by the key, if any.
*/
public String remove(String key)
{
if (key == null || key.length() == 0)
- {
- return null;
- }
+ return null;
return (String) props.remove(canonicalize(key));
}
/**
* Decodes a set of properties from the given input stream.
- *
+ *
* @param in The input stream.
* @throws IOException If an I/O error occurs.
*/
@@ -184,7 +163,7 @@ public class Properties implements Cloneable
int len = in.readInt();
MeteredInputStream min = new MeteredInputStream(in, len);
DataInputStream in2 = new DataInputStream(min);
- while (!min.limitReached())
+ while (! min.limitReached())
{
String name = in2.readUTF();
String value = in2.readUTF();
@@ -194,7 +173,7 @@ public class Properties implements Cloneable
/**
* Encodes this set of properties to the given output stream.
- *
+ *
* @param out The output stream to encode to.
* @throws IOException If an I/O error occurs.
*/
@@ -217,9 +196,6 @@ public class Properties implements Cloneable
return props.toString();
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private String canonicalize(String key)
{
return key.toLowerCase();
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java
index 528e70cc648..3e7f54d3e20 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PublicKeyEntry.java
@@ -38,43 +38,30 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import java.security.PublicKey;
-import java.security.KeyFactory;
-import java.security.spec.X509EncodedKeySpec;
-
-import java.util.Date;
-
import gnu.java.security.key.IKeyPairCodec;
import gnu.java.security.key.KeyPairCodecFactory;
import gnu.java.security.key.dss.DSSPublicKey;
import gnu.java.security.key.rsa.GnuRSAPublicKey;
import gnu.javax.crypto.key.dh.GnuDHPublicKey;
-public final class PublicKeyEntry extends PrimitiveEntry
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.security.KeyFactory;
+import java.security.PublicKey;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Date;
+public final class PublicKeyEntry
+ extends PrimitiveEntry
+{
public static final int TYPE = 6;
-
private PublicKey key;
- // Constructor.
- // ------------------------------------------------------------------------
-
public PublicKeyEntry(PublicKey key, Date creationDate, Properties properties)
{
super(TYPE, creationDate, properties);
-
if (key == null)
- {
- throw new IllegalArgumentException("no key specified");
- }
+ throw new IllegalArgumentException("no key specified");
this.key = key;
}
@@ -83,18 +70,13 @@ public final class PublicKeyEntry extends PrimitiveEntry
super(TYPE);
}
- // Class method.
- // ------------------------------------------------------------------------
-
public static PublicKeyEntry decode(DataInputStream in) throws IOException
{
PublicKeyEntry entry = new PublicKeyEntry();
entry.defaultDecode(in);
String type = entry.properties.get("type");
if (type == null)
- {
- throw new MalformedKeyringException("no key type");
- }
+ throw new MalformedKeyringException("no key type");
if (type.equalsIgnoreCase("RAW-DSS"))
{
IKeyPairCodec coder = KeyPairCodecFactory.getInstance("dss");
@@ -125,33 +107,23 @@ public final class PublicKeyEntry extends PrimitiveEntry
try
{
KeyFactory kf = KeyFactory.getInstance("DSA");
- entry.key = kf.generatePublic(new X509EncodedKeySpec(
- entry.payload));
+ entry.key = kf.generatePublic(new X509EncodedKeySpec(entry.payload));
}
catch (Exception x)
{
}
if (entry.key == null)
- {
- throw new MalformedKeyringException(
- "could not decode X.509 key");
- }
+ throw new MalformedKeyringException("could not decode X.509 key");
}
}
else
- {
- throw new MalformedKeyringException("unsupported public key type: "
- + type);
- }
+ throw new MalformedKeyringException("unsupported public key type: " + type);
return entry;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Returns the public key.
- *
+ *
* @return The public key.
*/
public PublicKey getKey()
@@ -185,8 +157,6 @@ public final class PublicKeyEntry extends PrimitiveEntry
payload = key.getEncoded();
}
else
- {
- throw new IllegalArgumentException("cannot encode public key");
- }
+ throw new IllegalArgumentException("cannot encode public key");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/kwa/AESKeyWrap.java b/libjava/classpath/gnu/javax/crypto/kwa/AESKeyWrap.java
new file mode 100644
index 00000000000..bb86c5477aa
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java b/libjava/classpath/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java
new file mode 100644
index 00000000000..206e01d13da
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java b/libjava/classpath/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java
new file mode 100644
index 00000000000..d9c2bed14d5
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/kwa/KeyUnwrappingException.java b/libjava/classpath/gnu/javax/crypto/kwa/KeyUnwrappingException.java
new file mode 100644
index 00000000000..54b4aff0a62
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java b/libjava/classpath/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java
new file mode 100644
index 00000000000..6f6cd121944
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/kwa/TripleDESKeyWrap.java b/libjava/classpath/gnu/javax/crypto/kwa/TripleDESKeyWrap.java
new file mode 100644
index 00000000000..71562bd752b
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/crypto/mac/BaseMac.java b/libjava/classpath/gnu/javax/crypto/mac/BaseMac.java
index 1b42a1644c9..16922130fb6 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/BaseMac.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/BaseMac.java
@@ -40,35 +40,26 @@ package gnu.javax.crypto.mac;
import gnu.java.security.hash.IMessageDigest;
-import java.util.Map;
import java.security.InvalidKeyException;
+import java.util.Map;
/**
- * <p>A base abstract class to facilitate <i>MAC</i> (Message Authentication
- * Code) implementations.</p>
+ * A base abstract class to facilitate <i>MAC</i> (Message Authentication Code)
+ * implementations.
*/
-public abstract class BaseMac implements IMac
+public abstract class BaseMac
+ implements IMac
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The canonical name prefix of the <i>MAC</i>. */
protected String name;
-
/** Reference to the underlying hash algorithm instance. */
protected IMessageDigest underlyingHash;
-
/** The length of the truncated output in bytes. */
protected int truncatedSize;
- /** The authentication key for this instance. */
- // protected transient byte[] K;
- // Constructor(s)
- // -------------------------------------------------------------------------
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name of this instance.
*/
protected BaseMac(String name)
@@ -79,8 +70,8 @@ public abstract class BaseMac implements IMac
}
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name of this instance.
* @param underlyingHash the underlying message digest algorithm instance.
*/
@@ -89,20 +80,10 @@ public abstract class BaseMac implements IMac
this(name);
if (underlyingHash != null)
- {
- truncatedSize = underlyingHash.hashSize();
- }
+ truncatedSize = underlyingHash.hashSize();
this.underlyingHash = underlyingHash;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.mac.IMac interface implementation ----------------------------
-
public String name()
{
return name;
@@ -137,12 +118,10 @@ public abstract class BaseMac implements IMac
return result;
}
- // methods to be implemented by concrete subclasses ------------------------
-
public abstract void init(Map attributes) throws InvalidKeyException,
IllegalStateException;
public abstract byte[] digest();
public abstract boolean selfTest();
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/HMac.java b/libjava/classpath/gnu/javax/crypto/mac/HMac.java
index c1f97b54195..f0e588d1831 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/HMac.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/HMac.java
@@ -48,70 +48,51 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>The implementation of the <i>HMAC</i> (Keyed-Hash Message Authentication
- * Code).</p>
- *
- * <p><i>HMAC</i> can be used in combination with any iterated cryptographic
- * hash function. <i>HMAC</i> also uses a <i>secret key</i> for calculation and
+ * The implementation of the <i>HMAC</i> (Keyed-Hash Message Authentication
+ * Code).
+ * <p>
+ * <i>HMAC</i> can be used in combination with any iterated cryptographic hash
+ * function. <i>HMAC</i> also uses a <i>secret key</i> for calculation and
* verification of the message authentication values. The main goals behind this
- * construction are</p>
- *
+ * construction are:
* <ul>
- * <li>To use, without modifications, available hash functions. In
- * particular, hash functions that perform well in software, and for which
- * code is freely and widely available.</li>
- *
- * <li>To preserve the original performance of the hash function without
- * incurring a significant degradation.</li>
- *
- * <li>To use and handle keys in a simple way.</li>
- *
- * <li>To have a well understood cryptographic analysis of the strength of
- * the authentication mechanism based on reasonable assumptions on the
- * underlying hash function.</li>
- *
- * <li>To allow for easy replaceability of the underlying hash function in
- * case that faster or more secure hash functions are found or required.</li>
+ * <li>To use, without modifications, available hash functions. In particular,
+ * hash functions that perform well in software, and for which code is freely
+ * and widely available.</li>
+ * <li>To preserve the original performance of the hash function without
+ * incurring a significant degradation.</li>
+ * <li>To use and handle keys in a simple way.</li>
+ * <li>To have a well understood cryptographic analysis of the strength of the
+ * authentication mechanism based on reasonable assumptions on the underlying
+ * hash function.</li>
+ * <li>To allow for easy replaceability of the underlying hash function in case
+ * that faster or more secure hash functions are found or required.</li>
* </ul>
- *
- * <p>References:</p>
- *
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc-2104.txt">RFC 2104</a>HMAC:
- * Keyed-Hashing for Message Authentication.<br>
- * H. Krawczyk, M. Bellare, and R. Canetti.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc-2104.txt">RFC 2104</a>HMAC:
+ * Keyed-Hashing for Message Authentication.<br>
+ * H. Krawczyk, M. Bellare, and R. Canetti.</li>
* </ol>
*/
-public class HMac extends BaseMac implements Cloneable
+public class HMac
+ extends BaseMac
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String USE_WITH_PKCS5_V2 = "gnu.crypto.hmac.pkcs5";
-
private static final byte IPAD_BYTE = 0x36;
-
private static final byte OPAD_BYTE = 0x5C;
-
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
protected int macSize;
-
protected int blockSize;
-
protected IMessageDigest ipadHash;
-
protected IMessageDigest opadHash;
-
protected byte[] ipad;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
+ * Trivial constructor for use by concrete subclasses.
*
* @param underlyingHash the underlying hash algorithm instance.
*/
@@ -124,14 +105,6 @@ public class HMac extends BaseMac implements Cloneable
ipadHash = opadHash = null;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone() throws CloneNotSupportedException
{
HMac result = (HMac) super.clone();
@@ -145,88 +118,65 @@ public class HMac extends BaseMac implements Cloneable
return result;
}
- // implementation of abstract methods in BaseMac ---------------------------
-
public void init(Map attributes) throws InvalidKeyException,
IllegalStateException
{
Integer ts = (Integer) attributes.get(TRUNCATED_SIZE);
truncatedSize = (ts == null ? macSize : ts.intValue());
if (truncatedSize < (macSize / 2))
- {
- throw new IllegalArgumentException("Truncated size too small");
- }
+ throw new IllegalArgumentException("Truncated size too small");
else if (truncatedSize < 10)
- {
- throw new IllegalArgumentException("Truncated size less than 80 bits");
- }
+ throw new IllegalArgumentException("Truncated size less than 80 bits");
// we dont use/save the key outside this method
byte[] K = (byte[]) attributes.get(MAC_KEY_MATERIAL);
if (K == null)
{ // take it as an indication to re-use previous key if set
if (ipadHash == null)
- {
- throw new InvalidKeyException("Null key");
- }
+ throw new InvalidKeyException("Null key");
// we already went through the motions; ie. up to step #4. re-use
underlyingHash = (IMessageDigest) ipadHash.clone();
return;
}
- // for HMACs used in key-derivation functions (e.g. PBKDF2) the key
- // material need not be >= the (output) block size of the underlying
- // algorithm
+ // for HMACs used in key-derivation functions (e.g. PBKDF2) the key material
+ // need not be >= the (output) block size of the underlying algorithm
Boolean pkcs5 = (Boolean) attributes.get(USE_WITH_PKCS5_V2);
if (pkcs5 == null)
- {
- pkcs5 = Boolean.FALSE;
- }
- if (K.length < macSize && !pkcs5.booleanValue())
- {
- throw new InvalidKeyException("Key too short");
- }
+ pkcs5 = Boolean.FALSE;
+ if (K.length < macSize && ! pkcs5.booleanValue())
+ throw new InvalidKeyException("Key too short");
if (K.length > blockSize)
{
- // (0) replace K with HASH(K) if K is larger than the hash's
- // block size. Then pad with zeros until it is the correct
- // size (the next `if').
+ // (0) replace K with HASH(K) if K is larger than the hash's block size.
+ // Then pad with zeros until it is the correct size (the next `if').
underlyingHash.update(K, 0, K.length);
K = underlyingHash.digest();
}
if (K.length < blockSize)
{
- // (1) append zeros to the end of K to create a B byte string
- // (e.g., if K is of length 20 bytes and B=64, then K will be
- // appended with 44 zero bytes 0x00)
+ // (1) append zeros to the end of K to create a B byte string (e.g., if
+ // K is of length 20 bytes and B=64, then K will be appended with 44
+ // zero bytes 0x00)
int limit = (K.length > blockSize) ? blockSize : K.length;
byte[] newK = new byte[blockSize];
System.arraycopy(K, 0, newK, 0, limit);
K = newK;
}
-
underlyingHash.reset();
opadHash = (IMessageDigest) underlyingHash.clone();
if (ipad == null)
- {
- ipad = new byte[blockSize];
- }
- // (2) XOR (bitwise exclusive-OR) the B byte string computed in step
- // (1) with ipad
- // (3) append the stream of data 'text' to the B byte string resulting
- // from step (2)
+ ipad = new byte[blockSize];
+ // (2) XOR (bitwise exclusive-OR) the B byte string computed in step (1)
+ // with ipad
+ // (3) append the stream of data 'text' to the B byte string resulting from
+ // step (2)
// (4) apply H to the stream generated in step (3)
for (int i = 0; i < blockSize; i++)
- {
- // underlyingHash.update((byte)(K[i] ^ IPAD_BYTE));
- ipad[i] = (byte) (K[i] ^ IPAD_BYTE);
- }
+ ipad[i] = (byte)(K[i] ^ IPAD_BYTE);
for (int i = 0; i < blockSize; i++)
- {
- opadHash.update((byte) (K[i] ^ OPAD_BYTE));
- }
-
+ opadHash.update((byte)(K[i] ^ OPAD_BYTE));
underlyingHash.update(ipad, 0, blockSize);
ipadHash = (IMessageDigest) underlyingHash.clone();
K = null;
@@ -245,28 +195,21 @@ public class HMac extends BaseMac implements Cloneable
public byte[] digest()
{
if (ipadHash == null)
- {
- throw new IllegalStateException("HMAC not initialised");
- }
-
+ throw new IllegalStateException("HMAC not initialised");
byte[] out = underlyingHash.digest();
- // (5) XOR (bitwise exclusive-OR) the B byte string computed in
- // step (1) with opad
+ // (5) XOR (bitwise exclusive-OR) the B byte string computed in step (1)
+ // with opad
underlyingHash = (IMessageDigest) opadHash.clone();
- // (6) append the H result from step (4) to the B byte string
- // resulting from step (5)
+ // (6) append the H result from step (4) to the B byte string resulting from
+ // step (5)
underlyingHash.update(out, 0, macSize);
- // (7) apply H to the stream generated in step (6) and output
- // the result
+ // (7) apply H to the stream generated in step (6) and output the result
out = underlyingHash.digest(); // which also resets the underlying hash
-
// truncate and return
if (truncatedSize == macSize)
return out;
-
byte[] result = new byte[truncatedSize];
System.arraycopy(out, 0, result, 0, truncatedSize);
-
return result;
}
@@ -279,31 +222,25 @@ public class HMac extends BaseMac implements Cloneable
IMac mac = new HMac(new MD5()); // use rfc-2104 test vectors
String tv1 = "9294727A3638BB1C13F48EF8158BFC9D";
String tv3 = "56BE34521D144C88DBB8C733F0E8B3F6";
- byte[] k1 = new byte[] { 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
- 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
- 0x0B, 0x0B };
- byte[] k3 = new byte[] { (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
- (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
- (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
- (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
- (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
- (byte) 0xAA };
+ byte[] k1 = new byte[] {
+ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
+ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B };
+ byte[] k3 = new byte[] {
+ (byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
+ (byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
+ (byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0xAA,
+ (byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0xAA };
byte[] data = new byte[50];
for (int i = 0; i < 50;)
- {
- data[i++] = (byte) 0xDD;
- }
+ data[i++] = (byte) 0xDD;
HashMap map = new HashMap();
-
// test vector #1
map.put(MAC_KEY_MATERIAL, k1);
mac.init(map);
mac.update("Hi There".getBytes("ASCII"), 0, 8);
- if (!tv1.equals(Util.toString(mac.digest())))
- {
- valid = Boolean.FALSE;
- }
+ if (! tv1.equals(Util.toString(mac.digest())))
+ valid = Boolean.FALSE;
// test #2 is not used since it causes a "Key too short" exception
@@ -311,10 +248,8 @@ public class HMac extends BaseMac implements Cloneable
map.put(MAC_KEY_MATERIAL, k3);
mac.init(map);
mac.update(data, 0, 50);
- if (!tv3.equals(Util.toString(mac.digest())))
- {
- valid = Boolean.FALSE;
- }
+ if (! tv3.equals(Util.toString(mac.digest())))
+ valid = Boolean.FALSE;
valid = Boolean.TRUE;
}
catch (Exception x)
diff --git a/libjava/classpath/gnu/javax/crypto/mac/HMacFactory.java b/libjava/classpath/gnu/javax/crypto/mac/HMacFactory.java
index 156e6ced5e7..bc70e8b66ed 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/HMacFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/HMacFactory.java
@@ -47,68 +47,56 @@ import java.util.Iterator;
import java.util.Set;
/**
- * <p>A <i>Factory</i> to instantiate Keyed-Hash Message Authentication Code
- * (HMAC) algorithm instances.</p>
+ * A <i>Factory</i> to instantiate Keyed-Hash Message Authentication Code
+ * (HMAC) algorithm instances.
*/
-public class HMacFactory implements Registry
+public class HMacFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
private HMacFactory()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Return an instance of a <i>HMAC</i> algorithm given the name of its
+ * Return an instance of a <i>HMAC</i> algorithm given the name of its
* underlying hash function, prefixed with the literal defined in
- * {@link Registry#HMAC_NAME_PREFIX}.</p>
- *
+ * {@link Registry#HMAC_NAME_PREFIX}.
+ *
* @param name the fully qualified name of the underlying algorithm: composed
- * as the concatenation of a literal prefix (see {@link Registry#HMAC_NAME_PREFIX})
- * and the name of the underlying hash algorithm.
- * @return an instance of the <i>HMAC</i> algorithm, or <code>null</code> if
- * none can be constructed.
+ * as the concatenation of a literal prefix (see
+ * {@link Registry#HMAC_NAME_PREFIX}) and the name of the underlying
+ * hash algorithm.
+ * @return an instance of the <i>HMAC</i> algorithm, or <code>null</code>
+ * if none can be constructed.
* @exception InternalError if the implementation does not pass its self-test.
*/
public static IMac getInstance(String name)
{
if (name == null)
- {
- return null;
- }
+ return null;
name = name.trim();
name = name.toLowerCase();
- if (!name.startsWith(HMAC_NAME_PREFIX))
- {
- return null;
- }
+ if (! name.startsWith(HMAC_NAME_PREFIX))
+ return null;
// strip the prefix
name = name.substring(HMAC_NAME_PREFIX.length()).trim();
IMac result = new HMac(HashFactory.getInstance(name));
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link java.util.Set} of names of <i>HMAC</i> algorithms
- * supported by this <i>Factory</i>.</p>
- *
+ * <p>
+ * Returns a {@link java.util.Set} of names of <i>HMAC</i> algorithms
+ * supported by this <i>Factory</i>.
+ * </p>
+ *
* @return a {@link java.util.Set} of HMAC algorithm names (Strings).
*/
public static final Set getNames()
@@ -116,13 +104,8 @@ public class HMacFactory implements Registry
Set hashNames = HashFactory.getNames();
HashSet hs = new HashSet();
for (Iterator it = hashNames.iterator(); it.hasNext();)
- {
- hs.add(HMAC_NAME_PREFIX + ((String) it.next()));
- }
+ hs.add(HMAC_NAME_PREFIX + ((String) it.next()));
return Collections.unmodifiableSet(hs);
}
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/IMac.java b/libjava/classpath/gnu/javax/crypto/mac/IMac.java
index c4170c42ce9..a9da9eefb63 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/IMac.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/IMac.java
@@ -38,108 +38,93 @@ exception statement from your version. */
package gnu.javax.crypto.mac;
-import java.util.Map;
import java.security.InvalidKeyException;
+import java.util.Map;
/**
- * <p>The basic visible methods of any MAC (Message Authentication Code)
- * algorithm.</p>
- *
- * <p>A <i>MAC</i> provides a way to check the integrity of information
+ * The basic visible methods of any MAC (Message Authentication Code) algorithm.
+ * <p>
+ * A <i>MAC</i> provides a way to check the integrity of information
* transmitted over, or stored in, an unreliable medium, based on a secret key.
* Typically, <i>MAC</i>s are used between two parties, that share a common
- * secret key, in order to validate information transmitted between them.</p>
- *
- * <p>When a <i>MAC</i> algorithm is based on a cryptographic hash function, it
- * is then called to a <i>HMAC</i> (Hashed Message Authentication Code) --see
- * <a href="http://www.ietf.org/rfc/rfc-2104.txt">RFC-2104</a>.</p>
- *
+ * secret key, in order to validate information transmitted between them.
+ * <p>
+ * When a <i>MAC</i> algorithm is based on a cryptographic hash function, it is
+ * then called to a <i>HMAC</i> (Hashed Message Authentication Code) --see <a
+ * href="http://www.ietf.org/rfc/rfc-2104.txt">RFC-2104</a>.
+ * <p>
* Another type of <i>MAC</i> algorithms exist: UMAC or <i>Universal Message
- * Authentication Code</i>, described in
- * <a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
- * draft-krovetz-umac-01.txt</a>.</p>
- *
- * <p>With <i>UMAC</i>s, the sender and receiver share a common secret key (the
- * <i>MAC</i> key) which determines:</p>
- *
+ * Authentication Code</i>, described in <a
+ * href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
+ * draft-krovetz-umac-01.txt</a>.
+ * <p>
+ * With <i>UMAC</i>s, the sender and receiver share a common secret key (the
+ * <i>MAC</i> key) which determines:
* <ul>
- * <li>The key for a <i>universal hash function</i>. This hash function is
- * <i>non-cryptographic</i>, in the sense that it does not need to have any
- * cryptographic <i>hardness</i> property. Rather, it needs to satisfy some
- * combinatorial property, which can be proven to hold without relying on
- * unproven hardness assumptions.</li>
- *
- * <li>The key for a <i>pseudorandom function</i>. This is where one needs a
- * cryptographic hardness assumption. The pseudorandom function may be
- * obtained from a <i>block cipher</i> or a <i>cryptographic hash function</i>.
- * </li>
+ * <li>The key for a <i>universal hash function</i>. This hash function is
+ * <i>non-cryptographic</i>, in the sense that it does not need to have any
+ * cryptographic <i>hardness</i> property. Rather, it needs to satisfy some
+ * combinatorial property, which can be proven to hold without relying on
+ * unproven hardness assumptions.</li>
+ * <li>The key for a <i>pseudorandom function</i>. This is where one needs a
+ * cryptographic hardness assumption. The pseudorandom function may be obtained
+ * from a <i>block cipher</i> or a <i>cryptographic hash function</i>. </li>
* </ul>
- *
- * <p>References:</p>
- *
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc-2104.txt">RFC 2104</a>HMAC:
- * Keyed-Hashing for Message Authentication.<br>
- * H. Krawczyk, M. Bellare, and R. Canetti.</li>
- *
- * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
- * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
- * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc-2104.txt">RFC 2104</a>HMAC:
+ * Keyed-Hashing for Message Authentication.<br>
+ * H. Krawczyk, M. Bellare, and R. Canetti.</li>
+ * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
+ * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
+ * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
* </ol>
*/
public interface IMac
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/**
* Property name of the user-supplied key material. The value associated to
* this property name is taken to be a byte array.
*/
String MAC_KEY_MATERIAL = "gnu.crypto.mac.key.material";
-
/**
- * <p>Property name of the desired truncated output size in bytes. The value
- * associated to this property name is taken to be an integer. If no value
- * is specified in the attributes map at initialisation time, then all bytes
- * of the underlying hash algorithm's output are emitted.</p>
- *
- * <p>This implementation, follows the recommendation of the <i>RFC 2104</i>
- * authors; specifically:</p>
- *
+ * Property name of the desired truncated output size in bytes. The value
+ * associated to this property name is taken to be an integer. If no value is
+ * specified in the attributes map at initialisation time, then all bytes of
+ * the underlying hash algorithm's output are emitted.
+ * <p>
+ * This implementation, follows the recommendation of the <i>RFC 2104</i>
+ * authors; specifically:
* <pre>
- * We recommend that the output length t be not less than half the
- * length of the hash output (to match the birthday attack bound)
- * and not less than 80 bits (a suitable lower bound on the number
- * of bits that need to be predicted by an attacker).
+ * We recommend that the output length t be not less than half the
+ * length of the hash output (to match the birthday attack bound)
+ * and not less than 80 bits (a suitable lower bound on the number
+ * of bits that need to be predicted by an attacker).
* </pre>
*/
String TRUNCATED_SIZE = "gnu.crypto.mac.truncated.size";
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the canonical name of this algorithm.</p>
- *
+ * Returns the canonical name of this algorithm.
+ *
* @return the canonical name of this algorithm.
*/
String name();
/**
- * <p>Returns the output length in bytes of this <i>MAC</i> algorithm.</p>
- *
+ * Returns the output length in bytes of this <i>MAC</i> algorithm.
+ *
* @return the output length in bytes of this <i>MAC</i> algorithm.
*/
int macSize();
/**
- * <p>Initialises the algorithm with designated attributes. Permissible names
- * and values are described in the class documentation above.</p>
- *
+ * Initialises the algorithm with designated attributes. Permissible names and
+ * values are described in the class documentation above.
+ *
* @param attributes a set of name-value pairs that describe the desired
- * future instance behaviour.
+ * future instance behaviour.
* @exception InvalidKeyException if the key data is invalid.
* @exception IllegalStateException if the instance is already initialised.
* @see #MAC_KEY_MATERIAL
@@ -147,18 +132,17 @@ public interface IMac
void init(Map attributes) throws InvalidKeyException, IllegalStateException;
/**
- * <p>Continues a <i>MAC</i> operation using the input byte.</p>
- *
+ * Continues a <i>MAC</i> operation using the input byte.
+ *
* @param b the input byte to digest.
*/
void update(byte b);
/**
- * <p>Continues a <i>MAC</i> operation, by filling the buffer, processing
- * data in the algorithm's MAC_SIZE-bit block(s), updating the context and
- * count, and buffering the remaining bytes in buffer for the next
- * operation.</p>
- *
+ * Continues a <i>MAC</i> operation, by filling the buffer, processing data
+ * in the algorithm's MAC_SIZE-bit block(s), updating the context and count,
+ * and buffering the remaining bytes in buffer for the next operation.
+ *
* @param in the input block.
* @param offset start of meaningful bytes in input block.
* @param length number of bytes, in input block, to consider.
@@ -166,32 +150,32 @@ public interface IMac
void update(byte[] in, int offset, int length);
/**
- * <p>Completes the <i>MAC</i> by performing final operations such as
- * padding and resetting the instance.</p>
- *
+ * Completes the <i>MAC</i> by performing final operations such as padding
+ * and resetting the instance.
+ *
* @return the array of bytes representing the <i>MAC</i> value.
*/
byte[] digest();
/**
- * <p>Resets the algorithm instance for re-initialisation and use with other
- * characteristics. This method always succeeds.</p>
+ * Resets the algorithm instance for re-initialisation and use with other
+ * characteristics. This method always succeeds.
*/
void reset();
/**
- * <p>A basic test. Ensures that the MAC of a pre-determined message is equal
- * to a known pre-computed value.</p>
- *
+ * A basic test. Ensures that the MAC of a pre-determined message is equal to
+ * a known pre-computed value.
+ *
* @return <code>true</code> if the implementation passes a basic self-test.
- * Returns <code>false</code> otherwise.
+ * Returns <code>false</code> otherwise.
*/
boolean selfTest();
/**
- * <p>Returns a clone copy of this instance.</p>
- *
+ * Returns a clone copy of this instance.
+ *
* @return a clone copy of this instance.
*/
Object clone() throws CloneNotSupportedException;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/MacFactory.java b/libjava/classpath/gnu/javax/crypto/mac/MacFactory.java
index d8f8bcfcee6..5d4a561824e 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/MacFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/MacFactory.java
@@ -48,17 +48,13 @@ import java.util.Iterator;
import java.util.Set;
/**
- * <p>A <i>Factory</i> that instantiates instances of every supported Message
- * Authentication Code algorithms, including all <i>HMAC</i> algorithms.</p>
+ * A <i>Factory</i> that instantiates instances of every supported Message
+ * Authentication Code algorithms, including all <i>HMAC</i> algorithms.
*/
-public class MacFactory implements Registry
+public class MacFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ private static Set names;
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
private MacFactory()
@@ -66,72 +62,51 @@ public class MacFactory implements Registry
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a <i>MAC</i> algorithm given its name.</p>
- *
+ * Returns an instance of a <i>MAC</i> algorithm given its name.
+ *
* @param name the name of the MAC algorithm.
* @return an instance of the <i>MAC</i> algorithm, or <code>null</code> if
- * none can be constructed.
+ * none can be constructed.
* @exception InternalError if the implementation does not pass its self-test.
*/
public static IMac getInstance(String name)
{
if (name == null)
- {
- return null;
- }
+ return null;
name = name.trim();
name = name.toLowerCase();
if (name.startsWith(HMAC_NAME_PREFIX))
- {
- return HMacFactory.getInstance(name);
- }
+ return HMacFactory.getInstance(name);
if (name.startsWith(OMAC_PREFIX))
{
name = name.substring(OMAC_PREFIX.length());
IBlockCipher cipher = CipherFactory.getInstance(name);
if (cipher == null)
- {
- return null;
- }
+ return null;
return new OMAC(cipher);
}
-
IMac result = null;
if (name.equalsIgnoreCase(UHASH32))
- {
- result = new UHash32();
- }
+ result = new UHash32();
else if (name.equalsIgnoreCase(UMAC32))
- {
- result = new UMac32();
- }
+ result = new UMac32();
else if (name.equalsIgnoreCase(TMMH16))
- {
- result = new TMMH16();
- }
- // else if (name.equalsIgnoreCase(TMMH32)) {
- // result = new TMMH32();
- // }
+ result = new TMMH16();
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link java.util.Set} of names of <i>MAC</i> algorithms
- * supported by this <i>Factory</i>.</p>
- *
- * @return a {@link java.util.Set} of MAC names (Strings).
+ * Returns a {@link Set} of names of <i>MAC</i> algorithms supported by this
+ * <i>Factory</i>.
+ *
+ * @return a {@link Set} of MAC names (Strings).
*/
public static final Set getNames()
{
@@ -144,21 +119,12 @@ public class MacFactory implements Registry
hs.add(UHASH32);
hs.add(UMAC32);
hs.add(TMMH16);
- // hs.add(TMMH32);
-
for (Iterator it = CipherFactory.getNames().iterator(); it.hasNext();)
- {
- hs.add(OMAC_PREFIX + it.next());
- }
+ hs.add(OMAC_PREFIX + it.next());
names = Collections.unmodifiableSet(hs);
}
}
return names;
}
-
- private static Set names;
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/MacInputStream.java b/libjava/classpath/gnu/javax/crypto/mac/MacInputStream.java
index 9acd18b19af..e734b1bbb4b 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/MacInputStream.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/MacInputStream.java
@@ -46,30 +46,19 @@ import java.io.IOException;
* A filtering input stream that computes a MAC (message authentication code)
* over all data read from the stream.
*/
-public class MacInputStream extends FilterInputStream
+public class MacInputStream
+ extends FilterInputStream
{
-
- // Field.
- // ------------------------------------------------------------------------
-
- /**
- * The digesting state. The MAC is updated only if this flag is true.
- */
+ /** The digesting state. The MAC is updated only if this flag is true. */
private boolean digesting;
-
- /**
- * The MAC being updated.
- */
+ /** The MAC being updated. */
private IMac mac;
- // Constructor.
- // ------------------------------------------------------------------------
-
/**
- * Creates a new MacInputStream. The stream is initially set to digest
- * data written, the <i>mac</i> argument must have already been initialized,
- * and the <i>mac</i> argument is <b>not</b> cloned.
- *
+ * Creates a new MacInputStream. The stream is initially set to digest data
+ * written, the <i>mac</i> argument must have already been initialized, and
+ * the <i>mac</i> argument is <b>not</b> cloned.
+ *
* @param in The underlying input stream.
* @param mac The mac instance to use.
*/
@@ -82,12 +71,9 @@ public class MacInputStream extends FilterInputStream
digesting = true;
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
/**
* Returns the MAC this stream is updating.
- *
+ *
* @return The MAC.
*/
public IMac getMac()
@@ -98,7 +84,7 @@ public class MacInputStream extends FilterInputStream
/**
* Sets the MAC this stream is updating, which must have already been
* initialized. The argument is not cloned by this method.
- *
+ *
* @param mac The new MAC.
* @throws NullPointerException If the argument is null.
*/
@@ -110,9 +96,9 @@ public class MacInputStream extends FilterInputStream
}
/**
- * Turns the digesting state on or off. When off, the MAC will not be
- * updated when data is written to the stream.
- *
+ * Turns the digesting state on or off. When off, the MAC will not be updated
+ * when data is written to the stream.
+ *
* @param flag The new digesting state.
*/
public void on(boolean flag)
@@ -135,4 +121,4 @@ public class MacInputStream extends FilterInputStream
mac.update(buf, off, i);
return i;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/MacOutputStream.java b/libjava/classpath/gnu/javax/crypto/mac/MacOutputStream.java
index a48d25ba3a5..739a78497a7 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/MacOutputStream.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/MacOutputStream.java
@@ -43,29 +43,23 @@ import java.io.IOException;
import java.io.OutputStream;
/**
- * <p>A filtering output stream that computes a MAC (message authentication
- * code) over all data written to the stream.</p>
+ * A filtering output stream that computes a MAC (message authentication code)
+ * over all data written to the stream.
*/
-public class MacOutputStream extends FilterOutputStream
+public class MacOutputStream
+ extends FilterOutputStream
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The digesting state. The MAC is updated only if this flag is true. */
private boolean digesting;
-
/** The MAC being updated. */
private IMac mac;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Creates a new <code>MacOutputStream</code>. The stream is initially set
+ * Creates a new <code>MacOutputStream</code>. The stream is initially set
* to digest data written, the <code>mac</code> argument must have already
- * been initialized, and the <code>mac</code> argument is <b>not</b> cloned.</p>
- *
+ * been initialized, and the <code>mac</code> argument is <b>not</b>
+ * cloned.
+ *
* @param out The underlying output stream.
* @param mac The mac instance to use.
*/
@@ -73,19 +67,14 @@ public class MacOutputStream extends FilterOutputStream
{
super(out);
if (mac == null)
- {
- throw new NullPointerException();
- }
+ throw new NullPointerException();
this.mac = mac;
digesting = true;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the MAC this stream is updating.</p>
- *
+ * Returns the MAC this stream is updating.
+ *
* @return The MAC.
*/
public IMac getMac()
@@ -94,25 +83,23 @@ public class MacOutputStream extends FilterOutputStream
}
/**
- * <p>Sets the MAC this stream is updating, which must have already been
- * initialized. The argument is not cloned by this method.</p>
- *
+ * Sets the MAC this stream is updating, which must have already been
+ * initialized. The argument is not cloned by this method.
+ *
* @param mac The non-null new MAC.
* @throws NullPointerException If the argument is null.
*/
public void setMac(IMac mac)
{
if (mac == null)
- {
- throw new NullPointerException();
- }
+ throw new NullPointerException();
this.mac = mac;
}
/**
- * <p>Turns the digesting state on or off. When off, the MAC will not be
- * updated when data is written to the stream.</p>
- *
+ * Turns the digesting state on or off. When off, the MAC will not be updated
+ * when data is written to the stream.
+ *
* @param flag The new digesting state.
*/
public void on(boolean flag)
@@ -123,18 +110,14 @@ public class MacOutputStream extends FilterOutputStream
public void write(int b) throws IOException
{
if (digesting)
- {
- mac.update((byte) b);
- }
+ mac.update((byte) b);
out.write(b);
}
public void write(byte[] buf, int off, int len) throws IOException
{
if (digesting)
- {
- mac.update(buf, off, len);
- }
+ mac.update(buf, off, len);
out.write(buf, off, len);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/OMAC.java b/libjava/classpath/gnu/javax/crypto/mac/OMAC.java
index c83320a1bc4..cd753acafbc 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/OMAC.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/OMAC.java
@@ -38,88 +38,60 @@ exception statement from your version. */
package gnu.javax.crypto.mac;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.mode.IMode;
-import gnu.javax.crypto.mode.ModeFactory;
import java.security.InvalidKeyException;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Logger;
/**
- * <p>The One-Key CBC MAC, OMAC. This message authentication code is based on
- * a block cipher in CBC mode.</p>
- *
- * <p>References:</p>
+ * The One-Key CBC MAC, OMAC. This message authentication code is based on a
+ * block cipher in CBC mode.
+ * <p>
+ * References:
* <ol>
* <li>Tetsu Iwata and Kaoru Kurosawa, <i><a
* href="http://crypt.cis.ibaraki.ac.jp/omac/docs/omac.pdf">OMAC: One-Key CBC
* MAC</a></i>.</li>
* </ol>
*/
-public class OMAC implements IMac
+public class OMAC
+ implements IMac
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
-
- private static void debug(String msg)
- {
- System.out.print(">>> OMAC: ");
- System.out.println(msg);
- }
-
+ private static final Logger log = Logger.getLogger(OMAC.class.getName());
private static final byte C1 = (byte) 0x87;
-
private static final byte C2 = 0x1b;
-
// Test key for OMAC-AES-128
- private static final byte[] KEY0 = Util.toBytesFromString("2b7e151628aed2a6abf7158809cf4f3c");
-
+ private static final byte[] KEY0 =
+ Util.toBytesFromString("2b7e151628aed2a6abf7158809cf4f3c");
// Test MAC for zero-length input.
- private static final byte[] DIGEST0 = Util.toBytesFromString("bb1d6929e95937287fa37d129b756746");
-
+ private static final byte[] DIGEST0 =
+ Util.toBytesFromString("bb1d6929e95937287fa37d129b756746");
private static Boolean valid;
-
private final IBlockCipher cipher;
-
private final String name;
-
private IMode mode;
-
private int blockSize;
-
private int outputSize;
-
private byte[] Lu, Lu2;
-
private byte[] M;
-
private byte[] Y;
-
private boolean init;
-
private int index;
- // Constructor.
- // ------------------------------------------------------------------------
-
public OMAC(IBlockCipher cipher)
{
this.cipher = cipher;
this.name = "OMAC-" + cipher.name();
}
- // Instance methods.
- // ------------------------------------------------------------------------
-
public Object clone()
{
return new OMAC(cipher);
@@ -141,135 +113,89 @@ public class OMAC implements IMac
attrib2.put(IBlockCipher.KEY_MATERIAL, attrib.get(MAC_KEY_MATERIAL));
cipher.reset();
cipher.init(attrib2);
-
blockSize = cipher.currentBlockSize();
Integer os = (Integer) attrib.get(TRUNCATED_SIZE);
if (os != null)
{
outputSize = os.intValue();
if (outputSize < 0 || outputSize > blockSize)
- {
- throw new IllegalArgumentException("truncated size out of range");
- }
+ throw new IllegalArgumentException("truncated size out of range");
}
else
- {
- outputSize = blockSize;
- }
+ outputSize = blockSize;
byte[] L = new byte[blockSize];
cipher.encryptBlock(L, 0, L, 0);
-
- if (DEBUG)
- {
- debug("L = " + Util.toString(L).toLowerCase());
- }
-
+ if (Configuration.DEBUG)
+ log.fine("L = " + Util.toString(L).toLowerCase());
if (Lu != null)
{
Arrays.fill(Lu, (byte) 0);
if (Lu.length != blockSize)
- {
- Lu = new byte[blockSize];
- }
+ Lu = new byte[blockSize];
}
else
- {
- Lu = new byte[blockSize];
- }
+ Lu = new byte[blockSize];
if (Lu2 != null)
{
Arrays.fill(Lu2, (byte) 0);
if (Lu2.length != blockSize)
- {
- Lu2 = new byte[blockSize];
- }
+ Lu2 = new byte[blockSize];
}
else
- {
- Lu2 = new byte[blockSize];
- }
+ Lu2 = new byte[blockSize];
boolean msb = (L[0] & 0x80) != 0;
for (int i = 0; i < blockSize; i++)
{
- Lu[i] = (byte) (L[i] << 1 & 0xFF);
+ Lu[i] = (byte)(L[i] << 1 & 0xFF);
if (i + 1 < blockSize)
- {
- Lu[i] |= (byte) ((L[i + 1] & 0x80) >> 7);
- }
+ Lu[i] |= (byte)((L[i + 1] & 0x80) >> 7);
}
if (msb)
{
if (blockSize == 16)
- {
- Lu[Lu.length - 1] ^= C1;
- }
+ Lu[Lu.length - 1] ^= C1;
else if (blockSize == 8)
- {
- Lu[Lu.length - 1] ^= C2;
- }
+ Lu[Lu.length - 1] ^= C2;
else
- {
- throw new IllegalArgumentException(
- "unsupported cipher block size: "
- + blockSize);
- }
- }
- if (DEBUG)
- {
- debug("Lu = " + Util.toString(Lu).toLowerCase());
+ throw new IllegalArgumentException("unsupported cipher block size: "
+ + blockSize);
}
-
+ if (Configuration.DEBUG)
+ log.fine("Lu = " + Util.toString(Lu).toLowerCase());
msb = (Lu[0] & 0x80) != 0;
for (int i = 0; i < blockSize; i++)
{
- Lu2[i] = (byte) (Lu[i] << 1 & 0xFF);
+ Lu2[i] = (byte)(Lu[i] << 1 & 0xFF);
if (i + 1 < blockSize)
- {
- Lu2[i] |= (byte) ((Lu[i + 1] & 0x80) >> 7);
- }
+ Lu2[i] |= (byte)((Lu[i + 1] & 0x80) >> 7);
}
if (msb)
{
if (blockSize == 16)
- {
- Lu2[Lu2.length - 1] ^= C1;
- }
+ Lu2[Lu2.length - 1] ^= C1;
else
- {
- Lu2[Lu2.length - 1] ^= C2;
- }
- }
- if (DEBUG)
- {
- debug("Lu2 = " + Util.toString(Lu2).toLowerCase());
+ Lu2[Lu2.length - 1] ^= C2;
}
-
+ if (Configuration.DEBUG)
+ log.fine("Lu2 = " + Util.toString(Lu2).toLowerCase());
if (M != null)
{
Arrays.fill(M, (byte) 0);
if (M.length != blockSize)
- {
- M = new byte[blockSize];
- }
+ M = new byte[blockSize];
}
else
- {
- M = new byte[blockSize];
- }
+ M = new byte[blockSize];
if (Y != null)
{
Arrays.fill(Y, (byte) 0);
if (Y.length != blockSize)
- {
- Y = new byte[blockSize];
- }
+ Y = new byte[blockSize];
}
else
- {
- Y = new byte[blockSize];
- }
+ Y = new byte[blockSize];
index = 0;
init = true;
@@ -277,10 +203,8 @@ public class OMAC implements IMac
public void update(byte b)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
if (index == M.length)
{
process();
@@ -291,15 +215,11 @@ public class OMAC implements IMac
public void update(byte[] buf, int off, int len)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
if (off < 0 || len < 0 || off + len > buf.length)
- {
- throw new IndexOutOfBoundsException("size=" + buf.length + "; off="
- + off + "; len=" + len);
- }
+ throw new IndexOutOfBoundsException("size=" + buf.length + "; off=" + off
+ + "; len=" + len);
for (int i = 0; i < len;)
{
if (index == blockSize)
@@ -323,30 +243,22 @@ public class OMAC implements IMac
public void digest(byte[] out, int off)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
if (off < 0 || off + outputSize > out.length)
- {
- throw new IndexOutOfBoundsException("size=" + out.length + "; off="
- + off + "; len=" + outputSize);
- }
+ throw new IndexOutOfBoundsException("size=" + out.length + "; off=" + off
+ + "; len=" + outputSize);
byte[] T = new byte[blockSize];
byte[] L = Lu;
if (index < blockSize)
{
M[index++] = (byte) 0x80;
while (index < blockSize)
- {
- M[index++] = 0;
- }
+ M[index++] = 0;
L = Lu2;
}
for (int i = 0; i < blockSize; i++)
- {
- T[i] = (byte) (M[i] ^ Y[i] ^ L[i]);
- }
+ T[i] = (byte)(M[i] ^ Y[i] ^ L[i]);
cipher.encryptBlock(T, 0, T, 0);
System.arraycopy(T, 0, out, off, outputSize);
reset();
@@ -356,13 +268,9 @@ public class OMAC implements IMac
{
index = 0;
if (Y != null)
- {
- Arrays.fill(Y, (byte) 0);
- }
+ Arrays.fill(Y, (byte) 0);
if (M != null)
- {
- Arrays.fill(M, (byte) 0);
- }
+ Arrays.fill(M, (byte) 0);
}
public boolean selfTest()
@@ -382,21 +290,14 @@ public class OMAC implements IMac
return false;
}
if (digest == null)
- {
- return false;
- }
+ return false;
return Arrays.equals(DIGEST0, digest);
}
- // Own methods.
- // ------------------------------------------------------------------------
-
private void process()
{
for (int i = 0; i < blockSize; i++)
- {
- M[i] = (byte) (M[i] ^ Y[i]);
- }
+ M[i] = (byte)(M[i] ^ Y[i]);
cipher.encryptBlock(M, 0, Y, 0);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/TMMH16.java b/libjava/classpath/gnu/javax/crypto/mac/TMMH16.java
index af6e78fcf87..0a7b4a6caeb 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/TMMH16.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/TMMH16.java
@@ -46,91 +46,63 @@ import java.security.InvalidKeyException;
import java.util.Map;
/**
- * <p><i>TMMH</i> is a <i>universal</i> hash function suitable for message
+ * <i>TMMH</i> is a <i>universal</i> hash function suitable for message
* authentication in the Wegman-Carter paradigm, as in the Stream Cipher
* Security Transform. It is simple, quick, and especially appropriate for
* Digital Signal Processors and other processors with a fast multiply
* operation, though a straightforward implementation requires storage equal in
- * length to the largest message to be hashed.</p>
- *
- * <p><i>TMMH</i> is a simple hash function which maps a key and a message to a
+ * length to the largest message to be hashed.
+ * <p>
+ * <i>TMMH</i> is a simple hash function which maps a key and a message to a
* hash value. There are two versions of TMMH: TMMH/16 and TMMH/32. <i>TMMH</i>
* can be used as a message authentication code, as described in Section 5 (see
- * References).</p>
- *
- * <p>The key, message, and hash value are all octet strings, and the lengths of
+ * References).
+ * <p>
+ * The key, message, and hash value are all octet strings, and the lengths of
* these quantities are denoted as <code>KEY_LENGTH</code>,
- * <code>MESSAGE_LENGTH</code>, and <code>TAG_LENGTH</code>, respectively. The
- * values of <code>KEY_LENGTH</code> and <code>TAG_LENGTH</code>
+ * <code>MESSAGE_LENGTH</code>, and <code>TAG_LENGTH</code>, respectively.
+ * The values of <code>KEY_LENGTH</code> and <code>TAG_LENGTH</code>
* <bold>MUST</bold> be fixed for any particular fixed value of the key, and
- * must obey the alignment restrictions described below.</p>
- *
- * <p>The parameter <code>MAX_HASH_LENGTH</code>, which denotes the maximum
+ * must obey the alignment restrictions described below.
+ * <p>
+ * The parameter <code>MAX_HASH_LENGTH</code>, which denotes the maximum
* value which <code>MESSAGE_LENGTH</code> may take, is equal to
- * <code>KEY_LENGTH - TAG_LENGTH</code>.</p>
- *
- * <p>References:</p>
- *
+ * <code>KEY_LENGTH - TAG_LENGTH</code>.
+ * <p>
+ * References:
* <ol>
- * <li><a
- href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-tmmh-01.txt">
- * The Truncated Multi-Modular Hash Function (TMMH)</a>, David A. McGrew.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-tmmh-01.txt"> The
+ * Truncated Multi-Modular Hash Function (TMMH)</a>, David A. McGrew.</li>
* </ol>
*/
-public class TMMH16 extends BaseMac implements Cloneable
+public class TMMH16
+ extends BaseMac
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
public static final String TAG_LENGTH = "gnu.crypto.mac.tmmh.tag.length";
-
public static final String KEYSTREAM = "gnu.crypto.mac.tmmh.keystream";
-
public static final String PREFIX = "gnu.crypto.mac.tmmh.prefix";
-
private static final int P = (1 << 16) + 1; // the TMMH/16 prime
-
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
private int tagWords = 0; // the tagLength expressed in words
-
private IRandom keystream = null; // the keystream generator
-
private byte[] prefix; // mask to use when operating as an authentication f.
-
private long keyWords; // key words counter
-
private long msgLength; // in bytes
-
private long msgWords; // should be = msgLength * WORD_LENGTH
-
private int[] context; // the tmmh running context; length == TAG_WORDS
-
private int[] K0; // the first TAG_WORDS words of the keystream
-
private int[] Ki; // the sliding TAG_WORDS words of the keystream
-
private int Mi; // current message word being constructed
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public TMMH16()
{
super(Registry.TMMH16);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // gnu.crypto.mac.IMac interface implementation ----------------------------
-
public int macSize()
{
return tagWords * 2;
@@ -143,22 +115,17 @@ public class TMMH16 extends BaseMac implements Cloneable
Integer tagLength = (Integer) attributes.get(TAG_LENGTH); // get tag length
if (tagLength == null)
{
- if (tagWords == 0)
- { // was never set
- throw new IllegalArgumentException(TAG_LENGTH);
- } // else re-use
+ if (tagWords == 0) // was never set
+ throw new IllegalArgumentException(TAG_LENGTH);
+ // else re-use
}
- else
- { // check if positive and is divisible by WORD_LENGTH
+ else // check if positive and is divisible by WORD_LENGTH
+ {
wantTagLength = tagLength.intValue();
if (wantTagLength < 2 || (wantTagLength % 2 != 0))
- {
- throw new IllegalArgumentException(TAG_LENGTH);
- }
- else if (wantTagLength > (512 / 8))
- { // 512-bits is our maximum
- throw new IllegalArgumentException(TAG_LENGTH);
- }
+ throw new IllegalArgumentException(TAG_LENGTH);
+ else if (wantTagLength > (512 / 8)) // 512-bits is our maximum
+ throw new IllegalArgumentException(TAG_LENGTH);
tagWords = wantTagLength / 2; // init local vars
K0 = new int[tagWords];
@@ -167,36 +134,27 @@ public class TMMH16 extends BaseMac implements Cloneable
}
prefix = (byte[]) attributes.get(PREFIX);
- if (prefix == null)
- { // default to all-zeroes
- prefix = new byte[tagWords * 2];
- }
- else
- { // ensure it's as long as it should
+ if (prefix == null) // default to all-zeroes
+ prefix = new byte[tagWords * 2];
+ else // ensure it's as long as it should
+ {
if (prefix.length != tagWords * 2)
- {
- throw new IllegalArgumentException(PREFIX);
- }
+ throw new IllegalArgumentException(PREFIX);
}
IRandom prng = (IRandom) attributes.get(KEYSTREAM); // get keystream
if (prng == null)
{
if (keystream == null)
- {
- throw new IllegalArgumentException(KEYSTREAM);
- } // else reuse
+ throw new IllegalArgumentException(KEYSTREAM);
+ // else reuse
}
else
- {
- keystream = prng;
- }
+ keystream = prng;
reset(); // reset context variables
- for (int i = 0; i < tagWords; i++)
- { // init starting key words
- Ki[i] = K0[i] = getNextKeyWord(keystream);
- }
+ for (int i = 0; i < tagWords; i++) // init starting key words
+ Ki[i] = K0[i] = getNextKeyWord(keystream);
}
// The words of the key are denoted as K[1], K[2], ..., K[KEY_WORDS], and the
@@ -206,12 +164,12 @@ public class TMMH16 extends BaseMac implements Cloneable
//
// If MESSAGE_LENGTH is greater than MAX_HASH_LENGTH, then the value of
// TMMH/16 is undefined. Implementations MUST indicate an error if asked to
- // hash a message with such a length. Otherwise, the hash value is defined
+ // hash a message with such a length. Otherwise, the hash value is defined
// to be the length TAG_WORDS sequence of words in which the j-th word in the
// sequence is defined as
//
// [ [ K[j] * MESSAGE_LENGTH +32 K[j+1] * M[1] +32 K[j+2] * M[2]
- // +32 ... K[j+MSG_WORDS] * M[MSG_WORDS] ] modulo p ] modulo 2^16
+ // +32 ... K[j+MSG_WORDS] * M[MSG_WORDS] ] modulo p ] modulo 2^16
//
// where j ranges from 1 to TAG_WORDS.
public void update(byte b)
@@ -222,23 +180,21 @@ public class TMMH16 extends BaseMac implements Cloneable
public void update(byte[] b, int offset, int len)
{
for (int i = 0; i < len; i++)
- {
- this.update(b[offset + i], keystream);
- }
+ this.update(b[offset + i], keystream);
}
// For TMMH/16, KEY_LENGTH and TAG_LENGTH MUST be a multiple of two. The key,
// message, and hash value are treated as a sequence of unsigned sixteen bit
- // integers in network byte order. (In this section, we call such an integer
- // a word.) If MESSAGE_LENGTH is odd, then a zero byte is appended to the
+ // integers in network byte order. (In this section, we call such an integer
+ // a word.) If MESSAGE_LENGTH is odd, then a zero byte is appended to the
// message to align it on a word boundary, though this process does not
// change the value of MESSAGE_LENGTH.
//
- // ... Otherwise, the hash value is defined to be the length TAG_WORDS
+ // ... Otherwise, the hash value is defined to be the length TAG_WORDS
// sequence of words in which the j-th word in the sequence is defined as
//
// [ [ K[j] * MESSAGE_LENGTH +32 K[j+1] * M[1] +32 K[j+2] * M[2]
- // +32 ... K[j+MSG_WORDS] * M[MSG_WORDS] ] modulo p ] modulo 2^16
+ // +32 ... K[j+MSG_WORDS] * M[MSG_WORDS] ] modulo p ] modulo 2^16
//
// where j ranges from 1 to TAG_WORDS.
//
@@ -255,9 +211,7 @@ public class TMMH16 extends BaseMac implements Cloneable
msgLength = msgWords = keyWords = 0L;
Mi = 0;
for (int i = 0; i < tagWords; i++)
- {
- context[i] = 0;
- }
+ context[i] = 0;
}
public boolean selfTest()
@@ -265,42 +219,31 @@ public class TMMH16 extends BaseMac implements Cloneable
if (valid == null)
{
// TODO: compute and test equality with one known vector
-
valid = Boolean.TRUE;
}
return valid.booleanValue();
}
- // Cloneable interface implementation ---------------------------------------
-
public Object clone() throws CloneNotSupportedException
{
TMMH16 result = (TMMH16) super.clone();
-
if (this.keystream != null)
result.keystream = (IRandom) this.keystream.clone();
-
if (this.prefix != null)
result.prefix = (byte[]) this.prefix.clone();
-
if (this.context != null)
result.context = (int[]) this.context.clone();
-
if (this.K0 != null)
result.K0 = (int[]) this.K0.clone();
-
if (this.Ki != null)
result.Ki = (int[]) this.Ki.clone();
-
return result;
}
- // own methods -------------------------------------------------------------
-
/**
- * <p>Similar to the same method with one argument, but uses the designated
- * random number generator to compute needed keying material.</p>
- *
+ * Similar to the same method with one argument, but uses the designated
+ * random number generator to compute needed keying material.
+ *
* @param b the byte to process.
* @param prng the source of randomness to use.
*/
@@ -309,14 +252,14 @@ public class TMMH16 extends BaseMac implements Cloneable
Mi <<= 8; // update message buffer
Mi |= b & 0xFF;
msgLength++; // update message length (bytes)
- if (msgLength % 2 == 0)
- { // got a full word
+ if (msgLength % 2 == 0) // got a full word
+ {
msgWords++; // update message words counter
System.arraycopy(Ki, 1, Ki, 0, tagWords - 1); // 1. shift Ki up by 1
Ki[tagWords - 1] = getNextKeyWord(prng); // 2. fill last box of Ki
long t; // temp var to allow working in modulo 2^32
- for (int i = 0; i < tagWords; i++)
- { // 3. update context
+ for (int i = 0; i < tagWords; i++) // 3. update context
+ {
t = context[i] & 0xFFFFFFFFL;
t += Ki[i] * Mi;
context[i] = (int) t;
@@ -326,28 +269,26 @@ public class TMMH16 extends BaseMac implements Cloneable
}
/**
- * <p>Similar to the same method with three arguments, but uses the
- * designated random number generator to compute needed keying material.</p>
- *
+ * Similar to the same method with three arguments, but uses the designated
+ * random number generator to compute needed keying material.
+ *
* @param b the byte array to process.
* @param offset the starting offset in <code>b</code> to start considering
- * the bytes to process.
+ * the bytes to process.
* @param len the number of bytes in <code>b</code> starting from
- * <code>offset</code> to process.
+ * <code>offset</code> to process.
* @param prng the source of randomness to use.
*/
public void update(byte[] b, int offset, int len, IRandom prng)
{
for (int i = 0; i < len; i++)
- {
- this.update(b[offset + i], prng);
- }
+ this.update(b[offset + i], prng);
}
/**
- * <p>Similar to the same method with no arguments, but uses the designated
- * random number generator to compute needed keying material.</p>
- *
+ * Similar to the same method with no arguments, but uses the designated
+ * random number generator to compute needed keying material.
+ *
* @param prng the source of randomness to use.
* @return the final result of the algorithm.
*/
@@ -357,12 +298,11 @@ public class TMMH16 extends BaseMac implements Cloneable
byte[] result = new byte[tagWords * 2];
for (int i = 0, j = 0; i < tagWords; i++)
{
- result[j] = (byte) ((context[i] >>> 8) ^ prefix[j]);
+ result[j] = (byte)((context[i] >>> 8) ^ prefix[j]);
j++;
- result[j] = (byte) (context[i] ^ prefix[j]);
+ result[j] = (byte)(context[i] ^ prefix[j]);
j++;
}
-
reset();
return result;
}
@@ -378,7 +318,6 @@ public class TMMH16 extends BaseMac implements Cloneable
{
throw new RuntimeException(String.valueOf(x));
}
-
keyWords++; // update key words counter
return result;
}
@@ -387,9 +326,7 @@ public class TMMH16 extends BaseMac implements Cloneable
{
long limit = msgLength; // formula works on real message length
while (msgLength % 2 != 0)
- {
- update((byte) 0x00, prng);
- }
+ update((byte) 0x00, prng);
long t;
for (int i = 0; i < tagWords; i++)
{
diff --git a/libjava/classpath/gnu/javax/crypto/mac/UHash32.java b/libjava/classpath/gnu/javax/crypto/mac/UHash32.java
index 8abb0255ed4..737e9ce24ec 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/UHash32.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/UHash32.java
@@ -40,7 +40,6 @@ package gnu.javax.crypto.mac;
import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
-
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.prng.UMacGenerator;
@@ -51,103 +50,63 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p><i>UHASH</i> is a keyed hash function, which takes as input a string of
+ * <i>UHASH</i> is a keyed hash function, which takes as input a string of
* arbitrary length, and produces as output a string of fixed length (such as 8
- * bytes). The actual output length depends on the parameter UMAC-OUTPUT-LEN.</p>
- *
- * <p><i>UHASH</i> has been shown to be <i>epsilon-ASU</i> ("Almost Strongly
+ * bytes). The actual output length depends on the parameter UMAC-OUTPUT-LEN.
+ * <p>
+ * <i>UHASH</i> has been shown to be <i>epsilon-ASU</i> ("Almost Strongly
* Universal"), where epsilon is a small (parameter-dependent) real number.
* Informally, saying that a keyed hash function is <i>epsilon-ASU</i> means
* that for any two distinct fixed input strings, the two outputs of the hash
* function with a random key "look almost like a pair of random strings". The
- * number epsilon measures how non-random the output strings may be.</p>
- *
- * <i>UHASH</i> has been designed to be fast by exploiting several architectural
- * features of modern commodity processors. It was specifically designed for use
- * in <i>UMAC</i>. But <i>UHASH</i> is useful beyond that domain, and can be
- * easily adopted for other purposes.</p>
- *
+ * number epsilon measures how non-random the output strings may be.
+ * <p>
+ * <i>UHASH</i> has been designed to be fast by exploiting several
+ * architectural features of modern commodity processors. It was specifically
+ * designed for use in <i>UMAC</i>. But <i>UHASH</i> is useful beyond that
+ * domain, and can be easily adopted for other purposes.
+ * <p>
* <i>UHASH</i> does its work in three layers. First, a hash function called
* <code>NH</code> is used to compress input messages into strings which are
* typically many times smaller than the input message. Second, the compressed
* message is hashed with an optimized <i>polynomial hash function</i> into a
* fixed-length 16-byte string. Finally, the 16-byte string is hashed using an
- * <i>inner-product hash</i> into a string of length WORD-LEN bytes. These three
- * layers are repeated (with a modified key) until the outputs total
- * UMAC-OUTPUT-LEN bytes.</p>
- *
- * <p>References:</p>
- *
+ * <i>inner-product hash</i> into a string of length WORD-LEN bytes. These
+ * three layers are repeated (with a modified key) until the outputs total
+ * UMAC-OUTPUT-LEN bytes.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
- * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
- * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
+ * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
+ * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
+ * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
* </ol>
*/
-public class UHash32 extends BaseMac
+public class UHash32
+ extends BaseMac
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
// UMAC prime values
private static final BigInteger PRIME_19 = BigInteger.valueOf(0x7FFFFL);
-
private static final BigInteger PRIME_32 = BigInteger.valueOf(0xFFFFFFFBL);
-
private static final BigInteger PRIME_36 = BigInteger.valueOf(0xFFFFFFFFBL);
-
- private static final BigInteger PRIME_64 = new BigInteger(
- 1,
- new byte[] {
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xC5 });
-
- private static final BigInteger PRIME_128 = new BigInteger(
- 1,
- new byte[] {
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0xFF,
- (byte) 0x61 });
-
+ private static final BigInteger PRIME_64 = new BigInteger(1, new byte[] {
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xC5 });
+ private static final BigInteger PRIME_128 = new BigInteger(1, new byte[] {
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x61 });
static final BigInteger TWO = BigInteger.valueOf(2L);
-
static final long BOUNDARY = TWO.shiftLeft(17).longValue();
-
// 2**64 - 2**32
static final BigInteger LOWER_RANGE = TWO.pow(64).subtract(TWO.pow(32));
-
// 2**128 - 2**96
static final BigInteger UPPER_RANGE = TWO.pow(128).subtract(TWO.pow(96));
-
static final byte[] ALL_ZEROES = new byte[32];
-
int streams;
-
L1Hash32[] l1hash;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public UHash32()
{
@@ -155,7 +114,7 @@ public class UHash32 extends BaseMac
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param that the instance to clone.
*/
@@ -166,24 +125,15 @@ public class UHash32 extends BaseMac
this.streams = that.streams;
if (that.l1hash != null)
{
- // this.l1hash = new L1Hash32[that.l1hash.length];
this.l1hash = new L1Hash32[that.streams];
- // for (int i = 0; i < that.l1hash.length; i++) {
for (int i = 0; i < that.streams; i++)
- {
- if (that.l1hash[i] != null)
- {
- this.l1hash[i] = (L1Hash32) that.l1hash[i].clone();
- }
- }
+ if (that.l1hash[i] != null)
+ this.l1hash[i] = (L1Hash32) that.l1hash[i].clone();
}
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>The prime numbers used in UMAC are:</p>
+ * The prime numbers used in UMAC are:
* <pre>
* +-----+--------------------+---------------------------------------+
* | x | prime(x) [Decimal] | prime(x) [Hexadecimal] |
@@ -219,18 +169,11 @@ public class UHash32 extends BaseMac
}
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new UHash32(this);
}
- // gnu.crypto.mac.IMac interface implementation ----------------------------
-
public int macSize()
{
return UMac32.OUTPUT_LEN;
@@ -241,18 +184,12 @@ public class UHash32 extends BaseMac
{
byte[] K = (byte[]) attributes.get(MAC_KEY_MATERIAL);
if (K == null)
- {
- throw new InvalidKeyException("Null Key");
- }
+ throw new InvalidKeyException("Null Key");
if (K.length != UMac32.KEY_LEN)
- {
- throw new InvalidKeyException("Invalid Key length: "
- + String.valueOf(K.length));
- }
-
+ throw new InvalidKeyException("Invalid Key length: "
+ + String.valueOf(K.length));
// Calculate iterations needed to make UMAC-OUTPUT-LEN bytes
streams = (UMac32.OUTPUT_LEN + 3) / 4;
-
// Define total key needed for all iterations using UMacGenerator.
// L1Key and L3Key1 both reuse most key between iterations.
IRandom kdf1 = new UMacGenerator();
@@ -261,15 +198,14 @@ public class UHash32 extends BaseMac
IRandom kdf4 = new UMacGenerator();
Map map = new HashMap();
map.put(IBlockCipher.KEY_MATERIAL, K);
- map.put(UMacGenerator.INDEX, new Integer(0));
+ map.put(UMacGenerator.INDEX, Integer.valueOf(0));
kdf1.init(map);
- map.put(UMacGenerator.INDEX, new Integer(1));
+ map.put(UMacGenerator.INDEX, Integer.valueOf(1));
kdf2.init(map);
- map.put(UMacGenerator.INDEX, new Integer(2));
+ map.put(UMacGenerator.INDEX, Integer.valueOf(2));
kdf3.init(map);
- map.put(UMacGenerator.INDEX, new Integer(3));
+ map.put(UMacGenerator.INDEX, Integer.valueOf(3));
kdf4.init(map);
-
// need to generate all bytes for use later in a Toepliz construction
byte[] L1Key = new byte[UMac32.L1_KEY_LEN + (streams - 1) * 16];
try
@@ -297,7 +233,6 @@ public class UHash32 extends BaseMac
x.printStackTrace(System.err);
throw new RuntimeException("KDF for L2Key reached limit");
}
-
byte[] k31 = new byte[64];
try
{
@@ -308,7 +243,6 @@ public class UHash32 extends BaseMac
x.printStackTrace(System.err);
throw new RuntimeException("KDF for L3Key1 reached limit");
}
-
byte[] k32 = new byte[4];
try
{
@@ -319,7 +253,6 @@ public class UHash32 extends BaseMac
x.printStackTrace(System.err);
throw new RuntimeException("KDF for L3Key2 reached limit");
}
-
L1Hash32 mac = new L1Hash32();
mac.init(k1, k2, k31, k32);
l1hash[i] = mac;
@@ -329,17 +262,13 @@ public class UHash32 extends BaseMac
public void update(byte b)
{
for (int i = 0; i < streams; i++)
- {
- l1hash[i].update(b);
- }
+ l1hash[i].update(b);
}
public void update(byte[] b, int offset, int len)
{
for (int i = 0; i < len; i++)
- {
- this.update(b[offset + i]);
- }
+ this.update(b[offset + i]);
}
public byte[] digest()
@@ -357,9 +286,7 @@ public class UHash32 extends BaseMac
public void reset()
{
for (int i = 0; i < streams; i++)
- {
- l1hash[i].reset();
- }
+ l1hash[i].reset();
}
public boolean selfTest()
@@ -367,38 +294,20 @@ public class UHash32 extends BaseMac
return true;
}
- // helper methods ----------------------------------------------------------
-
- // Inner classes
- // =========================================================================
-
/**
* First hash stage of the UHash32 algorithm.
*/
- class L1Hash32 implements Cloneable
+ class L1Hash32
+ implements Cloneable
{
-
- // Constants and variables
- // ----------------------------------------------------------------------
-
private int[] key; // key material as an array of 32-bit ints
-
private byte[] buffer; // work buffer L1_KEY_LEN long
-
private int count; // meaningful bytes in buffer
-
private ByteArrayOutputStream Y;
-
- // private byte[] y;
private long totalCount;
-
private L2Hash32 l2hash;
-
private L3Hash32 l3hash;
- // Constructor(s)
- // ----------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
L1Hash32()
{
@@ -412,7 +321,7 @@ public class UHash32 extends BaseMac
}
/**
- * <p>Private constructor for cloning purposes.</p>
+ * Private constructor for cloning purposes.
*
* @param that the instance to clone.
*/
@@ -427,38 +336,23 @@ public class UHash32 extends BaseMac
this.Y.write(otherY, 0, otherY.length);
this.totalCount = that.totalCount;
if (that.l2hash != null)
- {
- this.l2hash = (L2Hash32) that.l2hash.clone();
- }
+ this.l2hash = (L2Hash32) that.l2hash.clone();
if (that.l3hash != null)
- {
- this.l3hash = (L3Hash32) that.l3hash.clone();
- }
+ this.l3hash = (L3Hash32) that.l3hash.clone();
}
- // Class methods
- // ----------------------------------------------------------------------
-
- // Instance methods
- // ----------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation -------------------------
-
public Object clone()
{
return new L1Hash32(this);
}
- // other instance methods -----------------------------------------------
-
public void init(byte[] k1, byte[] k2, byte[] k31, byte[] k32)
{
for (int i = 0, j = 0; i < (UMac32.L1_KEY_LEN / 4); i++)
- {
- key[i] = k1[j++] << 24 | (k1[j++] & 0xFF) << 16
- | (k1[j++] & 0xFF) << 8 | (k1[j++] & 0xFF);
- }
-
+ key[i] = k1[j++] << 24
+ | (k1[j++] & 0xFF) << 16
+ | (k1[j++] & 0xFF) << 8
+ | (k1[j++] & 0xFF);
l2hash = new L2Hash32(k2);
l3hash = new L3Hash32(k31, k32);
}
@@ -484,8 +378,8 @@ public class UHash32 extends BaseMac
// For each iteration, extract key and three-layer hash.
// If length(M) <= L1_KEY_LEN, then skip L2-HASH.
- if (Y.size() == 16)
- { // we already hashed twice L1_KEY_LEN
+ if (Y.size() == 16) // we already hashed twice L1_KEY_LEN
+ {
byte[] A = Y.toByteArray();
Y.reset();
l2hash.update(A, 0, 16);
@@ -508,19 +402,16 @@ public class UHash32 extends BaseMac
byte[] y = nh32(count);
Y.write(y, 0, 8);
}
-
byte[] A = Y.toByteArray();
Y.reset();
byte[] B;
if (totalCount <= UMac32.L1_KEY_LEN)
{
// we might have 'update'd the bytes already. check
- if (A.length == 0)
- { // we did
- B = l2hash.digest();
- }
- else
- { // did not
+ if (A.length == 0) // we did
+ B = l2hash.digest();
+ else // did not
+ {
B = new byte[16];
System.arraycopy(A, 0, B, 8, 8);
}
@@ -528,12 +419,9 @@ public class UHash32 extends BaseMac
else
{
if (A.length != 0)
- {
- l2hash.update(A, 0, A.length);
- }
+ l2hash.update(A, 0, A.length);
B = l2hash.digest();
}
-
byte[] result = l3hash.digest(B);
reset();
return result;
@@ -545,13 +433,9 @@ public class UHash32 extends BaseMac
Y.reset();
totalCount = 0L;
if (l2hash != null)
- {
- l2hash.reset();
- }
+ l2hash.reset();
}
- // helper methods -------------------------------------------------------
-
/**
* 5.1 NH-32: NH hashing with a 32-bit word size.
*
@@ -562,116 +446,87 @@ public class UHash32 extends BaseMac
{
// Break M and K into 4-byte chunks
int t = len / 4;
-
// Let M_1, M_2, ..., M_t be 4-byte strings
// so that M = M_1 || M_2 || .. || M_t.
// Let K_1, K_2, ..., K_t be 4-byte strings
// so that K_1 || K_2 || .. || K_t is a prefix of K.
int[] m = new int[t];
-
int i;
int j = 0;
for (i = 0, j = 0; i < t; i++)
- {
- m[i] = buffer[j++] << 24 | (buffer[j++] & 0xFF) << 16
- | (buffer[j++] & 0xFF) << 8 | (buffer[j++] & 0xFF);
- }
-
+ m[i] = buffer[j++] << 24
+ | (buffer[j++] & 0xFF) << 16
+ | (buffer[j++] & 0xFF) << 8
+ | (buffer[j++] & 0xFF);
// Perform NH hash on the chunks, pairing words for multiplication
// which are 4 apart to accommodate vector-parallelism.
long result = len * 8L;
for (i = 0; i < t; i += 8)
{
result += ((m[i + 0] + key[i + 0]) & 0xFFFFFFFFL)
- * ((m[i + 4] + key[i + 4]) & 0xFFFFFFFFL);
+ * ((m[i + 4] + key[i + 4]) & 0xFFFFFFFFL);
result += ((m[i + 1] + key[i + 1]) & 0xFFFFFFFFL)
- * ((m[i + 5] + key[i + 5]) & 0xFFFFFFFFL);
+ * ((m[i + 5] + key[i + 5]) & 0xFFFFFFFFL);
result += ((m[i + 2] + key[i + 2]) & 0xFFFFFFFFL)
- * ((m[i + 6] + key[i + 6]) & 0xFFFFFFFFL);
+ * ((m[i + 6] + key[i + 6]) & 0xFFFFFFFFL);
result += ((m[i + 3] + key[i + 3]) & 0xFFFFFFFFL)
- * ((m[i + 7] + key[i + 7]) & 0xFFFFFFFFL);
+ * ((m[i + 7] + key[i + 7]) & 0xFFFFFFFFL);
}
-
- return new byte[] { (byte) (result >>> 56), (byte) (result >>> 48),
- (byte) (result >>> 40), (byte) (result >>> 32),
- (byte) (result >>> 24), (byte) (result >>> 16),
- (byte) (result >>> 8), (byte) result };
+ return new byte[] {
+ (byte)(result >>> 56), (byte)(result >>> 48),
+ (byte)(result >>> 40), (byte)(result >>> 32),
+ (byte)(result >>> 24), (byte)(result >>> 16),
+ (byte)(result >>> 8), (byte) result };
}
}
- // =========================================================================
-
/**
- * <p>Second hash stage of the UHash32 algorithm.</p>
- *
- * 5.4 L2-HASH-32: Second-layer hash.<p>
+ * Second hash stage of the UHash32 algorithm.
+ * <p>
+ * 5.4 L2-HASH-32: Second-layer hash.
* <ul>
- * <li>Input:<br>
- * K string of length 24 bytes.<br>
- * M string of length less than 2^64 bytes.</li>
- * <li>Returns:<br>
- * Y, string of length 16 bytes.</li>
+ * <li>Input:<br>
+ * K string of length 24 bytes.<br>
+ * M string of length less than 2^64 bytes.</li>
+ * <li>Returns:<br>
+ * Y, string of length 16 bytes.</li>
* </ul>
*/
- class L2Hash32 implements Cloneable
+ class L2Hash32
+ implements Cloneable
{
-
- // Constants and variables
- // ----------------------------------------------------------------------
-
private BigInteger k64, k128;
-
private BigInteger y;
-
private boolean highBound;
-
private long bytesSoFar;
-
private ByteArrayOutputStream buffer;
- // Constructor(s)
- // ----------------------------------------------------------------------
-
L2Hash32(byte[] K)
{
super();
if (K.length != 24)
- {
- throw new ExceptionInInitializerError("K length is not 24");
- }
-
+ throw new ExceptionInInitializerError("K length is not 24");
// Extract keys and restrict to special key-sets
// Mask64 = uint2str(0x01FFFFFF01FFFFFF, 8);
// Mask128 = uint2str(0x01FFFFFF01FFFFFF01FFFFFF01FFFFFF, 16);
// k64 = str2uint(K[1..8] and Mask64);
// k128 = str2uint(K[9..24] and Mask128);
int i = 0;
- k64 = new BigInteger(1, new byte[] { (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF) });
- k128 = new BigInteger(1, new byte[] { (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0x01),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF),
- (byte) (K[i++] & 0xFF) });
-
+ k64 = new BigInteger(1, new byte[] {
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF) });
+ k128 = new BigInteger(1, new byte[] {
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0x01), (byte)(K[i++] & 0xFF),
+ (byte)(K[i++] & 0xFF), (byte)(K[i++] & 0xFF) });
y = BigInteger.ONE;
highBound = false;
bytesSoFar = 0L;
@@ -694,36 +549,24 @@ public class UHash32 extends BaseMac
}
}
- // Class methods
- // ----------------------------------------------------------------------
-
- // Instance methods
- // ----------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation -------------------------
-
public Object clone()
{
return new L2Hash32(this);
}
- // other instance methods -----------------------------------------------
-
// this is called with either 8-bytes or 16-bytes
void update(byte[] b, int offset, int len)
{
if (len == 0)
- {
- return;
- }
+ return;
- if (!highBound)
- { // do the first (only?) 8-bytes
+ if (! highBound) // do the first (only?) 8-bytes
+ {
poly(64, LOWER_RANGE, k64, b, offset, 8);
bytesSoFar += 8L;
highBound = (bytesSoFar > BOUNDARY);
- if (highBound)
- { // if we just crossed the limit then process y
+ if (highBound) // if we just crossed the limit then process y
+ {
poly(128, UPPER_RANGE, k128, yTo16bytes(), 0, 16);
buffer = new ByteArrayOutputStream();
}
@@ -739,9 +582,7 @@ public class UHash32 extends BaseMac
byte[] bb = buffer.toByteArray();
poly(128, UPPER_RANGE, k128, bb, 0, 16);
if (bb.length > 16)
- {
- buffer.write(bb, 16, bb.length - 16);
- }
+ buffer.write(bb, 16, bb.length - 16);
}
}
}
@@ -751,19 +592,18 @@ public class UHash32 extends BaseMac
// If M no more than 2^17 bytes, hash under 64-bit prime,
// otherwise, hash first 2^17 bytes under 64-bit prime and
// remainder under 128-bit prime.
- if (!highBound)
- { // y is up-to-date
+ if (! highBound) // y is up-to-date
+ {
// do nothing
}
- else
- { // we may have some bytes in buffer
+ else // we may have some bytes in buffer
+ {
byte[] bb = buffer.toByteArray();
byte[] lastBlock = new byte[16];
System.arraycopy(bb, 0, lastBlock, 0, bb.length);
lastBlock[bb.length] = (byte) 0x80;
poly(128, UPPER_RANGE, k128, lastBlock, 0, 16);
}
-
byte[] result = yTo16bytes();
reset();
return result;
@@ -775,38 +615,29 @@ public class UHash32 extends BaseMac
highBound = false;
bytesSoFar = 0L;
if (buffer != null)
- {
- buffer.reset();
- }
+ buffer.reset();
}
- // helper methods -------------------------------------------------------
-
private byte[] yTo16bytes()
{
byte[] yy = y.toByteArray();
byte[] result = new byte[16];
if (yy.length > 16)
- {
- System.arraycopy(yy, yy.length - 16, result, 0, 16);
- }
+ System.arraycopy(yy, yy.length - 16, result, 0, 16);
else
- {
- System.arraycopy(yy, 0, result, 16 - yy.length, yy.length);
- }
+ System.arraycopy(yy, 0, result, 16 - yy.length, yy.length);
return result;
}
/**
- * 5.3 POLY: Polynomial hash
- * Function Name: POLY
- *
+ * 5.3 POLY: Polynomial hash Function Name: POLY
+ *
* @param wordbits positive integer divisible by 8: called with 64 or 128.
* @param maxwordrange positive integer less than 2**wordbits.
* @param k integer in the range 0 .. prime(wordbits) - 1.
- * @param M string with length divisible by (wordbits / 8) bytes.
- * return y, integer in the range 0 .. prime(wordbits) - 1.
+ * @param M string with length divisible by (wordbits / 8) bytes. return y,
+ * integer in the range 0 .. prime(wordbits) - 1.
*/
private void poly(int wordbits, BigInteger maxwordrange, BigInteger k,
byte[] M, int off, int len)
@@ -814,12 +645,9 @@ public class UHash32 extends BaseMac
byte[] mag = new byte[len];
System.arraycopy(M, off, mag, 0, len);
// Define constants used for fixing out-of-range words
- // int wordbytes = wordbits / 8;
-
BigInteger p = prime(wordbits);
BigInteger offset = TWO.pow(wordbits).subtract(p); // 2^wordbits - p;
BigInteger marker = p.subtract(BigInteger.ONE);
-
// Break M into chunks of length wordbytes bytes
// long n = M.length / wordbytes;
// Let M_1, M_2, ..., M_n be strings of length wordbytes bytes
@@ -829,48 +657,34 @@ public class UHash32 extends BaseMac
// then hash the words 'marker' and (m - offset), both in range.
// for (int i = 0; i < n; i++) {
BigInteger m = new BigInteger(1, mag);
- if (m.compareTo(maxwordrange) >= 0)
- { // m >= maxwordrange
+ if (m.compareTo(maxwordrange) >= 0) // m >= maxwordrange
+ {
y = y.multiply(k).add(marker).mod(p); // (k * y + marker) % p;
y = y.multiply(k).add(m.subtract(offset)).mod(p); // (k * y + (m - offset)) % p;
}
else
- {
- y = y.multiply(k).add(m).mod(p); // (k * y + m) % p;
- }
- // }
-
- // return y;
+ y = y.multiply(k).add(m).mod(p); // (k * y + m) % p;
}
}
- // =========================================================================
-
/**
* Third hash stage of the UHash32 algorithm.
- *
- * Input:
- * K1 string of length 64 bytes.
- * K2 string of length 4 bytes.
- * M string of length 16 bytes.
- * Returns:
- * Y, string of length 4 bytes.
+ * <ul>
+ * <li>Input:<br/>
+ * K1 string of length 64 bytes.<br/>
+ * K2 string of length 4 bytes.<br/>
+ * M string of length 16 bytes.</li>
+ * <li>Returns:<br/>
+ * Y, string of length 4 bytes.</li>
+ * </ul>
*/
- class L3Hash32 implements Cloneable
+ class L3Hash32
+ implements Cloneable
{
-
- // Constants and variables
- // ----------------------------------------------------------------------
-
private static final long PRIME_36 = 0x0000000FFFFFFFFBL;
-
private int[] k = new int[9];
- // Constructor(s)
- // ----------------------------------------------------------------------
-
/**
- *
* @param K1 string of length 64 bytes.
* @param K2 string of length 4 bytes.
*/
@@ -880,29 +694,26 @@ public class UHash32 extends BaseMac
// pre-conditions
if (K1.length != 64)
- {
- throw new ExceptionInInitializerError("K1 length is not 64");
- }
+ throw new ExceptionInInitializerError("K1 length is not 64");
if (K2.length != 4)
- {
- throw new ExceptionInInitializerError("K2 length is not 4");
- }
-
+ throw new ExceptionInInitializerError("K2 length is not 4");
// Break K1 into 8 chunks and convert to integers
- // int i = 0;
- // for (int j = 0; i < 8; ) {
for (int i = 0, j = 0; i < 8; i++)
{
- long kk = (K1[j++] & 0xFFL) << 56 | (K1[j++] & 0xFFL) << 48
- | (K1[j++] & 0xFFL) << 40 | (K1[j++] & 0xFFL) << 32
- | (K1[j++] & 0xFFL) << 24 | (K1[j++] & 0xFFL) << 16
- | (K1[j++] & 0xFFL) << 8 | (K1[j++] & 0xFFL);
- // k[i++] = (int)(kk % PRIME_36);
- k[i] = (int) (kk % PRIME_36);
+ long kk = (K1[j++] & 0xFFL) << 56
+ | (K1[j++] & 0xFFL) << 48
+ | (K1[j++] & 0xFFL) << 40
+ | (K1[j++] & 0xFFL) << 32
+ | (K1[j++] & 0xFFL) << 24
+ | (K1[j++] & 0xFFL) << 16
+ | (K1[j++] & 0xFFL) << 8
+ | (K1[j++] & 0xFFL);
+ k[i] = (int)(kk % PRIME_36);
}
- // k[i] = K2[0] << 24 | (K2[1] & 0xFF) << 16 | (K2[2] & 0xFF) << 8 | (K2[3] & 0xFF);
- k[8] = K2[0] << 24 | (K2[1] & 0xFF) << 16 | (K2[2] & 0xFF) << 8
- | (K2[3] & 0xFF);
+ k[8] = K2[0] << 24
+ | (K2[1] & 0xFF) << 16
+ | (K2[2] & 0xFF) << 8
+ | (K2[3] & 0xFF);
}
private L3Hash32(int[] k)
@@ -912,21 +723,11 @@ public class UHash32 extends BaseMac
this.k = k;
}
- // Class methods
- // ----------------------------------------------------------------------
-
- // Instance methods
- // ----------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation -------------------------
-
public Object clone()
{
return new L3Hash32((int[]) k.clone());
}
- // other instance methods -----------------------------------------------
-
/**
* @param M string of length 16 bytes.
* @return Y, string of length 4 bytes.
@@ -934,24 +735,24 @@ public class UHash32 extends BaseMac
byte[] digest(byte[] M)
{
if (M.length != 16)
- {
- throw new IllegalArgumentException("M length is not 16");
- }
+ throw new IllegalArgumentException("M length is not 16");
long m, y = 0L;
for (int i = 0, j = 0; i < 8; i++)
{
// Break M into 8 chunks and convert to integers
m = (M[j++] & 0xFFL) << 8 | (M[j++] & 0xFFL);
-
// Inner-product hash, extract last 32 bits and affine-translate
// y = (m_1 * k_1 + ... + m_8 * k_8) mod prime(36);
// y = y mod 2^32;
y += (m * (k[i] & 0xFFFFFFFFL)) % PRIME_36;
}
int Y = ((int) y) ^ k[8];
- return new byte[] { (byte) (Y >>> 24), (byte) (Y >>> 16),
- (byte) (Y >>> 8), (byte) Y };
+ return new byte[] {
+ (byte)(Y >>> 24),
+ (byte)(Y >>> 16),
+ (byte)(Y >>> 8),
+ (byte) Y };
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mac/UMac32.java b/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
index 01388885699..8e913db714a 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
@@ -53,123 +53,105 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>The implementation of the <i>UMAC</i> (Universal Message Authentication
- * Code).</p>
- *
- * <p>The <i>UMAC</i> algorithms described are <i>parameterized</i>. This means
+ * The implementation of the <i>UMAC</i> (Universal Message Authentication
+ * Code).
+ * <p>
+ * The <i>UMAC</i> algorithms described are <i>parameterized</i>. This means
* that various low-level choices, like the endian convention and the underlying
* cryptographic primitive, have not been fixed. One must choose values for
* these parameters before the authentication tag generated by <i>UMAC</i> (for
- * a given message, key, and nonce) becomes fully-defined. In this document
- * we provide two collections of parameter settings, and have named the sets
- * <i>UMAC16</i> and <i>UMAC32</i>. The parameter sets have been chosen based on
- * experimentation and provide good performance on a wide variety of processors.
- * <i>UMAC16</i> is designed to excel on processors which provide small-scale
- * SIMD parallelism of the type found in Intel's MMX and Motorola's AltiVec
- * instruction sets, while <i>UMAC32</i> is designed to do well on processors
- * with good 32- and 64- bit support. <i>UMAC32</i> may take advantage of SIMD
- * parallelism in future processors.</p>
- *
- * <p><i>UMAC</i> has been designed to allow implementations which accommodate
- * <i>on-line</i> authentication. This means that pieces of the message may
- * be presented to <i>UMAC</i> at different times (but in correct order) and an
+ * a given message, key, and nonce) becomes fully-defined. In this document we
+ * provide two collections of parameter settings, and have named the sets
+ * <i>UMAC16</i> and <i>UMAC32</i>. The parameter sets have been chosen based
+ * on experimentation and provide good performance on a wide variety of
+ * processors. <i>UMAC16</i> is designed to excel on processors which provide
+ * small-scale SIMD parallelism of the type found in Intel's MMX and Motorola's
+ * AltiVec instruction sets, while <i>UMAC32</i> is designed to do well on
+ * processors with good 32- and 64- bit support. <i>UMAC32</i> may take
+ * advantage of SIMD parallelism in future processors.
+ * <p>
+ * <i>UMAC</i> has been designed to allow implementations which accommodate
+ * <i>on-line</i> authentication. This means that pieces of the message may be
+ * presented to <i>UMAC</i> at different times (but in correct order) and an
* on-line implementation will be able to process the message correctly without
* the need to buffer more than a few dozen bytes of the message. For
* simplicity, the algorithms in this specification are presented as if the
- * entire message being authenticated were available at once.</p>
- *
- * <p>To authenticate a message, <code>Msg</code>, one first applies the
+ * entire message being authenticated were available at once.
+ * <p>
+ * To authenticate a message, <code>Msg</code>, one first applies the
* universal hash function, resulting in a string which is typically much
- * shorter than the original message. The pseudorandom function is applied to a
+ * shorter than the original message. The pseudorandom function is applied to a
* nonce, and the result is used in the manner of a Vernam cipher: the
* authentication tag is the xor of the output from the hash function and the
* output from the pseudorandom function. Thus, an authentication tag is
- * generated as</p>
- *
+ * generated as
* <pre>
- * AuthTag = f(Nonce) xor h(Msg)
+ * AuthTag = f(Nonce) xor h(Msg)
* </pre>
- *
- * <p>Here <code>f</code> is the pseudorandom function shared between the sender
+ * <p>
+ * Here <code>f</code> is the pseudorandom function shared between the sender
* and the receiver, and h is a universal hash function shared by the sender and
* the receiver. In <i>UMAC</i>, a shared key is used to key the pseudorandom
* function <code>f</code>, and then <code>f</code> is used for both tag
* generation and internally to generate all of the bits needed by the universal
- * hash function.</p>
- *
- * <p>The universal hash function that we use is called <code>UHASH</code>. It
+ * hash function.
+ * <p>
+ * The universal hash function that we use is called <code>UHASH</code>. It
* combines several software-optimized algorithms into a multi-layered
* structure. The algorithm is moderately complex. Some of this complexity comes
- * from extensive speed optimizations.</p>
- *
- * <p>For the pseudorandom function we use the block cipher of the <i>Advanced
- * Encryption Standard</i> (AES).</p>
- *
- * <p>The UMAC32 parameters, considered in this implementation are:</p>
+ * from extensive speed optimizations.
+ * <p>
+ * For the pseudorandom function we use the block cipher of the <i>Advanced
+ * Encryption Standard</i> (AES).
+ * <p>
+ * The UMAC32 parameters, considered in this implementation are:
* <pre>
- * UMAC32
- * ------
- * WORD-LEN 4
- * UMAC-OUTPUT-LEN 8
- * L1-KEY-LEN 1024
- * UMAC-KEY-LEN 16
- * ENDIAN-FAVORITE BIG *
- * L1-OPERATIONS-SIGN UNSIGNED
+ * UMAC32
+ * ------
+ * WORD-LEN 4
+ * UMAC-OUTPUT-LEN 8
+ * L1-KEY-LEN 1024
+ * UMAC-KEY-LEN 16
+ * ENDIAN-FAVORITE BIG *
+ * L1-OPERATIONS-SIGN UNSIGNED
* </pre>
- *
- * <p>Please note that this UMAC32 differs from the one described in the paper
- * by the <i>ENDIAN-FAVORITE</i> value.</p>
- *
- * <p>References:</p>
- *
+ * <p>
+ * Please note that this UMAC32 differs from the one described in the paper by
+ * the <i>ENDIAN-FAVORITE</i> value.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
- * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
- * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
+ * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
+ * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
+ * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
* </ol>
*/
-public class UMac32 extends BaseMac
+public class UMac32
+ extends BaseMac
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
* Property name of the user-supplied <i>Nonce</i>. The value associated to
* this property name is taken to be a byte array.
*/
public static final String NONCE_MATERIAL = "gnu.crypto.umac.nonce.material";
-
/** Known test vector. */
- // private static final String TV1 = "3E5A0E09198B0F94";
- // private static final String TV1 = "5FD764A6D3A9FD9D";
- // private static final String TV1 = "48658DE1D9A70304";
+ // private static final String TV1 = "3E5A0E09198B0F94";
+ // private static final String TV1 = "5FD764A6D3A9FD9D";
+ // private static final String TV1 = "48658DE1D9A70304";
private static final String TV1 = "455ED214A6909F20";
-
private static final BigInteger MAX_NONCE_ITERATIONS = BigInteger.ONE.shiftLeft(16 * 8);
-
// UMAC32 parameters
static final int OUTPUT_LEN = 8;
-
static final int L1_KEY_LEN = 1024;
-
static final int KEY_LEN = 16;
-
/** caches the result of the correctness test, once executed. */
private static Boolean valid;
-
private byte[] nonce;
-
private UHash32 uhash32;
-
private BigInteger nonceReuseCount;
-
/** The authentication key for this instance. */
private transient byte[] K;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public UMac32()
{
@@ -177,8 +159,8 @@ public class UMac32 extends BaseMac
}
/**
- * <p>Private constructor for cloning purposes.</p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param that the instance to clone.
*/
private UMac32(UMac32 that)
@@ -186,136 +168,103 @@ public class UMac32 extends BaseMac
this();
if (that.K != null)
- {
- this.K = (byte[]) that.K.clone();
- }
+ this.K = (byte[]) that.K.clone();
if (that.nonce != null)
- {
- this.nonce = (byte[]) that.nonce.clone();
- }
+ this.nonce = (byte[]) that.nonce.clone();
if (that.uhash32 != null)
- {
- this.uhash32 = (UHash32) that.uhash32.clone();
- }
+ this.uhash32 = (UHash32) that.uhash32.clone();
this.nonceReuseCount = that.nonceReuseCount;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new UMac32(this);
}
- // gnu.crypto.mac.IMac interface implementation ----------------------------
-
public int macSize()
{
return OUTPUT_LEN;
}
/**
- * <p>Initialising a <i>UMAC</i> instance consists of defining values for
- * the following parameters:</p>
- *
+ * Initialising a <i>UMAC</i> instance consists of defining values for the
+ * following parameters:
* <ol>
- * <li>Key Material: as the value of the attribute entry keyed by
- * {@link #MAC_KEY_MATERIAL}. The value is taken to be a byte array
- * containing the user-specified key material. The length of this array,
- * if/when defined SHOULD be exactly equal to {@link #KEY_LEN}.</li>
- *
- * <li>Nonce Material: as the value of the attribute entry keyed by
- * {@link #NONCE_MATERIAL}. The value is taken to be a byte array
- * containing the user-specified nonce material. The length of this array,
- * if/when defined SHOULD be (a) greater than zero, and (b) less or equal
- * to 16 (the size of the AES block).</li>
+ * <li>Key Material: as the value of the attribute entry keyed by
+ * {@link #MAC_KEY_MATERIAL}. The value is taken to be a byte array
+ * containing the user-specified key material. The length of this array,
+ * if/when defined SHOULD be exactly equal to {@link #KEY_LEN}.</li>
+ * <li>Nonce Material: as the value of the attribute entry keyed by
+ * {@link #NONCE_MATERIAL}. The value is taken to be a byte array containing
+ * the user-specified nonce material. The length of this array, if/when
+ * defined SHOULD be (a) greater than zero, and (b) less or equal to 16 (the
+ * size of the AES block).</li>
* </ol>
- *
- * <p>For convenience, this implementation accepts that not both parameters
- * be always specified.</p>
- *
+ * <p>
+ * For convenience, this implementation accepts that not both parameters be
+ * always specified.
* <ul>
- * <li>If the <i>Key Material</i> is specified, but the <i>Nonce Material</i>
- * is not, then this implementation, re-uses the previously set <i>Nonce
- * Material</i> after (a) converting the bytes to an unsigned integer,
- * (b) incrementing the number by one, and (c) converting it back to 16
- * bytes.</li>
- *
- * <li>If the <i>Nonce Material</i> is specified, but the <i>Key Material</i>
- * is not, then this implementation re-uses the previously set <i>Key
- * Material</i>.</li>
+ * <li>If the <i>Key Material</i> is specified, but the <i>Nonce Material</i>
+ * is not, then this implementation, re-uses the previously set <i>Nonce
+ * Material</i> after (a) converting the bytes to an unsigned integer, (b)
+ * incrementing the number by one, and (c) converting it back to 16 bytes.</li>
+ * <li>If the <i>Nonce Material</i> is specified, but the <i>Key Material</i>
+ * is not, then this implementation re-uses the previously set <i>Key Material</i>.
+ * </li>
* </ul>
- *
- * <p>This method throws an exception if no <i>Key Material</i> is specified
- * in the input map, and there is no previously set/defined <i>Key Material</i>
+ * <p>
+ * This method throws an exception if no <i>Key Material</i> is specified in
+ * the input map, and there is no previously set/defined <i>Key Material</i>
* (from an earlier invocation of this method). If a <i>Key Material</i> can
- * be used, but no <i>Nonce Material</i> is defined or previously set/defined,
- * then a default value of all-zeroes shall be used.</p>
- *
+ * be used, but no <i>Nonce Material</i> is defined or previously
+ * set/defined, then a default value of all-zeroes shall be used.
+ *
* @param attributes one or both of required parameters.
* @throws InvalidKeyException the key material specified is not of the
- * correct length.
+ * correct length.
*/
public void init(Map attributes) throws InvalidKeyException,
IllegalStateException
{
byte[] key = (byte[]) attributes.get(MAC_KEY_MATERIAL);
byte[] n = (byte[]) attributes.get(NONCE_MATERIAL);
-
boolean newKey = (key != null);
boolean newNonce = (n != null);
-
if (newKey)
{
if (key.length != KEY_LEN)
- {
- throw new InvalidKeyException("Key length: "
- + String.valueOf(key.length));
- }
+ throw new InvalidKeyException("Key length: "
+ + String.valueOf(key.length));
K = key;
}
else
{
if (K == null)
- {
- throw new InvalidKeyException("Null Key");
- }
+ throw new InvalidKeyException("Null Key");
}
-
if (newNonce)
{
if (n.length < 1 || n.length > 16)
+ throw new IllegalArgumentException("Invalid Nonce length: "
+ + String.valueOf(n.length));
+ if (n.length < 16) // pad with zeroes
{
- throw new IllegalArgumentException("Invalid Nonce length: "
- + String.valueOf(n.length));
- }
-
- if (n.length < 16)
- { // pad with zeroes
byte[] newN = new byte[16];
System.arraycopy(n, 0, newN, 0, n.length);
nonce = newN;
}
else
- {
- nonce = n;
- }
+ nonce = n;
nonceReuseCount = BigInteger.ZERO;
}
- else if (nonce == null)
- { // use all-0 nonce if 1st time
+ else if (nonce == null) // use all-0 nonce if 1st time
+ {
nonce = new byte[16];
nonceReuseCount = BigInteger.ZERO;
}
- else if (!newKey)
- { // increment nonce if still below max count
+ else if (! newKey) // increment nonce if still below max count
+ {
nonceReuseCount = nonceReuseCount.add(BigInteger.ONE);
if (nonceReuseCount.compareTo(MAX_NONCE_ITERATIONS) >= 0)
{
@@ -326,9 +275,7 @@ public class UMac32 extends BaseMac
N = N.add(BigInteger.ONE).mod(MAX_NONCE_ITERATIONS);
n = N.toByteArray();
if (n.length == 16)
- {
- nonce = n;
- }
+ nonce = n;
else if (n.length < 16)
{
nonce = new byte[16];
@@ -340,15 +287,11 @@ public class UMac32 extends BaseMac
System.arraycopy(n, n.length - 16, nonce, 0, 16);
}
}
- else
- { // do nothing, re-use old nonce value
- nonceReuseCount = BigInteger.ZERO;
- }
+ else // do nothing, re-use old nonce value
+ nonceReuseCount = BigInteger.ZERO;
if (uhash32 == null)
- {
- uhash32 = new UHash32();
- }
+ uhash32 = new UHash32();
Map map = new HashMap();
map.put(MAC_KEY_MATERIAL, K);
@@ -370,9 +313,7 @@ public class UMac32 extends BaseMac
byte[] result = uhash32.digest();
byte[] pad = pdf(); // pdf(K, nonce);
for (int i = 0; i < OUTPUT_LEN; i++)
- {
- result[i] = (byte) (result[i] ^ pad[i]);
- }
+ result[i] = (byte)(result[i] ^ pad[i]);
return result;
}
@@ -380,9 +321,7 @@ public class UMac32 extends BaseMac
public void reset()
{
if (uhash32 != null)
- {
- uhash32.reset();
- }
+ uhash32.reset();
}
public boolean selfTest()
@@ -412,43 +351,32 @@ public class UMac32 extends BaseMac
x.printStackTrace(System.err);
return false;
}
-
byte[] data = new byte[128];
data[0] = (byte) 0x80;
-
mac.update(data, 0, 128);
byte[] result = mac.digest();
- // System.out.println("UMAC test vector: "+Util.toString(result));
valid = Boolean.valueOf(TV1.equals(Util.toString(result)));
}
return valid.booleanValue();
}
- // helper methods ----------------------------------------------------------
-
/**
- *
* @return byte array of length 8 (or OUTPUT_LEN) bytes.
*/
private byte[] pdf()
{
// Make Nonce 16 bytes by prepending zeroes. done (see init())
-
// one AES invocation is enough for more than one PDF invocation
// number of index bits needed = 1
-
// Extract index bits and zero low bits of Nonce
BigInteger Nonce = new BigInteger(1, nonce);
int nlowbitsnum = Nonce.testBit(0) ? 1 : 0;
Nonce = Nonce.clearBit(0);
-
// Generate subkey, AES and extract indexed substring
IRandom kdf = new UMacGenerator();
Map map = new HashMap();
map.put(IBlockCipher.KEY_MATERIAL, K);
- // map.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(128/8));
- map.put(UMacGenerator.INDEX, new Integer(128));
- // map.put(UMacGenerator.CIPHER, Registry.AES_CIPHER);
+ map.put(UMacGenerator.INDEX, Integer.valueOf(128));
kdf.init(map);
byte[] Kp = new byte[KEY_LEN];
try
@@ -485,7 +413,6 @@ public class UMac32 extends BaseMac
aes.encryptBlock(nonce, 0, T, 0);
byte[] result = new byte[OUTPUT_LEN];
System.arraycopy(T, nlowbitsnum, result, 0, OUTPUT_LEN);
-
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/BaseMode.java b/libjava/classpath/gnu/javax/crypto/mode/BaseMode.java
index 0a9ab2dab1c..6d9418ccafa 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/BaseMode.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/BaseMode.java
@@ -49,46 +49,34 @@ import java.util.Iterator;
import java.util.Map;
/**
- * <p>A basic abstract class to facilitate implementing block cipher modes of
- * operations.</p>
+ * A basic abstract class to facilitate implementing block cipher modes of
+ * operations.
*/
-public abstract class BaseMode implements IMode
+public abstract class BaseMode
+ implements IMode
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The canonical name prefix of this mode. */
protected String name;
-
/** The state indicator of this instance. */
protected int state;
-
/** The underlying block cipher implementation. */
protected IBlockCipher cipher;
-
/** The block size, in bytes, to operate the underlying block cipher in. */
protected int cipherBlockSize;
-
/** The block size, in bytes, in which to operate the mode instance. */
protected int modeBlockSize;
-
/** The initialisation vector value. */
protected byte[] iv;
-
/** The instance lock. */
protected Object lock = new Object();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial constructor for use by concrete subclasses.</p>
- *
+ * Trivial constructor for use by concrete subclasses.
+ *
* @param name the canonical name prefix of this mode.
* @param underlyingCipher the implementation of the underlying cipher.
* @param cipherBlockSize the block size, in bytes, in which to operate the
- * underlying cipher.
+ * underlying cipher.
*/
protected BaseMode(String name, IBlockCipher underlyingCipher,
int cipherBlockSize)
@@ -101,14 +89,6 @@ public abstract class BaseMode implements IMode
state = -1;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IMode interface implementation ------------------------------------------
-
public void update(byte[] in, int inOffset, byte[] out, int outOffset)
throws IllegalStateException
{
@@ -128,25 +108,23 @@ public abstract class BaseMode implements IMode
}
}
- // IBlockCipher interface implementation -----------------------------------
-
public String name()
{
- return new StringBuffer().append(name).append('(').append(cipher.name()).append(
- ')').toString();
+ return new StringBuffer(name).append('(').append(cipher.name()).append(')')
+ .toString();
}
/**
- * <p>Returns the default value, in bytes, of the mode's block size. This
- * value is part of the construction arguments passed to the Factory methods
- * in {@link ModeFactory}. Unless changed by an invocation of any of the
+ * Returns the default value, in bytes, of the mode's block size. This value
+ * is part of the construction arguments passed to the Factory methods in
+ * {@link ModeFactory}. Unless changed by an invocation of any of the
* <code>init()</code> methods, a <i>Mode</i> instance would operate with
* the same block size as its underlying block cipher. As mentioned earlier,
- * the block size of the underlying block cipher itself is specified in one
- * of the method(s) available in the factory class.</p>
- *
+ * the block size of the underlying block cipher itself is specified in one of
+ * the method(s) available in the factory class.
+ *
* @return the default value, in bytes, of the mode's block size.
- * @see gnu.crypto.mode.ModeFactory
+ * @see ModeFactory
*/
public int defaultBlockSize()
{
@@ -154,9 +132,9 @@ public abstract class BaseMode implements IMode
}
/**
- * <p>Returns the default value, in bytes, of the underlying block cipher
- * key size.</p>
- *
+ * Returns the default value, in bytes, of the underlying block cipher key
+ * size.
+ *
* @return the default value, in bytes, of the underlying cipher's key size.
*/
public int defaultKeySize()
@@ -165,29 +143,28 @@ public abstract class BaseMode implements IMode
}
/**
- * <p>Returns an {@link Iterator} over the supported block sizes. Each
- * element returned by this object is an {@link Integer}.</p>
- *
- * <p>The default behaviour is to return an iterator with just one value,
- * which is that currently configured for the underlying block cipher.
- * Concrete implementations may override this behaviour to signal their
- * ability to support other values.</p>
- *
+ * Returns an {@link Iterator} over the supported block sizes. Each element
+ * returned by this object is an {@link Integer}.
+ * <p>
+ * The default behaviour is to return an iterator with just one value, which
+ * is that currently configured for the underlying block cipher. Concrete
+ * implementations may override this behaviour to signal their ability to
+ * support other values.
+ *
* @return an {@link Iterator} over the supported block sizes.
*/
public Iterator blockSizes()
{
ArrayList al = new ArrayList();
- al.add(new Integer(cipherBlockSize));
-
+ al.add(Integer.valueOf(cipherBlockSize));
return Collections.unmodifiableList(al).iterator();
}
/**
- * <p>Returns an {@link Iterator} over the supported underlying block cipher
- * key sizes. Each element returned by this object is an instance of
- * {@link Integer}.</p>
- *
+ * Returns an {@link Iterator} over the supported underlying block cipher key
+ * sizes. Each element returned by this object is an instance of
+ * {@link Integer}.
+ *
* @return an {@link Iterator} over the supported key sizes.
*/
public Iterator keySizes()
@@ -201,10 +178,7 @@ public abstract class BaseMode implements IMode
synchronized (lock)
{
if (state != -1)
- {
- throw new IllegalStateException();
- }
-
+ throw new IllegalStateException();
Integer want = (Integer) attributes.get(STATE);
if (want != null)
{
@@ -220,20 +194,13 @@ public abstract class BaseMode implements IMode
throw new IllegalArgumentException();
}
}
-
Integer bs = (Integer) attributes.get(MODE_BLOCK_SIZE);
modeBlockSize = (bs == null ? cipherBlockSize : bs.intValue());
-
byte[] iv = (byte[]) attributes.get(IV);
if (iv != null)
- {
- this.iv = (byte[]) iv.clone();
- }
+ this.iv = (byte[]) iv.clone();
else
- {
- this.iv = new byte[modeBlockSize];
- }
-
+ this.iv = new byte[modeBlockSize];
cipher.init(attributes);
setup();
}
@@ -242,9 +209,7 @@ public abstract class BaseMode implements IMode
public int currentBlockSize()
{
if (state == -1)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
return modeBlockSize;
}
@@ -255,7 +220,6 @@ public abstract class BaseMode implements IMode
state = -1;
iv = null;
cipher.reset();
-
teardown();
}
}
@@ -268,19 +232,12 @@ public abstract class BaseMode implements IMode
{
ks = ((Integer) kit.next()).intValue();
for (bit = blockSizes(); bit.hasNext();)
- {
- if (!testSymmetry(ks, ((Integer) bit.next()).intValue()))
- {
- return false;
- }
- }
+ if (! testSymmetry(ks, ((Integer) bit.next()).intValue()))
+ return false;
}
-
return true;
}
- // methods to be implemented by concrete subclasses ------------------------
-
public abstract Object clone();
/** The initialisation phase of the concrete mode implementation. */
@@ -293,8 +250,6 @@ public abstract class BaseMode implements IMode
public abstract void decryptBlock(byte[] in, int i, byte[] out, int o);
- // own methods -------------------------------------------------------------
-
private boolean testSymmetry(int ks, int bs)
{
try
@@ -304,44 +259,30 @@ public abstract class BaseMode implements IMode
byte[] k = new byte[ks];
int i;
for (i = 0; i < ks; i++)
- {
- k[i] = (byte) i;
- }
-
+ k[i] = (byte) i;
int blockCount = 5;
int limit = blockCount * bs;
byte[] pt = new byte[limit];
for (i = 0; i < limit; i++)
- {
- pt[i] = (byte) i;
- }
+ pt[i] = (byte) i;
byte[] ct = new byte[limit];
byte[] cpt = new byte[limit];
-
Map map = new HashMap();
map.put(KEY_MATERIAL, k);
- map.put(CIPHER_BLOCK_SIZE, new Integer(cipherBlockSize));
- map.put(STATE, new Integer(ENCRYPTION));
+ map.put(CIPHER_BLOCK_SIZE, Integer.valueOf(cipherBlockSize));
+ map.put(STATE, Integer.valueOf(ENCRYPTION));
map.put(IV, iv);
- map.put(MODE_BLOCK_SIZE, new Integer(bs));
-
+ map.put(MODE_BLOCK_SIZE, Integer.valueOf(bs));
mode.reset();
mode.init(map);
for (i = 0; i < blockCount; i++)
- {
- mode.update(pt, i * bs, ct, i * bs);
- }
-
+ mode.update(pt, i * bs, ct, i * bs);
mode.reset();
- map.put(STATE, new Integer(DECRYPTION));
+ map.put(STATE, Integer.valueOf(DECRYPTION));
mode.init(map);
for (i = 0; i < blockCount; i++)
- {
- mode.update(ct, i * bs, cpt, i * bs);
- }
-
+ mode.update(ct, i * bs, cpt, i * bs);
return Arrays.equals(pt, cpt);
-
}
catch (Exception x)
{
@@ -349,4 +290,4 @@ public abstract class BaseMode implements IMode
return false;
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/CBC.java b/libjava/classpath/gnu/javax/crypto/mode/CBC.java
index 10578a6ef50..f3b3fb3312f 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/CBC.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/CBC.java
@@ -42,36 +42,31 @@ import gnu.java.security.Registry;
import gnu.javax.crypto.cipher.IBlockCipher;
/**
- * The Cipher Block Chaining mode. This mode introduces feedback into
- * the cipher by XORing the previous ciphertext block with the plaintext
- * block before encipherment. That is, encrypting looks like this:</p>
- *
- * <blockquote><p>C<sub>i</sub> = E<sub>K</sub>(P<sub>i</sub> ^
- * C<sub>i-1</sub></p></blockquote>
- *
- * <p>Similarly, decrypting is:</p>
- *
- * <blockquote><p>P<sub>i</sub> = C<sub>i-1</sub> ^
- * D<sub>K</sub>(C<sub>i</sub>)</p></blockquote>
+ * The Cipher Block Chaining mode. This mode introduces feedback into the cipher
+ * by XORing the previous ciphertext block with the plaintext block before
+ * encipherment. That is, encrypting looks like this:
+ *
+ * <pre>
+ * C<sub>i</sub> = E<sub>K</sub>(P<sub>i</sub>&circ; C<sub>i-1</sub>)
+ * </pre>
+ * <p>
+ * Similarly, decrypting is:
+ * <pre>
+ * P<sub>i</sub> = C<sub>i-1</sub> &circ; D<sub>K</sub>(C<sub>i</sub>)
+ * </pre>
*/
-public class CBC extends BaseMode implements Cloneable
+public class CBC
+ extends BaseMode
+ implements Cloneable
{
-
- // Constants and Variables
- //------------------------------------------------------------------
-
/** The last (de|en)crypted block */
private byte[] lastBlock;
-
/** An intermediate buffer. */
private byte[] scratch;
- // Constructors
- // -----------------------------------------------------------------
-
/**
* Package-private constructor for the factory class.
- *
+ *
* @param underlyingCipher The cipher implementation.
* @param cipherBlockSize The cipher's block size.
*/
@@ -86,31 +81,20 @@ public class CBC extends BaseMode implements Cloneable
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Cloneable interface implementation
- // -----------------------------------------------------------------
-
public Object clone()
{
return new CBC(this);
}
- // Implementation of abstract methods in BaseMode
- // -----------------------------------------------------------------
-
public void setup()
{
if (modeBlockSize != cipherBlockSize)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
scratch = new byte[cipherBlockSize];
lastBlock = new byte[cipherBlockSize];
-
// lastBlock gets initialized to the initialization vector.
for (int i = 0; i < lastBlock.length && i < iv.length; i++)
- {
- lastBlock[i] = iv[i];
- }
+ lastBlock[i] = iv[i];
}
public void teardown()
@@ -122,9 +106,7 @@ public class CBC extends BaseMode implements Cloneable
public void encryptBlock(byte[] in, int i, byte[] out, int o)
{
for (int k = 0; k < scratch.length; k++)
- {
- scratch[k] = (byte) (lastBlock[k] ^ in[k + i]);
- }
+ scratch[k] = (byte)(lastBlock[k] ^ in[k + i]);
cipher.encryptBlock(scratch, 0, out, o);
System.arraycopy(out, o, lastBlock, 0, cipherBlockSize);
}
@@ -135,9 +117,7 @@ public class CBC extends BaseMode implements Cloneable
System.arraycopy(in, i, buf, 0, cipherBlockSize);
cipher.decryptBlock(in, i, scratch, 0);
for (int k = 0; k < scratch.length; k++)
- {
- out[o + k] = (byte) (lastBlock[k] ^ scratch[k]);
- }
+ out[o + k] = (byte)(lastBlock[k] ^ scratch[k]);
System.arraycopy(buf, 0, lastBlock, 0, cipherBlockSize);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/CFB.java b/libjava/classpath/gnu/javax/crypto/mode/CFB.java
index fef2b634cf2..6fc00637323 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/CFB.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/CFB.java
@@ -42,58 +42,48 @@ import gnu.java.security.Registry;
import gnu.javax.crypto.cipher.IBlockCipher;
/**
- * The cipher feedback mode. CFB mode is a stream mode that operates on
- * <i>s</i> bit blocks, where 1 &lt;= <i>s</i> &lt;= <i>b</i>, if
- * <i>b</i> is the underlying cipher's block size. Encryption is:
- *
- <pre>
- I[1] = IV
- I[j] = LSB(b-s, I[j-1]) | C[j-1] for j = 2...n
- O[j] = CIPH(K, I[j]) for j = 1,2...n
- C[j] = P[j] ^ MSB(s, O[j]) for j = 1,2...n
- </pre>
- *
- * <p>And decryption is:</p>
- *
- <pre>
- I[1] = IV
- I[j] = LSB(b-s, I[j-1]) | C[j-1] for j = 2...n
- O[j] = CIPH(K, I[j]) for j = 1,2...n
- P[j] = C[j] ^ MSB(s, O[j]) for j = 1,2...n
- </pre>
- *
- * <p>CFB mode requires an initialization vector, which need not be kept
- * secret.</p>
- *
- * <p>References:</p>
+ * The cipher feedback mode. CFB mode is a stream mode that operates on <i>s</i>
+ * bit blocks, where 1 &lt;= <i>s</i> &lt;= <i>b</i>, if <i>b</i> is the
+ * underlying cipher's block size. Encryption is:
+ * <pre>
+ * I[1] = IV
+ * I[j] = LSB(b-s, I[j-1]) | C[j-1] for j = 2...n
+ * O[j] = CIPH(K, I[j]) for j = 1,2...n
+ * C[j] = P[j] &circ; MSB(s, O[j]) for j = 1,2...n
+ * </pre>
+ * <p>
+ * And decryption is:
+ * <pre>
+ * I[1] = IV
+ * I[j] = LSB(b-s, I[j-1]) | C[j-1] for j = 2...n
+ * O[j] = CIPH(K, I[j]) for j = 1,2...n
+ * P[j] = C[j] &circ; MSB(s, O[j]) for j = 1,2...n
+ * </pre>
+ * <p>
+ * CFB mode requires an initialization vector, which need not be kept secret.
+ * <p>
+ * References:
* <ol>
- * <li>Bruce Schneier, <i>Applied Cryptography: Protocols, Algorithms,
- * and Source Code in C, Second Edition</i>. (1996 John Wiley and Sons)
- * ISBN 0-471-11709-9.</li>
- *
- * <li><a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
+ * <li>Bruce Schneier, <i>Applied Cryptography: Protocols, Algorithms, and
+ * Source Code in C, Second Edition</i>. (1996 John Wiley and Sons) ISBN
+ * 0-471-11709-9.</li>
+ * <li><a
+ * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
* Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
* Morris Dworkin.</li>
* </ol>
*/
-public class CFB extends BaseMode
+public class CFB
+ extends BaseMode
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
/** The shift register, the input block to the block cipher. */
private byte[] shiftRegister;
-
/** The output block from the block cipher. */
private byte[] scratch;
- // Constructors.
- // -----------------------------------------------------------------------
-
/**
* Package-private constructor for the factory class.
- *
+ *
* @param underlyingCipher The cipher implementation.
* @param cipherBlockSize The cipher's block size.
*/
@@ -104,7 +94,7 @@ public class CFB extends BaseMode
/**
* Cloneing constructor.
- *
+ *
* @param that The instance being cloned.
*/
private CFB(CFB that)
@@ -112,9 +102,6 @@ public class CFB extends BaseMode
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Instance methods implementing BaseMode.
- // -----------------------------------------------------------------------
-
public Object clone()
{
return new CFB(this);
@@ -123,25 +110,20 @@ public class CFB extends BaseMode
public void setup()
{
if (modeBlockSize > cipherBlockSize)
- {
- throw new IllegalArgumentException(
- "CFB block size cannot be larger than the cipher block size");
- }
+ throw new IllegalArgumentException(
+ "CFB block size cannot be larger than the cipher block size");
shiftRegister = new byte[cipherBlockSize];
scratch = new byte[cipherBlockSize];
- System.arraycopy(iv, 0, shiftRegister, 0, Math.min(iv.length,
- cipherBlockSize));
+ System.arraycopy(iv, 0,
+ shiftRegister, 0,
+ Math.min(iv.length, cipherBlockSize));
}
public void teardown()
{
if (shiftRegister != null)
- {
- for (int i = 0; i < shiftRegister.length; i++)
- {
- shiftRegister[i] = 0;
- }
- }
+ for (int i = 0; i < shiftRegister.length; i++)
+ shiftRegister[i] = 0;
shiftRegister = null;
}
@@ -149,13 +131,12 @@ public class CFB extends BaseMode
{
cipher.encryptBlock(shiftRegister, 0, scratch, 0);
for (int i = 0; i < modeBlockSize; i++)
- {
- out[outOffset + i] = (byte) (in[inOffset + i] ^ scratch[i]);
- }
- System.arraycopy(shiftRegister, modeBlockSize, shiftRegister, 0,
+ out[outOffset + i] = (byte)(in[inOffset + i] ^ scratch[i]);
+ System.arraycopy(shiftRegister, modeBlockSize,
+ shiftRegister, 0,
cipherBlockSize - modeBlockSize);
- System.arraycopy(out, outOffset, shiftRegister, cipherBlockSize
- - modeBlockSize,
+ System.arraycopy(out, outOffset,
+ shiftRegister, cipherBlockSize - modeBlockSize,
modeBlockSize);
}
@@ -163,13 +144,12 @@ public class CFB extends BaseMode
{
cipher.encryptBlock(shiftRegister, 0, scratch, 0);
for (int i = 0; i < modeBlockSize; i++)
- {
- out[outOffset + i] = (byte) (in[inOffset + i] ^ scratch[i]);
- }
- System.arraycopy(shiftRegister, modeBlockSize, shiftRegister, 0,
+ out[outOffset + i] = (byte)(in[inOffset + i] ^ scratch[i]);
+ System.arraycopy(shiftRegister, modeBlockSize,
+ shiftRegister, 0,
cipherBlockSize - modeBlockSize);
- System.arraycopy(in, inOffset, shiftRegister, cipherBlockSize
- - modeBlockSize,
+ System.arraycopy(in, inOffset,
+ shiftRegister, cipherBlockSize - modeBlockSize,
modeBlockSize);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/CTR.java b/libjava/classpath/gnu/javax/crypto/mode/CTR.java
index 49f4b9f3c2a..0c856b483ee 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/CTR.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/CTR.java
@@ -40,59 +40,50 @@ package gnu.javax.crypto.mode;
import gnu.java.security.Registry;
import gnu.java.security.util.Sequence;
-
import gnu.javax.crypto.cipher.IBlockCipher;
-import java.math.BigInteger;
import java.util.Arrays;
import java.util.Iterator;
/**
- * <p>The implementation of the Counter Mode.</p>
- *
- * <p>The algorithm steps are formally described as follows:</p>
- *
+ * The implementation of the Counter Mode.
+ * <p>
+ * The algorithm steps are formally described as follows:
+ *
* <pre>
- * CTR Encryption: O[j] = E(K)(T[j]); for j = 1, 2...n;
- * C[j] = P[j] ^ O[j]; for j = 1, 2...n.
- * CTR Decryption: O[j] = E(K)(T[j]); for j = 1, 2...n;
- * P[j] = C[j] ^ O[j]; for j = 1, 2...n.
+ * CTR Encryption: O[j] = E(K)(T[j]); for j = 1, 2...n;
+ * C[j] = P[j] &circ; O[j]; for j = 1, 2...n.
+ * CTR Decryption: O[j] = E(K)(T[j]); for j = 1, 2...n;
+ * P[j] = C[j] &circ; O[j]; for j = 1, 2...n.
* </pre>
- *
- * <p>where <code>P</code> is the plaintext, <code>C</code> is the ciphertext,
+ *
+ * <p>
+ * where <code>P</code> is the plaintext, <code>C</code> is the ciphertext,
* <code>E(K)</code> is the underlying block cipher encryption function
- * parametrised with the session key <code>K</code>, and <code>T</code> is the
- * <i>Counter</i>.</p>
- *
- * <p>This implementation, uses a standard incrementing function with a step of
- * 1, and an initial value similar to that described in the NIST document.</p>
- *
- * <p>References:</p>
- *
+ * parametrised with the session key <code>K</code>, and <code>T</code> is
+ * the <i>Counter</i>.
+ * <p>
+ * This implementation, uses a standard incrementing function with a step of 1,
+ * and an initial value similar to that described in the NIST document.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
- * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
- * Morris Dworkin.</li>
+ * <li><a
+ * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
+ * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
+ * Morris Dworkin.</li>
* </ol>
*/
-public class CTR extends BaseMode implements Cloneable
+public class CTR
+ extends BaseMode
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- /** The current counter. */
- // private BigInteger T;
private int off;
-
private byte[] counter, enc;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial package-private constructor for use by the Factory class.</p>
- *
+ * Trivial package-private constructor for use by the Factory class.
+ *
* @param underlyingCipher the underlying cipher implementation.
* @param cipherBlockSize the underlying cipher block size to use.
*/
@@ -102,8 +93,8 @@ public class CTR extends BaseMode implements Cloneable
}
/**
- * <p>Private constructor for cloning purposes.</p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param that the instance to clone.
*/
private CTR(CTR that)
@@ -111,61 +102,31 @@ public class CTR extends BaseMode implements Cloneable
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Cloneable interface implementation
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new CTR(this);
}
- // Implementation of abstract methods in BaseMode
- // -------------------------------------------------------------------------
-
public void setup()
{
if (modeBlockSize > cipherBlockSize)
- {
- throw new IllegalArgumentException(
- "mode size exceeds cipher block size");
- }
+ throw new IllegalArgumentException("mode size exceeds cipher block size");
off = 0;
counter = new byte[cipherBlockSize];
int i = cipherBlockSize - 1;
int j = iv.length - 1;
while (i >= 0 && j >= 0)
- {
- counter[i--] = iv[j--];
- }
+ counter[i--] = iv[j--];
enc = new byte[cipherBlockSize];
cipher.encryptBlock(counter, 0, enc, 0);
- // if (modeBlockSize != cipherBlockSize) {
- // throw new IllegalArgumentException();
- // }
-
- // byte[] tBytes = new byte[modeBlockSize+1];
- // tBytes[0] = (byte) 0x80;
- // for (int i = 0; i < modeBlockSize; i++) {
- // tBytes[i+1] = (byte)(256 - modeBlockSize + i);
- // }
-
- // T = new BigInteger(1, tBytes);
}
public void teardown()
{
if (counter != null)
- {
- Arrays.fill(counter, (byte) 0);
- }
+ Arrays.fill(counter, (byte) 0);
if (enc != null)
- {
- Arrays.fill(enc, (byte) 0);
- }
- // T = null;
+ Arrays.fill(enc, (byte) 0);
}
public void encryptBlock(byte[] in, int i, byte[] out, int o)
@@ -183,21 +144,11 @@ public class CTR extends BaseMode implements Cloneable
return new Sequence(1, cipherBlockSize).iterator();
}
- // own methods
- // -------------------------------------------------------------------------
-
private void ctr(byte[] in, int inOffset, byte[] out, int outOffset)
{
- // T = T.add(BigInteger.ONE);
- // byte[] O = T.toByteArray();
- // int ndx = O.length - modeBlockSize;
- // cipher.encryptBlock(O, ndx, O, ndx);
- // for (int i = 0; i < modeBlockSize; i++) {
- // out[outOffset++] = (byte)(in[inOffset++] ^ O[ndx++]);
- // }
for (int i = 0; i < modeBlockSize; i++)
{
- out[outOffset++] = (byte) (in[inOffset++] ^ enc[off++]);
+ out[outOffset++] = (byte)(in[inOffset++] ^ enc[off++]);
if (off == cipherBlockSize)
{
int j;
@@ -205,17 +156,13 @@ public class CTR extends BaseMode implements Cloneable
{
counter[j]++;
if ((counter[j] & 0xFF) != 0)
- {
- break;
- }
+ break;
}
if (j == 0)
- {
- counter[cipherBlockSize - 1]++;
- }
+ counter[cipherBlockSize - 1]++;
off = 0;
cipher.encryptBlock(counter, 0, enc, 0);
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/EAX.java b/libjava/classpath/gnu/javax/crypto/mode/EAX.java
index bf260989825..401616b9f1f 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/EAX.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/EAX.java
@@ -39,13 +39,11 @@ exception statement from your version. */
package gnu.javax.crypto.mode;
import gnu.java.security.Registry;
-
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.mac.IMac;
import gnu.javax.crypto.mac.MacFactory;
import java.security.InvalidKeyException;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -53,64 +51,48 @@ import java.util.Iterator;
import java.util.Map;
/**
- * <p>A conventional two-pass authenticated-encrypted mode, EAX. EAX is a
+ * A conventional two-pass authenticated-encrypted mode, EAX. EAX is a
* <i>Authenticated Encryption with Additional Data</i> (<b>AEAD</b>) scheme,
* which provides protection and authentication for the message, and provides
* authentication of an (optional) header. EAX is composed of the counter mode
* (CTR) and the one-key CBC MAC (OMAC).
- *
- * <p>This class makes full use of the {@link IAuthenticatedMode} interface,
- * that is, all methods of both {@link IMode} and {@link IMac} can be used
- * as specified in the {@link IAuthenticatedMode} interface.
- *
- * <p>References:</p>
+ * <p>
+ * This class makes full use of the {@link IAuthenticatedMode} interface, that
+ * is, all methods of both {@link IMode} and {@link IMac} can be used as
+ * specified in the {@link IAuthenticatedMode} interface.
+ * <p>
+ * References:
* <ol>
* <li>M. Bellare, P. Rogaway, and D. Wagner; <a
* href="http://www.cs.berkeley.edu/~daw/papers/eprint-short-ae.pdf">A
* Conventional Authenticated-Encryption Mode</a>.</li>
* </ol>
*/
-public class EAX implements IAuthenticatedMode
+public class EAX
+ implements IAuthenticatedMode
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
/** The tag size, in bytes. */
private int tagSize;
-
/** The nonce OMAC instance. */
private IMac nonceOmac;
-
/** The header OMAC instance. */
private IMac headerOmac;
-
/** The message OMAC instance. */
private IMac msgOmac;
-
/** The CTR instance. */
private IMode ctr;
-
/** The direction state (encrypting or decrypting). */
private int state;
-
/** Whether we're initialized or not. */
private boolean init;
-
/** The cipher block size. */
private int cipherBlockSize;
-
/** The cipher. */
private IBlockCipher cipher;
-
/** The [t]_n array. */
private byte[] t_n;
-
private static boolean valid = false;
- // Constructor.
- // ------------------------------------------------------------------------
-
public EAX(IBlockCipher cipher, int cipherBlockSize)
{
this.cipher = cipher;
@@ -118,9 +100,7 @@ public class EAX implements IAuthenticatedMode
String name = cipher.name();
int i = name.indexOf('-');
if (i >= 0)
- {
- name = name.substring(0, i);
- }
+ name = name.substring(0, i);
String omacname = Registry.OMAC_PREFIX + name;
nonceOmac = MacFactory.getInstance(omacname);
headerOmac = MacFactory.getInstance(omacname);
@@ -130,9 +110,6 @@ public class EAX implements IAuthenticatedMode
init = false;
}
- // IMode instance methods.
- // ------------------------------------------------------------------------
-
public Object clone()
{
return new EAX((IBlockCipher) cipher.clone(), cipherBlockSize);
@@ -167,17 +144,12 @@ public class EAX implements IAuthenticatedMode
{
byte[] nonce = (byte[]) attrib.get(IV);
if (nonce == null)
- {
- throw new IllegalArgumentException("no nonce provided");
- }
+ throw new IllegalArgumentException("no nonce provided");
byte[] key = (byte[]) attrib.get(KEY_MATERIAL);
if (key == null)
- {
- throw new IllegalArgumentException("no key provided");
- }
+ throw new IllegalArgumentException("no key provided");
Arrays.fill(t_n, (byte) 0);
-
nonceOmac.reset();
nonceOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key));
nonceOmac.update(t_n, 0, t_n.length);
@@ -186,57 +158,41 @@ public class EAX implements IAuthenticatedMode
nonceOmac.reset();
nonceOmac.update(t_n, 0, t_n.length);
nonceOmac.update(nonce, 0, nonce.length);
-
t_n[t_n.length - 1] = 1;
headerOmac.reset();
headerOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key));
headerOmac.update(t_n, 0, t_n.length);
-
t_n[t_n.length - 1] = 2;
msgOmac.reset();
msgOmac.init(Collections.singletonMap(MAC_KEY_MATERIAL, key));
msgOmac.update(t_n, 0, t_n.length);
-
Integer modeSize = (Integer) attrib.get(MODE_BLOCK_SIZE);
if (modeSize == null)
- {
- modeSize = new Integer(cipherBlockSize);
- }
+ modeSize = Integer.valueOf(cipherBlockSize);
HashMap ctrAttr = new HashMap();
ctrAttr.put(KEY_MATERIAL, key);
ctrAttr.put(IV, N);
- ctrAttr.put(STATE, new Integer(ENCRYPTION));
+ ctrAttr.put(STATE, Integer.valueOf(ENCRYPTION));
ctrAttr.put(MODE_BLOCK_SIZE, modeSize);
ctr.reset();
ctr.init(ctrAttr);
-
Integer st = (Integer) attrib.get(STATE);
if (st != null)
{
state = st.intValue();
if (state != ENCRYPTION && state != DECRYPTION)
- {
- throw new IllegalArgumentException("invalid state");
- }
+ throw new IllegalArgumentException("invalid state");
}
else
- {
- state = ENCRYPTION;
- }
+ state = ENCRYPTION;
Integer ts = (Integer) attrib.get(TRUNCATED_SIZE);
if (ts != null)
- {
- tagSize = ts.intValue();
- }
+ tagSize = ts.intValue();
else
- {
- tagSize = cipherBlockSize;
- }
+ tagSize = cipherBlockSize;
if (tagSize < 0 || tagSize > cipherBlockSize)
- {
- throw new IllegalArgumentException("tag size out of range");
- }
+ throw new IllegalArgumentException("tag size out of range");
init = true;
}
@@ -247,28 +203,20 @@ public class EAX implements IAuthenticatedMode
public void encryptBlock(byte[] in, int inOff, byte[] out, int outOff)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
if (state != ENCRYPTION)
- {
- throw new IllegalStateException("not encrypting");
- }
+ throw new IllegalStateException("not encrypting");
ctr.update(in, inOff, out, outOff);
msgOmac.update(out, outOff, ctr.currentBlockSize());
}
public void decryptBlock(byte[] in, int inOff, byte[] out, int outOff)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
if (state != DECRYPTION)
- {
- throw new IllegalStateException("not decrypting");
- }
+ throw new IllegalStateException("not decrypting");
msgOmac.update(in, inOff, ctr.currentBlockSize());
ctr.update(in, inOff, out, outOff);
}
@@ -301,9 +249,6 @@ public class EAX implements IAuthenticatedMode
return true; // XXX
}
- // IMac instance methods.
- // ------------------------------------------------------------------------
-
public int macSize()
{
return tagSize;
@@ -319,34 +264,26 @@ public class EAX implements IAuthenticatedMode
public void digest(byte[] out, int outOffset)
{
if (outOffset < 0 || outOffset + tagSize > out.length)
- {
- throw new IndexOutOfBoundsException();
- }
+ throw new IndexOutOfBoundsException();
byte[] N = nonceOmac.digest();
byte[] H = headerOmac.digest();
byte[] M = msgOmac.digest();
for (int i = 0; i < tagSize; i++)
- {
- out[outOffset + i] = (byte) (N[i] ^ H[i] ^ M[i]);
- }
+ out[outOffset + i] = (byte)(N[i] ^ H[i] ^ M[i]);
reset();
}
public void update(byte b)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
headerOmac.update(b);
}
public void update(byte[] buf, int off, int len)
{
- if (!init)
- {
- throw new IllegalStateException("not initialized");
- }
+ if (! init)
+ throw new IllegalStateException("not initialized");
headerOmac.update(buf, off, len);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/ECB.java b/libjava/classpath/gnu/javax/crypto/mode/ECB.java
index 3b33a1848fe..665e526ca11 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/ECB.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/ECB.java
@@ -42,44 +42,40 @@ import gnu.java.security.Registry;
import gnu.javax.crypto.cipher.IBlockCipher;
/**
- * <p>The implementation of the Electronic Codebook mode.</p>
- *
- * <p>The Electronic Codebook (ECB) mode is a confidentiality mode that is
- * defined as follows:</p>
- *
+ * The implementation of the Electronic Codebook mode.
+ * <p>
+ * The Electronic Codebook (ECB) mode is a confidentiality mode that is defined
+ * as follows:
* <ul>
- * <li>ECB Encryption: C<sub>j</sub> = CIPH<sub>K</sub>(P<sub>j</sub>) for j = 1...n</li>
- * <li>ECB Decryption: P<sub>j</sub> = CIPH<sup>-1</sup><sub>K</sub>(C<sub>j</sub>) for j = 1...n</li>
+ * <li>ECB Encryption: C<sub>j</sub> = CIPH<sub>K</sub>(P<sub>j</sub>)
+ * for j = 1...n</li>
+ * <li>ECB Decryption: P<sub>j</sub> = CIPH<sup>-1</sup><sub>K</sub>(C<sub>j</sub>)
+ * for j = 1...n</li>
* </ul>
- *
- * <p>In ECB encryption, the forward cipher function is applied directly, and
+ * <p>
+ * In ECB encryption, the forward cipher function is applied directly, and
* independently, to each block of the plaintext. The resulting sequence of
- * output blocks is the ciphertext.</p>
- *
- * <p>In ECB decryption, the inverse cipher function is applied directly, and
+ * output blocks is the ciphertext.
+ * <p>
+ * In ECB decryption, the inverse cipher function is applied directly, and
* independently, to each block of the ciphertext. The resulting sequence of
- * output blocks is the plaintext.</p>
- *
- * <p>References:</p>
- *
+ * output blocks is the plaintext.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
- * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
- * Morris Dworkin.</li>
+ * <li><a
+ * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
+ * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
+ * Morris Dworkin.</li>
* </ol>
*/
-public class ECB extends BaseMode implements Cloneable
+public class ECB
+ extends BaseMode
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial package-private constructor for use by the Factory class.</p>
- *
+ * Trivial package-private constructor for use by the Factory class.
+ *
* @param underlyingCipher the underlying cipher implementation.
* @param cipherBlockSize the underlying cipher block size to use.
*/
@@ -89,8 +85,8 @@ public class ECB extends BaseMode implements Cloneable
}
/**
- * <p>Private constructor for cloning purposes.</p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param that the mode to clone.
*/
private ECB(ECB that)
@@ -98,27 +94,15 @@ public class ECB extends BaseMode implements Cloneable
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new ECB(this);
}
- // Implementation of abstract methods in BaseMode --------------------------
-
public void setup()
{
if (modeBlockSize != cipherBlockSize)
- {
- throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE);
- }
+ throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE);
}
public void teardown()
@@ -134,4 +118,4 @@ public class ECB extends BaseMode implements Cloneable
{
cipher.decryptBlock(in, i, out, o);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java b/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
index 989e3edbcd0..703679dc0a6 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
@@ -43,16 +43,14 @@ import gnu.javax.crypto.mac.IMac;
/**
* The interface for encryption modes that also produce a message authentication
* tag.
- *
- * <p>This interface is merely the conjuction of the {@link IMode} and
- * {@link IMac} interfaces. Encryption and decryption is done via the
- * {@link IMode#update(byte[],int,byte[],int)} method, tag generation
- * is done via the {@link IMac#digest()} method, and header updating
- * (if supported by the mode) is done via the {@link
- * IMac#update(byte[],int,int)} method.
+ * <p>
+ * This interface is merely the conjuction of the {@link IMode} and {@link IMac}
+ * interfaces. Encryption and decryption is done via the
+ * {@link IMode#update(byte[],int,byte[],int)} method, tag generation is done
+ * via the {@link IMac#digest()} method, and header updating (if supported by
+ * the mode) is done via the {@link IMac#update(byte[],int,int)} method.
*/
-public interface IAuthenticatedMode extends IMode, IMac
+public interface IAuthenticatedMode
+ extends IMode, IMac
{
-
- // Trivial conjunction of IMode and IMac.
}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/ICM.java b/libjava/classpath/gnu/javax/crypto/mode/ICM.java
index d37908b5dfd..833ddb18f7f 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/ICM.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/ICM.java
@@ -44,75 +44,66 @@ import gnu.javax.crypto.cipher.IBlockCipher;
import java.math.BigInteger;
/**
- * <p>An implementation of <i>David McGrew</i> Integer Counter Mode (ICM) as an
- * {@link IMode}.</p>
- *
- * <p>ICM is a way to define a pseudorandom keystream generator using a block
- * cipher. The keystream can be used for additive encryption, key derivation,
- * or any other application requiring pseudorandom data. In the case of this
- * class, it is used as additive encryption, XOR-ing the keystream with the
- * input text --for both encryption and decryption.</p>
- *
- * <p>In ICM, the keystream is logically broken into segments. Each segment is
+ * An implementation of <i>David McGrew</i> Integer Counter Mode (ICM) as an
+ * {@link IMode}.
+ * <p>
+ * ICM is a way to define a pseudorandom keystream generator using a block
+ * cipher. The keystream can be used for additive encryption, key derivation, or
+ * any other application requiring pseudorandom data. In the case of this class,
+ * it is used as additive encryption, XOR-ing the keystream with the input text
+ * --for both encryption and decryption.
+ * <p>
+ * In ICM, the keystream is logically broken into segments. Each segment is
* identified with a segment index, and the segments have equal lengths. This
* segmentation makes ICM especially appropriate for securing packet-based
* protocols. ICM also allows a variety of configurations based, among other
- * things, on two parameters: the <i>block index length</i> and the
- * <i>segment index length</i>. A constraint on those two values exists: The sum
- * of <i>segment index length</i> and <i>block index length</i> <b>must not</b>
- * half the <i>block size</i> of the underlying cipher. This requirement protects
- * the ICM keystream generator from potentially failing to be pseudorandom.</p>
- *
- * <p>For simplicity, this implementation, fixes these two values to the
- * following:</p>
- *
+ * things, on two parameters: the <i>block index length</i> and the <i>segment
+ * index length</i>. A constraint on those two values exists: The sum of
+ * <i>segment index length</i> and <i>block index length</i> <b>must not</b>
+ * half the <i>block size</i> of the underlying cipher. This requirement
+ * protects the ICM keystream generator from potentially failing to be
+ * pseudorandom.
+ * <p>
+ * For simplicity, this implementation, fixes these two values to the following:
* <ul>
- * <li>block index length: is half the underlying cipher block size, and</li>
- * <li>segment index length: is zero.</li>
+ * <li>block index length: is half the underlying cipher block size, and</li>
+ * <li>segment index length: is zero.</li>
* </ul>
- *
- * <p>For a 128-bit block cipher, the above values imply a maximum keystream
- * length of 295,147,905,179,352,825,856 octets, since in ICM, each segment must
- * not exceed the value <code>(256 ^ <i>block index length</i>) * <i>block length</i></code>
- * octets.</p>
- *
- * <p>Finally, for this implementation of the ICM, the IV placeholder will be
- * used to pass the value of the <i>Offset</i> in the keystream segment.</p>
- *
- * <p>References:</p>
- *
+ * <p>
+ * For a 128-bit block cipher, the above values imply a maximum keystream length
+ * of 295,147,905,179,352,825,856 octets, since in ICM, each segment must not
+ * exceed the value
+ * <code>(256 ^ <i>block index length</i>) * <i>block length</i></code>
+ * octets.
+ * <p>
+ * Finally, for this implementation of the ICM, the IV placeholder will be used
+ * to pass the value of the <i>Offset</i> in the keystream segment.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-icm-00.txt">
- * Integer Counter Mode</a>, David A. McGrew.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-icm-00.txt">
+ * Integer Counter Mode</a>, David A. McGrew.</li>
* </ol>
*/
-public class ICM extends BaseMode implements Cloneable
+public class ICM
+ extends BaseMode
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The integer value 256 as a BigInteger. */
private static final BigInteger TWO_FIFTY_SIX = new BigInteger("256");
-
/** Maximum number of blocks per segment. */
private BigInteger maxBlocksPerSegment;
-
/** A work constant. */
private BigInteger counterRange;
-
/** The initial counter for a given keystream segment. */
private BigInteger C0;
-
/** The index of the next block for a given keystream segment. */
private BigInteger blockNdx;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial package-private constructor for use by the Factory class.</p>
- *
+ * Trivial package-private constructor for use by the Factory class.
+ *
* @param underlyingCipher the underlying cipher implementation.
* @param cipherBlockSize the underlying cipher block size to use.
*/
@@ -122,8 +113,8 @@ public class ICM extends BaseMode implements Cloneable
}
/**
- * <p>Private constructor for cloning purposes.<p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param that the instance to clone.
*/
private ICM(ICM that)
@@ -131,27 +122,15 @@ public class ICM extends BaseMode implements Cloneable
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Cloneable interface implementation
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new ICM(this);
}
- // Implementation of abstract methods in BaseMode
- // -------------------------------------------------------------------------
-
public void setup()
{
if (modeBlockSize != cipherBlockSize)
- {
- throw new IllegalArgumentException();
- }
-
+ throw new IllegalArgumentException();
counterRange = TWO_FIFTY_SIX.pow(cipherBlockSize);
maxBlocksPerSegment = TWO_FIFTY_SIX.pow(cipherBlockSize / 2);
BigInteger r = new BigInteger(1, iv);
@@ -177,35 +156,13 @@ public class ICM extends BaseMode implements Cloneable
icm(in, i, out, o);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
private void icm(byte[] in, int inOffset, byte[] out, int outOffset)
{
if (blockNdx.compareTo(maxBlocksPerSegment) >= 0)
throw new RuntimeException("Maximum blocks for segment reached");
-
- // encrypt the counter for the current blockNdx
- // C[i] = (C[0] + i) modulo (256^BLOCK_LENGTH).
-
BigInteger Ci = C0.add(blockNdx).modPow(BigInteger.ONE, counterRange);
byte[] result = Ci.toByteArray();
int limit = result.length;
- // if (limit < cipherBlockSize) {
- // byte[] data = new byte[cipherBlockSize];
- // System.arraycopy(result, 0, data, cipherBlockSize-limit, limit);
- // result = data;
- // } else if (limit > cipherBlockSize) {
- // byte[] data = new byte[cipherBlockSize];
- // System.arraycopy(result, limit-cipherBlockSize, data, 0, cipherBlockSize);
- // result = data;
- // }
- //
- // cipher.encryptBlock(result, 0, result, 0);
- // blockNdx = blockNdx.add(BigInteger.ONE); // increment blockNdx
- // for (int i = 0; i < modeBlockSize; ) { // xor result with input block
- // out[outOffset++] = (byte)(in[inOffset++] ^ result[i++]);
- // }
int ndx = 0;
if (limit < cipherBlockSize)
{
@@ -214,15 +171,11 @@ public class ICM extends BaseMode implements Cloneable
result = data;
}
else if (limit > cipherBlockSize)
- {
- ndx = limit - cipherBlockSize;
- }
+ ndx = limit - cipherBlockSize;
cipher.encryptBlock(result, ndx, result, ndx);
blockNdx = blockNdx.add(BigInteger.ONE); // increment blockNdx
- for (int i = 0; i < modeBlockSize; i++)
- { // xor result with input block
- out[outOffset++] = (byte) (in[inOffset++] ^ result[ndx++]);
- }
+ for (int i = 0; i < modeBlockSize; i++) // xor result with input block
+ out[outOffset++] = (byte)(in[inOffset++] ^ result[ndx++]);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/IMode.java b/libjava/classpath/gnu/javax/crypto/mode/IMode.java
index 4cb6ca64bd9..30485117d45 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/IMode.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/IMode.java
@@ -41,105 +41,83 @@ package gnu.javax.crypto.mode;
import gnu.javax.crypto.cipher.IBlockCipher;
/**
- * <p>The basic visible methods of any block cipher mode.</p>
- *
- * <p>Block ciphers encrypt plaintext in fixed size n-bit blocks. For messages
+ * The basic visible methods of any block cipher mode.
+ * <p>
+ * Block ciphers encrypt plaintext in fixed size n-bit blocks. For messages
* larger than n bits, the simplest approach is to segment the message into
* n-bit blocks and process (encrypt and/or decrypt) each one separately
* (Electronic Codebook or ECB mode). But this approach has disadvantages in
* most applications. The block cipher modes of operations are one way of
- * working around those disadvantages.</p>
- *
- * <p>A <i>Mode</i> always employs an underlying block cipher for processing its
+ * working around those disadvantages.
+ * <p>
+ * A <i>Mode</i> always employs an underlying block cipher for processing its
* input. For all intents and purposes, a <i>Mode</i> appears to behave as any
- * other block cipher with the following differences:</p>
- *
+ * other block cipher with the following differences:
* <ul>
- * <li>Depending on the specifications of the mode, the block size may be
- * different that that of the underlying cipher.</li>
- *
- * <li>While some modes of operations allow operations on block sizes that
- * can be 1-bit long, this library will only deal with sizes that are
- * multiple of 8 bits. This is because the <tt>byte</tt> is the smallest,
- * easy to handle, primitive type in Java.</li>
- *
- * <li>Some modes need an <i>Initialisation Vector</i> (IV) to be properly
- * initialised.</li>
+ * <li>Depending on the specifications of the mode, the block size may be
+ * different that that of the underlying cipher.</li>
+ * <li>While some modes of operations allow operations on block sizes that can
+ * be 1-bit long, this library will only deal with sizes that are multiple of 8
+ * bits. This is because the <tt>byte</tt> is the smallest, easy to handle,
+ * primitive type in Java.</li>
+ * <li>Some modes need an <i>Initialisation Vector</i> (IV) to be properly
+ * initialised.</li>
* </ul>
- *
- * <p>Possible additional initialisation values for an instance of that type
- * are:</p>
- *
+ * <p>
+ * Possible additional initialisation values for an instance of that type are:
* <ul>
- * <li>The block size in which to operate this mode instance. This
- * value is <b>optional</b>, if unspecified, the underlying block cipher's
- * configured block size shall be used.</li>
- *
- * <li>Whether this mode will be used for encryption or decryption. This
- * value is <b>mandatory</b> and should be included in the initialisation
- * parameters. If it isn't, a {@link java.lang.IllegalStateException} will
- * be thrown if any method, other than <code>reset()</code> is invoked on the
- * instance.</li>
- *
- * <li>The byte array containing the <i>initialisation vector</i>, if
- * required by this type of mode.</li>
+ * <li>The block size in which to operate this mode instance. This value is
+ * <b>optional</b>, if unspecified, the underlying block cipher's configured
+ * block size shall be used.</li>
+ * <li>Whether this mode will be used for encryption or decryption. This value
+ * is <b>mandatory</b> and should be included in the initialisation parameters.
+ * If it isn't, a {@link java.lang.IllegalStateException} will be thrown if any
+ * method, other than <code>reset()</code> is invoked on the instance.</li>
+ * <li>The byte array containing the <i>initialisation vector</i>, if required
+ * by this type of mode.</li>
* </ul>
*/
-public interface IMode extends IBlockCipher
+public interface IMode
+ extends IBlockCipher
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/**
- * <p>Property name of the state in which to operate this mode. The value
+ * Property name of the state in which to operate this mode. The value
* associated to this property name is taken to be an {@link Integer} which
- * value is either <code>ENCRYPTION</code> or <code>DECRYPTION</code>.</p>
+ * value is either <code>ENCRYPTION</code> or <code>DECRYPTION</code>.
*/
String STATE = "gnu.crypto.mode.state";
-
/**
- * <p>Property name of the block size in which to operate this mode. The
- * value associated with this property name is taken to be an {@link Integer}.
- * If it is not specified, the value of the block size of the underlying
- * block cipher, used to construct the mode instance, shall be used.</p>
+ * Property name of the block size in which to operate this mode. The value
+ * associated with this property name is taken to be an {@link Integer}. If
+ * it is not specified, the value of the block size of the underlying block
+ * cipher, used to construct the mode instance, shall be used.
*/
String MODE_BLOCK_SIZE = "gnu.crypto.mode.block.size";
-
/**
- * <p>Property name of the initialisation vector to use, if required, with
- * this instance. The value associated with this property name is taken to
- * be a byte array. If the concrete instance needs such a parameter, and it
- * has not been specified as part of the initialissation parameters, an
- * all-zero byte array of the appropriate size shall be used.</p>
+ * Property name of the initialisation vector to use, if required, with this
+ * instance. The value associated with this property name is taken to be a
+ * byte array. If the concrete instance needs such a parameter, and it has not
+ * been specified as part of the initialissation parameters, an all-zero byte
+ * array of the appropriate size shall be used.
*/
String IV = "gnu.crypto.mode.iv";
-
- /**
- * <p>Constant indicating the instance is being used for <i>encryption</i>.</p>
- */
+ /** Constant indicating the instance is being used for <i>encryption</i>. */
int ENCRYPTION = 1;
-
- /**
- * <p>Constant indicating the instance is being used for <i>decryption</i>.</p>
- */
+ /** Constant indicating the instance is being used for <i>decryption</i>. */
int DECRYPTION = 2;
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A convenience method. Effectively invokes the <code>encryptBlock()</code>
+ * A convenience method. Effectively invokes the <code>encryptBlock()</code>
* or <code>decryptBlock()</code> method depending on the operational state
- * of the instance.</p>
- *
+ * of the instance.
+ *
* @param in the plaintext.
* @param inOffset index of <code>in</code> from which to start considering
- * data.
+ * data.
* @param out the ciphertext.
* @param outOffset index of <code>out</code> from which to store result.
* @exception IllegalStateException if the instance is not initialised.
*/
void update(byte[] in, int inOffset, byte[] out, int outOffset)
throws IllegalStateException;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/ModeFactory.java b/libjava/classpath/gnu/javax/crypto/mode/ModeFactory.java
index 0e949ed9e96..d1acdf4e599 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/ModeFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/ModeFactory.java
@@ -49,16 +49,12 @@ import java.util.Iterator;
import java.util.Set;
/**
- * <p>A <i>Factory</i> to instantiate block cipher modes of operations.</p>
+ * A <i>Factory</i> to instantiate block cipher modes of operations.
*/
-public class ModeFactory implements Registry
+public class ModeFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ private static Set names;
/** Trivial constructor to enforce Singleton pattern. */
private ModeFactory()
@@ -66,37 +62,29 @@ public class ModeFactory implements Registry
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a block cipher mode of operations given its name
- * and characteristics of the underlying block cipher.</p>
- *
+ * Returns an instance of a block cipher mode of operations given its name and
+ * characteristics of the underlying block cipher.
+ *
* @param mode the case-insensitive name of the mode of operations.
* @param cipher the case-insensitive name of the block cipher.
* @param cipherBlockSize the block size, in bytes, of the underlying cipher.
* @return an instance of the block cipher algorithm, operating in a given
- * mode of operations, or <code>null</code> if none found.
+ * mode of operations, or <code>null</code> if none found.
* @exception InternalError if either the mode or the underlying block cipher
- * implementation does not pass its self-test.
+ * implementation does not pass its self-test.
*/
public static IMode getInstance(String mode, String cipher,
int cipherBlockSize)
{
if (mode == null || cipher == null)
- {
- return null;
- }
+ return null;
mode = mode.trim();
cipher = cipher.trim();
-
IBlockCipher cipherImpl = CipherFactory.getInstance(cipher);
if (cipherImpl == null)
- {
- return null;
- }
+ return null;
return getInstance(mode, cipherImpl, cipherBlockSize);
}
@@ -110,59 +98,36 @@ public class ModeFactory implements Registry
{
ok = (cipherBlockSize == ((Integer) it.next()).intValue());
if (ok)
- {
- break;
- }
- }
-
- if (!ok)
- {
- throw new IllegalArgumentException("cipherBlockSize");
+ break;
}
-
+ if (! ok)
+ throw new IllegalArgumentException("cipherBlockSize");
IMode result = null;
if (mode.equalsIgnoreCase(ECB_MODE))
- {
- result = new ECB(cipher, cipherBlockSize);
- }
+ result = new ECB(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(CTR_MODE))
- {
- result = new CTR(cipher, cipherBlockSize);
- }
+ result = new CTR(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(ICM_MODE))
- {
- result = new ICM(cipher, cipherBlockSize);
- }
+ result = new ICM(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(OFB_MODE))
- {
- result = new OFB(cipher, cipherBlockSize);
- }
+ result = new OFB(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(CBC_MODE))
- {
- result = new CBC(cipher, cipherBlockSize);
- }
+ result = new CBC(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(CFB_MODE))
- {
- result = new CFB(cipher, cipherBlockSize);
- }
+ result = new CFB(cipher, cipherBlockSize);
else if (mode.equalsIgnoreCase(EAX_MODE))
- {
- result = new EAX(cipher, cipherBlockSize);
- }
+ result = new EAX(cipher, cipherBlockSize);
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link java.util.Set} of names of mode supported by this
- * <i>Factory</i>.</p>
- *
- * @return a {@link java.util.Set} of mode names (Strings).
+ * Returns a {@link Set} of names of mode supported by this <i>Factory</i>.
+ *
+ * @return a {@link Set} of mode names (Strings).
*/
public static final Set getNames()
{
@@ -178,15 +143,9 @@ public class ModeFactory implements Registry
hs.add(CBC_MODE);
hs.add(CFB_MODE);
hs.add(EAX_MODE);
-
names = Collections.unmodifiableSet(hs);
}
}
return names;
}
-
- private static Set names;
-
- // Instance methods
- // -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/OFB.java b/libjava/classpath/gnu/javax/crypto/mode/OFB.java
index 68065d10b9c..c8b6d7e97e7 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/OFB.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/OFB.java
@@ -39,33 +39,33 @@ exception statement from your version. */
package gnu.javax.crypto.mode;
import gnu.java.security.Registry;
-
import gnu.javax.crypto.cipher.IBlockCipher;
/**
- * <p>The Output Feedback (OFB) mode is a confidentiality mode that requires a
+ * The Output Feedback (OFB) mode is a confidentiality mode that requires a
* unique <code>IV</code> for every message that is ever encrypted under the
- * given key. The OFB mode is defined as follows:</p>
- *
+ * given key. The OFB mode is defined as follows:
+ * <ul>
+ * <li>OFB Encryption:
* <ul>
- * <li>OFB Encryption:
- * <ul>
- * <li>I<sub>1</sub> = IV;</li>
- * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li>
- * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li>
- * <li>C<sub>j</sub> = P<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li>
- * </ul></li>
+ * <li>I<sub>1</sub> = IV;</li>
+ * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li>
+ * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li>
+ * <li>C<sub>j</sub> = P<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li>
+ * </ul>
+ * </li>
* <li>OFB Decryption:
- * <ul>
- * <li>I<sub>1</sub> = IV;</li>
- * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li>
- * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li>
- * <li>P<sub>j</sub> = C<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li>
- * </ul></li>
+ * <ul>
+ * <li>I<sub>1</sub> = IV;</li>
+ * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li>
+ * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li>
+ * <li>P<sub>j</sub> = C<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li>
* </ul>
- *
- * <p>In OFB encryption, the <code>IV</code> is transformed by the forward
- * cipher function to produce the first output block. The first output block is
+ * </li>
+ * </ul>
+ * <p>
+ * In OFB encryption, the <code>IV</code> is transformed by the forward cipher
+ * function to produce the first output block. The first output block is
* exclusive-ORed with the first plaintext block to produce the first ciphertext
* block. The first output block is then transformed by the forward cipher
* function to produce the second output block. The second output block is
@@ -74,9 +74,9 @@ import gnu.javax.crypto.cipher.IBlockCipher;
* cipher function to produce the third output block. Thus, the successive
* output blocks are produced from enciphering the previous output blocks, and
* the output blocks are exclusive-ORed with the corresponding plaintext blocks
- * to produce the ciphertext blocks.</p>
- *
- * <p>In OFB decryption, the <code>IV</code> is transformed by the forward cipher
+ * to produce the ciphertext blocks.
+ * <p>
+ * In OFB decryption, the <code>IV</code> is transformed by the forward cipher
* function to produce the first output block. The first output block is
* exclusive-ORed with the first ciphertext block to recover the first plaintext
* block. The first output block is then transformed by the forward cipher
@@ -86,51 +86,46 @@ import gnu.javax.crypto.cipher.IBlockCipher;
* forward cipher function to produce the third output block. Thus, the
* successive output blocks are produced from enciphering the previous output
* blocks, and the output blocks are exclusive-ORed with the corresponding
- * ciphertext blocks to recover the plaintext blocks.</p>
- *
- * <p>In both OFB encryption and OFB decryption, each forward cipher function
+ * ciphertext blocks to recover the plaintext blocks.
+ * <p>
+ * In both OFB encryption and OFB decryption, each forward cipher function
* (except the first) depends on the results of the previous forward cipher
- * function; therefore, multiple forward cipher functions cannot be performed
- * in parallel. However, if the <code>IV</code> is known, the output blocks can
- * be generated prior to the availability of the plaintext or ciphertext data.</p>
- *
- * <p>The OFB mode requires a unique <code>IV</code> for every message that is
+ * function; therefore, multiple forward cipher functions cannot be performed in
+ * parallel. However, if the <code>IV</code> is known, the output blocks can
+ * be generated prior to the availability of the plaintext or ciphertext data.
+ * <p>
+ * The OFB mode requires a unique <code>IV</code> for every message that is
* ever encrypted under the given key. If, contrary to this requirement, the
* same <code>IV</code> is used for the encryption of more than one message,
* then the confidentiality of those messages may be compromised. In particular,
* if a plaintext block of any of these messages is known, say, the j<sup>th</sup>
* plaintext block, then the j<sup>th</sup> output of the forward cipher
- * function can be determined easily from the j<sup>th</sup> ciphertext block of
- * the message. This information allows the j<sup>th</sup> plaintext block of
- * any other message that is encrypted using the same <code>IV</code> to be
- * easily recovered from the jth ciphertext block of that message.</p>
- *
- * <p>Confidentiality may similarly be compromised if any of the input blocks to
+ * function can be determined easily from the j<sup>th</sup> ciphertext block
+ * of the message. This information allows the j<sup>th</sup> plaintext block
+ * of any other message that is encrypted using the same <code>IV</code> to be
+ * easily recovered from the jth ciphertext block of that message.
+ * <p>
+ * Confidentiality may similarly be compromised if any of the input blocks to
* the forward cipher function for the encryption of a message is used as the
- * <code>IV</code> for the encryption of another message under the given key.</p>
- *
- * <p>References:</p>
- *
+ * <code>IV</code> for the encryption of another message under the given key.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
- * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
- * Morris Dworkin.</li>
+ * <li><a
+ * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
+ * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
+ * Morris Dworkin.</li>
* </ol>
*/
-public class OFB extends BaseMode implements Cloneable
+public class OFB
+ extends BaseMode
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private byte[] outputBlock;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial package-private constructor for use by the Factory class.</p>
- *
+ * Trivial package-private constructor for use by the Factory class.
+ *
* @param underlyingCipher the underlying cipher implementation.
* @param cipherBlockSize the underlying cipher block size to use.
*/
@@ -140,8 +135,8 @@ public class OFB extends BaseMode implements Cloneable
}
/**
- * <p>Private constructor for cloning purposes.</p>
- *
+ * Private constructor for cloning purposes.
+ *
* @param that the mode to clone.
*/
private OFB(OFB that)
@@ -149,28 +144,15 @@ public class OFB extends BaseMode implements Cloneable
this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // java.lang.Cloneable interface implementation ----------------------------
-
public Object clone()
{
return new OFB(this);
}
- // Implementation of abstract methods in BaseMode --------------------------
-
public void setup()
{
if (modeBlockSize != cipherBlockSize)
- {
- throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE);
- }
-
+ throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE);
outputBlock = (byte[]) iv.clone();
}
@@ -182,13 +164,11 @@ public class OFB extends BaseMode implements Cloneable
{
cipher.encryptBlock(outputBlock, 0, outputBlock, 0);
for (int j = 0; j < cipherBlockSize;)
- {
- out[o++] = (byte) (in[i++] ^ outputBlock[j++]);
- }
+ out[o++] = (byte)(in[i++] ^ outputBlock[j++]);
}
public void decryptBlock(byte[] in, int i, byte[] out, int o)
{
this.encryptBlock(in, i, out, o);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/BasePad.java b/libjava/classpath/gnu/javax/crypto/pad/BasePad.java
index 49c5d050a85..8b475d2d8cb 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/BasePad.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/BasePad.java
@@ -38,24 +38,24 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
+import gnu.java.security.Configuration;
+
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
- * <p>An abstract class to facilitate implementing padding algorithms.</p>
+ * An abstract class to facilitate implementing padding algorithms.
*/
-public abstract class BasePad implements IPad
+public abstract class BasePad
+ implements IPad
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(BasePad.class.getName());
/** The canonical name prefix of the padding algorithm. */
protected String name;
-
/** The block size, in bytes, for this instance. */
protected int blockSize;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor for use by concrete subclasses. */
protected BasePad(final String name)
{
@@ -65,84 +65,122 @@ public abstract class BasePad implements IPad
blockSize = -1;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IPad interface implementation -------------------------------------------
-
public String name()
{
final StringBuffer sb = new StringBuffer(name);
if (blockSize != -1)
- {
- sb.append('-').append(String.valueOf(8 * blockSize));
- }
+ sb.append('-').append(String.valueOf(8 * blockSize));
return sb.toString();
}
public void init(final int bs) throws IllegalStateException
{
if (blockSize != -1)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
blockSize = bs;
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;
}
+ /**
+ * A default implementation of a correctness test that exercises the padder
+ * implementation, using block sizes varying from 2 to 256 bytes.
+ *
+ * @return <code>true</code> if the concrete implementation correctly unpads
+ * what it pads for all tested block sizes. Returns <code>false</code>
+ * if the test fails for any block size.
+ */
public boolean selfTest()
{
+ final byte[] in = new byte[1024];
+ for (int bs = 2; bs < 256; bs++)
+ if (! test1BlockSize(bs, in))
+ return false;
+ return true;
+ }
+
+ /**
+ * The basic symmetric test for a padder given a specific block size.
+ * <p>
+ * The code ensures that the implementation is capable of unpadding what it
+ * pads.
+ *
+ * @param size the block size to test.
+ * @param buffer a work buffer. It is exposed as an argument for this method
+ * to reduce un-necessary object allocations.
+ * @return <code>true</code> if the test passes; <code>false</code>
+ * otherwise.
+ */
+ protected boolean test1BlockSize(int size, byte[] buffer)
+ {
byte[] padBytes;
final int offset = 5;
- final int limit = 1024;
- final byte[] in = new byte[limit];
- for (int bs = 2; bs < 256; bs++)
+ final int limit = buffer.length;
+ this.init(size);
+ for (int i = 0; i < limit - offset - blockSize; i++)
{
- this.init(bs);
- for (int i = 0; i < limit - offset - blockSize; i++)
+ padBytes = pad(buffer, offset, i);
+ if (((i + padBytes.length) % blockSize) != 0)
{
- padBytes = pad(in, offset, i);
- if (((i + padBytes.length) % blockSize) != 0)
- {
- new RuntimeException(name()).printStackTrace(System.err);
- return false;
- }
-
- System.arraycopy(padBytes, 0, in, offset + i, padBytes.length);
- try
- {
- if (padBytes.length != unpad(in, offset, i + padBytes.length))
- {
- new RuntimeException(name()).printStackTrace(System.err);
- return false;
- }
- }
- catch (WrongPaddingException x)
+ if (Configuration.DEBUG)
+ log.log(Level.SEVERE,
+ "Length of padded text MUST be a multiple of "
+ + blockSize, new RuntimeException(name()));
+ return false;
+ }
+ System.arraycopy(padBytes, 0, buffer, offset + i, padBytes.length);
+ try
+ {
+ if (padBytes.length != unpad(buffer, offset, i + padBytes.length))
{
- x.printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.log(Level.SEVERE,
+ "IPad [" + name() + "] failed symmetric operation",
+ new RuntimeException(name()));
return false;
}
}
- this.reset();
+ catch (WrongPaddingException x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "test1BlockSize", x);
+ return false;
+ }
}
-
+ this.reset();
return true;
}
- // abstract methods to implement by subclasses -----------------------------
-
/**
- * <p>If any additional checks or resource setup must be done by the
- * subclass, then this is the hook for it. This method will be called before
- * the {@link #init(int)} method returns.</p>
+ * If any additional checks or resource setup must be done by the subclass,
+ * then this is the hook for it. This method will be called before the
+ * {@link #init(int)} method returns.
*/
public abstract void setup();
@@ -150,4 +188,4 @@ public abstract class BasePad implements IPad
public abstract int unpad(byte[] in, int off, int len)
throws WrongPaddingException;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/IPad.java b/libjava/classpath/gnu/javax/crypto/pad/IPad.java
index 4b4c925e622..0e3db7db19e 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/IPad.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/IPad.java
@@ -38,29 +38,32 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
+import java.util.Map;
+
/**
- * <p>The basic visible methods of any padding algorithm.</p>
- *
- * <p>Padding algorithms serve to <i>pad</i> and <i>unpad</i> byte arrays usually
+ * 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>
* operation. Their input buffers are usually those processed by instances of
- * {@link gnu.crypto.mode.IMode} and/or {@link gnu.crypto.cipher.IBlockCipher}.</p>
+ * {@link gnu.javax.crypto.mode.IMode} and/or
+ * {@link gnu.javax.crypto.cipher.IBlockCipher}.
*/
public interface IPad
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
+ /**
+ * 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();
/**
* Initialises the padding scheme with a designated block size.
- *
+ *
* @param bs the designated block size.
* @exception IllegalStateException if the instance is already initialised.
* @exception IllegalArgumentException if the block size value is invalid.
@@ -68,29 +71,43 @@ 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.
* @param offset the starting index of meaningful data in <i>in</i>.
* @param length the number of meaningful bytes in <i>in</i>.
* @return the possibly 0-byte long sequence to be appended to the designated
- * input.
+ * input.
*/
byte[] pad(byte[] in, int offset, int length);
/**
* Returns the number of bytes to discard from a designated input buffer.
- *
+ *
* @param in the input buffer containing the bytes to unpad.
* @param offset the starting index of meaningful data in <i>in</i>.
* @param length the number of meaningful bytes in <i>in</i>.
* @return the number of bytes to discard, to the left of index position
- * <tt>offset + length</tt> in <i>in</i>. In other words, if the return
- * value of a successful invocation of this method is <tt>result</tt>, then
- * the unpadded byte sequence will be <tt>offset + length - result</tt> bytes
- * in <i>in</i>, starting from index position <tt>offset</tt>.
+ * <code>offset + length</code> in <i>in</i>. In other words, if
+ * the return value of a successful invocation of this method is
+ * <code>result</code>, then the unpadded byte sequence will be
+ * <code>offset + length - result</code> bytes in <i>in</i>,
+ * starting from index position <code>offset</code>.
* @exception WrongPaddingException if the data is not terminated with the
- * expected padding bytes.
+ * expected padding bytes.
*/
int unpad(byte[] in, int offset, int length) throws WrongPaddingException;
@@ -102,9 +119,9 @@ public interface IPad
/**
* A basic symmetric pad/unpad test.
- *
- * @return <tt>true</tt> if the implementation passes a basic symmetric
- * self-test. Returns <tt>false</tt> otherwise.
+ *
+ * @return <code>true</code> if the implementation passes a basic symmetric
+ * self-test. Returns <code>false</code> otherwise.
*/
boolean selfTest();
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/ISO10126.java b/libjava/classpath/gnu/javax/crypto/pad/ISO10126.java
new file mode 100644
index 00000000000..8e8c59254fc
--- /dev/null
+++ b/libjava/classpath/gnu/javax/crypto/pad/ISO10126.java
@@ -0,0 +1,109 @@
+/* ISO10126.java -- An implementation of the ISO 10126-2 padding scheme
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto.pad;
+
+import gnu.java.security.Registry;
+import gnu.java.security.util.PRNG;
+
+/**
+ * The implementation of the ISO 10126-2 padding algorithm.
+ * <p>
+ * The last byte of the padding block is the number of padding bytes, all other
+ * padding bytes are random.
+ * <p>
+ * References:
+ * <ol>
+ * <li><a href="http://www.w3.org/TR/xmlenc-core/">XML Encryption Syntax and
+ * Processing</a> Section "5.2 Block Encryption Algorithms"; "Padding".</li>
+ * </ol>
+ */
+public final class ISO10126
+ extends BasePad
+{
+ /** Used to generate random numbers for padding bytes. */
+ private PRNG prng;
+
+ ISO10126()
+ {
+ super(Registry.ISO10126_PAD);
+ prng = PRNG.getInstance();
+ }
+
+ public void setup()
+ {
+ // Nothing to do here
+ }
+
+ public byte[] pad(byte[] in, int offset, int length)
+ {
+ int padLength = blockSize - (length % blockSize);
+ final byte[] pad = new byte[padLength];
+
+ // generate random numbers for the padding bytes except for the last byte
+ prng.nextBytes(pad, 0, padLength - 1);
+ // the last byte contains the number of padding bytes
+ pad[padLength - 1] = (byte) padLength;
+
+ return pad;
+ }
+
+ public int unpad(byte[] in, int offset, int length)
+ throws WrongPaddingException
+ {
+ // the last byte contains the number of padding bytes
+ int padLength = in[offset + length - 1] & 0xFF;
+ if (padLength > length)
+ throw new WrongPaddingException();
+
+ return padLength;
+ }
+
+ /**
+ * The default self-test in the super-class would take too long to finish
+ * with this type of padder --due to the large amount of random data needed.
+ * We override the default test and replace it with a simple one for a 16-byte
+ * block-size (default AES block-size). The Mauve test TestOfISO10126 will
+ * exercise all block-sizes that the default self-test uses for the other
+ * padders.
+ */
+ public boolean selfTest()
+ {
+ return test1BlockSize(16, new byte[1024]);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java b/libjava/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java
index 03c3d61a303..9ddc6098949 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java
@@ -38,73 +38,47 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.sig.rsa.EME_PKCS1_V1_5;
import gnu.java.security.util.PRNG;
import gnu.java.security.util.Util;
-import java.io.PrintWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
- * <p>A padding algorithm implementation of the EME-PKCS1-V1.5 encoding/decoding
+ * A padding algorithm implementation of the EME-PKCS1-V1.5 encoding/decoding
* algorithm as described in section 7.2 of RFC-3447. This is effectively an
* <i>Adapter</i> over an instance of {@link EME_PKCS1_V1_5} initialised with
- * the RSA public shared modulus length (in bytes).</p>
- *
- * <p>References:</p>
+ * the RSA public shared modulus length (in bytes).
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
- * Standards (PKCS) #1:</a><br>
- * RSA Cryptography Specifications Version 2.1.<br>
- * Jakob Jonsson and Burt Kaliski.</li>
+ * <li><a href="http://www.ietf.org/rfc/rfc3447.txt">Public-Key Cryptography
+ * Standards (PKCS) #1:</a><br>
+ * RSA Cryptography Specifications Version 2.1.<br>
+ * Jakob Jonsson and Burt Kaliski.</li>
* </ol>
- *
+ *
* @see EME_PKCS1_V1_5
*/
-public class PKCS1_V1_5 extends BasePad
+public class PKCS1_V1_5
+ extends BasePad
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = Registry.EME_PKCS1_V1_5_PAD;
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(final String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(PKCS1_V1_5.class.getName());
private EME_PKCS1_V1_5 codec;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Trivial package-private constructor for use by the <i>Factory</i> class.
- * </p>
+ * Trivial package-private constructor for use by the <i>Factory</i> class.
*
- * @see gnu.crypto.pad.PadFactory
+ * @see PadFactory
*/
PKCS1_V1_5()
{
super(Registry.EME_PKCS1_V1_5_PAD);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BasePad
- // -------------------------------------------------------------------------
-
public void setup()
{
codec = EME_PKCS1_V1_5.getInstance(blockSize);
@@ -117,10 +91,8 @@ public class PKCS1_V1_5 extends BasePad
final byte[] EM = codec.encode(M);
final byte[] result = new byte[blockSize - length];
System.arraycopy(EM, 0, result, 0, result.length);
- if (DEBUG && debuglevel > 8)
- {
- debug("padding: 0x" + Util.toString(result));
- }
+ if (Configuration.DEBUG)
+ log.fine("padding: 0x" + Util.toString(result));
return result;
}
@@ -130,15 +102,11 @@ public class PKCS1_V1_5 extends BasePad
final byte[] EM = new byte[length];
System.arraycopy(in, offset, EM, 0, length);
final int result = length - codec.decode(EM).length;
- if (DEBUG && debuglevel > 8)
- {
- debug("padding length: " + String.valueOf(result));
- }
+ if (Configuration.DEBUG)
+ log.fine("padding length: " + String.valueOf(result));
return result;
}
- // overloaded methods ------------------------------------------------------
-
public boolean selfTest()
{
final int[] mLen = new int[] { 16, 20, 32, 48, 64 };
@@ -156,29 +124,33 @@ public class PKCS1_V1_5 extends BasePad
p = pad(M, 0, j);
if (j + p.length != blockSize)
{
- new RuntimeException(name()).printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.log(Level.SEVERE,
+ "Length of padded text MUST be a multiple of "
+ + blockSize, new RuntimeException(name()));
return false;
}
-
System.arraycopy(p, 0, EM, 0, p.length);
System.arraycopy(M, 0, EM, p.length, j);
try
{
if (p.length != unpad(EM, 0, blockSize))
{
- new RuntimeException(name()).printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.log(Level.SEVERE, "Failed symmetric operation",
+ new RuntimeException(name()));
return false;
}
}
catch (WrongPaddingException x)
{
- x.printStackTrace(System.err);
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "selfTest", x);
return false;
}
}
reset();
}
-
return true;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/PKCS7.java b/libjava/classpath/gnu/javax/crypto/pad/PKCS7.java
index 5697aff2712..bef1784eeb3 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/PKCS7.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/PKCS7.java
@@ -1,129 +1,98 @@
/* PKCS7.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
-your option) any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-USA
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
+ Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
+
+ This file is a part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ USA
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package gnu.javax.crypto.pad;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-import java.io.PrintWriter;
+import java.util.logging.Logger;
/**
- * <p>The implementation of the PKCS7 padding algorithm.</p>
- *
- * <p>This algorithm is described for 8-byte blocks in [RFC-1423] and extended to
- * block sizes of up to 256 bytes in [PKCS-7].</p>
- *
- * References:<br>
- * <a href="http://www.ietf.org/rfc/rfc1423.txt">RFC-1423</a>: Privacy
+ * The implementation of the PKCS7 padding algorithm.
+ * <p>
+ * This algorithm is described for 8-byte blocks in [RFC-1423] and extended to
+ * block sizes of up to 256 bytes in [PKCS-7].
+ * <p>
+ * References:
+ * <ol>
+ * <li><a href="http://www.ietf.org/rfc/rfc1423.txt">RFC-1423</a>: Privacy
* Enhancement for Internet Electronic Mail: Part III: Algorithms, Modes, and
- * Identifiers.<br>
- * <a href="http://www.ietf.org/">IETF</a>.
- * <a href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-7/">[PKCS-7]</a>PKCS #7:
- * Cryptographic Message Syntax Standard - An RSA Laboratories Technical Note.<br>
- * <a href="http://www.rsasecurity.com/">RSA Security</a>.<p>
+ * Identifiers.</li>
+ * <li><a href="http://www.ietf.org/">IETF</a>.</li>
+ * <li><a href="http://www.rsasecurity.com/rsalabs/pkcs/pkcs-7/">[PKCS-7]</a>
+ * PKCS #7: Cryptographic Message Syntax Standard - An RSA Laboratories
+ * Technical Note.</li>
+ * <li><a href="http://www.rsasecurity.com/">RSA Security</a>.</li>
+ * </ol>
*/
-public final class PKCS7 extends BasePad
+public final class PKCS7
+ extends BasePad
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "pkcs7";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(PKCS7.class.getName());
/**
- * Trivial package-private constructor for use by the <i>Factory</i> class.<p>
- *
- * @see gnu.crypto.pad.PadFactory
+ * Trivial package-private constructor for use by the <i>Factory</i> class.
+ *
+ * @see PadFactory
*/
PKCS7()
{
super(Registry.PKCS7_PAD);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BasePad
- // -------------------------------------------------------------------------
-
public void setup()
{
if (blockSize < 2 || blockSize > 256)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
}
public byte[] pad(byte[] in, int offset, int length)
{
int padLength = blockSize;
if (length % blockSize != 0)
- {
- padLength = blockSize - length % blockSize;
- }
+ padLength = blockSize - length % blockSize;
byte[] result = new byte[padLength];
for (int i = 0; i < padLength;)
- {
- result[i++] = (byte) padLength;
- }
-
- if (DEBUG && debuglevel > 8)
- {
- debug("padding: 0x" + Util.toString(result));
- }
+ result[i++] = (byte) padLength;
+ if (Configuration.DEBUG)
+ log.fine("padding: 0x" + Util.toString(result));
return result;
}
@@ -133,17 +102,10 @@ public final class PKCS7 extends BasePad
int limit = offset + length;
int result = in[limit - 1] & 0xFF;
for (int i = 0; i < result; i++)
- {
- if (result != (in[--limit] & 0xFF))
- {
- throw new WrongPaddingException();
- }
- }
-
- if (DEBUG && debuglevel > 8)
- {
- debug("padding length: " + String.valueOf(result));
- }
+ if (result != (in[--limit] & 0xFF))
+ throw new WrongPaddingException();
+ if (Configuration.DEBUG)
+ log.fine("padding length: " + result);
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java b/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
index 913d69dcbaf..eaa78112e09 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
@@ -45,16 +45,13 @@ import java.util.HashSet;
import java.util.Set;
/**
- * <p>A Factory to instantiate padding schemes.</p>
+ * A Factory to instantiate padding schemes.
*/
-public class PadFactory implements Registry
+public class PadFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ /** Collection of padding algorithm names --cached for speed. */
+ private static Set names;
/** Trivial constructor to enforce Singleton pattern. */
private PadFactory()
@@ -62,76 +59,62 @@ public class PadFactory implements Registry
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a padding algorithm given its name.</p>
- *
+ * Returns an instance of a padding algorithm given its name.
+ *
* @param pad the case-insensitive name of the padding algorithm.
- * @return an instance of the padding algorithm, operating with a given
- * block size, or <code>null</code> if none found.
+ * @return an instance of the padding algorithm, operating with a given block
+ * size, or <code>null</code> if none found.
* @throws InternalError if the implementation does not pass its self-test.
*/
public static final IPad getInstance(String pad)
{
if (pad == null)
- {
- return null;
- }
+ return null;
pad = pad.trim().toLowerCase();
if (pad.endsWith("padding"))
pad = pad.substring(0, pad.length() - "padding".length());
IPad result = null;
if (pad.equals(PKCS7_PAD) || pad.equals(PKCS5_PAD))
- {
- result = new PKCS7();
- }
+ result = new PKCS7();
else if (pad.equals(TBC_PAD))
- {
- result = new TBC();
- }
+ result = new TBC();
else if (pad.equals(EME_PKCS1_V1_5_PAD))
- {
- result = new PKCS1_V1_5();
- }
+ result = new PKCS1_V1_5();
else if (pad.equals(SSL3_PAD))
- {
- result = new SSL3();
- }
+ result = new SSL3();
else if (pad.equals(TLS1_PAD))
- {
- result = new TLS1();
- }
+ result = new TLS1();
+ else if (pad.equals(ISO10126_PAD))
+ result = new ISO10126();
- if (result != null && !result.selfTest())
- {
- throw new InternalError(result.name());
- }
+ if (result != null && ! result.selfTest())
+ throw new InternalError(result.name());
return result;
}
/**
- * <p>Returns a {@link java.util.Set} of names of padding algorithms
- * supported by this <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of names of padding algorithms supported by this
+ * <i>Factory</i>.
+ *
* @return a {@link Set} of padding algorithm names (Strings).
*/
public static final Set getNames()
{
- HashSet hs = new HashSet();
- hs.add(PKCS5_PAD);
- hs.add(PKCS7_PAD);
- hs.add(TBC_PAD);
- hs.add(EME_PKCS1_V1_5_PAD);
- hs.add(SSL3_PAD);
- hs.add(TLS1_PAD);
-
- return Collections.unmodifiableSet(hs);
+ if (names == null)
+ {
+ HashSet hs = new HashSet();
+ hs.add(PKCS5_PAD);
+ hs.add(PKCS7_PAD);
+ hs.add(TBC_PAD);
+ hs.add(EME_PKCS1_V1_5_PAD);
+ hs.add(SSL3_PAD);
+ hs.add(TLS1_PAD);
+ hs.add(ISO10126_PAD);
+ names = Collections.unmodifiableSet(hs);
+ }
+ return names;
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/SSL3.java b/libjava/classpath/gnu/javax/crypto/pad/SSL3.java
index 25aeefa13d0..78964d6193a 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/SSL3.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/SSL3.java
@@ -39,39 +39,31 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
/**
- * The padding scheme used by the Secure Sockets Layer, version 3. This
- * padding scheme is used in the block-ciphered struct, e.g.:
- *
+ * The padding scheme used by the Secure Sockets Layer, version 3. This padding
+ * scheme is used in the block-ciphered struct, e.g.:
* <pre>
- * block-ciphered struct {
- * opaque content[SSLCompressed.length];
- * opaque MAC[CipherSpec.hash_size];
- * uint8 padding[GenericBlockCipher.padding_length];
- * uint8 padding_length;
- * } GenericBlockCipher;
+ * block-ciphered struct {
+ * opaque content[SSLCompressed.length];
+ * opaque MAC[CipherSpec.hash_size];
+ * uint8 padding[GenericBlockCipher.padding_length];
+ * uint8 padding_length;
+ * } GenericBlockCipher;
* </pre>
- *
- * <p>Where <i>padding_length</i> is <i>cipher_block_size</i> -
- * ((<i>SSLCompressed.length</i> + <i>CipherSpec.hash_size</i>)
- * % <i>cipher_block_size</i>) - 1. That is, the padding is enough bytes
- * to make the plaintext a multiple of the block size minus one, plus one
- * additional byte for the padding length. The padding can be any arbitrary
- * data.</p>
+ * <p>
+ * Where <i>padding_length</i> is <i>cipher_block_size</i> -
+ * ((<i>SSLCompressed.length</i> + <i>CipherSpec.hash_size</i>) %
+ * <i>cipher_block_size</i>) - 1. That is, the padding is enough bytes to make
+ * the plaintext a multiple of the block size minus one, plus one additional
+ * byte for the padding length. The padding can be any arbitrary data.
*/
-public class SSL3 extends BasePad
+public class SSL3
+ extends BasePad
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
public SSL3()
{
super("ssl3");
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
public void setup()
{
if (blockSize <= 0 || blockSize > 255)
@@ -83,7 +75,7 @@ public class SSL3 extends BasePad
int padlen = blockSize - (len % blockSize);
byte[] pad = new byte[padlen];
for (int i = 0; i < padlen; i++)
- pad[i] = (byte) (padlen - 1);
+ pad[i] = (byte)(padlen - 1);
return pad;
}
@@ -95,4 +87,4 @@ public class SSL3 extends BasePad
throw new WrongPaddingException();
return padlen + 1;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/TBC.java b/libjava/classpath/gnu/javax/crypto/pad/TBC.java
index 25c3e4286bc..e5ff4b5dcb6 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/TBC.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/TBC.java
@@ -38,95 +38,63 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.Util;
-import java.io.PrintWriter;
+import java.util.logging.Logger;
/**
- * <p>The implementation of the Trailing Bit Complement (TBC) padding algorithm.</p>
- *
- * <p>In this mode, "...the data string is padded at the trailing end with the
+ * The implementation of the Trailing Bit Complement (TBC) padding algorithm.
+ * <p>
+ * In this mode, "...the data string is padded at the trailing end with the
* complement of the trailing bit of the unpadded message: if the trailing bit
- * is <tt>1</tt>, then <tt>0</tt> bits are appended, and if the trailing bit is
- * <tt>0</tt>, then <tt>1</tt> bits are appended. As few bits are added as are
- * necessary to meet the formatting size requirement."</p>
- *
- * References:<br>
- * <a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
- * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>,
- * Morris Dworkin.<p>
+ * is <tt>1</tt>, then <tt>0</tt> bits are appended, and if the trailing
+ * bit is <tt>0</tt>, then <tt>1</tt> bits are appended. As few bits are
+ * added as are necessary to meet the formatting size requirement."
+ * <p>
+ * References:
+ * <ol>
+ * <li><a
+ * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf">
+ * Recommendation for Block Cipher Modes of Operation Methods and
+ * Techniques</a>, Morris Dworkin.</li>
+ * </ol>
*/
-public final class TBC extends BasePad
+public final class TBC
+ extends BasePad
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "tbc";
-
- private static final boolean DEBUG = false;
-
- private static final int debuglevel = 9;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String s)
- {
- err.println(">>> " + NAME + ": " + s);
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(TBC.class.getName());
/**
- * Trivial package-private constructor for use by the <i>Factory</i> class.<p>
- *
- * @see gnu.crypto.pad.PadFactory
+ * Trivial package-private constructor for use by the <i>Factory</i> class.
+ *
+ * @see PadFactory
*/
TBC()
{
super(Registry.TBC_PAD);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BasePad
- // -------------------------------------------------------------------------
-
public void setup()
{
if (blockSize < 1 || blockSize > 256)
- {
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException();
}
public byte[] pad(byte[] in, int offset, int length)
{
int padLength = blockSize;
if (length % blockSize != 0)
- {
- padLength = blockSize - length % blockSize;
- }
+ padLength = blockSize - length % blockSize;
byte[] result = new byte[padLength];
int lastBit = in[offset + length - 1] & 0x01;
if (lastBit == 0)
- {
- for (int i = 0; i < padLength;)
- {
- result[i++] = 0x01;
- }
- } // else it's already set to zeroes by virtue of initialisation
-
- if (DEBUG && debuglevel > 8)
- {
- debug("padding: 0x" + Util.toString(result));
- }
+ for (int i = 0; i < padLength;)
+ result[i++] = 0x01;
+ // else it's already set to zeroes by virtue of initialisation
+ if (Configuration.DEBUG)
+ log.fine("padding: 0x" + Util.toString(result));
return result;
}
@@ -141,16 +109,10 @@ public final class TBC extends BasePad
result++;
limit--;
}
-
if (result > length)
- {
- throw new WrongPaddingException();
- }
-
- if (DEBUG && debuglevel > 8)
- {
- debug("padding length: " + String.valueOf(result));
- }
+ throw new WrongPaddingException();
+ if (Configuration.DEBUG)
+ log.fine("padding length: " + result);
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/TLS1.java b/libjava/classpath/gnu/javax/crypto/pad/TLS1.java
index 00a538f882a..1d690dd599c 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/TLS1.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/TLS1.java
@@ -38,42 +38,32 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
-import gnu.java.security.util.Util;
-
/**
- * The padding scheme used by the Transport Layer Security protocol,
- * version 1. This padding scheme is used in the block-ciphered struct,
- * e.g.:
- *
+ * The padding scheme used by the Transport Layer Security protocol, version 1.
+ * This padding scheme is used in the block-ciphered struct, e.g.:
* <pre>
- * block-ciphered struct {
- * opaque content[TLSCompressed.length];
- * opaque MAC[CipherSpec.hash_size];
- * uint8 padding[GenericBlockCipher.padding_length];
- * uint8 padding_length;
- * } GenericBlockCipher;
+ * block-ciphered struct {
+ * opaque content[TLSCompressed.length];
+ * opaque MAC[CipherSpec.hash_size];
+ * uint8 padding[GenericBlockCipher.padding_length];
+ * uint8 padding_length;
+ * } GenericBlockCipher;
* </pre>
- *
- * <p>Where <i>padding_length</i> is any multiple of <i>cipher_block_size</i> -
- * ((<i>SSLCompressed.length</i> + <i>CipherSpec.hash_size</i>)
- * % <i>cipher_block_size</i>) - 1 that is less than 255. Every byte of the
+ * <p>
+ * Where <i>padding_length</i> is any multiple of <i>cipher_block_size</i> -
+ * ((<i>SSLCompressed.length</i> + <i>CipherSpec.hash_size</i>) %
+ * <i>cipher_block_size</i>) - 1 that is less than 255. Every byte of the
* padding must be equal to <i>padding_length</i>. That is, the end of the
- * plaintext is <i>n</i> + 1 copies of the unsigned byte <i>n</i>.</p>
+ * plaintext is <i>n</i> + 1 copies of the unsigned byte <i>n</i>.
*/
-public class TLS1 extends BasePad
+public class TLS1
+ extends BasePad
{
-
- // Constructors.
- // -------------------------------------------------------------------------
-
public TLS1()
{
super("tls1");
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
public void setup()
{
if (blockSize <= 0 || blockSize > 255)
@@ -85,9 +75,7 @@ public class TLS1 extends BasePad
int padlen = blockSize - (len % blockSize);
byte[] pad = new byte[padlen];
for (int i = 0; i < padlen; i++)
- {
- pad[i] = (byte) (padlen - 1);
- }
+ pad[i] = (byte)(padlen - 1);
return pad;
}
@@ -96,10 +84,8 @@ public class TLS1 extends BasePad
{
int padlen = in[off + len - 1] & 0xFF;
for (int i = off + (len - padlen - 1); i < off + len - 1; i++)
- {
- if ((in[i] & 0xFF) != padlen)
- throw new WrongPaddingException();
- }
+ if ((in[i] & 0xFF) != padlen)
+ throw new WrongPaddingException();
return padlen + 1;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java b/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
index e477cf303c7..090d021ebfd 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
@@ -39,23 +39,10 @@ exception statement from your version. */
package gnu.javax.crypto.pad;
/**
- * <p>A checked exception that indicates that a padding algorithm did not find the
- * expected padding bytes when unpadding some data.</p>
+ * A checked exception that indicates that a padding algorithm did not find the
+ * expected padding bytes when unpadding some data.
*/
-public class WrongPaddingException extends Exception
+public class WrongPaddingException
+ extends Exception
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
- // implicit 0-arguments constructor
-
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instant methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/ARCFour.java b/libjava/classpath/gnu/javax/crypto/prng/ARCFour.java
index 22316ec8b9b..b7265294268 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/ARCFour.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/ARCFour.java
@@ -45,88 +45,65 @@ import gnu.java.security.prng.LimitReachedException;
import java.util.Map;
/**
- * RC4 is a stream cipher developed by Ron Rivest. Until 1994 RC4 was a
- * trade secret of RSA Data Security, Inc., when it was released
- * anonymously to a mailing list. This version is a descendent of that
- * code, and since there is no proof that the leaked version was in fact
- * RC4 and because "RC4" is a trademark, it is called "ARCFOUR", short for
- * "Allegedly RC4".
- *
- * <p>This class only implements the <i>keystream</i> of ARCFOUR. To use
- * this as a stream cipher, one would say:</p>
- *
- * <pre> out = in ^ arcfour.nextByte();</pre>
- *
- * <p>This operation works for encryption and decryption.</p>
- *
- * <p>References:</p>
- *
+ * RC4 is a stream cipher developed by Ron Rivest. Until 1994 RC4 was a trade
+ * secret of RSA Data Security, Inc., when it was released anonymously to a
+ * mailing list. This version is a descendent of that code, and since there is
+ * no proof that the leaked version was in fact RC4 and because "RC4" is a
+ * trademark, it is called "ARCFOUR", short for "Allegedly RC4".
+ * <p>
+ * This class only implements the <i>keystream</i> of ARCFOUR. To use this as a
+ * stream cipher, one would say:
+ * <pre>
+ * out = in &circ; arcfour.nextByte();
+ * </pre>
+ * <p>
+ * This operation works for encryption and decryption.
+ * <p>
+ * References:
* <ol>
- * <li>Schneier, Bruce: <i>Applied Cryptography: Protocols, Algorithms,
- * and Source Code in C, Second Edition.</i> (1996 John Wiley and Sons),
- * pp. 397--398. ISBN 0-471-11709-9</li>
+ * <li>Schneier, Bruce: <i>Applied Cryptography: Protocols, Algorithms, and
+ * Source Code in C, Second Edition.</i> (1996 John Wiley and Sons), pp.
+ * 397--398. ISBN 0-471-11709-9</li>
* <li>K. Kaukonen and R. Thayer, "A Stream Cipher Encryption Algorithm
* 'Arcfour'", Internet Draft (expired), <a
* href="http://www.mozilla.org/projects/security/pki/nss/draft-kaukonen-cipher-arcfour-03.txt">draft-kaukonen-cipher-arcfour-03.txt</a></li>
* </ol>
*/
-public class ARCFour extends BasePRNG implements Cloneable
+public class ARCFour
+ extends BasePRNG
+ implements Cloneable
{
-
- // Constants and variables.
- // -----------------------------------------------------------------------
-
/** The attributes property name for the key bytes. */
public static final String ARCFOUR_KEY_MATERIAL = "gnu.crypto.prng.arcfour.key-material";
-
/** The size of the internal S-box. */
public static final int ARCFOUR_SBOX_SIZE = 256;
-
/** The S-box. */
private byte[] s;
-
private byte m, n;
- // Constructors.
- // -----------------------------------------------------------------------
-
/** Default 0-arguments constructor. */
public ARCFour()
{
super(Registry.ARCFOUR_PRNG);
}
- // Methods implementing BasePRNG.
- // -----------------------------------------------------------------------
-
public void setup(Map attributes)
{
byte[] kb = (byte[]) attributes.get(ARCFOUR_KEY_MATERIAL);
-
if (kb == null)
- {
- throw new IllegalArgumentException("ARCFOUR needs a key");
- }
-
+ throw new IllegalArgumentException("ARCFOUR needs a key");
s = new byte[ARCFOUR_SBOX_SIZE];
m = n = 0;
byte[] k = new byte[ARCFOUR_SBOX_SIZE];
-
for (int i = 0; i < ARCFOUR_SBOX_SIZE; i++)
- {
- s[i] = (byte) i;
- }
-
+ s[i] = (byte) i;
if (kb.length > 0)
- {
- for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++)
- {
- k[i] = kb[j++];
- if (j >= kb.length)
- j = 0;
- }
- }
-
+ for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++)
+ {
+ k[i] = kb[j++];
+ if (j >= kb.length)
+ j = 0;
+ }
for (int i = 0, j = 0; i < ARCFOUR_SBOX_SIZE; i++)
{
j = j + s[i] + k[i];
@@ -134,7 +111,6 @@ public class ARCFour extends BasePRNG implements Cloneable
s[i] = s[j & 0xff];
s[j & 0xff] = temp;
}
-
buffer = new byte[ARCFOUR_SBOX_SIZE];
try
{
@@ -150,12 +126,12 @@ public class ARCFour extends BasePRNG implements Cloneable
for (int i = 0; i < buffer.length; i++)
{
m++;
- n = (byte) (n + s[m & 0xff]);
+ n = (byte)(n + s[m & 0xff]);
byte temp = s[m & 0xff];
s[m & 0xff] = s[n & 0xff];
s[n & 0xff] = temp;
- temp = (byte) (s[m & 0xff] + s[n & 0xff]);
+ temp = (byte)(s[m & 0xff] + s[n & 0xff]);
buffer[i] = s[temp & 0xff];
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java b/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
index 6585dcb907a..2cf75a96644 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.javax.crypto.prng;
+import gnu.java.security.Configuration;
import gnu.java.security.Properties;
import gnu.java.security.Registry;
import gnu.java.security.hash.HashFactory;
@@ -48,7 +49,6 @@ import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
import gnu.java.security.util.SimpleList;
import gnu.java.security.util.Util;
-
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
@@ -56,15 +56,11 @@ import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintStream;
-
import java.net.MalformedURLException;
import java.net.URL;
-
import java.security.AccessController;
import java.security.InvalidKeyException;
import java.security.PrivilegedAction;
-
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -73,115 +69,85 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
- * <p>An entropy pool-based pseudo-random number generator based on the PRNG
- * in Peter Gutmann's cryptlib (<a
- * href="http://www.cs.auckland.ac.nz/~pgut001/cryptlib/">http://www.cs.auckland.ac.nz/~pgut001/cryptlib/</a>).</p>
- *
- * <p>The basic properties of this generator are:</p>
- *
+ * An entropy pool-based pseudo-random number generator based on the PRNG in
+ * Peter Gutmann's cryptlib (<a
+ * href="http://www.cs.auckland.ac.nz/~pgut001/cryptlib/">http://www.cs.auckland.ac.nz/~pgut001/cryptlib/</a>).
+ * <p>
+ * The basic properties of this generator are:
* <ol>
* <li>The internal state cannot be determined by knowledge of the input.</li>
* <li>It is resistant to bias introduced by specific inputs.</li>
* <li>The output does not reveal the state of the generator.</li>
* </ol>
*/
-public class CSPRNG extends BasePRNG
+public class CSPRNG
+ extends BasePRNG
{
-
- // Constants and fields.
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
-
- private static void debug(String msg)
- {
- System.err.print(">>> CSPRNG: ");
- System.err.println(msg);
- }
-
+ private static final Logger log = Logger.getLogger(CSPRNG.class.getName());
/**
- * Property name for the list of files to read for random values. The
- * mapped value is a list with the following values:
- *
+ * Property name for the list of files to read for random values. The mapped
+ * value is a list with the following values:
* <ol>
* <li>A {@link Double}, indicating the suggested <i>quality</i> of this
* source. This value must be between 0 and 100.</li>
- * <li>An {@link Integer}, indicating the number of bytes to skip in the file
- * before reading bytes. This can be any nonnegative value.</li>
+ * <li>An {@link Integer}, indicating the number of bytes to skip in the
+ * file before reading bytes. This can be any nonnegative value.</li>
* <li>An {@link Integer}, indicating the number of bytes to read.</li>
* <li>A {@link String}, indicating the path to the file.</li>
* </ol>
- *
- * @see gnu.crypto.util.SimpleList
+ *
+ * @see gnu.java.security.util.SimpleList
*/
public static final String FILE_SOURCES = "gnu.crypto.prng.pool.files";
-
/**
- * Property name for the list of URLs to poll for random values. The
- * mapped value is a list formatted similarly as in {@link #FILE_SOURCES},
- * but the fourth member is a {@link URL}.
+ * Property name for the list of URLs to poll for random values. The mapped
+ * value is a list formatted similarly as in {@link #FILE_SOURCES}, but the
+ * fourth member is a {@link URL}.
*/
public static final String URL_SOURCES = "gnu.crypto.prng.pool.urls";
-
/**
- * Property name for the list of programs to execute, and use the output
- * as new random bytes. The mapped property is formatted similarly an in
- * {@link #FILE_SOURCES} and {@link #URL_SOURCES}, except the fourth
- * member is a {@link String} of the program to execute.
+ * Property name for the list of programs to execute, and use the output as
+ * new random bytes. The mapped property is formatted similarly an in
+ * {@link #FILE_SOURCES} and {@link #URL_SOURCES}, except the fourth member
+ * is a {@link String} of the program to execute.
*/
public static final String PROGRAM_SOURCES = "gnu.crypto.prng.pool.programs";
-
/**
- * Property name for a list of other sources of entropy. The mapped
- * value must be a list of {@link EntropySource} objects.
+ * Property name for a list of other sources of entropy. The mapped value must
+ * be a list of {@link EntropySource} objects.
*/
public static final String OTHER_SOURCES = "gnu.crypto.prng.pool.other";
-
/**
- * Property name for whether or not to wait for the slow poll to
- * complete, passed as a {@link Boolean}. The default value is true.
+ * Property name for whether or not to wait for the slow poll to complete,
+ * passed as a {@link Boolean}. The default value is true.
*/
public static final String BLOCKING = "gnu.crypto.prng.pool.blocking";
-
private static final String FILES = "gnu.crypto.csprng.file.";
-
private static final String URLS = "gnu.crypto.csprng.url.";
-
private static final String PROGS = "gnu.crypto.csprng.program.";
-
private static final String OTHER = "gnu.crypto.csprng.other.";
-
private static final String BLOCK = "gnu.crypto.csprng.blocking";
-
private static final int POOL_SIZE = 256;
-
private static final int ALLOC_SIZE = 260;
-
private static final int OUTPUT_SIZE = POOL_SIZE / 2;
-
private static final int X917_POOL_SIZE = 16;
-
private static final String HASH_FUNCTION = Registry.SHA160_HASH;
-
private static final String CIPHER = Registry.AES_CIPHER;
-
private static final int MIX_COUNT = 10;
-
private static final int X917_LIFETIME = 8192;
-
// FIXME this should be configurable.
private static final int SPINNER_COUNT = 8;
-
/**
* The spinner group singleton. We use this to add a small amount of
- * randomness (in addition to the current time and the amount of
- * free memory) based on the randomness (if any) present due to
- * system load and thread scheduling.
+ * randomness (in addition to the current time and the amount of free memory)
+ * based on the randomness (if any) present due to system load and thread
+ * scheduling.
*/
private static final Spinner[] SPINNERS = new Spinner[SPINNER_COUNT];
-
private static final Thread[] SPINNER_THREADS = new Thread[SPINNER_COUNT];
static
{
@@ -194,87 +160,38 @@ public class CSPRNG extends BasePRNG
SPINNER_THREADS[i].start();
}
}
-
- /**
- * The message digest (SHA-1) used in the mixing function.
- */
+ /** The message digest (SHA-1) used in the mixing function. */
private final IMessageDigest hash;
-
- /**
- * The cipher (AES) used in the output masking function.
- */
+ /** The cipher (AES) used in the output masking function. */
private final IBlockCipher cipher;
-
- /**
- * The number of times the pool has been mixed.
- */
+ /** The number of times the pool has been mixed. */
private int mixCount;
-
- /**
- * The entropy pool.
- */
+ /** The entropy pool. */
private final byte[] pool;
-
- /**
- * The quality of the random pool (percentage).
- */
+ /** The quality of the random pool (percentage). */
private double quality;
-
- /**
- * The index of the next byte in the entropy pool.
- */
+ /** The index of the next byte in the entropy pool. */
private int index;
-
- /**
- * The pool for the X9.17-like generator.
- */
+ /** The pool for the X9.17-like generator. */
private byte[] x917pool;
-
- /**
- * The number of iterations of the X9.17-like generators.
- */
+ /** The number of iterations of the X9.17-like generators. */
private int x917count;
-
- /**
- * Whether or not the X9.17-like generator is initialized.
- */
+ /** Whether or not the X9.17-like generator is initialized. */
private boolean x917init;
-
- /**
- * The list of file soures.
- */
+ /** The list of file soures. */
private final List files;
-
- /**
- * The list of URL sources.
- */
+ /** The list of URL sources. */
private final List urls;
-
- /**
- * The list of program sources.
- */
+ /** The list of program sources. */
private final List progs;
-
- /**
- * The list of other sources.
- */
+ /** The list of other sources. */
private final List other;
-
- /**
- * Whether or not to wait for the slow poll to complete.
- */
+ /** Whether or not to wait for the slow poll to complete. */
private boolean blocking;
-
- /**
- * The thread that polls for random data.
- */
+ /** The thread that polls for random data. */
private Poller poller;
-
private Thread pollerThread;
- // Constructor.
- // -------------------------------------------------------------------------
-
public CSPRNG()
{
super("CSPRNG");
@@ -294,69 +211,75 @@ public class CSPRNG extends BasePRNG
other = new LinkedList();
}
- // Class methods.
- // -------------------------------------------------------------------------
-
/**
- * <p>Create and initialize a CSPRNG instance with the "system" parameters;
- * the files, URLs, programs, and {@link EntropySource} sources used by
- * the instance are derived from properties set in the system {@link
- * Properties}.</p>
- *
- * <p>All properties are of the from <i>name</i>.</i>N</i>, where <i>name</i>
+ * Create and initialize a CSPRNG instance with the "system" parameters; the
+ * files, URLs, programs, and {@link EntropySource} sources used by the
+ * instance are derived from properties set in the system {@link Properties}.
+ * <p>
+ * All properties are of the from <i>name</i>.</i>N</i>, where <i>name</i>
* is the name of the source, and <i>N</i> is an integer (staring at 1) that
- * indicates the preference number for that source.</p>
- *
- * <p>The following vales for <i>name</i> are used here:</p>
- *
+ * indicates the preference number for that source.
+ * <p>
+ * The following vales for <i>name</i> are used here:
* <dl>
* <dt>gnu.crypto.csprng.file</dt>
- * <dd><p>These properties are file sources, passed as the {@link #FILE_SOURCES}
- * parameter of the instance. The property value is a 4-tuple formatted as:</p>
- *
+ * <dd>
+ * <p>
+ * These properties are file sources, passed as the {@link #FILE_SOURCES}
+ * parameter of the instance. The property value is a 4-tuple formatted as:
+ * </p>
* <blockquote><i>quality</i> ; <i>offset</i> ; <i>count</i> ; <i>path</i></blockquote>
- *
- * <p>The parameters are mapped to the parameters defined for {@link
- * #FILE_SOURCES}. Leading or trailing spaces on any item are trimmed
- * off.</p></dd>
- *
+ * <p>
+ * The parameters are mapped to the parameters defined for {@link
+ * #FILE_SOURCES}. Leading or trailing spaces on any item are trimmed off.
+ * </p>
+ * </dd>
* <dt>gnu.crypto.csprng.url</dt>
- * <dd><p>These properties are URL sources, passed as the {@link #URL_SOURCES}
+ * <dd>
+ * <p>
+ * These properties are URL sources, passed as the {@link #URL_SOURCES}
* parameter of the instance. The property is formatted the same way as file
- * sources, but the <i>path</i> argument must be a valid URL.</p></dd>
- *
+ * sources, but the <i>path</i> argument must be a valid URL.
+ * </p>
+ * </dd>
* <dt>gnu.crypto.csprng.program</dt>
- * <dd><p>These properties are program sources, passed as the {@link
- * #PROGRAM_SOURCES} parameter of the instance. This property is formatted
- * the same way as file and URL sources, but the last argument is a program
- * and its arguments.</p></dd>
- *
+ * <dd>
+ * <p>
+ * These properties are program sources, passed as the {@link
+ * #PROGRAM_SOURCES} parameter of the instance. This property is formatted the
+ * same way as file and URL sources, but the last argument is a program and
+ * its arguments.
+ * </p>
+ * </dd>
* <dt>gnu.crypto.cspring.other</dt>
- * <dd><p>These properties are other sources, passed as the {@link OTHER_SOURCES}
- * parameter of the instance. The property value must be the full name
- * of a class that implements the {@link EntropySource} interface and has a
- * public no-argument constructor.</p></dd>
+ * <dd>
+ * <p>
+ * These properties are other sources, passed as the {@link #OTHER_SOURCES}
+ * parameter of the instance. The property value must be the full name of a
+ * class that implements the {@link EntropySource} interface and has a public
+ * no-argument constructor.
+ * </p>
+ * </dd>
* </dl>
- *
- * <p>Finally, a boolean property "gnu.crypto.csprng.blocking" can be set to
- * the desired value of {@link #BLOCKING}.</p>
- *
- * <p>An example of valid properties would be:</p>
- *
+ * <p>
+ * Finally, a boolean property "gnu.crypto.csprng.blocking" can be set to the
+ * desired value of {@link #BLOCKING}.
+ * <p>
+ * An example of valid properties would be:
* <pre>
- * gnu.crypto.csprng.blocking=true
- *
- * gnu.crypto.csprng.file.1=75.0;0;256;/dev/random
- * gnu.crypto.csprng.file.2=10.0;0;100;/home/user/file
- *
- * gnu.crypto.csprng.url.1=5.0;0;256;http://www.random.org/cgi-bin/randbyte?nbytes=256
- * gnu.crypto.csprng.url.2=0;256;256;http://slashdot.org/
- *
- * gnu.crypto.csprng.program.1=0.5;0;10;last -n 50
- * gnu.crypto.csprng.program.2=0.5;0;10;tcpdump -c 5
- *
- * gnu.crypto.csprng.other.1=foo.bar.MyEntropySource
- * gnu.crypto.csprng.other.2=com.company.OtherEntropySource
+ * gnu.crypto.csprng.blocking=true
+ *
+ * gnu.crypto.csprng.file.1=75.0;0;256;/dev/random
+ * gnu.crypto.csprng.file.2=10.0;0;100;/home/user/file
+ *
+ * gnu.crypto.csprng.url.1=5.0;0;256;http://www.random.org/cgi-bin/randbyte?nbytes=256
+ * gnu.crypto.csprng.url.2=0;256;256;http://slashdot.org/
+ *
+ * gnu.crypto.csprng.program.1=0.5;0;10;last -n 50
+ * gnu.crypto.csprng.program.2=0.5;0;10;tcpdump -c 5
+ *
+ * gnu.crypto.csprng.other.1=foo.bar.MyEntropySource
+ * gnu.crypto.csprng.other.2=com.company.OtherEntropySource
* </pre>
*/
public static IRandom getSystemInstance() throws ClassNotFoundException,
@@ -366,70 +289,57 @@ public class CSPRNG extends BasePRNG
HashMap attrib = new HashMap();
attrib.put(BLOCKING, Boolean.valueOf(getProperty(BLOCK)));
String s = null;
-
// Get each file source "gnu.crypto.csprng.file.N".
List l = new LinkedList();
for (int i = 0; (s = getProperty(FILES + i)) != null; i++)
- {
- try
- {
- l.add(parseString(s.trim()));
- }
- catch (NumberFormatException nfe)
- {
- }
- }
+ try
+ {
+ l.add(parseString(s.trim()));
+ }
+ catch (NumberFormatException nfe)
+ {
+ }
attrib.put(FILE_SOURCES, l);
-
l = new LinkedList();
for (int i = 0; (s = getProperty(URLS + i)) != null; i++)
- {
- try
- {
- l.add(parseURL(s.trim()));
- }
- catch (NumberFormatException nfe)
- {
- }
- catch (MalformedURLException mue)
- {
- }
- }
+ try
+ {
+ l.add(parseURL(s.trim()));
+ }
+ catch (NumberFormatException nfe)
+ {
+ }
+ catch (MalformedURLException mue)
+ {
+ }
attrib.put(URL_SOURCES, l);
-
l = new LinkedList();
for (int i = 0; (s = getProperty(PROGS + i)) != null; i++)
- {
- try
- {
- l.add(parseString(s.trim()));
- }
- catch (NumberFormatException nfe)
- {
- }
- }
+ try
+ {
+ l.add(parseString(s.trim()));
+ }
+ catch (NumberFormatException nfe)
+ {
+ }
attrib.put(PROGRAM_SOURCES, l);
-
l = new LinkedList();
for (int i = 0; (s = getProperty(OTHER + i)) != null; i++)
- {
- try
- {
- Class c = Class.forName(s.trim());
- l.add(c.newInstance());
- }
- catch (ClassNotFoundException cnfe)
- {
- }
- catch (InstantiationException ie)
- {
- }
- catch (IllegalAccessException iae)
- {
- }
- }
+ try
+ {
+ Class c = Class.forName(s.trim());
+ l.add(c.newInstance());
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ }
+ catch (InstantiationException ie)
+ {
+ }
+ catch (IllegalAccessException iae)
+ {
+ }
attrib.put(OTHER_SOURCES, l);
-
instance.init(attrib);
return instance;
}
@@ -449,9 +359,7 @@ public class CSPRNG extends BasePRNG
{
StringTokenizer tok = new StringTokenizer(s, ";");
if (tok.countTokens() != 4)
- {
- throw new IllegalArgumentException("malformed property");
- }
+ throw new IllegalArgumentException("malformed property");
Double quality = new Double(tok.nextToken());
Integer offset = new Integer(tok.nextToken());
Integer length = new Integer(tok.nextToken());
@@ -464,9 +372,7 @@ public class CSPRNG extends BasePRNG
{
StringTokenizer tok = new StringTokenizer(s, ";");
if (tok.countTokens() != 4)
- {
- throw new IllegalArgumentException("malformed property");
- }
+ throw new IllegalArgumentException("malformed property");
Double quality = new Double(tok.nextToken());
Integer offset = new Integer(tok.nextToken());
Integer length = new Integer(tok.nextToken());
@@ -474,9 +380,6 @@ public class CSPRNG extends BasePRNG
return new SimpleList(quality, offset, length, url);
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
public Object clone()
{
return new CSPRNG();
@@ -485,34 +388,25 @@ public class CSPRNG extends BasePRNG
public void setup(Map attrib)
{
List list = null;
-
- if (DEBUG)
- {
- debug(String.valueOf(attrib));
- }
+ if (Configuration.DEBUG)
+ log.fine("attrib=" + String.valueOf(attrib));
try
{
list = (List) attrib.get(FILE_SOURCES);
- if (DEBUG)
- {
- debug(String.valueOf(list));
- }
+ if (Configuration.DEBUG)
+ log.fine("list=" + String.valueOf(list));
if (list != null)
{
files.clear();
for (Iterator it = list.iterator(); it.hasNext();)
{
List l = (List) it.next();
- if (DEBUG)
- {
- debug("l=" + l);
- }
+ if (Configuration.DEBUG)
+ log.fine("l=" + l);
if (l.size() != 4)
{
- if (DEBUG)
- {
- debug("file list too small: " + l.size());
- }
+ if (Configuration.DEBUG)
+ log.fine("file list too small: " + l.size());
throw new IllegalArgumentException("invalid file list");
}
Double quality = (Double) l.get(0);
@@ -525,37 +419,27 @@ public class CSPRNG extends BasePRNG
}
catch (ClassCastException cce)
{
- if (DEBUG)
- {
- debug("bad file list: " + cce.getMessage());
- cce.printStackTrace();
- }
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "bad file list", cce);
throw new IllegalArgumentException("invalid file list");
}
-
try
{
list = (List) attrib.get(URL_SOURCES);
- if (DEBUG)
- {
- debug(String.valueOf(list));
- }
+ if (Configuration.DEBUG)
+ log.fine("list=" + String.valueOf(list));
if (list != null)
{
urls.clear();
for (Iterator it = list.iterator(); it.hasNext();)
{
List l = (List) it.next();
- if (DEBUG)
- {
- debug("l=" + l);
- }
+ if (Configuration.DEBUG)
+ log.fine("l=" + l);
if (l.size() != 4)
{
- if (DEBUG)
- {
- debug("URL list too small: " + l.size());
- }
+ if (Configuration.DEBUG)
+ log.fine("URL list too small: " + l.size());
throw new IllegalArgumentException("invalid URL list");
}
Double quality = (Double) l.get(0);
@@ -568,37 +452,27 @@ public class CSPRNG extends BasePRNG
}
catch (ClassCastException cce)
{
- if (DEBUG)
- {
- debug("bad URL list: " + cce.getMessage());
- cce.printStackTrace();
- }
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "bad URL list", cce);
throw new IllegalArgumentException("invalid URL list");
}
-
try
{
list = (List) attrib.get(PROGRAM_SOURCES);
- if (DEBUG)
- {
- debug(String.valueOf(list));
- }
+ if (Configuration.DEBUG)
+ log.fine("list=" + String.valueOf(list));
if (list != null)
{
progs.clear();
for (Iterator it = list.iterator(); it.hasNext();)
{
List l = (List) it.next();
- if (DEBUG)
- {
- debug("l=" + l);
- }
+ if (Configuration.DEBUG)
+ log.fine("l=" + l);
if (l.size() != 4)
{
- if (DEBUG)
- {
- debug("program list too small: " + l.size());
- }
+ if (Configuration.DEBUG)
+ log.fine("program list too small: " + l.size());
throw new IllegalArgumentException("invalid program list");
}
Double quality = (Double) l.get(0);
@@ -611,35 +485,25 @@ public class CSPRNG extends BasePRNG
}
catch (ClassCastException cce)
{
- if (DEBUG)
- {
- debug("bad program list: " + cce.getMessage());
- cce.printStackTrace();
- }
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "bad program list", cce);
throw new IllegalArgumentException("invalid program list");
}
-
try
{
list = (List) attrib.get(OTHER_SOURCES);
- if (DEBUG)
- {
- debug(String.valueOf(list));
- }
+ if (Configuration.DEBUG)
+ log.fine("list=" + String.valueOf(list));
if (list != null)
{
other.clear();
for (Iterator it = list.iterator(); it.hasNext();)
{
EntropySource src = (EntropySource) it.next();
- if (DEBUG)
- {
- debug("src=" + src);
- }
+ if (Configuration.DEBUG)
+ log.fine("src=" + src);
if (src == null)
- {
- throw new NullPointerException("null source in source list");
- }
+ throw new NullPointerException("null source in source list");
other.add(src);
}
}
@@ -653,19 +517,14 @@ public class CSPRNG extends BasePRNG
{
Boolean block = (Boolean) attrib.get(BLOCKING);
if (block != null)
- {
- blocking = block.booleanValue();
- }
+ blocking = block.booleanValue();
else
- {
- blocking = true;
- }
+ blocking = true;
}
catch (ClassCastException cce)
{
throw new IllegalArgumentException("invalid blocking parameter");
}
-
poller = new Poller(files, urls, progs, other, this);
try
{
@@ -679,27 +538,21 @@ public class CSPRNG extends BasePRNG
public void fillBlock() throws LimitReachedException
{
- if (DEBUG)
- {
- debug("fillBlock");
- }
+ if (Configuration.DEBUG)
+ log.fine("fillBlock");
if (getQuality() < 100.0)
{
- if (DEBUG)
- {
- debug("doing slow poll");
- }
+ if (Configuration.DEBUG)
+ log.fine("doing slow poll");
slowPoll();
}
-
do
{
fastPoll();
mixRandomPool();
}
while (mixCount < MIX_COUNT);
-
- if (!x917init || x917count >= X917_LIFETIME)
+ if (! x917init || x917count >= X917_LIFETIME)
{
mixRandomPool(pool);
Map attr = new HashMap();
@@ -715,59 +568,45 @@ public class CSPRNG extends BasePRNG
{
throw new Error(ike.toString());
}
-
mixRandomPool(pool);
generateX917(pool);
mixRandomPool(pool);
generateX917(pool);
-
if (x917init)
- {
- quality = 0.0;
- }
+ quality = 0.0;
x917init = true;
x917count = 0;
}
-
byte[] export = new byte[ALLOC_SIZE];
for (int i = 0; i < ALLOC_SIZE; i++)
- {
- export[i] = (byte) (pool[i] ^ 0xFF);
- }
-
+ export[i] = (byte)(pool[i] ^ 0xFF);
mixRandomPool();
mixRandomPool(export);
-
generateX917(export);
-
for (int i = 0; i < OUTPUT_SIZE; i++)
- {
- buffer[i] = (byte) (export[i] ^ export[i + OUTPUT_SIZE]);
- }
+ buffer[i] = (byte)(export[i] ^ export[i + OUTPUT_SIZE]);
Arrays.fill(export, (byte) 0);
}
/**
- * Add an array of bytes into the randomness pool. Note that this method
- * will <i>not</i> increment the pool's quality counter (this can only be
- * done via a source provided to the setup method).
- *
+ * Add an array of bytes into the randomness pool. Note that this method will
+ * <i>not</i> increment the pool's quality counter (this can only be done via
+ * a source provided to the setup method).
+ *
* @param buf The byte array.
* @param off The offset from whence to start reading bytes.
* @param len The number of bytes to add.
* @throws ArrayIndexOutOfBoundsException If <i>off</i> or <i>len</i> are
- * out of the range of <i>buf</i>.
+ * out of the range of <i>buf</i>.
*/
public synchronized void addRandomBytes(byte[] buf, int off, int len)
{
if (off < 0 || len < 0 || off + len > buf.length)
+ throw new ArrayIndexOutOfBoundsException();
+ if (Configuration.DEBUG)
{
- throw new ArrayIndexOutOfBoundsException();
- }
- if (DEBUG)
- {
- debug("adding random bytes:");
- debug(Util.toString(buf, off, len));
+ log.fine("adding random bytes:");
+ log.fine(Util.toString(buf, off, len));
}
final int count = off + len;
for (int i = off; i < count; i++)
@@ -782,18 +621,16 @@ public class CSPRNG extends BasePRNG
}
/**
- * Add a single random byte to the randomness pool. Note that this method
- * will <i>not</i> increment the pool's quality counter (this can only be
- * done via a source provided to the setup method).
- *
+ * Add a single random byte to the randomness pool. Note that this method will
+ * <i>not</i> increment the pool's quality counter (this can only be done via
+ * a source provided to the setup method).
+ *
* @param b The byte to add.
*/
public synchronized void addRandomByte(byte b)
{
- if (DEBUG)
- {
- debug("adding byte " + Integer.toHexString(b));
- }
+ if (Configuration.DEBUG)
+ log.fine("adding byte " + Integer.toHexString(b));
pool[index++] ^= b;
if (index >= pool.length)
{
@@ -802,23 +639,14 @@ public class CSPRNG extends BasePRNG
}
}
- // Package methods.
- // -------------------------------------------------------------------------
-
synchronized void addQuality(double quality)
{
- if (DEBUG)
- {
- debug("adding quality " + quality);
- }
+ if (Configuration.DEBUG)
+ log.fine("adding quality " + quality);
if (this.quality < 100)
- {
- this.quality += quality;
- }
- if (DEBUG)
- {
- debug("quality now " + this.quality);
- }
+ this.quality += quality;
+ if (Configuration.DEBUG)
+ log.fine("quality now " + this.quality);
}
synchronized double getQuality()
@@ -826,13 +654,10 @@ public class CSPRNG extends BasePRNG
return quality;
}
- // Own methods.
- // -------------------------------------------------------------------------
-
/**
- * The mix operation. This method will, for every 20-byte block in the
- * random pool, hash that block, the previous 20 bytes, and the next
- * 44 bytes with SHA-1, writing the result back into that block.
+ * The mix operation. This method will, for every 20-byte block in the random
+ * pool, hash that block, the previous 20 bytes, and the next 44 bytes with
+ * SHA-1, writing the result back into that block.
*/
private void mixRandomPool(byte[] buf)
{
@@ -841,25 +666,17 @@ public class CSPRNG extends BasePRNG
{
// First update the bytes [p-19..p-1].
if (i == 0)
- {
- hash.update(buf, buf.length - hashSize, hashSize);
- }
+ hash.update(buf, buf.length - hashSize, hashSize);
else
- {
- hash.update(buf, i - hashSize, hashSize);
- }
-
+ hash.update(buf, i - hashSize, hashSize);
// Now the next 64 bytes.
if (i + 64 < buf.length)
- {
- hash.update(buf, i, 64);
- }
+ hash.update(buf, i, 64);
else
{
hash.update(buf, i, buf.length - i);
hash.update(buf, 0, 64 - (buf.length - i));
}
-
byte[] digest = hash.digest();
System.arraycopy(digest, 0, buf, i, hashSize);
}
@@ -878,28 +695,22 @@ public class CSPRNG extends BasePRNG
{
int copy = Math.min(buf.length - i, X917_POOL_SIZE);
for (int j = 0; j < copy; j++)
- {
- x917pool[j] ^= pool[off + j];
- }
-
+ x917pool[j] ^= pool[off + j];
cipher.encryptBlock(x917pool, 0, x917pool, 0);
System.arraycopy(x917pool, 0, buf, off, copy);
cipher.encryptBlock(x917pool, 0, x917pool, 0);
-
off += copy;
x917count++;
}
}
/**
- * Add random data always immediately available into the random pool, such
- * as the values of the eight asynchronous counters, the current time, the
- * current memory usage, the calling thread name, and the current stack
- * trace.
- *
- * <p>This method does not alter the quality counter, and is provided more
- * to maintain randomness, not to seriously improve the current random
- * state.
+ * Add random data always immediately available into the random pool, such as
+ * the values of the eight asynchronous counters, the current time, the
+ * current memory usage, the calling thread name, and the current stack trace.
+ * <p>
+ * This method does not alter the quality counter, and is provided more to
+ * maintain randomness, not to seriously improve the current random state.
*/
private void fastPoll()
{
@@ -909,14 +720,12 @@ public class CSPRNG extends BasePRNG
addRandomByte(b);
addRandomByte((byte) System.currentTimeMillis());
addRandomByte((byte) Runtime.getRuntime().freeMemory());
-
String s = Thread.currentThread().getName();
if (s != null)
{
byte[] buf = s.getBytes();
addRandomBytes(buf, 0, buf.length);
}
-
ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
PrintStream pout = new PrintStream(bout);
Throwable t = new Throwable();
@@ -928,12 +737,10 @@ public class CSPRNG extends BasePRNG
private void slowPoll() throws LimitReachedException
{
- if (DEBUG)
- {
- debug("poller is alive? "
- + (pollerThread == null ? false : pollerThread.isAlive()));
- }
- if (pollerThread == null || !pollerThread.isAlive())
+ if (Configuration.DEBUG)
+ log.fine("poller is alive? "
+ + (pollerThread == null ? false : pollerThread.isAlive()));
+ if (pollerThread == null || ! pollerThread.isAlive())
{
boolean interrupted = false;
pollerThread = new Thread(poller);
@@ -941,27 +748,21 @@ public class CSPRNG extends BasePRNG
pollerThread.setPriority(Thread.NORM_PRIORITY - 1);
pollerThread.start();
if (blocking)
- {
- try
- {
- pollerThread.join();
- }
- catch (InterruptedException ie)
- {
- interrupted = true;
- }
- }
-
+ try
+ {
+ pollerThread.join();
+ }
+ catch (InterruptedException ie)
+ {
+ interrupted = true;
+ }
// If the full slow poll has completed after we waited for it,
// and there in insufficient randomness, throw an exception.
- if (!interrupted && blocking && quality < 100.0)
+ if (! interrupted && blocking && quality < 100.0)
{
- if (DEBUG)
- {
- debug("insufficient quality: " + quality);
- }
- throw new LimitReachedException(
- "insufficient randomness was polled");
+ if (Configuration.DEBUG)
+ log.fine("insufficient quality: " + quality);
+ throw new LimitReachedException("insufficient randomness was polled");
}
}
}
@@ -979,33 +780,21 @@ public class CSPRNG extends BasePRNG
Arrays.fill(buffer, (byte) 0);
}
- // Inner classes.
- // -------------------------------------------------------------------------
-
/**
- * A simple thread that constantly updates a byte counter. This class is
- * used in a group of lowest-priority threads and the values of their
- * counters (updated in competition with all other threads) is used as a
- * source of entropy bits.
+ * A simple thread that constantly updates a byte counter. This class is used
+ * in a group of lowest-priority threads and the values of their counters
+ * (updated in competition with all other threads) is used as a source of
+ * entropy bits.
*/
- private static class Spinner implements Runnable
+ private static class Spinner
+ implements Runnable
{
-
- // Field.
- // -----------------------------------------------------------------------
-
- private byte counter;
-
- // Constructor.
- // -----------------------------------------------------------------------
+ protected byte counter;
private Spinner()
{
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
public void run()
{
while (true)
@@ -1022,27 +811,16 @@ public class CSPRNG extends BasePRNG
}
}
- private final class Poller implements Runnable
+ private final class Poller
+ implements Runnable
{
-
- // Fields.
- // -----------------------------------------------------------------------
-
private final List files;
-
private final List urls;
-
private final List progs;
-
private final List other;
-
private final CSPRNG pool;
-
private boolean running;
- // Constructor.
- // -----------------------------------------------------------------------
-
Poller(List files, List urls, List progs, List other, CSPRNG pool)
{
super();
@@ -1053,17 +831,14 @@ public class CSPRNG extends BasePRNG
this.pool = pool;
}
- // Instance methods.
- // -----------------------------------------------------------------------
-
public void run()
{
running = true;
- if (DEBUG)
+ if (Configuration.DEBUG)
{
- debug("files: " + files);
- debug("URLs: " + urls);
- debug("progs: " + progs);
+ log.fine("files: " + files);
+ log.fine("URLs: " + urls);
+ log.fine("progs: " + progs);
}
Iterator files_it = files.iterator();
Iterator urls_it = urls.iterator();
@@ -1073,190 +848,132 @@ public class CSPRNG extends BasePRNG
while (files_it.hasNext() || urls_it.hasNext() || prog_it.hasNext()
|| other_it.hasNext())
{
-
// There is enough random data. Go away.
- if (pool.getQuality() >= 100.0 || !running)
- {
- return;
- }
-
+ if (pool.getQuality() >= 100.0 || ! running)
+ return;
if (files_it.hasNext())
- {
- try
- {
- List l = (List) files_it.next();
- if (DEBUG)
- {
- debug(l.toString());
- }
- double qual = ((Double) l.get(0)).doubleValue();
- int offset = ((Integer) l.get(1)).intValue();
- int count = ((Integer) l.get(2)).intValue();
- String src = (String) l.get(3);
- InputStream in = new FileInputStream(src);
- byte[] buf = new byte[count];
- if (offset > 0)
- {
- in.skip(offset);
- }
- int len = in.read(buf);
- if (len >= 0)
- {
- pool.addRandomBytes(buf, 0, len);
- pool.addQuality(qual * ((double) len / (double) count));
- }
- if (DEBUG)
- {
- debug("got " + len + " bytes from " + src);
- }
- }
- catch (Exception x)
- {
- if (DEBUG)
- {
- debug(x.toString());
- x.printStackTrace();
- }
- }
- }
-
- if (pool.getQuality() >= 100.0 || !running)
- {
- return;
- }
-
+ try
+ {
+ List l = (List) files_it.next();
+ if (Configuration.DEBUG)
+ log.fine(l.toString());
+ double qual = ((Double) l.get(0)).doubleValue();
+ int offset = ((Integer) l.get(1)).intValue();
+ int count = ((Integer) l.get(2)).intValue();
+ String src = (String) l.get(3);
+ InputStream in = new FileInputStream(src);
+ byte[] buf = new byte[count];
+ if (offset > 0)
+ in.skip(offset);
+ int len = in.read(buf);
+ if (len >= 0)
+ {
+ pool.addRandomBytes(buf, 0, len);
+ pool.addQuality(qual * ((double) len / (double) count));
+ }
+ if (Configuration.DEBUG)
+ log.fine("got " + len + " bytes from " + src);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "run", x);
+ }
+ if (pool.getQuality() >= 100.0 || ! running)
+ return;
if (urls_it.hasNext())
- {
- try
- {
- List l = (List) urls_it.next();
- if (DEBUG)
- {
- debug(l.toString());
- }
- double qual = ((Double) l.get(0)).doubleValue();
- int offset = ((Integer) l.get(1)).intValue();
- int count = ((Integer) l.get(2)).intValue();
- URL src = (URL) l.get(3);
- InputStream in = src.openStream();
- byte[] buf = new byte[count];
- if (offset > 0)
- {
- in.skip(offset);
- }
- int len = in.read(buf);
- if (len >= 0)
- {
- pool.addRandomBytes(buf, 0, len);
- pool.addQuality(qual * ((double) len / (double) count));
- }
- if (DEBUG)
- {
- debug("got " + len + " bytes from " + src);
- }
- }
- catch (Exception x)
- {
- if (DEBUG)
- {
- debug(x.toString());
- x.printStackTrace();
- }
- }
- }
-
- if (pool.getQuality() >= 100.0 || !running)
- {
- return;
- }
-
+ try
+ {
+ List l = (List) urls_it.next();
+ if (Configuration.DEBUG)
+ log.fine(l.toString());
+ double qual = ((Double) l.get(0)).doubleValue();
+ int offset = ((Integer) l.get(1)).intValue();
+ int count = ((Integer) l.get(2)).intValue();
+ URL src = (URL) l.get(3);
+ InputStream in = src.openStream();
+ byte[] buf = new byte[count];
+ if (offset > 0)
+ in.skip(offset);
+ int len = in.read(buf);
+ if (len >= 0)
+ {
+ pool.addRandomBytes(buf, 0, len);
+ pool.addQuality(qual * ((double) len / (double) count));
+ }
+ if (Configuration.DEBUG)
+ log.fine("got " + len + " bytes from " + src);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "run", x);
+ }
+ if (pool.getQuality() >= 100.0 || ! running)
+ return;
Process proc = null;
if (prog_it.hasNext())
- {
- try
- {
- List l = (List) prog_it.next();
- if (DEBUG)
- {
- debug(l.toString());
- }
- double qual = ((Double) l.get(0)).doubleValue();
- int offset = ((Integer) l.get(1)).intValue();
- int count = ((Integer) l.get(2)).intValue();
- String src = (String) l.get(3);
- proc = null;
- proc = Runtime.getRuntime().exec(src);
- InputStream in = proc.getInputStream();
- byte[] buf = new byte[count];
- if (offset > 0)
- {
- in.skip(offset);
- }
- int len = in.read(buf);
- if (len >= 0)
- {
- pool.addRandomBytes(buf, 0, len);
- pool.addQuality(qual * ((double) len / (double) count));
- }
- proc.destroy();
- proc.waitFor();
- if (DEBUG)
- {
- debug("got " + len + " bytes from " + src);
- }
- }
- catch (Exception x)
- {
- if (DEBUG)
- {
- debug(x.toString());
- x.printStackTrace();
- }
- try
- {
- if (proc != null)
- {
- proc.destroy();
- proc.waitFor();
- }
- }
- catch (Exception ignored)
- {
- }
- }
- }
-
- if (pool.getQuality() >= 100.0 || !running)
- {
- return;
- }
-
+ try
+ {
+ List l = (List) prog_it.next();
+ if (Configuration.DEBUG)
+ log.finer(l.toString());
+ double qual = ((Double) l.get(0)).doubleValue();
+ int offset = ((Integer) l.get(1)).intValue();
+ int count = ((Integer) l.get(2)).intValue();
+ String src = (String) l.get(3);
+ proc = null;
+ proc = Runtime.getRuntime().exec(src);
+ InputStream in = proc.getInputStream();
+ byte[] buf = new byte[count];
+ if (offset > 0)
+ in.skip(offset);
+ int len = in.read(buf);
+ if (len >= 0)
+ {
+ pool.addRandomBytes(buf, 0, len);
+ pool.addQuality(qual * ((double) len / (double) count));
+ }
+ proc.destroy();
+ proc.waitFor();
+ if (Configuration.DEBUG)
+ log.fine("got " + len + " bytes from " + src);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "run", x);
+ try
+ {
+ if (proc != null)
+ {
+ proc.destroy();
+ proc.waitFor();
+ }
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ if (pool.getQuality() >= 100.0 || ! running)
+ return;
if (other_it.hasNext())
- {
- try
- {
- EntropySource src = (EntropySource) other_it.next();
- byte[] buf = src.nextBytes();
- if (pool == null)
- {
- return;
- }
- pool.addRandomBytes(buf, 0, buf.length);
- pool.addQuality(src.quality());
- if (DEBUG)
- {
- debug("got " + buf.length + " bytes from " + src);
- }
- }
- catch (Exception x)
- {
- if (DEBUG)
- {
- debug(x.toString());
- x.printStackTrace();
- }
- }
- }
+ try
+ {
+ EntropySource src = (EntropySource) other_it.next();
+ byte[] buf = src.nextBytes();
+ if (pool == null)
+ return;
+ pool.addRandomBytes(buf, 0, buf.length);
+ pool.addQuality(src.quality());
+ if (Configuration.DEBUG)
+ log.fine("got " + buf.length + " bytes from " + src);
+ }
+ catch (Exception x)
+ {
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "run", x);
+ }
}
}
@@ -1265,4 +982,4 @@ public class CSPRNG extends BasePRNG
running = false;
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java b/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
index 69ce860f451..8aec9ab7d6d 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
@@ -45,7 +45,6 @@ import gnu.java.security.prng.BasePRNG;
import gnu.java.security.prng.LimitReachedException;
import gnu.java.security.prng.RandomEvent;
import gnu.java.security.prng.RandomEventListener;
-
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
@@ -53,9 +52,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-
import java.security.InvalidKeyException;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
@@ -63,68 +60,54 @@ import java.util.Map;
/**
* The Fortuna continuously-seeded pseudo-random number generator. This
- * generator is composed of two major pieces: the entropy accumulator
- * and the generator function. The former takes in random bits and
- * incorporates them into the generator's state. The latter takes this
- * base entropy and generates pseudo-random bits from it.
- *
- * <p>There are some things users of this class <em>must</em> be aware of:
- *
+ * generator is composed of two major pieces: the entropy accumulator and the
+ * generator function. The former takes in random bits and incorporates them
+ * into the generator's state. The latter takes this base entropy and generates
+ * pseudo-random bits from it.
+ * <p>
+ * There are some things users of this class <em>must</em> be aware of:
* <dl>
* <dt>Adding Random Data</dt>
* <dd>This class does not do any polling of random sources, but rather
- * provides an interface for adding random events. Applications that use
- * this code <em>must</em> provide this mechanism. We use this design
- * because an application writer who knows the system he is targeting
- * is in a better position to judge what random data is available.</dd>
- *
+ * provides an interface for adding random events. Applications that use this
+ * code <em>must</em> provide this mechanism. We use this design because an
+ * application writer who knows the system he is targeting is in a better
+ * position to judge what random data is available.</dd>
* <dt>Storing the Seed</dt>
- * <dd>This class implements {@link Serializable} in such a way that it
- * writes a 64 byte seed to the stream, and reads it back again when being
- * deserialized. This is the extent of seed file management, however, and
- * those using this class are encouraged to think deeply about when, how
- * often, and where to store the seed.</dd>
+ * <dd>This class implements {@link Serializable} in such a way that it writes
+ * a 64 byte seed to the stream, and reads it back again when being
+ * deserialized. This is the extent of seed file management, however, and those
+ * using this class are encouraged to think deeply about when, how often, and
+ * where to store the seed.</dd>
* </dl>
- *
- * <p><b>References:</b></p>
- *
+ * <p>
+ * <b>References:</b>
* <ul>
- * <li>Niels Ferguson and Bruce Schneier, <i>Practical Cryptography</i>,
- * pp. 155--184. Wiley Publishing, Indianapolis. (2003 Niels Ferguson and
- * Bruce Schneier). ISBN 0-471-22357-3.</li>
+ * <li>Niels Ferguson and Bruce Schneier, <i>Practical Cryptography</i>, pp.
+ * 155--184. Wiley Publishing, Indianapolis. (2003 Niels Ferguson and Bruce
+ * Schneier). ISBN 0-471-22357-3.</li>
* </ul>
*/
-public class Fortuna extends BasePRNG implements Serializable,
- RandomEventListener
+public class Fortuna
+ extends BasePRNG
+ implements Serializable, RandomEventListener
{
-
private static final long serialVersionUID = 0xFACADE;
-
private static final int SEED_FILE_SIZE = 64;
-
private static final int NUM_POOLS = 32;
-
private static final int MIN_POOL_SIZE = 64;
-
private final Generator generator;
-
private final IMessageDigest[] pools;
-
private long lastReseed;
-
private int pool;
-
private int pool0Count;
-
private int reseedCount;
-
public static final String SEED = "gnu.crypto.prng.fortuna.seed";
public Fortuna()
{
super(Registry.FORTUNA_PRNG);
- generator = new Generator(
- CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER),
+ generator = new Generator(CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER),
HashFactory.getInstance(Registry.SHA256_HASH));
pools = new IMessageDigest[NUM_POOLS];
for (int i = 0; i < NUM_POOLS; i++)
@@ -144,11 +127,11 @@ public class Fortuna extends BasePRNG implements Serializable,
generator.init(attributes);
try
{
- fillBlock ();
+ fillBlock();
}
catch (LimitReachedException shouldNotHappen)
{
- throw new RuntimeException (shouldNotHappen);
+ throw new RuntimeException(shouldNotHappen);
}
}
@@ -160,10 +143,8 @@ public class Fortuna extends BasePRNG implements Serializable,
reseedCount++;
byte[] seed = new byte[0];
for (int i = 0; i < NUM_POOLS; i++)
- {
- if (reseedCount % (1 << i) == 0)
- generator.addRandomBytes(pools[i].digest());
- }
+ if (reseedCount % (1 << i) == 0)
+ generator.addRandomBytes(pools[i].digest());
lastReseed = System.currentTimeMillis();
pool0Count = 0;
}
@@ -223,23 +204,19 @@ public class Fortuna extends BasePRNG implements Serializable,
}
/**
- * The Fortuna generator function. The generator is a PRNG in its own
- * right; Fortuna itself is basically a wrapper around this generator
- * that manages reseeding in a secure way.
+ * The Fortuna generator function. The generator is a PRNG in its own right;
+ * Fortuna itself is basically a wrapper around this generator that manages
+ * reseeding in a secure way.
*/
- public static class Generator extends BasePRNG implements Cloneable
+ public static class Generator
+ extends BasePRNG
+ implements Cloneable
{
-
private static final int LIMIT = 1 << 20;
-
private final IBlockCipher cipher;
-
private final IMessageDigest hash;
-
private final byte[] counter;
-
private final byte[] key;
-
private boolean seeded;
public Generator(final IBlockCipher cipher, final IMessageDigest hash)
@@ -270,9 +247,8 @@ public class Fortuna extends BasePRNG implements Serializable,
public void nextBytes(byte[] out, int offset, int length)
{
- if (!seeded)
+ if (! seeded)
throw new IllegalStateException("generator not seeded");
-
int count = 0;
do
{
@@ -286,7 +262,6 @@ public class Fortuna extends BasePRNG implements Serializable,
throw new Error(shouldNeverHappen);
}
count += amount;
-
for (int i = 0; i < key.length; i += counter.length)
{
fillBlock();
@@ -318,7 +293,7 @@ public class Fortuna extends BasePRNG implements Serializable,
public void fillBlock()
{
- if (!seeded)
+ if (! seeded)
throw new IllegalStateException("generator not seeded");
cipher.encryptBlock(counter, 0, buffer, 0);
incrementCounter();
@@ -332,13 +307,12 @@ public class Fortuna extends BasePRNG implements Serializable,
byte[] seed = (byte[]) attributes.get(SEED);
if (seed != null)
addRandomBytes(seed);
- fillBlock ();
+ fillBlock();
}
/**
- * Resets the cipher's key. This is done after every reseed, which
- * combines the old key and the seed, and processes that throigh the
- * hash function.
+ * Resets the cipher's key. This is done after every reseed, which combines
+ * the old key and the seed, and processes that throigh the hash function.
*/
private void resetKey()
{
@@ -359,8 +333,8 @@ public class Fortuna extends BasePRNG implements Serializable,
}
/**
- * Increment `counter' as a sixteen-byte little-endian unsigned integer
- * by one.
+ * Increment `counter' as a sixteen-byte little-endian unsigned integer by
+ * one.
*/
private void incrementCounter()
{
@@ -372,4 +346,4 @@ public class Fortuna extends BasePRNG implements Serializable,
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java b/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
index 7d4f4c9a32c..5b0bd4f8b1e 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
@@ -41,9 +41,8 @@ package gnu.javax.crypto.prng;
import gnu.java.security.Registry;
import gnu.java.security.prng.BasePRNG;
import gnu.java.security.prng.LimitReachedException;
-
-import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.cipher.CipherFactory;
+import gnu.javax.crypto.cipher.IBlockCipher;
import java.math.BigInteger;
import java.security.InvalidKeyException;
@@ -51,171 +50,132 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>Counter Mode is a way to define a pseudorandom keystream generator using
- * a block cipher. The keystream can be used for additive encryption, key
- * derivation, or any other application requiring pseudorandom data.</p>
- *
- * <p>In ICM, the keystream is logically broken into segments. Each segment is
+ * Counter Mode is a way to define a pseudorandom keystream generator using a
+ * block cipher. The keystream can be used for additive encryption, key
+ * derivation, or any other application requiring pseudorandom data.
+ * <p>
+ * In ICM, the keystream is logically broken into segments. Each segment is
* identified with a segment index, and the segments have equal lengths. This
* segmentation makes ICM especially appropriate for securing packet-based
- * protocols.</p>
- *
- * <p>This implementation adheres to the definition of the ICM keystream
- * generation function that allows for any symetric key block cipher algorithm
- * (initialisation parameter <code>gnu.crypto.prng.icm.cipher.name</code> taken
- * to be an instance of {@link java.lang.String}) to be used. If such a
+ * protocols.
+ * <p>
+ * This implementation adheres to the definition of the ICM keystream generation
+ * function that allows for any symetric key block cipher algorithm
+ * (initialisation parameter <code>gnu.crypto.prng.icm.cipher.name</code>
+ * taken to be an instance of {@link java.lang.String}) to be used. If such a
* parameter is not defined/included in the initialisation <code>Map</code>,
* then the "Rijndael" algorithm is used. Furthermore, if the initialisation
* parameter <code>gnu.crypto.cipher.block.size</code> (taken to be a instance
* of {@link java.lang.Integer}) is missing or undefined in the initialisation
- * <code>Map</code>, then the cipher's <em>default</em> block size is used.</p>
- *
- * <p>The practical limits and constraints of such generator are:</p>
+ * <code>Map</code>, then the cipher's <em>default</em> block size is used.
+ * <p>
+ * The practical limits and constraints of such generator are:
* <ul>
- * <li>The number of blocks in any segment <b>MUST NOT</b> exceed <code>
- * 256 ** BLOCK_INDEX_LENGTH</code>. The number of segments <b>MUST NOT</b>
- * exceed <code>256 ** SEGMENT_INDEX_LENGTH</code>. These restrictions ensure
- * the uniqueness of each block cipher input.</li>
- *
- * <li>Each segment contains <code>SEGMENT_LENGTH</code> octets; this value
- * <b>MUST NOT</b> exceed the value <code>(256 ** BLOCK_INDEX_LENGTH) *
+ * <li>The number of blocks in any segment <b>MUST NOT</b> exceed <code>
+ * 256 ** BLOCK_INDEX_LENGTH</code>.
+ * The number of segments <b>MUST NOT</b> exceed
+ * <code>256 ** SEGMENT_INDEX_LENGTH</code>. These restrictions ensure the
+ * uniqueness of each block cipher input.</li>
+ * <li>Each segment contains <code>SEGMENT_LENGTH</code> octets; this value
+ * <b>MUST NOT</b> exceed the value <code>(256 ** BLOCK_INDEX_LENGTH) *
* BLOCK_LENGTH</code>.</li>
- *
- * <li>The sum of <code>SEGMENT_INDEX_LENGTH</code> and
- * <code>BLOCK_INDEX_LENGTH</code> <b>MUST NOT</b> exceed <code>BLOCK_LENGTH
- * / 2</code>. This requirement protects the ICM keystream generator from
- * potentially failing to be pseudorandom.</li>
+ * <li>The sum of <code>SEGMENT_INDEX_LENGTH</code> and
+ * <code>BLOCK_INDEX_LENGTH</code> <b>MUST NOT</b> exceed <code>BLOCK_LENGTH
+ * / 2</code>.
+ * This requirement protects the ICM keystream generator from potentially
+ * failing to be pseudorandom.</li>
* </ul>
- *
- * <p><b>NOTE</b>: Rijndael is used as the default symmetric key block cipher
+ * <p>
+ * <b>NOTE</b>: Rijndael is used as the default symmetric key block cipher
* algorithm because, with its default block and key sizes, it is the AES. Yet
* being Rijndael, the algorithm offers more versatile block and key sizes which
- * may prove to be useful for generating <em>longer</em> key streams.</p>
- *
- * <p>References:</p>
- *
+ * may prove to be useful for generating <em>longer</em> key streams.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-icm-00.txt">
- * Integer Counter Mode</a>, David A. McGrew.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-icm-00.txt">
+ * Integer Counter Mode</a>, David A. McGrew.</li>
* </ol>
*/
-public class ICMGenerator extends BasePRNG implements Cloneable
+public class ICMGenerator
+ extends BasePRNG
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Property name of underlying block cipher for this ICM generator. */
public static final String CIPHER = "gnu.crypto.prng.icm.cipher.name";
-
/** Property name of ICM's block index length. */
- public static final String BLOCK_INDEX_LENGTH = "gnu.crypto.prng.icm.block.index.length";
-
+ public static final String BLOCK_INDEX_LENGTH =
+ "gnu.crypto.prng.icm.block.index.length";
/** Property name of ICM's segment index length. */
- public static final String SEGMENT_INDEX_LENGTH = "gnu.crypto.prng.icm.segment.index.length";
-
+ public static final String SEGMENT_INDEX_LENGTH =
+ "gnu.crypto.prng.icm.segment.index.length";
/** Property name of ICM's offset. */
public static final String OFFSET = "gnu.crypto.prng.icm.offset";
-
/** Property name of ICM's segment index. */
public static final String SEGMENT_INDEX = "gnu.crypto.prng.icm.segment.index";
-
/** The integer value 256 as a BigInteger. */
private static final BigInteger TWO_FIFTY_SIX = new BigInteger("256");
-
/** The underlying cipher implementation. */
private IBlockCipher cipher;
-
/** This keystream block index length in bytes. */
private int blockNdxLength = -1;
-
/** This keystream segment index length in bytes. */
private int segmentNdxLength = -1;
-
/** The index of the next block for a given keystream segment. */
private BigInteger blockNdx = BigInteger.ZERO;
-
/** The segment index for this keystream. */
private BigInteger segmentNdx;
-
/** The initial counter for a given keystream segment. */
private BigInteger C0;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public ICMGenerator()
{
super(Registry.ICM_PRNG);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BasePRNG --------------------------
-
- // Conceptually, ICM is a keystream generator that takes a secret key
- // and a segment index as an input and then outputs a keystream
- // segment. The segmentation lends itself to packet encryption, as
- // each keystream segment can be used to encrypt a distinct packet.
- //
- // An ICM key consists of the block cipher key and an Offset. The
- // Offset is an integer with BLOCK_LENGTH octets...
+ // Conceptually, ICM is a keystream generator that takes a secret key and a
+ // segment index as an input and then outputs a keystream segment. The
+ // segmentation lends itself to packet encryption, as each keystream segment
+ // can be used to encrypt a distinct packet.
//
+ // An ICM key consists of the block cipher key and an Offset. The Offset is
+ // an integer with BLOCK_LENGTH octets...
public void setup(Map attributes)
{
// find out which cipher algorithm to use
boolean newCipher = true;
String underlyingCipher = (String) attributes.get(CIPHER);
if (underlyingCipher == null)
- {
- if (cipher == null)
- { // happy birthday
- // ensure we have a reliable implementation of this cipher
- cipher = CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER);
- }
- else
- { // we already have one. use it as is
- newCipher = false;
- }
- }
- else
- { // ensure we have a reliable implementation of this cipher
- cipher = CipherFactory.getInstance(underlyingCipher);
- }
+ if (cipher == null) // happy birthday
+ // ensure we have a reliable implementation of this cipher
+ cipher = CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER);
+ else
+ // we already have one. use it as is
+ newCipher = false;
+ else // ensure we have a reliable implementation of this cipher
+ cipher = CipherFactory.getInstance(underlyingCipher);
// find out what block size we should use it in
int cipherBlockSize = 0;
Integer bs = (Integer) attributes.get(IBlockCipher.CIPHER_BLOCK_SIZE);
if (bs != null)
- {
- cipherBlockSize = bs.intValue();
- }
+ cipherBlockSize = bs.intValue();
else
{
- if (newCipher)
- { // assume we'll use its default block size
- cipherBlockSize = cipher.defaultBlockSize();
- } // else use as is
+ if (newCipher) // assume we'll use its default block size
+ cipherBlockSize = cipher.defaultBlockSize();
+ // else use as is
}
-
// get the key material
byte[] key = (byte[]) attributes.get(IBlockCipher.KEY_MATERIAL);
if (key == null)
- {
- throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
- }
-
+ throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
// now initialise the cipher
HashMap map = new HashMap();
- if (cipherBlockSize != 0)
- { // only needed if new or changed
- map.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(cipherBlockSize));
- }
+ if (cipherBlockSize != 0) // only needed if new or changed
+ map.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(cipherBlockSize));
map.put(IBlockCipher.KEY_MATERIAL, key);
try
{
@@ -225,135 +185,96 @@ public class ICMGenerator extends BasePRNG implements Cloneable
{
throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
}
-
// at this point we have an initialised (new or otherwise) cipher
// ensure that remaining params make sense
-
cipherBlockSize = cipher.currentBlockSize();
BigInteger counterRange = TWO_FIFTY_SIX.pow(cipherBlockSize);
-
// offset, like the underlying cipher key is not cloneable
// always look for it and throw an exception if it's not there
Object obj = attributes.get(OFFSET);
// allow either a byte[] or a BigInteger
BigInteger r;
if (obj instanceof BigInteger)
+ r = (BigInteger) obj;
+ else // assume byte[]. should be same length as cipher block size
{
- r = (BigInteger) obj;
- }
- else
- { // assume byte[]. should be same length as cipher block size
byte[] offset = (byte[]) obj;
if (offset.length != cipherBlockSize)
- {
- throw new IllegalArgumentException(OFFSET);
- }
-
+ throw new IllegalArgumentException(OFFSET);
r = new BigInteger(1, offset);
}
-
int wantBlockNdxLength = -1; // number of octets in the block index
Integer i = (Integer) attributes.get(BLOCK_INDEX_LENGTH);
if (i != null)
{
wantBlockNdxLength = i.intValue();
if (wantBlockNdxLength < 1)
- {
- throw new IllegalArgumentException(BLOCK_INDEX_LENGTH);
- }
+ throw new IllegalArgumentException(BLOCK_INDEX_LENGTH);
}
-
int wantSegmentNdxLength = -1; // number of octets in the segment index
i = (Integer) attributes.get(SEGMENT_INDEX_LENGTH);
if (i != null)
{
wantSegmentNdxLength = i.intValue();
if (wantSegmentNdxLength < 1)
- {
- throw new IllegalArgumentException(SEGMENT_INDEX_LENGTH);
- }
+ throw new IllegalArgumentException(SEGMENT_INDEX_LENGTH);
}
-
// if both are undefined check if it's a reuse
if ((wantBlockNdxLength == -1) && (wantSegmentNdxLength == -1))
{
- if (blockNdxLength == -1)
- { // new instance
- throw new IllegalArgumentException(BLOCK_INDEX_LENGTH + ", "
- + SEGMENT_INDEX_LENGTH);
- } // else reuse old values
+ if (blockNdxLength == -1) // new instance
+ throw new IllegalArgumentException(BLOCK_INDEX_LENGTH + ", "
+ + SEGMENT_INDEX_LENGTH);
+ // else reuse old values
}
- else
- { // only one is undefined, set it to BLOCK_LENGTH/2 minus the other
+ else // only one is undefined, set it to BLOCK_LENGTH/2 minus the other
+ {
int limit = cipherBlockSize / 2;
if (wantBlockNdxLength == -1)
- {
- wantBlockNdxLength = limit - wantSegmentNdxLength;
- }
+ wantBlockNdxLength = limit - wantSegmentNdxLength;
else if (wantSegmentNdxLength == -1)
- {
- wantSegmentNdxLength = limit - wantBlockNdxLength;
- }
+ wantSegmentNdxLength = limit - wantBlockNdxLength;
else if ((wantSegmentNdxLength + wantBlockNdxLength) > limit)
- {
- throw new IllegalArgumentException(BLOCK_INDEX_LENGTH + ", "
- + SEGMENT_INDEX_LENGTH);
- }
+ throw new IllegalArgumentException(BLOCK_INDEX_LENGTH + ", "
+ + SEGMENT_INDEX_LENGTH);
// save new values
blockNdxLength = wantBlockNdxLength;
segmentNdxLength = wantSegmentNdxLength;
}
-
// get the segment index as a BigInteger
BigInteger s = (BigInteger) attributes.get(SEGMENT_INDEX);
if (s == null)
{
- if (segmentNdx == null)
- { // segment index was never set
- throw new IllegalArgumentException(SEGMENT_INDEX);
- }
+ if (segmentNdx == null) // segment index was never set
+ throw new IllegalArgumentException(SEGMENT_INDEX);
// reuse; check if still valid
if (segmentNdx.compareTo(TWO_FIFTY_SIX.pow(segmentNdxLength)) > 0)
- {
- throw new IllegalArgumentException(SEGMENT_INDEX);
- }
+ throw new IllegalArgumentException(SEGMENT_INDEX);
}
else
{
if (s.compareTo(TWO_FIFTY_SIX.pow(segmentNdxLength)) > 0)
- {
- throw new IllegalArgumentException(SEGMENT_INDEX);
- }
+ throw new IllegalArgumentException(SEGMENT_INDEX);
segmentNdx = s;
}
-
// The initial counter of the keystream segment with segment index s is
// defined as follows, where r denotes the Offset:
//
// C[0] = (s * (256^BLOCK_INDEX_LENGTH) + r) modulo (256^BLOCK_LENGTH)
- //
- C0 = segmentNdx.multiply(TWO_FIFTY_SIX.pow(blockNdxLength)).add(r).modPow(
- BigInteger.ONE,
- counterRange);
+ C0 = segmentNdx.multiply(TWO_FIFTY_SIX.pow(blockNdxLength))
+ .add(r).modPow(BigInteger.ONE, counterRange);
}
public void fillBlock() throws LimitReachedException
{
if (C0 == null)
- {
- throw new IllegalStateException();
- }
+ throw new IllegalStateException();
if (blockNdx.compareTo(TWO_FIFTY_SIX.pow(blockNdxLength)) >= 0)
- {
- throw new LimitReachedException();
- }
-
+ throw new LimitReachedException();
int cipherBlockSize = cipher.currentBlockSize();
BigInteger counterRange = TWO_FIFTY_SIX.pow(cipherBlockSize);
-
// encrypt the counter for the current blockNdx
// C[i] = (C[0] + i) modulo (256^BLOCK_LENGTH).
-
BigInteger Ci = C0.add(blockNdx).modPow(BigInteger.ONE, counterRange);
buffer = Ci.toByteArray();
int limit = buffer.length;
@@ -370,7 +291,6 @@ public class ICMGenerator extends BasePRNG implements Cloneable
cipherBlockSize);
buffer = data;
}
-
cipher.encryptBlock(buffer, 0, buffer, 0);
blockNdx = blockNdx.add(BigInteger.ONE); // increment blockNdx
}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java b/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
index d39cd0a6597..0f91d4add72 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
@@ -49,51 +49,42 @@ import java.util.HashMap;
import java.util.Map;
/**
- * <p>An implementation of the <i>key derivation function</i> KDF2 from PKCS #5:
+ * An implementation of the <i>key derivation function</i> KDF2 from PKCS #5:
* Password-Based Cryptography (<b>PBE</b>). This KDF is essentially a way to
* transform a password and a salt into a stream of random bytes, which may then
- * be used to initialize a cipher or a MAC.</p>
- *
- * <p>This version uses a MAC as its pseudo-random function, and the password is
- * used as the key.</p>
- *
- * <p>References:</p>
+ * be used to initialize a cipher or a MAC.
+ * <p>
+ * This version uses a MAC as its pseudo-random function, and the password is
+ * used as the key.
+ * <p>
+ * References:
* <ol>
- * <li>B. Kaliski, <a href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898:
- * Password-Based Cryptography Specification, Version 2.0</a></li>
+ * <li>B. Kaliski, <a href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898:
+ * Password-Based Cryptography Specification, Version 2.0</a></li>
* </ol>
*/
-public class PBKDF2 extends BasePRNG implements Cloneable
+public class PBKDF2
+ extends BasePRNG
+ implements Cloneable
{
-
- // Contstants and variables
- // -------------------------------------------------------------------------
-
/**
- * The bytes fed into the MAC. This is initially the concatenation of the
- * salt and the block number.
+ * The bytes fed into the MAC. This is initially the concatenation of the salt
+ * and the block number.
*/
private byte[] in;
-
/** The iteration count. */
private int iterationCount;
-
/** The salt. */
private byte[] salt;
-
/** The MAC (the pseudo-random function we use). */
private IMac mac;
-
/** The number of hLen-sized blocks generated. */
private long count;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Creates a new PBKDF2 object. The argument is the MAC that will serve as
- * the pseudo-random function. The MAC does not need to be initialized.</p>
- *
+ * Creates a new PBKDF2 object. The argument is the MAC that will serve as the
+ * pseudo-random function. The MAC does not need to be initialized.
+ *
* @param mac The pseudo-random function.
*/
public PBKDF2(IMac mac)
@@ -103,30 +94,19 @@ public class PBKDF2 extends BasePRNG implements Cloneable
iterationCount = -1;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public void setup(Map attributes)
{
Map macAttrib = new HashMap();
macAttrib.put(HMac.USE_WITH_PKCS5_V2, Boolean.TRUE);
-
byte[] s = (byte[]) attributes.get(IPBE.SALT);
if (s == null)
{
if (salt == null)
- {
- throw new IllegalArgumentException("no salt specified");
- } // Otherwise re-use.
+ throw new IllegalArgumentException("no salt specified");
+ // Otherwise re-use.
}
else
- {
- salt = s;
- }
-
+ salt = s;
byte[] macKeyMaterial;
char[] password = (char[]) attributes.get(IPBE.PASSWORD);
if (password != null)
@@ -136,7 +116,6 @@ public class PBKDF2 extends BasePRNG implements Cloneable
encoding = IPBE.DEFAULT_PASSWORD_ENCODING;
else
encoding = encoding.trim();
-
try
{
macKeyMaterial = new String(password).getBytes(encoding);
@@ -152,10 +131,10 @@ public class PBKDF2 extends BasePRNG implements Cloneable
if (macKeyMaterial != null)
macAttrib.put(IMac.MAC_KEY_MATERIAL, macKeyMaterial);
- else if (!initialised)
- throw new IllegalArgumentException("Neither password nor key-material were specified");
+ else if (! initialised)
+ throw new IllegalArgumentException(
+ "Neither password nor key-material were specified");
// otherwise re-use previous password/key-material
-
try
{
mac.init(macAttrib);
@@ -164,27 +143,19 @@ public class PBKDF2 extends BasePRNG implements Cloneable
{
throw new IllegalArgumentException(x.getMessage());
}
-
Integer ic = (Integer) attributes.get(IPBE.ITERATION_COUNT);
if (ic != null)
- {
- iterationCount = ic.intValue();
- }
+ iterationCount = ic.intValue();
if (iterationCount <= 0)
- {
- throw new IllegalArgumentException("bad iteration count");
- }
-
+ throw new IllegalArgumentException("bad iteration count");
count = 0L;
buffer = new byte[mac.macSize()];
try
{
fillBlock();
- // } catch (Exception x) {
}
catch (LimitReachedException x)
{
- // x.printStackTrace(System.err);
throw new Error(x.getMessage());
}
}
@@ -192,34 +163,22 @@ public class PBKDF2 extends BasePRNG implements Cloneable
public void fillBlock() throws LimitReachedException
{
if (++count > ((1L << 32) - 1))
- {
- throw new LimitReachedException();
- }
- // for (int i = 0; i < buffer.length; i++) {
- // buffer[i] = 0;
- // }
+ throw new LimitReachedException();
Arrays.fill(buffer, (byte) 0x00);
int limit = salt.length;
- // in = new byte[salt.length + 4];
in = new byte[limit + 4];
System.arraycopy(salt, 0, in, 0, salt.length);
- // in[salt.length ] = (byte)(count >>> 24);
- // in[salt.length+1] = (byte)(count >>> 16);
- // in[salt.length+2] = (byte)(count >>> 8);
- // in[salt.length+3] = (byte) count;
- in[limit++] = (byte) (count >>> 24);
- in[limit++] = (byte) (count >>> 16);
- in[limit++] = (byte) (count >>> 8);
- in[limit] = (byte) count;
+ in[limit++] = (byte)(count >>> 24);
+ in[limit++] = (byte)(count >>> 16);
+ in[limit++] = (byte)(count >>> 8);
+ in[limit ] = (byte) count;
for (int i = 0; i < iterationCount; i++)
{
mac.reset();
mac.update(in, 0, in.length);
in = mac.digest();
for (int j = 0; j < buffer.length; j++)
- {
- buffer[j] ^= in[j];
- }
+ buffer[j] ^= in[j];
}
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/PRNGFactory.java b/libjava/classpath/gnu/javax/crypto/prng/PRNGFactory.java
index 9ff6558b0e3..ee75f8d8a1e 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/PRNGFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/PRNGFactory.java
@@ -40,11 +40,9 @@ package gnu.javax.crypto.prng;
import gnu.java.security.Registry;
import gnu.java.security.prng.IRandom;
-
-
+import gnu.javax.crypto.mac.HMacFactory;
import gnu.javax.crypto.mac.IMac;
import gnu.javax.crypto.mac.MacFactory;
-import gnu.javax.crypto.mac.HMacFactory;
import java.util.Collections;
import java.util.HashSet;
@@ -52,92 +50,66 @@ import java.util.Iterator;
import java.util.Set;
/**
- * <p>A Factory to instantiate pseudo random number generators.</p>
+ * A Factory to instantiate pseudo random number generators.
*/
-public class PRNGFactory implements Registry
+public class PRNGFactory
+ implements Registry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
private PRNGFactory()
{
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a padding algorithm given its name.</p>
- *
+ * Returns an instance of a padding algorithm given its name.
+ *
* @param prng the case-insensitive name of the PRNG.
* @return an instance of the pseudo-random number generator.
* @exception InternalError if the implementation does not pass its self-
- * test.
+ * test.
*/
public static IRandom getInstance(String prng)
{
if (prng == null)
- {
- return null;
- }
-
+ return null;
prng = prng.trim();
IRandom result = null;
if (prng.equalsIgnoreCase(ARCFOUR_PRNG) || prng.equalsIgnoreCase(RC4_PRNG))
- {
- result = new ARCFour();
- }
+ result = new ARCFour();
else if (prng.equalsIgnoreCase(ICM_PRNG))
- {
- result = new ICMGenerator();
- }
+ result = new ICMGenerator();
else if (prng.equalsIgnoreCase(UMAC_PRNG))
- {
- result = new UMacGenerator();
- }
+ result = new UMacGenerator();
else if (prng.toLowerCase().startsWith(PBKDF2_PRNG_PREFIX))
{
String macName = prng.substring(PBKDF2_PRNG_PREFIX.length());
IMac mac = MacFactory.getInstance(macName);
if (mac == null)
- {
- return null;
- }
+ return null;
result = new PBKDF2(mac);
}
if (result != null)
return result;
- return gnu.java.security.prng.PRNGFactory.getInstance (prng);
+ return gnu.java.security.prng.PRNGFactory.getInstance(prng);
}
/**
- * <p>Returns a {@link Set} of names of padding algorithms supported by this
- * <i>Factory</i>.</p>
- *
+ * Returns a {@link Set} of names of padding algorithms supported by this
+ * <i>Factory</i>.
+ *
* @return a {@link Set} of pseudo-random number generator algorithm names
- * (Strings).
+ * (Strings).
*/
public static Set getNames()
{
- HashSet hs = new HashSet (gnu.java.security.prng.PRNGFactory.getNames ());
+ HashSet hs = new HashSet(gnu.java.security.prng.PRNGFactory.getNames());
hs.add(ICM_PRNG);
hs.add(UMAC_PRNG);
// add all hmac implementations as candidate PBKDF2 ones too
for (Iterator it = HMacFactory.getNames().iterator(); it.hasNext();)
- {
- hs.add(PBKDF2_PRNG_PREFIX + ((String) it.next()));
- }
-
+ hs.add(PBKDF2_PRNG_PREFIX + ((String) it.next()));
return Collections.unmodifiableSet(hs);
}
-
- // Instance methods
- // -------------------------------------------------------------------------
}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/UMacGenerator.java b/libjava/classpath/gnu/javax/crypto/prng/UMacGenerator.java
index 0e3725ce986..39c99f73af6 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/UMacGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/UMacGenerator.java
@@ -50,121 +50,90 @@ import java.util.Map;
import java.security.InvalidKeyException;
/**
- * <p><i>KDF</i>s (Key Derivation Functions) are used to stretch user-supplied
- * key material to specific size(s) required by high level cryptographic
- * primitives. Described in the <A
+ * <i>KDF</i>s (Key Derivation Functions) are used to stretch user-supplied key
+ * material to specific size(s) required by high level cryptographic primitives.
+ * Described in the <A
* HREF="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">UMAC</A>
* paper, this function basically operates an underlying <em>symmetric key block
* cipher</em> instance in output feedback mode (OFB), as a <b>strong</b>
- * pseudo-random number generator.</p>
- *
- * <p><code>UMacGenerator</code> requires an <em>index</em> parameter
+ * pseudo-random number generator.
+ * <p>
+ * <code>UMacGenerator</code> requires an <em>index</em> parameter
* (initialisation parameter <code>gnu.crypto.prng.umac.kdf.index</code> taken
- * to be an instance of {@link java.lang.Integer} with a value between
- * <code>0</code> and <code>255</code>). Using the same key, but different
- * indices, generates different pseudorandom outputs.</p>
- *
- * <p>This implementation generalises the definition of the
- * <code>UmacGenerator</code> algorithm to allow for other than the AES symetric
- * key block cipher algorithm (initialisation parameter
+ * to be an instance of {@link Integer} with a value between <code>0</code> and
+ * <code>255</code>). Using the same key, but different indices, generates
+ * different pseudorandom outputs.
+ * <p>
+ * This implementation generalises the definition of the
+ * <code>UmacGenerator</code> algorithm to allow for other than the AES
+ * symetric key block cipher algorithm (initialisation parameter
* <code>gnu.crypto.prng.umac.cipher.name</code> taken to be an instance of
- * {@link java.lang.String}). If such a parameter is not defined/included in the
+ * {@link String}). If such a parameter is not defined/included in the
* initialisation <code>Map</code>, then the "Rijndael" algorithm is used.
* Furthermore, if the initialisation parameter
- * <code>gnu.crypto.cipher.block.size</code> (taken to be a instance of {@link
- * java.lang.Integer}) is missing or undefined in the initialisation <code>Map
- * </code>, then the cipher's <em>default</em> block size is used.</p>
- *
- * <p><b>NOTE</b>: Rijndael is used as the default symmetric key block cipher
+ * <code>gnu.crypto.cipher.block.size</code> (taken to be a instance of
+ * {@link Integer}) is missing or undefined in the initialisation
+ * <code>Map</code>, then the cipher's <em>default</em> block size is used.
+ * <p>
+ * <b>NOTE</b>: Rijndael is used as the default symmetric key block cipher
* algorithm because, with its default block and key sizes, it is the AES. Yet
* being Rijndael, the algorithm offers more versatile block and key sizes which
- * may prove to be useful for generating "longer" key streams.</p>
- *
- * <p>References:</p>
- *
+ * may prove to be useful for generating "longer" key streams.
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
- * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
- * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
+ * <li><a href="http://www.ietf.org/internet-drafts/draft-krovetz-umac-01.txt">
+ * UMAC</a>: Message Authentication Code using Universal Hashing.<br>
+ * T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.</li>
* </ol>
*/
-public class UMacGenerator extends BasePRNG implements Cloneable
+public class UMacGenerator
+ extends BasePRNG
+ implements Cloneable
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/**
- * <p>Property name of the KDF <code>index</code> value to use in this
+ * Property name of the KDF <code>index</code> value to use in this
* instance. The value is taken to be an {@link Integer} less than
- * <code>256</code>.</p>
+ * <code>256</code>.
*/
public static final String INDEX = "gnu.crypto.prng.umac.index";
-
/** The name of the underlying symmetric key block cipher algorithm. */
public static final String CIPHER = "gnu.crypto.prng.umac.cipher.name";
-
/** The generator's underlying block cipher. */
private IBlockCipher cipher;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial 0-arguments constructor. */
public UMacGenerator()
{
super(Registry.UMAC_PRNG);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Implementation of abstract methods in BasePRNG --------------------------
-
public void setup(Map attributes)
{
boolean newCipher = true;
String cipherName = (String) attributes.get(CIPHER);
if (cipherName == null)
- {
- if (cipher == null)
- { // happy birthday
- cipher = CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER);
- }
- else
- { // we already have one. use it as is
- newCipher = false;
- }
- }
+ if (cipher == null) // happy birthday
+ cipher = CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER);
+ else // we already have one. use it as is
+ newCipher = false;
else
- {
- cipher = CipherFactory.getInstance(cipherName);
- }
-
+ cipher = CipherFactory.getInstance(cipherName);
// find out what block size we should use it in
int cipherBlockSize = 0;
Integer bs = (Integer) attributes.get(IBlockCipher.CIPHER_BLOCK_SIZE);
if (bs != null)
- {
- cipherBlockSize = bs.intValue();
- }
+ cipherBlockSize = bs.intValue();
else
{
- if (newCipher)
- { // assume we'll use its default block size
- cipherBlockSize = cipher.defaultBlockSize();
- } // else use as is
+ if (newCipher) // assume we'll use its default block size
+ cipherBlockSize = cipher.defaultBlockSize();
+ // else use as is
}
-
// get the key material
byte[] key = (byte[]) attributes.get(IBlockCipher.KEY_MATERIAL);
if (key == null)
- {
- throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
- }
+ throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
int keyLength = key.length;
// ensure that keyLength is valid for the chosen underlying cipher
@@ -173,15 +142,10 @@ public class UMacGenerator extends BasePRNG implements Cloneable
{
ok = (keyLength == ((Integer) it.next()).intValue());
if (ok)
- {
- break;
- }
+ break;
}
- if (!ok)
- {
- throw new IllegalArgumentException("key length");
- }
-
+ if (! ok)
+ throw new IllegalArgumentException("key length");
// ensure that remaining params make sense
int index = -1;
Integer i = (Integer) attributes.get(INDEX);
@@ -189,17 +153,12 @@ public class UMacGenerator extends BasePRNG implements Cloneable
{
index = i.intValue();
if (index < 0 || index > 255)
- {
- throw new IllegalArgumentException(INDEX);
- }
+ throw new IllegalArgumentException(INDEX);
}
-
// now initialise the underlying cipher
Map map = new HashMap();
- if (cipherBlockSize != 0)
- { // only needed if new or changed
- map.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(cipherBlockSize));
- }
+ if (cipherBlockSize != 0) // only needed if new or changed
+ map.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(cipherBlockSize));
map.put(IBlockCipher.KEY_MATERIAL, key);
try
{
@@ -209,7 +168,6 @@ public class UMacGenerator extends BasePRNG implements Cloneable
{
throw new IllegalArgumentException(IBlockCipher.KEY_MATERIAL);
}
-
buffer = new byte[cipher.currentBlockSize()];
buffer[cipher.currentBlockSize() - 1] = (byte) index;
try
@@ -225,4 +183,4 @@ public class UMacGenerator extends BasePRNG implements Cloneable
{
cipher.encryptBlock(buffer, 0, buffer, 0);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/AuthInfo.java b/libjava/classpath/gnu/javax/crypto/sasl/AuthInfo.java
index 1e942559dcf..733d2f0bf47 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/AuthInfo.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/AuthInfo.java
@@ -56,10 +56,6 @@ import java.util.StringTokenizer;
*/
public class AuthInfo
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static final ArrayList factories = new ArrayList();
static
{
@@ -72,14 +68,14 @@ public class AuthInfo
{
for (StringTokenizer st = new StringTokenizer(pkgs, "|"); st.hasMoreTokens();)
{
- clazz = st.nextToken();
- if (!"gnu.crypto.sasl".equals(clazz))
+ clazz = st.nextToken().trim();
+ if (! "gnu.javax.crypto.sasl".equals(clazz))
{
clazz += ".AuthInfoProviderFactory";
try
{
- IAuthInfoProviderFactory factory = (IAuthInfoProviderFactory) Class.forName(
- clazz).newInstance();
+ IAuthInfoProviderFactory factory =
+ (IAuthInfoProviderFactory) Class.forName(clazz).newInstance();
factories.add(factory);
}
catch (ClassCastException ignored)
@@ -99,33 +95,25 @@ public class AuthInfo
}
// always add ours last; unless it's already there
if (!factories.contains(ours))
- {
- factories.add(ours);
- }
+ factories.add(ours);
}
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial constructor to enforce Singleton pattern. */
private AuthInfo()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * A convenience method to return the authentication information provider
- * for a designated SASL mechnanism. It goes through all the installed
- * provider factories, one at a time, and attempts to return a new instance
- * of the provider for the designated mechanism. It stops at the first
- * factory returning a non-null provider.
- *
+ * A convenience method to return the authentication information provider for
+ * a designated SASL mechnanism. It goes through all the installed provider
+ * factories, one at a time, and attempts to return a new instance of the
+ * provider for the designated mechanism. It stops at the first factory
+ * returning a non-null provider.
+ *
* @param mechanism the name of a SASL mechanism.
* @return an implementation that provides {@link IAuthInfoProvider} for that
- * mechanism; or <code>null</code> if none found.
+ * mechanism; or <code>null</code> if none found.
*/
public static IAuthInfoProvider getProvider(String mechanism)
{
@@ -134,9 +122,7 @@ public class AuthInfo
IAuthInfoProviderFactory factory = (IAuthInfoProviderFactory) it.next();
IAuthInfoProvider result = factory.getInstance(mechanism);
if (result != null)
- {
- return result;
- }
+ return result;
}
return null;
}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/AuthInfoProviderFactory.java b/libjava/classpath/gnu/javax/crypto/sasl/AuthInfoProviderFactory.java
index 6ba5fc56296..c4fc816dc3e 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/AuthInfoProviderFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/AuthInfoProviderFactory.java
@@ -46,44 +46,22 @@ import gnu.javax.crypto.sasl.srp.SRPAuthInfoProvider;
/**
* The concrete SASL authentication information provider factory.
*/
-public class AuthInfoProviderFactory implements IAuthInfoProviderFactory
+public class AuthInfoProviderFactory
+ implements IAuthInfoProviderFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constructor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProviderFactory interface implementation -----------------------
-
public IAuthInfoProvider getInstance(String mechanism)
{
if (mechanism == null)
- {
- return null;
- }
+ return null;
mechanism = mechanism.trim().toUpperCase();
if (mechanism.startsWith(Registry.SASL_SRP_MECHANISM))
- {
- return new SRPAuthInfoProvider();
- }
+ return new SRPAuthInfoProvider();
if (mechanism.equals(Registry.SASL_CRAM_MD5_MECHANISM))
- {
- return new CramMD5AuthInfoProvider();
- }
+ return new CramMD5AuthInfoProvider();
if (mechanism.equals(Registry.SASL_PLAIN_MECHANISM))
- {
- return new PlainAuthInfoProvider();
- }
+ return new PlainAuthInfoProvider();
return null;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ClientFactory.java b/libjava/classpath/gnu/javax/crypto/sasl/ClientFactory.java
index ef184632cc4..84acfcd1455 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ClientFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ClientFactory.java
@@ -47,11 +47,11 @@ import gnu.javax.crypto.sasl.srp.SRPClient;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
@@ -62,53 +62,32 @@ import javax.security.sasl.SaslException;
/**
* The implementation of {@link SaslClientFactory}.
*/
-public class ClientFactory implements SaslClientFactory
+public class ClientFactory
+ implements SaslClientFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
public static final Set getNames()
{
- return Collections.unmodifiableSet(new HashSet(
- Arrays.asList(getNamesInternal(null))));
+ return Collections.unmodifiableSet(new HashSet(Arrays.asList(getNamesInternal(null))));
}
private static final String[] getNamesInternal(Map props)
{
- String[] all = new String[] { Registry.SASL_SRP_MECHANISM,
- Registry.SASL_CRAM_MD5_MECHANISM,
- Registry.SASL_PLAIN_MECHANISM,
- Registry.SASL_ANONYMOUS_MECHANISM };
-
+ String[] all = new String[] {
+ Registry.SASL_SRP_MECHANISM,
+ Registry.SASL_CRAM_MD5_MECHANISM,
+ Registry.SASL_PLAIN_MECHANISM,
+ Registry.SASL_ANONYMOUS_MECHANISM };
if (props == null)
- {
- return all;
- }
+ return all;
if (hasPolicy(Sasl.POLICY_PASS_CREDENTIALS, props))
- {
- return new String[0];
- }
-
+ return new String[0];
List result = new ArrayList(all.length);
- ;
for (int i = 0; i < all.length;)
- {
- result.add(all[i++]);
- }
-
+ result.add(all[i++]);
if (hasPolicy(Sasl.POLICY_NOPLAINTEXT, props))
- {
- result.remove(Registry.SASL_PLAIN_MECHANISM);
- }
+ result.remove(Registry.SASL_PLAIN_MECHANISM);
if (hasPolicy(Sasl.POLICY_NOACTIVE, props))
{
result.remove(Registry.SASL_CRAM_MD5_MECHANISM);
@@ -135,32 +114,19 @@ public class ClientFactory implements SaslClientFactory
public static final ClientMechanism getInstance(String mechanism)
{
if (mechanism == null)
- {
- return null;
- }
+ return null;
mechanism = mechanism.trim().toUpperCase();
if (mechanism.equals(Registry.SASL_SRP_MECHANISM))
- {
- return new SRPClient();
- }
+ return new SRPClient();
if (mechanism.equals(Registry.SASL_CRAM_MD5_MECHANISM))
- {
- return new CramMD5Client();
- }
+ return new CramMD5Client();
if (mechanism.equals(Registry.SASL_PLAIN_MECHANISM))
- {
- return new PlainClient();
- }
+ return new PlainClient();
if (mechanism.equals(Registry.SASL_ANONYMOUS_MECHANISM))
- {
- return new AnonymousClient();
- }
+ return new AnonymousClient();
return null;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public SaslClient createSaslClient(String[] mechanisms,
String authorisationID, String protocol,
String serverName, Map props,
@@ -173,29 +139,21 @@ public class ClientFactory implements SaslClientFactory
mechanism = mechanisms[i];
result = getInstance(mechanism);
if (result != null)
- {
- break;
- }
+ break;
}
-
if (result != null)
{
HashMap attributes = new HashMap();
if (props != null)
- {
- attributes.putAll(props);
- }
+ attributes.putAll(props);
attributes.put(Registry.SASL_AUTHORISATION_ID, authorisationID);
attributes.put(Registry.SASL_PROTOCOL, protocol);
attributes.put(Registry.SASL_SERVER_NAME, serverName);
attributes.put(Registry.SASL_CALLBACK_HANDLER, cbh);
-
result.init(attributes);
return result;
}
-
- throw new SaslException(
- "No supported mechanism found in given mechanism list");
+ throw new SaslException("No supported mechanism found in given mechanism list");
}
public String[] getMechanismNames(Map props)
@@ -207,4 +165,4 @@ public class ClientFactory implements SaslClientFactory
{
return "true".equalsIgnoreCase(String.valueOf(props.get(propertyName)));
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java b/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java
index 45873ae6b27..7f8e9c120b4 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java
@@ -42,50 +42,37 @@ import gnu.java.security.Registry;
import java.util.HashMap;
import java.util.Map;
+
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslException;
/**
- * <p>A base class to facilitate implementing SASL client-side mechanisms.</p>
+ * A base class to facilitate implementing SASL client-side mechanisms.
*/
-public abstract class ClientMechanism implements SaslClient
+public abstract class ClientMechanism
+ implements SaslClient
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Name of this mechanism. */
protected String mechanism;
-
/** The authorisation identity. */
protected String authorizationID;
-
/** Name of protocol using this mechanism. */
protected String protocol;
-
/** Name of server to authenticate to. */
protected String serverName;
-
/** Properties of qualities desired for this mechanism. */
protected Map properties;
-
/** Callback handler to use with this mechanism instance. */
protected CallbackHandler handler;
-
/** Channel binding data to use with this mechanism instance. */
protected byte[] channelBinding;
-
/** Whether authentication phase is completed (true) or not (false). */
protected boolean complete = false;
-
/** The state of the authentication automaton. */
protected int state = -1;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected ClientMechanism(final String mechanism)
{
super();
@@ -94,20 +81,10 @@ public abstract class ClientMechanism implements SaslClient
this.state = -1;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods to be implemented by concrete subclasses ---------------
-
protected abstract void initMechanism() throws SaslException;
protected abstract void resetMechanism() throws SaslException;
- // javax.security.sasl.SaslClient interface implementation -----------------
-
public abstract byte[] evaluateChallenge(byte[] challenge)
throws SaslException;
@@ -121,20 +98,16 @@ public abstract class ClientMechanism implements SaslClient
public byte[] unwrap(final byte[] incoming, final int offset, final int len)
throws SaslException
{
- if (!isComplete())
- {
- throw new IllegalMechanismStateException();
- }
+ if (! isComplete())
+ throw new IllegalMechanismStateException();
return this.engineUnwrap(incoming, offset, len);
}
public byte[] wrap(final byte[] outgoing, final int offset, final int len)
throws SaslException
{
- if (!isComplete())
- {
- throw new IllegalMechanismStateException();
- }
+ if (! isComplete())
+ throw new IllegalMechanismStateException();
return this.engineWrap(outgoing, offset, len);
}
@@ -145,58 +118,32 @@ public abstract class ClientMechanism implements SaslClient
public Object getNegotiatedProperty(final String propName)
{
- if (!isComplete())
- {
- throw new IllegalStateException();
- }
+ if (! isComplete())
+ throw new IllegalStateException();
if (Sasl.QOP.equals(propName))
- {
- return getNegotiatedQOP();
- }
+ return getNegotiatedQOP();
if (Sasl.STRENGTH.equals(propName))
- {
- return getNegotiatedStrength();
- }
+ return getNegotiatedStrength();
if (Sasl.SERVER_AUTH.equals(propName))
- {
- return getNegotiatedServerAuth();
- }
+ return getNegotiatedServerAuth();
if (Sasl.MAX_BUFFER.equals(propName))
- {
- return getNegotiatedMaxBuffer();
- }
+ return getNegotiatedMaxBuffer();
if (Sasl.RAW_SEND_SIZE.equals(propName))
- {
- return getNegotiatedRawSendSize();
- }
+ return getNegotiatedRawSendSize();
if (Sasl.POLICY_NOPLAINTEXT.equals(propName))
- {
- return getNegotiatedPolicyNoPlainText();
- }
+ return getNegotiatedPolicyNoPlainText();
if (Sasl.POLICY_NOACTIVE.equals(propName))
- {
- return getNegotiatedPolicyNoActive();
- }
+ return getNegotiatedPolicyNoActive();
if (Sasl.POLICY_NODICTIONARY.equals(propName))
- {
- return getNegotiatedPolicyNoDictionary();
- }
+ return getNegotiatedPolicyNoDictionary();
if (Sasl.POLICY_NOANONYMOUS.equals(propName))
- {
- return getNegotiatedPolicyNoAnonymous();
- }
+ return getNegotiatedPolicyNoAnonymous();
if (Sasl.POLICY_FORWARD_SECRECY.equals(propName))
- {
- return getNegotiatedPolicyForwardSecrecy();
- }
+ return getNegotiatedPolicyForwardSecrecy();
if (Sasl.POLICY_PASS_CREDENTIALS.equals(propName))
- {
- return getNegotiatedPolicyPassCredentials();
- }
+ return getNegotiatedPolicyPassCredentials();
if (Sasl.REUSE.equals(propName))
- {
- return getReuse();
- }
+ return getReuse();
return null;
}
@@ -204,8 +151,6 @@ public abstract class ClientMechanism implements SaslClient
{
}
- // other Instance methods --------------------------------------------------
-
public String getAuthorizationID()
{
return authorizationID;
@@ -288,30 +233,23 @@ public abstract class ClientMechanism implements SaslClient
}
/**
- * <p>Initialises the mechanism with designated attributes. Permissible names
- * and values are mechanism specific.</p>
- *
+ * Initialises the mechanism with designated attributes. Permissible names and
+ * values are mechanism specific.
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalMechanismStateException if the instance is already
- * initialised.
+ * initialised.
* @throws SaslException if an exception occurs during the process.
*/
public void init(final Map attributes) throws SaslException
{
if (state != -1)
- {
- throw new IllegalMechanismStateException("init()");
- }
-
+ throw new IllegalMechanismStateException("init()");
if (properties == null)
- {
- properties = new HashMap();
- }
+ properties = new HashMap();
else
- {
- properties.clear();
- }
+ properties.clear();
if (attributes != null)
{
authorizationID = (String) attributes.get(Registry.SASL_AUTHORISATION_ID);
@@ -322,35 +260,25 @@ public abstract class ClientMechanism implements SaslClient
properties.putAll(attributes);
}
else
- {
- handler = null;
- }
+ handler = null;
if (authorizationID == null)
- {
- authorizationID = "";
- }
+ authorizationID = "";
if (protocol == null)
- {
- protocol = "";
- }
+ protocol = "";
if (serverName == null)
- {
- serverName = "";
- }
+ serverName = "";
if (channelBinding == null)
- {
- channelBinding = new byte[0];
- }
+ channelBinding = new byte[0];
initMechanism();
complete = false;
state = 0;
}
/**
- * <p>Resets the mechanism instance for re-initialisation and use with other
- * characteristics.</p>
- *
+ * Resets the mechanism instance for re-initialisation and use with other
+ * characteristics.
+ *
* @throws SaslException if an exception occurs during the process.
*/
public void reset() throws SaslException
@@ -362,4 +290,4 @@ public abstract class ClientMechanism implements SaslClient
complete = false;
state = -1;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java b/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
index adfc06593f2..62b68572552 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
@@ -45,12 +45,12 @@ import javax.security.sasl.SaslException;
* exception is thrown to indicate that a violation has occured during the
* processing of a <i>confidentiality</i> protection filter.
*/
-public class ConfidentialityException extends SaslException
+public class ConfidentialityException
+ extends SaslException
{
-
/**
- * Constructs a new instance of <code>ConfidentialityException</code> with no
- * detail message.
+ * Constructs a new instance of <code>ConfidentialityException</code> with
+ * no detail message.
*/
public ConfidentialityException()
{
@@ -60,7 +60,7 @@ public class ConfidentialityException extends SaslException
/**
* Constructs a new instance of <code>ConfidentialityException</code> with
* the specified detail message.
- *
+ *
* @param s the detail message.
*/
public ConfidentialityException(String s)
@@ -71,7 +71,7 @@ public class ConfidentialityException extends SaslException
/**
* Constructs a new instance of <code>ConfidentialityException</code> with a
* detailed message and a root exception.
- *
+ *
* @param s possibly null additional detail about the exception.
* @param x a possibly null root exception that caused this one.
*/
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProvider.java b/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProvider.java
index 2b913a137b8..60c50d5d4df 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProvider.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProvider.java
@@ -47,71 +47,70 @@ import javax.security.sasl.AuthenticationException;
*/
public interface IAuthInfoProvider
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
* Activates (initialises) this provider instance. SHOULD be the first method
* invoked on the provider.
- *
+ *
* @param context a collection of name-value bindings describing the
- * activation context.
- * @throws AuthenticationException if an exception occurs during the operation.
+ * activation context.
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
void activate(Map context) throws AuthenticationException;
/**
* Passivates (releases) this provider instance. SHOULD be the last method
- * invoked on the provider. Once it is done, no other method may be invoked
- * on the same instance before it is <i>activated</i> agains.
- *
- * @throws AuthenticationException if an exception occurs during the operation.
+ * invoked on the provider. Once it is done, no other method may be invoked on
+ * the same instance before it is <i>activated</i> agains.
+ *
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
void passivate() throws AuthenticationException;
/**
* Checks if a user with a designated name is known to this provider.
- *
+ *
* @param userName the name of a user to check.
- * @return <code>true</code> if the user with the designated name is known to
- * this provider; <code>false</code> otherwise.
- * @throws AuthenticationException if an exception occurs during the operation.
+ * @return <code>true</code> if the user with the designated name is known
+ * to this provider; <code>false</code> otherwise.
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
boolean contains(String userName) throws AuthenticationException;
/**
* Returns a collection of information about a designated user. The contents
* of the returned map is provider-specific of name-to-value mappings.
- *
+ *
* @param userID a map of name-to-value bindings that fully describe a user.
* @return a collection of information about the designated user.
- * @throws AuthenticationException if an exception occurs during the operation.
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
Map lookup(Map userID) throws AuthenticationException;
/**
* Updates the credentials of a designated user.
- *
+ *
* @param userCredentials a map of name-to-value bindings that fully describe
- * a user, including per new credentials.
- * @throws AuthenticationException if an exception occurs during the operation.
+ * a user, including per new credentials.
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
void update(Map userCredentials) throws AuthenticationException;
/**
* A provider may operate in more than mode; e.g. SRP-II caters for user
- * credentials computed in more than one message digest algorithm. This
- * method returns the set of name-to-value bindings describing the mode of
- * the provider.
- *
+ * credentials computed in more than one message digest algorithm. This method
+ * returns the set of name-to-value bindings describing the mode of the
+ * provider.
+ *
* @param mode a unique identifier describing the operational mode.
* @return a collection of name-to-value bindings describing the designated
- * mode.
- * @throws AuthenticationException if an exception occurs during the operation.
+ * mode.
+ * @throws AuthenticationException if an exception occurs during the
+ * operation.
*/
Map getConfiguration(String mode) throws AuthenticationException;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java b/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java
index e630b8da14b..b6dc775d8a8 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/IAuthInfoProviderFactory.java
@@ -43,20 +43,13 @@ package gnu.javax.crypto.sasl;
*/
public interface IAuthInfoProviderFactory
{
-
- // Constants
- // -------------------------------------------------------------------------
-
- // Methods
- // -------------------------------------------------------------------------
-
/**
- * Returns an implementation of a provider for a designated mechanism
- * capable of honouring {@link IAuthInfoProvider} requests.
- *
+ * Returns an implementation of a provider for a designated mechanism capable
+ * of honouring {@link IAuthInfoProvider} requests.
+ *
* @param mechanism the unique name of a mechanism.
* @return an implementation of {@link IAuthInfoProvider} for that mechanism
- * or <code>null</code> if none found.
+ * or <code>null</code> if none found.
*/
IAuthInfoProvider getInstance(String mechanism);
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java b/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
index b46ad98e316..547ac41030d 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
@@ -47,9 +47,9 @@ import javax.security.sasl.AuthenticationException;
* invoked on incomplete mechanisms was invoked but the authentication phase of
* that mechanism was already completed.
*/
-public class IllegalMechanismStateException extends AuthenticationException
+public class IllegalMechanismStateException
+ extends AuthenticationException
{
-
/**
* Constructs a new instance of <code>IllegalMechanismStateException</code>
* with no detail message.
@@ -62,7 +62,7 @@ public class IllegalMechanismStateException extends AuthenticationException
/**
* Constructs a new instance of <code>IllegalMechanismStateException</code>
* with the specified detail message.
- *
+ *
* @param detail the detail message.
*/
public IllegalMechanismStateException(String detail)
@@ -73,7 +73,7 @@ public class IllegalMechanismStateException extends AuthenticationException
/**
* Constructs a new instance of <code>IllegalMechanismStateException</code>
* with the specified detail message, and cause.
- *
+ *
* @param detail the detail message.
* @param ex the original cause.
*/
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/InputBuffer.java b/libjava/classpath/gnu/javax/crypto/sasl/InputBuffer.java
index a64ea3e0e65..d676a595dc5 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/InputBuffer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/InputBuffer.java
@@ -45,39 +45,33 @@ import java.io.IOException;
import java.math.BigInteger;
/**
- * <p>The implementation of an incoming SASL buffer.</p>
- *
- * <p>The data elements this class caters for are described in [1].</p>
- *
- * <p>References:</p>
+ * The implementation of an incoming SASL buffer.
+ * <p>
+ * The data elements this class caters for are described in [1].
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
- * Secure Remote Password Authentication Mechanism</a>;<br/>
- * draft-burdis-cat-srp-sasl-09,<br/>
- * <a href="mailto:keith@rucus.ru.ac.za">Keith Burdis</a> and
- * <a href="mailto:raif@forge.com.au">Ra&iuml;f S. Naffah</a>.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
+ * Secure Remote Password Authentication Mechanism</a>;<br/>
+ * draft-burdis-cat-srp-sasl-09,<br/> <a
+ * href="mailto:keith@rucus.ru.ac.za">Keith Burdis</a> and <a
+ * href="mailto:raif@forge.com.au">Ra&iuml;f S. Naffah</a>.</li>
* </ol>
*/
public class InputBuffer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The internal buffer stream containing the buffer's contents. */
protected ByteArrayInputStream in;
-
/** The length of the buffer, according to its header. */
protected int length;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Constructs a SASL buffer given the buffer's encoded form, including its
- * header bytes.</p>
- *
- * @param frame the encoded form, including the header bytes, of a SASL buffer.
+ * Constructs a SASL buffer given the buffer's encoded form, including its
+ * header bytes.
+ *
+ * @param frame the encoded form, including the header bytes, of a SASL
+ * buffer.
* @throws SaslEncodingException if the buffer is malformed.
*/
public InputBuffer(byte[] frame) throws SaslEncodingException
@@ -85,17 +79,13 @@ public class InputBuffer
this();
if (frame.length < 4)
- {
- throw new SaslEncodingException("SASL buffer header too short");
- }
-
- length = (frame[0] & 0xFF) << 24 | (frame[1] & 0xFF) << 16
- | (frame[2] & 0xFF) << 8 | (frame[3] & 0xFF);
+ throw new SaslEncodingException("SASL buffer header too short");
+ length = (frame[0] & 0xFF) << 24
+ | (frame[1] & 0xFF) << 16
+ | (frame[2] & 0xFF) << 8
+ | (frame[3] & 0xFF);
if (length > Registry.SASL_BUFFER_MAX_LIMIT || length < 0)
- {
- throw new SaslEncodingException("SASL buffer size limit exceeded");
- }
-
+ throw new SaslEncodingException("SASL buffer size limit exceeded");
in = new ByteArrayInputStream(frame, 4, length);
}
@@ -105,16 +95,13 @@ public class InputBuffer
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a SASL buffer given the buffer's encoded contents,
- * excluding the buffer's header bytes.</p>
- *
- * <p>Calls the method with the same name and three arguments as:
+ * Returns an instance of a SASL buffer given the buffer's encoded contents,
+ * excluding the buffer's header bytes.
+ * <p>
+ * Calls the method with the same name and three arguments as:
* <code>getInstance(raw, 0, raw.length)</code>.
- *
+ *
* @param raw the encoded form, excluding the header bytes, of a SASL buffer.
* @return a new instance of {@link InputBuffer}.
*/
@@ -124,9 +111,9 @@ public class InputBuffer
}
/**
- * <p>Returns an instance of a SASL buffer given the buffer's encoded
- * contents, excluding the buffer's header bytes.</p>
- *
+ * Returns an instance of a SASL buffer given the buffer's encoded contents,
+ * excluding the buffer's header bytes.
+ *
* @param raw the encoded form, excluding the header bytes, of a SASL buffer.
* @param offset offset where to start using raw bytes from.
* @param len number of bytes to use.
@@ -140,21 +127,8 @@ public class InputBuffer
}
/**
- * <p>Converts four octets into the number that they represent.</p>
- *
- * @param b the four octets.
- * @return the length.
- */
- // public static int fourBytesToLength(byte[] b) throws SaslEncodingException {
- // int result = b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF);
- // if (result > Registry.SASL_FOUR_BYTE_MAX_LIMIT || result < 0) {
- // throw new SaslEncodingException("SASL EOS size limit exceeded");
- // }
- // return result;
- // }
- /**
- * <p>Converts two octets into the number that they represent.</p>
- *
+ * Converts two octets into the number that they represent.
+ *
* @param b the two octets.
* @return the length.
*/
@@ -162,49 +136,37 @@ public class InputBuffer
{
final int result = (b[0] & 0xFF) << 8 | (b[1] & 0xFF);
if (result > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException("SASL MPI/Text size limit exceeded");
- }
+ throw new SaslEncodingException("SASL MPI/Text size limit exceeded");
return result;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public boolean hasMoreElements()
{
return (in.available() > 0);
}
/**
- * <p>Decodes a SASL scalar quantity, <code>count</code>-octet long, from the
- * current buffer.</p>
- *
+ * Decodes a SASL scalar quantity, <code>count</code>-octet long, from the
+ * current buffer.
+ *
* @param count the number of octets of this scalar quantity.
- * @return a native representation of a SASL scalar (unsigned integer) quantity.
+ * @return a native representation of a SASL scalar (unsigned integer)
+ * quantity.
* @throws SaslEncodingException if an encoding exception occurs during the
- * operation.
+ * operation.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public long getScalar(int count) throws IOException
{
if (count < 0 || count > 4)
- {
- throw new SaslEncodingException("Invalid SASL scalar octet count: "
- + String.valueOf(count));
- }
- if (!hasMoreElements())
- {
- throw new SaslEncodingException(
- "Not enough bytes for a scalar in buffer");
- }
+ throw new SaslEncodingException("Invalid SASL scalar octet count: "
+ + String.valueOf(count));
+ if (! hasMoreElements())
+ throw new SaslEncodingException("Not enough bytes for a scalar in buffer");
if (in.available() < count)
- {
- throw new SaslEncodingException("Illegal SASL scalar encoding");
- }
+ throw new SaslEncodingException("Illegal SASL scalar encoding");
byte[] element = new byte[count];
in.read(element);
-
long result = 0L;
for (int i = 0; i < count; i++)
{
@@ -215,125 +177,96 @@ public class InputBuffer
}
/**
- * <p>Decodes a SASL OS from the current buffer.</p>
- *
+ * Decodes a SASL OS from the current buffer.
+ *
* @return a native representation of a SASL OS.
* @throws SaslEncodingException if an encoding exception occurs during the
- * operation.
+ * operation.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public byte[] getOS() throws IOException
{
- if (!hasMoreElements())
- {
- throw new SaslEncodingException(
- "Not enough bytes for an octet-sequence in buffer");
- }
+ if (! hasMoreElements())
+ throw new SaslEncodingException(
+ "Not enough bytes for an octet-sequence in buffer");
final int elementLength = in.read();
if (elementLength > Registry.SASL_ONE_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException(
- "SASL octet-sequence size limit exceeded");
- }
-
+ throw new SaslEncodingException("SASL octet-sequence size limit exceeded");
if (in.available() < elementLength)
- {
- throw new SaslEncodingException("Illegal SASL octet-sequence encoding");
- }
-
+ throw new SaslEncodingException("Illegal SASL octet-sequence encoding");
byte[] result = new byte[elementLength];
in.read(result);
-
return result;
}
/**
- * <p>Decodes a SASL EOS from the current buffer.</p>
- *
+ * Decodes a SASL EOS from the current buffer.
+ *
* @return a native representation of a SASL EOS.
* @throws SaslEncodingException if an encoding exception occurs during the
- * operation.
+ * operation.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public byte[] getEOS() throws IOException
{
if (in.available() < 2)
- {
- throw new SaslEncodingException(
- "Not enough bytes for an extended octet-sequence in buffer");
- }
-
+ throw new SaslEncodingException(
+ "Not enough bytes for an extended octet-sequence in buffer");
byte[] elementLengthBytes = new byte[2];
in.read(elementLengthBytes);
final int elementLength = twoBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
- {
- throw new SaslEncodingException(
- "Illegal SASL extended octet-sequence encoding");
- }
-
+ throw new SaslEncodingException(
+ "Illegal SASL extended octet-sequence encoding");
byte[] result = new byte[elementLength];
in.read(result);
-
return result;
}
/**
- * <p>Decodes a SASL MPI from the current buffer.</p>
- *
+ * Decodes a SASL MPI from the current buffer.
+ *
* @return a native representation of a SASL MPI.
* @throws SaslEncodingException if an encoding exception occurs during the
- * operation.
+ * operation.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public BigInteger getMPI() throws IOException
{
if (in.available() < 2)
- {
- throw new SaslEncodingException("Not enough bytes for an MPI in buffer");
- }
+ throw new SaslEncodingException("Not enough bytes for an MPI in buffer");
byte[] elementLengthBytes = new byte[2];
in.read(elementLengthBytes);
final int elementLength = twoBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
- {
- throw new SaslEncodingException(
- "Illegal SASL multi-precision integer encoding");
- }
-
+ throw new SaslEncodingException(
+ "Illegal SASL multi-precision integer encoding");
byte[] element = new byte[elementLength];
in.read(element);
-
return new BigInteger(1, element);
}
/**
- * <p>Decodes a SASL Text from the current buffer.</p>
- *
+ * Decodes a SASL Text from the current buffer.
+ *
* @return a native representation of a SASL Text.
* @throws SaslEncodingException if an encoding exception occurs during the
- * operation.
+ * operation.
* @throws SaslEncodingException if the UTF-8 character encoding is not
- * supported on this platform.
+ * supported on this platform.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public String getText() throws IOException
{
if (in.available() < 2)
- {
- throw new SaslEncodingException("Not enough bytes for a text in buffer");
- }
+ throw new SaslEncodingException("Not enough bytes for a text in buffer");
byte[] elementLengthBytes = new byte[2];
in.read(elementLengthBytes);
final int elementLength = twoBytesToLength(elementLengthBytes);
if (in.available() < elementLength)
- {
- throw new SaslEncodingException("Illegal SASL text encoding");
- }
-
+ throw new SaslEncodingException("Illegal SASL text encoding");
byte[] element = new byte[elementLength];
in.read(element);
-
return new String(element, "UTF8");
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/IntegrityException.java b/libjava/classpath/gnu/javax/crypto/sasl/IntegrityException.java
index 4a56ca2d564..9b793ce3e5e 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/IntegrityException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/IntegrityException.java
@@ -46,9 +46,9 @@ import javax.security.sasl.SaslException;
* processing of an <i>integrity</i> protection filter, including <i>replay
* detection</i>.
*/
-public class IntegrityException extends SaslException
+public class IntegrityException
+ extends SaslException
{
-
/**
* Constructs a new instance of <code>IntegrityException</code> with no
* detail message.
@@ -61,7 +61,7 @@ public class IntegrityException extends SaslException
/**
* Constructs a new instance of <code>IntegrityException</code> with the
* specified detail message.
- *
+ *
* @param s the detail message.
*/
public IntegrityException(String s)
@@ -72,7 +72,7 @@ public class IntegrityException extends SaslException
/**
* Constructs a new instance of <code>IntegrityException</code> with a
* detailed message and a root exception.
- *
+ *
* @param s possibly null additional detail about the exception.
* @param x a possibly null root exception that caused this one.
*/
@@ -80,4 +80,4 @@ public class IntegrityException extends SaslException
{
super(s, x);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/NoSuchMechanismException.java b/libjava/classpath/gnu/javax/crypto/sasl/NoSuchMechanismException.java
index 65432082a4e..5b16a788ccb 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/NoSuchMechanismException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/NoSuchMechanismException.java
@@ -44,19 +44,19 @@ import javax.security.sasl.SaslException;
* A checked exception thrown to indicate that a designated SASL mechanism
* implementation was not found.
*/
-public class NoSuchMechanismException extends SaslException
+public class NoSuchMechanismException
+ extends SaslException
{
-
/**
* Constructs a <code>NoSuchMechanismException</code> with the specified
* detail message. In the case of this exception, the detail message
* designates the offending mechanism name.
- *
+ *
* @param arg the detail message, which in this case is the offending
- * mechanism name.
+ * mechanism name.
*/
public NoSuchMechanismException(String arg)
{
super(arg);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/NoSuchUserException.java b/libjava/classpath/gnu/javax/crypto/sasl/NoSuchUserException.java
index fe362c74261..387339f6009 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/NoSuchUserException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/NoSuchUserException.java
@@ -44,9 +44,9 @@ import javax.security.sasl.AuthenticationException;
* A checked exception thrown to indicate that a designated user is unknown to
* the authentication layer.
*/
-public class NoSuchUserException extends AuthenticationException
+public class NoSuchUserException
+ extends AuthenticationException
{
-
/** Constructs a <code>NoSuchUserException</code> with no detail message. */
public NoSuchUserException()
{
@@ -55,9 +55,9 @@ public class NoSuchUserException extends AuthenticationException
/**
* Constructs a <code>NoSuchUserException</code> with the specified detail
- * message. In the case of this exception, the detail message designates
- * the offending username.
- *
+ * message. In the case of this exception, the detail message designates the
+ * offending username.
+ *
* @param arg the detail message, which in this case is the username.
*/
public NoSuchUserException(String arg)
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/OutputBuffer.java b/libjava/classpath/gnu/javax/crypto/sasl/OutputBuffer.java
index d219e7e9f0e..92e34dfbfe7 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/OutputBuffer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/OutputBuffer.java
@@ -46,31 +46,25 @@ import java.io.IOException;
import java.math.BigInteger;
/**
- * <p>The implementation of an outgoing SASL buffer.</p>
- *
- * <p>The data elements this class caters for are described in [1].</p>
- *
- * <p>References:</p>
+ * The implementation of an outgoing SASL buffer.
+ * <p>
+ * The data elements this class caters for are described in [1].
+ * <p>
+ * References:
* <ol>
- * <li><a href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
- * Secure Remote Password Authentication Mechanism</a>;<br/>
- * draft-burdis-cat-srp-sasl-09,<br/>
- * <a href="mailto:keith@rucus.ru.ac.za">Keith Burdis</a> and
- * <a href="mailto:raif@forge.com.au">Ra&iuml;f S. Naffah</a>.</li>
+ * <li><a
+ * href="http://www.ietf.org/internet-drafts/draft-burdis-cat-srp-sasl-09.txt">
+ * Secure Remote Password Authentication Mechanism</a>;<br/>
+ * draft-burdis-cat-srp-sasl-09,<br/> <a
+ * href="mailto:keith@rucus.ru.ac.za">Keith Burdis</a> and <a
+ * href="mailto:raif@forge.com.au">Ra&iuml;f S. Naffah</a>.</li>
* </ol>
*/
public class OutputBuffer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The internal output stream. */
private ByteArrayOutputStream out;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public OutputBuffer()
{
super();
@@ -78,16 +72,10 @@ public class OutputBuffer
out = new ByteArrayOutputStream();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Encodes a SASL scalar quantity, <code>count</code>-octet long, to the
- * current buffer.</p>
- *
+ * Encodes a SASL scalar quantity, <code>count</code>-octet long, to the
+ * current buffer.
+ *
* @param count number of octets to encode <code>b</code> with.
* @param b the scalar quantity.
* @throws SaslEncodingException if an encoding size constraint is violated.
@@ -96,21 +84,17 @@ public class OutputBuffer
public void setScalar(int count, int b) throws IOException
{
if (count < 0 || count > 4)
- {
- throw new SaslEncodingException("Invalid SASL scalar octet count: "
- + String.valueOf(count));
- }
+ throw new SaslEncodingException("Invalid SASL scalar octet count: "
+ + String.valueOf(count));
byte[] element = new byte[count];
for (int i = count; --i >= 0; b >>>= 8)
- {
- element[i] = (byte) b;
- }
+ element[i] = (byte) b;
out.write(element);
}
/**
- * <p>Encodes a SASL OS to the current buffer.</p>
- *
+ * Encodes a SASL OS to the current buffer.
+ *
* @param b the OS element.
* @throws SaslEncodingException if an encoding size constraint is violated.
* @throws IOException if any other I/O exception occurs during the operation.
@@ -119,16 +103,14 @@ public class OutputBuffer
{
final int length = b.length;
if (length > Registry.SASL_ONE_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException("SASL octet-sequence too long");
- }
+ throw new SaslEncodingException("SASL octet-sequence too long");
out.write(length & 0xFF);
out.write(b);
}
/**
- * <p>Encodes a SASL EOS to the current buffer.</p>
- *
+ * Encodes a SASL EOS to the current buffer.
+ *
* @param b the EOS element.
* @throws SaslEncodingException if an encoding size constraint is violated.
* @throws IOException if any other I/O exception occurs during the operation.
@@ -137,17 +119,15 @@ public class OutputBuffer
{
final int length = b.length;
if (length > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException("SASL extended octet-sequence too long");
- }
- byte[] lengthBytes = { (byte) (length >>> 8), (byte) length };
+ throw new SaslEncodingException("SASL extended octet-sequence too long");
+ byte[] lengthBytes = { (byte)(length >>> 8), (byte) length };
out.write(lengthBytes);
out.write(b);
}
/**
- * <p>Encodes a SASL MPI to the current buffer.</p>
- *
+ * Encodes a SASL MPI to the current buffer.
+ *
* @param val the MPI element.
* @throws SaslEncodingException if an encoding size constraint is violated.
* @throws IOException if any other I/O exception occurs during the operation.
@@ -157,21 +137,19 @@ public class OutputBuffer
byte[] b = Util.trim(val);
final int length = b.length;
if (length > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException("SASL multi-precision integer too long");
- }
- byte[] lengthBytes = { (byte) (length >>> 8), (byte) length };
+ throw new SaslEncodingException("SASL multi-precision integer too long");
+ byte[] lengthBytes = { (byte)(length >>> 8), (byte) length };
out.write(lengthBytes);
out.write(b);
}
/**
- * <p>Encodes a SASL Text to the current buffer.</p>
- *
+ * Encodes a SASL Text to the current buffer.
+ *
* @param str the Text element.
* @throws SaslEncodingException if an encoding size constraint is violated.
* @throws SaslEncodingException if the UTF-8 encoding is not supported on
- * this platform.
+ * this platform.
* @throws IOException if any other I/O exception occurs during the operation.
*/
public void setText(String str) throws IOException
@@ -179,18 +157,16 @@ public class OutputBuffer
byte[] b = str.getBytes("UTF8");
final int length = b.length;
if (length > Registry.SASL_TWO_BYTE_MAX_LIMIT)
- {
- throw new SaslEncodingException("SASL text too long");
- }
- byte[] lengthBytes = { (byte) (length >>> 8), (byte) length };
+ throw new SaslEncodingException("SASL text too long");
+ byte[] lengthBytes = { (byte)(length >>> 8), (byte) length };
out.write(lengthBytes);
out.write(b);
}
/**
- * <p>Returns the encoded form of the current buffer including the 4-byte
- * length header.</p>
- *
+ * Returns the encoded form of the current buffer including the 4-byte length
+ * header.
+ *
* @throws SaslEncodingException if an encoding size constraint is violated.
*/
public byte[] encode() throws SaslEncodingException
@@ -198,28 +174,25 @@ public class OutputBuffer
byte[] buffer = wrap();
final int length = buffer.length;
byte[] result = new byte[length + 4];
- result[0] = (byte) (length >>> 24);
- result[1] = (byte) (length >>> 16);
- result[2] = (byte) (length >>> 8);
+ result[0] = (byte)(length >>> 24);
+ result[1] = (byte)(length >>> 16);
+ result[2] = (byte)(length >>> 8);
result[3] = (byte) length;
System.arraycopy(buffer, 0, result, 4, length);
-
return result;
}
/**
- * <p>Returns the encoded form of the current buffer excluding the 4-byte
- * length header.</p>
- *
+ * Returns the encoded form of the current buffer excluding the 4-byte length
+ * header.
+ *
* @throws SaslEncodingException if an encoding size constraint is violated.
*/
public byte[] wrap() throws SaslEncodingException
{
final int length = out.size();
if (length > Registry.SASL_BUFFER_MAX_LIMIT || length < 0)
- {
- throw new SaslEncodingException("SASL buffer too long");
- }
+ throw new SaslEncodingException("SASL buffer too long");
return out.toByteArray();
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/SaslEncodingException.java b/libjava/classpath/gnu/javax/crypto/sasl/SaslEncodingException.java
index 9f4c59f1c2b..f6a74641dd2 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/SaslEncodingException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/SaslEncodingException.java
@@ -44,9 +44,9 @@ import javax.security.sasl.SaslException;
* A checked exception, thrown when an exception occurs while decoding a SASL
* buffer and/or a SASL data element from/to a buffer.
*/
-public class SaslEncodingException extends SaslException
+public class SaslEncodingException
+ extends SaslException
{
-
/** Constructs a <code>SaslEncodingException</code> with no detail message. */
public SaslEncodingException()
{
@@ -56,11 +56,11 @@ public class SaslEncodingException extends SaslException
/**
* Constructs a <code>SaslEncodingException</code> with the specified detail
* message.
- *
+ *
* @param s the detail message.
*/
public SaslEncodingException(String s)
{
super(s);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/SaslInputStream.java b/libjava/classpath/gnu/javax/crypto/sasl/SaslInputStream.java
index 57eb2b5c52d..d127bf5ba22 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/SaslInputStream.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/SaslInputStream.java
@@ -38,12 +38,13 @@ exception statement from your version. */
package gnu.javax.crypto.sasl;
+import gnu.java.security.Configuration;
import gnu.java.security.util.Util;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
-import java.io.IOException;
-import java.io.PrintWriter;
+import java.util.logging.Logger;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
@@ -53,55 +54,24 @@ import javax.security.sasl.SaslServer;
* An input stream that uses either a {@link SaslClient} or a {@link SaslServer}
* to process the data through these entities' security layer filter(s).
*/
-public class SaslInputStream extends InputStream
+public class SaslInputStream
+ extends InputStream
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "SaslOutputStream";
-
- private static final String ERROR = "ERROR";
-
- private static final String WARN = " WARN";
-
- // private static final String INFO = " INFO";
- private static final String TRACE = "DEBUG";
-
- private static final boolean DEBUG = true;
-
- private static final int debuglevel = 3;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String level, Object obj)
- {
- err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(SaslInputStream.class.getName());
private SaslClient client;
-
private SaslServer server;
-
private int maxRawSendSize;
-
private InputStream source;
-
private byte[] internalBuf;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public SaslInputStream(SaslClient client, InputStream source)
throws IOException
{
super();
this.client = client;
- maxRawSendSize = Integer.parseInt((String) client.getNegotiatedProperty(Sasl.RAW_SEND_SIZE));
+ String size = (String) client.getNegotiatedProperty(Sasl.RAW_SEND_SIZE);
+ maxRawSendSize = Integer.parseInt(size);
server = null;
this.source = source;
}
@@ -112,19 +82,12 @@ public class SaslInputStream extends InputStream
super();
this.server = server;
- maxRawSendSize = Integer.parseInt((String) server.getNegotiatedProperty(Sasl.RAW_SEND_SIZE));
+ String size = (String) server.getNegotiatedProperty(Sasl.RAW_SEND_SIZE);
+ maxRawSendSize = Integer.parseInt(size);
client = null;
this.source = source;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Overloaded java.io.InputStream methods ----------------------------------
-
public int available() throws IOException
{
return (internalBuf == null) ? 0 : internalBuf.length;
@@ -136,25 +99,25 @@ public class SaslInputStream extends InputStream
}
/**
- * <p>Reads the next byte of data from the input stream. The value byte is
+ * Reads the next byte of data from the input stream. The value byte is
* returned as an <code>int</code> in the range <code>0</code> to
* <code>255</code>. If no byte is available because the end of the stream
* has been reached, the value <code>-1</code> is returned. This method
- * blocks until input data is available, the end of the stream is detected,
- * or an exception is thrown.</p>
- *
- * <p>From a SASL mechanism provider's perspective, if a security layer has
- * been negotiated, the underlying <i>source</i> is expected to contain SASL
+ * blocks until input data is available, the end of the stream is detected, or
+ * an exception is thrown.
+ * <p>
+ * From a SASL mechanism provider's perspective, if a security layer has been
+ * negotiated, the underlying <i>source</i> is expected to contain SASL
* buffers, as defined in RFC 2222. Four octets in network byte order in the
* front of each buffer identify the length of the buffer. The provider is
* responsible for performing any integrity checking or other processing on
* the buffer before returning the data as a stream of octets. For example,
* the protocol driver's request for a single octet from the stream might;
* i.e. an invocation of this method, may result in an entire SASL buffer
- * being read and processed before that single octet can be returned.</p>
- *
- * @return the next byte of data, or <code>-1</code> if the end of the stream
- * is reached.
+ * being read and processed before that single octet can be returned.
+ *
+ * @return the next byte of data, or <code>-1</code> if the end of the
+ * stream is reached.
* @throws IOException if an I/O error occurs.
*/
public int read() throws IOException
@@ -168,7 +131,6 @@ public class SaslInputStream extends InputStream
else
{
byte[] tmp = new byte[internalBuf.length - 1];
- // System.arraycopy(internalBuf, 0, tmp, 0, tmp.length);
System.arraycopy(internalBuf, 1, tmp, 0, tmp.length);
internalBuf = tmp;
}
@@ -179,94 +141,83 @@ public class SaslInputStream extends InputStream
int check = read(buf);
result = (check > 0) ? (buf[0] & 0xFF) : -1;
}
-
return result;
}
/**
- * <p>Reads up to <code>len</code> bytes of data from the underlying
- * <i>source</i> input stream into an array of bytes. An attempt is made to
- * read as many as <code>len</code> bytes, but a smaller number may be read,
- * possibly zero. The number of bytes actually read is returned as an
- * integer.</p>
- *
- * <p>This method blocks until input data is available, end of file is
- * detected, or an exception is thrown.</p>
- *
- * <p>If <code>b</code> is <code>null</code>, a {@link NullPointerException} is
- * thrown.</p>
- *
- * <p>If <code>off</code> is negative, or <code>len</code> is negative, or
- * <code>off+len</code> is greater than the length of the array <code>b</code>,
- * then an {@link IndexOutOfBoundsException} is thrown.</p>
- *
- * <p>If <code>len</code> is zero, then no bytes are read and <code>0</code>
+ * Reads up to <code>len</code> bytes of data from the underlying <i>source</i>
+ * input stream into an array of bytes. An attempt is made to read as many as
+ * <code>len</code> bytes, but a smaller number may be read, possibly zero.
+ * The number of bytes actually read is returned as an integer.
+ * <p>
+ * This method blocks until input data is available, end of file is detected,
+ * or an exception is thrown.
+ * <p>
+ * If <code>b</code> is <code>null</code>, a {@link NullPointerException}
+ * is thrown.
+ * <p>
+ * If <code>off</code> is negative, or <code>len</code> is negative, or
+ * <code>off+len</code> is greater than the length of the array
+ * <code>b</code>, then an {@link IndexOutOfBoundsException} is thrown.
+ * <p>
+ * If <code>len</code> is zero, then no bytes are read and <code>0</code>
* is returned; otherwise, there is an attempt to read at least one byte. If
* no byte is available because the stream is at end of file, the value
* <code>-1</code> is returned; otherwise, at least one byte is read and
- * stored into <code>b</code>.</p>
- *
- * <p>The first byte read is stored into element <code>b[off]</code>, the
- * next one into <code>b[off+1]</code>, and so on. The number of bytes read
- * is, at most, equal to <code>len</code>. Let <code>k</code> be the number
+ * stored into <code>b</code>.
+ * <p>
+ * The first byte read is stored into element <code>b[off]</code>, the next
+ * one into <code>b[off+1]</code>, and so on. The number of bytes read is,
+ * at most, equal to <code>len</code>. Let <code>k</code> be the number
* of bytes actually read; these bytes will be stored in elements
* <code>b[off]</code> through <code>b[off+k-1]</code>, leaving elements
- * <code>b[off+k]</code> through <code>b[off+len-1]</code> unaffected.</p>
- *
- * <p>In every case, elements <code>b[0]</code> through <code>b[off]</code>
+ * <code>b[off+k]</code> through <code>b[off+len-1]</code> unaffected.
+ * <p>
+ * In every case, elements <code>b[0]</code> through <code>b[off]</code>
* and elements <code>b[off+len]</code> through <code>b[b.length-1]</code>
- * are unaffected.</p>
- *
- * <p>If the first byte cannot be read for any reason other than end of file,
- * then an {@link IOException} is thrown. In particular, an {@link IOException}
- * is thrown if the input stream has been closed.</p>
- *
- * <p>From the SASL mechanism provider's perspective, if a security layer has
+ * are unaffected.
+ * <p>
+ * If the first byte cannot be read for any reason other than end of file,
+ * then an {@link IOException} is thrown. In particular, an
+ * {@link IOException} is thrown if the input stream has been closed.
+ * <p>
+ * From the SASL mechanism provider's perspective, if a security layer has
* been negotiated, the underlying <i>source</i> is expected to contain SASL
* buffers, as defined in RFC 2222. Four octets in network byte order in the
* front of each buffer identify the length of the buffer. The provider is
* responsible for performing any integrity checking or other processing on
* the buffer before returning the data as a stream of octets. The protocol
* driver's request for a single octet from the stream might result in an
- * entire SASL buffer being read and processed before that single octet can
- * be returned.</p>
- *
+ * entire SASL buffer being read and processed before that single octet can be
+ * returned.
+ *
* @param b the buffer into which the data is read.
* @param off the start offset in array <code>b</code> at which the data is
- * wricodeen.
+ * wricodeen.
* @param len the maximum number of bytes to read.
* @return the total number of bytes read into the buffer, or <code>-1</code>
- * if there is no more data because the end of the stream has been reached.
+ * if there is no more data because the end of the stream has been
+ * reached.
* @throws IOException if an I/O error occurs.
*/
public int read(byte[] b, int off, int len) throws IOException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> read(b, " + String.valueOf(off) + ", "
- + String.valueOf(len) + ")");
-
- if (b == null)
- {
- throw new NullPointerException("b");
- }
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "read", new Object[] {
+ b, Integer.valueOf(off), Integer.valueOf(len)
+ });
if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
|| ((off + len) < 0))
- {
- throw new IndexOutOfBoundsException("off=" + String.valueOf(off)
- + ", len=" + String.valueOf(len)
- + ", b.length="
- + String.valueOf(b.length));
- }
+ throw new IndexOutOfBoundsException("off=" + off + ", len=" + len
+ + ", b.length=" + b.length);
if (len == 0)
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== read() --> 0");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "read", Integer.valueOf(0));
return 0;
}
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Available: " + String.valueOf(available()));
-
+ if (Configuration.DEBUG)
+ log.finer("Available: " + available());
int result = 0;
if (internalBuf == null || internalBuf.length < 1)
try
@@ -274,24 +225,26 @@ public class SaslInputStream extends InputStream
internalBuf = readSaslBuffer();
if (internalBuf == null)
{
- if (DEBUG && debuglevel > 4)
- debug(WARN, "Underlying stream empty. Returning -1");
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== read() --> -1");
+ if (Configuration.DEBUG)
+ {
+ log.finer("Underlying stream empty. Returning -1");
+ log.exiting(this.getClass().getName(), "read",
+ Integer.valueOf(-1));
+ }
return -1;
}
}
catch (InterruptedIOException x)
{
- if (DEBUG && debuglevel > 6)
- debug(TRACE, x);
- if (DEBUG && debuglevel > 4)
- debug(WARN, "Reading thread was interrupted. Returning -1");
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== read() --> -1");
+ if (Configuration.DEBUG)
+ {
+ log.finer("Reading thread was interrupted. Returning -1");
+ log.throwing(this.getClass().getName(), "read", x);
+ log.exiting(this.getClass().getName(), "read",
+ Integer.valueOf(-1));
+ }
return -1;
}
-
if (len <= internalBuf.length)
{
result = len;
@@ -311,10 +264,8 @@ public class SaslInputStream extends InputStream
result = internalBuf.length;
System.arraycopy(internalBuf, 0, b, off, result);
internalBuf = null;
-
off += result;
len -= result;
-
int remaining; // count of bytes remaining in buffer after an iteration
int delta; // count of bytes moved to b after an iteration
int datalen;
@@ -328,13 +279,11 @@ public class SaslInputStream extends InputStream
data = readSaslBuffer();
if (data == null)
{
- if (DEBUG && debuglevel > 4)
- debug(WARN, "Underlying stream exhausted. Breaking...");
+ if (Configuration.DEBUG)
+ log.finer("Underlying stream exhausted. Breaking...");
break;
}
-
datalen = data.length;
-
// copy [part of] the result to b
remaining = (datalen <= len) ? 0 : datalen - len;
delta = datalen - remaining;
@@ -344,7 +293,6 @@ public class SaslInputStream extends InputStream
internalBuf = new byte[remaining];
System.arraycopy(data, delta, internalBuf, 0, remaining);
}
-
// update off, result and len
off += delta;
result += delta;
@@ -352,36 +300,32 @@ public class SaslInputStream extends InputStream
}
else
{ // nothing much we can do except return what we have
- if (DEBUG && debuglevel > 4)
- debug(WARN,
- "Not enough bytes in source to read a buffer. Breaking...");
+ if (Configuration.DEBUG)
+ log.finer("Not enough bytes in source to read a buffer. Breaking...");
break;
}
}
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Remaining: "
- + (internalBuf == null ? 0 : internalBuf.length));
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== read() --> " + String.valueOf(result));
+ if (Configuration.DEBUG)
+ {
+ log.finer("Remaining: "
+ + (internalBuf == null ? 0 : internalBuf.length));
+ log.exiting(this.getClass().getName(), "read()", String.valueOf(result));
+ }
return result;
}
- // other nstance methods ---------------------------------------------------
-
/**
* Reads a SASL buffer from the underlying source if at least 4 bytes are
* available.
- *
+ *
* @return the byte[] of decoded buffer contents, or null if the underlying
- * source was exhausted.
+ * source was exhausted.
* @throws IOException if an I/O exception occurs during the operation.
*/
private byte[] readSaslBuffer() throws IOException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> readSaslBuffer()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "readSaslBuffer()");
int realLength; // check if we read as many bytes as we're supposed to
byte[] result = new byte[4];
try
@@ -389,32 +333,27 @@ public class SaslInputStream extends InputStream
realLength = source.read(result);
if (realLength == -1)
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== readSaslBuffer() --> null");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "readSaslBuffer");
return null;
}
}
catch (IOException x)
{
- if (DEBUG && debuglevel > 0)
- debug(ERROR, x);
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "readSaslBuffer", x);
throw x;
}
-
if (realLength != 4)
- {
- throw new IOException("Was expecting 4 but found "
- + String.valueOf(realLength));
- }
- int bufferLength = result[0] << 24 | (result[1] & 0xFF) << 16
- | (result[2] & 0xFF) << 8 | (result[3] & 0xFF);
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "SASL buffer size: " + bufferLength);
+ throw new IOException("Was expecting 4 but found " + realLength);
+ int bufferLength = result[0] << 24
+ | (result[1] & 0xFF) << 16
+ | (result[2] & 0xFF) << 8
+ | (result[3] & 0xFF);
+ if (Configuration.DEBUG)
+ log.finer("SASL buffer size: " + bufferLength);
if (bufferLength > maxRawSendSize || bufferLength < 0)
- {
- throw new SaslEncodingException("SASL buffer (security layer) too long");
- }
+ throw new SaslEncodingException("SASL buffer (security layer) too long");
result = new byte[bufferLength];
try
@@ -423,37 +362,32 @@ public class SaslInputStream extends InputStream
}
catch (IOException x)
{
- if (DEBUG && debuglevel > 0)
- debug(ERROR, x);
+ if (Configuration.DEBUG)
+ log.throwing(this.getClass().getName(), "readSaslBuffer", x);
throw x;
}
-
if (realLength != bufferLength)
- throw new IOException("Was expecting " + String.valueOf(bufferLength)
- + " but found " + String.valueOf(realLength));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (before security) (hex): "
- + Util.dumpString(result));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (before security) (str): \""
- + new String(result) + "\"");
-
- if (client != null)
+ throw new IOException("Was expecting " + bufferLength + " but found "
+ + realLength);
+ if (Configuration.DEBUG)
{
- result = client.unwrap(result, 0, realLength);
+ log.finer("Incoming buffer (before security) (hex): "
+ + Util.dumpString(result));
+ log.finer("Incoming buffer (before security) (str): \""
+ + new String(result) + "\"");
}
+ if (client != null)
+ result = client.unwrap(result, 0, realLength);
else
+ result = server.unwrap(result, 0, realLength);
+ if (Configuration.DEBUG)
{
- result = server.unwrap(result, 0, realLength);
+ log.finer("Incoming buffer (after security) (hex): "
+ + Util.dumpString(result));
+ log.finer("Incoming buffer (after security) (str): \""
+ + new String(result) + "\"");
+ log.exiting(this.getClass().getName(), "readSaslBuffer");
}
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (after security) (hex): "
- + Util.dumpString(result));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (after security) (str): \""
- + new String(result) + "\"");
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== readSaslBuffer()");
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java b/libjava/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java
index 6997201377a..d21f1f37ae2 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java
@@ -38,11 +38,12 @@ exception statement from your version. */
package gnu.javax.crypto.sasl;
+import gnu.java.security.Configuration;
import gnu.java.security.util.Util;
-import java.io.OutputStream;
import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.util.logging.Logger;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
@@ -52,51 +53,23 @@ import javax.security.sasl.SaslServer;
* An output stream that uses either a {@link SaslClient} or a {@link SaslServer}
* to process the data through these entities' security layer filter(s).
*/
-public class SaslOutputStream extends OutputStream
+public class SaslOutputStream
+ extends OutputStream
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "SaslOutputStream";
-
- // private static final String ERROR = "ERROR";
- // private static final String WARN = " WARN";
- // private static final String INFO = " INFO";
- private static final String TRACE = "DEBUG";
-
- private static final boolean DEBUG = true;
-
- private static final int debuglevel = 3;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(String level, Object obj)
- {
- err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(SaslOutputStream.class.getName());
private SaslClient client;
-
private SaslServer server;
-
private int maxRawSendSize;
-
private OutputStream dest;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public SaslOutputStream(SaslClient client, OutputStream dest)
throws IOException
{
super();
this.client = client;
- maxRawSendSize = Integer.parseInt((String) client.getNegotiatedProperty(Sasl.RAW_SEND_SIZE));
+ String size = (String) client.getNegotiatedProperty(Sasl.RAW_SEND_SIZE);
+ maxRawSendSize = Integer.parseInt(size);
server = null;
this.dest = dest;
}
@@ -107,17 +80,12 @@ public class SaslOutputStream extends OutputStream
super();
this.server = server;
- maxRawSendSize = Integer.parseInt((String) server.getNegotiatedProperty(Sasl.RAW_SEND_SIZE));
+ String size = (String) server.getNegotiatedProperty(Sasl.RAW_SEND_SIZE);
+ maxRawSendSize = Integer.parseInt(size);
client = null;
this.dest = dest;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Overloaded java.io.OutputStream methods
- // -------------------------------------------------------------------------
-
public void close() throws IOException
{
dest.flush();
@@ -148,71 +116,60 @@ public class SaslOutputStream extends OutputStream
*/
public void write(byte[] b, int off, int len) throws IOException
{
- if (b == null)
- {
- throw new NullPointerException("b");
- }
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "write");
if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
|| ((off + len) < 0))
- {
- throw new IndexOutOfBoundsException("off=" + String.valueOf(off)
- + ", len=" + String.valueOf(len)
- + ", b.length="
- + String.valueOf(b.length));
- }
+ throw new IndexOutOfBoundsException("off=" + off + ", len=" + len
+ + ", b.length=" + b.length);
if (len == 0)
{
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "write");
return;
}
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> write()");
-
int chunckSize, length, chunck = 1;
byte[] output = null, result;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "About to wrap " + String.valueOf(len) + " byte(s)...");
+ if (Configuration.DEBUG)
+ log.finer("About to wrap " + len + " byte(s)...");
while (len > 0)
{
chunckSize = (len > maxRawSendSize ? maxRawSendSize : len);
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (before security) (hex): "
- + Util.dumpString(b, off, chunckSize));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (before security) (str): \""
- + new String(b, off, chunckSize) + "\"");
-
+ if (Configuration.DEBUG)
+ {
+ log.finer("Outgoing buffer (before security) (hex): "
+ + Util.dumpString(b, off, chunckSize));
+ log.finer("Outgoing buffer (before security) (str): \""
+ + new String(b, off, chunckSize) + "\"");
+ }
if (client != null)
output = client.wrap(b, off, chunckSize);
else
output = server.wrap(b, off, chunckSize);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (after security) (hex): "
- + Util.dumpString(output));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (after security) (str): \""
- + new String(output) + "\"");
-
+ if (Configuration.DEBUG)
+ {
+ log.finer("Outgoing buffer (after security) (hex): "
+ + Util.dumpString(output));
+ log.finer("Outgoing buffer (after security) (str): \""
+ + new String(output) + "\"");
+ }
length = output.length;
result = new byte[length + 4];
- result[0] = (byte) (length >>> 24);
- result[1] = (byte) (length >>> 16);
- result[2] = (byte) (length >>> 8);
+ result[0] = (byte)(length >>> 24);
+ result[1] = (byte)(length >>> 16);
+ result[2] = (byte)(length >>> 8);
result[3] = (byte) length;
System.arraycopy(output, 0, result, 4, length);
-
dest.write(result);
-
off += chunckSize;
len -= chunckSize;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Wrapped chunck #" + String.valueOf(chunck));
+ if (Configuration.DEBUG)
+ log.finer("Wrapped chunck #" + chunck);
chunck++;
}
-
dest.flush();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== write()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "write");
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/SaslUtil.java b/libjava/classpath/gnu/javax/crypto/sasl/SaslUtil.java
index e70312c0d4d..4b0b697fe79 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/SaslUtil.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/SaslUtil.java
@@ -40,7 +40,6 @@ package gnu.javax.crypto.sasl;
import gnu.java.security.util.Util;
-import java.math.BigInteger;
import java.security.MessageDigest;
/**
@@ -48,30 +47,17 @@ import java.security.MessageDigest;
*/
public class SaslUtil
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
private SaslUtil()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
public static final boolean validEmailAddress(String address)
{
// need to do better than this
return (address.indexOf("@") != -1);
}
- // Visualisation methods
- // -------------------------------------------------------------------------
-
/** Returns the context of the designated hash as a string. */
public static final String dump(MessageDigest md)
{
@@ -86,4 +72,4 @@ public class SaslUtil
}
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ServerFactory.java b/libjava/classpath/gnu/javax/crypto/sasl/ServerFactory.java
index e9b08dbd49a..7aa37962845 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ServerFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ServerFactory.java
@@ -62,53 +62,33 @@ import javax.security.sasl.SaslServerFactory;
/**
* The implementation of the {@link SaslServerFactory}.
*/
-public class ServerFactory implements SaslServerFactory
+public class ServerFactory
+ implements SaslServerFactory
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-arguments constructor
- // Class methods
- // -------------------------------------------------------------------------
-
public static final Set getNames()
{
- return Collections.unmodifiableSet(new HashSet(
- Arrays.asList(getNamesInternal(null))));
+ return Collections.unmodifiableSet(new HashSet(Arrays.asList(getNamesInternal(null))));
}
private static final String[] getNamesInternal(Map props)
{
- String[] all = new String[] { Registry.SASL_SRP_MECHANISM,
- Registry.SASL_CRAM_MD5_MECHANISM,
- Registry.SASL_PLAIN_MECHANISM,
- Registry.SASL_ANONYMOUS_MECHANISM };
-
+ String[] all = new String[] {
+ Registry.SASL_SRP_MECHANISM,
+ Registry.SASL_CRAM_MD5_MECHANISM,
+ Registry.SASL_PLAIN_MECHANISM,
+ Registry.SASL_ANONYMOUS_MECHANISM };
List result = new ArrayList(4);
int i;
for (i = 0; i < all.length;)
- {
- result.add(all[i++]);
- }
-
+ result.add(all[i++]);
if (props == null)
- {
- return (String[]) result.toArray(new String[0]); // all
- }
- if (hasPolicy(Sasl.POLICY_PASS_CREDENTIALS, props))
- { // none
- return new String[0];
- }
-
+ return (String[]) result.toArray(new String[0]); // all
+ if (hasPolicy(Sasl.POLICY_PASS_CREDENTIALS, props)) // none
+ return new String[0];
if (hasPolicy(Sasl.POLICY_NOPLAINTEXT, props))
- {
- result.remove(Registry.SASL_PLAIN_MECHANISM);
- }
+ result.remove(Registry.SASL_PLAIN_MECHANISM);
if (hasPolicy(Sasl.POLICY_NOACTIVE, props))
{
result.remove(Registry.SASL_CRAM_MD5_MECHANISM);
@@ -135,32 +115,19 @@ public class ServerFactory implements SaslServerFactory
public static final ServerMechanism getInstance(String mechanism)
{
if (mechanism == null)
- {
- return null;
- }
+ return null;
mechanism = mechanism.trim().toUpperCase();
if (mechanism.equals(Registry.SASL_SRP_MECHANISM))
- {
- return new SRPServer();
- }
+ return new SRPServer();
if (mechanism.equals(Registry.SASL_CRAM_MD5_MECHANISM))
- {
- return new CramMD5Server();
- }
+ return new CramMD5Server();
if (mechanism.equals(Registry.SASL_PLAIN_MECHANISM))
- {
- return new PlainServer();
- }
+ return new PlainServer();
if (mechanism.equals(Registry.SASL_ANONYMOUS_MECHANISM))
- {
- return new AnonymousServer();
- }
+ return new AnonymousServer();
return null;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
public SaslServer createSaslServer(String mechanism, String protocol,
String serverName, Map props,
CallbackHandler cbh) throws SaslException
@@ -170,13 +137,10 @@ public class ServerFactory implements SaslServerFactory
{
HashMap attributes = new HashMap();
if (props != null)
- {
- attributes.putAll(props);
- }
+ attributes.putAll(props);
attributes.put(Registry.SASL_PROTOCOL, protocol);
attributes.put(Registry.SASL_SERVER_NAME, serverName);
attributes.put(Registry.SASL_CALLBACK_HANDLER, cbh);
-
result.init(attributes);
}
return result;
@@ -191,4 +155,4 @@ public class ServerFactory implements SaslServerFactory
{
return "true".equalsIgnoreCase(String.valueOf(props.get(propertyName)));
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ServerMechanism.java b/libjava/classpath/gnu/javax/crypto/sasl/ServerMechanism.java
index f12a075d949..75603a14aec 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ServerMechanism.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ServerMechanism.java
@@ -45,51 +45,36 @@ import java.util.Map;
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslServer;
import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
/**
- * <p>A base class to facilitate implementing SASL server-side mechanisms.</p>
+ * A base class to facilitate implementing SASL server-side mechanisms.
*/
-public abstract class ServerMechanism implements SaslServer
+public abstract class ServerMechanism
+ implements SaslServer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** Name of this mechanism. */
protected String mechanism;
-
/** Name of protocol using this mechanism. */
protected String protocol;
-
/** Name of server to authenticate to. */
protected String serverName;
-
/** Properties of qualities desired for this mechanism. */
protected Map properties;
-
/** Callback handler to use with this mechanism instance. */
protected CallbackHandler handler;
-
/** Whether authentication phase is completed (true) or not (false). */
protected boolean complete = false;
-
/** The authorisation identity. */
protected String authorizationID;
-
/** Channel binding data to use with this mechanism instance. */
protected byte[] channelBinding;
-
/** The state of the authentication automaton. -1 means uninitialised. */
protected int state = -1;
-
/** The provider for authentication information. */
protected IAuthInfoProvider authenticator;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
protected ServerMechanism(final String mechanism)
{
super();
@@ -99,20 +84,10 @@ public abstract class ServerMechanism implements SaslServer
this.state = -1;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods to be implemented by concrete subclasses ---------------
-
protected abstract void initMechanism() throws SaslException;
protected abstract void resetMechanism() throws SaslException;
- // javax.security.sasl.SaslServer interface implementation -----------------
-
public abstract byte[] evaluateResponse(byte[] response) throws SaslException;
public boolean isComplete()
@@ -123,20 +98,16 @@ public abstract class ServerMechanism implements SaslServer
public byte[] unwrap(final byte[] incoming, final int offset, final int len)
throws SaslException
{
- if (!isComplete())
- {
- throw new IllegalMechanismStateException();
- }
+ if (! isComplete())
+ throw new IllegalMechanismStateException();
return this.engineUnwrap(incoming, offset, len);
}
public byte[] wrap(final byte[] outgoing, final int offset, final int len)
throws SaslException
{
- if (!isComplete())
- {
- throw new IllegalMechanismStateException();
- }
+ if (! isComplete())
+ throw new IllegalMechanismStateException();
return this.engineWrap(outgoing, offset, len);
}
@@ -152,58 +123,32 @@ public abstract class ServerMechanism implements SaslServer
public Object getNegotiatedProperty(final String propName)
{
- if (!isComplete())
- {
- throw new IllegalStateException();
- }
+ if (! isComplete())
+ throw new IllegalStateException();
if (Sasl.QOP.equals(propName))
- {
- return getNegotiatedQOP();
- }
+ return getNegotiatedQOP();
if (Sasl.STRENGTH.equals(propName))
- {
- return getNegotiatedStrength();
- }
+ return getNegotiatedStrength();
if (Sasl.SERVER_AUTH.equals(propName))
- {
- return getNegotiatedServerAuth();
- }
+ return getNegotiatedServerAuth();
if (Sasl.MAX_BUFFER.equals(propName))
- {
- return getNegotiatedMaxBuffer();
- }
+ return getNegotiatedMaxBuffer();
if (Sasl.RAW_SEND_SIZE.equals(propName))
- {
- return getNegotiatedRawSendSize();
- }
+ return getNegotiatedRawSendSize();
if (Sasl.POLICY_NOPLAINTEXT.equals(propName))
- {
- return getNegotiatedPolicyNoPlainText();
- }
+ return getNegotiatedPolicyNoPlainText();
if (Sasl.POLICY_NOACTIVE.equals(propName))
- {
- return getNegotiatedPolicyNoActive();
- }
+ return getNegotiatedPolicyNoActive();
if (Sasl.POLICY_NODICTIONARY.equals(propName))
- {
- return getNegotiatedPolicyNoDictionary();
- }
+ return getNegotiatedPolicyNoDictionary();
if (Sasl.POLICY_NOANONYMOUS.equals(propName))
- {
- return getNegotiatedPolicyNoAnonymous();
- }
+ return getNegotiatedPolicyNoAnonymous();
if (Sasl.POLICY_FORWARD_SECRECY.equals(propName))
- {
- return getNegotiatedPolicyForwardSecrecy();
- }
+ return getNegotiatedPolicyForwardSecrecy();
if (Sasl.POLICY_PASS_CREDENTIALS.equals(propName))
- {
- return getNegotiatedPolicyPassCredentials();
- }
+ return getNegotiatedPolicyPassCredentials();
if (Sasl.REUSE.equals(propName))
- {
- return getReuse();
- }
+ return getReuse();
return null;
}
@@ -212,8 +157,6 @@ public abstract class ServerMechanism implements SaslServer
reset();
}
- // other Instance methods --------------------------------------------------
-
protected String getNegotiatedQOP()
{
return Registry.QOP_AUTH;
@@ -291,30 +234,23 @@ public abstract class ServerMechanism implements SaslServer
}
/**
- * <p>Initialises the mechanism with designated attributes. Permissible names
- * and values are mechanism specific.</p>
- *
+ * Initialises the mechanism with designated attributes. Permissible names and
+ * values are mechanism specific.
+ *
* @param attributes a set of name-value pairs that describes the desired
- * future behaviour of this instance.
+ * future behaviour of this instance.
* @throws IllegalMechanismStateException if the instance is already
- * initialised.
+ * initialised.
* @throws SaslException if an exception occurs during the process.
*/
public void init(final Map attributes) throws SaslException
{
if (state != -1)
- {
- throw new IllegalMechanismStateException("init()");
- }
-
+ throw new IllegalMechanismStateException("init()");
if (properties == null)
- {
- properties = new HashMap();
- }
+ properties = new HashMap();
else
- {
- properties.clear();
- }
+ properties.clear();
if (attributes != null)
{
protocol = (String) attributes.get(Registry.SASL_PROTOCOL);
@@ -324,35 +260,24 @@ public abstract class ServerMechanism implements SaslServer
properties.putAll(attributes);
}
else
- {
- handler = null;
- }
-
+ handler = null;
if (protocol == null)
- {
- protocol = "";
- }
+ protocol = "";
if (serverName == null)
- {
- serverName = "";
- }
+ serverName = "";
if (authenticator != null)
- {
- authenticator.activate(properties);
- }
+ authenticator.activate(properties);
if (channelBinding == null)
- {
- channelBinding = new byte[0];
- }
+ channelBinding = new byte[0];
initMechanism();
complete = false;
state = 0;
}
/**
- * <p>Resets the mechanism instance for re-initialisation and use with other
- * characteristics.</p>
- *
+ * Resets the mechanism instance for re-initialisation and use with other
+ * characteristics.
+ *
* @throws SaslException if an exception occurs during the process.
*/
public void reset() throws SaslException
@@ -360,12 +285,10 @@ public abstract class ServerMechanism implements SaslServer
resetMechanism();
properties.clear();
if (authenticator != null)
- {
- authenticator.passivate();
- }
+ authenticator.passivate();
protocol = serverName = null;
channelBinding = null;
complete = false;
state = -1;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/UserAlreadyExistsException.java b/libjava/classpath/gnu/javax/crypto/sasl/UserAlreadyExistsException.java
index 764a36df30e..1563be9173d 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/UserAlreadyExistsException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/UserAlreadyExistsException.java
@@ -44,9 +44,9 @@ import javax.security.sasl.SaslException;
* A checked exception thrown to indicate that a designated user is already
* known to the the authentication layer.
*/
-public class UserAlreadyExistsException extends SaslException
+public class UserAlreadyExistsException
+ extends SaslException
{
-
/**
* Constructs a <code>UserAlreadyExistsException</code> with no detail
* message.
@@ -60,7 +60,7 @@ public class UserAlreadyExistsException extends SaslException
* Constructs a <code>UserAlreadyExistsException</code> with the specified
* detail message. In the case of this exception, the detail message
* designates the offending username.
- *
+ *
* @param userName the detail message, which in this case is the username.
*/
public UserAlreadyExistsException(String userName)
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousClient.java b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousClient.java
index f5b1faab299..87f5e5fb54e 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousClient.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousClient.java
@@ -44,35 +44,22 @@ import gnu.javax.crypto.sasl.IllegalMechanismStateException;
import java.io.UnsupportedEncodingException;
+import javax.security.sasl.AuthenticationException;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslException;
-import javax.security.sasl.AuthenticationException;
/**
- * <p>The ANONYMOUS client-side mechanism.</p>
+ * The ANONYMOUS client-side mechanism.
*/
-public class AnonymousClient extends ClientMechanism implements SaslClient
+public class AnonymousClient
+ extends ClientMechanism
+ implements SaslClient
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public AnonymousClient()
{
super(Registry.SASL_ANONYMOUS_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -81,8 +68,6 @@ public class AnonymousClient extends ClientMechanism implements SaslClient
{
}
- // javax.security.sasl.SaslClient interface implementation -----------------
-
public boolean hasInitialResponse()
{
return true;
@@ -99,13 +84,10 @@ public class AnonymousClient extends ClientMechanism implements SaslClient
private byte[] response() throws SaslException
{
- if (!AnonymousUtil.isValidTraceInformation(authorizationID))
- {
- throw new AuthenticationException(
- "Authorisation ID is not a valid email address");
- }
+ if (! AnonymousUtil.isValidTraceInformation(authorizationID))
+ throw new AuthenticationException(
+ "Authorisation ID is not a valid email address");
complete = true;
- // return authorizationID.getBytes();
final byte[] result;
try
{
@@ -117,4 +99,4 @@ public class AnonymousClient extends ClientMechanism implements SaslClient
}
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousServer.java b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousServer.java
index 2c10f78a78b..76456044c8f 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousServer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousServer.java
@@ -50,28 +50,15 @@ import javax.security.sasl.SaslServer;
/**
* The ANONYMOUS server-side mechanism.
*/
-public class AnonymousServer extends ServerMechanism implements SaslServer
+public class AnonymousServer
+ extends ServerMechanism
+ implements SaslServer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public AnonymousServer()
{
super(Registry.SASL_ANONYMOUS_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -80,14 +67,10 @@ public class AnonymousServer extends ServerMechanism implements SaslServer
{
}
- // javax.security.sasl.SaslServer interface implementation -----------------
-
public byte[] evaluateResponse(final byte[] response) throws SaslException
{
if (response == null)
- {
- return null;
- }
+ return null;
try
{
authorizationID = new String(response, "UTF-8");
@@ -104,4 +87,4 @@ public class AnonymousServer extends ServerMechanism implements SaslServer
authorizationID = null;
throw new AuthenticationException("Invalid email address");
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java
index 99e95eaeca0..9047ebd5c6e 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/anonymous/AnonymousUtil.java
@@ -45,65 +45,39 @@ import gnu.javax.crypto.sasl.SaslUtil;
*/
public class AnonymousUtil
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Trivial private constructor to enforce Singleton pattern. */
private AnonymousUtil()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
static boolean isValidTraceInformation(String traceInformation)
{
if (traceInformation == null)
- {
- return false;
- }
+ return false;
if (traceInformation.length() == 0)
- {
- return true;
- }
+ return true;
if (SaslUtil.validEmailAddress(traceInformation))
- {
- return true;
- }
+ return true;
return isValidToken(traceInformation);
}
static boolean isValidToken(String token)
{
if (token == null)
- {
- return false;
- }
+ return false;
if (token.length() == 0)
- {
- return false;
- }
+ return false;
if (token.length() > 255)
- {
- return false;
- }
+ return false;
if (token.indexOf('@') != -1)
- {
- return false;
- }
+ return false;
for (int i = 0; i < token.length(); i++)
{
char c = token.charAt(i);
if (c < 0x20 || c > 0x7E)
- {
- return false;
- }
+ return false;
}
return true;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java
index cf73b6f982f..dec0366c04c 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5AuthInfoProvider.java
@@ -51,44 +51,26 @@ import javax.security.sasl.AuthenticationException;
/**
* The CRAM-MD5 mechanism authentication information provider implementation.
*/
-public class CramMD5AuthInfoProvider implements IAuthInfoProvider
+public class CramMD5AuthInfoProvider
+ implements IAuthInfoProvider
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private PasswordFile passwordFile = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constrcutor
- // Class methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProvider interface implementation
- // -------------------------------------------------------------------------
-
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
{
String pfn = (String) context.get(CramMD5Registry.PASSWORD_FILE);
if (pfn == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
- {
- passwordFile = new PasswordFile(pfn);
- }
+ passwordFile = new PasswordFile(pfn);
}
}
catch (IOException x)
@@ -105,10 +87,8 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
public boolean contains(String userName) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("contains()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("contains()",
+ new IllegalStateException());
boolean result = false;
try
{
@@ -124,18 +104,13 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
public Map lookup(Map userID) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("lookup()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("lookup()", new IllegalStateException());
Map result = new HashMap();
try
{
String userName = (String) userID.get(Registry.SASL_USERNAME);
if (userName == null)
- {
- throw new NoSuchUserException("");
- }
+ throw new NoSuchUserException("");
String[] data = passwordFile.lookup(userName);
result.put(Registry.SASL_USERNAME, data[0]);
result.put(Registry.SASL_PASSWORD, data[1]);
@@ -148,9 +123,7 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("lookup()", x);
}
return result;
@@ -159,10 +132,7 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
public void update(Map userCredentials) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("update()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("update()", new IllegalStateException());
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
@@ -174,9 +144,7 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
String shell = (String) userCredentials.get(CramMD5Registry.SHELL_FIELD);
if (uid == null || gid == null || gecos == null || dir == null
|| shell == null)
- {
- passwordFile.changePasswd(userName, password);
- }
+ passwordFile.changePasswd(userName, password);
else
{
String[] attributes = new String[] { uid, gid, gecos, dir, shell };
@@ -186,9 +154,7 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("update()", x);
}
}
@@ -197,4 +163,4 @@ public class CramMD5AuthInfoProvider implements IAuthInfoProvider
{
throw new AuthenticationException("", new UnsupportedOperationException());
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Client.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Client.java
index 094109ff9aa..c90cbe986a4 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Client.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Client.java
@@ -56,25 +56,15 @@ import javax.security.sasl.SaslException;
/**
* The CRAM-MD5 SASL client-side mechanism.
*/
-public class CramMD5Client extends ClientMechanism implements SaslClient
+public class CramMD5Client
+ extends ClientMechanism
+ implements SaslClient
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public CramMD5Client()
{
super(Registry.SASL_CRAM_MD5_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -83,8 +73,6 @@ public class CramMD5Client extends ClientMechanism implements SaslClient
{
}
- // javax.security.sasl.SaslClient interface implementation -----------------
-
public boolean hasInitialResponse()
{
return false;
@@ -93,30 +81,22 @@ public class CramMD5Client extends ClientMechanism implements SaslClient
public byte[] evaluateChallenge(final byte[] challenge) throws SaslException
{
if (challenge == null)
- {
- throw new SaslException("null challenge");
- }
+ throw new SaslException("null challenge");
try
{
final String username;
final char[] password;
Callback[] callbacks;
-
- if ((!properties.containsKey(Registry.SASL_USERNAME))
- && (!properties.containsKey(Registry.SASL_PASSWORD)))
+ if ((! properties.containsKey(Registry.SASL_USERNAME))
+ && (! properties.containsKey(Registry.SASL_PASSWORD)))
{
callbacks = new Callback[2];
-
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
callbacks[0] = nameCB;
@@ -128,47 +108,35 @@ public class CramMD5Client extends ClientMechanism implements SaslClient
else
{
if (properties.containsKey(Registry.SASL_USERNAME))
- {
- username = (String) properties.get(Registry.SASL_USERNAME);
- }
+ username = (String) properties.get(Registry.SASL_USERNAME);
else
{
callbacks = new Callback[1];
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
callbacks[0] = nameCB;
this.handler.handle(callbacks);
username = nameCB.getName();
}
if (properties.containsKey(Registry.SASL_PASSWORD))
- {
- password = ((String) properties.get(Registry.SASL_PASSWORD)).toCharArray();
- }
+ password = ((String) properties.get(Registry.SASL_PASSWORD)).toCharArray();
else
{
callbacks = new Callback[1];
- final PasswordCallback pwdCB = new PasswordCallback(
- "password: ",
+ final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
callbacks[0] = pwdCB;
this.handler.handle(callbacks);
password = pwdCB.getPassword();
}
}
-
if (password == null)
- {
- throw new SaslException("null password supplied");
- }
+ throw new SaslException("null password supplied");
final byte[] digest;
try
{
@@ -181,7 +149,6 @@ public class CramMD5Client extends ClientMechanism implements SaslClient
final String response = username + " "
+ Util.toString(digest).toLowerCase();
this.complete = true;
-
return response.getBytes("UTF-8");
}
catch (UnsupportedCallbackException x)
@@ -198,4 +165,4 @@ public class CramMD5Client extends ClientMechanism implements SaslClient
{
return Registry.QOP_AUTH;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java
index 1c61cace491..bbd46a3f281 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Registry.java
@@ -45,22 +45,16 @@ public interface CramMD5Registry
{
/** Name of the password file (used by the server) property. */
String PASSWORD_FILE = "gnu.crypto.sasl.crammd5.password.file";
-
/** Default password file (used by the server) pathname. */
String DEFAULT_PASSWORD_FILE = "/etc/passwd";
-
/** Name of the UID field in the plain password file. */
String UID_FIELD = "crammd5.uid";
-
/** Name of the GID field in the plain password file. */
String GID_FIELD = "crammd5.gid";
-
/** Name of the GECOS field in the plain password file. */
String GECOS_FIELD = "crammd5.gecos";
-
/** Name of the DIR field in the plain password file. */
String DIR_FIELD = "crammd5.dir";
-
/** Name of the SHELL field in the plain password file. */
String SHELL_FIELD = "crammd5.shell";
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Server.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Server.java
index d6622b6db4e..9be03414b66 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Server.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Server.java
@@ -55,29 +55,19 @@ import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
/**
- * <p>The CRAM-MD5 SASL server-side mechanism.</p>
+ * The CRAM-MD5 SASL server-side mechanism.
*/
-public class CramMD5Server extends ServerMechanism implements SaslServer
+public class CramMD5Server
+ extends ServerMechanism
+ implements SaslServer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private byte[] msgID;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public CramMD5Server()
{
super(Registry.SASL_CRAM_MD5_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -86,8 +76,6 @@ public class CramMD5Server extends ServerMechanism implements SaslServer
{
}
- // javax.security.sasl.SaslServer interface implementation -----------------
-
public byte[] evaluateResponse(final byte[] response) throws SaslException
{
if (state == 0)
@@ -96,7 +84,6 @@ public class CramMD5Server extends ServerMechanism implements SaslServer
state++;
return msgID;
}
-
final String responseStr = new String(response);
final int index = responseStr.lastIndexOf(" ");
final String username = responseStr.substring(0, index);
@@ -109,10 +96,8 @@ public class CramMD5Server extends ServerMechanism implements SaslServer
{
throw new AuthenticationException("evaluateResponse()", x);
}
-
// Look up the password
final char[] password = lookupPassword(username);
-
// Compute the digest
byte[] digest;
try
@@ -125,19 +110,15 @@ public class CramMD5Server extends ServerMechanism implements SaslServer
}
try
{
- // digest = (new String(Util.toString(digest).toLowerCase())).getBytes("UTF-8");
digest = Util.toString(digest).toLowerCase().getBytes("UTF-8");
}
catch (UnsupportedEncodingException x)
{
throw new AuthenticationException("evaluateResponse()", x);
}
-
// Compare the received and computed digests
- if (!Arrays.equals(digest, responseDigest))
- {
- throw new AuthenticationException("Digest mismatch");
- }
+ if (! Arrays.equals(digest, responseDigest))
+ throw new AuthenticationException("Digest mismatch");
state++;
return null;
}
@@ -152,34 +133,26 @@ public class CramMD5Server extends ServerMechanism implements SaslServer
return Registry.QOP_AUTH;
}
- // Other instance methods --------------------------------------------------
-
private char[] lookupPassword(final String userName) throws SaslException
{
try
{
- if (!authenticator.contains(userName))
- {
- throw new NoSuchUserException(userName);
- }
+ if (! authenticator.contains(userName))
+ throw new NoSuchUserException(userName);
final Map userID = new HashMap();
userID.put(Registry.SASL_USERNAME, userName);
final Map credentials = authenticator.lookup(userID);
final String password = (String) credentials.get(Registry.SASL_PASSWORD);
if (password == null)
- {
- throw new AuthenticationException("lookupPassword()",
- new InternalError());
- }
+ throw new AuthenticationException("lookupPassword()",
+ new InternalError());
return password.toCharArray();
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("lookupPassword()", x);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Util.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Util.java
index 6e753934933..2145512215a 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Util.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/CramMD5Util.java
@@ -56,29 +56,17 @@ import javax.security.sasl.SaslException;
*/
class CramMD5Util
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
private CramMD5Util()
{
super();
}
- // Class methods
- // -------------------------------------------------------------------------
-
static byte[] createMsgID() throws SaslException
{
- // <process-ID.clock@hostname>
final String encoded;
try
{
- encoded = Util.toBase64(Thread.currentThread().getName().getBytes(
- "UTF-8"));
+ encoded = Util.toBase64(Thread.currentThread().getName().getBytes("UTF-8"));
}
catch (UnsupportedEncodingException x)
{
@@ -92,20 +80,15 @@ class CramMD5Util
catch (UnknownHostException ignored)
{
}
-
final byte[] result;
try
{
- result = new StringBuffer().append("<").append(
- encoded.substring(
- 0,
- encoded.length())).append(
- ".").append(
- String.valueOf(System.currentTimeMillis())).append(
- "@").append(
- hostname).append(
- ">").toString().getBytes(
- "UTF-8");
+ result = new StringBuffer("<")
+ .append(encoded.substring(0,encoded.length()))
+ .append(".").append(String.valueOf(System.currentTimeMillis()))
+ .append("@").append(hostname).append(">")
+ .toString()
+ .getBytes("UTF-8");
}
catch (UnsupportedEncodingException x)
{
@@ -134,4 +117,4 @@ class CramMD5Util
mac.update(data, 0, data.length);
return mac.digest();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/PasswordFile.java b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/PasswordFile.java
index 081af461521..df952111660 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/crammd5/PasswordFile.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/crammd5/PasswordFile.java
@@ -59,26 +59,16 @@ import java.util.StringTokenizer;
*/
public class PasswordFile
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private static String DEFAULT_FILE;
static
{
DEFAULT_FILE = System.getProperty(CramMD5Registry.PASSWORD_FILE,
CramMD5Registry.DEFAULT_PASSWORD_FILE);
}
-
private HashMap entries;
-
private File passwdFile;
-
private long lastmod;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public PasswordFile() throws IOException
{
this(DEFAULT_FILE);
@@ -95,25 +85,14 @@ public class PasswordFile
update();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public synchronized void add(final String user, final String passwd,
final String[] attributes) throws IOException
{
checkCurrent(); // check if the entry exists
if (entries.containsKey(user))
- {
- throw new UserAlreadyExistsException(user);
- }
+ throw new UserAlreadyExistsException(user);
if (attributes.length != 5)
- {
- throw new IllegalArgumentException("Wrong number of attributes");
- }
-
+ throw new IllegalArgumentException("Wrong number of attributes");
final String[] fields = new String[7]; // create the new entry
fields[0] = user;
fields[1] = passwd;
@@ -126,33 +105,26 @@ public class PasswordFile
throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- { // check if the entry exists
- throw new NoSuchUserException(user);
- }
-
- final String[] fields = (String[]) entries.get(user); // get the existing entry
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
+ final String[] fields = (String[]) entries.get(user); // get existing entry
fields[1] = passwd; // modify the password field
entries.remove(user); // delete the existing entry
entries.put(user, fields); // add the new entry
-
savePasswd();
}
public synchronized String[] lookup(final String user) throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- {
- throw new NoSuchUserException(user);
- }
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
return (String[]) entries.get(user);
}
public synchronized boolean contains(final String s) throws IOException
{
checkCurrent();
-
return entries.containsKey(s);
}
@@ -165,9 +137,7 @@ public class PasswordFile
private void checkCurrent() throws IOException
{
if (passwdFile.lastModified() > lastmod)
- {
- update();
- }
+ update();
}
private synchronized void readPasswd(final InputStream in) throws IOException
@@ -183,68 +153,39 @@ public class PasswordFile
{
fields[0] = st.nextToken(); // username
st.nextToken();
-
fields[1] = st.nextToken(); // passwd
if (fields[1].equals(":"))
- {
- fields[1] = "";
- }
+ fields[1] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[2] = st.nextToken(); // uid
if (fields[2].equals(":"))
- {
- fields[2] = "";
- }
+ fields[2] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[3] = st.nextToken(); // gid
if (fields[3].equals(":"))
- {
- fields[3] = "";
- }
+ fields[3] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[4] = st.nextToken(); // gecos
if (fields[4].equals(":"))
- {
- fields[4] = "";
- }
+ fields[4] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[5] = st.nextToken(); // dir
if (fields[5].equals(":"))
- {
- fields[5] = "";
- }
+ fields[5] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[6] = st.nextToken(); // shell
if (fields[6].equals(":"))
- {
- fields[6] = "";
- }
+ fields[6] = "";
}
catch (NoSuchElementException x)
{
continue;
}
-
entries.put(fields[0], fields);
}
}
@@ -268,25 +209,21 @@ public class PasswordFile
fields = (String[]) entries.get(key);
sb = new StringBuffer(fields[0]);
for (i = 1; i < fields.length; i++)
- {
- sb.append(":").append(fields[i]);
- }
+ sb.append(":").append(fields[i]);
pw.println(sb.toString());
}
}
finally
{
if (pw != null)
- {
- try
- {
- pw.flush();
- }
- finally
- {
- pw.close();
- }
- }
+ try
+ {
+ pw.flush();
+ }
+ finally
+ {
+ pw.close();
+ }
try
{
fos.close();
@@ -298,4 +235,4 @@ public class PasswordFile
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java b/libjava/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java
index 4ef6b8541b1..b6fb3f87ead 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java
@@ -38,8 +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;
@@ -47,41 +46,32 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.PrintWriter;
+import java.security.AccessController;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.StringTokenizer;
import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
/**
* A representation of a Plain password file.
*/
public class PasswordFile
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
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;
-
- // private String[] last_params;
private long lastmod;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public PasswordFile() throws IOException
{
this(DEFAULT_FILE);
@@ -98,31 +88,20 @@ public class PasswordFile
update();
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
public synchronized void add(String user, String passwd, String[] attributes)
throws IOException
{
checkCurrent();
if (entries.containsKey(user))
- {
- throw new UserAlreadyExistsException(user);
- }
+ throw new UserAlreadyExistsException(user);
if (attributes.length != 5)
- {
- throw new IllegalArgumentException("Wrong number of attributes");
- }
+ throw new IllegalArgumentException("Wrong number of attributes");
// create the new entry
String[] fields = new String[7];
fields[0] = user;
fields[1] = passwd;
System.arraycopy(attributes, 0, fields, 2, 5);
entries.put(user, fields);
-
savePasswd();
}
@@ -130,26 +109,20 @@ public class PasswordFile
throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- {
- throw new NoSuchUserException(user);
- }
-
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
String[] fields = (String[]) entries.get(user); // get the existing entry
fields[1] = passwd; // modify the password field
entries.remove(user); // delete the existing entry
entries.put(user, fields); // add the new entry
-
savePasswd();
}
public synchronized String[] lookup(String user) throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- {
- throw new NoSuchUserException(user);
- }
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
return (String[]) entries.get(user);
}
@@ -159,8 +132,6 @@ public class PasswordFile
return entries.containsKey(s);
}
- //----------------------------------------------------------------//
-
private synchronized void update() throws IOException
{
lastmod = passwdFile.lastModified();
@@ -170,9 +141,7 @@ public class PasswordFile
private void checkCurrent() throws IOException
{
if (passwdFile.lastModified() > lastmod)
- {
- update();
- }
+ update();
}
private synchronized void readPasswd(InputStream in) throws IOException
@@ -188,68 +157,39 @@ public class PasswordFile
{
fields[0] = st.nextToken(); // username
st.nextToken();
-
fields[1] = st.nextToken(); // passwd
if (fields[1].equals(":"))
- {
- fields[1] = "";
- }
+ fields[1] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[2] = st.nextToken(); // uid
if (fields[2].equals(":"))
- {
- fields[2] = "";
- }
+ fields[2] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[3] = st.nextToken(); // gid
if (fields[3].equals(":"))
- {
- fields[3] = "";
- }
+ fields[3] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[4] = st.nextToken(); // gecos
if (fields[4].equals(":"))
- {
- fields[4] = "";
- }
+ fields[4] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[5] = st.nextToken(); // dir
if (fields[5].equals(":"))
- {
- fields[5] = "";
- }
+ fields[5] = "";
else
- {
- st.nextToken();
- }
-
+ st.nextToken();
fields[6] = st.nextToken(); // shell
if (fields[6].equals(":"))
- {
- fields[6] = "";
- }
+ fields[6] = "";
}
catch (NoSuchElementException ignored)
{
continue;
}
-
entries.put(fields[0], fields);
}
}
@@ -273,37 +213,31 @@ public class PasswordFile
fields = (String[]) entries.get(key);
sb = new StringBuffer(fields[0]);
for (int i = 1; i < fields.length; i++)
- {
- sb.append(":" + fields[i]);
- }
+ sb.append(":" + fields[i]);
pw.println(sb.toString());
}
}
finally
{
if (pw != null)
- {
- try
- {
- pw.flush();
- }
- finally
- {
- pw.close();
- }
- }
+ try
+ {
+ pw.flush();
+ }
+ finally
+ {
+ pw.close();
+ }
if (fos != null)
- {
- try
- {
- fos.close();
- }
- catch (IOException ignored)
- {
- }
- }
+ try
+ {
+ fos.close();
+ }
+ catch (IOException ignored)
+ {
+ }
lastmod = passwdFile.lastModified();
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
index 9882ce9bb48..e0cf82fb60c 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
@@ -51,44 +51,26 @@ import javax.security.sasl.AuthenticationException;
/**
* The PLAIN mechanism authentication information provider implementation.
*/
-public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
+public class PlainAuthInfoProvider
+ implements IAuthInfoProvider, PlainRegistry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private PasswordFile passwordFile = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constrcutor
- // Class methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProvider interface implementation
- // -------------------------------------------------------------------------
-
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
{
String pfn = (String) context.get(PASSWORD_FILE);
if (pfn == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
- {
- passwordFile = new PasswordFile(pfn);
- }
+ passwordFile = new PasswordFile(pfn);
}
}
catch (IOException x)
@@ -105,10 +87,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
public boolean contains(String userName) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("contains()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("contains()",
+ new IllegalStateException());
boolean result = false;
try
{
@@ -124,18 +104,13 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
public Map lookup(Map userID) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("lookup()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("lookup()", new IllegalStateException());
Map result = new HashMap();
try
{
String userName = (String) userID.get(Registry.SASL_USERNAME);
if (userName == null)
- {
- throw new NoSuchUserException("");
- }
+ throw new NoSuchUserException("");
String[] data = passwordFile.lookup(userName);
result.put(Registry.SASL_USERNAME, data[0]);
result.put(Registry.SASL_PASSWORD, data[1]);
@@ -148,13 +123,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
- else
- {
- throw new AuthenticationException("lookup()", x);
- }
+ throw (AuthenticationException) x;
+ throw new AuthenticationException("lookup()", x);
}
return result;
}
@@ -162,10 +132,7 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
public void update(Map userCredentials) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("update()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("update()", new IllegalStateException());
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
@@ -177,9 +144,7 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
String shell = (String) userCredentials.get(SHELL_FIELD);
if (uid == null || gid == null || gecos == null || dir == null
|| shell == null)
- {
- passwordFile.changePasswd(userName, password);
- }
+ passwordFile.changePasswd(userName, password);
else
{
String[] attributes = new String[] { uid, gid, gecos, dir, shell };
@@ -189,13 +154,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
- else
- {
- throw new AuthenticationException("update()", x);
- }
+ throw (AuthenticationException) x;
+ throw new AuthenticationException("update()", x);
}
}
@@ -203,4 +163,4 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
{
throw new AuthenticationException("", new UnsupportedOperationException());
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainClient.java b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainClient.java
index 066db377054..5c60578db67 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainClient.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainClient.java
@@ -48,30 +48,17 @@ import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
/**
- * <p>The PLAIN SASL client-side mechanism.</p>
+ * The PLAIN SASL client-side mechanism.
*/
-public class PlainClient extends ClientMechanism implements SaslClient
+public class PlainClient
+ extends ClientMechanism
+ implements SaslClient
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public PlainClient()
{
super(Registry.SASL_PLAIN_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -80,8 +67,6 @@ public class PlainClient extends ClientMechanism implements SaslClient
{
}
- // javax.security.sasl.SaslClient interface implementation -----------------
-
public boolean hasInitialResponse()
{
return true;
@@ -94,22 +79,16 @@ public class PlainClient extends ClientMechanism implements SaslClient
final String username;
final char[] password;
Callback[] callbacks;
-
- if ((!properties.containsKey(Registry.SASL_USERNAME))
- && (!properties.containsKey(Registry.SASL_PASSWORD)))
+ if ((! properties.containsKey(Registry.SASL_USERNAME))
+ && (! properties.containsKey(Registry.SASL_PASSWORD)))
{
callbacks = new Callback[2];
-
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
callbacks[0] = nameCB;
@@ -121,67 +100,49 @@ public class PlainClient extends ClientMechanism implements SaslClient
else
{
if (properties.containsKey(Registry.SASL_USERNAME))
- {
- username = (String) properties.get(Registry.SASL_USERNAME);
- }
+ username = (String) properties.get(Registry.SASL_USERNAME);
else
{
callbacks = new Callback[1];
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
callbacks[0] = nameCB;
this.handler.handle(callbacks);
username = nameCB.getName();
}
-
if (properties.containsKey(Registry.SASL_PASSWORD))
- {
- password = ((String) properties.get(Registry.SASL_PASSWORD)).toCharArray();
- }
+ password = ((String) properties.get(Registry.SASL_PASSWORD)).toCharArray();
else
{
callbacks = new Callback[1];
- final PasswordCallback pwdCB = new PasswordCallback(
- "password: ",
+ final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
callbacks[0] = pwdCB;
this.handler.handle(callbacks);
password = pwdCB.getPassword();
}
}
-
if (password == null)
- {
- throw new SaslException("null password supplied");
- }
+ throw new SaslException("null password supplied");
final StringBuffer sb = new StringBuffer();
if (authorizationID != null)
- {
- sb.append(authorizationID);
- }
+ sb.append(authorizationID);
sb.append('\0');
sb.append(username);
sb.append('\0');
sb.append(password);
this.complete = true;
-
final byte[] response = sb.toString().getBytes("UTF-8");
return response;
}
catch (Exception x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("evaluateChallenge()", x);
}
}
@@ -190,4 +151,4 @@ public class PlainClient extends ClientMechanism implements SaslClient
{
return Registry.QOP_AUTH;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainRegistry.java b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainRegistry.java
index 0b48c0ad30d..84e17605345 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainRegistry.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainRegistry.java
@@ -40,28 +40,18 @@ package gnu.javax.crypto.sasl.plain;
public interface PlainRegistry
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/** Name of PLAIN password file property. */
String PASSWORD_FILE = "gnu.crypto.sasl.plain.password.file";
-
/** Default fully qualified pathname of the PLAIN password file. */
String DEFAULT_PASSWORD_FILE = "/etc/tpasswd";
-
/** Name of the UID field in the plain password file. */
String UID_FIELD = "plain.uid";
-
/** Name of the GID field in the plain password file. */
String GID_FIELD = "plain.gid";
-
/** Name of the GECOS field in the plain password file. */
String GECOS_FIELD = "plain.gecos";
-
/** Name of the DIR field in the plain password file. */
String DIR_FIELD = "plain.dir";
-
/** Name of the SHELL field in the plain password file. */
String SHELL_FIELD = "plain.shell";
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainServer.java b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainServer.java
index 20568847303..52deef51ee9 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainServer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/plain/PlainServer.java
@@ -54,30 +54,17 @@ import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
/**
- * <p>The PLAIN SASL server-side mechanism.</p>
+ * The PLAIN SASL server-side mechanism.
*/
-public class PlainServer extends ServerMechanism implements SaslServer
+public class PlainServer
+ extends ServerMechanism
+ implements SaslServer
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public PlainServer()
{
super(Registry.SASL_PLAIN_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
}
@@ -86,43 +73,27 @@ public class PlainServer extends ServerMechanism implements SaslServer
{
}
- // javax.security.sasl.SaslServer interface implementation -----------------
-
public byte[] evaluateResponse(final byte[] response) throws SaslException
{
if (response == null)
- {
- return null;
- }
+ return null;
try
{
final String nullStr = new String("\0");
- final StringTokenizer strtok = new StringTokenizer(
- new String(response),
+ final StringTokenizer strtok = new StringTokenizer(new String(response),
nullStr, true);
-
authorizationID = strtok.nextToken();
- if (!authorizationID.equals(nullStr))
- {
- strtok.nextToken();
- }
+ if (! authorizationID.equals(nullStr))
+ strtok.nextToken();
else
- {
- authorizationID = null;
- }
+ authorizationID = null;
final String id = strtok.nextToken();
if (id.equals(nullStr))
- {
- throw new SaslException("No identity given");
- }
+ throw new SaslException("No identity given");
if (authorizationID == null)
- {
- authorizationID = id;
- }
- if ((!authorizationID.equals(nullStr)) && (!authorizationID.equals(id)))
- {
- throw new SaslException("Delegation not supported");
- }
+ authorizationID = id;
+ if ((! authorizationID.equals(nullStr)) && (! authorizationID.equals(id)))
+ throw new SaslException("Delegation not supported");
strtok.nextToken();
final byte[] pwd;
try
@@ -134,9 +105,7 @@ public class PlainServer extends ServerMechanism implements SaslServer
throw new SaslException("evaluateResponse()", x);
}
if (pwd == null)
- {
- throw new SaslException("No password given");
- }
+ throw new SaslException("No password given");
final byte[] password;
try
{
@@ -146,10 +115,8 @@ public class PlainServer extends ServerMechanism implements SaslServer
{
throw new SaslException("evaluateResponse()", x);
}
- if (!Arrays.equals(pwd, password))
- {
- throw new SaslException("Password incorrect");
- }
+ if (! Arrays.equals(pwd, password))
+ throw new SaslException("Password incorrect");
this.complete = true;
return null;
}
@@ -164,33 +131,25 @@ public class PlainServer extends ServerMechanism implements SaslServer
return Registry.QOP_AUTH;
}
- // other methods -----------------------------------------------------------
-
private char[] lookupPassword(final String userName) throws SaslException
{
try
{
- if (!authenticator.contains(userName))
- {
- throw new NoSuchUserException(userName);
- }
+ if (! authenticator.contains(userName))
+ throw new NoSuchUserException(userName);
final Map userID = new HashMap();
userID.put(Registry.SASL_USERNAME, userName);
final Map credentials = authenticator.lookup(userID);
final String password = (String) credentials.get(Registry.SASL_PASSWORD);
if (password == null)
- {
- throw new SaslException("lookupPassword()", new InternalError());
- }
+ throw new SaslException("lookupPassword()", new InternalError());
return password.toCharArray();
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("lookupPassword()", x);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/CALG.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/CALG.java
index 6215783d6a9..308543230b5 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/CALG.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/CALG.java
@@ -58,65 +58,55 @@ import java.util.HashMap;
import javax.security.sasl.SaslException;
/**
- * <p>A Factory class that returns CALG (Confidentiality Algorithm) instances
- * that operate as described in the draft-burdis-cat-sasl-srp-08.</p>
- *
- * <p>The designated CALG block cipher should be used in OFB (Output Feedback
+ * A Factory class that returns CALG (Confidentiality Algorithm) instances that
+ * operate as described in the draft-burdis-cat-sasl-srp-08.
+ * <p>
+ * The designated CALG block cipher should be used in OFB (Output Feedback
* Block) mode in the ISO variant, as described in <i>The Handbook of Applied
- * Cryptography</i>, algorithm 7.20.</p>
- *
- * <p>Let <code>k</code> be the block size of the chosen symmetric key block
- * cipher algorithm; e.g. for AES this is <code>128</code> bits or <code>16</code>
- * octets. The OFB mode used shall be of length/size <code>k</code>.</p>
- *
- * <p>It is recommended that block ciphers operating in OFB mode be used with an
+ * Cryptography</i>, algorithm 7.20.
+ * <p>
+ * Let <code>k</code> be the block size of the chosen symmetric key block
+ * cipher algorithm; e.g. for AES this is <code>128</code> bits or
+ * <code>16</code> octets. The OFB mode used shall be of length/size
+ * <code>k</code>.
+ * <p>
+ * It is recommended that block ciphers operating in OFB mode be used with an
* Initial Vector (the mode's IV). In such a mode of operation - OFB with key
* re-use - the IV need not be secret. For the mechanism in question the IVs
- * shall be a random octet sequence of <code>k</code> bytes.</p>
- *
- * The input data to the confidentiality protection algorithm shall be
- * a multiple of the symmetric cipher block size <code>k</code>. When the input
+ * shall be a random octet sequence of <code>k</code> bytes.
+ * <p>
+ * The input data to the confidentiality protection algorithm shall be a
+ * multiple of the symmetric cipher block size <code>k</code>. When the input
* length is not a multiple of <code>k</code> octets, the data shall be padded
- * according to the following scheme:</p>
- *
- * <p>Assuming the length of the input is <code>l</code> octets,
+ * according to the following scheme:
+ * <p>
+ * Assuming the length of the input is <code>l</code> octets,
* <code>(k - (l mod k))</code> octets, all having the value
* <code>(k - (l mod k))</code>, shall be appended to the original data. In
* other words, the input is padded at the trailing end with one of the
- * following sequences:</p>
- *
+ * following sequences:
* <pre>
- *
- * 01 -- if l mod k = k-1
- * 02 02 -- if l mod k = k-2
- * ...
- * ...
- * ...
- * k k ... k k -- if l mod k = 0
- *</pre>
- *
- * <p>The padding can be removed unambiguously since all input is padded and no
+ *
+ * 01 -- if l mod k = k-1
+ * 02 02 -- if l mod k = k-2
+ * ...
+ * ...
+ * ...
+ * k k ... k k -- if l mod k = 0
+ * </pre>
+ * <p>
+ * The padding can be removed unambiguously since all input is padded and no
* padding sequence is a suffix of another. This padding method is well-defined
* if and only if <code>k &lt; 256</code> octets, which is the case with
- * symmetric key block ciphers today, and in the forseeable future.</p>
+ * symmetric key block ciphers today, and in the forseeable future.
*/
public final class CALG
{
-
- // Constants and variables
- // --------------------------------------------------------------------------
-
private Assembly assembly;
-
private Object modeNdx; // initialisation key of the cascade's attributes
-
private int blockSize; // the underlying cipher's blocksize == IV length
-
private int keySize; // the underlying cipher's key size (in bytes).
- // Constructor(s)
- // --------------------------------------------------------------------------
-
/** Private constructor to enforce instantiation through Factory method. */
private CALG(final int blockSize, final int keySize, final Object modeNdx,
final Assembly assembly)
@@ -129,12 +119,9 @@ public final class CALG
this.assembly = assembly;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a SASL-SRP CALG implementation.</p>
- *
+ * Returns an instance of a SASL-SRP CALG implementation.
+ *
* @param algorithm the name of the symmetric cipher algorithm.
* @return an instance of this object.
*/
@@ -144,118 +131,60 @@ public final class CALG
final int blockSize = cipher.defaultBlockSize();
final int keySize = cipher.defaultKeySize();
final Cascade ofbCipher = new Cascade();
- final Object modeNdx = ofbCipher.append(Stage.getInstance(
- ModeFactory.getInstance(
- Registry.OFB_MODE,
- cipher,
- blockSize),
- Direction.FORWARD));
+ IMode ofbMode = ModeFactory.getInstance(Registry.OFB_MODE,
+ cipher,
+ blockSize);
+ Stage modeStage = Stage.getInstance(ofbMode, Direction.FORWARD);
+ final Object modeNdx = ofbCipher.append(modeStage);
final IPad pkcs7 = PadFactory.getInstance(Registry.PKCS7_PAD);
- // the passed IV may be longer that what we need. ensure correct length
- // byte[] realIV = null;
- // if (iv.length == blockSize) {
- // realIV = iv;
- // } else {
- // realIV = new byte[blockSize];
- // if (iv.length > blockSize) {
- // System.arraycopy(iv, 0, realIV, 0, blockSize);
- // } else { // shouldnt happen
- // System.arraycopy(iv, 0, realIV, 0, iv.length);
- // }
- // }
-
- // HashMap modeAttributes = new HashMap();
- // modeAttributes.put(IBlockCipher.KEY_MATERIAL, K.clone());
- // modeAttributes.put(IMode.IV, realIV);
-
final Assembly asm = new Assembly();
asm.addPreTransformer(Transformer.getCascadeTransformer(ofbCipher));
asm.addPreTransformer(Transformer.getPaddingTransformer(pkcs7));
-
- // HashMap attributes = new HashMap();
- // attributes.put(Assembly.DIRECTION, dir);
- // attributes.put(modeNdx, modeAttributes);
- // try {
- // asm.init(attributes);
- // } catch (TransformerException x) {
- // throw new SaslException("getInstance()", x);
- // }
-
return new CALG(blockSize, keySize, modeNdx, asm);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Initialises a SASL-SRP CALG implementation.</p>
- *
+ * Initialises a SASL-SRP CALG implementation.
+ *
* @param kdf the key derivation function.
* @param iv the initial vector value to use.
* @param dir whether this CALG is used for encryption or decryption.
*/
- // public void init(byte[] K, byte[] iv, Direction dir) throws SaslException {
public void init(final KDF kdf, final byte[] iv, final Direction dir)
throws SaslException
{
- // IBlockCipher cipher = CipherFactory.getInstance(algorithm);
- // int blockSize = cipher.defaultBlockSize();
- // Cascade ofbCipher = new Cascade();
- // Object modeNdx = ofbCipher.append(
- // Stage.getInstace(
- // ModeFactory.getInstance(Registry.OFB_MODE, cipher, blockSize),
- // Direction.FORWARD));
- // IPad pkcs7 = PadFactory.getInstance(Registry.PKCS7_PAD);
- // the passed IV may be longer that what we need. ensure correct length
final byte[] realIV;
if (iv.length == blockSize)
- {
- realIV = iv;
- }
+ realIV = iv;
else
{
realIV = new byte[blockSize];
if (iv.length > blockSize)
- {
- System.arraycopy(iv, 0, realIV, 0, blockSize);
- }
- else
- { // shouldnt happen
- System.arraycopy(iv, 0, realIV, 0, iv.length);
- }
+ System.arraycopy(iv, 0, realIV, 0, blockSize);
+ else // shouldnt happen
+ System.arraycopy(iv, 0, realIV, 0, iv.length);
}
-
final HashMap modeAttributes = new HashMap();
- // modeAttributes.put(IBlockCipher.KEY_MATERIAL, K.clone());
final byte[] sk = kdf.derive(keySize);
modeAttributes.put(IBlockCipher.KEY_MATERIAL, sk);
- //System.out.println("**** Initialised CALG with: "+gnu.crypto.util.Util.dumpString(sk));
modeAttributes.put(IMode.IV, realIV);
-
- // Assembly asm = new Assembly();
- // asm.addPreTransformer(Transformer.getCascadeTransformer(ofbCipher));
- // asm.addPreTransformer(Transformer.getPaddingTransformer(pkcs7));
-
final HashMap attributes = new HashMap();
attributes.put(Assembly.DIRECTION, dir);
attributes.put(modeNdx, modeAttributes);
try
{
- // asm.init(attributes);
assembly.init(attributes);
}
catch (TransformerException x)
{
throw new SaslException("getInstance()", x);
}
-
- // return new CALG(asm);
}
/**
- * <p>Encrypts or decrypts, depending on the mode already set, a designated
- * array of bytes and returns the result.</p>
- *
+ * Encrypts or decrypts, depending on the mode already set, a designated array
+ * of bytes and returns the result.
+ *
* @param data the data to encrypt/decrypt.
* @return the decrypted/encrypted result.
* @throws ConfidentialityException if an exception occurs duirng the process.
@@ -266,9 +195,9 @@ public final class CALG
}
/**
- * <p>Encrypts or decrypts, depending on the mode already set, a designated
- * array of bytes and returns the result.</p>
- *
+ * Encrypts or decrypts, depending on the mode already set, a designated array
+ * of bytes and returns the result.
+ *
* @param data the data to encrypt/decrypt.
* @param offset where to start in <code>data</code>.
* @param length how many bytes to consider in <code>data</code>.
@@ -289,4 +218,4 @@ public final class CALG
}
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/ClientStore.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/ClientStore.java
index ce16f4aa75d..866e610d83d 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/ClientStore.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/ClientStore.java
@@ -41,29 +41,19 @@ package gnu.javax.crypto.sasl.srp;
import java.util.HashMap;
/**
- * <p>The client-side implementation of the SRP security context store.</p>
+ * The client-side implementation of the SRP security context store.
*/
public class ClientStore
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The underlying singleton. */
private static ClientStore singleton = null;
-
/** The map of uid --> SASL Security Context record. */
private static final HashMap uid2ssc = new HashMap();
-
/** The map of sid --> Session timing record. */
private static final HashMap uid2ttl = new HashMap();
-
/** A synchronisation lock. */
private static final Object lock = new Object();
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Private constructor to enforce Singleton pattern. */
private ClientStore()
{
@@ -72,33 +62,25 @@ public class ClientStore
// TODO: add a cleaning timer thread
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the classloader Singleton.</p>
- *
+ * Returns the classloader Singleton.
+ *
* @return the classloader Singleton instance.
*/
static synchronized final ClientStore instance()
{
if (singleton == null)
- {
- singleton = new ClientStore();
- }
+ singleton = new ClientStore();
return singleton;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a boolean flag indicating if the designated client's session is
- * still alive or not.</p>
- *
+ * Returns a boolean flag indicating if the designated client's session is
+ * still alive or not.
+ *
* @param uid the identifier of the client whose session to check.
* @return <code>true</code> if the designated client's session is still
- * alive. <code>false</code> otherwise.
+ * alive. <code>false</code> otherwise.
*/
boolean isAlive(final String uid)
{
@@ -107,11 +89,11 @@ public class ClientStore
{
final Object obj = uid2ssc.get(uid);
result = (obj != null);
- if (result)
- { // is it still alive?
+ if (result) // is it still alive?
+ {
final StoreEntry sto = (StoreEntry) uid2ttl.get(uid);
- if (!sto.isAlive())
- { // invalidate it
+ if (! sto.isAlive()) // invalidate it
+ {
uid2ssc.remove(uid);
uid2ttl.remove(uid);
}
@@ -121,11 +103,11 @@ public class ClientStore
}
/**
- * <p>Records a mapping between a client's unique identifier and its security
- * context.</p>
- *
- * @param uid the unique identifier of the SRP client for which the session
- * is to be cached.
+ * Records a mapping between a client's unique identifier and its security
+ * context.
+ *
+ * @param uid the unique identifier of the SRP client for which the session is
+ * to be cached.
* @param ttl the session's Time-To-Live indicator (in seconds).
* @param ctx the client's security context.
*/
@@ -139,9 +121,9 @@ public class ClientStore
}
/**
- * <p>Removes the mapping between the designated SRP client unique identifier
- * and the its session security context (and other timing information).</p>
- *
+ * Removes the mapping between the designated SRP client unique identifier and
+ * the its session security context (and other timing information).
+ *
* @param uid the identifier of the client whose session is to invalidate.
*/
void invalidateSession(final String uid)
@@ -154,9 +136,9 @@ public class ClientStore
}
/**
- * <p>Returns an SRP client's security context record mapped by that client's
- * unique identifier.</p>
- *
+ * Returns an SRP client's security context record mapped by that client's
+ * unique identifier.
+ *
* @param uid the identifier of the client whose session is to restore.
* @return the SRP client's security context.
*/
@@ -170,4 +152,4 @@ public class ClientStore
}
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
index 51492f9773c..85c93700fbf 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
@@ -48,20 +48,14 @@ import java.util.HashMap;
import javax.security.sasl.SaslException;
/**
- * <p>A Factory class that returns IALG (Integrity Algorithm) instances that
- * operate as described in the draft-burdis-cat-sasl-srp-04 and later.</p>
+ * A Factory class that returns IALG (Integrity Algorithm) instances that
+ * operate as described in the draft-burdis-cat-sasl-srp-04 and later.
*/
-public final class IALG implements Cloneable
+public final class IALG
+ implements Cloneable
{
-
- // Constants and variables
- // --------------------------------------------------------------------------
-
private IMac hmac;
- // Constructor(s)
- // --------------------------------------------------------------------------
-
/** Private constructor to enforce instantiation through Factory method. */
private IALG(final IMac hmac)
{
@@ -70,12 +64,9 @@ public final class IALG implements Cloneable
this.hmac = hmac;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of a SASL-SRP IALG implementation.</p>
- *
+ * Returns an instance of a SASL-SRP IALG implementation.
+ *
* @param algorithm the name of the HMAC algorithm.
* @return an instance of this object.
*/
@@ -85,44 +76,24 @@ public final class IALG implements Cloneable
final IMac hmac;
hmac = MacFactory.getInstance(algorithm);
if (hmac == null)
- {
- throw new SaslException("getInstance()",
- new NoSuchAlgorithmException(algorithm));
- }
- // try {
- // byte[] sk = (byte[]) K.clone();
- // HashMap map = new HashMap();
- // map.put(IMac.MAC_KEY_MATERIAL, sk);
- // hmac.init(map);
- // } catch (InvalidKeyException x) {
- // throw new SaslException("getInstance()", x);
- // }
+ throw new SaslException("getInstance()",
+ new NoSuchAlgorithmException(algorithm));
return new IALG(hmac);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
- // Cloneable interface implementation --------------------------------------
-
public Object clone() throws CloneNotSupportedException
{
return new IALG((IMac) hmac.clone());
}
- // other methdds -----------------------------------------------------------
-
- // public void init(final byte[] K) throws SaslException {
public void init(final KDF kdf) throws SaslException
{
try
{
- // final byte[] sk = (byte[]) K.clone();
final byte[] sk = kdf.derive(hmac.macSize());
final HashMap map = new HashMap();
map.put(IMac.MAC_KEY_MATERIAL, sk);
hmac.init(map);
- //System.out.println("**** Initialised IALG with: "+gnu.crypto.util.Util.dumpString(sk));
}
catch (InvalidKeyException x)
{
@@ -146,8 +117,8 @@ public final class IALG implements Cloneable
}
/**
- * <p>Returns the length (in bytes) of this SASL SRP Integrity Algorithm.</p>
- *
+ * Returns the length (in bytes) of this SASL SRP Integrity Algorithm.
+ *
* @return the length, in bytes, of this integrity protection algorithm.
*/
public int length()
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/KDF.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/KDF.java
index 0d5eeacd182..aa3edac0c3b 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/KDF.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/KDF.java
@@ -47,67 +47,46 @@ import gnu.javax.crypto.prng.UMacGenerator;
import java.util.HashMap;
/**
- * <p>The SASL-SRP KDF implementation, which is also used, depending on how it
- * was instantiated, as a secure Pseudo Random Number Generator.</p>
+ * The SASL-SRP KDF implementation, which is also used, depending on how it was
+ * instantiated, as a secure Pseudo Random Number Generator.
*/
public class KDF
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- private static final int AES_BLOCK_SIZE = 16; // default block size for the AES
-
+ private static final int AES_BLOCK_SIZE = 16; // default block size for AES
private static final int AES_KEY_SIZE = 16; // default key size for the AES
-
private static final byte[] buffer = new byte[1];
-
/** Our default source of randomness. */
private static final PRNG prng = PRNG.getInstance();
-
- /** The shared secret K to use. */
- // private byte[] keyMaterial;
/** The underlying UMAC Generator instance. */
private UMacGenerator umac = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/**
- * <p>Constructs an instance of the <code>KDF</code> initialised with the
- * designated shared secret bytes.</p>
- *
+ * Constructs an instance of the <code>KDF</code> initialised with the
+ * designated shared secret bytes.
+ *
* @param keyMaterial the SASL SRP shared secret (K) bytes.
*/
private KDF(final byte[] keyMaterial, final int ndx)
{
super();
- // if (ndx != 0) {
- // this.keyMaterial = (byte[]) keyMaterial.clone();
- // }
final HashMap map = new HashMap();
map.put(UMacGenerator.CIPHER, Registry.AES_CIPHER);
- map.put(UMacGenerator.INDEX, new Integer(ndx));
- map.put(IBlockCipher.CIPHER_BLOCK_SIZE, new Integer(AES_BLOCK_SIZE));
+ map.put(UMacGenerator.INDEX, Integer.valueOf(ndx));
+ map.put(IBlockCipher.CIPHER_BLOCK_SIZE, Integer.valueOf(AES_BLOCK_SIZE));
final byte[] key = new byte[AES_KEY_SIZE];
System.arraycopy(keyMaterial, 0, key, 0, AES_KEY_SIZE);
map.put(IBlockCipher.KEY_MATERIAL, key);
-
umac = new UMacGenerator();
umac.init(map);
- //System.out.println("**** Initialised KDF with: "+gnu.crypto.util.Util.dumpString(key));
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>A Factory mehod that returns an instance of a <code>KDF</code> based on
- * supplied seed data.</p>
- *
+ * A Factory mehod that returns an instance of a <code>KDF</code> based on
+ * supplied seed data.
+ *
* @param K the SASL SRP shared secret for a <code>KDF</code> to be used for
- * <i>CALG</i> and <i>IALG</i> setup. <code>null</code> otherwise.
+ * <i>CALG</i> and <i>IALG</i> setup. <code>null</code> otherwise.
* @return an instance of a <code>KDF</code>.
*/
static final KDF getInstance(final byte[] K)
@@ -134,36 +113,28 @@ public class KDF
return (buffer[0] & 0xFF);
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a designated number of bytes suitable for use in the SASL SRP
- * mechanism.</p>
- *
+ * Returns a designated number of bytes suitable for use in the SASL SRP
+ * mechanism.
+ *
* @param length the number of bytes needed.
* @return a byte array containing the generated/selected bytes.
*/
public synchronized byte[] derive(final int length)
{
final byte[] result = new byte[length];
- // if (keyMaterial == null || length > keyMaterial.length) {
try
{
umac.nextBytes(result, 0, length);
}
- catch (IllegalStateException x)
- { // should not happen
+ catch (IllegalStateException x) // should not happen
+ {
x.printStackTrace(System.err);
}
- catch (LimitReachedException x)
- { // idem
+ catch (LimitReachedException x) // idem
+ {
x.printStackTrace(System.err);
}
- // } else {
- // System.arraycopy(keyMaterial, 0, result, 0, length);
- // }
-
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/PasswordFile.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/PasswordFile.java
index 1628a4167ab..36888df8724 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/PasswordFile.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/PasswordFile.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.srp;
import gnu.java.security.Registry;
-import gnu.java.security.hash.IMessageDigest;
import gnu.java.security.util.Util;
import gnu.javax.crypto.key.srp6.SRPAlgorithm;
import gnu.javax.crypto.sasl.NoSuchUserException;
@@ -50,9 +49,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
@@ -62,70 +61,58 @@ import java.util.NoSuchElementException;
import java.util.StringTokenizer;
/**
- * <p>The implementation of SRP password files.</p>
- *
- * <p>For SRP, there are three (3) files:
+ * The implementation of SRP password files.
+ * <p>
+ * For SRP, there are three (3) files:
* <ol>
- * <li>The password configuration file: tpasswd.conf. It contains the pairs
- * &lt;N,g> indexed by a number for each pair used for a user. By default,
- * this file's pathname is constructed from the base password file pathname
- * by prepending it with the ".conf" suffix.</li>
- *
- * <li>The base password file: tpasswd. It contains the related password
- * entries for all the users with values computed using SRP's default
- * message digest algorithm: SHA-1 (with 160-bit output block size).</li>
- *
- * <li>The extended password file: tpasswd2. Its name, by default, is
- * constructed by adding the suffix "2" to the fully qualified pathname of
- * the base password file. It contains, in addition to the same fields as
- * the base password file, albeit with a different verifier value, an extra
- * field identifying the message digest algorithm used to compute this
- * (verifier) value.</li>
- * </ol></p>
- *
- * <p>This implementation assumes the following message digest algorithm codes:
+ * <li>The password configuration file: tpasswd.conf. It contains the pairs
+ * &lt;N,g> indexed by a number for each pair used for a user. By default, this
+ * file's pathname is constructed from the base password file pathname by
+ * prepending it with the ".conf" suffix.</li>
+ * <li>The base password file: tpasswd. It contains the related password
+ * entries for all the users with values computed using SRP's default message
+ * digest algorithm: SHA-1 (with 160-bit output block size).</li>
+ * <li>The extended password file: tpasswd2. Its name, by default, is
+ * constructed by adding the suffix "2" to the fully qualified pathname of the
+ * base password file. It contains, in addition to the same fields as the base
+ * password file, albeit with a different verifier value, an extra field
+ * identifying the message digest algorithm used to compute this (verifier)
+ * value.</li>
+ * </ol>
+ * <p>
+ * This implementation assumes the following message digest algorithm codes:
* <ul>
- * <li>0: the default hash algorithm, which is SHA-1 (or its alias SHA-160).</li>
- * <li>1: MD5.</li>
- * <li>2: RIPEMD-128.</li>
- * <li>3: RIPEMD-160.</li>
- * <li>4: SHA-256.</li>
- * <li>5: SHA-384.</li>
- * <li>6: SHA-512.</li>
- * </ul></p>
- *
- * <p><b>IMPORTANT:</b> This method computes the verifiers as described in
- * RFC-2945, which differs from the description given on the web page for
- * SRP-6.</p>
- *
- * <p>Reference:</p>
+ * <li>0: the default hash algorithm, which is SHA-1 (or its alias SHA-160).</li>
+ * <li>1: MD5.</li>
+ * <li>2: RIPEMD-128.</li>
+ * <li>3: RIPEMD-160.</li>
+ * <li>4: SHA-256.</li>
+ * <li>5: SHA-384.</li>
+ * <li>6: SHA-512.</li>
+ * </ul>
+ * <p>
+ * <b>IMPORTANT:</b> This method computes the verifiers as described in
+ * RFC-2945, which differs from the description given on the web page for SRP-6.
+ * <p>
+ * Reference:
* <ol>
- * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
- * Thomas J. Wu.</li>
+ * <li><a href="http://srp.stanford.edu/design.html">SRP Protocol Design</a><br>
+ * Thomas J. Wu.</li>
* </ol>
*/
public class PasswordFile
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
// names of property keys used in this class
private static final String USER_FIELD = "user";
-
private static final String VERIFIERS_FIELD = "verifier";
-
private static final String SALT_FIELD = "salt";
-
private static final String CONFIG_FIELD = "config";
-
private static String DEFAULT_FILE;
static
{
DEFAULT_FILE = System.getProperty(SRPRegistry.PASSWORD_FILE,
SRPRegistry.DEFAULT_PASSWORD_FILE);
}
-
/** The SRP algorithm instances used by this object. */
private static final HashMap srps;
static
@@ -150,27 +137,19 @@ public class PasswordFile
}
private String confName, pwName, pw2Name;
-
private File configFile, passwdFile, passwd2File;
-
private long lastmodPasswdFile, lastmodPasswd2File;
-
private HashMap entries = new HashMap();
-
private HashMap configurations = new HashMap();
-
// default N values to use when creating a new password.conf file
private static final BigInteger[] Nsrp = new BigInteger[] {
- SRPAlgorithm.N_2048,
- SRPAlgorithm.N_1536,
- SRPAlgorithm.N_1280,
- SRPAlgorithm.N_1024,
- SRPAlgorithm.N_768,
- SRPAlgorithm.N_640,
- SRPAlgorithm.N_512 };
-
- // Constructor(s)
- // -------------------------------------------------------------------------
+ SRPAlgorithm.N_2048,
+ SRPAlgorithm.N_1536,
+ SRPAlgorithm.N_1280,
+ SRPAlgorithm.N_1024,
+ SRPAlgorithm.N_768,
+ SRPAlgorithm.N_640,
+ SRPAlgorithm.N_512 };
public PasswordFile() throws IOException
{
@@ -206,63 +185,43 @@ public class PasswordFile
update();
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a string representing the decimal value of an integer
- * identifying the message digest algorithm to use for the SRP computations.
- * </p>
- *
+ * Returns a string representing the decimal value of an integer identifying
+ * the message digest algorithm to use for the SRP computations.
+ *
* @param mdName the canonical name of a message digest algorithm.
* @return a string representing the decimal value of an ID for that
- * algorithm.
+ * algorithm.
*/
private static final String nameToID(final String mdName)
{
if (Registry.SHA_HASH.equalsIgnoreCase(mdName)
|| Registry.SHA1_HASH.equalsIgnoreCase(mdName)
|| Registry.SHA160_HASH.equalsIgnoreCase(mdName))
- {
- return "0";
- }
+ return "0";
else if (Registry.MD5_HASH.equalsIgnoreCase(mdName))
- {
- return "1";
- }
+ return "1";
else if (Registry.RIPEMD128_HASH.equalsIgnoreCase(mdName))
- {
- return "2";
- }
+ return "2";
else if (Registry.RIPEMD160_HASH.equalsIgnoreCase(mdName))
- {
- return "3";
- }
+ return "3";
else if (Registry.SHA256_HASH.equalsIgnoreCase(mdName))
- {
- return "4";
- }
+ return "4";
else if (Registry.SHA384_HASH.equalsIgnoreCase(mdName))
- {
- return "5";
- }
+ return "5";
else if (Registry.SHA512_HASH.equalsIgnoreCase(mdName))
- {
- return "6";
- }
+ return "6";
return "0";
}
- // SRP password configuration file methods ---------------------------------
-
/**
- * <p>Checks if the current configuration file contains the &lt;N, g> pair
- * for the designated <code>index</code>.</p>
- *
+ * Checks if the current configuration file contains the &lt;N, g> pair for
+ * the designated <code>index</code>.
+ *
* @param index a string representing 1-digit identification of an &lt;N, g>
- * pair used.
- * @return <code>true</code> if the designated <code>index</code> is that of
- * a known &lt;N, g> pair, and <code>false</code> otherwise.
+ * pair used.
+ * @return <code>true</code> if the designated <code>index</code> is that
+ * of a known &lt;N, g> pair, and <code>false</code> otherwise.
* @throws IOException if an exception occurs during the process.
* @see SRPRegistry#N_2048_BITS
* @see SRPRegistry#N_1536_BITS
@@ -280,16 +239,16 @@ public class PasswordFile
}
/**
- * <p>Returns a pair of strings representing the pair of <code>N</code> and
- * <code>g</code> MPIs for the designated <code>index</code>.</p>
- *
+ * Returns a pair of strings representing the pair of <code>N</code> and
+ * <code>g</code> MPIs for the designated <code>index</code>.
+ *
* @param index a string representing 1-digit identification of an &lt;N, g>
- * pair to look up.
+ * pair to look up.
* @return a pair of strings, arranged in an array, where the first (at index
- * position #0) is the repesentation of the MPI <code>N</code>, and the
- * second (at index position #1) is the representation of the MPI
- * <code>g</code>. If the <code>index</code> refers to an unknown pair, then
- * an empty string array is returned.
+ * position #0) is the repesentation of the MPI <code>N</code>, and
+ * the second (at index position #1) is the representation of the MPI
+ * <code>g</code>. If the <code>index</code> refers to an unknown
+ * pair, then an empty string array is returned.
* @throws IOException if an exception occurs during the process.
*/
public synchronized String[] lookupConfig(final String index)
@@ -298,14 +257,10 @@ public class PasswordFile
checkCurrent();
String[] result = null;
if (configurations.containsKey(index))
- {
- result = (String[]) configurations.get(index);
- }
+ result = (String[]) configurations.get(index);
return result;
}
- // SRP base and extended password configuration files methods --------------
-
public synchronized boolean contains(final String user) throws IOException
{
checkCurrent();
@@ -318,9 +273,7 @@ public class PasswordFile
{
checkCurrent();
if (entries.containsKey(user))
- {
- throw new UserAlreadyExistsException(user);
- }
+ throw new UserAlreadyExistsException(user);
final HashMap fields = new HashMap(4);
fields.put(USER_FIELD, user); // 0
fields.put(VERIFIERS_FIELD, newVerifiers(user, salt, passwd, index)); // 1
@@ -334,10 +287,8 @@ public class PasswordFile
throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- {
- throw new NoSuchUserException(user);
- }
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
final HashMap fields = (HashMap) entries.get(user);
final byte[] salt;
try
@@ -369,27 +320,23 @@ public class PasswordFile
finally
{
if (pw1 != null)
- {
- try
- {
- pw1.flush();
- }
- finally
- {
- pw1.close();
- }
- }
+ try
+ {
+ pw1.flush();
+ }
+ finally
+ {
+ pw1.close();
+ }
if (pw2 != null)
- {
- try
- {
- pw2.flush();
- }
- finally
- {
- pw2.close();
- }
- }
+ try
+ {
+ pw2.flush();
+ }
+ finally
+ {
+ pw2.close();
+ }
try
{
f1.close();
@@ -410,24 +357,22 @@ public class PasswordFile
}
/**
- * <p>Returns the triplet: verifier, salt and configuration file index, of a
+ * Returns the triplet: verifier, salt and configuration file index, of a
* designated user, and a designated message digest algorithm name, as an
- * array of strings.</p>
- *
+ * array of strings.
+ *
* @param user the username.
* @param mdName the canonical name of the SRP's message digest algorithm.
* @return a string array containing, in this order, the BASE-64 encodings of
- * the verifier, the salt and the index in the password configuration file of
- * the MPIs N and g of the designated user.
+ * the verifier, the salt and the index in the password configuration
+ * file of the MPIs N and g of the designated user.
*/
public synchronized String[] lookup(final String user, final String mdName)
throws IOException
{
checkCurrent();
- if (!entries.containsKey(user))
- {
- throw new NoSuchUserException(user);
- }
+ if (! entries.containsKey(user))
+ throw new NoSuchUserException(user);
final HashMap fields = (HashMap) entries.get(user);
final HashMap verifiers = (HashMap) fields.get(VERIFIERS_FIELD);
final String salt = (String) fields.get(SALT_FIELD);
@@ -436,8 +381,6 @@ public class PasswordFile
return new String[] { verifier, salt, index };
}
- // Other instance methods --------------------------------------------------
-
private synchronized void readOrCreateConf() throws IOException
{
configurations.clear();
@@ -469,13 +412,9 @@ public class PasswordFile
finally
{
if (pw0 != null)
- {
- pw0.close();
- }
+ pw0.close();
else if (f0 != null)
- {
- f0.close();
- }
+ f0.close();
}
}
}
@@ -511,26 +450,27 @@ public class PasswordFile
{
ndx = (String) it.next();
mpi = (String[]) configurations.get(ndx);
- sb = new StringBuffer(ndx).append(":").append(mpi[0]).append(":").append(
- mpi[1]);
+ sb = new StringBuffer(ndx)
+ .append(":").append(mpi[0])
+ .append(":").append(mpi[1]);
pw.println(sb.toString());
}
}
/**
- * <p>Compute the new verifiers for the designated username and password.</p>
- *
- * <p><b>IMPORTANT:</b> This method computes the verifiers as described in
+ * Compute the new verifiers for the designated username and password.
+ * <p>
+ * <b>IMPORTANT:</b> This method computes the verifiers as described in
* RFC-2945, which differs from the description given on the web page for
- * SRP-6.</p>
- *
+ * SRP-6.
+ *
* @param user the user's name.
* @param s the user's salt.
* @param password the user's password
* @param index the index of the &lt;N, g> pair to use for this user.
* @return a {@link java.util.Map} of user verifiers.
* @throws UnsupportedEncodingException if the US-ASCII decoder is not
- * available on this platform.
+ * available on this platform.
*/
private HashMap newVerifiers(final String user, final byte[] s,
final String password, final String index)
@@ -540,7 +480,6 @@ public class PasswordFile
final String[] mpi = (String[]) configurations.get(index);
final BigInteger N = new BigInteger(1, Util.fromBase64(mpi[0]));
final BigInteger g = new BigInteger(1, Util.fromBase64(mpi[1]));
-
final HashMap result = new HashMap(srps.size());
BigInteger x, v;
SRP srp;
@@ -551,7 +490,6 @@ public class PasswordFile
x = new BigInteger(1, srp.computeX(s, user, password));
v = g.modPow(x, N);
final String verifier = Util.toBase64(v.toByteArray());
-
result.put(digestID, verifier);
}
return result;
@@ -560,7 +498,6 @@ public class PasswordFile
private synchronized void update() throws IOException
{
entries.clear();
-
FileInputStream fis;
passwdFile = new File(pwName);
lastmodPasswdFile = passwdFile.lastModified();
@@ -588,9 +525,7 @@ public class PasswordFile
{
if (passwdFile.lastModified() > lastmodPasswdFile
|| passwd2File.lastModified() > lastmodPasswd2File)
- {
- update();
- }
+ update();
}
private void readPasswd(final InputStream in) throws IOException
@@ -612,16 +547,13 @@ public class PasswordFile
{
throw new IOException("SRP base password file corrupt");
}
-
final HashMap verifiers = new HashMap(6);
verifiers.put("0", verifier);
-
final HashMap fields = new HashMap(4);
fields.put(USER_FIELD, user);
fields.put(VERIFIERS_FIELD, verifiers);
fields.put(SALT_FIELD, salt);
fields.put(CONFIG_FIELD, index);
-
entries.put(user, fields);
}
}
@@ -645,7 +577,6 @@ public class PasswordFile
{
throw new IOException("SRP extended password file corrupt");
}
-
fields = (HashMap) entries.get(user);
if (fields != null)
{
@@ -667,33 +598,28 @@ public class PasswordFile
{
user = (String) i.next();
fields = (HashMap) entries.get(user);
- if (!user.equals(fields.get(USER_FIELD)))
- {
- throw new IOException("Inconsistent SRP password data");
- }
+ if (! user.equals(fields.get(USER_FIELD)))
+ throw new IOException("Inconsistent SRP password data");
verifiers = (HashMap) fields.get(VERIFIERS_FIELD);
- sb1 = new StringBuffer().append(user).append(":").append(
- (String) verifiers.get("0")).append(
- ":").append(
- (String) fields.get(SALT_FIELD)).append(
- ":").append(
- (String) fields.get(CONFIG_FIELD));
+ sb1 = new StringBuffer(user)
+ .append(":").append((String) verifiers.get("0"))
+ .append(":").append((String) fields.get(SALT_FIELD))
+ .append(":").append((String) fields.get(CONFIG_FIELD));
pw1.println(sb1.toString());
// write extended information
j = verifiers.keySet().iterator();
while (j.hasNext())
{
digestID = (String) j.next();
- if (!"0".equals(digestID))
+ if (! "0".equals(digestID))
{
// #0 is the default digest, already present in tpasswd!
- sb2 = new StringBuffer().append(digestID).append(":").append(
- user).append(
- ":").append(
- (String) verifiers.get(digestID));
+ sb2 = new StringBuffer(digestID)
+ .append(":").append(user)
+ .append(":").append((String) verifiers.get(digestID));
pw2.println(sb2.toString());
}
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRP.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRP.java
index d3eb596d4c3..437e42a5a83 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRP.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRP.java
@@ -47,27 +47,18 @@ import java.math.BigInteger;
import java.util.HashMap;
/**
- * <p>A Factory class that returns SRP Singletons that know all SRP-related
+ * A Factory class that returns SRP Singletons that know all SRP-related
* mathematical computations and protocol-related operations for both the
- * client- and server-sides.</p>
+ * client- and server-sides.
*/
public final class SRP
{
-
- // Constants and variables
- // --------------------------------------------------------------------------
-
/** The map of already instantiated SRP algorithm instances. */
private static final HashMap algorithms = new HashMap();
-
private static final byte COLON = (byte) 0x3A;
-
/** The underlying message digest algorithm used for all SRP calculations. */
private IMessageDigest mda;
- // Constructor(s)
- // --------------------------------------------------------------------------
-
/** Trivial private constructor to enforce Singleton pattern. */
private SRP(final IMessageDigest mda)
{
@@ -76,25 +67,18 @@ public final class SRP
this.mda = mda;
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns an instance of this object that uses the designated message
- * digest algorithm as its digest function.</p>
- *
+ * Returns an instance of this object that uses the designated message digest
+ * algorithm as its digest function.
+ *
* @return an instance of this object for the designated digest name.
*/
public static synchronized SRP instance(String mdName)
{
if (mdName != null)
- {
- mdName = mdName.trim().toLowerCase();
- }
+ mdName = mdName.trim().toLowerCase();
if (mdName == null || mdName.equals(""))
- {
- mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
- }
+ mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
SRP result = (SRP) algorithms.get(mdName);
if (result == null)
{
@@ -110,31 +94,24 @@ public final class SRP
{
final byte[] result = new byte[length];
for (int i = 0; i < length; ++i)
- {
- result[i] = (byte) (b1[i] ^ b2[i]);
- }
+ result[i] = (byte)(b1[i] ^ b2[i]);
return result;
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/** @return the message digest algorithm name used by this instance. */
public String getAlgorithm()
{
return mda.name();
}
- // Message Digest algorithm related methods --------------------------------
-
/**
- * <p>Returns a new instance of the SRP message digest algorithm --which is
+ * Returns a new instance of the SRP message digest algorithm --which is
* SHA-160 by default, but could be anything else provided the proper
- * conditions as specified in the SRP specifications.</p>
- *
+ * conditions as specified in the SRP specifications.
+ *
* @return a new instance of the underlying SRP message digest algorithm.
* @throws RuntimeException if the implementation of the message digest
- * algorithm does not support cloning.
+ * algorithm does not support cloning.
*/
public IMessageDigest newDigest()
{
@@ -142,12 +119,12 @@ public final class SRP
}
/**
- * <p>Convenience method to return the result of digesting the designated
- * input with a new instance of the SRP message digest algorithm.</p>
- *
+ * Convenience method to return the result of digesting the designated input
+ * with a new instance of the SRP message digest algorithm.
+ *
* @param src some bytes to digest.
- * @return the bytes constituting the result of digesting the designated
- * input with a new instance of the SRP message digest algorithm.
+ * @return the bytes constituting the result of digesting the designated input
+ * with a new instance of the SRP message digest algorithm.
*/
public byte[] digest(final byte[] src)
{
@@ -157,13 +134,13 @@ public final class SRP
}
/**
- * <p>Convenience method to return the result of digesting the designated
- * input with a new instance of the SRP message digest algorithm.</p>
- *
+ * Convenience method to return the result of digesting the designated input
+ * with a new instance of the SRP message digest algorithm.
+ *
* @param src a String whose bytes (using US-ASCII encoding) are to be
- * digested.
- * @return the bytes constituting the result of digesting the designated
- * input with a new instance of the SRP message digest algorithm.
+ * digested.
+ * @return the bytes constituting the result of digesting the designated input
+ * with a new instance of the SRP message digest algorithm.
* @throws UnsupportedEncodingException if US-ASCII charset is not found.
*/
public byte[] digest(final String src) throws UnsupportedEncodingException
@@ -171,17 +148,15 @@ public final class SRP
return digest(src.getBytes("US-ASCII"));
}
- // Other methods -----------------------------------------------------------
-
/**
- * <p>Convenience method to XOR N bytes from two arrays; N being the output
- * size of the SRP message digest algorithm.</p>
- *
+ * Convenience method to XOR N bytes from two arrays; N being the output size
+ * of the SRP message digest algorithm.
+ *
* @param a the first byte array.
* @param b the second one.
* @return N bytes which are the result of the XOR operations on the first N
- * bytes from the designated arrays. N is the size of the SRP message digest
- * algorithm; eg. 20 for SHA-160.
+ * bytes from the designated arrays. N is the size of the SRP message
+ * digest algorithm; eg. 20 for SHA-160.
*/
public byte[] xor(final byte[] a, final byte[] b)
{
@@ -212,7 +187,6 @@ public final class SRP
hash.update(b, 0, b.length);
hash.update(cn, 0, cn.length);
hash.update(cCB, 0, cCB.length);
-
return hash.digest();
}
@@ -235,14 +209,13 @@ public final class SRP
b = digest(o);
hash.update(b, 0, b.length);
hash.update(sid, 0, sid.length);
- hash.update((byte) (ttl >>> 24));
- hash.update((byte) (ttl >>> 16));
- hash.update((byte) (ttl >>> 8));
+ hash.update((byte)(ttl >>> 24));
+ hash.update((byte)(ttl >>> 16));
+ hash.update((byte)(ttl >>> 8));
hash.update((byte) ttl);
hash.update(cIV, 0, cIV.length);
hash.update(sIV, 0, sIV.length);
hash.update(sCB, 0, sCB.length);
-
return hash.digest();
}
@@ -252,7 +225,6 @@ public final class SRP
hash.update(K, 0, K.length);
hash.update(cn, 0, cn.length);
hash.update(sn, 0, sn.length);
-
return hash.digest();
}
@@ -276,10 +248,8 @@ public final class SRP
hash.update(COLON);
hash.update(p, 0, p.length);
final byte[] up = hash.digest();
-
hash.update(s, 0, s.length);
hash.update(up, 0, up.length);
-
return hash.digest();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java
index 9ea21efb6c2..3a43a94a0b5 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPAuthInfoProvider.java
@@ -50,37 +50,21 @@ import java.util.Map;
import javax.security.sasl.AuthenticationException;
/**
- * <p>The SRP mechanism authentication information provider implementation.</p>
+ * The SRP mechanism authentication information provider implementation.
*/
-public class SRPAuthInfoProvider implements IAuthInfoProvider
+public class SRPAuthInfoProvider
+ implements IAuthInfoProvider
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private PasswordFile passwordFile = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constrcutor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProvider interface implementation ------------------------------
-
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
{
passwordFile = (PasswordFile) context.get(SRPRegistry.PASSWORD_DB);
@@ -88,13 +72,9 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
{
String pfn = (String) context.get(SRPRegistry.PASSWORD_FILE);
if (pfn == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
- {
- passwordFile = new PasswordFile(pfn);
- }
+ passwordFile = new PasswordFile(pfn);
}
}
}
@@ -112,10 +92,8 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
public boolean contains(String userName) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("contains()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("contains()",
+ new IllegalStateException());
boolean result = false;
try
{
@@ -131,20 +109,14 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
public Map lookup(Map userID) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("lookup()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("lookup()", new IllegalStateException());
Map result = new HashMap();
try
{
String userName = (String) userID.get(Registry.SASL_USERNAME);
if (userName == null)
- {
- throw new NoSuchUserException("");
- }
+ throw new NoSuchUserException("");
String mdName = (String) userID.get(SRPRegistry.MD_NAME_FIELD);
-
String[] data = passwordFile.lookup(userName, mdName);
result.put(SRPRegistry.USER_VERIFIER_FIELD, data[0]);
result.put(SRPRegistry.SALT_FIELD, data[1]);
@@ -153,9 +125,7 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("lookup()", x);
}
return result;
@@ -165,7 +135,6 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
{
if (passwordFile == null)
throw new AuthenticationException("update()", new IllegalStateException());
-
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
@@ -173,20 +142,14 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
String salt = (String) userCredentials.get(SRPRegistry.SALT_FIELD);
String config = (String) userCredentials.get(SRPRegistry.CONFIG_NDX_FIELD);
if (salt == null || config == null)
- {
- passwordFile.changePasswd(userName, password);
- }
+ passwordFile.changePasswd(userName, password);
else
- {
- passwordFile.add(userName, password, Util.fromBase64(salt), config);
- }
+ passwordFile.add(userName, password, Util.fromBase64(salt), config);
}
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("update()", x);
}
}
@@ -194,10 +157,8 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
public Map getConfiguration(String mode) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("getConfiguration()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("getConfiguration()",
+ new IllegalStateException());
Map result = new HashMap();
try
{
@@ -208,11 +169,9 @@ public class SRPAuthInfoProvider implements IAuthInfoProvider
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("getConfiguration()", x);
}
return result;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java
index 1a1664ff79d..f4ef4cc34c1 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java
@@ -38,151 +38,91 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.srp;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.hash.MD5;
import gnu.java.security.util.PRNG;
import gnu.java.security.util.Util;
-
+import gnu.javax.crypto.assembly.Direction;
+import gnu.javax.crypto.cipher.CipherFactory;
+import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.key.IKeyAgreementParty;
import gnu.javax.crypto.key.IncomingMessage;
-import gnu.javax.crypto.key.KeyAgreementFactory;
import gnu.javax.crypto.key.KeyAgreementException;
+import gnu.javax.crypto.key.KeyAgreementFactory;
import gnu.javax.crypto.key.OutgoingMessage;
import gnu.javax.crypto.key.srp6.SRP6KeyAgreement;
-import gnu.javax.crypto.assembly.Direction;
-import gnu.javax.crypto.cipher.CipherFactory;
-import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.sasl.ClientMechanism;
import gnu.javax.crypto.sasl.IllegalMechanismStateException;
import gnu.javax.crypto.sasl.InputBuffer;
import gnu.javax.crypto.sasl.IntegrityException;
import gnu.javax.crypto.sasl.OutputBuffer;
-
import gnu.javax.security.auth.Password;
-import java.io.IOException;
-import java.io.PrintWriter;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
+import java.util.logging.Logger;
+import javax.security.auth.DestroyFailedException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.DestroyFailedException;
import javax.security.sasl.AuthenticationException;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslException;
/**
- * <p>The SASL-SRP client-side mechanism.</p>
+ * The SASL-SRP client-side mechanism.
*/
-public class SRPClient extends ClientMechanism implements SaslClient
+public class SRPClient
+ extends ClientMechanism
+ implements SaslClient
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "SRPClient";
-
- // private static final String ERROR = "ERROR";
- // private static final String WARN = " WARN";
- private static final String INFO = " INFO";
-
- private static final String TRACE = "DEBUG";
-
- private static final boolean DEBUG = true;
-
- private static final int debuglevel = 3;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(final String level, final Object obj)
- {
- err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
- // private static final HashMap uid2ctx = new HashMap();
-
+ private static final Logger log = Logger.getLogger(SRPClient.class.getName());
private String uid; // the unique key for this type of client
-
private String U; // the authentication identity
-
BigInteger N, g, A, B;
-
private Password password; // the authentication credentials
-
private byte[] s; // the user's salt
-
private byte[] cIV, sIV; // client+server IVs, when confidentiality is on
-
private byte[] M1, M2; // client+server evidences
-
private byte[] cn, sn; // client's and server's nonce
-
private SRP srp; // SRP algorithm instance used by this client
-
private byte[] sid; // session ID when re-used
-
private int ttl; // session time-to-live in seconds
-
private byte[] sCB; // the peer's channel binding data
-
private String L; // available options
-
private String o;
-
private String chosenIntegrityAlgorithm;
-
private String chosenConfidentialityAlgorithm;
-
private int rawSendSize = Registry.SASL_BUFFER_MAX_LIMIT;
-
private byte[] K; // shared session key
-
private boolean replayDetection = true; // whether Replay Detection is on
-
private int inCounter = 0; // messages sequence numbers
-
private int outCounter = 0;
-
private IALG inMac, outMac; // if !null, use for integrity
-
private CALG inCipher, outCipher; // if !null, use for confidentiality
-
- private IKeyAgreementParty clientHandler = KeyAgreementFactory.getPartyAInstance(Registry.SRP_SASL_KA);
-
+ private IKeyAgreementParty clientHandler =
+ KeyAgreementFactory.getPartyAInstance(Registry.SRP_SASL_KA);
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public SRPClient()
{
super(Registry.SASL_SRP_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
- // we shall keep track of the sid (and the security context of this
- // SRP client) based on the initialisation parameters of an SRP session.
+ // we shall keep track of the sid (and the security context of this SRP
+ // client) based on the initialisation parameters of an SRP session.
// we shall compute a unique key for those parameters and key the sid
// (and the security context) accordingly.
// 1. compute the mapping key. use MD5 (the fastest) for this purpose
@@ -195,9 +135,8 @@ public class SRPClient extends ClientMechanism implements SaslClient
b = protocol.getBytes();
md.update(b, 0, b.length);
if (channelBinding.length > 0)
- {
- md.update(channelBinding, 0, channelBinding.length);
- }
+ md.update(channelBinding, 0, channelBinding.length);
+
uid = Util.toBase64(md.digest());
if (ClientStore.instance().isAlive(uid))
{
@@ -246,15 +185,12 @@ public class SRPClient extends ClientMechanism implements SaslClient
sIV = null;
inMac = outMac = null;
inCipher = outCipher = null;
-
sid = null;
ttl = 0;
cn = null;
sn = null;
}
- // javax.security.sasl.SaslClient interface implementation -----------------
-
public boolean hasInitialResponse()
{
return true;
@@ -282,7 +218,7 @@ public class SRPClient extends ClientMechanism implements SaslClient
}
return result;
case 2: // should only occur if session re-use was rejected
- if (!complete)
+ if (! complete)
{
state++;
return receiveEvidence(challenge);
@@ -296,211 +232,139 @@ public class SRPClient extends ClientMechanism implements SaslClient
protected byte[] engineUnwrap(final byte[] incoming, final int offset,
final int len) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> engineUnwrap()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineUnwrap");
if (inMac == null && inCipher == null)
- {
- throw new IllegalStateException("connection is not protected");
- }
-
+ throw new IllegalStateException("connection is not protected");
// at this point one, or both, of confidentiality and integrity protection
// services are active.
-
final byte[] result;
try
{
- // final InputBuffer frameIn = InputBuffer.getInstance(incoming, offset, len);
- // result = frameIn.getEOS();
if (inMac != null)
{ // integrity bytes are at the end of the stream
final int macBytesCount = inMac.length();
final int payloadLength = len - macBytesCount;
- // final byte[] received_mac = frameIn.getOS();
final byte[] received_mac = new byte[macBytesCount];
System.arraycopy(incoming, offset + payloadLength, received_mac, 0,
macBytesCount);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got C (received MAC): "
- + Util.dumpString(received_mac));
- // inMac.update(result);
+ if (Configuration.DEBUG)
+ log.fine("Got C (received MAC): " + Util.dumpString(received_mac));
inMac.update(incoming, offset, payloadLength);
if (replayDetection)
{
inCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "inCounter=" + String.valueOf(inCounter));
- inMac.update(new byte[] { (byte) (inCounter >>> 24),
- (byte) (inCounter >>> 16),
- (byte) (inCounter >>> 8),
- (byte) inCounter });
+ if (Configuration.DEBUG)
+ log.fine("inCounter=" + inCounter);
+ inMac.update(new byte[] {
+ (byte)(inCounter >>> 24),
+ (byte)(inCounter >>> 16),
+ (byte)(inCounter >>> 8),
+ (byte) inCounter });
}
-
final byte[] computed_mac = inMac.doFinal();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Computed MAC: " + Util.dumpString(computed_mac));
- if (!Arrays.equals(received_mac, computed_mac))
- {
- throw new IntegrityException("engineUnwrap()");
- }
-
+ if (Configuration.DEBUG)
+ log.fine("Computed MAC: " + Util.dumpString(computed_mac));
+ if (! Arrays.equals(received_mac, computed_mac))
+ throw new IntegrityException("engineUnwrap()");
// deal with the payload, which can be either plain or encrypted
if (inCipher != null)
- {
- result = inCipher.doFinal(incoming, offset, payloadLength);
- }
+ result = inCipher.doFinal(incoming, offset, payloadLength);
else
{
result = new byte[len - macBytesCount];
System.arraycopy(incoming, offset, result, 0, result.length);
}
}
- else
- { // no integrity protection; just confidentiality
- // if (inCipher != null) {
- result = inCipher.doFinal(incoming, offset, len);
- // } else {
- // result = new byte[len];
- // System.arraycopy(incoming, offset, result, 0, len);
- // }
- }
- // if (inCipher != null) {
- // result = inCipher.doFinal(result);
- // }
+ else // no integrity protection; just confidentiality
+ result = inCipher.doFinal(incoming, offset, len);
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("engineUnwrap()", x);
}
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== engineUnwrap()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineUnwrap");
return result;
}
protected byte[] engineWrap(final byte[] outgoing, final int offset,
final int len) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> engineWrap()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineWrap");
if (outMac == null && outCipher == null)
- {
- throw new IllegalStateException("connection is not protected");
- }
-
+ throw new IllegalStateException("connection is not protected");
// at this point one, or both, of confidentiality and integrity protection
// services are active.
-
- // byte[] data = new byte[len];
- // System.arraycopy(outgoing, offset, data, 0, len);
byte[] result;
try
{
- // OutputBuffer frameOut = new OutputBuffer();
final ByteArrayOutputStream out = new ByteArrayOutputStream();
// Process the data
if (outCipher != null)
{
- // data = outCipher.doFinal(data);
result = outCipher.doFinal(outgoing, offset, len);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding c (encrypted plaintext): "
- + Util.dumpString(result));
-
- // frameOut.setEOS(data);
+ if (Configuration.DEBUG)
+ log.fine("Encoding c (encrypted plaintext): "
+ + Util.dumpString(result));
out.write(result);
-
if (outMac != null)
{
outMac.update(result);
if (replayDetection)
{
outCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "outCounter=" + String.valueOf(outCounter));
- outMac.update(new byte[] { (byte) (outCounter >>> 24),
- (byte) (outCounter >>> 16),
- (byte) (outCounter >>> 8),
- (byte) outCounter });
+ if (Configuration.DEBUG)
+ log.fine("outCounter=" + outCounter);
+ outMac.update(new byte[] {
+ (byte)(outCounter >>> 24),
+ (byte)(outCounter >>> 16),
+ (byte)(outCounter >>> 8),
+ (byte) outCounter });
}
final byte[] C = outMac.doFinal();
- // frameOut.setOS(C);
out.write(C);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding C (integrity checksum): "
- + Util.dumpString(C));
- } // else confidentiality only; do nothing
+ if (Configuration.DEBUG)
+ log.fine("Encoding C (integrity checksum): " + Util.dumpString(C));
+ }
+ // else confidentiality only; do nothing
}
- else
- { // no confidentiality; just integrity [+ replay detection]
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding p (plaintext): "+Util.dumpString(data));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding p (plaintext): "
- + Util.dumpString(outgoing, offset, len));
-
- // frameOut.setEOS(data);
+ else // no confidentiality; just integrity [+ replay detection]
+ {
+ if (Configuration.DEBUG)
+ log.fine("Encoding p (plaintext): "
+ + Util.dumpString(outgoing, offset, len));
out.write(outgoing, offset, len);
-
- // if (outMac != null) {
- // outMac.update(data);
outMac.update(outgoing, offset, len);
if (replayDetection)
{
outCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "outCounter=" + String.valueOf(outCounter));
- outMac.update(new byte[] { (byte) (outCounter >>> 24),
- (byte) (outCounter >>> 16),
- (byte) (outCounter >>> 8),
- (byte) outCounter });
+ if (Configuration.DEBUG)
+ log.fine("outCounter=" + outCounter);
+ outMac.update(new byte[] {
+ (byte)(outCounter >>> 24),
+ (byte)(outCounter >>> 16),
+ (byte)(outCounter >>> 8),
+ (byte) outCounter });
}
final byte[] C = outMac.doFinal();
- // frameOut.setOS(C);
out.write(C);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding C (integrity checksum): "
- + Util.dumpString(C));
- // }
+ if (Configuration.DEBUG)
+ log.fine("Encoding C (integrity checksum): " + Util.dumpString(C));
}
-
- // frameOut.setEOS(data);
- //
- // if (outMac != null) {
- // outMac.update(data);
- // if (replayDetection) {
- // outCounter++;
- // if (DEBUG && debuglevel > 6) debug(TRACE, "outCounter="+String.valueOf(outCounter));
- // outMac.update(new byte[] {
- // (byte)(outCounter >>> 24),
- // (byte)(outCounter >>> 16),
- // (byte)(outCounter >>> 8),
- // (byte) outCounter });
- // }
- // byte[] C = outMac.doFinal();
- // frameOut.setOS(C);
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding C (integrity checksum): "+Util.dumpString(C));
- // }
-
- // result = frameOut.wrap();
result = out.toByteArray();
-
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("engineWrap()", x);
}
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== engineWrap()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineWrap");
return result;
}
@@ -509,13 +373,8 @@ public class SRPClient extends ClientMechanism implements SaslClient
if (inMac != null)
{
if (inCipher != null)
- {
- return Registry.QOP_AUTH_CONF;
- }
- else
- {
- return Registry.QOP_AUTH_INT;
- }
+ return Registry.QOP_AUTH_CONF;
+ return Registry.QOP_AUTH_INT;
}
return Registry.QOP_AUTH;
}
@@ -525,13 +384,8 @@ public class SRPClient extends ClientMechanism implements SaslClient
if (inMac != null)
{
if (inCipher != null)
- {
- return Registry.STRENGTH_HIGH;
- }
- else
- {
- return Registry.STRENGTH_MEDIUM;
- }
+ return Registry.STRENGTH_HIGH;
+ return Registry.STRENGTH_MEDIUM;
}
return Registry.STRENGTH_LOW;
}
@@ -546,23 +400,18 @@ public class SRPClient extends ClientMechanism implements SaslClient
return Registry.REUSE_TRUE;
}
- // other methods -----------------------------------------------------------
-
private byte[] sendIdentities() throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> sendIdentities()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "sendIdentities");
// If necessary, prompt the client for the username and password
getUsernameAndPassword();
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Password: \"" + new String(password.getPassword()) + "\"");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding U (username): \"" + U + "\"");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding I (userid): \"" + authorizationID + "\"");
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("Password: \"" + new String(password.getPassword()) + "\"");
+ log.fine("Encoding U (username): \"" + U + "\"");
+ log.fine("Encoding I (userid): \"" + authorizationID + "\"");
+ }
// if session re-use generate new 16-byte nonce
if (sid.length != 0)
{
@@ -570,10 +419,7 @@ public class SRPClient extends ClientMechanism implements SaslClient
getDefaultPRNG().nextBytes(cn);
}
else
- {
- cn = new byte[0];
- }
-
+ cn = new byte[0];
final OutputBuffer frameOut = new OutputBuffer();
try
{
@@ -586,36 +432,30 @@ public class SRPClient extends ClientMechanism implements SaslClient
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendIdentities()", x);
}
final byte[] result = frameOut.encode();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendIdentities()");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "C: " + Util.dumpString(result));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " U = " + U);
- if (DEBUG && debuglevel > 2)
- debug(INFO, " I = " + authorizationID);
- if (DEBUG && debuglevel > 2)
- debug(INFO, "sid = " + new String(sid));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " cn = " + Util.dumpString(cn));
- if (DEBUG && debuglevel > 2)
- debug(INFO, "cCB = " + Util.dumpString(channelBinding));
+ if (Configuration.DEBUG)
+ {
+ log.fine("C: " + Util.dumpString(result));
+ log.fine(" U = " + U);
+ log.fine(" I = " + authorizationID);
+ log.fine("sid = " + new String(sid));
+ log.fine(" cn = " + Util.dumpString(cn));
+ log.fine("cCB = " + Util.dumpString(channelBinding));
+ log.exiting(this.getClass().getName(), "sendIdentities");
+ }
return result;
}
private byte[] sendPublicKey(final byte[] input) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> sendPublicKey()");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "S: " + Util.dumpString(input));
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "sendPublicKey");
+ log.fine("S: " + Util.dumpString(input));
+ }
// Server sends [00], N, g, s, B, L
// or [FF], sn, sCB
final InputBuffer frameIn = new InputBuffer(input);
@@ -623,60 +463,50 @@ public class SRPClient extends ClientMechanism implements SaslClient
try
{
ack = (int) frameIn.getScalar(1);
- if (ack == 0x00)
- { // new session
+ if (ack == 0x00) // new session
+ {
N = frameIn.getMPI();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got N (modulus): " + Util.dump(N));
+ if (Configuration.DEBUG)
+ log.fine("Got N (modulus): " + Util.dump(N));
g = frameIn.getMPI();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got g (generator): " + Util.dump(g));
+ if (Configuration.DEBUG)
+ log.fine("Got g (generator): " + Util.dump(g));
s = frameIn.getOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got s (salt): " + Util.dumpString(s));
+ if (Configuration.DEBUG)
+ log.fine("Got s (salt): " + Util.dumpString(s));
B = frameIn.getMPI();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got B (server ephermeral public key): "
- + Util.dump(B));
+ if (Configuration.DEBUG)
+ log.fine("Got B (server ephermeral public key): " + Util.dump(B));
L = frameIn.getText();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got L (available options): \"" + L + "\"");
+ if (Configuration.DEBUG)
+ log.fine("Got L (available options): \"" + L + "\"");
}
- else if (ack == 0xFF)
- { // session re-use
+ else if (ack == 0xFF) // session re-use
+ {
sn = frameIn.getOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sn (server nonce): " + Util.dumpString(sn));
+ if (Configuration.DEBUG)
+ log.fine("Got sn (server nonce): " + Util.dumpString(sn));
sCB = frameIn.getEOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sCB (server channel binding): "
- + Util.dumpString(sCB));
- }
- else
- { // unexpected scalar
- throw new SaslException("sendPublicKey(): Invalid scalar (" + ack
- + ") in server's request");
+ if (Configuration.DEBUG)
+ log.fine("Got sCB (server channel binding): " + Util.dumpString(sCB));
}
+ else // unexpected scalar
+ throw new SaslException("sendPublicKey(): Invalid scalar (" + ack
+ + ") in server's request");
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("sendPublicKey()", x);
}
-
if (ack == 0x00)
{ // new session ---------------------------------------
o = createO(L.toLowerCase()); // do this first to initialise the SRP hash
-
final byte[] pBytes; // use ASCII encoding to inter-operate w/ non-java
pBytes = password.getBytes();
-
// ----------------------------------------------------------------------
final HashMap mapA = new HashMap();
- // mapA.put(SRP6KeyAgreement.HASH_FUNCTION, srp.newDigest());
mapA.put(SRP6KeyAgreement.HASH_FUNCTION, srp.getAlgorithm());
mapA.put(SRP6KeyAgreement.USER_IDENTITY, U);
mapA.put(SRP6KeyAgreement.USER_PASSWORD, pBytes);
@@ -689,9 +519,6 @@ public class SRPClient extends ClientMechanism implements SaslClient
{
throw new SaslException("sendPublicKey()", x);
}
-
- // ----------------------------------------------------------------------
-
// -------------------------------------------------------------------
try
{
@@ -702,7 +529,6 @@ public class SRPClient extends ClientMechanism implements SaslClient
out.writeMPI(B);
IncomingMessage in = new IncomingMessage(out.toByteArray());
out = clientHandler.processMessage(in);
-
in = new IncomingMessage(out.toByteArray());
A = in.readMPI();
K = clientHandler.getSharedSecret();
@@ -712,13 +538,11 @@ public class SRPClient extends ClientMechanism implements SaslClient
throw new SaslException("sendPublicKey()", x);
}
// -------------------------------------------------------------------
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "K: " + Util.dumpString(K));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding A (client ephemeral public key): "
- + Util.dump(A));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("K: " + Util.dumpString(K));
+ log.fine("Encoding A (client ephemeral public key): " + Util.dump(A));
+ }
try
{
M1 = srp.generateM1(N, g, U, s, A, B, K, authorizationID, L, cn,
@@ -728,13 +552,11 @@ public class SRPClient extends ClientMechanism implements SaslClient
{
throw new AuthenticationException("sendPublicKey()", x);
}
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding o (client chosen options): \"" + o + "\"");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding cIV (client IV): \"" + Util.dumpString(cIV)
- + "\"");
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("Encoding o (client chosen options): \"" + o + "\"");
+ log.fine("Encoding cIV (client IV): \"" + Util.dumpString(cIV) + "\"");
+ }
final OutputBuffer frameOut = new OutputBuffer();
try
{
@@ -746,74 +568,65 @@ public class SRPClient extends ClientMechanism implements SaslClient
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendPublicKey()", x);
}
final byte[] result = frameOut.encode();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendPublicKey()");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "New session, or session re-use rejected...");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "C: " + Util.dumpString(result));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " A = 0x" + A.toString(16));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " M1 = " + Util.dumpString(M1));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " o = " + o);
- if (DEBUG && debuglevel > 2)
- debug(INFO, "cIV = " + Util.dumpString(cIV));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("New session, or session re-use rejected...");
+ log.fine("C: " + Util.dumpString(result));
+ log.fine(" A = 0x" + A.toString(16));
+ log.fine(" M1 = " + Util.dumpString(M1));
+ log.fine(" o = " + o);
+ log.fine("cIV = " + Util.dumpString(cIV));
+ log.exiting(this.getClass().getName(), "sendPublicKey");
+ }
return result;
}
- else
- { // session re-use accepted -------------------------------------
+ else // session re-use accepted -------------------------------------------
+ {
setupSecurityServices(true);
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendPublicKey()");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Session re-use accepted...");
+ if (Configuration.DEBUG)
+ {
+ log.fine("Session re-use accepted...");
+ log.exiting(this.getClass().getName(), "sendPublicKey");
+ }
return null;
}
}
private byte[] receiveEvidence(byte[] input) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> receiveEvidence()");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "S: " + Util.dumpString(input));
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "receiveEvidence");
+ log.fine("S: " + Util.dumpString(input));
+ }
// Server send M2, sIV, sCB, sid, ttl
final InputBuffer frameIn = new InputBuffer(input);
try
{
M2 = frameIn.getOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got M2 (server evidence): " + Util.dumpString(M2));
+ if (Configuration.DEBUG)
+ log.fine("Got M2 (server evidence): " + Util.dumpString(M2));
sIV = frameIn.getOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sIV (server IV): " + Util.dumpString(sIV));
+ if (Configuration.DEBUG)
+ log.fine("Got sIV (server IV): " + Util.dumpString(sIV));
sid = frameIn.getEOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sid (session ID): " + new String(sid));
+ if (Configuration.DEBUG)
+ log.fine("Got sid (session ID): " + new String(sid));
ttl = (int) frameIn.getScalar(4);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got ttl (session time-to-live): " + ttl + "sec.");
+ if (Configuration.DEBUG)
+ log.fine("Got ttl (session time-to-live): " + ttl + "sec.");
sCB = frameIn.getEOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sCB (server channel binding): "
- + Util.dumpString(sCB));
+ if (Configuration.DEBUG)
+ log.fine("Got sCB (server channel binding): " + Util.dumpString(sCB));
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("receiveEvidence()", x);
}
@@ -827,18 +640,13 @@ public class SRPClient extends ClientMechanism implements SaslClient
{
throw new AuthenticationException("receiveEvidence()", x);
}
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Expected: " + Util.dumpString(expected));
- if (!Arrays.equals(M2, expected))
- {
- throw new AuthenticationException("M2 mismatch");
- }
-
+ if (Configuration.DEBUG)
+ log.fine("Expected: " + Util.dumpString(expected));
+ if (! Arrays.equals(M2, expected))
+ throw new AuthenticationException("M2 mismatch");
setupSecurityServices(false);
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== receiveEvidence()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "receiveEvidence");
return null;
}
@@ -846,19 +654,15 @@ public class SRPClient extends ClientMechanism implements SaslClient
{
try
{
- if ((!properties.containsKey(Registry.SASL_USERNAME))
- && (!properties.containsKey(Registry.SASL_PASSWORD)))
+ if ((! properties.containsKey(Registry.SASL_USERNAME))
+ && (! properties.containsKey(Registry.SASL_PASSWORD)))
{
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
handler.handle(new Callback[] { nameCB, pwdCB });
@@ -868,21 +672,15 @@ public class SRPClient extends ClientMechanism implements SaslClient
else
{
if (properties.containsKey(Registry.SASL_USERNAME))
- {
- this.U = (String) properties.get(Registry.SASL_USERNAME);
- }
+ this.U = (String) properties.get(Registry.SASL_USERNAME);
else
{
final NameCallback nameCB;
final String defaultName = System.getProperty("user.name");
if (defaultName == null)
- {
- nameCB = new NameCallback("username: ");
- }
+ nameCB = new NameCallback("username: ");
else
- {
- nameCB = new NameCallback("username: ", defaultName);
- }
+ nameCB = new NameCallback("username: ", defaultName);
this.handler.handle(new Callback[] { nameCB });
this.U = nameCB.getName();
}
@@ -897,14 +695,12 @@ public class SRPClient extends ClientMechanism implements SaslClient
else if (pw instanceof String)
password = new Password(((String) pw).toCharArray());
else
- throw new IllegalArgumentException(
- pw.getClass().getName()
- + "is not a valid password class");
+ throw new IllegalArgumentException(pw.getClass().getName()
+ + "is not a valid password class");
}
else
{
- final PasswordCallback pwdCB = new PasswordCallback(
- "password: ",
+ final PasswordCallback pwdCB = new PasswordCallback("password: ",
false);
this.handler.handle(new Callback[] { pwdCB });
password = new Password(pwdCB.getPassword());
@@ -912,13 +708,9 @@ public class SRPClient extends ClientMechanism implements SaslClient
}
if (U == null)
- {
- throw new AuthenticationException("null username supplied");
- }
+ throw new AuthenticationException("null username supplied");
if (password == null)
- {
- throw new AuthenticationException("null password supplied");
- }
+ throw new AuthenticationException("null password supplied");
}
catch (UnsupportedCallbackException x)
{
@@ -935,9 +727,8 @@ public class SRPClient extends ClientMechanism implements SaslClient
// to us by the client.
private String createO(final String aol) throws AuthenticationException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> createO(\"" + aol + "\")");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "createO", aol);
boolean replaydetectionAvailable = false;
boolean integrityAvailable = false;
boolean confidentialityAvailable = false;
@@ -945,7 +736,6 @@ public class SRPClient extends ClientMechanism implements SaslClient
int i;
String mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
-
final StringTokenizer st = new StringTokenizer(aol, ",");
while (st.hasMoreTokens())
{
@@ -953,55 +743,45 @@ public class SRPClient extends ClientMechanism implements SaslClient
if (option.startsWith(SRPRegistry.OPTION_SRP_DIGEST + "="))
{
option = option.substring(option.indexOf('=') + 1);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "mda: <" + option + ">");
+ if (Configuration.DEBUG)
+ log.fine("mda: <" + option + ">");
for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
- {
- if (SRPRegistry.SRP_ALGORITHMS[i].equals(option))
- {
- mdName = option;
- break;
- }
- }
+ if (SRPRegistry.SRP_ALGORITHMS[i].equals(option))
+ {
+ mdName = option;
+ break;
+ }
}
else if (option.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
- {
- replaydetectionAvailable = true;
- }
+ replaydetectionAvailable = true;
else if (option.startsWith(SRPRegistry.OPTION_INTEGRITY + "="))
{
option = option.substring(option.indexOf('=') + 1);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "ialg: <" + option + ">");
+ if (Configuration.DEBUG)
+ log.fine("ialg: <" + option + ">");
for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
- {
- if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
- {
- chosenIntegrityAlgorithm = option;
- integrityAvailable = true;
- break;
- }
- }
+ if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
+ {
+ chosenIntegrityAlgorithm = option;
+ integrityAvailable = true;
+ break;
+ }
}
else if (option.startsWith(SRPRegistry.OPTION_CONFIDENTIALITY + "="))
{
option = option.substring(option.indexOf('=') + 1);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "calg: <" + option + ">");
+ if (Configuration.DEBUG)
+ log.fine("calg: <" + option + ">");
for (i = 0; i < SRPRegistry.CONFIDENTIALITY_ALGORITHMS.length; i++)
- {
- if (SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
- {
- chosenConfidentialityAlgorithm = option;
- confidentialityAvailable = true;
- break;
- }
- }
+ if (SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
+ {
+ chosenConfidentialityAlgorithm = option;
+ confidentialityAvailable = true;
+ break;
+ }
}
else if (option.startsWith(SRPRegistry.OPTION_MANDATORY + "="))
- {
- mandatory = option.substring(option.indexOf('=') + 1);
- }
+ mandatory = option.substring(option.indexOf('=') + 1);
else if (option.startsWith(SRPRegistry.OPTION_MAX_BUFFER_SIZE + "="))
{
final String maxBufferSize = option.substring(option.indexOf('=') + 1);
@@ -1010,32 +790,27 @@ public class SRPClient extends ClientMechanism implements SaslClient
rawSendSize = Integer.parseInt(maxBufferSize);
if (rawSendSize > Registry.SASL_BUFFER_MAX_LIMIT
|| rawSendSize < 1)
- {
- throw new AuthenticationException(
- "Illegal value for 'maxbuffersize' option");
- }
+ throw new AuthenticationException(
+ "Illegal value for 'maxbuffersize' option");
}
catch (NumberFormatException x)
{
throw new AuthenticationException(
- SRPRegistry.OPTION_MAX_BUFFER_SIZE
- + "="
- + String.valueOf(maxBufferSize),
- x);
+ SRPRegistry.OPTION_MAX_BUFFER_SIZE + "=" + maxBufferSize, x);
}
}
}
-
- replayDetection = replaydetectionAvailable
- && Boolean.valueOf(
- (String) properties.get(SRPRegistry.SRP_REPLAY_DETECTION)).booleanValue();
- boolean integrity = integrityAvailable
- && Boolean.valueOf(
- (String) properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION)).booleanValue();
- boolean confidentiality = confidentialityAvailable
- && Boolean.valueOf(
- (String) properties.get(SRPRegistry.SRP_CONFIDENTIALITY)).booleanValue();
-
+ String s;
+ Boolean flag;
+ s = (String) properties.get(SRPRegistry.SRP_REPLAY_DETECTION);
+ flag = Boolean.valueOf(s);
+ replayDetection = replaydetectionAvailable && flag.booleanValue();
+ s = (String) properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION);
+ flag = Boolean.valueOf(s);
+ boolean integrity = integrityAvailable && flag.booleanValue();
+ s = (String) properties.get(SRPRegistry.SRP_CONFIDENTIALITY);
+ flag = Boolean.valueOf(s);
+ boolean confidentiality = confidentialityAvailable && flag.booleanValue();
// make sure we do the right thing
if (SRPRegistry.OPTION_REPLAY_DETECTION.equals(mandatory))
{
@@ -1043,95 +818,68 @@ public class SRPClient extends ClientMechanism implements SaslClient
integrity = true;
}
else if (SRPRegistry.OPTION_INTEGRITY.equals(mandatory))
- {
- integrity = true;
- }
+ integrity = true;
else if (SRPRegistry.OPTION_CONFIDENTIALITY.equals(mandatory))
- {
- confidentiality = true;
- }
+ confidentiality = true;
+
if (replayDetection)
{
if (chosenIntegrityAlgorithm == null)
- {
- throw new AuthenticationException(
- "Replay detection is required but no "
- + "integrity protection algorithm was chosen");
- }
+ throw new AuthenticationException(
+ "Replay detection is required but no integrity protection "
+ + "algorithm was chosen");
}
if (integrity)
{
if (chosenIntegrityAlgorithm == null)
- {
- throw new AuthenticationException(
- "Integrity protection is required but no "
- + "algorithm was chosen");
- }
+ throw new AuthenticationException(
+ "Integrity protection is required but no algorithm was chosen");
}
if (confidentiality)
{
if (chosenConfidentialityAlgorithm == null)
- {
- throw new AuthenticationException(
- "Confidentiality protection is required "
- + "but no algorithm was chosen");
- }
+ throw new AuthenticationException(
+ "Confidentiality protection is required but no algorithm was chosen");
}
-
// 1. check if we'll be using confidentiality; if not set IV to 0-byte
if (chosenConfidentialityAlgorithm == null)
- {
- cIV = new byte[0];
- }
+ cIV = new byte[0];
else
{
// 2. get the block size of the cipher
final IBlockCipher cipher = CipherFactory.getInstance(chosenConfidentialityAlgorithm);
if (cipher == null)
- {
- throw new AuthenticationException("createO()",
- new NoSuchAlgorithmException());
- }
+ throw new AuthenticationException("createO()",
+ new NoSuchAlgorithmException());
final int blockSize = cipher.defaultBlockSize();
// 3. generate random iv
cIV = new byte[blockSize];
getDefaultPRNG().nextBytes(cIV);
}
-
srp = SRP.instance(mdName);
-
// Now create the options list specifying which of the available options
// we have chosen.
// For now we just select the defaults. Later we need to add support for
// properties (perhaps in a file) where a user can specify the list of
// algorithms they would prefer to use.
-
final StringBuffer sb = new StringBuffer();
- sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=").append(mdName).append(
- ",");
+ sb.append(SRPRegistry.OPTION_SRP_DIGEST)
+ .append("=").append(mdName).append(",");
if (replayDetection)
- {
- sb.append(SRPRegistry.OPTION_REPLAY_DETECTION).append(",");
- }
+ sb.append(SRPRegistry.OPTION_REPLAY_DETECTION).append(",");
if (integrity)
- {
- sb.append(SRPRegistry.OPTION_INTEGRITY).append("=").append(
- chosenIntegrityAlgorithm).append(
- ",");
- }
+ sb.append(SRPRegistry.OPTION_INTEGRITY)
+ .append("=").append(chosenIntegrityAlgorithm).append(",");
if (confidentiality)
- {
- sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=").append(
- chosenConfidentialityAlgorithm).append(
- ",");
- }
- final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE).append(
- "=").append(
- Registry.SASL_BUFFER_MAX_LIMIT).toString();
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== createO() --> " + result);
+ sb.append(SRPRegistry.OPTION_CONFIDENTIALITY)
+ .append("=").append(chosenConfidentialityAlgorithm).append(",");
+
+ final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE)
+ .append("=").append(Registry.SASL_BUFFER_MAX_LIMIT)
+ .toString();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "createO", result);
return result;
}
@@ -1139,33 +887,30 @@ public class SRPClient extends ClientMechanism implements SaslClient
throws SaslException
{
complete = true; // signal end of authentication phase
- if (!sessionReUse)
+ if (! sessionReUse)
{
outCounter = inCounter = 0;
// instantiate cipher if confidentiality protection filter is active
if (chosenConfidentialityAlgorithm != null)
{
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Activating confidentiality protection filter");
+ if (Configuration.DEBUG)
+ log.fine("Activating confidentiality protection filter");
inCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
outCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
}
// instantiate hmacs if integrity protection filter is active
if (chosenIntegrityAlgorithm != null)
{
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Activating integrity protection filter");
+ if (Configuration.DEBUG)
+ log.fine("Activating integrity protection filter");
inMac = IALG.getInstance(chosenIntegrityAlgorithm);
outMac = IALG.getInstance(chosenIntegrityAlgorithm);
}
}
- else
- { // same session new Keys
- K = srp.generateKn(K, cn, sn);
- }
+ else // same session new Keys
+ K = srp.generateKn(K, cn, sn);
final KDF kdf = KDF.getInstance(K);
-
// initialise in/out ciphers if confidentiality protection is used
if (inCipher != null)
{
@@ -1178,16 +923,13 @@ public class SRPClient extends ClientMechanism implements SaslClient
inMac.init(kdf);
outMac.init(kdf);
}
-
if (sid != null && sid.length != 0)
{ // update the security context and save in map
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Updating security context for UID = " + uid);
- ClientStore.instance().cacheSession(
- uid,
+ if (Configuration.DEBUG)
+ log.fine("Updating security context for UID = " + uid);
+ ClientStore.instance().cacheSession(uid,
ttl,
- new SecurityContext(
- srp.getAlgorithm(),
+ new SecurityContext(srp.getAlgorithm(),
sid,
K,
cIV,
@@ -1205,7 +947,6 @@ public class SRPClient extends ClientMechanism implements SaslClient
{
if (prng == null)
prng = PRNG.getInstance();
-
return prng;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPRegistry.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPRegistry.java
index 262cbcba305..d474cb6f8c2 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPRegistry.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPRegistry.java
@@ -41,35 +41,29 @@ package gnu.javax.crypto.sasl.srp;
import gnu.java.security.Registry;
/**
- * <p>A list of key names designating the values exchanged between the server
- * and client in an SRP communication authentication phase.</p>
+ * A list of key names designating the values exchanged between the server
+ * and client in an SRP communication authentication phase.
*/
public interface SRPRegistry
{
-
/** Indices of (N, g) parameter values for SRP (.conf) password database. */
String N_2048_BITS = "1";
-
String N_1536_BITS = "2";
-
String N_1280_BITS = "3";
-
String N_1024_BITS = "4";
-
String N_768_BITS = "5";
-
String N_640_BITS = "6";
-
String N_512_BITS = "7";
-
/** Available hash algorithms for all SRP calculations. */
- String[] SRP_ALGORITHMS = { Registry.SHA160_HASH, // the default one
- Registry.MD5_HASH, Registry.RIPEMD128_HASH,
- Registry.RIPEMD160_HASH,
-
- Registry.SHA256_HASH, Registry.SHA384_HASH,
- Registry.SHA512_HASH };
-
+ String[] SRP_ALGORITHMS = {
+ Registry.SHA160_HASH, // the default one
+ Registry.MD5_HASH,
+ Registry.RIPEMD128_HASH,
+ Registry.RIPEMD160_HASH,
+
+ Registry.SHA256_HASH,
+ Registry.SHA384_HASH,
+ Registry.SHA512_HASH };
/**
* The name of the default message digest algorithm to use when no name is
* explicitely given. In this implementation it is the <b>first</b> among
@@ -77,143 +71,95 @@ public interface SRPRegistry
* 160-bit output.
*/
String SRP_DEFAULT_DIGEST_NAME = SRP_ALGORITHMS[0];
-
/**
* The property name of the message digest algorithm name to use in a given
* SRP incarnation.
*/
String SRP_DIGEST_NAME = "srp.digest.name";
-
/** The public shared modulus: n. */
String SHARED_MODULUS = "srp.N";
-
/** The GF generator used: g. */
String FIELD_GENERATOR = "srp.g";
-
/** The list of server's available security options. */
String AVAILABLE_OPTIONS = "srp.L";
-
/** The client's chosen security options. */
String CHOSEN_OPTIONS = "srp.o";
-
/** The client's username. */
String USER_NAME = "srp.U";
-
/** The client's authorization ID. */
String USER_ROLE = "srp.I";
-
/** The user's salt. */
String USER_SALT = "srp.s";
-
/** The user's password verifier. */
String PASSWORD_VERIFIER = "srp.v";
-
/** The client's public ephemeral exponent: A. */
String CLIENT_PUBLIC_KEY = "srp.A";
-
/** The server's public ephemeral exponent: B. */
String SERVER_PUBLIC_KEY = "srp.B";
-
/** The client's evidence: M1. */
String CLIENT_EVIDENCE = "srp.M1";
-
/** The server's evidence: M2. */
String SERVER_EVIDENCE = "srp.M2";
-
/** Name of underlying hash algorithm for use with all SRP calculations. */
String SRP_HASH = "gnu.crypto.sasl.srp.hash";
-
/** Name of SRP mandatory service property. */
String SRP_MANDATORY = "gnu.crypto.sasl.srp.mandatory";
-
/** Name of SRP replay detection property. */
String SRP_REPLAY_DETECTION = "gnu.crypto.sasl.srp.replay.detection";
-
/** Name of SRP integrity protection property. */
String SRP_INTEGRITY_PROTECTION = "gnu.crypto.sasl.srp.integrity";
-
/** Name of SRP confidentiality protection property. */
String SRP_CONFIDENTIALITY = "gnu.crypto.sasl.srp.confidentiality";
-
/** Name of the main SRP password file pathname property. */
String PASSWORD_FILE = "gnu.crypto.sasl.srp.password.file";
-
/**
* Name of the SRP password database property --a reference to
- * {@link gnu.crypto.sasl.srp.PasswordFile} object.
+ * {@link PasswordFile} object.
*/
String PASSWORD_DB = "gnu.crypto.sasl.srp.password.db";
-
/** Default fully qualified pathname of the SRP password file. */
String DEFAULT_PASSWORD_FILE = "/etc/tpasswd";
-
/** Default value for replay detection security service. */
boolean DEFAULT_REPLAY_DETECTION = true;
-
/** Default value for integrity protection security service. */
boolean DEFAULT_INTEGRITY = true; // implied by the previous option
-
/** Default value for confidentiality protection security service. */
boolean DEFAULT_CONFIDENTIALITY = false;
-
// constants defining HMAC names
String HMAC_SHA1 = "hmac-sha1";
-
String HMAC_MD5 = "hmac-md5";
-
String HMAC_RIPEMD_160 = "hmac-ripemd-160";
-
/** Available HMAC algorithms for integrity protection. */
String[] INTEGRITY_ALGORITHMS = { HMAC_SHA1, HMAC_MD5, HMAC_RIPEMD_160 };
-
// constants defining Cipher names
String AES = "aes";
-
String BLOWFISH = "blowfish";
-
/** Available Cipher algorithms for confidentiality protection. */
String[] CONFIDENTIALITY_ALGORITHMS = { AES, BLOWFISH };
-
/** String for mandatory replay detection. */
String OPTION_MANDATORY = "mandatory";
-
/** String for mda: the SRP digest algorithm name. */
String OPTION_SRP_DIGEST = "mda";
-
/** String for mandatory replay detection. */
String OPTION_REPLAY_DETECTION = "replay_detection";
-
/** String for mandatory integrity protection. */
String OPTION_INTEGRITY = "integrity";
-
/** String for mandatory confidentiality protection. */
String OPTION_CONFIDENTIALITY = "confidentiality";
-
/** String for mandatory replay detection. */
String OPTION_MAX_BUFFER_SIZE = "maxbuffersize";
-
/** String for no mandatory security service. */
String MANDATORY_NONE = "none";
-
/** Default mandatory security service required. */
- // String DEFAULT_MANDATORY = MANDATORY_NONE;
String DEFAULT_MANDATORY = OPTION_REPLAY_DETECTION;
-
- // String DEFAULT_MANDATORY = OPTION_INTEGRITY;
- // String DEFAULT_MANDATORY = OPTION_CONFIDENTIALITY;
-
/** Name of the UID field in the plain password file. */
String MD_NAME_FIELD = "srp.md.name";
-
/** Name of the GID field in the plain password file. */
String USER_VERIFIER_FIELD = "srp.user.verifier";
-
/** Name of the GECOS field in the plain password file. */
String SALT_FIELD = "srp.salt";
-
/** Name of the SHELL field in the plain password file. */
String CONFIG_NDX_FIELD = "srp.config.ndx";
-
/** Minimum bitlength of the SRP public modulus. */
int MINIMUM_MODULUS_BITLENGTH = 512;
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
index 672660b261c..ff7e4e9d689 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
@@ -38,18 +38,18 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.srp;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.util.PRNG;
import gnu.java.security.util.Util;
-
import gnu.javax.crypto.assembly.Direction;
import gnu.javax.crypto.cipher.CipherFactory;
import gnu.javax.crypto.cipher.IBlockCipher;
import gnu.javax.crypto.key.IKeyAgreementParty;
-import gnu.javax.crypto.key.KeyAgreementFactory;
+import gnu.javax.crypto.key.IncomingMessage;
import gnu.javax.crypto.key.KeyAgreementException;
+import gnu.javax.crypto.key.KeyAgreementFactory;
import gnu.javax.crypto.key.OutgoingMessage;
-import gnu.javax.crypto.key.IncomingMessage;
import gnu.javax.crypto.key.srp6.SRP6KeyAgreement;
import gnu.javax.crypto.sasl.IllegalMechanismStateException;
import gnu.javax.crypto.sasl.InputBuffer;
@@ -57,114 +57,58 @@ import gnu.javax.crypto.sasl.IntegrityException;
import gnu.javax.crypto.sasl.OutputBuffer;
import gnu.javax.crypto.sasl.ServerMechanism;
-import java.io.IOException;
-import java.io.PrintWriter;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
+import java.util.logging.Logger;
import javax.security.sasl.AuthenticationException;
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
/**
- * <p>The SASL-SRP server-side mechanism.</p>
+ * The SASL-SRP server-side mechanism.
*/
-public class SRPServer extends ServerMechanism implements SaslServer
+public class SRPServer
+ extends ServerMechanism
+ implements SaslServer
{
-
- // Debugging methods and variables
- // -------------------------------------------------------------------------
-
- private static final String NAME = "SRPServer";
-
- // private static final String ERROR = "ERROR";
- private static final String WARN = " WARN";
-
- private static final String INFO = " INFO";
-
- private static final String TRACE = "DEBUG";
-
- private static final boolean DEBUG = true;
-
- private static final int debuglevel = 3;
-
- private static final PrintWriter err = new PrintWriter(System.out, true);
-
- private static void debug(final String level, final Object obj)
- {
- err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
- }
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
+ private static final Logger log = Logger.getLogger(SRPServer.class.getName());
private String U = null; // client's username
-
private BigInteger N, g, A, B;
-
private byte[] s; // salt
-
private byte[] cIV, sIV; // client+server IVs, when confidentiality is on
-
private byte[] cn, sn; // client's and server's nonce
-
private SRP srp; // SRP algorithm instance used by this server
-
private byte[] sid; // session ID when re-used
-
private int ttl = 360; // session time-to-live in seconds
-
private byte[] cCB; // peer's channel binding'
-
private String mandatory; // List of available options
-
private String L = null;
-
private String o;
-
private String chosenIntegrityAlgorithm;
-
private String chosenConfidentialityAlgorithm;
-
private int rawSendSize = Registry.SASL_BUFFER_MAX_LIMIT;
-
private byte[] K; // shared session key
-
private boolean replayDetection = true; // whether Replay Detection is on
-
private int inCounter = 0; // messages sequence numbers
-
private int outCounter = 0;
-
private IALG inMac, outMac; // if !null, use for integrity
-
private CALG inCipher, outCipher; // if !null, use for confidentiality
-
- private IKeyAgreementParty serverHandler = KeyAgreementFactory.getPartyBInstance(Registry.SRP_SASL_KA);
-
+ private IKeyAgreementParty serverHandler =
+ KeyAgreementFactory.getPartyBInstance(Registry.SRP_SASL_KA);
/** Our default source of randomness. */
private PRNG prng = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
public SRPServer()
{
super(Registry.SASL_SRP_MECHANISM);
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // abstract methods implementation -----------------------------------------
-
protected void initMechanism() throws SaslException
{
// TODO:
@@ -183,25 +127,20 @@ public class SRPServer extends ServerMechanism implements SaslServer
K = null;
inMac = outMac = null;
inCipher = outCipher = null;
-
sid = null;
}
- // javax.security.sasl.SaslServer interface implementation -----------------
-
public byte[] evaluateResponse(final byte[] response) throws SaslException
{
switch (state)
{
case 0:
if (response == null)
- {
- return null;
- }
+ return null;
state++;
return sendProtocolElements(response);
case 1:
- if (!complete)
+ if (! complete)
{
state++;
return sendEvidence(response);
@@ -215,65 +154,15 @@ public class SRPServer extends ServerMechanism implements SaslServer
protected byte[] engineUnwrap(final byte[] incoming, final int offset,
final int len) throws SaslException
{
- // if (DEBUG && debuglevel > 8) debug(TRACE, "==> engineUnwrap()");
- //
- // if (inMac == null && inCipher == null) {
- // throw new IllegalStateException("connection is not protected");
- // }
- //
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Incoming buffer (before security): "+Util.dumpString(incoming, offset, len));
- //
- // byte[] data = null;
- // try {
- // InputBuffer frameIn = InputBuffer.getInstance(incoming, offset, len);
- // data = frameIn.getEOS();
- // if (inMac != null) {
- // byte[] received_mac = frameIn.getOS();
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Got C (received MAC): "+Util.dumpString(received_mac));
- // inMac.update(data);
- // if (replayDetection) {
- // inCounter++;
- // if (DEBUG && debuglevel > 6) debug(TRACE, "inCounter="+String.valueOf(inCounter));
- // inMac.update(new byte[] {
- // (byte)(inCounter >>> 24),
- // (byte)(inCounter >>> 16),
- // (byte)(inCounter >>> 8),
- // (byte) inCounter });
- // }
- // final byte[] computed_mac = inMac.doFinal();
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Computed MAC: "+Util.dumpString(computed_mac));
- // if (!Arrays.equals(received_mac, computed_mac))
- // throw new IntegrityException("engineUnwrap()");
- // }
- // if (inCipher != null) {
- // data = inCipher.doFinal(data);
- // }
- // } catch (IOException x) {
- // if (x instanceof SaslException) {
- // throw (SaslException) x;
- // }
- // throw new SaslException("engineUnwrap()", x);
- // }
- //
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Incoming buffer (after security): "+Util.dumpString(data));
- // if (DEBUG && debuglevel > 8) debug(TRACE, "<== engineUnwrap()");
- // return data;
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> engineUnwrap()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineUnwrap");
if (inMac == null && inCipher == null)
- {
- throw new IllegalStateException("connection is not protected");
- }
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (before security): "
- + Util.dumpString(incoming, offset, len));
-
+ throw new IllegalStateException("connection is not protected");
+ if (Configuration.DEBUG)
+ log.fine("Incoming buffer (before security): "
+ + Util.dumpString(incoming, offset, len));
// at this point one, or both, of confidentiality and integrity protection
// services are active.
-
final byte[] result;
try
{
@@ -284,137 +173,67 @@ public class SRPServer extends ServerMechanism implements SaslServer
final byte[] received_mac = new byte[macBytesCount];
System.arraycopy(incoming, offset + payloadLength, received_mac, 0,
macBytesCount);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got C (received MAC): "
- + Util.dumpString(received_mac));
+ if (Configuration.DEBUG)
+ log.fine("Got C (received MAC): " + Util.dumpString(received_mac));
inMac.update(incoming, offset, payloadLength);
if (replayDetection)
{
inCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "inCounter=" + String.valueOf(inCounter));
- inMac.update(new byte[] { (byte) (inCounter >>> 24),
- (byte) (inCounter >>> 16),
- (byte) (inCounter >>> 8),
- (byte) inCounter });
+ if (Configuration.DEBUG)
+ log.fine("inCounter=" + String.valueOf(inCounter));
+ inMac.update(new byte[] {
+ (byte)(inCounter >>> 24),
+ (byte)(inCounter >>> 16),
+ (byte)(inCounter >>> 8),
+ (byte) inCounter });
}
-
final byte[] computed_mac = inMac.doFinal();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Computed MAC: " + Util.dumpString(computed_mac));
- if (!Arrays.equals(received_mac, computed_mac))
- {
- throw new IntegrityException("engineUnwrap()");
- }
-
+ if (Configuration.DEBUG)
+ log.fine("Computed MAC: " + Util.dumpString(computed_mac));
+ if (! Arrays.equals(received_mac, computed_mac))
+ throw new IntegrityException("engineUnwrap()");
// deal with the payload, which can be either plain or encrypted
if (inCipher != null)
- {
- result = inCipher.doFinal(incoming, offset, payloadLength);
- }
+ result = inCipher.doFinal(incoming, offset, payloadLength);
else
{
result = new byte[payloadLength];
System.arraycopy(incoming, offset, result, 0, result.length);
}
}
- else
- { // no integrity protection; just confidentiality
- // if (inCipher != null) {
- result = inCipher.doFinal(incoming, offset, len);
- // } else {
- // result = new byte[len];
- // System.arraycopy(incoming, offset, result, 0, len);
- // }
- }
+ else // no integrity protection; just confidentiality
+ result = inCipher.doFinal(incoming, offset, len);
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("engineUnwrap()", x);
}
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Incoming buffer (after security): "
- + Util.dumpString(result));
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== engineUnwrap()");
+ if (Configuration.DEBUG)
+ {
+ log.fine("Incoming buffer (after security): " + Util.dumpString(result));
+ log.exiting(this.getClass().getName(), "engineUnwrap");
+ }
return result;
}
protected byte[] engineWrap(final byte[] outgoing, final int offset,
final int len) throws SaslException
{
- // if (DEBUG && debuglevel > 8) debug(TRACE, "==> engineWrap()");
- //
- // if (outMac == null && outCipher == null) {
- // throw new IllegalStateException("connection is not protected");
- // }
- //
- // byte[] data = new byte[len];
- // System.arraycopy(outgoing, offset, data, 0, len);
- //
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Outgoing buffer (before security) (hex): "+Util.dumpString(data));
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Outgoing buffer (before security) (str): \""+new String(data)+"\"");
- //
- // final byte[] result;
- // try {
- // OutputBuffer frameOut = new OutputBuffer();
- // // Process the data
- // if (outCipher != null) {
- // data = outCipher.doFinal(data);
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding c (encrypted plaintext): "+Util.dumpString(data));
- // } else {
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding p (plaintext): "+Util.dumpString(data));
- // }
- // frameOut.setEOS(data);
- // if (outMac != null) {
- // outMac.update(data);
- // if (replayDetection) {
- // outCounter++;
- // if (DEBUG && debuglevel > 6) debug(TRACE, "outCounter="+String.valueOf(outCounter));
- // outMac.update(new byte[] {
- // (byte)(outCounter >>> 24),
- // (byte)(outCounter >>> 16),
- // (byte)(outCounter >>> 8),
- // (byte) outCounter});
- // }
- // byte[] C = outMac.doFinal();
- // frameOut.setOS(C);
- // if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding C (integrity checksum): "+Util.dumpString(C));
- // }
- // result = frameOut.wrap();
- //
- // } catch (IOException x) {
- // if (x instanceof SaslException) {
- // throw (SaslException) x;
- // }
- // throw new SaslException("engineWrap()", x);
- // }
- //
- // if (DEBUG && debuglevel > 8) debug(TRACE, "<== engineWrap()");
- // return result;
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> engineWrap()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "engineWrap");
if (outMac == null && outCipher == null)
+ throw new IllegalStateException("connection is not protected");
+ if (Configuration.DEBUG)
{
- throw new IllegalStateException("connection is not protected");
+ log.fine("Outgoing buffer (before security) (hex): "
+ + Util.dumpString(outgoing, offset, len));
+ log.fine("Outgoing buffer (before security) (str): \""
+ + new String(outgoing, offset, len) + "\"");
}
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (before security) (hex): "
- + Util.dumpString(outgoing, offset, len));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Outgoing buffer (before security) (str): \""
- + new String(outgoing, offset, len) + "\"");
-
// at this point one, or both, of confidentiality and integrity protection
// services are active.
-
byte[] result;
try
{
@@ -422,74 +241,64 @@ public class SRPServer extends ServerMechanism implements SaslServer
if (outCipher != null)
{
result = outCipher.doFinal(outgoing, offset, len);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding c (encrypted plaintext): "
- + Util.dumpString(result));
-
+ if (Configuration.DEBUG)
+ log.fine("Encoding c (encrypted plaintext): "
+ + Util.dumpString(result));
out.write(result);
-
if (outMac != null)
{
outMac.update(result);
if (replayDetection)
{
outCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "outCounter=" + String.valueOf(outCounter));
- outMac.update(new byte[] { (byte) (outCounter >>> 24),
- (byte) (outCounter >>> 16),
- (byte) (outCounter >>> 8),
- (byte) outCounter });
+ if (Configuration.DEBUG)
+ log.fine("outCounter=" + outCounter);
+ outMac.update(new byte[] {
+ (byte)(outCounter >>> 24),
+ (byte)(outCounter >>> 16),
+ (byte)(outCounter >>> 8),
+ (byte) outCounter });
}
final byte[] C = outMac.doFinal();
out.write(C);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding C (integrity checksum): "
- + Util.dumpString(C));
- } // else ciphertext only; do nothing
+ if (Configuration.DEBUG)
+ log.fine("Encoding C (integrity checksum): " + Util.dumpString(C));
+ }
+ // else ciphertext only; do nothing
}
- else
- { // no confidentiality; just integrity [+ replay detection]
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding p (plaintext): "
- + Util.dumpString(outgoing, offset, len));
-
+ else // no confidentiality; just integrity [+ replay detection]
+ {
+ if (Configuration.DEBUG)
+ log.fine("Encoding p (plaintext): "
+ + Util.dumpString(outgoing, offset, len));
out.write(outgoing, offset, len);
-
- // if (outMac != null) {
outMac.update(outgoing, offset, len);
if (replayDetection)
{
outCounter++;
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "outCounter=" + String.valueOf(outCounter));
- outMac.update(new byte[] { (byte) (outCounter >>> 24),
- (byte) (outCounter >>> 16),
- (byte) (outCounter >>> 8),
- (byte) outCounter });
+ if (Configuration.DEBUG)
+ log.fine("outCounter=" + outCounter);
+ outMac.update(new byte[] {
+ (byte)(outCounter >>> 24),
+ (byte)(outCounter >>> 16),
+ (byte)(outCounter >>> 8),
+ (byte) outCounter });
}
final byte[] C = outMac.doFinal();
out.write(C);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding C (integrity checksum): "
- + Util.dumpString(C));
- // } // else plaintext only; do nothing
+ if (Configuration.DEBUG)
+ log.fine("Encoding C (integrity checksum): " + Util.dumpString(C));
}
-
result = out.toByteArray();
-
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new SaslException("engineWrap()", x);
}
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== engineWrap()");
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "engineWrap");
return result;
}
@@ -498,13 +307,8 @@ public class SRPServer extends ServerMechanism implements SaslServer
if (inMac != null)
{
if (inCipher != null)
- {
- return Registry.QOP_AUTH_CONF;
- }
- else
- {
- return Registry.QOP_AUTH_INT;
- }
+ return Registry.QOP_AUTH_CONF;
+ return Registry.QOP_AUTH_INT;
}
return Registry.QOP_AUTH;
}
@@ -514,13 +318,8 @@ public class SRPServer extends ServerMechanism implements SaslServer
if (inMac != null)
{
if (inCipher != null)
- {
- return Registry.STRENGTH_HIGH;
- }
- else
- {
- return Registry.STRENGTH_MEDIUM;
- }
+ return Registry.STRENGTH_HIGH;
+ return Registry.STRENGTH_MEDIUM;
}
return Registry.STRENGTH_LOW;
}
@@ -535,45 +334,39 @@ public class SRPServer extends ServerMechanism implements SaslServer
return Registry.REUSE_TRUE;
}
- // other methods -----------------------------------------------------------
-
private byte[] sendProtocolElements(final byte[] input) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> sendProtocolElements()");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "C: " + Util.dumpString(input));
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "sendProtocolElements");
+ log.fine("C: " + Util.dumpString(input));
+ }
// Client send U, I, sid, cn
final InputBuffer frameIn = new InputBuffer(input);
try
{
U = frameIn.getText(); // Extract username
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got U (username): \"" + U + "\"");
+ if (Configuration.DEBUG)
+ log.fine("Got U (username): \"" + U + "\"");
authorizationID = frameIn.getText(); // Extract authorisation ID
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got I (userid): \"" + authorizationID + "\"");
+ if (Configuration.DEBUG)
+ log.fine("Got I (userid): \"" + authorizationID + "\"");
sid = frameIn.getEOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got sid (session ID): " + new String(sid));
+ if (Configuration.DEBUG)
+ log.fine("Got sid (session ID): " + new String(sid));
cn = frameIn.getOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got cn (client nonce): " + Util.dumpString(cn));
+ if (Configuration.DEBUG)
+ log.fine("Got cn (client nonce): " + Util.dumpString(cn));
cCB = frameIn.getEOS();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got cCB (client channel binding): "
- + Util.dumpString(cCB));
+ if (Configuration.DEBUG)
+ log.fine("Got cCB (client channel binding): " + Util.dumpString(cCB));
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendProtocolElements()", x);
}
-
// do/can we re-use?
if (ServerStore.instance().isAlive(sid))
{
@@ -589,15 +382,10 @@ public class SRPServer extends ServerMechanism implements SaslServer
outMac = ctx.getOutMac();
inCipher = ctx.getInCipher();
outCipher = ctx.getOutCipher();
-
if (sn == null || sn.length != 16)
- {
- sn = new byte[16];
- }
+ sn = new byte[16];
getDefaultPRNG().nextBytes(sn);
-
setupSecurityServices(false);
-
final OutputBuffer frameOut = new OutputBuffer();
try
{
@@ -608,34 +396,27 @@ public class SRPServer extends ServerMechanism implements SaslServer
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendProtocolElements()", x);
}
final byte[] result = frameOut.encode();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendProtocolElements()");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Old session...");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "S: " + Util.dumpString(result));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " sn = " + Util.dumpString(sn));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " sCB = " + Util.dumpString(channelBinding));
+ if (Configuration.DEBUG)
+ {
+ log.fine("Old session...");
+ log.fine("S: " + Util.dumpString(result));
+ log.fine(" sn = " + Util.dumpString(sn));
+ log.fine(" sCB = " + Util.dumpString(channelBinding));
+ log.exiting(this.getClass().getName(), "sendProtocolElements");
+ }
return result;
}
else
{ // new session
authenticator.activate(properties);
-
// -------------------------------------------------------------------
final HashMap mapB = new HashMap();
- // mapB.put(SRP6KeyAgreement.HASH_FUNCTION, srp.newDigest());
mapB.put(SRP6KeyAgreement.HASH_FUNCTION, srp.getAlgorithm());
mapB.put(SRP6KeyAgreement.HOST_PASSWORD_DB, authenticator);
-
try
{
serverHandler.init(mapB);
@@ -643,7 +424,6 @@ public class SRPServer extends ServerMechanism implements SaslServer
out.writeString(U);
IncomingMessage in = new IncomingMessage(out.toByteArray());
out = serverHandler.processMessage(in);
-
in = new IncomingMessage(out.toByteArray());
N = in.readMPI();
g = in.readMPI();
@@ -655,26 +435,22 @@ public class SRPServer extends ServerMechanism implements SaslServer
throw new SaslException("sendProtocolElements()", x);
}
// -------------------------------------------------------------------
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding N (modulus): " + Util.dump(N));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding g (generator): " + Util.dump(g));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding s (client's salt): " + Util.dumpString(s));
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding B (server ephemeral public key): "
- + Util.dump(B));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("Encoding N (modulus): " + Util.dump(N));
+ log.fine("Encoding g (generator): " + Util.dump(g));
+ log.fine("Encoding s (client's salt): " + Util.dumpString(s));
+ log.fine("Encoding B (server ephemeral public key): " + Util.dump(B));
+ }
// The server creates an options list (L), which consists of a
// comma-separated list of option strings that specify the security
// service options the server supports.
L = createL();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding L (available options): \"" + L + "\"");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Encoding sIV (server IV): " + Util.dumpString(sIV));
-
+ if (Configuration.DEBUG)
+ {
+ log.fine("Encoding L (available options): \"" + L + "\"");
+ log.fine("Encoding sIV (server IV): " + Util.dumpString(sIV));
+ }
final OutputBuffer frameOut = new OutputBuffer();
try
{
@@ -688,69 +464,58 @@ public class SRPServer extends ServerMechanism implements SaslServer
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendProtocolElements()", x);
}
final byte[] result = frameOut.encode();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendProtocolElements()");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "New session...");
- if (DEBUG && debuglevel > 2)
- debug(INFO, "S: " + Util.dumpString(result));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " N = 0x" + N.toString(16));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " g = 0x" + g.toString(16));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " s = " + Util.dumpString(s));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " B = 0x" + B.toString(16));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " L = " + L);
+ if (Configuration.DEBUG)
+ {
+ log.fine("New session...");
+ log.fine("S: " + Util.dumpString(result));
+ log.fine(" N = 0x" + N.toString(16));
+ log.fine(" g = 0x" + g.toString(16));
+ log.fine(" s = " + Util.dumpString(s));
+ log.fine(" B = 0x" + B.toString(16));
+ log.fine(" L = " + L);
+ log.exiting(this.getClass().getName(), "sendProtocolElements");
+ }
return result;
}
}
private byte[] sendEvidence(final byte[] input) throws SaslException
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> sendEvidence()");
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "C: " + Util.dumpString(input));
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "sendEvidence");
+ log.fine("C: " + Util.dumpString(input));
+ }
// Client send A, M1, o, cIV
final InputBuffer frameIn = new InputBuffer(input);
final byte[] M1;
try
{
A = frameIn.getMPI(); // Extract client's ephemeral public key
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got A (client ephemeral public key): " + Util.dump(A));
+ if (Configuration.DEBUG)
+ log.fine("Got A (client ephemeral public key): " + Util.dump(A));
M1 = frameIn.getOS(); // Extract evidence
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got M1 (client evidence): " + Util.dumpString(M1));
+ if (Configuration.DEBUG)
+ log.fine("Got M1 (client evidence): " + Util.dumpString(M1));
o = frameIn.getText(); // Extract client's options list
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got o (client chosen options): \"" + o + "\"");
+ if (Configuration.DEBUG)
+ log.fine("Got o (client chosen options): \"" + o + "\"");
cIV = frameIn.getOS(); // Extract client's IV
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "Got cIV (client IV): " + Util.dumpString(cIV));
+ if (Configuration.DEBUG)
+ log.fine("Got cIV (client IV): " + Util.dumpString(cIV));
}
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendEvidence()", x);
}
-
// Parse client's options and set security layer variables
parseO(o);
-
// ----------------------------------------------------------------------
try
{
@@ -765,10 +530,8 @@ public class SRPServer extends ServerMechanism implements SaslServer
throw new SaslException("sendEvidence()", x);
}
// ----------------------------------------------------------------------
-
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "K: " + Util.dumpString(K));
-
+ if (Configuration.DEBUG)
+ log.fine("K: " + Util.dumpString(K));
final byte[] expected;
try
{
@@ -779,15 +542,10 @@ public class SRPServer extends ServerMechanism implements SaslServer
{
throw new AuthenticationException("sendEvidence()", x);
}
-
// Verify client evidence
- if (!Arrays.equals(M1, expected))
- {
- throw new AuthenticationException("M1 mismatch");
- }
-
+ if (! Arrays.equals(M1, expected))
+ throw new AuthenticationException("M1 mismatch");
setupSecurityServices(true);
-
final byte[] M2;
try
{
@@ -798,7 +556,6 @@ public class SRPServer extends ServerMechanism implements SaslServer
{
throw new AuthenticationException("sendEvidence()", x);
}
-
final OutputBuffer frameOut = new OutputBuffer();
try
{
@@ -811,93 +568,71 @@ public class SRPServer extends ServerMechanism implements SaslServer
catch (IOException x)
{
if (x instanceof SaslException)
- {
- throw (SaslException) x;
- }
+ throw (SaslException) x;
throw new AuthenticationException("sendEvidence()", x);
}
final byte[] result = frameOut.encode();
- if (DEBUG && debuglevel > 2)
- debug(INFO, "S: " + Util.dumpString(result));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " M2 = " + Util.dumpString(M2));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " sIV = " + Util.dumpString(sIV));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " sid = " + new String(sid));
- if (DEBUG && debuglevel > 2)
- debug(INFO, " ttl = " + ttl);
- if (DEBUG && debuglevel > 2)
- debug(INFO, " sCB = " + Util.dumpString(channelBinding));
-
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== sendEvidence()");
+ if (Configuration.DEBUG)
+ {
+ log.fine("S: " + Util.dumpString(result));
+ log.fine(" M2 = " + Util.dumpString(M2));
+ log.fine(" sIV = " + Util.dumpString(sIV));
+ log.fine(" sid = " + new String(sid));
+ log.fine(" ttl = " + ttl);
+ log.fine(" sCB = " + Util.dumpString(channelBinding));
+ log.exiting(this.getClass().getName(), "sendEvidence");
+ }
return result;
}
private String createL()
{
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "==> createL()");
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "createL()");
String s = (String) properties.get(SRPRegistry.SRP_MANDATORY);
if (s == null)
+ s = SRPRegistry.DEFAULT_MANDATORY;
+
+ if (! SRPRegistry.MANDATORY_NONE.equals(s)
+ && ! SRPRegistry.OPTION_REPLAY_DETECTION.equals(s)
+ && ! SRPRegistry.OPTION_INTEGRITY.equals(s)
+ && ! SRPRegistry.OPTION_CONFIDENTIALITY.equals(s))
{
+ if (Configuration.DEBUG)
+ log.fine("Unrecognised mandatory option (" + s + "). Using default...");
s = SRPRegistry.DEFAULT_MANDATORY;
}
- if (!SRPRegistry.MANDATORY_NONE.equals(s)
- && !SRPRegistry.OPTION_REPLAY_DETECTION.equals(s)
- && !SRPRegistry.OPTION_INTEGRITY.equals(s)
- && !SRPRegistry.OPTION_CONFIDENTIALITY.equals(s))
- {
- if (DEBUG && debuglevel > 4)
- debug(WARN, "Unrecognised mandatory option (" + s
- + "). Using default...");
- s = SRPRegistry.DEFAULT_MANDATORY;
- }
-
mandatory = s;
-
s = (String) properties.get(SRPRegistry.SRP_CONFIDENTIALITY);
final boolean confidentiality = (s == null ? SRPRegistry.DEFAULT_CONFIDENTIALITY
- : Boolean.valueOf(s).booleanValue());
-
+ : Boolean.valueOf(s).booleanValue());
s = (String) properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION);
boolean integrity = (s == null ? SRPRegistry.DEFAULT_INTEGRITY
- : Boolean.valueOf(s).booleanValue());
-
+ : Boolean.valueOf(s).booleanValue());
s = (String) properties.get(SRPRegistry.SRP_REPLAY_DETECTION);
final boolean replayDetection = (s == null ? SRPRegistry.DEFAULT_REPLAY_DETECTION
- : Boolean.valueOf(s).booleanValue());
-
+ : Boolean.valueOf(s).booleanValue());
final StringBuffer sb = new StringBuffer();
- sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=").append(
- srp.getAlgorithm()).append(
- ",");
+ sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=")
+ .append(srp.getAlgorithm()).append(",");
+
+ if (! SRPRegistry.MANDATORY_NONE.equals(mandatory))
+ sb.append(SRPRegistry.OPTION_MANDATORY)
+ .append("=").append(mandatory).append(",");
- if (!SRPRegistry.MANDATORY_NONE.equals(mandatory))
- {
- sb.append(SRPRegistry.OPTION_MANDATORY).append("=").append(mandatory).append(
- ",");
- }
if (replayDetection)
{
sb.append(SRPRegistry.OPTION_REPLAY_DETECTION).append(",");
// if replay detection is on then force integrity protection
integrity = true;
}
-
int i;
if (integrity)
{
for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
- {
- sb.append(SRPRegistry.OPTION_INTEGRITY).append("=").append(
- SRPRegistry.INTEGRITY_ALGORITHMS[i]).append(
- ",");
- }
+ sb.append(SRPRegistry.OPTION_INTEGRITY).append("=")
+ .append(SRPRegistry.INTEGRITY_ALGORITHMS[i]).append(",");
}
-
if (confidentiality)
{
IBlockCipher cipher;
@@ -905,19 +640,15 @@ public class SRPServer extends ServerMechanism implements SaslServer
{
cipher = CipherFactory.getInstance(SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]);
if (cipher != null)
- {
- sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=").append(
- SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]).append(
- ",");
- }
+ sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=")
+ .append(SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]).append(",");
}
}
-
- final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE).append(
- "=").append(
- Registry.SASL_BUFFER_MAX_LIMIT).toString();
- if (DEBUG && debuglevel > 8)
- debug(TRACE, "<== createL()");
+ final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE)
+ .append("=").append(Registry.SASL_BUFFER_MAX_LIMIT)
+ .toString();
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "createL");
return result;
}
@@ -934,69 +665,51 @@ public class SRPServer extends ServerMechanism implements SaslServer
while (st.hasMoreTokens())
{
option = st.nextToken();
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "option: <" + option + ">");
+ if (Configuration.DEBUG)
+ log.fine("option: <" + option + ">");
if (option.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
- {
- replayDetection = true;
- }
+ replayDetection = true;
else if (option.startsWith(SRPRegistry.OPTION_INTEGRITY + "="))
{
if (integrity)
+ throw new AuthenticationException(
+ "Only one integrity algorithm may be chosen");
+ option = option.substring(option.indexOf('=') + 1);
+ if (Configuration.DEBUG)
+ log.fine("algorithm: <" + option + ">");
+ for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
{
- throw new AuthenticationException(
- "Only one integrity algorithm may be chosen");
- }
- else
- {
- option = option.substring(option.indexOf('=') + 1);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "algorithm: <" + option + ">");
- for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
- {
- if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
- {
- chosenIntegrityAlgorithm = option;
- integrity = true;
- break;
- }
- }
- if (!integrity)
+ if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
{
- throw new AuthenticationException(
- "Unknown integrity algorithm: "
- + option);
+ chosenIntegrityAlgorithm = option;
+ integrity = true;
+ break;
}
}
+ if (! integrity)
+ throw new AuthenticationException("Unknown integrity algorithm: "
+ + option);
}
else if (option.startsWith(SRPRegistry.OPTION_CONFIDENTIALITY + "="))
{
if (confidentiality)
+ throw new AuthenticationException(
+ "Only one confidentiality algorithm may be chosen");
+ option = option.substring(option.indexOf('=') + 1);
+ if (Configuration.DEBUG)
+ log.fine("algorithm: <" + option + ">");
+ for (i = 0; i < SRPRegistry.CONFIDENTIALITY_ALGORITHMS.length; i++)
{
- throw new AuthenticationException(
- "Only one confidentiality algorithm may be chosen");
- }
- else
- {
- option = option.substring(option.indexOf('=') + 1);
- if (DEBUG && debuglevel > 6)
- debug(TRACE, "algorithm: <" + option + ">");
- for (i = 0; i < SRPRegistry.CONFIDENTIALITY_ALGORITHMS.length; i++)
- {
- if (SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
- {
- chosenConfidentialityAlgorithm = option;
- confidentiality = true;
- break;
- }
- }
- if (!confidentiality)
+ if (SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
{
- throw new AuthenticationException(
- "Unknown confidentiality algorithm: "
- + option);
+ chosenConfidentialityAlgorithm = option;
+ confidentiality = true;
+ break;
}
}
+ if (! confidentiality)
+ throw new AuthenticationException("Unknown confidentiality algorithm: "
+ + option);
}
else if (option.startsWith(SRPRegistry.OPTION_MAX_BUFFER_SIZE + "="))
{
@@ -1007,70 +720,51 @@ public class SRPServer extends ServerMechanism implements SaslServer
if (rawSendSize > Registry.SASL_BUFFER_MAX_LIMIT
|| rawSendSize < 1)
throw new AuthenticationException(
- "Illegal value for 'maxbuffersize' option");
+ "Illegal value for 'maxbuffersize' option");
}
catch (NumberFormatException x)
{
throw new AuthenticationException(
- SRPRegistry.OPTION_MAX_BUFFER_SIZE
- + "="
- + String.valueOf(maxBufferSize),
- x);
+ SRPRegistry.OPTION_MAX_BUFFER_SIZE + "=" + maxBufferSize, x);
}
}
}
-
// check if client did the right thing
if (replayDetection)
{
- if (!integrity)
- {
- throw new AuthenticationException(
- "Missing integrity protection algorithm "
- + "but replay detection is chosen");
- }
+ if (! integrity)
+ throw new AuthenticationException(
+ "Missing integrity protection algorithm but replay detection is chosen");
}
if (mandatory.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
{
- if (!replayDetection)
- {
- throw new AuthenticationException(
- "Replay detection is mandatory but was not chosen");
- }
+ if (! replayDetection)
+ throw new AuthenticationException(
+ "Replay detection is mandatory but was not chosen");
}
if (mandatory.equals(SRPRegistry.OPTION_INTEGRITY))
{
- if (!integrity)
- {
- throw new AuthenticationException(
- "Integrity protection is mandatory but was not chosen");
- }
+ if (! integrity)
+ throw new AuthenticationException(
+ "Integrity protection is mandatory but was not chosen");
}
if (mandatory.equals(SRPRegistry.OPTION_CONFIDENTIALITY))
{
- if (!confidentiality)
- {
- throw new AuthenticationException(
- "Confidentiality is mandatory but was not chosen");
- }
+ if (! confidentiality)
+ throw new AuthenticationException(
+ "Confidentiality is mandatory but was not chosen");
}
-
int blockSize = 0;
if (chosenConfidentialityAlgorithm != null)
{
final IBlockCipher cipher = CipherFactory.getInstance(chosenConfidentialityAlgorithm);
if (cipher != null)
- {
- blockSize = cipher.defaultBlockSize();
- }
- else
- { // should not happen
- throw new AuthenticationException("Confidentiality algorithm ("
- + chosenConfidentialityAlgorithm
- + ") not available");
- }
+ blockSize = cipher.defaultBlockSize();
+ else // should not happen
+ throw new AuthenticationException("Confidentiality algorithm ("
+ + chosenConfidentialityAlgorithm
+ + ") not available");
}
-
sIV = new byte[blockSize];
if (blockSize > 0)
getDefaultPRNG().nextBytes(sIV);
@@ -1086,30 +780,26 @@ public class SRPServer extends ServerMechanism implements SaslServer
// instantiate cipher if confidentiality protection filter is active
if (chosenConfidentialityAlgorithm != null)
{
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Activating confidentiality protection filter");
+ if (Configuration.DEBUG)
+ log.fine("Activating confidentiality protection filter");
inCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
outCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
}
// instantiate hmacs if integrity protection filter is active
if (chosenIntegrityAlgorithm != null)
{
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Activating integrity protection filter");
+ if (Configuration.DEBUG)
+ log.fine("Activating integrity protection filter");
inMac = IALG.getInstance(chosenIntegrityAlgorithm);
outMac = IALG.getInstance(chosenIntegrityAlgorithm);
}
-
// generate a new sid if at least integrity is used
sid = (inMac != null ? ServerStore.getNewSessionID() : new byte[0]);
}
- else
- { // same session new keys
- K = srp.generateKn(K, cn, sn);
- }
+ else // same session new keys
+ K = srp.generateKn(K, cn, sn);
final KDF kdf = KDF.getInstance(K);
-
// initialise in/out ciphers if confidentaility protection is used
if (inCipher != null)
{
@@ -1122,15 +812,12 @@ public class SRPServer extends ServerMechanism implements SaslServer
outMac.init(kdf);
inMac.init(kdf);
}
-
if (sid != null && sid.length != 0)
{ // update the security context and save in map
- if (DEBUG && debuglevel > 2)
- debug(INFO, "Updating security context for sid = " + new String(sid));
- ServerStore.instance().cacheSession(
- ttl,
- new SecurityContext(
- srp.getAlgorithm(),
+ if (Configuration.DEBUG)
+ log.fine("Updating security context for sid = " + new String(sid));
+ ServerStore.instance().cacheSession(ttl,
+ new SecurityContext(srp.getAlgorithm(),
sid,
K,
cIV,
@@ -1148,7 +835,6 @@ public class SRPServer extends ServerMechanism implements SaslServer
{
if (prng == null)
prng = PRNG.getInstance();
-
return prng;
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SecurityContext.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SecurityContext.java
index feca25cadb8..1111d95b4f0 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SecurityContext.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SecurityContext.java
@@ -39,41 +39,23 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.srp;
/**
- * <p>A package-private placeholder for an SRP security context.</p>
+ * A package-private placeholder for an SRP security context.
*/
class SecurityContext
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private String mdName;
-
private byte[] sid;
-
private byte[] K;
-
private byte[] cIV;
-
private byte[] sIV;
-
private boolean replayDetection;
-
private int inCounter;
-
private int outCounter;
-
private IALG inMac;
-
private IALG outMac;
-
private CALG inCipher;
-
private CALG outCipher;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
SecurityContext(final String mdName, final byte[] sid, final byte[] K,
final byte[] cIV, final byte[] sIV,
final boolean replayDetection, final int inCounter,
@@ -96,12 +78,6 @@ class SecurityContext
this.outCipher = outCipher;
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
String getMdName()
{
return mdName;
@@ -161,4 +137,4 @@ class SecurityContext
{
return outCipher;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/ServerStore.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/ServerStore.java
index 99bf96a9444..e9b1a728273 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/ServerStore.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/ServerStore.java
@@ -41,32 +41,21 @@ package gnu.javax.crypto.sasl.srp;
import java.util.HashMap;
/**
- * <p>The server-side implementation of the SRP security context store.</p>
+ * The server-side implementation of the SRP security context store.
*/
public class ServerStore
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
/** The underlying singleton. */
private static ServerStore singleton = null;
-
/** The map of sid --> Security Context record. */
private static final HashMap sid2ssc = new HashMap();
-
/** The map of sid --> Session timing record. */
private static final HashMap sid2ttl = new HashMap();
-
/** A synchronisation lock. */
private static final Object lock = new Object();
-
/** A counter to generate legible SIDs. */
private static int counter = 0;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
/** Private constructor to enforce Singleton pattern. */
private ServerStore()
{
@@ -75,48 +64,38 @@ public class ServerStore
// TODO: add a cleaning timer thread
}
- // Class methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns the classloader Singleton.</p>
- *
+ * Returns the classloader Singleton.
+ *
* @return the classloader Singleton instance.
*/
static synchronized final ServerStore instance()
{
if (singleton == null)
- {
- singleton = new ServerStore();
- }
+ singleton = new ServerStore();
return singleton;
}
/**
- * <p>Returns a legible new session identifier.</p>
- *
+ * Returns a legible new session identifier.
+ *
* @return a new session identifier.
*/
static synchronized final byte[] getNewSessionID()
{
final String sid = String.valueOf(++counter);
- return new StringBuffer("SID-").append(
- "0000000000".substring(
- 0,
- 10 - sid.length())).append(
- sid).toString().getBytes();
+ return new StringBuffer("SID-")
+ .append("0000000000".substring(0, 10 - sid.length())).append(sid)
+ .toString().getBytes();
}
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns a boolean flag indicating if the designated session is still
- * alive or not.</p>
- *
+ * Returns a boolean flag indicating if the designated session is still alive
+ * or not.
+ *
* @param sid the identifier of the session to check.
* @return <code>true</code> if the designated session is still alive.
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
boolean isAlive(final byte[] sid)
{
@@ -130,8 +109,8 @@ public class ServerStore
if (ctx != null)
{
result = ctx.isAlive();
- if (!result)
- { // invalidate it en-passant
+ if (! result) // invalidate it en-passant
+ {
sid2ssc.remove(key);
sid2ttl.remove(key);
}
@@ -142,9 +121,9 @@ public class ServerStore
}
/**
- * <p>Records a mapping between a session identifier and the Security Context
- * of the designated SRP server mechanism instance.</p>
- *
+ * Records a mapping between a session identifier and the Security Context of
+ * the designated SRP server mechanism instance.
+ *
* @param ttl the session's Time-To-Live indicator (in seconds).
* @param ctx the server's security context.
*/
@@ -159,11 +138,11 @@ public class ServerStore
}
/**
- * <p>Updates the mapping between the designated session identifier and the
- * designated server's SASL Security Context. In the process, computes
- * and return the underlying mechanism server's evidence that shall be
- * returned to the client in a session re-use exchange.</p>
- *
+ * Updates the mapping between the designated session identifier and the
+ * designated server's SASL Security Context. In the process, computes and
+ * return the underlying mechanism server's evidence that shall be returned to
+ * the client in a session re-use exchange.
+ *
* @param sid the identifier of the session to restore.
* @return an SRP server's security context.
*/
@@ -180,8 +159,8 @@ public class ServerStore
}
/**
- * <p>Removes all information related to the designated session ID.</p>
- *
+ * Removes all information related to the designated session ID.
+ *
* @param sid the identifier of the seesion to invalidate.
*/
void invalidateSession(final byte[] sid)
@@ -193,4 +172,4 @@ public class ServerStore
sid2ttl.remove(key);
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java
index c5041fa4b38..130678ebd7a 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/StoreEntry.java
@@ -39,21 +39,13 @@ exception statement from your version. */
package gnu.javax.crypto.sasl.srp;
/**
- * <p>A simple timing-related object for use by SRP re-use code.</p>
+ * A simple timing-related object for use by SRP re-use code.
*/
class StoreEntry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private boolean perenial;
-
private long timeToDie;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
StoreEntry(int ttl)
{
super();
@@ -70,20 +62,14 @@ class StoreEntry
}
}
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
/**
- * <p>Returns <code>true</code> if the Time-To_live period has not elapsed.</p>
- *
+ * Returns <code>true</code> if the Time-To_live period has not elapsed.
+ *
* @return <code>true</code> if the Time-To-Live period (in seconds) has not
- * elapsed yet; <code>false</code> otherwise.
+ * elapsed yet; <code>false</code> otherwise.
*/
boolean isAlive()
{
return (perenial ? true : (System.currentTimeMillis() < timeToDie));
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/imageio/IIOInputStream.java b/libjava/classpath/gnu/javax/imageio/IIOInputStream.java
new file mode 100644
index 00000000000..2638e2fe240
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/IIOInputStream.java
@@ -0,0 +1,102 @@
+/* GIFStream.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio;
+
+import java.io.InputStream;
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * Implements InputStream on an ImageInputStream
+ * The purpose of this is to avoid IIO dependencies in the various decoders.
+ * (which only use read() anyway).
+ */
+public class IIOInputStream extends InputStream
+{
+ private ImageInputStream is;
+
+ public IIOInputStream( ImageInputStream is )
+ {
+ this.is = is;
+ }
+
+ public int available()
+ {
+ return 0;
+ }
+
+ public void close() throws IOException
+ {
+ is.close();
+ }
+
+ public void mark(int readlimit)
+ {
+ is.mark();
+ }
+
+ public boolean markSupported()
+ {
+ return true;
+ }
+
+ public int read() throws IOException
+ {
+ return is.read();
+ }
+
+ public int read(byte[] b) throws IOException
+ {
+ return is.read(b);
+ }
+
+ public int read(byte[] b, int offset, int length) throws IOException
+ {
+ return is.read(b, offset, length);
+ }
+
+ public void reset() throws IOException
+ {
+ is.reset();
+ }
+
+ public long skip(long n) throws IOException
+ {
+ return is.skipBytes(n);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/gif/GIFFile.java b/libjava/classpath/gnu/javax/imageio/gif/GIFFile.java
new file mode 100644
index 00000000000..a11a8c0c6f5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/gif/GIFFile.java
@@ -0,0 +1,709 @@
+/* GIFFile.java -- GIF decoder
+ 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.imageio.gif;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Vector;
+
+/**
+ * GIFFile - reads a GIF file.
+ *
+ * This class only does the bare minimum work, and returns the data in raw
+ * formats (described below). The class is J2ME compatible, and hopefully
+ * we can keep it that way without any significant overhead.
+ *
+ * @author Sven de Marothy.
+ */
+public class GIFFile
+{
+ // "NETSCAPE2.0" - identifier
+ private final static byte[] nsBlock = new byte[]
+ {0x4e, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e, 0x30 };
+
+ /**
+ * Block identifiers
+ */
+ private final static int EXTENSION = 0x21;
+ private final static int LOCAL = 0x2C;
+ private final static int TERMINATOR = 0x3B;
+
+ /**
+ * Extension block types
+ */
+ private final static int EXTENSION_COMMENT = 254;
+ private final static int EXTENSION_GCONTROL = 249;
+ private final static int EXTENSION_APPLICATION = 255;
+
+ /**
+ * Undraw commands for animation.
+ */
+ private final static int UNDRAW_OVERWRITE = 1;
+ private final static int UNDRAW_RESTORE_BACKGROUND = 2;
+ private final static int UNDRAW_RESTORE_PREVIOUS = 3;
+
+ /**
+ * Image position and dimensions (images may be partial)
+ */
+ private int x, y, width, height;
+
+ /**
+ * Global dimensions
+ */
+ private int globalWidth, globalHeight;
+
+ /**
+ * Background color index.
+ */
+ private byte bgIndex;
+
+ /**
+ * Number of colors
+ */
+ private int nColors;
+
+ /**
+ * Global palette, if any
+ */
+ private byte[] globalPalette;
+
+ /**
+ * Any
+ */
+ private boolean hasGlobalColorMap;
+
+ /**
+ * Local palette, if any (used if available)
+ */
+ private byte[] localPalette;
+
+ /**
+ * Interlaced GIF or not?
+ */
+ private boolean interlaced;
+
+ /**
+ * Has transparency?
+ */
+ private boolean hasTransparency;
+
+ /**
+ * Undraw mode (animations)
+ */
+ private int undraw;
+
+ /**
+ * Transparent index;
+ */
+ private int transparentIndex;
+
+ /**
+ * The uncompressed raster
+ */
+ private byte[] raster;
+
+ /**
+ * The compressed data (freed after uncompressing)
+ */
+ private byte[] compressedData;
+
+ /**
+ * Frame delay in 100ths of a second ( centiseconds, metrically )
+ */
+ private int duration;
+
+ /**
+ * Indices used during decompression
+ */
+ private int dataBlockIndex;
+
+ /**
+ * The file comment , if a comment block exists.
+ */
+ private String comment;
+
+ /**
+ * Fields used by getBits()
+ */
+ private int remainingBits = 0;
+ private int currentBits = 0;
+
+ /**
+ * Netscape animation extension
+ */
+ private boolean isLooped = false;
+
+ /** Number of loops, 0 = infinite */
+ private int loops;
+
+ /**
+ * Additional frames if it's an animated GIF.
+ */
+ private Vector animationFrames;
+
+ /**
+ * Loads the file from an input stream, which is not closed.
+ * @throws IOException if an I/O error occured.
+ * @throws GIFException if some file parsing error occured
+ */
+ public GIFFile(InputStream in) throws IOException, GIFException
+ {
+ // Validate the signature
+ if( !readSignature( in ) )
+ throw new GIFException("Invalid GIF signature.");
+
+ {
+ byte[] data = new byte[7];
+ if (in.read(data) != 7)
+ throw new IOException("Couldn't read global descriptor.");
+
+ globalWidth = ((data[1] & 0xFF) << 8) | (data[0] & 0xFF);
+ globalHeight = ((data[3] & 0xFF) << 8) | (data[2] & 0xFF);
+ byte flags = data[4];
+ bgIndex = data[5];
+ nColors = (1 << (( flags & 0x07) + 1));
+ hasGlobalColorMap = ((flags & 0x80) != 0);
+ }
+
+ if( hasGlobalColorMap )
+ {
+ globalPalette = new byte[ nColors * 3 ];
+ if( in.read( globalPalette ) != nColors * 3 )
+ throw new IOException("Couldn't read color map.");
+ }
+
+ int c = in.read();
+ while( c == EXTENSION )
+ {
+ readExtension( in );
+ c = in.read();
+ }
+
+ if( c != LOCAL )
+ throw new GIFException("Extension blocks not followed by a local descriptor ("+c+")");
+
+ loadImage( in );
+ c = in.read();
+
+ if( c == TERMINATOR ) // Not an animated GIF.
+ return;
+
+ // Load animation frames. Just quit if an error occurs instead
+ // of throwing an exception.
+ animationFrames = new Vector();
+ try
+ {
+ while( c != TERMINATOR )
+ {
+ animationFrames.add( new GIFFile( this, in, c ) );
+ c = in.read();
+ }
+ }
+ catch(IOException ioe)
+ {
+ }
+ catch(GIFException gife)
+ {
+ }
+ }
+
+ /**
+ * Constructor for additional animation frames.
+ */
+ private GIFFile(GIFFile parent, InputStream in, int c)
+ throws IOException, GIFException
+ {
+ // Copy global properties.
+ globalWidth = parent.globalWidth;
+ globalHeight = parent.globalHeight;
+ nColors = parent.nColors;
+ globalPalette = parent.globalPalette;
+ hasGlobalColorMap = parent.hasGlobalColorMap;
+ interlaced = parent.interlaced;
+ comment = parent.comment;
+ isLooped = parent.isLooped;
+ loops = parent.loops;
+
+ while( c == EXTENSION )
+ {
+ readExtension( in );
+ c = in.read();
+ }
+
+ if( c != LOCAL )
+ throw new GIFException("Extension blocks not followed by a local descriptor ("+c+")");
+
+ loadImage( in );
+ }
+
+ /**
+ * Reads a GIF file signature from an inputstream and checks it.
+ *
+ * @param in - the stream (reads 6 bytes, does not close or reset).
+ * @return true if the signature is a valid GIF signature.
+ * @throws an IOException if the signature could not be read.
+ */
+ public static boolean readSignature( InputStream in ) throws IOException
+ {
+ byte[] data = new byte[6];
+ if (in.read(data) != 6)
+ throw new IOException("Couldn't read signature.");
+
+ if( data[0] != 0x47 || data[1] != 0x49 || data[2] != 0x46 ||
+ data[3] != 0x38 ) // GIF8
+ return false;
+
+ if( (data[4] != 0x39 && data[4] != 0x37) || // 7 | 9
+ (data[5] != 0x61 && data[5] != 0x62) ) // 'a' or 'b'
+ return false;
+ return true;
+ }
+
+
+ /**
+ * Loads the image local descriptor and then loads/decodes the image raster,
+ * and then performs any necessary postprocessing like deinterlacing.
+ */
+ private void loadImage(InputStream in)
+ throws IOException, GIFException
+ {
+ readLocal( in );
+
+ try
+ {
+ decodeRaster( in );
+ }
+ catch(ArrayIndexOutOfBoundsException aioobe)
+ {
+ throw new GIFException("Error decompressing image.");
+ }
+
+ if( interlaced ) // Clean up
+ deinterlace();
+ packPixels();
+ }
+
+ /**
+ * Pack the pixels if it's a 2, 4 or 16 color image.
+ * While GIF may support any number of colors from 2-256, we won't bother
+ * trying to pack pixels not resulting in even byte boundaries.
+ * (AWT doesn't support that anyway, and most apps do the same.)
+ */
+ private void packPixels()
+ {
+ if( nColors != 2 && nColors != 4 && nColors != 16 )
+ return;
+
+ int nbits = 1;
+ int ppbyte = 8;
+ if( nColors == 4 )
+ {
+ nbits = 2;
+ ppbyte = 4;
+ }
+ else if( nColors == 16 )
+ {
+ nbits = 4;
+ ppbyte = 2;
+ }
+
+ int rem = (width & (ppbyte - 1));
+ int w = ( rem == 0 ) ? (width / ppbyte) :
+ ((width + ppbyte - rem) / ppbyte);
+ byte[] nr = new byte[ w * height ];
+ for(int j = 0; j < height; j++)
+ {
+ for(int i = 0; i < width - ppbyte; i += ppbyte)
+ for(int k = 0; k < ppbyte; k++)
+ nr[ j * w + (i / ppbyte) ] |= (byte)((raster[ width * j + i + k ]
+ << (8 - nbits * (1 + k))));
+ for(int i = 0; i < rem; i++)
+ nr[ j * w + w - 1 ] |= (byte)((raster[ width * j + width - rem + i ]
+ << (nbits * (rem - i))));
+ }
+ raster = nr;
+ }
+
+ /**
+ * Returns the (global) width
+ */
+ public int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Returns the image height
+ */
+ public int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Returns the # of colors.
+ */
+ public int getNColors()
+ {
+ return nColors;
+ }
+
+ /**
+ * Returns whether the GIF has transparency.
+ */
+ public boolean hasTransparency()
+ {
+ return hasTransparency;
+ }
+
+ /**
+ * Returns the index of the transparent color.
+ */
+ public int getTransparentIndex()
+ {
+ return transparentIndex;
+ }
+
+ /**
+ * Retuns the GIF file comment, or null if none exists.
+ */
+ public String getComment()
+ {
+ return comment;
+ }
+
+ /**
+ * Get duration of the frame for animations.
+ */
+ public int getDuration()
+ {
+ return duration;
+ }
+
+ /**
+ * Deinterlaces the image.
+ */
+ private void deinterlace()
+ {
+ byte[] nr = new byte[ width * height ];
+ int n = 0;
+ for(int i = 0; i < ((height + 7) >> 3); i++)
+ {
+ System.arraycopy( raster, n, nr, width * i * 8, width );
+ n += width;
+ }
+ for(int i = 0; i < ((height + 3) >> 3); i++)
+ {
+ System.arraycopy( raster, n, nr, width * ( 8 * i + 4 ), width );
+ n += width;
+ }
+ for(int i = 0; i < (height >> 2); i++)
+ {
+ System.arraycopy( raster, n, nr, width * (4 * i + 2), width );
+ n += width;
+ }
+ for(int i = 0; i < (height >> 1); i++)
+ {
+ System.arraycopy( raster, n, nr, width * (2 * i + 1), width );
+ n += width;
+ }
+ raster = nr;
+ }
+
+ /**
+ * Reads the local descriptor
+ */
+ private void readLocal(InputStream in) throws IOException
+ {
+ byte[] data = new byte[9];
+ if (in.read(data) != 9)
+ throw new IOException("Couldn't read local descriptor.");
+ x = ((data[1] & 0xFF) << 8) | (data[0] & 0xFF);
+ y = ((data[3] & 0xFF) << 8) | (data[2] & 0xFF);
+ width = ((data[5] & 0xFF) << 8) | (data[4] & 0xFF);
+ height = ((data[7] & 0xFF) << 8) | (data[6] & 0xFF);
+ byte flags = data[8];
+ interlaced = (( flags & 0x40 ) != 0);
+ if( (flags & 0x80) != 0 )
+ { // has a local color map
+ int nLocalColors = (1 << (( flags & 0x07) + 1));
+ if( !hasGlobalColorMap )
+ nColors = nLocalColors;
+ localPalette = new byte[ nLocalColors * 3 ];
+ if( in.read( localPalette ) != nLocalColors * 3 )
+ throw new IOException("Couldn't read color map.");
+ }
+ }
+
+ /**
+ * Returns the image's palette in raw format
+ * (r0,g0,b0,r1,g1,b2..r(Ncolors-1),g(Ncolors-1),b(Ncolors-1))
+ */
+ public byte[] getRawPalette()
+ {
+ return hasGlobalColorMap ? globalPalette : localPalette;
+ }
+
+ /**
+ * Returns the image file for animated gifs.
+ */
+ public GIFFile getImage( int index )
+ {
+ if( index == 0 )
+ return this;
+ if( animationFrames == null )
+ throw new ArrayIndexOutOfBoundsException("Only one image in file");
+ return (GIFFile)animationFrames.elementAt( index - 1 );
+ }
+
+ /**
+ * Return the image's raw image data.
+ * If the color depth is 1,2 or 4 bits per pixel the pixels are packed
+ * and the scanlines padded up to the nearest byte if needed.
+ */
+ public byte[] getRawImage()
+ {
+ return raster;
+ }
+
+ /**
+ * Return the number of images in the GIF file
+ */
+ public int nImages()
+ {
+ if( animationFrames != null )
+ return 1 + animationFrames.size();
+ return 1;
+ }
+
+ /**
+ * Handles extension blocks.
+ */
+ private void readExtension(InputStream in) throws IOException, GIFException
+ {
+ int functionCode = in.read();
+ byte[] data = readData(in);
+ switch( functionCode )
+ {
+ case EXTENSION_COMMENT: // comment block
+ comment = new String(data, "8859_1");
+ break;
+
+ case EXTENSION_GCONTROL: // Graphics control extension
+ undraw = (data[0] & 0x1C) >> 2;
+ // allegedly there can be bad values of this.
+ if( undraw < 1 && undraw > 3 ) undraw = 1;
+ hasTransparency = ((data[0] & 0x01) == 1);
+ transparentIndex = (data[3] & 0xFF);
+ duration = ((data[2] & 0xFF) << 8) | (data[1] & 0xFF);
+ break;
+
+ // Application extension. We only parse the Netscape animation
+ // extension here. Which is the only one most use anyway.
+ case EXTENSION_APPLICATION:
+ boolean isNS = true;
+ for(int i = 0; i < nsBlock.length; i++ )
+ if( nsBlock[i] != data[i] )
+ isNS = false;
+ if( isNS )
+ {
+ isLooped = true;
+ loops = ((data[12] & 0xFF) << 8) | (data[13] & 0xFF);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Reads a series of data blocks and merges them into a single one.
+ */
+ private byte[] readData(InputStream in) throws IOException
+ {
+ Vector v = new Vector();
+ int totalBytes = 0;
+
+ int n = in.read();
+ do
+ {
+ totalBytes += n;
+ byte[] block = new byte[ n ];
+ in.read(block);
+ v.add(block);
+ n = in.read();
+ }
+ while( n > 0 );
+
+ n = 0;
+ byte[] bigBuffer = new byte[ totalBytes ];
+ for( int i = 0; i < v.size(); i++ )
+ {
+ byte[] block = (byte[])v.elementAt(i);
+ System.arraycopy(block, 0, bigBuffer, n, block.length);
+ n += block.length;
+ }
+ return bigBuffer;
+ }
+
+ /**
+ * Loads a compressed image block and decompresses it.
+ */
+ private void decodeRaster(InputStream in) throws IOException
+ {
+ int initialCodeSize = in.read();
+ compressedData = readData( in );
+ dataBlockIndex = 0;
+
+ int rasterIndex = 0; // Index into the raster
+ int clearCode = (1 << initialCodeSize); // 256 usually
+ int endCode = clearCode + 1; // The stop code.
+
+ raster = new byte[ width * height ];
+
+ int codeSize = initialCodeSize + 1;
+ int code = getBits( codeSize ); // = clear
+ int nextCode = endCode + 1;
+
+ /*
+ * Initialize LZW dictionary
+ *
+ * First index - code #
+ * Second index:
+ * 0 = color index
+ * 1 = parent (-1 - no parent)
+ * 2 = first value
+ * 3 - depth
+ * The latter two aren't strictly necessary but make things faster, since
+ * copying the values forward is faster than going back and looking.
+ */
+ short[][] dictionary = new short[ 4096 ][ 4 ];
+
+ for(short i = 0; i < nColors; i ++ )
+ {
+ dictionary[i][0] = i; // color index
+ dictionary[i][1] = -1; // parent
+ dictionary[i][2] = i; // first
+ dictionary[i][3] = 1; // depth
+ }
+
+ code = getBits( codeSize ); // get second code
+ raster[ rasterIndex++ ] = (byte)dictionary[code][0];
+ int old = code;
+ code = getBits( codeSize ); // start at the third code
+ int c;
+
+ do
+ {
+ if( code == clearCode )
+ {
+ codeSize = initialCodeSize + 1;
+ nextCode = endCode + 1;
+ // get and output second code
+ code = getBits( codeSize );
+ raster[ rasterIndex++ ] = (byte)dictionary[code][0];
+ old = code;
+ }
+ else
+ {
+ dictionary[nextCode][1] = (short)old; // parent = old
+ dictionary[nextCode][2] = dictionary[old][2]; // first pixel
+ dictionary[nextCode][3] = (short)(dictionary[old][3] + 1); // depth
+
+ // appended pixel = first pixel of c
+ if( code < nextCode )
+ {
+ dictionary[nextCode][0] = dictionary[code][2];
+ old = code;
+ }
+ else // first of old
+ {
+ dictionary[nextCode][0] = dictionary[old][2];
+ old = nextCode;
+ }
+
+ c = old;
+ // output the code c
+ int depth = dictionary[c][3];
+ for( int i = depth - 1; i >= 0; i-- )
+ {
+ raster[ rasterIndex + i ] = (byte)dictionary[c][0];
+ c = dictionary[c][1]; // go to parent.
+ }
+ rasterIndex += depth;
+ nextCode ++;
+
+ if( codeSize < 12 && nextCode >= (1 << codeSize) )
+ codeSize++;
+ }
+ code = getBits( codeSize );
+ }
+ while( code != endCode && dataBlockIndex < compressedData.length );
+
+ compressedData = null; // throw away compressed data.
+ }
+
+ /**
+ * Returns nbits number of bits (in the LSBs) from compressedData
+ */
+ private int getBits( int nbits )
+ {
+ while( nbits > remainingBits )
+ {
+ int c = (compressedData[ dataBlockIndex++ ] & 0xFF) << remainingBits;
+ currentBits |= c;
+ remainingBits += 8;
+ }
+ int rval = (currentBits & ((1 << nbits) - 1));
+ currentBits = (currentBits >> nbits);
+ remainingBits -= nbits;
+ return rval;
+ }
+
+ /**
+ * Generic exception used by GIFFile to report decoding errors.
+ */
+ public static class GIFException extends Exception
+ {
+ public GIFException(String message)
+ {
+ super(message);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/gif/GIFImageReader.java b/libjava/classpath/gnu/javax/imageio/gif/GIFImageReader.java
new file mode 100644
index 00000000000..47108dd0c17
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/gif/GIFImageReader.java
@@ -0,0 +1,241 @@
+/* GIFImageReader.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.gif;
+
+import gnu.javax.imageio.IIOInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.imageio.*;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.SampleModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+public class GIFImageReader extends ImageReader
+{
+ private GIFFile file;
+
+ protected GIFImageReader(ImageReaderSpi originatingProvider)
+ {
+ super( originatingProvider );
+ file = null;
+ }
+
+ private void readImage() throws IOException
+ {
+ if( file != null )
+ return;
+
+ try
+ {
+ if( input instanceof InputStream )
+ file = new GIFFile( (InputStream)input );
+ else
+ file = new GIFFile( new IIOInputStream((ImageInputStream)input) );
+ }
+ catch(GIFFile.GIFException ge)
+ {
+ throw new IIOException(ge.getMessage());
+ }
+ }
+
+ /**
+ * Returns the Global/Local palette as an IndexColorModel
+ */
+ private IndexColorModel getPalette(int index)
+ {
+ GIFFile f = file.getImage( index );
+ byte[] data = f.getRawPalette();
+ int nc = f.getNColors();
+ byte[] r = new byte[nc];
+ byte[] g = new byte[nc];
+ byte[] b = new byte[nc];
+
+ for(int i = 0; i < nc; i ++ )
+ {
+ r[i] = data[ i * 3 ];
+ g[i] = data[ i * 3 + 1 ];
+ b[i] = data[ i * 3 + 2 ];
+ }
+
+ if( f.hasTransparency() )
+ {
+ byte[] a = new byte[nc];
+ for(int i = 0; i < nc; i ++ )
+ a[i] = (byte)0xFF;
+ a[f.getTransparentIndex()] = 0;
+ return new IndexColorModel(8, nc, r, g, b, a);
+ }
+
+ return new IndexColorModel(8, nc, r, g, b);
+ }
+
+ private void validateIndex(int imageIndex)
+ throws IndexOutOfBoundsException
+ {
+ if( imageIndex < 0 || imageIndex >= getNumImages(false) )
+ throw new IndexOutOfBoundsException("Invalid image index.");
+ }
+
+ public void setInput(Object input)
+ {
+ super.setInput(input);
+ }
+
+ public void setInput(Object input,
+ boolean seekForwardOnly,
+ boolean ignoreMetadata)
+ {
+ super.setInput(input, seekForwardOnly, ignoreMetadata);
+ }
+
+ public void setInput(Object input, boolean isStreamable)
+ {
+ super.setInput(input, isStreamable);
+
+ if (!(input instanceof ImageInputStream) &&
+ !(input instanceof InputStream))
+ throw new IllegalArgumentException("Input not an ImageInputStream.");
+ }
+
+ private void checkStream() throws IOException
+ {
+ if (!(input instanceof ImageInputStream) &&
+ !(input instanceof InputStream))
+ throw new IllegalStateException("Input not an ImageInputStream or InputStream.");
+
+ if(input == null)
+ throw new IllegalStateException("No input stream.");
+ }
+
+ public int getWidth(int imageIndex) throws IOException
+ {
+ validateIndex( imageIndex );
+ return file.getImage( imageIndex ).getWidth();
+ }
+
+ public int getHeight(int imageIndex) throws IOException
+ {
+ validateIndex( imageIndex );
+ return file.getImage( imageIndex ).getHeight();
+ }
+
+ public Iterator getImageTypes(int imageIndex)
+ {
+ validateIndex( imageIndex );
+ return null;
+ }
+
+ /**
+ * Returns the number of images.
+ */
+ public int getNumImages(boolean allowSearch)
+ {
+ try // Image should be loaded here already. But just in case:
+ {
+ readImage();
+ }
+ catch(IOException ioe)
+ {
+ return 0; // Well, now we're in trouble. But return something anyway.
+ }
+ return file.nImages();
+ }
+
+
+ // FIXME: Support metadata
+ public IIOMetadata getImageMetadata(int imageIndex)
+ {
+ validateIndex( imageIndex );
+ return null;
+ }
+
+ // FIXME: Support metadata
+ public IIOMetadata getStreamMetadata()
+ {
+ return null;
+ }
+
+ /**
+ * Reads the image indexed by imageIndex and returns it as
+ * a complete BufferedImage, using a supplied ImageReadParam.
+ */
+ public BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException, IIOException
+ {
+ validateIndex( imageIndex );
+ GIFFile f = file.getImage( imageIndex );
+ int width = f.getWidth();
+ int height = f.getHeight();
+ SampleModel sm;
+ switch( f.getNColors() )
+ {
+ case 16:
+ sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, 4);
+ break;
+ case 4:
+ sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, 2);
+ break;
+ case 2:
+ sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, 1);
+ break;
+ default:
+ sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height,
+ new int[] {0xFF});
+ break;
+ }
+ DataBuffer db = new DataBufferByte(f.getRawImage(), width * height, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(getPalette( imageIndex ), raster, false, null);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java b/libjava/classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java
new file mode 100644
index 00000000000..a3184862353
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java
@@ -0,0 +1,124 @@
+/* GIFImageReaderSpi.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.gif;
+
+import gnu.javax.imageio.IIOInputStream;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Locale;
+import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.ImageInputStream;
+
+public class GIFImageReaderSpi extends ImageReaderSpi
+{
+ static final String vendorName = "GNU";
+ static final String version = "0.1";
+ static final String readerClassName =
+ "gnu.javax.imageio.gif.GIFImageReader";
+ static final String[] names = { "Compuserve GIF" };
+ static final String[] suffixes = { ".gif" };
+ static final String[] MIMETypes = {
+ "image/gif",
+ "image/x-gif"}; // Not sure this is legal, but it seems to be used a bit
+ static final String[] writerSpiNames = null;
+ static final boolean supportsStandardStreamMetadataFormat = false;
+ static final String nativeStreamMetadataFormatName = null;
+ static final String nativeStreamMetadataFormatClassName = null;
+ static final String[] extraStreamMetadataFormatNames = null;
+ static final String[] extraStreamMetadataFormatClassNames = null;
+ static final boolean supportsStandardImageMetadataFormat = false;
+ static final String nativeImageMetadataFormatName = null;
+ static final String nativeImageMetadataFormatClassName = null;
+ static final String[] extraImageMetadataFormatNames = null;
+ static final String[] extraImageMetadataFormatClassNames = null;
+
+ public GIFImageReaderSpi()
+ {
+ super(vendorName, version,
+ names, suffixes, MIMETypes,
+ readerClassName,
+ new Class[]{ ImageInputStream.class, InputStream.class },
+ writerSpiNames,
+ supportsStandardStreamMetadataFormat,
+ nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName,
+ extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames,
+ supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName,
+ nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames,
+ extraImageMetadataFormatClassNames);
+ }
+
+ public String getDescription(Locale locale)
+ {
+ return "Compuserve GIF";
+ }
+
+ public boolean canDecodeInput(Object input)
+ throws IOException
+ {
+ if( input == null )
+ throw new IllegalArgumentException("Input object cannot be null.");
+
+ if( !(input instanceof ImageInputStream) &&
+ !(input instanceof InputStream))
+ return false;
+
+ boolean retval;
+ InputStream in;
+ if( input instanceof ImageInputStream )
+ in = new IIOInputStream( (ImageInputStream)input );
+ else
+ in = (InputStream)input;
+
+ in.mark(10); // we read 6 bytes
+ retval = GIFFile.readSignature( in );
+ in.reset();
+
+ return retval;
+ }
+
+ public ImageReader createReaderInstance(Object extension)
+ {
+ return new GIFImageReader(this);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/DCT.java b/libjava/classpath/gnu/javax/imageio/jpeg/DCT.java
new file mode 100644
index 00000000000..91b6eb88f25
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/DCT.java
@@ -0,0 +1,347 @@
+/* DCT.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+/**
+ * Discrete Cosine Transformations.
+ */
+public class DCT
+{
+
+ /**
+ * Cosine matrix
+ */
+ public double c[][] = new double[8][8];
+
+ /**
+ * Transformed cosine matrix
+ */
+ public double cT[][] = new double[8][8];
+
+ public DCT()
+ {
+ initMatrix();
+ }
+
+ /**
+ * Figure A.3.3 IDCT, Cu Cv on A-5 of the ISO DIS 10918-1. Requirements and
+ * Guidelines.
+ *
+ * @param u
+ * @return
+ */
+ public static double C(int u)
+ {
+ return ((u == 0) ? (double) 1 / (double) Math.sqrt((double) 2)
+ : (double) 1);
+ }
+
+ /**
+ * Initialize matrix values for the fast_idct function
+ */
+ private void initMatrix()
+ {
+ for (int j = 0; j < 8; j++)
+ {
+ double nn = (double) (8);
+ c[0][j] = 1.0 / Math.sqrt(nn);
+ cT[j][0] = c[0][j];
+ }
+ for (int i = 1; i < 8; i++)
+ {
+ for (int j = 0; j < 8; j++)
+ {
+ double jj = (double) j;
+ double ii = (double) i;
+ c[i][j] =
+ Math.sqrt(2.0 / 8.0)
+ * Math.cos(((2.0 * jj + 1.0) * ii * Math.PI) / (2.0 * 8.0));
+ cT[j][i] = c[i][j];
+ }
+ }
+ }
+
+ /**
+ * slow_idct - Figure A.3.3 IDCT (informative) on A-5 of the ISO DIS
+ * 10918-1. Requirements and Guidelines. This is a slow IDCT, there are
+ * better algorithms to use, it's fairly expensive with processor speed.
+ *
+ * @param matrix
+ * @return
+ */
+ public static double[][] slow_idct(double[][] matrix)
+ {
+ double[][] output = new double[matrix.length][matrix.length];
+ for (int y = 0; y < 8; y++)
+ {
+ for (int x = 0; x < 8; x++)
+ {
+ double val = 0;
+ for (double v = 0; v < 8; v++)
+ {
+ double innerloop = 0;
+ for (double u = 0; u < 8; u++)
+ innerloop += (DCT.C((int) u) / (double) 2)
+ * matrix[(int) v][(int) u]
+ * Math.cos((2 * x + 1) * u * Math.PI / (double) 16)
+ * Math.cos((2 * y + 1) * v * Math.PI / (double) 16);
+ val += (DCT.C((int) v) / (double) 2) * innerloop;
+ }
+ output[y][x] = (val + 128);
+ }
+ }
+ return (output);
+ }
+
+ public static float[][] slow_fdct(float[][] value)
+ {
+ float[][] buffer = new float[8][8];
+
+ for (int u = 0; u < 8; u++)
+ {
+ for (int v = 0; v < 8; v++)
+ {
+ buffer[u][v] =
+ (float) (1 / 4) * (float) C((int) u) * (float) C((int) v);
+ float innerval = 0;
+ for (int x = 0; x < 8; x++)
+ {
+ for (int y = 0; y < 8; y++)
+ {
+ innerval += value[y][x]
+ * Math.cos(((2 * x + 1) * u * Math.PI) / 16)
+ * Math.cos(((2 * y + 1) * v * Math.PI) / 16);
+ }
+ }
+ buffer[u][v] *= innerval;
+ }
+ }
+ return (buffer);
+ }
+
+ public float[][] fast_fdct(float[][] input)
+ {
+ float output[][] = new float[8][8];
+ double temp[][] = new double[8][8];
+ double temp1;
+ int i;
+ int j;
+ int k;
+
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ temp[i][j] = 0.0;
+ for (k = 0; k < 8; k++)
+ {
+ temp[i][j] += (((int) (input[i][k]) - 128) * cT[k][j]);
+ }
+ }
+ }
+
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ temp1 = 0.0;
+
+ for (k = 0; k < 8; k++)
+ {
+ temp1 += (c[i][k] * temp[k][j]);
+ }
+
+ output[i][j] = (int) Math.round(temp1) * 8;
+ }
+ }
+
+ return output;
+ }
+
+ /**
+ * fast_idct - Figure A.3.3 IDCT (informative) on A-5 of the ISO DIS
+ * 10918-1. Requires and Guidelines. This is a fast IDCT, it much more
+ * effecient and only inaccurate at about 1/1000th of a percent of values
+ * analyzed. Cannot be static because initMatrix must run before any
+ * fast_idct values can be computed.
+ *
+ * @param input
+ * @return
+ */
+ public double[][] fast_idct(double[][] input)
+ {
+ double output[][] = new double[8][8];
+ double temp[][] = new double[8][8];
+ double temp1;
+ int i, j, k;
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ temp[i][j] = 0.0;
+ for (k = 0; k < 8; k++)
+ {
+ temp[i][j] += input[i][k] * c[k][j];
+ }
+ }
+ }
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ temp1 = 0.0;
+ for (k = 0; k < 8; k++)
+ temp1 += cT[i][k] * temp[k][j];
+ temp1 += 128.0;
+ if (temp1 < 0)
+ output[i][j] = 0;
+ else if (temp1 > 255)
+ output[i][j] = 255;
+ else
+ output[i][j] = (int) Math.round(temp1);
+ }
+ }
+ return output;
+ }
+
+ public double[][] idj_fast_fdct(float input[][])
+ {
+ double output[][] = new double[8][8];
+ double tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ double tmp10, tmp11, tmp12, tmp13;
+ double z1, z2, z3, z4, z5, z11, z13;
+ int i;
+ int j;
+
+ // Subtracts 128 from the input values
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ output[i][j] = ((double) input[i][j] - (double) 128.0);
+ // input[i][j] -= 128;
+
+ }
+ }
+
+ for (i = 0; i < 8; i++)
+ {
+ tmp0 = output[i][0] + output[i][7];
+ tmp7 = output[i][0] - output[i][7];
+ tmp1 = output[i][1] + output[i][6];
+ tmp6 = output[i][1] - output[i][6];
+ tmp2 = output[i][2] + output[i][5];
+ tmp5 = output[i][2] - output[i][5];
+ tmp3 = output[i][3] + output[i][4];
+ tmp4 = output[i][3] - output[i][4];
+
+ tmp10 = tmp0 + tmp3;
+ tmp13 = tmp0 - tmp3;
+ tmp11 = tmp1 + tmp2;
+ tmp12 = tmp1 - tmp2;
+
+ output[i][0] = tmp10 + tmp11;
+ output[i][4] = tmp10 - tmp11;
+
+ z1 = (tmp12 + tmp13) * (double) 0.707106781;
+ output[i][2] = tmp13 + z1;
+ output[i][6] = tmp13 - z1;
+
+ tmp10 = tmp4 + tmp5;
+ tmp11 = tmp5 + tmp6;
+ tmp12 = tmp6 + tmp7;
+
+ z5 = (tmp10 - tmp12) * (double) 0.382683433;
+ z2 = ((double) 0.541196100) * tmp10 + z5;
+ z4 = ((double) 1.306562965) * tmp12 + z5;
+ z3 = tmp11 * ((double) 0.707106781);
+
+ z11 = tmp7 + z3;
+ z13 = tmp7 - z3;
+
+ output[i][5] = z13 + z2;
+ output[i][3] = z13 - z2;
+ output[i][1] = z11 + z4;
+ output[i][7] = z11 - z4;
+ }
+
+ for (i = 0; i < 8; i++)
+ {
+ tmp0 = output[0][i] + output[7][i];
+ tmp7 = output[0][i] - output[7][i];
+ tmp1 = output[1][i] + output[6][i];
+ tmp6 = output[1][i] - output[6][i];
+ tmp2 = output[2][i] + output[5][i];
+ tmp5 = output[2][i] - output[5][i];
+ tmp3 = output[3][i] + output[4][i];
+ tmp4 = output[3][i] - output[4][i];
+
+ tmp10 = tmp0 + tmp3;
+ tmp13 = tmp0 - tmp3;
+ tmp11 = tmp1 + tmp2;
+ tmp12 = tmp1 - tmp2;
+
+ output[0][i] = tmp10 + tmp11;
+ output[4][i] = tmp10 - tmp11;
+
+ z1 = (tmp12 + tmp13) * (double) 0.707106781;
+ output[2][i] = tmp13 + z1;
+ output[6][i] = tmp13 - z1;
+
+ tmp10 = tmp4 + tmp5;
+ tmp11 = tmp5 + tmp6;
+ tmp12 = tmp6 + tmp7;
+
+ z5 = (tmp10 - tmp12) * (double) 0.382683433;
+ z2 = ((double) 0.541196100) * tmp10 + z5;
+ z4 = ((double) 1.306562965) * tmp12 + z5;
+ z3 = tmp11 * ((double) 0.707106781);
+
+ z11 = tmp7 + z3;
+ z13 = tmp7 - z3;
+
+ output[5][i] = z13 + z2;
+ output[3][i] = z13 - z2;
+ output[1][i] = z11 + z4;
+ output[7][i] = z11 - z4;
+ }
+
+ return output;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/HuffmanTable.java b/libjava/classpath/gnu/javax/imageio/jpeg/HuffmanTable.java
new file mode 100644
index 00000000000..78f3c1c4f38
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/HuffmanTable.java
@@ -0,0 +1,207 @@
+/* HuffmanTable.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.io.IOException;
+
+import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
+
+
+/**
+ * This Object construct a JPEGHuffmanTable which can be used to encode/decode
+ * a scan from a JPEG codec stream. The table must be initalized with either a
+ * BITS byte amount and a Huffman Table Value for decoding or a Huffman Size
+ * and Huffman Code table for encoding.
+ */
+public class HuffmanTable
+{
+ public final static int HUFFMAN_MAX_TABLES = 4;
+
+ private short[] huffcode = new short[256];
+ private short[] huffsize = new short[256];
+ private short[] EHUFCO;
+ private short[] EHUFSI;
+ private short[] valptr = new short[16];
+ private short[] mincode = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1,-1,-1};
+ private short[] maxcode = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1};
+ private short[] huffval;
+ private short[] bits;
+
+ static byte JPEG_DC_TABLE = 0;
+ static byte JPEG_AC_TABLE = 1;
+
+ private short lastk = 0;
+
+ public HuffmanTable(JPEGHuffmanTable table)
+ {
+ huffcode = table.getValues();
+ bits = table.getLengths();
+ }
+
+ /**
+ * Generated from FIGURE C.1 - Generation of table of Huffman code sizes on
+ * ISO DIS 10918-1. Requirements and Guidelines
+ */
+ private void generateSizeTable()
+ {
+ short index=0;
+ for(short i=0; i < bits.length ; i++)
+ {
+ for(short j=0; j < bits[i] ; j++)
+ {
+ huffsize[index] = (short) (i+1);
+ index++;
+ }
+ }
+ lastk = index;
+ }
+
+ /**
+ * Generated from FIGURE C.2 - Generation of table of Huffman codes on
+ * ISO DIS 10918-1. Requirements and Guidelines
+ */
+ private void generateCodeTable()
+ {
+ short k=0;
+ short si = huffsize[0];
+ short code = 0;
+ for(short i=0; i < huffsize.length ; i++)
+ {
+ while(huffsize[k]==si)
+ {
+ huffcode[k] = code;
+ code++;
+ k++;
+ }
+ code <<= 1;
+ si++;
+ }
+ }
+
+ /**
+ * Generated from FIGURE F.15 - Generation of decode table generation on
+ * ISO DIS 10918-1. Requirements and Guidelines
+ */
+ private void generateDecoderTables()
+ {
+ short bitcount = 0;
+ for(int i=0; i < 16 ; i++)
+ {
+ if(bits[i]!=0)
+ valptr[i] = bitcount;
+ for(int j=0 ; j < bits[i] ; j++)
+ {
+ if(huffcode[j+bitcount] < mincode[i] || mincode[i] == -1)
+ mincode[i] = huffcode[j+bitcount];
+
+ if(huffcode[j+bitcount] > maxcode[i])
+ maxcode[i] = huffcode[j+bitcount];
+ }
+ if(mincode[i]!=-1)
+ valptr[i] = (short) (valptr[i] - mincode[i]);
+ bitcount += bits[i];
+ }
+ }
+
+ /**
+ * Generated from FIGURE C.3 - Generation of Order Codes and tables EHUFCO
+ * and EHUFSI from the ISO DIS 10918-1. Requirements and Guidelines
+ */
+ public void orderCodes(boolean isDC)
+ {
+ EHUFCO = new short[isDC ? 15 : 255];
+ EHUFSI = new short[isDC ? 15 : 255];
+
+ for (int p=0; p < lastk ; p++)
+ {
+ int i = huffval[p];
+ if(i < 0 || i > EHUFCO.length || EHUFSI[i]!=0)
+ System.err.println("Error, bad huffman table.");
+ EHUFCO[i] = huffcode[p];
+ EHUFSI[i] = huffsize[p];
+ }
+ }
+
+ /**
+ * Generated from FIGURE F.12 - Extending the sign bit of a decoded value in on
+ * ISO DIS 10918-1. Requirements and Guidelines<p>
+ *
+ * @param diff TODO
+ * @param t TODO
+ * @return TODO
+ */
+ public static int extend(int diff, int t)
+ {
+ int Vt = (int)Math.pow(2,(t-1));
+ if(diff<Vt)
+ {
+ Vt=(-1 << t)+1;
+ diff=diff+Vt;
+ }
+ return diff;
+ }
+
+ /**
+ * Generated from FIGURE F.16 - Procedure for DECODE on
+ * ISO DIS 10918-1. Requirements and Guidelines<p>
+ *
+ * This function takes in a dynamic amount of bits and using the Huffman
+ * table returns information on how many bits must be read in to a byte in
+ * order to reconstruct said byte.
+ *
+ * @param JPEGStream the bits of the data stream.
+ */
+ public int decode(JPEGImageInputStream JPEGStream)
+ throws IOException, JPEGException
+ {
+ int i=0;
+ short code = (short) JPEGStream.readBits(1);
+ while(code > maxcode[i])
+ {
+ i++;
+ code <<= 1;
+ code |= JPEGStream.readBits(1);
+ }
+ int val = huffval[code+(valptr[i])];
+ if(val < 0)
+ val = 256 + val;
+ return val;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGComponent.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGComponent.java
new file mode 100644
index 00000000000..d5799fd412b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGComponent.java
@@ -0,0 +1,351 @@
+/* JPEGComponent.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.util.ArrayList;
+import java.io.IOException;
+import java.awt.image.WritableRaster;
+
+import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
+
+/**
+ * This class holds the methods to decode and write a component information to
+ * a raster.
+ */
+public class JPEGComponent
+{
+ public byte factorH, factorV, component_id, quant_id;
+ public int width = 0, height = 0, maxV = 0, maxH = 0;
+ public HuffmanTable ACTable;
+ public HuffmanTable DCTable;
+ public int[] quantizationTable;
+ public double previousDC = 0;
+ ArrayList data = new ArrayList();
+
+ /**
+ * Initializes the component
+ *
+ * @param id
+ * @param factorHorizontal
+ * @param factorVertical
+ * @param quantizationID
+ */
+ public JPEGComponent(byte id, byte factorHorizontal, byte factorVertical,
+ byte quantizationID)
+ {
+ component_id = id;
+ factorH = factorHorizontal;
+ factorV = factorVertical;
+ quant_id = quantizationID;
+ }
+
+ /**
+ * If a restart marker is found with too little of an MCU count (i.e. our
+ * Restart Interval is 63 and we have 61 we copy the last MCU until it's
+ * full)
+ *
+ * @param index
+ * @param length
+ */
+ public void padMCU(int index, int length)
+ {
+ double[] src = (double[]) data.get(index - 1);
+ for (int i = 0; i < length; i++)
+ data.add(index, src);
+ }
+
+ /**
+ * Reset the interval by setting the previous DC value
+ */
+ public void resetInterval()
+ {
+ previousDC = 0;
+ }
+
+ /**
+ * Run the Quantization backward method on all of the block data.
+ */
+ public void quantitizeData()
+ {
+ for (int i = 0; i < data.size(); i++)
+ {
+ double[] mydata = (double[]) data.get(i);
+ for (int j = 0; j < mydata.length; j++)
+ mydata[j] *= quantizationTable[j];
+ }
+ }
+
+ public void setDCTable(JPEGHuffmanTable table)
+ {
+ DCTable = new HuffmanTable(table);
+ }
+
+ public void setACTable(JPEGHuffmanTable table)
+ {
+ ACTable = new HuffmanTable(table);
+ }
+
+ /**
+ * Run the Inverse DCT method on all of the block data
+ */
+ public void idctData(DCT myDCT)
+ {
+ for (int i = 0; i < data.size(); i++)
+ data.add(i,myDCT.fast_idct(ZigZag.decode8x8_map((double[]) data.remove(i))));
+ }
+
+ /**
+ * This scales up the component size based on the factor size. This
+ * calculates everyting up automatically so it's simply ran at the end of
+ * the frame to normalize the size of all of the components.
+ */
+ public void scaleByFactors()
+ {
+ int factorUpVertical = maxV / factorV;
+ int factorUpHorizontal = maxH / factorH;
+
+ if (factorUpVertical > 1)
+ {
+ for (int i = 0; i < data.size(); i++)
+ {
+ double[][] src = (double[][]) data.remove(i);
+ double[][] dest =
+ new double[src.length * factorUpVertical][src[0].length];
+ for (int j = 0; j < src.length; j++)
+ {
+ for (int u = 0; u < factorUpVertical; u++)
+ {
+ dest[j * factorUpVertical + u] = src[j];
+ }
+ }
+ data.add(i, dest);
+ }
+ }
+
+ if (factorUpHorizontal > 1)
+ {
+ for (int i = 0; i < data.size(); i++)
+ {
+ double[][] src = (double[][]) data.remove(i);
+ double[][] dest =
+ new double[src.length][src[0].length * factorUpHorizontal];
+ for (int j = 0; j < src.length; j++)
+ {
+ for (int u = 0; u < src[0].length; u++)
+ {
+ for (int v = 0; v < factorUpHorizontal; v++)
+ dest[j][u * factorUpHorizontal + v] = src[j][u];
+ }
+ }
+ data.add(i, dest);
+ }
+ }
+ }
+
+ /**
+ * This write the block of data to the raster throwing out anything that
+ * spills over the raster width or height.
+ *
+ * @param raster
+ * @param data
+ * @param compIndex
+ * @param x
+ * @param y
+ */
+ public void writeBlock(WritableRaster raster, double[][] data,
+ int compIndex, int x, int y)
+ {
+ for (int yIndex = 0; yIndex < data.length; yIndex++)
+ {
+ for (int xIndex = 0; xIndex < data[yIndex].length; xIndex++)
+ {
+ // The if statement is needed because blocks can spill over the
+ // frame width because they are padded to make sure we keep the
+ // height of the block the same as the width of the block
+ if (x + xIndex < raster.getWidth()
+ && y + yIndex < raster.getHeight())
+ raster.setSample(x + xIndex, y + yIndex, compIndex,
+ data[yIndex][xIndex]);
+ }
+ }
+ }
+
+ /**
+ * This writes data to a raster block, so really it's reading not writing
+ * but it writes the data to the raster block by factor size in a zig zag
+ * fashion. This has the helper function writeBlock which does the actual
+ * writing.
+ *
+ * @param raster
+ * @param componentIndex
+ */
+ public void writeData(WritableRaster raster, int componentIndex)
+ {
+ int x = 0, y = 0, lastblockheight = 0, incrementblock = 0;
+
+ // Keep looping through all of the blocks until there are no more.
+ while(data.size() > 0)
+ {
+ int blockwidth = 0;
+ int blockheight = 0;
+
+ if (x >= raster.getWidth())
+ {
+ x = 0;
+ y += incrementblock;
+ }
+
+ // Loop through the horizontal component blocks of the MCU first
+ // then for each horizontal line write out all of the vertical
+ // components
+ for (int factorVIndex = 0; factorVIndex < factorV; factorVIndex++)
+ {
+ blockwidth = 0;
+
+ for (int factorHIndex = 0; factorHIndex < factorH; factorHIndex++)
+ {
+ // Captures the width of this block so we can increment the
+ // X coordinate
+ double[][] blockdata = (double[][]) data.remove(0);
+
+ // Writes the data at the specific X and Y coordinate of
+ // this component
+ writeBlock(raster, blockdata, componentIndex, x, y);
+ blockwidth += blockdata[0].length;
+ x += blockdata[0].length;
+ blockheight = blockdata.length;
+ }
+ y += blockheight;
+ x -= blockwidth;
+ lastblockheight += blockheight;
+ }
+ y -= lastblockheight;
+ incrementblock = lastblockheight;
+ lastblockheight = 0;
+ x += blockwidth;
+ }
+ }
+
+ /**
+ * Set the quantization table for this component.
+ *
+ * @param quanttable
+ */
+ public void setQuantizationTable(int[] quanttable)
+ {
+ quantizationTable = quanttable;
+ }
+
+ /**
+ * Read in a partial MCU for this component
+ *
+ * @param stream TODO
+ * @throws JPEGException TODO
+ * @throws IOException TODO
+ */
+ public void readComponentMCU(JPEGImageInputStream stream)
+ throws JPEGException, IOException
+ {
+ for (int i = 0; i < factorH * factorV; i++)
+ {
+ double dc = decode_dc_coefficient(stream);
+ double[] datablock = decode_ac_coefficients(stream);
+ datablock[0] = dc;
+ data.add(datablock);
+ }
+ }
+
+ /**
+ * Generated from text on F-22, F.2.2.1 - Huffman decoding of DC
+ * coefficients on ISO DIS 10918-1. Requirements and Guidelines.
+ *
+ * @param JPEGStream TODO
+ *
+ * @return TODO
+ * @throws JPEGException TODO
+ * @throws IOException TODO
+ */
+ public double decode_dc_coefficient(JPEGImageInputStream JPEGStream)
+ throws JPEGException, IOException
+ {
+ int t = DCTable.decode(JPEGStream);
+ double diff = JPEGStream.readBits(t);
+ diff = HuffmanTable.extend((int) diff, t);
+ diff = (previousDC + diff);
+ previousDC = diff;
+ return diff;
+ }
+
+ /**
+ * Generated from text on F-23, F.13 - Huffman decoded of AC coefficients
+ * on ISO DIS 10918-1. Requirements and Guidelines.
+ *
+ * @param JPEGStream TODO
+ * @return TODO
+ *
+ * @throws JPEGException TODO
+ * @throws IOException TODO
+ */
+ public double[] decode_ac_coefficients(JPEGImageInputStream JPEGStream)
+ throws JPEGException, IOException
+ {
+ double[] zz = new double[64];
+
+ for (int k = 1; k < 64; k++)
+ {
+ int s = ACTable.decode(JPEGStream);
+ int r = s >> 4;
+ s &= 15;
+
+ if (s != 0)
+ {
+ k += r;
+ r = (int) JPEGStream.readBits(s);
+ s = (int) HuffmanTable.extend(r, s);
+ zz[k] = s;
+ }
+ else
+ {
+ if (r != 15)
+ return (zz);
+ k += 15;
+ }
+ }
+ return zz;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java
new file mode 100644
index 00000000000..3610ebe874f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java
@@ -0,0 +1,630 @@
+/* JPEGDecoder.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.io.IOException;
+import java.nio.ByteOrder;
+
+import javax.imageio.*;
+import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
+import javax.imageio.plugins.jpeg.JPEGQTable;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.awt.Point;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+public class JPEGDecoder
+{
+ byte majorVersion;
+ byte minorVersion;
+ byte units;
+ short Xdensity;
+ short Ydensity;
+ byte Xthumbnail;
+ byte Ythumbnail;
+ byte[] thumbnail;
+ BufferedImage image;
+ int width;
+ int height;
+
+ byte marker;
+
+ /**
+ * This decoder expects JFIF 1.02 encoding.
+ */
+ public static final byte MAJOR_VERSION = (byte) 1;
+ public static final byte MINOR_VERSION = (byte) 2;
+
+ /**
+ * The length of the JFIF field not including thumbnail data.
+ */
+ public static final short JFIF_FIXED_LENGTH = 16;
+
+ /**
+ * The length of the JFIF extension field not including extension
+ * data.
+ */
+ public static final short JFXX_FIXED_LENGTH = 8;
+
+ private JPEGImageInputStream jpegStream;
+
+ ArrayList jpegFrames = new ArrayList();
+
+ JPEGHuffmanTable[] dcTables = new JPEGHuffmanTable[4];
+ JPEGHuffmanTable[] acTables = new JPEGHuffmanTable[4];
+ JPEGQTable[] qTables = new JPEGQTable[4];
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+ public JPEGDecoder(ImageInputStream in)
+ throws IOException, JPEGException
+ {
+ jpegStream = new JPEGImageInputStream(in);
+ jpegStream.setByteOrder(ByteOrder.LITTLE_ENDIAN);
+
+ if (jpegStream.findNextMarker() != JPEGMarker.SOI)
+ throw new JPEGException("Failed to find SOI marker.");
+
+ if (jpegStream.findNextMarker() != JPEGMarker.APP0)
+ throw new JPEGException("Failed to find APP0 marker.");
+
+ int length = jpegStream.readShort();
+ if (!(length >= JFIF_FIXED_LENGTH))
+ throw new JPEGException("Failed to find JFIF field.");
+
+ byte[] identifier = new byte[5];
+ jpegStream.read(identifier);
+ if (identifier[0] != JPEGMarker.JFIF_J
+ || identifier[1] != JPEGMarker.JFIF_F
+ || identifier[2] != JPEGMarker.JFIF_I
+ || identifier[3] != JPEGMarker.JFIF_F
+ || identifier[4] != JPEGMarker.X00)
+ throw new JPEGException("Failed to read JFIF identifier.");
+
+ majorVersion = jpegStream.readByte();
+ minorVersion = jpegStream.readByte();
+ if (majorVersion != MAJOR_VERSION
+ || (majorVersion == MAJOR_VERSION
+ && minorVersion < MINOR_VERSION))
+ throw new JPEGException("Unsupported JFIF version.");
+
+ units = jpegStream.readByte();
+ if (units > (byte) 2)
+ throw new JPEGException("Units field is out of range.");
+
+ Xdensity = jpegStream.readShort();
+ Ydensity = jpegStream.readShort();
+ Xthumbnail = jpegStream.readByte();
+ Ythumbnail = jpegStream.readByte();
+
+ // 3 * for RGB data
+ int thumbnailLength = 3 * Xthumbnail * Ythumbnail;
+ if (length > JFIF_FIXED_LENGTH
+ && thumbnailLength != length - JFIF_FIXED_LENGTH)
+ throw new JPEGException("Invalid length, Xthumbnail"
+ + " or Ythumbnail field.");
+
+ if (thumbnailLength > 0)
+ {
+ thumbnail = new byte[thumbnailLength];
+ if (jpegStream.read(thumbnail) != thumbnailLength)
+ throw new IOException("Failed to read thumbnail.");
+ }
+ }
+
+ public void decode()
+ throws IOException
+ {
+ System.out.println ("DECODE!!!");
+ // The frames in this jpeg are loaded into a list. There is
+ // usually just one frame except in heirarchial progression where
+ // there are multiple frames.
+ JPEGFrame frame = null;
+
+ // The restart interval defines how many MCU's we should have
+ // between the 8-modulo restart marker. The restart markers allow
+ // us to tell whether or not our decoding process is working
+ // correctly, also if there is corruption in the image we can
+ // recover with these restart intervals. (See RSTm DRI).
+ int resetInterval = 0;
+
+ // The JPEGDecoder constructor parses the JFIF field. At this
+ // point jpegStream points to the first byte after the JFIF field.
+
+ // Find the first marker after the JFIF field.
+ byte marker = jpegStream.findNextMarker();
+
+ // Check for a JFIF extension field directly following the JFIF
+ // header and advance the current marker to the next marker in the
+ // stream, if necessary.
+ decodeJFIFExtension();
+
+ // Loop through until there are no more markers to read in, at
+ // that point everything is loaded into the jpegFrames array and
+ // can be processed.
+ while (true)
+ {
+ switch (marker)
+ {
+ // APPn Application Reserved Information - Just throw this
+ // information away because we wont be using it.
+ case JPEGMarker.APP0:
+ case JPEGMarker.APP1:
+ case JPEGMarker.APP2:
+ case JPEGMarker.APP3:
+ case JPEGMarker.APP4:
+ case JPEGMarker.APP5:
+ case JPEGMarker.APP6:
+ case JPEGMarker.APP7:
+ case JPEGMarker.APP8:
+ case JPEGMarker.APP9:
+ case JPEGMarker.APP10:
+ case JPEGMarker.APP11:
+ case JPEGMarker.APP12:
+ case JPEGMarker.APP13:
+ case JPEGMarker.APP14:
+ case JPEGMarker.APP15:
+ jpegStream.skipBytes(jpegStream.readShort() - 2);
+ break;
+
+ case JPEGMarker.SOF0:
+ // SOFn Start of Frame Marker, Baseline DCT - This is the start
+ // of the frame header that defines certain variables that will
+ // be carried out through the rest of the encoding. Multiple
+ // frames are used in a heirarchiel system, however most JPEG's
+ // only contain a single frame.
+ jpegFrames.add(new JPEGFrame());
+ frame = (JPEGFrame) jpegFrames.get(jpegFrames.size() - 1);
+ // Skip the frame length.
+ jpegStream.readShort();
+ // Bits percision, either 8 or 12.
+ frame.setPrecision(jpegStream.readByte());
+ // Scan lines = to the height of the frame.
+ frame.setScanLines(jpegStream.readShort());
+ // Scan samples per line = to the width of the frame.
+ frame.setSamplesPerLine(jpegStream.readShort());
+ // Number of Color Components (or channels).
+ frame.setComponentCount(jpegStream.readByte());
+
+ // Set the color mode for this frame, so far only 2 color
+ // modes are supported.
+ if (frame.getComponentCount() == 1)
+ frame.setColorMode(JPEGFrame.JPEG_COLOR_GRAY);
+ else
+ frame.setColorMode(JPEGFrame.JPEG_COLOR_YCbCr);
+ // Add all of the necessary components to the frame.
+ for (int i = 0; i < frame.getComponentCount(); i++)
+ frame.addComponent(jpegStream.readByte(), jpegStream.readByte(),
+ jpegStream.readByte());
+ break;
+
+ case JPEGMarker.SOF2:
+ jpegFrames.add(new JPEGFrame());
+ frame = (JPEGFrame) jpegFrames.get(jpegFrames.size() - 1);
+ // Skip the frame length.
+ jpegStream.readShort();
+ // Bits percision, either 8 or 12.
+ frame.setPrecision(jpegStream.readByte());
+ // Scan lines = to the height of the frame.
+ frame.setScanLines(jpegStream.readShort());
+ // Scan samples per line = to the width of the frame.
+ frame.setSamplesPerLine(jpegStream.readShort());
+ // Number of Color Components (or channels).
+ frame.setComponentCount(jpegStream.readByte());
+
+ // Set the color mode for this frame, so far only 2 color
+ // modes are supported.
+ if (frame.getComponentCount() == 1)
+ frame.setColorMode(JPEGFrame.JPEG_COLOR_GRAY);
+ else
+ frame.setColorMode(JPEGFrame.JPEG_COLOR_YCbCr);
+
+ // Add all of the necessary components to the frame.
+ for (int i = 0; i < frame.getComponentCount(); i++)
+ frame.addComponent(jpegStream.readByte(), jpegStream.readByte(),
+ jpegStream.readByte());
+ break;
+
+ case JPEGMarker.DHT:
+ // DHT non-SOF Marker - Huffman Table is required for decoding
+ // the JPEG stream, when we receive a marker we load in first
+ // the table length (16 bits), the table class (4 bits), table
+ // identifier (4 bits), then we load in 16 bytes and each byte
+ // represents the count of bytes to load in for each of the 16
+ // bytes. We load this into an array to use later and move on 4
+ // huffman tables can only be used in an image.
+ int huffmanLength = (jpegStream.readShort() - 2);
+
+ // Keep looping until we are out of length.
+ int index = huffmanLength;
+
+ // Multiple tables may be defined within a DHT marker. This
+ // will keep reading until there are no tables left, most
+ // of the time there are just one tables.
+ while (index > 0)
+ {
+ // Read the identifier information and class
+ // information about the Huffman table, then read the
+ // 16 byte codelength in and read in the Huffman values
+ // and put it into table info.
+ byte huffmanInfo = jpegStream.readByte();
+ byte tableClass = (byte) (huffmanInfo >> 4);
+ byte huffmanIndex = (byte) (huffmanInfo & 0x0f);
+ short[] codeLength = new short[16];
+ jpegStream.readFully(codeLength, 0, codeLength.length);
+ int huffmanValueLen = 0;
+ for (int i = 0; i < 16; i++)
+ huffmanValueLen += codeLength[i];
+ index -= (huffmanValueLen + 17);
+ short[] huffmanVal = new short[huffmanValueLen];
+ for (int i = 0; i < huffmanVal.length; i++)
+ huffmanVal[i] = jpegStream.readByte();
+ // Assign DC Huffman Table.
+ if (tableClass == HuffmanTable.JPEG_DC_TABLE)
+ dcTables[(int) huffmanIndex] = new JPEGHuffmanTable(codeLength,
+ huffmanVal);
+ // Assign AC Huffman Table.
+ else if (tableClass == HuffmanTable.JPEG_AC_TABLE)
+ acTables[(int) huffmanIndex] = new JPEGHuffmanTable(codeLength,
+ huffmanVal);
+ }
+ break;
+ case JPEGMarker.DQT:
+ // DQT non-SOF Marker - This defines the quantization
+ // coeffecients, this allows us to figure out the quality of
+ // compression and unencode the data. The data is loaded and
+ // then stored in to an array.
+ short quantizationLength = (short) (jpegStream.readShort() - 2);
+ for (int j = 0; j < quantizationLength / 65; j++)
+ {
+ byte quantSpecs = jpegStream.readByte();
+ int[] quantData = new int[64];
+ if ((byte) (quantSpecs >> 4) == 0)
+ // Precision 8 bit.
+ {
+ for (int i = 0; i < 64; i++)
+ quantData[i] = jpegStream.readByte();
+
+ }
+ else if ((byte) (quantSpecs >> 4) == 1)
+ // Precision 16 bit.
+ {
+ for (int i = 0; i < 64; i++)
+ quantData[i] = jpegStream.readShort();
+ }
+ qTables[(int) (quantSpecs & 0x0f)] = new JPEGQTable (quantData);
+ }
+ break;
+ case JPEGMarker.SOS:
+ // SOS non-SOF Marker - Start Of Scan Marker, this is where the
+ // actual data is stored in a interlaced or non-interlaced with
+ // from 1-4 components of color data, if three components most
+ // likely a YCrCb model, this is a fairly complex process.
+
+ // Read in the scan length.
+ jpegStream.readShort();
+ // Number of components in the scan.
+ byte numberOfComponents = jpegStream.readByte();
+ byte[] componentSelector = new byte[numberOfComponents];
+ for (int i = 0; i < numberOfComponents; i++)
+ {
+ // Component ID, packed byte containing the Id for the
+ // AC table and DC table.
+ byte componentID = jpegStream.readByte();
+ byte tableInfo = jpegStream.readByte();
+ frame.setHuffmanTables(componentID,
+ acTables[(byte) (tableInfo >> 4)],
+ dcTables[(byte) (tableInfo & 0x0f)]);
+ componentSelector[i] = componentID;
+ }
+ byte startSpectralSelection = jpegStream.readByte();
+ byte endSpectralSelection = jpegStream.readByte();
+ byte successiveApproximation = jpegStream.readByte();
+
+ int mcuIndex = 0;
+ int mcuTotalIndex = 0;
+ // This loops through until a MarkerTagFound exception is
+ // found, if the marker tag is a RST (Restart Marker) it
+ // simply skips it and moves on this system does not handle
+ // corrupt data streams very well, it could be improved by
+ // handling misplaced restart markers.
+ while (true)
+ {
+ try
+ {
+ // Loop though capturing MCU, instruct each
+ // component to read in its necessary count, for
+ // scaling factors the components automatically
+ // read in how much they need
+ for (int compIndex = 0; compIndex < numberOfComponents; compIndex++)
+ {
+ JPEGComponent comp = (JPEGComponent) frame.components.getComponentByID(componentSelector[compIndex]);
+ comp.readComponentMCU(jpegStream);
+ }
+ mcuIndex++;
+ mcuTotalIndex++;
+ }
+ // We've found a marker, see if the marker is a restart
+ // marker or just the next marker in the stream. If
+ // it's the next marker in the stream break out of the
+ // while loop, if it's just a restart marker skip it
+ catch (JPEGMarkerFoundException bse)
+ {
+ // Handle JPEG Restart Markers, this is where the
+ // count of MCU's per interval is compared with
+ // the count actually obtained, if it's short then
+ // pad on some MCU's ONLY for components that are
+ // greater than one. Also restart the DC prediction
+ // to zero.
+ if (marker == JPEGMarker.RST0
+ || marker == JPEGMarker.RST1
+ || marker == JPEGMarker.RST2
+ || marker == JPEGMarker.RST3
+ || marker == JPEGMarker.RST4
+ || marker == JPEGMarker.RST5
+ || marker == JPEGMarker.RST6
+ || marker == JPEGMarker.RST7)
+ {
+ for (int compIndex = 0; compIndex < numberOfComponents; compIndex++)
+ {
+ JPEGComponent comp = (JPEGComponent) frame.components.getComponentByID(componentSelector[compIndex]);
+ if (compIndex > 1)
+ comp.padMCU(mcuTotalIndex, resetInterval - mcuIndex);
+ comp.resetInterval();
+ }
+ mcuTotalIndex += (resetInterval - mcuIndex);
+ mcuIndex = 0;
+ }
+ else
+ {
+ // We're at the end of our scan, exit out.
+ break;
+ }
+ }
+ }
+ break;
+ case JPEGMarker.DRI:
+ // DRI - This defines the restart interval, if we have a
+ // restart interval when we reach our restart modulo calculate
+ // whether the count of MCU's specified in the restart
+ // interval have been reached, if they havent then pad with
+ // whatever MCU was last used, this is supposed to be a form of
+ // error recovery but it turns out that some JPEG encoders
+ // purposely cause missing MCU's on repeating MCU's to compress
+ // data even more (even though it adds an extra layer of
+ // complexity.. But since when is JPEG easy?
+ jpegStream.skipBytes(2);
+ resetInterval = jpegStream.readShort();
+ break;
+ case JPEGMarker.COM:
+ // COM - This is a comment that was inserted into the JPEG, we
+ // simply skip over the comment because it's really of no
+ // importance, usually contains a verbal description of the
+ // application or author who created the JPEG.
+ jpegStream.skipBytes(jpegStream.readShort() - 2);
+ break;
+ case JPEGMarker.DNL:
+ // DNL - This sets the height of the image. This is the Define
+ // Number Lines for the image, I'm not sure exactly why we need
+ // this but, whatever we'll abide.
+ frame.setScanLines(jpegStream.readShort());
+ break;
+ case JPEGMarker.EOI:
+ // EOI - End of Image, this processes the frames and turns the
+ // frames into a buffered image.
+
+ if (jpegFrames.size() == 0)
+ {
+ return;
+ }
+ else if (jpegFrames.size() == 1)
+ {
+ // Only one frame, JPEG Non-Heirarchial Frame.
+
+ DCT myDCT = new DCT();
+ WritableRaster raster =
+ Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
+ frame.width,
+ frame.height,
+ frame.getComponentCount(),
+ new Point(0, 0));
+
+ // Unencode the data.
+ for (int i = 0; i < frame.getComponentCount(); i++)
+ {
+ JPEGComponent comp =
+ (JPEGComponent) frame.components.get(i);
+ comp.setQuantizationTable(qTables[comp.quant_id].getTable());
+ comp.quantitizeData();
+ comp.idctData(myDCT);
+ }
+ // Scale the image and write the data to the raster.
+ for (int i = 0; i < frame.getComponentCount(); i++)
+ {
+ JPEGComponent comp = (JPEGComponent) frame.components.get(i);
+ comp.scaleByFactors();
+ comp.writeData(raster, i);
+ // Ensure garbage collection.
+ comp = null;
+ }
+ // Grayscale Color Image (1 Component).
+ if (frame.getComponentCount() == 1)
+ {
+ ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ ComponentColorModel ccm =
+ new ComponentColorModel(cs, false, false,
+ Transparency.OPAQUE,
+ DataBuffer.TYPE_BYTE);
+ image = new BufferedImage(ccm, raster, false,
+ new Hashtable());
+ }
+ // YCbCr Color Image (3 Components).
+ else if (frame.getComponentCount() == 3)
+ {
+ ComponentColorModel ccm =
+ new ComponentColorModel(new YCbCr_ColorSpace(), false,
+ false, Transparency.OPAQUE,
+ DataBuffer.TYPE_BYTE);
+ image = new BufferedImage(ccm, raster, false,
+ new Hashtable());
+ }
+ // Possibly CMYK or RGBA ?
+ else
+ {
+ throw new JPEGException("Unsupported Color Mode: 4 "
+ + "Component Color Mode found.");
+ }
+ height = frame.height;
+ width = frame.width;
+ }
+ else
+ {
+ //JPEG Heirarchial Frame (progressive or baseline).
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Hierarchial JPEG");
+ }
+ break;
+ case JPEGMarker.SOF1:
+ // ERROR - If we encounter any of the following marker codes
+ // error out with a codec exception, progressive, heirarchial,
+ // differential, arithmetic, lossless JPEG's are not supported.
+ // This is where enhancements can be made for future versions.
+ // Thankfully 99% of all JPEG's are baseline DCT.
+ throw new JPEGException("Unsupported Codec Type: Extended "
+ + "Sequential DCT JPEG's Not-Supported");
+ //case JPEGMarker.SOF2:
+ // throw new JPEGException("Unsupported Codec Type: Progressive DCT JPEG's Not-Supported");
+ case JPEGMarker.SOF3:
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Lossless (sequential)");
+ case JPEGMarker.SOF5:
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Differential sequential DCT");
+ case JPEGMarker.SOF6:
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Differential progressive DCT");
+ case JPEGMarker.SOF7:
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Differential lossless");
+ case JPEGMarker.SOF9:
+ case JPEGMarker.SOF10:
+ case JPEGMarker.SOF11:
+ case JPEGMarker.SOF13:
+ case JPEGMarker.SOF14:
+ case JPEGMarker.SOF15:
+ throw new JPEGException("Unsupported Codec Type:"
+ + " Arithmetic Coding Frame");
+ default:
+ // Unknown marker found, ignore it.
+ }
+ marker = jpegStream.findNextMarker();
+ }
+ }
+
+ // If the current marker is APP0, tries to decode a JFIF extension
+ // and advances the current marker to the next marker in the stream.
+ private void decodeJFIFExtension() throws IOException
+ {
+ if (marker == JPEGMarker.APP0)
+ {
+ int length = jpegStream.readShort();
+
+ if (length >= JFXX_FIXED_LENGTH)
+ {
+ byte[] identifier = new byte[5];
+ jpegStream.read(identifier);
+ if (identifier[0] != JPEGMarker.JFIF_J
+ || identifier[1] != JPEGMarker.JFIF_F
+ || identifier[2] != JPEGMarker.JFIF_X
+ || identifier[3] != JPEGMarker.JFIF_X
+ || identifier[4] != JPEGMarker.X00)
+ // Not a JFXX field. Ignore it and continue.
+ jpegStream.skipBytes(length - 7);
+ else
+ {
+ byte extension_code = jpegStream.readByte();
+
+ switch (extension_code)
+ {
+ case JPEGMarker.JFXX_JPEG:
+ // FIXME: add support for JFIF Extension:
+ // Thumbnail coded using JPEG.
+ jpegStream.skipBytes(length - 8);
+ case JPEGMarker.JFXX_ONE_BPP:
+ // FIXME: add support for JFIF Extension:
+ // Thumbnail stored using 1 byte/pixel.
+ jpegStream.skipBytes(length - 8);
+ case JPEGMarker.JFXX_THREE_BPP:
+ // FIXME: add support for JFIF Extension:
+ // Thumbnail stored using 3 bytes/pixel.
+ jpegStream.skipBytes(length - 8);
+ }
+ }
+ }
+ else
+ {
+ // Unknown APP0 marker. Ignore it and continue.
+ jpegStream.skipBytes(length - 2);
+ }
+ marker = jpegStream.findNextMarker();
+ }
+ }
+
+ public BufferedImage getImage()
+ {
+ return image;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGException.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGException.java
new file mode 100644
index 00000000000..b684069ccb6
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGException.java
@@ -0,0 +1,55 @@
+/* JPEGException.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+// FIXME: change to IIOException
+import java.io.IOException;
+import javax.imageio.*;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+
+public class JPEGException extends IIOException
+{
+ public JPEGException(String message)
+ {
+ super(message);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGFrame.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGFrame.java
new file mode 100644
index 00000000000..9b958f98f2c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGFrame.java
@@ -0,0 +1,108 @@
+/* JPEGFrame.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
+
+public class JPEGFrame
+{
+ public final static byte JPEG_COLOR_GRAY = 1;
+ public final static byte JPEG_COLOR_RGB = 2;
+ public final static byte JPEG_COLOR_YCbCr = 3;
+ public final static byte JPEG_COLOR_CMYK = 4;
+
+ public byte precision = 8;
+ public byte colorMode = JPEGFrame.JPEG_COLOR_YCbCr;
+ public byte componentCount = 0;
+
+ public short width=0, height=0;
+
+ public JPEGScan components;
+
+ public JPEGFrame()
+ {
+ components = new JPEGScan();
+ }
+
+ public void addComponent(byte componentID, byte sampleFactors,
+ byte quantizationTableID)
+ {
+ byte sampleHorizontalFactor = (byte)(sampleFactors >> 4);
+ byte sampleVerticalFactor = (byte)(sampleFactors & 0x0f);
+ components.addComponent(componentID, sampleHorizontalFactor,
+ sampleVerticalFactor, quantizationTableID);
+ }
+
+ public void setPrecision(byte data)
+ {
+ precision = data;
+ }
+
+ public void setScanLines(short data)
+ {
+ height = data;
+ }
+
+ public void setSamplesPerLine(short data)
+ {
+ width = data;
+ }
+
+ public void setColorMode(byte data)
+ {
+ colorMode = data;
+ }
+
+ public void setComponentCount(byte data)
+ {
+ componentCount = data;
+ }
+
+ public byte getComponentCount()
+ {
+ return componentCount;
+ }
+
+ public void setHuffmanTables(byte componentID, JPEGHuffmanTable ACTable,
+ JPEGHuffmanTable DCTable)
+ {
+ JPEGComponent comp = (JPEGComponent)components.getComponentByID(componentID);
+ comp.setACTable(ACTable);
+ comp.setDCTable(DCTable);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java
new file mode 100644
index 00000000000..4ae909baf15
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java
@@ -0,0 +1,195 @@
+/* JPEGImageInputStream.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.io.EOFException;
+import java.io.IOException;
+import javax.imageio.*;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageInputStreamImpl;
+
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+
+public class JPEGImageInputStream
+ extends ImageInputStreamImpl
+{
+ private ImageInputStream in;
+
+ byte marker;
+
+ public JPEGImageInputStream(ImageInputStream in)
+ {
+ super();
+
+ this.in = in;
+ }
+
+ public int read()
+ throws IOException
+ {
+ setBitOffset(0);
+ return in.read();
+ }
+
+ public int read(byte[] data, int offset, int len)
+ throws IOException
+ {
+ setBitOffset(0);
+ return in.read(data, offset, len);
+ }
+
+ /**
+ * Pull a byte from the stream, this checks to see if the byte is 0xff
+ * and if the next byte isn't 0x00 (stuffed byte) it errors out. If it's
+ * 0x00 then it simply ignores the byte.
+ *
+ * @return the next byte in the buffer
+ *
+ * @throws IOException TODO
+ * @throws BitStreamException TODO
+ */
+ private byte pullByte() throws IOException, JPEGMarkerFoundException
+ {
+ byte mybyte = readByte();
+ // FIXME: handle multiple 0xff in a row
+ if(mybyte==(byte)(0xff))
+ {
+ byte secondbyte = readByte();
+ if(secondbyte != (byte)(0x00))
+ {
+ marker = secondbyte;
+ throw new JPEGMarkerFoundException();
+ }
+ }
+ return mybyte;
+ }
+
+ /**
+ * This returns the marker that was last encountered. This should only be
+ * used if removeBit() throws a MarkerTagFound exception.
+ *
+ * @return marker as byte
+ */
+ public byte getMarker()
+ {
+ return marker;
+ }
+
+ /**
+ * Removes a bit from the buffer. (Removes from the top of a queue). This
+ * also checks for markers and throws MarkerTagFound exception if it does.
+ * If MarkerTagFound is thrown you can use getMarker() method to get the
+ * marker that caused the throw.
+ *
+ * @param l specifies how many bits you want to remove and add to the
+ * integer
+ * @return the amount of bits specified by l as an integer
+ *
+ * @throws IOException TODO
+ * @throws JPEGMarkerFoundException
+ * @throws BitStreamException TODO
+ */
+ public int readBit()
+ throws IOException, JPEGMarkerFoundException
+{
+ checkClosed();
+
+ // Calc new bit offset here, readByte resets it.
+ int newOffset = (bitOffset + 1) & 0x7;
+
+ byte data = pullByte();
+
+ if (bitOffset != 0)
+ {
+ seek(getStreamPosition() - 1);
+ data = (byte) (data >> (8 - newOffset));
+ }
+
+ bitOffset = newOffset;
+ return data & 0x1;
+}
+
+
+ /**
+ * This method skips over the the data and finds the next position
+ * in the bit sequence with a X'FF' X'??' sequence. Multiple X'FF
+ * bytes in sequence are considered padding and interpreted as one
+ * X'FF byte.
+ *
+ * @return the next marker byte in the stream
+ * @throws IOException if the end of the stream is reached
+ * unexpectedly
+ */
+ public byte findNextMarker()
+ throws IOException
+ {
+ boolean marked0xff = false;
+ byte byteinfo = JPEGMarker.X00;
+
+ setBitOffset(0);
+ while (true)
+ {
+ byteinfo = readByte();
+ if (!marked0xff)
+ {
+ if (byteinfo == JPEGMarker.XFF)
+ marked0xff = true;
+ }
+ else
+ {
+ if (byteinfo == JPEGMarker.XFF)
+ // Ignore the value 0xff when it is immediately
+ // followed by another 0xff byte.
+ continue;
+ else if (byteinfo == JPEGMarker.X00)
+ // The sequence 0xff 0x00 is used to encode the
+ // actual value 0xff. So restart our search for a
+ // marker.
+ marked0xff = false;
+ else
+ // One or more 0xff values were follwed by a
+ // non-0x00, non-0xff value so return this as the
+ // marker byte.
+ return byteinfo;
+ }
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java
new file mode 100644
index 00000000000..51bc0ce3760
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java
@@ -0,0 +1,141 @@
+/* JPEGImageReader.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.io.IOException;
+import javax.imageio.*;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+
+public class JPEGImageReader extends ImageReader
+{
+ JPEGDecoder decoder;
+
+ protected JPEGImageReader(ImageReaderSpi originatingProvider)
+ {
+ super(originatingProvider);
+ System.out.println("JPEGIMAGEREADER!!!");
+ }
+
+ // Abstract ImageReader methods.
+ public int getHeight(int imageIndex)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ decodeStream();
+ return decoder.getHeight();
+ }
+
+ public IIOMetadata getImageMetadata(int imageIndex)
+ throws IOException
+ {
+ // FIXME: handle metadata
+ checkIndex(imageIndex);
+ return null;
+ }
+
+ public Iterator getImageTypes(int imageIndex)
+ throws IOException
+ {
+ return null;
+ }
+
+ public int getNumImages(boolean allowSearch)
+ throws IOException
+ {
+ return 1;
+ }
+
+ public IIOMetadata getStreamMetadata()
+ throws IOException
+ {
+ // FIXME: handle metadata
+ return null;
+ }
+
+ public int getWidth(int imageIndex)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ decodeStream();
+ return decoder.getWidth();
+ }
+
+ public BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ decodeStream();
+ return decoder.getImage();
+ }
+
+ // private helper methods
+ private void checkIndex(int imageIndex)
+ throws IndexOutOfBoundsException
+ {
+ if (imageIndex != 0)
+ throw new IndexOutOfBoundsException();
+ }
+
+ private void checkStream() throws IOException
+ {
+ if (!(input instanceof ImageInputStream))
+ throw new IllegalStateException("Input not an ImageInputStream.");
+ if(input == null)
+ throw new IllegalStateException("No input stream.");
+ }
+
+ private void decodeStream()
+ throws IOException, IIOException
+ {
+ System.out.println("DECONDING 1");
+ if (decoder != null)
+ return;
+
+ System.out.println("DECONDING 2");
+ checkStream();
+
+ System.out.println("DECONDING 3");
+ decoder = new JPEGDecoder((ImageInputStream)input);
+ System.out.println("DECONDING 4");
+ decoder.decode();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java
new file mode 100644
index 00000000000..c1e9adf6027
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java
@@ -0,0 +1,137 @@
+/* JPEGImageReaderSpi.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.io.IOException;
+import java.util.Locale;
+import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.stream.ImageInputStream;
+
+public class JPEGImageReaderSpi extends ImageReaderSpi
+{
+ static final String vendorName = "GNU";
+ static final String version = "0.1";
+ static final String readerClassName =
+ "gnu.javax.imageio.jpeg.JPEGImageReader";
+ static final String[] names = { "JPEG" };
+ static final String[] suffixes = { ".jpeg", ".jpg", ".jpe" };
+ static final String[] MIMETypes = { "image/jpeg" };
+ static final String[] writerSpiNames =
+ { "gnu.javax.imageio.jpeg.JPEGImageWriterSpi" };
+
+ static final boolean supportsStandardStreamMetadataFormat = false;
+ static final String nativeStreamMetadataFormatName = null;
+ static final String nativeStreamMetadataFormatClassName = null;
+ static final String[] extraStreamMetadataFormatNames = null;
+ static final String[] extraStreamMetadataFormatClassNames = null;
+ static final boolean supportsStandardImageMetadataFormat = false;
+ static final String nativeImageMetadataFormatName = null;
+ static final String nativeImageMetadataFormatClassName = null;
+ static final String[] extraImageMetadataFormatNames = null;
+ static final String[] extraImageMetadataFormatClassNames = null;
+
+ private static JPEGImageReaderSpi readerSpi;
+
+ public JPEGImageReaderSpi()
+ {
+ super(vendorName, version,
+ names, suffixes, MIMETypes,
+ readerClassName,
+ STANDARD_INPUT_TYPE, // Accept ImageInputStreams
+ writerSpiNames,
+ supportsStandardStreamMetadataFormat,
+ nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName,
+ extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames,
+ supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName,
+ nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames,
+ extraImageMetadataFormatClassNames);
+ System.out.println ("JPEGImageReaderSPI!!!");
+ }
+
+ public String getDescription(Locale locale)
+ {
+ return "JPEG ISO 10918-1, JFIF V1.02";
+ }
+
+ public boolean canDecodeInput(Object input)
+ throws IOException
+ {
+ if (!(input instanceof ImageInputStream))
+ return false;
+
+ ImageInputStream in = (ImageInputStream) input;
+ boolean retval;
+
+ in.mark();
+ try
+ {
+ new JPEGDecoder(in);
+ retval = true;
+ }
+ catch(JPEGException e)
+ {
+ retval = false;
+ }
+ in.reset();
+
+ return retval;
+ }
+
+ public ImageReader createReaderInstance(Object extension)
+ {
+ return new JPEGImageReader(this);
+ }
+
+ public static void registerSpis(IIORegistry reg)
+ {
+ reg.registerServiceProvider(getReaderSpi(), ImageReaderSpi.class);
+ }
+
+ public static synchronized JPEGImageReaderSpi getReaderSpi()
+ {
+ if (readerSpi == null)
+ readerSpi = new JPEGImageReaderSpi();
+ return readerSpi;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarker.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarker.java
new file mode 100644
index 00000000000..c80a0ca78fe
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarker.java
@@ -0,0 +1,205 @@
+/* JPEGMarker.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+public class JPEGMarker
+{
+ /**
+ * JFIF identifiers.
+ */
+ public final static byte JFIF_J = (byte) 0x4a;
+ public final static byte JFIF_F = (byte) 0x46;
+ public final static byte JFIF_I = (byte) 0x49;
+ public final static byte JFIF_X = (byte) 0x46;
+
+ /**
+ * JFIF extension codes.
+ */
+ public final static byte JFXX_JPEG = (byte) 0x10;
+ public final static byte JFXX_ONE_BPP = (byte) 0x11;
+ public final static byte JFXX_THREE_BPP = (byte) 0x13;
+
+ /**
+ * Marker prefix byte.
+ */
+ public final static byte XFF = (byte) 0xff;
+
+ /**
+ * Marker byte that represents a literal 0xff.
+ */
+ public final static byte X00 = (byte) 0x00;
+
+ /**
+ * Application Reserved Keyword.
+ */
+ public final static byte APP0 = (byte) 0xe0;
+
+ public final static byte APP1 = (byte) 0xe1;
+ public final static byte APP2 = (byte) 0xe2;
+ public final static byte APP3 = (byte) 0xe3;
+ public final static byte APP4 = (byte) 0xe4;
+ public final static byte APP5 = (byte) 0xe5;
+ public final static byte APP6 = (byte) 0xe6;
+ public final static byte APP7 = (byte) 0xe7;
+ public final static byte APP8 = (byte) 0xe8;
+ public final static byte APP9 = (byte) 0xe9;
+ public final static byte APP10 = (byte) 0xea;
+ public final static byte APP11 = (byte) 0xeb;
+ public final static byte APP12 = (byte) 0xec;
+ public final static byte APP13 = (byte) 0xed;
+ public final static byte APP14 = (byte) 0xee;
+ public final static byte APP15 = (byte) 0xef;
+
+ /**
+ * Modulo Restart Interval.
+ */
+ public final static byte RST0 = (byte) 0xd0;
+
+ public final static byte RST1 = (byte) 0xd1;
+ public final static byte RST2 = (byte) 0xd2;
+ public final static byte RST3 = (byte) 0xd3;
+ public final static byte RST4 = (byte) 0xd4;
+ public final static byte RST5 = (byte) 0xd5;
+ public final static byte RST6 = (byte) 0xd6;
+ public final static byte RST7 = (byte) 0xd7;
+
+ /**
+ * Nondifferential Huffman-coding frame (baseline dct).
+ */
+ public final static byte SOF0 = (byte) 0xc0;
+
+ /**
+ * Nondifferential Huffman-coding frame (extended dct).
+ */
+ public final static byte SOF1 = (byte) 0xc1;
+
+ /**
+ * Nondifferential Huffman-coding frame (progressive dct).
+ */
+ public final static byte SOF2 = (byte) 0xc2;
+
+ /**
+ * Nondifferential Huffman-coding frame Lossless (Sequential).
+ */
+ public final static byte SOF3 = (byte) 0xc3;
+
+ /**
+ * Differential Huffman-coding frame Sequential DCT.
+ */
+ public final static byte SOF5 = (byte) 0xc5;
+
+ /**
+ * Differential Huffman-coding frame Progressive DCT.
+ */
+ public final static byte SOF6 = (byte) 0xc6;
+
+ /**
+ * Differential Huffman-coding frame lossless.
+ */
+ public final static byte SOF7 = (byte) 0xc7;
+
+ /**
+ * Nondifferential Arithmetic-coding frame (extended dct).
+ */
+ public final static byte SOF9 = (byte) 0xc9;
+
+ /**
+ * Nondifferential Arithmetic-coding frame (progressive dct).
+ */
+ public final static byte SOF10 = (byte) 0xca;
+
+ /**
+ * Nondifferential Arithmetic-coding frame (lossless).
+ */
+ public final static byte SOF11 = (byte) 0xcb;
+
+ /**
+ * Differential Arithmetic-coding frame (sequential dct).
+ */
+ public final static byte SOF13 = (byte) 0xcd;
+
+ /**
+ * Differential Arithmetic-coding frame (progressive dct).
+ */
+ public final static byte SOF14 = (byte) 0xce;
+
+ /**
+ * Differential Arithmetic-coding frame (lossless).
+ */
+ public final static byte SOF15 = (byte) 0xcf;
+
+ /**
+ * Huffman Table.
+ */
+ public final static byte DHT = (byte) 0xc4;
+
+ /**
+ * Quantization Table.
+ */
+ public final static byte DQT = (byte) 0xdb;
+
+ /**
+ * Start of Scan.
+ */
+ public final static byte SOS = (byte) 0xda;
+
+ /**
+ * Defined Restart Interval.
+ */
+ public final static byte DRI = (byte) 0xdd;
+
+ /**
+ * Comment in JPEG.
+ */
+ public final static byte COM = (byte) 0xfe;
+
+ /**
+ * Start of Image.
+ */
+ public final static byte SOI = (byte) 0xd8;
+
+ /**
+ * End of Image.
+ */
+ public final static byte EOI = (byte) 0xd9;
+
+ /**
+ * Define Number of Lines.
+ */
+ public final static byte DNL = (byte) 0xdc;
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java
new file mode 100644
index 00000000000..2e72d495b52
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java
@@ -0,0 +1,50 @@
+/* JPEGMarkerFoundException.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.imageio.jpeg;
+
+import java.io.IOException;
+
+public class JPEGMarkerFoundException
+ extends IOException
+{
+ public JPEGMarkerFoundException()
+ {
+ super("");
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/JPEGScan.java b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGScan.java
new file mode 100644
index 00000000000..e0725102135
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/JPEGScan.java
@@ -0,0 +1,151 @@
+/* JPEGScan.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.util.ArrayList;
+
+public class JPEGScan
+{
+ private int maxHeight = 0, maxWidth = 0, maxV = 0, maxH = 0;
+ private int numOfComponents = 0, numOfComponentBlocks = 0;
+ private ArrayList components = new ArrayList();
+
+ public JPEGScan()
+ {
+ // Nothing to do here.
+ }
+
+ public JPEGScan(int h, int w)
+ {
+ maxHeight=h;
+ maxWidth=w;
+ }
+
+ private void recalculateDimensions()
+ {
+ JPEGComponent comp;
+
+ // Compute the maximum H, maximum V factors defined in Annex A of the ISO
+ // DIS 10918-1.
+ for(int i=0; i < components.size() ; i++)
+ {
+ comp = (JPEGComponent)components.get(i);
+ if(comp.factorH > maxH)
+ maxH=comp.factorH;
+ if(comp.factorV > maxV)
+ maxV=comp.factorV;
+ }
+
+ for(int i=0; i < components.size() ; i++)
+ {
+ comp = (JPEGComponent)components.get(i);
+ comp.maxH = maxH;
+ comp.maxV = maxV;
+ }
+
+ }
+
+ public void addComponent(byte id, byte factorHorizontal, byte factorVertical,
+ byte quantizationID)
+ {
+ JPEGComponent component = new JPEGComponent(id, factorHorizontal, factorVertical, quantizationID);
+ components.add((Object)component);
+ recalculateDimensions();
+ numOfComponents++;
+ numOfComponentBlocks += factorHorizontal*factorVertical;
+ }
+
+ public JPEGComponent getComponentByID(byte id)
+ {
+ JPEGComponent comp = (JPEGComponent)components.get(0);
+ for(int i=0; i < components.size() ; i++)
+ {
+ comp=(JPEGComponent)components.get(i);
+ if(comp.component_id==id)
+ break;
+ }
+ return(comp);
+ }
+
+ public JPEGComponent get(int id)
+ {
+ return((JPEGComponent)components.get(id));
+ }
+
+ public int getX(byte id)
+ {
+ JPEGComponent comp = getComponentByID(id);
+ return(comp.width);
+ }
+
+ public int getY(byte id)
+ {
+ JPEGComponent comp = getComponentByID(id);
+ return(comp.height);
+ }
+
+ public int getMaxV()
+ {
+ return(maxV);
+ }
+
+ public int getMaxH()
+ {
+ return(maxH);
+ }
+
+ public void setWidth(int w)
+ {
+ maxWidth=w;
+ }
+
+ public void setHeight(int h)
+ {
+ maxHeight=h;
+ }
+
+ public int size()
+ {
+ return(numOfComponents);
+ }
+
+ public int sizeComponentBlocks()
+ {
+ return(numOfComponentBlocks);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java b/libjava/classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java
new file mode 100644
index 00000000000..a3970b7fa65
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java
@@ -0,0 +1,113 @@
+/* YCbCr_ColorSpace.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+import java.awt.color.ColorSpace;
+
+public class YCbCr_ColorSpace extends ColorSpace {
+ public YCbCr_ColorSpace() {
+ super(ColorSpace.TYPE_YCbCr, 3);
+ }
+
+ public float[] fromCIEXYZ(float[] data) {
+ return(new float[data.length]);
+ }
+
+ public float[] toCIEXYZ(float[] data) {
+ return(new float[data.length]);
+ }
+
+ public float[] fromRGB(float[] data) {
+ return(new float[data.length]);
+ }
+
+ /* YCbCr to RGB range 0 to 1 */
+ public float[] toRGB(float[] data) {
+ float[] dest = new float[3];
+
+ data[0] *= 255;
+ data[1] *= 255;
+ data[2] *= 255;
+
+ dest[0] = (float)data[0] + (float)1.402*((float)data[2]-(float)128);
+ dest[1] = (float)data[0] - (float)0.34414*((float)data[1]-(float)128) - (float)0.71414*((float)data[2]-(float)128);
+ dest[2] = (float)data[0] + (float)1.772*((float)data[1]-(float)128);
+
+ dest[0] /= 255;
+ dest[1] /= 255;
+ dest[2] /= 255;
+
+ //dest[0] = ((float)1.164*((float)data[0]*(float)255 - (float)16) + (float)1.596*((float)data[2]*(float)255 - (float)128))/(float)255;
+ //dest[1] = ((float)1.164*((float)data[0]*(float)255 - (float)16) - (float)0.813*((float)data[2]*(float)255 - (float)128) - (float)0.392*(data[1]*255 - 128))/(float)255;
+ //dest[2] = ((float)1.164*((float)data[0]*(float)255 - (float)16) + (float)2.017*((float)data[1]*(float)255 - (float)128))/(float)255;
+
+ //System.err.println("toRGB values received: 0: "+data[0]+" 1: "+data[1]+" 2: "+data[2]+" sent: 0: "+dest[0]+" 1: "+dest[1]+" 2: "+dest[2]);
+ if(dest[0] < (float)0)
+ dest[0] = 0;
+ if(dest[1] < (float)0)
+ dest[1] = 0;
+ if(dest[2] < (float)0)
+ dest[2] = 0;
+
+ if(dest[0] > (float)1)
+ dest[0] = 1;
+ if(dest[1] > (float)1)
+ dest[1] = 1;
+ if(dest[2] > (float)1)
+ dest[2] = 1;
+
+
+ return(dest);
+ }
+
+ /* RGB to YCbCr range 0-255 */
+ public static float[] toYCbCr(float[] data) {
+ float[] dest = new float[3];
+ //dest[0] = (float)0.257*data[0] + (float)0.504*data[1] + (float)0.098*data[2] + 16;
+ //dest[1] = (float)-0.148*data[0] - (float)0.291*data[1] + (float)0.439*data[2] + 128;
+ //dest[2] = (float)0.439*data[0] - (float)0.368*data[1] - (float)0.071*data[2] + 128;
+
+ dest[0] = (float)((0.299 * (float)data[0] + 0.587 * (float)data[1] + 0.114 * (float)data[2]));
+ dest[1] = 128 + (float)((-0.16874 * (float)data[0] - 0.33126 * (float)data[1] + 0.5 * (float)data[2]));
+ dest[2] = 128 + (float)((0.5 * (float)data[0] - 0.41869 * (float)data[1] - 0.08131 * (float)data[2]));
+
+
+ return(dest);
+
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/jpeg/ZigZag.java b/libjava/classpath/gnu/javax/imageio/jpeg/ZigZag.java
new file mode 100644
index 00000000000..0c19d74ff26
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/jpeg/ZigZag.java
@@ -0,0 +1,520 @@
+/* ZigZag.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.jpeg;
+
+/**
+ * This class implements the Zig Zag Algorithm on any array with
+ * the same amount of rows and columns. It takes a matrix and in turn builds an
+ * encoded byte array (or double array) from it. The adverse is also true, this
+ * will take a byte or double array and build a matrix based on the zig zag
+ * algorithm.
+ * <p>This is used exclusively in the JPEG DCT encoding.</p>
+ */
+public class ZigZag
+{
+ public final static boolean ZIGZAG_FORWARD = true;
+ public final static boolean ZIGZAG_BACKWARD = false;
+ public final static int ZIGZAG_8X8_MAP[] =
+ {
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+ };
+
+ /**
+ * Encodes a matrix of equal width and height to a byte array.
+ *
+ * @param matrix
+ *
+ * @return
+ */
+ public static byte[] encode(byte[][] matrix)
+ {
+ byte[] buffer = new byte[matrix.length ^ 2];
+ boolean direction = ZigZag.ZIGZAG_FORWARD;
+ int x = 0, y = 0, index = 0;
+ for (int zigIndex = 0; zigIndex < (matrix.length * 2 - 1);
+ zigIndex++, direction = !direction)
+ {
+ if (direction == ZigZag.ZIGZAG_FORWARD)
+ {
+ while (x >= 0 && y != matrix.length)
+ {
+ if (x == matrix.length)
+ {
+ x--;
+ y++;
+ }
+ buffer[index] = matrix[x][y];
+ y++;
+ x--;
+ index++;
+ }
+ x++;
+ }
+ else
+ {
+ while (y >= 0 && x != matrix.length)
+ {
+ if (y == matrix.length)
+ {
+ y--;
+ x++;
+ }
+ buffer[index] = matrix[x][y];
+ y--;
+ x++;
+ index++;
+ }
+ y++;
+ }
+ }
+ return (buffer);
+ }
+
+ /**
+ * Encodes a matrix of equal width and height to a double array
+ *
+ * @param matrix
+ *
+ * @return
+ */
+ public static double[] encode(double[][] matrix)
+ {
+ double[] buffer = new double[matrix.length * matrix.length];
+ boolean direction = ZigZag.ZIGZAG_FORWARD;
+ int x = 0, y = 0, index = 0;
+ for (int zigIndex = 0; zigIndex < (matrix.length * 2 - 1);
+ zigIndex++, direction = !direction)
+ {
+ if (direction == ZigZag.ZIGZAG_FORWARD)
+ {
+ while (x >= 0 && y != matrix.length)
+ {
+ if (x == matrix.length)
+ {
+ x--;
+ y++;
+ }
+ buffer[index] = matrix[x][y];
+ y++;
+ x--;
+ index++;
+ }
+ x++;
+ }
+ else
+ {
+ while (y >= 0 && x != matrix.length)
+ {
+ if (y == matrix.length)
+ {
+ y--;
+ x++;
+ }
+ buffer[index] = matrix[x][y];
+ y--;
+ x++;
+ index++;
+ }
+ y++;
+ }
+ }
+ return (buffer);
+ }
+
+ /**
+ * Encodes a matrix of equal width and height to a float array
+ *
+ * @param matrix
+ *
+ * @return
+ */
+ public static float[] encode(float[][] matrix)
+ {
+ float[] buffer = new float[matrix.length * matrix.length];
+ boolean direction = ZigZag.ZIGZAG_FORWARD;
+ int x = 0, y = 0, index = 0;
+ for (int zigIndex = 0; zigIndex < (matrix.length * 2 - 1);
+ zigIndex++, direction = !direction)
+ {
+ if (direction == ZigZag.ZIGZAG_FORWARD)
+ {
+ while (x >= 0 && y != matrix.length)
+ {
+ if (x == matrix.length)
+ {
+ x--;
+ y++;
+ }
+ buffer[index] = matrix[x][y];
+ y++;
+ x--;
+ index++;
+ }
+ x++;
+ }
+ else
+ {
+ while (y >= 0 && x != matrix.length)
+ {
+ if (y == matrix.length)
+ {
+ y--;
+ x++;
+ }
+ buffer[index] = matrix[x][y];
+ y--;
+ x++;
+ index++;
+ }
+ y++;
+ }
+ }
+ return (buffer);
+ }
+
+ /**
+ * Encodes a matrix of equal width and height to a float array
+ *
+ * @param matrix
+ *
+ * @return
+ */
+ public static short[] encode(short[][] matrix)
+ {
+ short[] buffer = new short[matrix.length * matrix.length];
+ boolean direction = ZigZag.ZIGZAG_FORWARD;
+ int x = 0, y = 0, index = 0;
+ for (int zigIndex = 0; zigIndex < (matrix.length * 2 - 1);
+ zigIndex++, direction = !direction)
+ {
+ if (direction == ZigZag.ZIGZAG_FORWARD)
+ {
+ while (x >= 0 && y != matrix.length)
+ {
+ if (x == matrix.length)
+ {
+ x--;
+ y++;
+ }
+ buffer[index] = matrix[x][y];
+ y++;
+ x--;
+ index++;
+ }
+ x++;
+ }
+ else
+ {
+ while (y >= 0 && x != matrix.length)
+ {
+ if (y == matrix.length)
+ {
+ y--;
+ x++;
+ }
+ buffer[index] = matrix[x][y];
+ y--;
+ x++;
+ index++;
+ }
+ y++;
+ }
+ }
+ return (buffer);
+ }
+
+ /**
+ * Convert a double array into a matrix with the same amount of columns and
+ * rows with length sqrt(double array length)
+ *
+ * @param data
+ *
+ * @return
+ */
+ public static double[][] decode(double[] data)
+ {
+ return decode(data, (int) Math.sqrt(data.length),
+ (int) Math.sqrt(data.length));
+ }
+
+ /**
+ * Convert a byte array into a matrix with the same amount of columns and
+ * rows with length sqrt(double array length)
+ *
+ * @param data
+ *
+ * @return
+ */
+ public static byte[][] decode(byte[] data)
+ {
+ return decode(data, (int) Math.sqrt(data.length),
+ (int) Math.sqrt(data.length));
+ }
+
+ public static int[][] decode(int[] data)
+ {
+ return decode(data, (int) Math.sqrt(data.length),
+ (int) Math.sqrt(data.length));
+ }
+
+ public static byte[][] decode(byte[] data, int width, int height)
+ {
+ byte[][] buffer = new byte[height][width];
+
+ for (int v = 0; v < height; v++)
+ for (int z = 0; z < width; z++)
+ buffer[v][z] = 11;
+
+ boolean dir = ZigZag.ZIGZAG_FORWARD;
+ int xindex = 0, yindex = 0, dataindex = 0;
+
+ while (xindex < width && yindex < height && dataindex < data.length)
+ {
+ buffer[yindex][xindex] = data[dataindex];
+ dataindex++;
+
+ if (dir == ZigZag.ZIGZAG_FORWARD)
+ {
+ if (yindex == 0 || xindex == (width - 1))
+ {
+ dir = ZigZag.ZIGZAG_BACKWARD;
+ if (xindex == (width - 1))
+ yindex++;
+ else
+ xindex++;
+ }
+ else
+ {
+ yindex--;
+ xindex++;
+ }
+ }
+ else
+ { /* Backwards */
+ if (xindex == 0 || yindex == (height - 1))
+ {
+ dir = ZigZag.ZIGZAG_FORWARD;
+ if (yindex == (height - 1))
+ xindex++;
+ else
+ yindex++;
+ }
+ else
+ {
+ yindex++;
+ xindex--;
+ }
+ }
+ }
+ return (buffer);
+ }
+
+ public static double[][] decode(double[] data, int width, int height)
+ {
+ double[][] buffer = new double[height][width];
+
+ for (int v = 0; v < height; v++)
+ for (int z = 0; z < width; z++)
+ buffer[v][z] = 11;
+
+ boolean dir = ZigZag.ZIGZAG_FORWARD;
+ int xindex = 0, yindex = 0, dataindex = 0;
+
+ while (xindex < width && yindex < height && dataindex < data.length)
+ {
+ buffer[yindex][xindex] = data[dataindex];
+ dataindex++;
+ System.err.println("Setting " + dataindex + " to row: " + yindex
+ + " column: " + xindex + " yourval:"
+ + (yindex*8+xindex));
+ if (dir == ZigZag.ZIGZAG_FORWARD)
+ {
+ if (yindex == 0 || xindex == (width - 1))
+ {
+ dir = ZigZag.ZIGZAG_BACKWARD;
+ if (xindex == (width - 1))
+ yindex++;
+ else
+ xindex++;
+ }
+ else
+ {
+ yindex--;
+ xindex++;
+ }
+ }
+ else
+ { /* Backwards */
+ if (xindex == 0 || yindex == (height - 1))
+ {
+ dir = ZigZag.ZIGZAG_FORWARD;
+ if (yindex == (height - 1))
+ xindex++;
+ else
+ yindex++;
+ }
+ else
+ {
+ yindex++;
+ xindex--;
+ }
+ }
+ }
+ return (buffer);
+ }
+
+ public static float[][] decode(float[] data, int width, int height)
+ {
+ float[][] buffer = new float[height][width];
+
+ for (int v = 0; v < height; v++)
+ for (int z = 0; z < width; z++)
+ buffer[v][z] = 11;
+
+ boolean dir = ZigZag.ZIGZAG_FORWARD;
+ int xindex = 0, yindex = 0, dataindex = 0;
+
+ while (xindex < width && yindex < height && dataindex < data.length)
+ {
+ buffer[yindex][xindex] = data[dataindex];
+ dataindex++;
+
+ if (dir == ZigZag.ZIGZAG_FORWARD)
+ {
+ if (yindex == 0 || xindex == (width - 1))
+ {
+ dir = ZigZag.ZIGZAG_BACKWARD;
+ if (xindex == (width - 1))
+ yindex++;
+ else
+ xindex++;
+ }
+ else
+ {
+ yindex--;
+ xindex++;
+ }
+ }
+ else
+ { /* Backwards */
+ if (xindex == 0 || yindex == (height - 1))
+ {
+ dir = ZigZag.ZIGZAG_FORWARD;
+ if (yindex == (height - 1))
+ xindex++;
+ else
+ yindex++;
+ }
+ else
+ {
+ yindex++;
+ xindex--;
+ }
+ }
+ }
+ return (buffer);
+ }
+
+ public static int[][] decode(int[] data, int width, int height)
+ {
+ int[][] buffer = new int[height][width];
+
+ for (int v = 0; v < height; v++)
+ for (int z = 0; z < width; z++)
+ buffer[v][z] = 11;
+
+ boolean dir = ZigZag.ZIGZAG_FORWARD;
+ int xindex = 0, yindex = 0, dataindex = 0;
+
+ while (xindex < width && yindex < height && dataindex < data.length)
+ {
+ buffer[yindex][xindex] = data[dataindex];
+ dataindex++;
+
+ if (dir == ZigZag.ZIGZAG_FORWARD)
+ {
+ if (yindex == 0 || xindex == (width - 1))
+ {
+ dir = ZigZag.ZIGZAG_BACKWARD;
+ if (xindex == (width - 1))
+ yindex++;
+ else
+ xindex++;
+ }
+ else
+ {
+ yindex--;
+ xindex++;
+ }
+ }
+ else
+ { /* Backwards */
+ if (xindex == 0 || yindex == (height - 1))
+ {
+ dir = ZigZag.ZIGZAG_FORWARD;
+ if (yindex == (height - 1))
+ xindex++;
+ else
+ yindex++;
+ }
+ else
+ {
+ yindex++;
+ xindex--;
+ }
+ }
+ }
+ return (buffer);
+ }
+
+ public static double[][] decode8x8_map(double input[])
+ {
+ double[][] output = new double[8][8];
+ for(int i=0; i < 64 ; i++)
+ output[ZIGZAG_8X8_MAP[i]/8][ZIGZAG_8X8_MAP[i]%8] = input[i];
+ return (output);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGChunk.java b/libjava/classpath/gnu/javax/imageio/png/PNGChunk.java
new file mode 100644
index 00000000000..6b53810c89d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGChunk.java
@@ -0,0 +1,284 @@
+/* PNGChunk.java -- Generic PNG chunk
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.png;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Class to load and validate a generic PNG chunk.
+ */
+public class PNGChunk
+{
+
+ /**
+ * CRC table and initialization code.
+ */
+ private static long[] crcTable;
+
+ static
+ {
+ long c;
+ crcTable = new long[256];
+
+ for(int i = 0; i < 256; i++)
+ {
+ c = i;
+ for(int j = 0; j < 8; j++)
+ if( (c & 1) == 1 )
+ c = 0xEDB88320L ^ (c >> 1);
+ else
+ c = c >> 1;
+ crcTable[i] = c;
+ }
+ }
+
+ /**
+ * (recognized) PNG chunk types.
+ */
+ public static final int TYPE_HEADER = 0x49484452; // 'IHDR'
+ public static final int TYPE_PALETTE = 0x504c5445;// 'PLTE'
+ public static final int TYPE_DATA = 0x49444154; // 'IDAT'
+ public static final int TYPE_TIME = 0x74494d45; // 'tIME'
+ public static final int TYPE_END = 0x49454e44; // 'IEND'
+ public static final int TYPE_PHYS = 0x70485973; // 'pHYS'
+ public static final int TYPE_GAMMA = 0x67414d41; // 'gAMA'
+ public static final int TYPE_PROFILE = 0x69434350; // 'iCCP'
+
+ /**
+ * The chunk type - Represented in the file as 4 ASCII bytes,
+ */
+ private int type;
+
+ /**
+ * The chunk data
+ */
+ protected byte[] data;
+
+ /**
+ * The chunk's crc
+ */
+ private int crc;
+
+ /**
+ * Constructor for reading a generic chunk.
+ */
+ protected PNGChunk( int type, byte[] data, int crc )
+ {
+ this.type = type;
+ this.data = data;
+ this.crc = crc;
+ }
+
+ /**
+ * Constructor for creating new chunks.
+ * (only used by subclasses - creating a generic chunk is rather useless)
+ */
+ protected PNGChunk( int type )
+ {
+ this.type = type;
+ }
+
+ /**
+ * Loads a chunk from an InputStream. Does not perform validation,
+ * but will throw an IOException if the read fails.
+ * @param in - th einputstream to read from
+ * @param strict - if true, a PNGException is thrown on all invalid chunks,
+ * if false, only critical chunks will throw PNGExceptions.
+ */
+ public static PNGChunk readChunk(InputStream in, boolean strict)
+ throws IOException, PNGException
+ {
+ byte data[] = new byte[4];
+ if( in.read( data ) != 4 )
+ throw new IOException("Could not read chunk length.");
+ int length = ((data[0] & 0xFF) << 24) | ((data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+
+ if( in.read( data ) != 4 )
+ throw new IOException("Could not read chunk type.");
+ int type = ((data[0] & 0xFF) << 24) | ((data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+
+ byte[] chkdata = new byte[ length ];
+ if( in.read( chkdata ) != length )
+ throw new IOException("Could not read chunk data.");
+
+ if( in.read( data ) != 4 )
+ throw new IOException("Could not read chunk CRC.");
+
+ int crc = ((data[0] & 0xFF) << 24) | ( (data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+
+ if( strict )
+ return getChunk( type, chkdata, crc );
+ else
+ {
+ try
+ {
+ return getChunk( type, chkdata, crc );
+ }
+ catch(PNGException pnge)
+ {
+ if( isEssentialChunk( type ) )
+ throw pnge;
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Returns a specialied object for a chunk, if we have one.
+ */
+ private static PNGChunk getChunk( int type, byte[] data, int crc )
+ throws PNGException
+ {
+ switch( type )
+ {
+ case TYPE_HEADER:
+ return new PNGHeader( type, data, crc );
+ case TYPE_DATA:
+ return new PNGData( type, data, crc );
+ case TYPE_PALETTE:
+ return new PNGPalette( type, data, crc );
+ case TYPE_TIME:
+ return new PNGTime( type, data, crc );
+ case TYPE_PHYS:
+ return new PNGPhys( type, data, crc );
+ case TYPE_GAMMA:
+ return new PNGGamma( type, data, crc );
+ case TYPE_PROFILE:
+ return new PNGICCProfile( type, data, crc );
+ default:
+ return new PNGChunk( type, data, crc );
+ }
+ }
+
+ /**
+ * Returns whether the chunk is essential or not
+ */
+ private static boolean isEssentialChunk( int type )
+ {
+ switch( type )
+ {
+ case TYPE_HEADER:
+ case TYPE_DATA:
+ case TYPE_PALETTE:
+ case TYPE_END:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Validates the chunk
+ */
+ public boolean isValidChunk()
+ {
+ return (crc == calcCRC());
+ }
+
+ /**
+ * Returns the chunk type.
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ /**
+ * Writes a PNG chunk to an output stream,
+ * performing the CRC calculation as well.
+ */
+ public void writeChunk(OutputStream out) throws IOException
+ {
+ out.write( getInt(data.length) );
+ out.write( getInt(type) );
+ out.write( data );
+ out.write( getInt(calcCRC()) );
+ }
+
+ /**
+ * Return whether the chunk contains any data.
+ */
+ public boolean isEmpty()
+ {
+ return ( data.length == 0 );
+ }
+
+ /**
+ * Convenience method. Cast an int to four bytes (big endian).
+ * (Now why doesn't java have a simple way of doing this?)
+ */
+ public static byte[] getInt(int intValue)
+ {
+ long i = (intValue & 0xFFFFFFFFL);
+ byte[] b = new byte[4];
+ b[0] = (byte)((i & 0xFF000000L) >> 24);
+ b[1] = (byte)((i & 0x00FF0000L) >> 16);
+ b[2] = (byte)((i & 0x0000FF00L) >> 8);
+ b[3] = (byte)(i & 0x000000FFL);
+ return b;
+ }
+
+ /**
+ * Calculates this chunk's CRC value.
+ */
+ private int calcCRC()
+ {
+ long c = 0xFFFFFFFFL;
+ byte[] t = getInt( type );
+ for(int i = 0; i < 4; i++)
+ c = crcTable[ (int)((c ^ t[i]) & 0xFF) ] ^ (c >> 8);
+
+ for(int i = 0; i < data.length; i++)
+ c = crcTable[ (int)((c ^ data[i]) & 0xFF) ] ^ (c >> 8);
+
+ return (int)(c ^ 0xFFFFFFFFL);
+ }
+
+ public String toString()
+ {
+ return "PNG Chunk. Type: " + new String( getInt(type) ) + " , CRC: " +
+ crc + " , calculated CRC: "+calcCRC();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java b/libjava/classpath/gnu/javax/imageio/png/PNGData.java
index 46b0733d363..2a8f8aa2d55 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGData.java
@@ -1,5 +1,5 @@
-/* GtkCheckboxGroupPeer.java - Wrap a CheckboxGroup
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* PNGData.java -- PNG IDAT chunk.
+ Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -35,52 +35,70 @@ 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.imageio.png;
-package gnu.java.awt.peer.gtk;
+import java.util.zip.Inflater;
+import java.util.zip.Deflater;
-import java.awt.CheckboxGroup;
-import java.util.WeakHashMap;
+/**
+ * A PNG IDAT (data) chunk.
+ */
+public class PNGData extends PNGChunk
+{
+ private int offset;
-// Note that there is no peer interface for a CheckboxGroup. We
-// introduce our own in order to make it easier to keep a piece of
-// native state for each one.
-public class GtkCheckboxGroupPeer extends GtkGenericPeer
-{
- // This maps from a CheckboxGroup to the native peer.
- private static WeakHashMap map = new WeakHashMap ();
+ protected PNGData( int type, byte[] data, int crc )
+ {
+ super( type, data, crc );
+ }
- // Find the native peer corresponding to a CheckboxGroup.
- public static synchronized GtkCheckboxGroupPeer
- getCheckboxGroupPeer (CheckboxGroup group)
+ protected PNGData( int chunkSize )
{
- if (group == null)
- return null;
- GtkCheckboxGroupPeer nat = (GtkCheckboxGroupPeer) map.get (group);
- if (nat == null)
- {
- nat = new GtkCheckboxGroupPeer ();
- map.put (group, nat);
- }
- return nat;
+ super( PNGChunk.TYPE_DATA );
+ data = new byte[ chunkSize ];
+ offset = 0;
}
- private GtkCheckboxGroupPeer ()
+ /**
+ * Deflates the available data in def to the chunk.
+ *
+ * @return true if the chunk is filled and no more data can be written,
+ * false otherwise.
+ */
+ public void deflateToChunk( Deflater def )
{
- // We don't need any special state here. Note that we can't store
- // a reference to the java-side CheckboxGroup. That would mean
- // they could never be collected.
- super (null);
+ offset += def.deflate( data, offset, data.length - offset );
}
- // Dispose of our native resources.
- public native void dispose ();
+ /**
+ * Returns true if the chunk is filled.
+ */
+ public boolean chunkFull()
+ {
+ return (offset >= data.length);
+ }
- // Remove a given checkbox from this group.
- public native void remove (GtkCheckboxPeer box);
+ /**
+ * Shrink the chunk to offset size, used for the last chunk in a stream
+ * (no trailing data!)
+ */
+ public void shrink()
+ {
+ byte[] newData = new byte[ offset ];
+ System.arraycopy( data, 0, newData, 0, offset );
+ data = newData;
+ }
+
+ /**
+ * Feeds the data in the chunk to a ZIP inflater object.
+ */
+ public void feedToInflater( Inflater inf )
+ {
+ inf.setInput( data );
+ }
- // When collected, clean up the native state.
- protected void finalize ()
+ public String toString()
{
- dispose ();
+ return "PNG Data chunk. Length = "+data.length;
}
}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGDecoder.java b/libjava/classpath/gnu/javax/imageio/png/PNGDecoder.java
new file mode 100644
index 00000000000..20fc32ce371
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGDecoder.java
@@ -0,0 +1,331 @@
+/* PNGDecoder.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 gnu.javax.imageio.png;
+
+import java.util.zip.Inflater;
+import java.util.zip.DataFormatException;
+import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.IndexColorModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.Raster;
+import java.awt.image.SampleModel;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.WritableRaster;
+import java.awt.color.ColorSpace;
+
+public class PNGDecoder
+{
+ private PNGHeader header;
+ private byte[] raster;
+ private byte[] scanline, lastScanline;
+ private byte[] filterType;
+ private int offset, length;
+ private int currentScanline;
+ private final int stride;
+ private Inflater inflater;
+ private boolean readFilter;
+ private int bpp; // bytes per pixel
+
+ /**
+ * Constructs a filter object for
+ */
+ public PNGDecoder(PNGHeader header)
+ {
+ this.header = header;
+ offset = 0;
+ inflater = new Inflater();
+ stride = header.getScanlineStride();
+ length = stride * header.getHeight();
+
+ // Allocate the output raster
+ raster = new byte[ length ];
+ scanline = new byte[ stride ];
+ lastScanline = new byte[ stride ];
+ currentScanline = 0;
+ readFilter = true;
+ bpp = header.bytesPerPixel();
+ filterType = new byte[1];
+ inflater = new Inflater();
+ }
+
+ private int getBytes( byte[] buf, int offset ) throws PNGException
+ {
+ try
+ {
+ return inflater.inflate( buf, offset, buf.length - offset);
+ }
+ catch(DataFormatException dfe)
+ {
+ throw new PNGException("Error inflating data.");
+ }
+ }
+
+ /**
+ * Decodes a data chunk.
+ */
+ public void addData( PNGData chunk ) throws PNGException
+ {
+ int n = 0;
+ if( isFinished() )
+ return;
+ chunk.feedToInflater( inflater );
+ do
+ {
+ if( readFilter )
+ if( getBytes( filterType, 0 ) < 1 )
+ return;
+
+ n = getBytes( scanline, offset );
+
+ if( offset + n < stride )
+ {
+ offset += n;
+ readFilter = false;
+ }
+ else
+ {
+ scanline = PNGFilter.unFilterScanline( filterType[0], scanline,
+ lastScanline, bpp );
+ System.arraycopy( scanline, 0,
+ raster, currentScanline * stride, stride );
+ lastScanline = scanline;
+ scanline = new byte[scanline.length];
+ currentScanline++;
+ readFilter = true;
+ offset = 0;
+ }
+ }
+ while( n > 0 && currentScanline < header.getHeight() );
+ }
+
+ /**
+ * Parse the appropriate color type and create an AWT raster for it.
+ * @param raster - the file header.
+ */
+ public WritableRaster getRaster( PNGHeader header )
+ {
+ SampleModel sm = null;
+ DataBuffer db = null;
+ int t;
+ int width = header.getWidth();
+ int height = header.getHeight();
+ int depth = header.getDepth();
+
+ switch( header.getColorType() )
+ {
+ case PNGHeader.GRAYSCALE_WITH_ALPHA:
+ if( depth == 8 )
+ {
+ t = DataBuffer.TYPE_BYTE;
+ db = getByteBuffer();
+ }
+ else
+ {
+ t = DataBuffer.TYPE_USHORT;
+ db = getShortBuffer();
+ }
+ sm = new ComponentSampleModel(t, width, height, 2, width * 2,
+ new int[]{0, 1});
+ break;
+
+ case PNGHeader.GRAYSCALE:
+ switch( depth )
+ {
+ case 16:
+ sm = new ComponentSampleModel(DataBuffer.TYPE_USHORT,
+ width, height, 1, width,
+ new int[]{ 0 });
+ db = getShortBuffer();
+ break;
+
+ case 8:
+ sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, 1, width,
+ new int[]{ 0 });
+ db = getByteBuffer();
+ break;
+
+ default:
+ sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, depth);
+ db = getByteBuffer();
+ break;
+ }
+ break;
+
+ case PNGHeader.RGB:
+ if( depth == 8 )
+ {
+ t = DataBuffer.TYPE_BYTE;
+ db = getByteBuffer();
+ }
+ else
+ {
+ t = DataBuffer.TYPE_USHORT;
+ db = getShortBuffer();
+ }
+ sm = new ComponentSampleModel(t, width, height, 3, 3 * width,
+ new int[]{0, 1, 2});
+ break;
+
+ case PNGHeader.RGB_WITH_ALPHA:
+ if( depth == 8 )
+ {
+ t = DataBuffer.TYPE_BYTE;
+ db = getByteBuffer();
+ }
+ else
+ {
+ t = DataBuffer.TYPE_USHORT;
+ db = getShortBuffer();
+ }
+
+ sm = new ComponentSampleModel(t, width, height, 4, width * 4,
+ new int[]{0, 1, 2, 3});
+ break;
+
+ case PNGHeader.INDEXED:
+ if( depth == 8 )
+ sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height,
+ new int[] {0xFF});
+ else
+ sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, depth);
+ db = getByteBuffer();
+ break;
+ }
+
+ return Raster.createWritableRaster(sm, db, null);
+ }
+
+ /**
+ * Wrap the raster with a DataBufferUShort,
+ * conversion is big-endian (PNG native).
+ */
+ private DataBuffer getShortBuffer()
+ {
+ short[] data = new short[(raster.length >> 1)];
+ for( int i = 0; i < data.length; i++ )
+ data[i] = (short)(((raster[i * 2] & 0xFF) << 8) |
+ (raster[i * 2 + 1] & 0xFF));
+ return new DataBufferUShort( data, data.length );
+ }
+
+ /**
+ * Wrap the raster with a DataBufferByte
+ */
+ private DataBuffer getByteBuffer()
+ {
+ return new DataBufferByte( raster, raster.length );
+ }
+
+ public ColorModel getColorModel( ColorSpace cs,
+ int colorType, int depth )
+ {
+ int[] bits;
+ boolean hasAlpha = false;
+ int transferType;
+
+ switch( colorType )
+ {
+ case PNGHeader.GRAYSCALE_WITH_ALPHA:
+ if( cs == null )
+ cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
+ hasAlpha = true;
+ bits = new int[]{ depth, depth };
+ break;
+
+ case PNGHeader.RGB:
+ bits = new int[]{ depth, depth, depth };
+ break;
+
+ case PNGHeader.RGB_WITH_ALPHA:
+ hasAlpha = true;
+ bits = new int[]{ depth, depth, depth, depth };
+ break;
+
+ case PNGHeader.GRAYSCALE:
+ if( depth < 8 )
+ return grayPalette( depth );
+
+ if( cs == null )
+ cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
+ bits = new int[]{ depth };
+ break;
+
+ default:
+ case PNGHeader.INDEXED:
+ return null; // Handled by the palette chunk.
+ }
+
+ if( cs == null )
+ cs = ColorSpace.getInstance( ColorSpace.CS_sRGB );
+
+
+ return new ComponentColorModel(cs, bits, hasAlpha, false,
+ (hasAlpha ?
+ ComponentColorModel.TRANSLUCENT :
+ ComponentColorModel.OPAQUE),
+ ((depth == 16) ? DataBuffer.TYPE_USHORT :
+ DataBuffer.TYPE_BYTE));
+ }
+
+ private IndexColorModel grayPalette(int depth)
+ {
+ byte[] c = new byte[ (1 << depth) ];
+ for(int i = 0; i < c.length; i++)
+ c[i] = (byte)(255.0 * (((double)i) / ((double)c.length - 1.0)));
+ return new IndexColorModel(8, c.length, c, c, c);
+ }
+
+ public byte[] getRaster()
+ {
+ return raster;
+ }
+
+ public boolean isFinished()
+ {
+ return currentScanline >= header.getHeight();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGEncoder.java b/libjava/classpath/gnu/javax/imageio/png/PNGEncoder.java
new file mode 100644
index 00000000000..c0a30a7baef
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGEncoder.java
@@ -0,0 +1,235 @@
+/* PNGEncoder.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 gnu.javax.imageio.png;
+
+import java.util.Vector;
+import java.util.zip.Deflater;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+public class PNGEncoder
+{
+ /**
+ * The default data chunk size. 8 kb.
+ */
+ private static final int defaultChunkSize = 8192;
+
+ private PNGHeader header;
+ private PNGPalette palette;
+ private int stride, bpp;
+ private byte[] rawData;
+ private PNGICCProfile profile;
+
+ public PNGEncoder( BufferedImage bi ) throws PNGException
+ {
+ ColorModel c = bi.getColorModel();
+ int width = bi.getWidth();
+ int height = bi.getHeight();
+ int depth = 0;
+ int colorType;
+ boolean interlace = false;
+
+ if( c instanceof IndexColorModel )
+ {
+ colorType = PNGHeader.INDEXED;
+ int n = ((IndexColorModel)c).getMapSize();
+ if( n <= 2 )
+ depth = 1;
+ else if( n <= 4 )
+ depth = 2;
+ else if( n <= 16 )
+ depth = 4;
+ else if( n <= 256 )
+ depth = 8;
+ else
+ throw new PNGException("Depth must be <= 8 bits for indexed color.");
+ palette = new PNGPalette( ((IndexColorModel)c) );
+ }
+ else
+ {
+ ColorSpace cs = c.getColorSpace();
+ ColorSpace grayCS = ColorSpace.getInstance( ColorSpace.CS_GRAY );
+ if( cs == grayCS || bi.getType() == BufferedImage.TYPE_BYTE_GRAY
+ || bi.getType() == BufferedImage.TYPE_USHORT_GRAY )
+ colorType = c.hasAlpha() ? PNGHeader.GRAYSCALE_WITH_ALPHA :
+ PNGHeader.GRAYSCALE;
+ else
+ colorType = c.hasAlpha() ? PNGHeader.RGB_WITH_ALPHA : PNGHeader.RGB;
+ // Figure out the depth
+ int[] bits = c.getComponentSize();
+ depth = bits[0];
+ for(int i = 1; i < bits.length; i++ )
+ if( bits[i] > depth ) depth = bits[i];
+ if( (cs != grayCS && !cs.isCS_sRGB()) && cs instanceof ICC_ColorSpace )
+ profile = new PNGICCProfile( ((ICC_ColorSpace)cs).getProfile() );
+ }
+
+ header = new PNGHeader(width, height, depth, colorType, interlace);
+
+ stride = header.getScanlineStride(); // scanline stride
+ bpp = header.bytesPerPixel(); // bytes per pixel
+ getRawData( bi );
+ }
+
+ /**
+ * Returns the generated header.
+ */
+ public PNGHeader getHeader()
+ {
+ return header;
+ }
+
+ /**
+ * Returns the generated palette.
+ */
+ public PNGPalette getPalette()
+ {
+ return palette;
+ }
+
+ /**
+ * Returns the associated ICC profile, if any.
+ */
+ public PNGICCProfile getProfile()
+ {
+ return profile;
+ }
+
+ /**
+ * Encodes the raster and returns a Vector of PNGData chunks.
+ */
+ public Vector encodeImage()
+ {
+ Deflater deflater = new Deflater(); // The deflater
+ boolean useFilter = PNGFilter.useFilter( header );
+ byte[] lastScanline = new byte[ stride ];
+
+ byte[] data = new byte[ rawData.length + header.getHeight() ];
+
+ byte filterByte = PNGFilter.FILTER_NONE;
+ for( int i = 0; i < header.getHeight(); i++)
+ {
+ byte[] scanline = new byte[ stride ];
+ System.arraycopy(rawData, (i * stride), scanline, 0, stride);
+ if( useFilter && i > 0)
+ filterByte = PNGFilter.chooseFilter( scanline, lastScanline, bpp);
+
+ byte[] filtered = PNGFilter.filterScanline( filterByte, scanline,
+ lastScanline, bpp );
+ data[i * (stride + 1)] = filterByte;
+ System.arraycopy(filtered, 0, data, 1 + (i * (stride + 1)), stride);
+
+ lastScanline = scanline;
+ }
+
+ deflater.setInput( data );
+ deflater.finish();
+
+ PNGData chunk;
+ Vector chunks = new Vector();
+ do
+ {
+ chunk = new PNGData( defaultChunkSize );
+ chunk.deflateToChunk( deflater );
+ chunks.add( chunk );
+ }
+ while( chunk.chunkFull() );
+ chunk.shrink(); // Shrink the last chunk.
+ return chunks;
+ }
+
+ /**
+ * Get the image's raw data.
+ * FIXME: This may need improving on.
+ */
+ private void getRawData( BufferedImage bi ) throws PNGException
+ {
+ WritableRaster raster = bi.getRaster();
+ rawData = new byte[ stride * header.getHeight() ];
+ if( header.isIndexed() )
+ {
+ DataBuffer db = raster.getDataBuffer();
+ if( !( db instanceof DataBufferByte ) )
+ throw new PNGException("Unexpected DataBuffer for an IndexColorModel.");
+ byte[] data = ((DataBufferByte)db).getData();
+ for(int i = 0; i < header.getHeight(); i++ )
+ System.arraycopy( data, i * stride, rawData, i * stride, stride );
+ return;
+ }
+
+ if( header.getDepth() == 16 )
+ {
+ DataBuffer db = raster.getDataBuffer();
+ if( !( db instanceof DataBufferUShort ) )
+ throw new PNGException("Unexpected DataBuffer for 16-bit.");
+ short[] data = ((DataBufferUShort)db).getData();
+ for(int i = 0; i < header.getHeight(); i++ )
+ for(int j = 0; j < ( stride >> 1); j++)
+ {
+ rawData[ j * 2 + i * stride ] = (byte)((data[j + i * (stride >> 1 )] & 0xFF00) >> 8);
+ rawData[ j * 2 + i * stride + 1 ] = (byte)(data[j + i * (stride >> 1 )] & 0xFF);
+ }
+ return;
+ }
+
+ int size = ( header.getColorType() == PNGHeader.RGB_WITH_ALPHA ) ? 4 : 3;
+ int width = header.getWidth();
+ int height = header.getHeight();
+ int[] pixels = bi.getRGB( 0, 0, width, height, null, 0, width );
+
+ for( int i = 0; i < width * height; i++ )
+ {
+ rawData[ i * size ] = (byte)((pixels[i] & 0xFF0000) >> 16);
+ rawData[ i * size + 1 ] = (byte)((pixels[i] & 0xFF00) >> 8);
+ rawData[ i * size + 2 ] = (byte)(pixels[i] & 0xFF);
+ }
+
+ if( size == 4 )
+ for( int i = 0; i < width * height; i++ )
+ rawData[ i * size + 3 ] = (byte)((pixels[i] & 0xFF000000) >> 24);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGException.java b/libjava/classpath/gnu/javax/imageio/png/PNGException.java
new file mode 100644
index 00000000000..67486e57971
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGException.java
@@ -0,0 +1,48 @@
+/* PNGException.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 gnu.javax.imageio.png;
+
+import java.io.IOException;
+
+public class PNGException extends IOException
+{
+ public PNGException(String msg)
+ {
+ super( msg );
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGFile.java b/libjava/classpath/gnu/javax/imageio/png/PNGFile.java
new file mode 100644
index 00000000000..cc0ca297fcb
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGFile.java
@@ -0,0 +1,258 @@
+/* PNGFile.java -- High-level representation of a PNG file.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.png;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.Vector;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
+import java.awt.image.ColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.color.ColorSpace;
+
+public class PNGFile
+{
+ /**
+ * The PNG file signature.
+ */
+ private static final byte[] signature = new byte[]
+ { (byte)137, 80, 78, 71, 13, 10, 26, 10 };
+
+ /**
+ * The end chunk in raw form, no need for anything fancy here, it's just
+ * 0 bytes of length, the "IEND" tag and its CRC.
+ */
+ private static final byte[] endChunk = new byte[]
+ { 0, 0, 0, 0, (byte)0x49, (byte)0x45, (byte)0x4E, (byte)0x44,
+ (byte)0xAE, (byte)0x42, (byte)0x60, (byte)0x82 };
+
+ /**
+ * The loaded data.
+ */
+ private Vector chunks;
+
+ /**
+ * The Header chunk
+ */
+ private PNGHeader header;
+
+ /**
+ * Whether this file has a palette chunk or not.
+ */
+ private boolean hasPalette;
+
+ /**
+ * Image width and height.
+ */
+ private int width, height;
+
+ /**
+ * The decoder, if any.
+ */
+ private PNGDecoder decoder;
+
+ /**
+ * The encoder, if any. (Either this or the above must exist).
+ */
+ private PNGEncoder encoder;
+
+ /**
+ * The source of this PNG (if encoding)
+ */
+ private BufferedImage sourceImage;
+
+ /**
+ * Creates a PNGFile object from an InputStream.
+ */
+ public PNGFile(InputStream in) throws IOException, PNGException
+ {
+ PNGChunk chunk;
+ byte[] fileHdr = new byte[8];
+ chunks = new Vector();
+ hasPalette = false;
+
+ if( in.read( fileHdr ) != 8 )
+ throw new IOException("Could not read file header.");
+ if( !validateHeader( fileHdr ) )
+ throw new PNGException("Invalid file header. Not a PNG file.");
+
+ chunk = PNGChunk.readChunk( in, false );
+ if( !(chunk instanceof PNGHeader) )
+ throw new PNGException("First chunk not a header chunk.");
+ header = (PNGHeader)chunk;
+ if( !header.isValidChunk() )
+ throw new PNGException("First chunk not a valid header.");
+ System.out.println(header);
+
+ decoder = new PNGDecoder( header );
+ // Read chunks.
+ do
+ {
+ chunk = PNGChunk.readChunk( in, false );
+ /*
+ * We could exit here or output some kind of warning.
+ * But in the meantime, we'll just silently drop invalid chunks.
+ */
+ if( chunk.isValidChunk() )
+ {
+ if( chunk instanceof PNGData )
+ decoder.addData( (PNGData)chunk );
+ else // Silently ignore multiple headers, and use only the first.
+ if( chunk.getType() != PNGChunk.TYPE_END )
+ {
+ chunks.add( chunk );
+ hasPalette |= ( chunk instanceof PNGPalette );
+ }
+ }
+ else
+ System.out.println("WARNING: Invalid chunk!");
+ }
+ while( chunk.getType() != PNGChunk.TYPE_END );
+
+ if( header.isIndexed() && !hasPalette )
+ throw new PNGException("File is indexed color and has no palette.");
+
+ width = header.getWidth();
+ height = header.getHeight();
+ }
+
+ /**
+ * Creates a PNG file from an existing BufferedImage.
+ */
+ public PNGFile(BufferedImage bi) throws PNGException
+ {
+ sourceImage = bi;
+ width = bi.getWidth();
+ height = bi.getHeight();
+ chunks = new Vector();
+ encoder = new PNGEncoder( bi );
+ header = encoder.getHeader();
+ if( header.isIndexed() )
+ chunks.add( encoder.getPalette() );
+
+ // Do the compression and put the data chunks in the list.
+ chunks.addAll( encoder.encodeImage() );
+ }
+
+ /**
+ * Writes a PNG file to an OutputStream
+ */
+ public void writePNG(OutputStream out) throws IOException
+ {
+ out.write( signature ); // write the signature.
+ header.writeChunk( out );
+ for( int i = 0; i < chunks.size(); i++ )
+ {
+ PNGChunk chunk = ((PNGChunk)chunks.elementAt(i));
+ chunk.writeChunk( out );
+ }
+ out.write( endChunk );
+ }
+
+ /**
+ * Check 8 bytes to see if it's a valid PNG header.
+ */
+ private boolean validateHeader( byte[] hdr )
+ {
+ if( hdr.length != 8 )
+ return false;
+ for( int i = 0; i < 8; i++ )
+ if( signature[i] != hdr[i] )
+ return false;
+ return true;
+ }
+
+ /**
+ * Return a loaded image as a bufferedimage.
+ */
+ public BufferedImage getBufferedImage()
+ {
+ if( decoder == null )
+ return sourceImage;
+
+ WritableRaster r = decoder.getRaster( header );
+ ColorModel cm;
+ if( header.isIndexed() )
+ {
+ PNGPalette pngp = getPalette();
+ cm = pngp.getPalette( getColorSpace() );
+ }
+ else
+ cm = decoder.getColorModel( getColorSpace(),
+ header.getColorType(),
+ header.getDepth() );
+
+ return new BufferedImage(cm, r, false, null);
+ }
+
+ /**
+ * Find the palette chunk and return it
+ */
+ private PNGPalette getPalette()
+ {
+ for(int i = 0; i < chunks.size(); i++ )
+ if( chunks.elementAt(i) instanceof PNGPalette )
+ return ((PNGPalette)chunks.elementAt(i));
+ return null;
+ }
+
+ /**
+ * Return the Color space to use, first preference is ICC profile, then
+ * a gamma chunk, or returns null for the default sRGB.
+ */
+ private ColorSpace getColorSpace()
+ {
+ PNGICCProfile icc = null;
+ PNGGamma gamma = null;
+ for(int i = 0; i < chunks.size(); i++ )
+ {
+ if( chunks.elementAt(i) instanceof PNGICCProfile )
+ icc = ((PNGICCProfile)chunks.elementAt(i));
+ else if(chunks.elementAt(i) instanceof PNGGamma )
+ gamma = ((PNGGamma)chunks.elementAt(i));
+ }
+
+ if( icc != null )
+ return icc.getColorSpace();
+// if( gamma != null && !header.isGrayscale())
+// return gamma.getColorSpace( header.isGrayscale() );
+ return null;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGFilter.java b/libjava/classpath/gnu/javax/imageio/png/PNGFilter.java
new file mode 100644
index 00000000000..63af1992932
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGFilter.java
@@ -0,0 +1,237 @@
+/* PNGFilter.java -- PNG image filters.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.png;
+
+/**
+ * A utility class of static methods implementing the PNG filtering algorithms.
+ */
+public class PNGFilter
+{
+
+ public static final byte FILTER_NONE = 0;
+ public static final byte FILTER_SUB = 1;
+ public static final byte FILTER_UP = 2;
+ public static final byte FILTER_AVERAGE = 3;
+ public static final byte FILTER_PAETH = 4;
+
+ /**
+ * Return whether a filter should be used or FILTER_NONE,
+ * following the recommendations in the PNG spec.
+ */
+ public static boolean useFilter( PNGHeader header )
+ {
+ switch( header.getColorType() )
+ {
+ case PNGHeader.INDEXED:
+ return false;
+
+ case PNGHeader.GRAYSCALE:
+ case PNGHeader.RGB:
+ if( header.bytesPerPixel() <= 1 )
+ return false;
+ case PNGHeader.GRAYSCALE_WITH_ALPHA:
+ case PNGHeader.RGB_WITH_ALPHA:
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * Heuristic for adaptively choosing a filter, following the scheme
+ * suggested in the PNG spec.
+ * @return a fiter type.
+ */
+ public static byte chooseFilter( byte[] scanline, byte[] lastScanline,
+ int bpp)
+
+ {
+ long[] values = new long[5];
+ int idx = 0;
+ for( int i = 0; i < 5; i++ )
+ {
+ byte[] filtered = filterScanline((byte)i, scanline, lastScanline, bpp);
+ values[i] = 0;
+ for(int j = 0; j < filtered.length; j++ )
+ values[i] += (int)(filtered[j] & 0xFF);
+ if( values[ idx ] > values[i] )
+ idx = i;
+ }
+ return (byte)idx;
+ }
+
+ /**
+ * Filter a scanline.
+ */
+ public static byte[] filterScanline( byte filtertype, byte[] scanline,
+ byte[] lastScanline, int bpp)
+ {
+ int stride = scanline.length;
+ byte[] out = new byte[ stride ];
+ switch( filtertype )
+ {
+ case FILTER_SUB:
+ for( int i = 0; i < bpp; i++)
+ out[ i ] = scanline[ i ];
+
+ for( int i = bpp; i < stride; i++ )
+ out[i] = (byte)(scanline[ i ] -
+ scanline[ i - bpp ]);
+ break;
+
+ case FILTER_UP:
+ for( int i = 0; i < stride; i++ )
+ out[ i ] = (byte)(scanline[ i ] - lastScanline[ i ]);
+ break;
+
+ case FILTER_AVERAGE:
+ for( int i = 0; i < bpp; i++)
+ out[ i ] = (byte)((scanline[ i ] & 0xFF) - ((lastScanline[ i ] & 0xFF) >> 1));
+ for( int i = bpp; i < stride; i++ )
+ out[ i ] = (byte)((scanline[ i ] & 0xFF) -
+ (((scanline[ i - bpp ] & 0xFF) +
+ (lastScanline[ i ] & 0xFF)) >> 1));
+ break;
+
+ case FILTER_PAETH:
+ for( int i = 0; i < stride; i++ )
+ {
+ int x;
+ {
+ int a, b, c;
+ if( i >= bpp )
+ {
+ a = (scanline[ i - bpp ] & 0xFF); // left
+ c = (lastScanline[ i - bpp ] & 0xFF); // upper-left
+ }
+ else
+ a = c = 0;
+ b = (lastScanline[ i ] & 0xFF); // up
+
+ int p = (a + b - c); // initial estimate
+ // distances to a, b, c
+ int pa = (p > a) ? p - a : a - p;
+ int pb = (p > b) ? p - b : b - p;
+ int pc = (p > c) ? p - c : c - p;
+ // return nearest of a,b,c,
+ // breaking ties in order a,b,c.
+ if( pa <= pb && pa <= pc ) x = a;
+ else { if( pb <= pc ) x = b;
+ else x = c;
+ }
+ }
+ out[ i ] = (byte)(scanline[ i ] - x);
+ }
+ break;
+ default:
+ case FILTER_NONE:
+ return scanline;
+ }
+ return out;
+ }
+
+ /**
+ * Unfilter a scanline.
+ */
+ public static byte[] unFilterScanline( int filtertype, byte[] scanline,
+ byte[] lastScanline, int bpp)
+ {
+ int stride = scanline.length;
+ byte[] out = new byte[ stride ];
+ switch( filtertype )
+ {
+
+ case FILTER_NONE:
+ System.arraycopy( scanline, 0, out, 0, stride );
+ break;
+
+ case FILTER_SUB:
+ for( int i = 0; i < bpp; i++)
+ out[ i ] = scanline[ i ];
+
+ for( int i = bpp; i < stride; i++ )
+ out[ i ] = (byte)(scanline[ i ] +
+ out[ i - bpp ]);
+ break;
+
+ case FILTER_UP:
+ for( int i = 0; i < stride; i++ )
+ out[ i ] = (byte)(scanline[ i ] + lastScanline[ i ]);
+ break;
+
+ case FILTER_AVERAGE:
+ for( int i = 0; i < bpp; i++)
+ out[ i ] = (byte)((scanline[ i ] & 0xFF) + ((lastScanline[ i ] & 0xFF) >> 1));
+ for( int i = bpp; i < stride; i++ )
+ out[ i ] = (byte)((scanline[ i ] & 0xFF) +
+ (((out[ i - bpp ] & 0xFF) + (lastScanline[ i ] & 0xFF)) >> 1));
+ break;
+
+ case FILTER_PAETH:
+ for( int i = 0; i < stride; i++ )
+ {
+ int x;
+ {
+ int a, b, c;
+ if( i >= bpp )
+ {
+ a = (out[ i - bpp ] & 0xFF); // left
+ c = (lastScanline[ i - bpp ] & 0xFF); // upper-left
+ }
+ else
+ a = c = 0;
+ b = (lastScanline[ i ] & 0xFF); // up
+
+ int p = (a + b - c); // initial estimate
+ // distances to a, b, c
+ int pa = (p > a) ? p - a : a - p;
+ int pb = (p > b) ? p - b : b - p;
+ int pc = (p > c) ? p - c : c - p;
+ // return nearest of a,b,c,
+ // breaking ties in order a,b,c.
+ if( pa <= pb && pa <= pc ) x = a;
+ else { if( pb <= pc ) x = b;
+ else x = c;
+ }
+ }
+ out[ i ] = (byte)(scanline[ i ] + x);
+ }
+ break;
+ }
+ return out;
+ }
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGGamma.java b/libjava/classpath/gnu/javax/imageio/png/PNGGamma.java
new file mode 100644
index 00000000000..af777d9b4f6
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGGamma.java
@@ -0,0 +1,89 @@
+/* PNGGamma.java -- GAMA chunk.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.png;
+
+import java.awt.color.ICC_ProfileGray;
+import java.awt.color.ICC_ProfileRGB;
+import java.awt.color.ICC_Profile;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ColorSpace;
+
+/**
+ * A PNG gAMA (gamma) chunk.
+ */
+public class PNGGamma extends PNGChunk
+{
+ private double gamma;
+
+ protected PNGGamma( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ if( data.length < 4 )
+ throw new PNGException("Unexpectedly short time chunk. ("+data.length+" bytes)");
+ long g = ((data[0] & 0xFF) << 24) | ( (data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+ gamma = (double)g;
+ gamma = 100000.0/gamma;
+ }
+
+ public PNGGamma( double g )
+ {
+ super( TYPE_GAMMA );
+ data = new byte[ 4 ];
+ gamma = g;
+ long tmp = (long)(100000.0/gamma);
+ data[0] = (byte)((tmp & 0xFF000000) >> 24);
+ data[1] = (byte)((tmp & 0xFF0000) >> 16);
+ data[2] = (byte)((tmp & 0xFF00) >> 8);
+ data[3] = (byte)(tmp & 0xFF);
+ }
+
+ /**
+ * Returns a ColorSpace object corresponding to this gamma value.
+ */
+ public ColorSpace getColorSpace(boolean grayscale)
+ {
+ // FIXME.
+ return null;
+ }
+
+ public String toString()
+ {
+ return "PNG Gamma chunk, value: "+gamma;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGHeader.java b/libjava/classpath/gnu/javax/imageio/png/PNGHeader.java
new file mode 100644
index 00000000000..c9ef2dc37fe
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGHeader.java
@@ -0,0 +1,257 @@
+/* PNGHeader.java -- PNG Header
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.png;
+
+/**
+ * A PNG Header chunk.
+ */
+public class PNGHeader extends PNGChunk
+{
+ private int width, height, depth;
+ private int colorType, compression, filter, interlace;
+
+ /**
+ * The valid interlace types.
+ */
+ public static final int INTERLACE_NONE = 0;
+ public static final int INTERLACE_ADAM7 = 1;
+
+ /**
+ * The valid color types.
+ */
+ public static final int GRAYSCALE = 0;
+ public static final int RGB = 2;
+ public static final int INDEXED = 3;
+ public static final int GRAYSCALE_WITH_ALPHA = 4;
+ public static final int RGB_WITH_ALPHA = 6;
+
+ /**
+ * Parses a PNG Header chunk.
+ */
+ protected PNGHeader( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ if( data.length < 13 )
+ throw new PNGException("Unexpectedly short header chunk. (" + data.length
+ + " bytes)");
+
+ width = ((data[0] & 0xFF) << 24) | ( (data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+ height = ((data[4] & 0xFF) << 24) | ( (data[5] & 0xFF) << 16 ) |
+ ((data[6] & 0xFF) << 8) | (data[7] & 0xFF);
+ depth = (data[8] & 0xFF);
+ colorType = (data[9] & 0xFF);
+ compression = (data[10] & 0xFF);
+ filter = (data[11] & 0xFF);
+ interlace = (data[12] & 0xFF);
+ }
+
+ /**
+ * Create a PNG header chunk.
+ * Warning: This trusts that the parameters are valid.
+ */
+ public PNGHeader(int width, int height, int depth,
+ int colorType, boolean interlace)
+ {
+ super( TYPE_HEADER );
+ data = new byte[ 13 ];
+
+ this.width = width;
+ this.height = height;
+ this.depth = depth;
+ compression = filter = 0;
+ this.colorType = colorType;
+ this.interlace = interlace ? 1 : 0;
+
+ // Build the data chunk.
+ byte[] a = getInt( width );
+ byte[] b = getInt( height );
+ data[0] = a[0]; data[1] = a[1]; data[2] = a[2]; data[3] = a[3];
+ data[4] = b[0]; data[5] = b[1]; data[6] = b[2]; data[7] = b[3];
+ data[8] = (byte)depth;
+ data[9] = (byte)colorType;
+ data[10] = (byte)compression;
+ data[11] = (byte)filter;
+ data[12] = (byte)this.interlace;
+ }
+
+ /**
+ * Validates the header fields
+ */
+ public boolean isValidChunk()
+ {
+ if( !super.isValidChunk() )
+ return false;
+
+ // width and height must be nonzero
+ if( width == 0 || height == 0 )
+ return false;
+ // colorType can be 0,2,3,4,6
+ if( (colorType & 0xFFFFFFF8) != 0 || colorType == 5 || colorType == 1)
+ return false;
+ // Possible valid depths are 1,2,4,8,16
+ if( !((depth == 1) || (depth == 2) || (depth == 4) ||
+ (depth == 8) || (depth == 16)) )
+ return false;
+ if( colorType == INDEXED && depth == 16 )
+ return false;
+ if( ( colorType == RGB || colorType == GRAYSCALE_WITH_ALPHA ||
+ colorType == RGB_WITH_ALPHA ) &&
+ depth < 8 )
+ return false;
+ // Only compression and filter methods zero are defined
+ if( compression != 0 || filter != 0 )
+ return false;
+ // Interlace methods, 0 and 1 are valid values.
+ if( (interlace & 0xFFFFFFFE) != 0 )
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Returns <code>true</code> if this PNG is indexed-color
+ */
+ public boolean isIndexed()
+ {
+ return (colorType == INDEXED);
+ }
+
+ /**
+ * Returns <code>true</code> if this PNG is grayscale
+ */
+ public boolean isGrayscale()
+ {
+ return ((colorType == GRAYSCALE) || (colorType == GRAYSCALE_WITH_ALPHA));
+ }
+
+ /**
+ * Returns the color type of the image.
+ */
+ public int getColorType()
+ {
+ return colorType;
+ }
+
+ /**
+ * Returns whether the image is interlaced or not.
+ */
+ public boolean isInterlaced()
+ {
+ return (interlace != 0);
+ }
+
+ /**
+ * Returns the number of bytes per pixel.
+ */
+ public int bytesPerPixel()
+ {
+ switch( colorType )
+ {
+ case GRAYSCALE_WITH_ALPHA:
+ return ((depth * 2) >> 3);
+ case RGB:
+ return ((depth * 3) >> 3);
+ case RGB_WITH_ALPHA:
+ return ((depth * 4) >> 3);
+
+ default:
+ case GRAYSCALE:
+ case INDEXED:
+ int i = (depth >> 3);
+ if( i > 0 ) return i;
+ return 1; // if bytes per pixel < 1, return 1 anyway.
+ }
+ }
+
+ /**
+ * Returns the stride of one scanline, in bytes.
+ */
+ public int getScanlineStride()
+ {
+ long nBits = 0; // bits per scanline - scanlines are on byte offsets.
+ switch( colorType )
+ {
+ case GRAYSCALE:
+ nBits = width * depth;
+ break;
+ case RGB:
+ nBits = width * depth * 3;
+ break;
+ case INDEXED:
+ nBits = depth * width;
+ break;
+ case GRAYSCALE_WITH_ALPHA:
+ nBits = depth * width * 2;
+ break;
+ case RGB_WITH_ALPHA:
+ nBits = depth * width * 4;
+ break;
+ }
+ // Round up number of bits to the nearest byte
+ if( (nBits & 0x07) != 0 )
+ nBits += (8 - (nBits & 0x07));
+
+ return (int)(nBits >> 3); // return # of bytes.
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public int getDepth()
+ {
+ return depth;
+ }
+
+ /**
+ * Debugging string.
+ */
+ public String toString()
+ {
+ return "Header Chunk. Image width:"+width+" height:"+height+
+ " depth:"+depth+" color type:"+colorType+" compression type:"+
+ compression+" filter type:"+ filter+" interlace:"+interlace;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGICCProfile.java b/libjava/classpath/gnu/javax/imageio/png/PNGICCProfile.java
new file mode 100644
index 00000000000..d2696e1c6b8
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGICCProfile.java
@@ -0,0 +1,114 @@
+/* PNGICCProfile.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 gnu.javax.imageio.png;
+
+import java.awt.color.ICC_Profile;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ColorSpace;
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.util.zip.InflaterInputStream;
+import java.util.zip.Deflater;
+
+/**
+ * A PNG iCCP (ICC Profile) chunk.
+ */
+public class PNGICCProfile extends PNGChunk
+{
+ private String name;
+ private ICC_Profile profile;
+ // A generic profile name to use "ICC Profile"
+ private static final byte[] genericName = new byte[]
+ { 0x49, 0x43, 0x43, 0x20, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65 };
+
+ protected PNGICCProfile( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ int i = 0;
+ while( data[i++] != 0 );
+ try
+ {
+ name = new String(data, 0, i, "8859_1");
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ name = ""; // shouldn't really happen.
+ }
+ if( data[i++] != 0 )
+ throw new PNGException("Can't handle nonzero compression types with iCCP chunks.");
+ try
+ {
+ ByteArrayInputStream bos = new ByteArrayInputStream( data, i,
+ data.length - i );
+ profile = ICC_Profile.getInstance( new InflaterInputStream( bos ) );
+ }
+ catch(IOException ioe)
+ {
+ throw new PNGException("Couldn't read iCCP profile chunk.");
+ }
+ System.out.println("Got profile:"+profile);
+ }
+
+ public PNGICCProfile( ICC_Profile profile )
+ {
+ super( TYPE_PROFILE );
+ this.profile = profile;
+ byte[] profData = profile.getData();
+ byte[] outData = new byte[ profData.length * 2 ];
+ Deflater deflater = new Deflater();
+ deflater.setInput( profData );
+ deflater.finish();
+ int n = deflater.deflate( outData );
+ data = new byte[ n + 11 + 2 ];
+ System.arraycopy(genericName, 0, data, 0, 11 );
+ data[11] = data[12] = 0; // null separator and compression type.
+ // Copy compressed data
+ System.arraycopy(outData, 0, data, 13, n );
+ }
+
+ public ColorSpace getColorSpace()
+ {
+ return new ICC_ColorSpace( profile );
+ }
+
+ public String toString()
+ {
+ return "PNG ICC Profile, name: "+name;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGImageReader.java b/libjava/classpath/gnu/javax/imageio/png/PNGImageReader.java
new file mode 100644
index 00000000000..64aa3fea5af
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGImageReader.java
@@ -0,0 +1,224 @@
+/* PNGImageReader.java -- The ImageIO ImageReader for PNG
+ 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.imageio.png;
+
+import gnu.javax.imageio.IIOInputStream;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.imageio.ImageReadParam;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * The ImageIO ImageReader for PNG images.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class PNGImageReader
+ extends ImageReader
+{
+
+ /**
+ * The PNG file.
+ */
+ private PNGFile pngFile;
+
+ /**
+ * The decoded image.
+ */
+ private BufferedImage image;
+
+ /**
+ * The supported image types for PNG.
+ */
+ private ArrayList imageTypes;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param spi the corresponding ImageReaderSpi
+ */
+ public PNGImageReader(PNGImageReaderSpi spi)
+ {
+ super(spi);
+ }
+
+ /**
+ * Returns the height of the image.
+ */
+ public int getHeight(int imageIndex)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ readImage();
+ return image.getHeight();
+ }
+
+ /**
+ * Returns the width of the image.
+ *
+ * @param imageIndex the index of the image
+ *
+ * @return the width of the image
+ */
+ public int getWidth(int imageIndex) throws IOException
+ {
+ checkIndex(imageIndex);
+ readImage();
+ return image.getWidth();
+ }
+
+ /**
+ * Returns the image types for the image.
+ *
+ * @see ImageReader#getImageTypes(int)
+ */
+ public Iterator getImageTypes(int imageIndex)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ readImage();
+ if (imageTypes == null)
+ {
+ imageTypes = new ArrayList();
+ imageTypes.add(new ImageTypeSpecifier(image.getColorModel(),
+ image.getSampleModel()));
+ }
+ return imageTypes.iterator();
+ }
+
+ /**
+ * Returns the number of images in the stream.
+ *
+ * @return the number of images in the stream
+ *
+ * @see ImageReader#getNumImages(boolean)
+ */
+ public int getNumImages(boolean allowSearch)
+ throws IOException
+ {
+ return 1;
+ }
+
+ /**
+ * Reads the image.
+ *
+ * @param imageIndex the index of the image to read
+ * @param param additional parameters
+ */
+ public BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException
+ {
+ checkIndex(imageIndex);
+ readImage();
+ return image;
+ }
+
+ /**
+ * Sets the input and checks the input parameter.
+ *
+ * @see ImageReader#setInput(Object, boolean, boolean)
+ */
+ public void setInput(Object input,
+ boolean seekForwardOnly,
+ boolean ignoreMetadata)
+ {
+ super.setInput(input, seekForwardOnly, ignoreMetadata);
+ if (! (input instanceof InputStream || input instanceof ImageInputStream))
+ throw new IllegalArgumentException("Input not an ImageInputStream");
+ }
+
+ public IIOMetadata getImageMetadata(int imageIndex)
+ throws IOException
+ {
+ // TODO: Not (yet) supported.
+ checkIndex(imageIndex);
+ return null;
+ }
+
+ public IIOMetadata getStreamMetadata()
+ throws IOException
+ {
+ // TODO: Not (yet) supported.
+ return null;
+ }
+
+ /**
+ * Checks the image indexa and throws and IndexOutOfBoundsException if
+ * appropriate.
+ *
+ * @param index the index to check
+ */
+ private void checkIndex(int index)
+ {
+ if (index > 0)
+ throw new IndexOutOfBoundsException("Image index out of bounds");
+ }
+
+ /**
+ * Makes sure that the image is read.
+ *
+ * @throws IOException if something goes wrong
+ */
+ private void readImage()
+ throws IOException
+ {
+ if (pngFile == null)
+ {
+ if (input instanceof InputStream)
+ pngFile = new PNGFile((InputStream) input);
+ else if (input instanceof ImageInputStream)
+ pngFile = new PNGFile(new IIOInputStream((ImageInputStream) input));
+ else
+ assert false : "Must not happen";
+ }
+
+ if (pngFile != null && image == null)
+ {
+ image = pngFile.getBufferedImage();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java b/libjava/classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java
new file mode 100644
index 00000000000..0092ab55846
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java
@@ -0,0 +1,128 @@
+/* PNGImageReaderSpi.java -- The ImageReader service provider for PNG
+ 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.imageio.png;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+
+import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * The ImageIO ImageReader service provider for PNG images.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class PNGImageReaderSpi
+ extends ImageReaderSpi
+{
+
+ /**
+ * The PNG file signature.
+ */
+ private static final byte[] SIGNATURE = new byte[]
+ { (byte) 137, 80, 78, 71, 13, 10, 26, 10 };
+
+ private static final String VENDOR_NAME = "GNU";
+ static final String VERSION = "1.0";
+ static final String READER_CLASSNAME =
+ "gnu.javax.imageio.png.PNGImageReader";
+ static final String[] NAMES = { "Portable Network Graphics" };
+ static final String[] SUFFIXES = { ".png" , ".PNG" };
+ static final String[] MIME_TYPES = { "image/png" };
+ static final String[] WRITER_SPI_NAMES =
+ new String[] { "gnu.javax.imageio.png.PNGWriterSpi" };
+ static final Class[] INPUT_TYPES = new Class[]{ InputStream.class,
+ ImageInputStream.class};
+ public PNGImageReaderSpi()
+ {
+ super(VENDOR_NAME, VERSION, NAMES, SUFFIXES, MIME_TYPES, READER_CLASSNAME,
+ INPUT_TYPES, WRITER_SPI_NAMES, false, null, null, null, null, false,
+ null, null, null, null);
+ }
+
+ /**
+ * Determines if the PNG ImageReader can decode the specified input.
+ *
+ * @param source the source to decode
+ */
+ public boolean canDecodeInput(Object source) throws IOException
+ {
+ boolean canDecode = false;
+ if (source instanceof ImageInputStream)
+ {
+ ImageInputStream in = (ImageInputStream) source;
+ in.mark();
+ canDecode = true;
+ for (int i = 0; i < SIGNATURE.length && canDecode; i++)
+ {
+ byte sig = (byte) in.read();
+ if (sig != SIGNATURE[i]) {
+ canDecode = false;
+ }
+ }
+ in.reset();
+ }
+ return canDecode;
+ }
+
+ /**
+ * Returns a new PNGImageReader instance.
+ *
+ * @param extension the extension, ignored
+ */
+ public ImageReader createReaderInstance(Object extension)
+ throws IOException
+ {
+ return new PNGImageReader(this);
+ }
+
+ /**
+ * Returns a description.
+ *
+ * @param locale the locale
+ */
+ public String getDescription(Locale locale)
+ {
+ return "Portable Network Graphics";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGPalette.java b/libjava/classpath/gnu/javax/imageio/png/PNGPalette.java
new file mode 100644
index 00000000000..478129df54e
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGPalette.java
@@ -0,0 +1,127 @@
+/* PNGPalette.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 gnu.javax.imageio.png;
+
+import java.awt.color.ColorSpace;
+import java.awt.image.IndexColorModel;
+
+/**
+ * A PNG Palette chunk.
+ */
+public class PNGPalette extends PNGChunk
+{
+ private int[] red,green,blue;
+
+ protected PNGPalette( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ double l = data.length;
+ l /= 3.0;
+ // Check if it's divisible by 3. (Yuck.)
+ if( l - Math.floor(l) != 0.0 )
+ throw new PNGException("Invalid size of palette chunk.");
+ int nEntries = (int)l;
+
+ red = new int[ nEntries ];
+ green = new int[ nEntries ];
+ blue = new int[ nEntries ];
+ for( int i = 0; i < nEntries; i++ )
+ {
+ red[i] = (data[ i * 3 ] & 0xFF);
+ green[i] = (data[ i * 3 + 1 ] & 0xFF);
+ blue[i] = (data[ i * 3 + 2] & 0xFF);
+ }
+ }
+
+ public PNGPalette( IndexColorModel cm )
+ {
+ super( TYPE_PALETTE );
+ int n = cm.getMapSize();
+ data = new byte[ n * 3 ];
+ red = new int[ n ];
+ green = new int[ n ];
+ blue = new int[ n ];
+ for(int i = 0; i < n; i++ )
+ {
+ red[i] = data[i * 3] = (byte)cm.getRed(i);
+ green[i] = data[i * 3 + 1] = (byte)cm.getGreen(i);
+ blue[i] = data[i * 3 + 2] = (byte)cm.getBlue(i);
+ }
+ }
+
+ public IndexColorModel getPalette( ColorSpace cs )
+ {
+ int nc = red.length;
+ byte[] r = new byte[nc];
+ byte[] g = new byte[nc];
+ byte[] b = new byte[nc];
+
+ if( cs == null )
+ {
+ for(int i = 0; i < nc; i ++ )
+ {
+ r[i] = (byte)red[i];
+ g[i] = (byte)green[i];
+ b[i] = (byte)blue[i];
+ }
+ }
+ else
+ {
+ for(int i = 0; i < nc; i ++ )
+ {
+ float[] in = new float[3];
+ in[0] = (((float)red[i]) / 255f);
+ in[1] = (((float)green[i]) / 255f);
+ in[2] = (((float)blue[i]) / 255f);
+ float[] out = cs.toRGB( in );
+ r[i] = (byte)( Math.round(out[0] * 255.0) );
+ g[i] = (byte)( Math.round(out[1] * 255.0) );
+ b[i] = (byte)( Math.round(out[2] * 255.0) );
+ }
+ }
+ return new IndexColorModel(8, nc, r, g, b);
+ }
+
+ public String toString()
+ {
+ String s = "PNG Palette:\n";
+ for( int i = 0; i < red.length; i++)
+ s = s + "Index " + i + ": ["+ red[i] +", "+green[i]+", "+blue[i]+"]\n";
+ return s;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGPhys.java b/libjava/classpath/gnu/javax/imageio/png/PNGPhys.java
new file mode 100644
index 00000000000..0a82d6acbff
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGPhys.java
@@ -0,0 +1,112 @@
+/* PNGPhys.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 gnu.javax.imageio.png;
+
+/**
+ * A PNG "pHYS" chunk - pixel physical dimensions
+ */
+public class PNGPhys extends PNGChunk
+{
+ long x, y;
+ double ratio;
+ boolean usesRatio;
+
+ protected PNGPhys( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ if( data.length < 9 )
+ throw new PNGException("Unexpected size of pHYS chunk.");
+ x = ((data[0] & 0xFF) << 24) | ( (data[1] & 0xFF) << 16 ) |
+ ((data[2] & 0xFF) << 8) | (data[3] & 0xFF);
+ y = ((data[4] & 0xFF) << 24) | ( (data[5] & 0xFF) << 16 ) |
+ ((data[6] & 0xFF) << 8) | (data[7] & 0xFF);
+ if(data[8] == 0)
+ {
+ ratio = ((double)x)/((double)y);
+ usesRatio = true;
+ }
+ }
+
+ public PNGPhys( double ratio )
+ {
+ super( TYPE_PHYS );
+
+ this.ratio = ratio;
+ usesRatio = true;
+
+ if( ratio < 1.0 )
+ {
+ y = 0xFFFFFFFF;
+ x = (long)(0xFFFFFFFFL * ratio);
+ }
+ else
+ {
+ x = 0xFFFFFFFF;
+ y = (long)(0xFFFFFFFFL * ratio);
+ }
+ makeData();
+ }
+
+ public PNGPhys( int x, int y )
+ {
+ super( TYPE_PHYS );
+ usesRatio = false;
+ this.x = x;
+ this.y = y;
+ makeData();
+ }
+
+ private void makeData()
+ {
+ data = new byte[ 9 ];
+ byte[] a = getInt( (int)x );
+ byte[] b = getInt( (int)y );
+ data[0] = a[0]; data[1] = a[1]; data[2] = a[2]; data[3] = a[3];
+ data[4] = b[0]; data[5] = b[1]; data[6] = b[2]; data[7] = b[3];
+ data[7] = (usesRatio) ? 0 : (byte)0xFF;
+ }
+
+ public String toString()
+ {
+ String s = "PNG Physical pixel size chunk.";
+ if( usesRatio )
+ return s + " Aspect ratio (x/y): " + ratio;
+ else
+ return s + " " + x + " by " + y + " pixels per meter. (x, y).";
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/png/PNGTime.java b/libjava/classpath/gnu/javax/imageio/png/PNGTime.java
new file mode 100644
index 00000000000..9b5c0332a27
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/png/PNGTime.java
@@ -0,0 +1,83 @@
+/* PNGTime.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 gnu.javax.imageio.png;
+
+import java.util.Date;
+
+/**
+ * A PNG tIME chunk.
+ */
+public class PNGTime extends PNGChunk
+{
+ private Date date;
+
+ protected PNGTime( int type, byte[] data, int crc ) throws PNGException
+ {
+ super( type, data, crc );
+ if( data.length < 7 )
+ throw new PNGException("Unexpectedly short time chunk. ("+data.length+" bytes)");
+
+ // PNG value is absolute (2006, not 106 or 06), java is from 1900.
+ int year = ( (data[0] & 0xFF) << 8 ) | (data[1] & 0xFF);
+ int month = (data[2] & 0xFF); // java counts from 0. PNG from 1.
+ int day = (data[3] & 0xFF);
+ int hour = (data[4] & 0xFF);
+ int minute = (data[5] & 0xFF);
+ int second = (data[6] & 0xFF);
+ date = new Date( year - 1900, month - 1, day, hour, minute, second );
+ }
+
+ public PNGTime( Date d )
+ {
+ super( TYPE_TIME );
+ data = new byte[ 7 ];
+ int tmp = d.getYear() + 1900;
+ data[0] = (byte)((tmp & 0xFF00) >> 8);
+ data[1] = (byte)(tmp & 0x00FF);
+ data[2] = (byte)(d.getMonth() + 1);
+ data[3] = (byte)(d.getDay());
+ data[4] = (byte)(d.getHours());
+ data[5] = (byte)(d.getMinutes());
+ data[6] = (byte)(d.getSeconds());
+ }
+
+ public String toString()
+ {
+ return "PNG Time chunk: "+date;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/KeyPool.java b/libjava/classpath/gnu/javax/net/ssl/provider/KeyPool.java
index e342700c269..18d9dc281ab 100644
--- a/libjava/classpath/gnu/javax/net/ssl/provider/KeyPool.java
+++ b/libjava/classpath/gnu/javax/net/ssl/provider/KeyPool.java
@@ -41,15 +41,6 @@ package gnu.javax.net.ssl.provider;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.SecureRandom;
-import java.security.Security;
-import java.util.LinkedList;
-import javax.crypto.spec.DHParameterSpec;
-
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.prng.IRandom;
-import gnu.java.security.prng.LimitReachedException;
-import gnu.java.security.util.Prime2;
final class KeyPool
{
@@ -92,7 +83,7 @@ final class KeyPool
nextBytes(kb);
p = new BigInteger(1, kb).setBit(0);
if (p.compareTo(lower) >= 0 && p.compareTo(upper) <= 0 &&
- Prime2.isProbablePrime(p) && p.gcd(E).equals(ONE))
+ p.isProbablePrime(80) && p.gcd(E).equals(ONE))
break;
}
@@ -101,7 +92,7 @@ final class KeyPool
nextBytes(kb);
q = new BigInteger(1, kb).setBit(0);
n = q.multiply(p);
- if (n.bitLength() == 512 && Prime2.isProbablePrime(q) &&
+ if (n.bitLength() == 512 && q.isProbablePrime(80) &&
q.gcd(E).equals(ONE))
break;
}
diff --git a/libjava/classpath/gnu/javax/print/CupsServer.java b/libjava/classpath/gnu/javax/print/CupsServer.java
index 6d9601fb933..0486e69deb0 100644
--- a/libjava/classpath/gnu/javax/print/CupsServer.java
+++ b/libjava/classpath/gnu/javax/print/CupsServer.java
@@ -84,24 +84,43 @@ public class CupsServer
/**
* Creates a <code>CupsServer</code> object which
- * tries to connect to the cups server on localhost.
+ * tries to connect to a cups server.
+ *
+ * If <code>gnu.javax.print.server</code> is explicitly set, then
+ * that hostname will be used. Otherwise it will default to localhost.
*
* @param username the username
* @param password the password for the username.
*/
public CupsServer(String username, String password)
{
+ this.username = username;
+ this.password = password;
+
+ this.uri = null;
+ try
+ {
+ String serv = System.getProperty("gnu.javax.print.server");
+ if( serv != null )
+ this.uri = new URI("http://"+serv+":631");
+ }
+ catch(URISyntaxException use)
+ {
+ throw new RuntimeException("gnu.javax.print.CupsServer value is not a valid hostname.");
+ }
+ catch(SecurityException se)
+ {
+ }
+
try
{
- this.uri = new URI("http://localhost:631");
+ if( this.uri == null )
+ this.uri = new URI("http://localhost:631");
}
catch (URISyntaxException e)
{
// does not happen
}
-
- this.username = username;
- this.password = password;
}
/**
@@ -193,7 +212,7 @@ public class CupsServer
Map printerAttributes = (Map) prAttr.get(i);
Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
-
+
try
{
CupsPrintService cups = new CupsPrintService(uri.getURI(),
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppRequest.java b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
index 8abab519282..05a6faae72e 100644
--- a/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
+++ b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
@@ -119,6 +119,11 @@ public class IppRequest
{
/**
+ * The printer-poll timeout.
+ */
+ private static final int timeout = 1000;
+
+ /**
* Helper class used to write the attributes of a request
* into the supplied data output stream in the correct way.
*
@@ -789,7 +794,7 @@ public class IppRequest
alreadySent = true;
- OutputStream stream = stream = connection.getOutputStream();
+ OutputStream stream = connection.getOutputStream();
DataOutputStream out = new DataOutputStream(stream);
// the header 8 bytes long
@@ -838,8 +843,13 @@ public class IppRequest
out.flush();
stream.flush();
-
- int responseCode = responseCode = connection.getResponseCode();
+
+ // Set the connection timeout, for if the printer is offline.
+ // FIXME: The print services polling should probably be done in its
+ // own thread.
+ connection.setConnectTimeout( timeout );
+
+ int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK)
{
diff --git a/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java b/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
index 052b6c43d73..d4bd9ed267a 100644
--- a/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
+++ b/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
@@ -137,7 +137,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
{
if (choices[i].equals(replies[j]))
{
- indices.add(new Integer(i));
+ indices.add(Integer.valueOf(i));
}
}
if (indices.size() == 0)
diff --git a/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java b/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java
index f6c39bb3d7b..b5b5069233c 100644
--- a/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java
+++ b/libjava/classpath/gnu/javax/security/auth/login/ConfigFileParser.java
@@ -38,12 +38,15 @@ exception statement from your version. */
package gnu.javax.security.auth.login;
+import gnu.java.security.Configuration;
+
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import javax.security.auth.login.AppConfigurationEntry;
@@ -88,26 +91,12 @@ import javax.security.auth.login.AppConfigurationEntry;
*/
public final class ConfigFileParser
{
- // Constants and fields
- // --------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static final void debug(String m) {if (DEBUG) System.err.println(m);};
-
+ private static final Logger log = Logger.getLogger(ConfigFileParser.class.getName());
private ConfigFileTokenizer cft;
private Map map = new HashMap();
- // Constructor(s)
- // --------------------------------------------------------------------------
-
// default 0-arguments constructor
- // Class methods
- // --------------------------------------------------------------------------
-
- // Instance methods
- // --------------------------------------------------------------------------
-
/**
* Returns the parse result as a {@link Map} where the keys are application
* names, and the entries are {@link List}s of {@link AppConfigurationEntry}
@@ -161,7 +150,8 @@ public final class ConfigFileParser
}
String appName = cft.sval;
- debug("DEBUG: APP_NAME_OR_OTHER = " + appName);
+ if (Configuration.DEBUG)
+ log.fine("APP_NAME_OR_OTHER = " + appName);
if (cft.nextToken() != '{')
abort("Missing '{' after APP_NAME_OR_OTHER");
@@ -202,13 +192,15 @@ public final class ConfigFileParser
}
String clazz = validateClassName(cft.sval);
- debug("DEBUG: MODULE_CLASS = " + clazz);
+ if (Configuration.DEBUG)
+ log.fine("MODULE_CLASS = " + clazz);
if (cft.nextToken() != ConfigFileTokenizer.TT_WORD)
abort("Was expecting FLAG but found none");
String flag = cft.sval;
- debug("DEBUG: FLAG = " + flag);
+ if (Configuration.DEBUG)
+ log.fine("DEBUG: FLAG = " + flag);
AppConfigurationEntry.LoginModuleControlFlag f = null;
if (flag.equalsIgnoreCase("required"))
f = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
@@ -230,32 +222,39 @@ public final class ConfigFileParser
abort("Was expecting PARAM_NAME but got '" + ((char) c) + "'");
paramName = cft.sval;
- debug("DEBUG: PARAM_NAME = " + paramName);
+ if (Configuration.DEBUG)
+ log.fine("PARAM_NAME = " + paramName);
if (cft.nextToken() != '=')
abort("Missing '=' after PARAM_NAME");
c = cft.nextToken();
if (c != '"' && c != '\'')
- debug(" WARN: Was expecting a quoted string but got no quote " +
- "character. Assume unquoted string");
-
+ {
+ if (Configuration.DEBUG)
+ log.fine("Was expecting a quoted string but got no quote character."
+ + " Assume unquoted string");
+ }
paramValue = expandParamValue(cft.sval);
- debug("DEBUG: PARAM_VALUE = " + paramValue);
+ if (Configuration.DEBUG)
+ log.fine("PARAM_VALUE = " + paramValue);
options.put(paramName, paramValue);
c = cft.nextToken();
}
-
AppConfigurationEntry ace = new AppConfigurationEntry(clazz, f, options);
- debug("DEBUG: LOGIN_MODULE_ENTRY = " + ace);
+ if (Configuration.DEBUG)
+ log.fine("LOGIN_MODULE_ENTRY = " + ace);
listOfACEs.add(ace);
return true;
}
private void abort(String m) throws IOException
{
- debug("ERROR: " + m);
- debug("DEBUG: Map (so far) = " + String.valueOf(map));
+ if (Configuration.DEBUG)
+ {
+ log.fine(m);
+ log.fine("Map (so far) = " + String.valueOf(map));
+ }
throw new IOException(m);
}
@@ -264,12 +263,13 @@ public final class ConfigFileParser
if (cn.startsWith(".") || cn.endsWith("."))
abort("MODULE_CLASS MUST NOT start or end with a '.'");
- String[] tokens = cn.split(".");
+ String[] tokens = cn.split("\\.");
for (int i = 0; i < tokens.length; i++)
{
String t = tokens[i];
- if (Character.isJavaIdentifierStart(cn.toCharArray()[0]))
- abort("");
+ if (! Character.isJavaIdentifierStart(t.charAt(0)))
+ abort("Class name [" + cn
+ + "] contains an invalid sub-package identifier: " + t);
// we dont check the rest of the characters for isJavaIdentifierPart()
// because that's what the tokenizer does.
@@ -311,14 +311,17 @@ public final class ConfigFileParser
int j = s.indexOf("}", i + 2);
if (j == -1)
{
- debug(" WARN: Found a ${ prefix with no } suffix. Ignore");
+ if (Configuration.DEBUG)
+ log.fine("Found a ${ prefix with no } suffix. Ignore");
break;
}
String sysPropName = s.substring(i + 2, j);
- debug("DEBUG: Found a reference to System property " + sysPropName);
+ if (Configuration.DEBUG)
+ log.fine("Found a reference to System property " + sysPropName);
String sysPropValue = System.getProperty(sysPropName);
- debug("DEBUG: Resolved " + sysPropName + " to '" + sysPropValue + "'");
+ if (Configuration.DEBUG)
+ log.fine("Resolved " + sysPropName + " to '" + sysPropValue + "'");
if (sysPropValue != null)
{
result = s.substring(0, i) + sysPropValue + s.substring(j + 1);
@@ -330,7 +333,8 @@ public final class ConfigFileParser
}
catch (Exception x)
{
- debug(" WARN: Exception while expanding " + s + ". Ignore: " + x);
+ if (Configuration.DEBUG)
+ log.fine("Exception (ignored) while expanding " + s + ": " + x);
}
return result;
diff --git a/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java b/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java
index 2cfe916e400..06a1d2c7ce9 100644
--- a/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java
+++ b/libjava/classpath/gnu/javax/security/auth/login/ConfigFileTokenizer.java
@@ -38,14 +38,17 @@ exception statement from your version. */
package gnu.javax.security.auth.login;
+import gnu.java.security.Configuration;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
+import java.util.logging.Logger;
/**
* A UTF-8 friendly, JAAS Login Module Configuration file tokenizer written in
* the deault syntax. This class emulates, to a certain extent, the behavior of
- * a {@link java.io.SrteamTokenizer} instance <code>st</code>, when set as
+ * a {@link java.io.StreamTokenizer} instance <code>st</code>, when set as
* follows:
*
* <pre>
@@ -76,12 +79,7 @@ import java.io.Reader;
*/
public class ConfigFileTokenizer
{
- // Constants and fields
- // --------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static final void debug(String m) {if (DEBUG) System.err.println(m);};
-
+ private static final Logger log = Logger.getLogger(ConfigFileParser.class.getName());
/** A constant indicating that the end of the stream has been read. */
public static final int TT_EOF = -1;
/** A constant indicating that a word token has been read. */
@@ -235,9 +233,12 @@ public class ConfigFileTokenizer
private void abort(String m) throws IOException
{
- debug("DEBUG: " + m);
- debug("DEBUG: sb = " + sb);
- debug("DEBUG: sbNdx = " + sbNdx);
+ if (Configuration.DEBUG)
+ {
+ log.fine(m);
+ log.fine("sb = " + sb);
+ log.fine("sbNdx = " + sbNdx);
+ }
throw new IOException(m);
}
}
diff --git a/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java b/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java
index f0b8594a0df..8cd61c9544c 100644
--- a/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java
+++ b/libjava/classpath/gnu/javax/security/auth/login/GnuConfiguration.java
@@ -50,6 +50,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import javax.security.auth.AuthPermission;
import javax.security.auth.login.AppConfigurationEntry;
@@ -127,12 +128,7 @@ import javax.security.auth.login.Configuration;
*/
public final class GnuConfiguration extends Configuration
{
- // Constants and fields
- // --------------------------------------------------------------------------
-
- private static final boolean DEBUG = true;
- private static final void debug(String m) {if (DEBUG) System.err.println(m);};
-
+ private static final Logger log = Logger.getLogger(GnuConfiguration.class.getName());
/**
* The internal map of login modules keyed by application name. Each entry in
* this map is a {@link List} of {@link AppConfigurationEntry}s for that
@@ -179,7 +175,8 @@ public final class GnuConfiguration extends Configuration
if (loginModules == null || loginModules.size() == 0)
return null;
- debug("DEBUG: " + appName + " -> " + loginModules.size() + " entry(ies)");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine(appName + " -> " + loginModules.size() + " entry(ies)");
return (AppConfigurationEntry[]) loginModules.toArray(new AppConfigurationEntry[0]);
}
@@ -193,7 +190,7 @@ public final class GnuConfiguration extends Configuration
* @throws SecurityException if the caller does not have an
* {@link AuthPermission} for the action named
* <code>refreshLoginConfiguration</code>.
- * @see {@link AuthPermission}
+ * @see AuthPermission
*/
public void refresh()
{
@@ -215,13 +212,25 @@ public final class GnuConfiguration extends Configuration
private void init()
{
if (processSecurityProperties())
- debug(" INFO: Using login configuration defined by Security property(ies)");
+ {
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Using login configuration defined by Security property(ies)");
+ }
else if (processSystemProperty())
- debug(" INFO: Using login configuration defined by System property");
+ {
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Using login configuration defined by System property");
+ }
else if (processUserHome())
- debug(" INFO: Using login configuration defined in ${user.home}");
+ {
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Using login configuration defined in ${user.home}");
+ }
else
- debug(" WARN: No login configuration file found");
+ {
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("No login configuration file found");
+ }
}
/**
@@ -249,16 +258,18 @@ public final class GnuConfiguration extends Configuration
s = s.trim();
if (s.length() != 0)
{
- debug("DEBUG: java.security.auth.login.config.url." + counter
- + " = " + s);
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("java.security.auth.login.config.url." + counter
+ + " = " + s);
parseConfig(getInputStreamFromURL(s));
result = true;
}
}
catch (Throwable t)
{
- debug(" WARN: Exception while handling Security property at #"
- + counter + ". Continue: " + t);
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Exception while handling Security property at #"
+ + counter + ". Continue: " + t);
}
return result;
}
@@ -287,7 +298,8 @@ public final class GnuConfiguration extends Configuration
}
catch (MalformedURLException x)
{
- debug(" WARN: Failed opening as URL: " + s + ". Will try as File");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Failed opening as URL: " + s + ". Will try as File");
result = new FileInputStream(s);
}
return result;
@@ -311,7 +323,8 @@ public final class GnuConfiguration extends Configuration
s = s.trim();
if (s.length() != 0)
{
- debug("DEBUG: java.security.auth.login.config = " + s);
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("java.security.auth.login.config = " + s);
parseConfig(getInputStreamFromURL(s));
result = true;
}
@@ -319,7 +332,8 @@ public final class GnuConfiguration extends Configuration
}
catch (Throwable t)
{
- debug(" WARN: Exception while handling System property. Continue: " + t);
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Exception while handling System property. Continue: " + t);
}
return result;
}
@@ -349,8 +363,9 @@ public final class GnuConfiguration extends Configuration
if (jaasFile == null)
{
- debug(" WARN: Login Configuration file, in " + userHome
- + ", does not exist or is inaccessible");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Login Configuration file, in " + userHome
+ + ", does not exist or is inaccessible");
return result;
}
@@ -360,7 +375,8 @@ public final class GnuConfiguration extends Configuration
}
catch (Throwable t)
{
- debug(" WARN: Exception while handling ${user.home}: " + t);
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("Exception (ignored) while handling ${user.home}: " + t);
}
return result;
}
@@ -397,54 +413,54 @@ public final class GnuConfiguration extends Configuration
String uh = System.getProperty("user.home");
if (uh == null || uh.trim().length() == 0)
{
- debug(" WARN: User home path is not set or is empty");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("User home path is not set or is empty");
return null;
}
-
uh = uh.trim();
File result = new File(uh);
- if (!result.exists())
+ if (! result.exists())
{
- debug(" WARN: User home '" + uh + "' does not exist");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("User home '" + uh + "' does not exist");
return null;
}
-
- if (!result.isDirectory())
+ if (! result.isDirectory())
{
- debug(" WARN: User home '" + uh + "' is not a directory");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("User home '" + uh + "' is not a directory");
return null;
}
-
- if (!result.canRead())
+ if (! result.canRead())
{
- debug(" WARN: User home '" + uh + "' is not readable");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("User home '" + uh + "' is not readable");
return null;
}
-
return result;
}
private File getConfigFromUserHome(File userHome, String fileName)
{
File result = new File(userHome, fileName);
- if (!result.exists())
+ if (! result.exists())
{
- debug(" WARN: File '" + fileName + "' does not exist in user's home");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("File '" + fileName + "' does not exist in user's home");
return null;
}
-
- if (!result.isFile())
+ if (! result.isFile())
{
- debug(" WARN: File '" + fileName + "' in user's home is not a file");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("File '" + fileName + "' in user's home is not a file");
return null;
}
-
- if (!result.canRead())
+ if (! result.canRead())
{
- debug(" WARN: File '" + fileName + "' in user's home is not readable");
+ if (gnu.java.security.Configuration.DEBUG)
+ log.fine("File '" + fileName + "' in user's home is not readable");
return null;
}
-
return result;
}
}
diff --git a/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java b/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java
new file mode 100644
index 00000000000..cb5a8e82dfa
--- /dev/null
+++ b/libjava/classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java
@@ -0,0 +1,77 @@
+/* ExtendedMidiFileFormat.java -- extended with track count info.
+ 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.midi.file;
+
+/**
+ * ExtendedMidiFileFormat is a package private class that simply
+ * adds the number of MIDI tracks for the MidiFileFormat class.
+ *
+ * @author Anthony Green (green@redhat.com)
+ */
+class ExtendedMidiFileFormat
+ extends javax.sound.midi.MidiFileFormat
+{
+ private int ntracks;
+
+ /**
+ * Get the number of tracks for this MIDI file.
+ *
+ * @return the number of tracks for this MIDI file
+ */
+ public int getNumberTracks()
+ {
+ return ntracks;
+ }
+
+ /**
+ * Create an ExtendedMidiFileFormat object from the given parameters.
+ *
+ * @param type the MIDI file type (0, 1, or 2)
+ * @param divisionType the MIDI file division type
+ * @param resolution the MIDI file timing resolution
+ * @param bytes the MIDI file size in bytes
+ * @param microseconds the MIDI file length in microseconds
+ * @param ntracks the number of tracks
+ */
+ public ExtendedMidiFileFormat(int type, float divisionType, int resolution,
+ int bytes, long microseconds, int ntracks)
+ {
+ super(type, divisionType, resolution, bytes, microseconds);
+ this.ntracks = ntracks;
+ }
+}
diff --git a/libjava/classpath/javax/swing/text/html/HTMLTableView.java b/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java
index cac44d8dc27..010d17093c1 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLTableView.java
+++ b/libjava/classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java
@@ -1,4 +1,4 @@
-/* HTMLTableView.java -- A table view for HTML tables
+/* MidiDataInputStream.java -- adds variable length MIDI ints
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,48 +35,49 @@ 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.midi.file;
-package javax.swing.text.html;
-
-import javax.swing.text.Element;
-import javax.swing.text.TableView;
-import javax.swing.text.View;
-import javax.swing.text.ViewFactory;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
/**
- * A conrete implementation of TableView that renders HTML tables.
- *
- * @author Roman Kennke (kennke@aicas.com)
+ * MidiDataInputStream is simply a DataInputStream with the addition
+ * of special variable length int reading as defined by the MIDI spec.
+ *
+ * @author Anthony Green (green@redhat.com)
*/
-class HTMLTableView
- extends TableView
+public class MidiDataInputStream
+ extends DataInputStream
{
-
/**
- * Creates a new HTMLTableView for the specified element.
- *
- * @param el the element for the table view
+ * Create a MidiDataInputStream.
*/
- public HTMLTableView(Element el)
+ public MidiDataInputStream(InputStream is)
{
- super(el);
+ super(is);
}
-
+
/**
- * Loads the children of the Table. This completely bypasses the ViewFactory
- * and creates instances of TableRow instead.
+ * Read an int encoded in the MIDI-style variable length
+ * encoding format.
*
- * @param vf ignored
+ * @return an int
*/
- protected void loadChildren(ViewFactory vf)
+ public int readVariableLengthInt()
+ throws IOException
{
- Element el = getElement();
- int numChildren = el.getElementCount();
- View[] rows = new View[numChildren];
- for (int i = 0; i < numChildren; ++i)
+ int c, value = readByte();
+
+ if ((value & 0x80) != 0)
{
- rows[i] = createTableRow(el.getElement(i));
+ value &= 0x7F;
+ do
+ {
+ value = (value << 7) + ((c = readByte()) & 0x7F);
+ } while ((c & 0x80) != 0);
}
- replace(0, getViewCount(), rows);
+
+ return value;
}
}
diff --git a/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java b/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java
new file mode 100644
index 00000000000..f9a3dac8e87
--- /dev/null
+++ b/libjava/classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java
@@ -0,0 +1,114 @@
+/* MidiDataOutputStream.java -- adds variable length MIDI ints
+ 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.midi.file;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * MidiDataOutputStream is simply a DataOutputStream with the addition
+ * of special variable length int writing as defined by the MIDI spec.
+ *
+ * @author Anthony Green (green@redhat.com)
+ */
+public class MidiDataOutputStream
+ extends DataOutputStream
+{
+ /**
+ * Create a MidiDataOutputStream.
+ */
+ public MidiDataOutputStream(OutputStream os)
+ {
+ super(os);
+ }
+
+ /**
+ * Return the length of a variable length encoded int without
+ * writing it out.
+ *
+ * @return the length of the encoding
+ */
+ public int variableLengthIntLength (int value)
+ {
+ int length = 0;
+ int buffer = value & 0x7F;
+
+ while ((value >>= 7) != 0)
+ {
+ buffer <<= 8;
+ buffer |= ((value & 0x7F) | 0x80);
+ }
+
+ while (true)
+ {
+ length++;
+ if ((buffer & 0x80) != 0)
+ buffer >>>= 8;
+ else
+ break;
+ }
+
+ return length;
+ }
+
+ /**
+ * Write an int encoded in the MIDI-style variable length
+ * encoding format.
+ */
+ public synchronized void writeVariableLengthInt (int value)
+ throws IOException
+ {
+ int buffer = value & 0x7F;
+
+ while ((value >>= 7) != 0)
+ {
+ buffer <<= 8;
+ buffer |= ((value & 0x7F) | 0x80);
+ }
+
+ while (true)
+ {
+ writeByte(buffer & 0xff);
+ if ((buffer & 0x80) != 0)
+ buffer >>>= 8;
+ else
+ break;
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java b/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java
new file mode 100644
index 00000000000..cb640e14a6a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/sound/midi/file/MidiFileReader.java
@@ -0,0 +1,378 @@
+/* MidiFileReader.java -- Read MIDI 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.midi.file;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.MidiEvent;
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.ShortMessage;
+import javax.sound.midi.SysexMessage;
+import javax.sound.midi.Track;
+
+/**
+ * A MIDI file reader.
+ *
+ * This code reads MIDI file types 0 and 1.
+ *
+ * There are many decent documents on the web describing the MIDI file
+ * format. I didn't bother looking for the official document. If it
+ * exists, I'm not even sure if it is freely available. We should
+ * update this comment if we find out anything helpful here.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class MidiFileReader extends javax.sound.midi.spi.MidiFileReader
+{
+ /* Get the MidiFileFormat for the given input stream.
+ * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.io.InputStream)
+ */
+ public MidiFileFormat getMidiFileFormat(InputStream in)
+ throws InvalidMidiDataException, IOException
+ {
+ DataInputStream din;
+ if (in instanceof DataInputStream)
+ din = (DataInputStream) in;
+ else
+ din = new DataInputStream(in);
+
+ int type, ntracks, division, resolution, bytes;
+ float divisionType;
+
+ if (din.readInt() != 0x4d546864) // "MThd"
+ throw new InvalidMidiDataException("Invalid MIDI chunk header.");
+
+ bytes = din.readInt();
+ if (bytes < 6)
+ throw new
+ InvalidMidiDataException("Invalid MIDI chunk header length: " + bytes);
+
+ type = din.readShort();
+ if (type < 0 || type > 2)
+ throw new
+ InvalidMidiDataException("Invalid MIDI file type value: " + type);
+
+ ntracks = din.readShort();
+ if (ntracks <= 0)
+ throw new
+ InvalidMidiDataException("Invalid number of MIDI tracks: " + ntracks);
+
+ division = din.readShort();
+ if ((division & 0x8000) != 0)
+ {
+ division = -((division >>> 8) & 0xFF);
+ switch (division)
+ {
+ case 24:
+ divisionType = Sequence.SMPTE_24;
+ break;
+
+ case 25:
+ divisionType = Sequence.SMPTE_25;
+ break;
+
+ case 29:
+ divisionType = Sequence.SMPTE_30DROP;
+ break;
+
+ case 30:
+ divisionType = Sequence.SMPTE_30;
+ break;
+
+ default:
+ throw new
+ InvalidMidiDataException("Invalid MIDI frame division type: "
+ + division);
+ }
+ resolution = division & 0xff;
+ }
+ else
+ {
+ divisionType = Sequence.PPQ;
+ resolution = division & 0x7fff;
+ }
+
+ // If we haven't read every byte in the header now, just skip the rest.
+ din.skip(bytes - 6);
+
+ return new ExtendedMidiFileFormat(type, divisionType, resolution,
+ MidiFileFormat.UNKNOWN_LENGTH,
+ MidiFileFormat.UNKNOWN_LENGTH, ntracks);
+ }
+
+ /* Get the MidiFileFormat from the given URL.
+ * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.net.URL)
+ */
+ public MidiFileFormat getMidiFileFormat(URL url)
+ throws InvalidMidiDataException, IOException
+ {
+ InputStream is = url.openStream();
+ try
+ {
+ return getMidiFileFormat(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /* Get the MidiFileFormat from the given file.
+ * @see javax.sound.midi.spi.MidiFileReader#getMidiFileFormat(java.io.File)
+ */
+ public MidiFileFormat getMidiFileFormat(File file)
+ throws InvalidMidiDataException, IOException
+ {
+ InputStream is = new FileInputStream(file);
+ try
+ {
+ return getMidiFileFormat(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /* Get the MIDI Sequence found in this input stream.
+ * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.io.InputStream)
+ */
+ public Sequence getSequence(InputStream is) throws InvalidMidiDataException,
+ IOException
+ {
+ MidiDataInputStream din = new MidiDataInputStream(is);
+ ExtendedMidiFileFormat mff = (ExtendedMidiFileFormat) getMidiFileFormat(din);
+
+ Sequence seq = new Sequence(mff.getDivisionType(), mff.getResolution());
+
+ int ntracks = mff.getNumberTracks();
+
+ while (ntracks-- > 0)
+ {
+ Track track = seq.createTrack();
+ int Mtrk = din.readInt();
+ if (Mtrk != 0x4d54726b)
+ throw new InvalidMidiDataException("Invalid MIDI track header.");
+ int length = din.readInt();
+
+ int runningStatus = -1;
+ int click = 0;
+
+ // Set this to true when we've hit an End of Track meta event.
+ boolean done = false;
+
+ // Read all events.
+ while (! done)
+ {
+ MidiMessage mm;
+ int dtime = din.readVariableLengthInt();
+ click += dtime;
+
+ int sbyte = din.readUnsignedByte();
+
+ if (sbyte < 0xf0)
+ {
+ ShortMessage sm;
+ switch (sbyte & 0xf0)
+ {
+ case ShortMessage.NOTE_OFF:
+ case ShortMessage.NOTE_ON:
+ case ShortMessage.POLY_PRESSURE:
+ case ShortMessage.CONTROL_CHANGE:
+ case ShortMessage.PITCH_BEND:
+ case ShortMessage.SONG_POSITION_POINTER:
+ sm = new ShortMessage();
+ sm.setMessage(sbyte, din.readByte(), din.readByte());
+ runningStatus = sbyte;
+ break;
+
+ case ShortMessage.PROGRAM_CHANGE:
+ case ShortMessage.CHANNEL_PRESSURE:
+ case ShortMessage.SONG_SELECT:
+ case 0xF5: // FIXME: unofficial bus select. Not in spec??
+ sm = new ShortMessage();
+ sm.setMessage(sbyte, din.readByte(), 0);
+ runningStatus = sbyte;
+ break;
+
+ case ShortMessage.TUNE_REQUEST:
+ case ShortMessage.END_OF_EXCLUSIVE:
+ case ShortMessage.TIMING_CLOCK:
+ case ShortMessage.START:
+ case ShortMessage.CONTINUE:
+ case ShortMessage.STOP:
+ case ShortMessage.ACTIVE_SENSING:
+ case ShortMessage.SYSTEM_RESET:
+ sm = new ShortMessage();
+ sm.setMessage(sbyte, 0, 0);
+ runningStatus = sbyte;
+ break;
+
+ default:
+ if (runningStatus != - 1)
+ {
+ switch (runningStatus & 0xf0)
+ {
+ case ShortMessage.NOTE_OFF:
+ case ShortMessage.NOTE_ON:
+ case ShortMessage.POLY_PRESSURE:
+ case ShortMessage.CONTROL_CHANGE:
+ case ShortMessage.PITCH_BEND:
+ case ShortMessage.SONG_POSITION_POINTER:
+ sm = new ShortMessage();
+ sm.setMessage(runningStatus, sbyte, din.readByte());
+ break;
+
+ case ShortMessage.PROGRAM_CHANGE:
+ case ShortMessage.CHANNEL_PRESSURE:
+ case ShortMessage.SONG_SELECT:
+ case 0xF5: // FIXME: unofficial bus select. Not in
+ // spec??
+ sm = new ShortMessage();
+ sm.setMessage(runningStatus, sbyte, 0);
+ continue;
+
+ case ShortMessage.TUNE_REQUEST:
+ case ShortMessage.END_OF_EXCLUSIVE:
+ case ShortMessage.TIMING_CLOCK:
+ case ShortMessage.START:
+ case ShortMessage.CONTINUE:
+ case ShortMessage.STOP:
+ case ShortMessage.ACTIVE_SENSING:
+ case ShortMessage.SYSTEM_RESET:
+ sm = new ShortMessage();
+ sm.setMessage(runningStatus, 0, 0);
+ continue;
+
+ default:
+ throw new
+ InvalidMidiDataException("Invalid Short MIDI Event: "
+ + sbyte);
+ }
+ }
+ else
+ throw new
+ InvalidMidiDataException("Invalid Short MIDI Event: "
+ + sbyte);
+ }
+ mm = sm;
+ }
+ else if (sbyte == 0xf0 || sbyte == 0xf7)
+ {
+ // System Exclusive event
+ int slen = din.readVariableLengthInt();
+ byte sysex[] = new byte[slen];
+ din.readFully(sysex);
+ SysexMessage sm = new SysexMessage();
+ sm.setMessage(sbyte, sysex, slen);
+ mm = sm;
+ runningStatus = - 1;
+ }
+ else if (sbyte == 0xff)
+ {
+ // Meta Message
+ byte mtype = din.readByte();
+ int mlen = din.readVariableLengthInt();
+ byte meta[] = new byte[mlen];
+ din.readFully(meta);
+ MetaMessage metam = new MetaMessage();
+ metam.setMessage(mtype, meta, mlen);
+ mm = metam;
+
+ if (mtype == 0x2f) // End of Track
+ done = true;
+
+ runningStatus = - 1;
+ }
+ else
+ {
+ throw new InvalidMidiDataException("Invalid status byte: "
+ + sbyte);
+ }
+
+ track.add(new MidiEvent(mm, click));
+ }
+ }
+
+ return seq;
+ }
+
+ /* Get the MIDI Sequence found at the given URL.
+ * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.net.URL)
+ */
+ public Sequence getSequence(URL url) throws InvalidMidiDataException,
+ IOException
+ {
+ InputStream is = url.openStream();
+ try
+ {
+ return getSequence(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /* Get the MIDI Sequence found in the given file.
+ * @see javax.sound.midi.spi.MidiFileReader#getSequence(java.io.File)
+ */
+ public Sequence getSequence(File file) throws InvalidMidiDataException,
+ IOException
+ {
+ InputStream is = new FileInputStream(file);
+ try
+ {
+ return getSequence(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java b/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java
new file mode 100644
index 00000000000..71970d5ba6e
--- /dev/null
+++ b/libjava/classpath/gnu/javax/sound/midi/file/MidiFileWriter.java
@@ -0,0 +1,199 @@
+/* MidiFileWriter.java -- Write MIDI 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.midi.file;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.MidiEvent;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.Track;
+
+/**
+ * A MIDI file writer.
+ *
+ * This code writes MIDI file types 0 and 1.
+ *
+ * There are many decent documents on the web describing the MIDI file
+ * format. I didn't bother looking for the official document. If it
+ * exists, I'm not even sure if it is freely available. We should
+ * update this comment if we find out anything helpful here.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class MidiFileWriter
+ extends javax.sound.midi.spi.MidiFileWriter
+{
+ /* Return an array indicating which midi file types are supported.
+ * @see javax.sound.midi.spi.MidiFileWriter#getMidiFileTypes()
+ */
+ public int[] getMidiFileTypes()
+ {
+ return new int[]{0, 1};
+ }
+
+ /* Return an array indicating which midi file types are supported
+ * for a given Sequence.
+ * @see javax.sound.midi.spi.MidiFileWriter#getMidiFileTypes(javax.sound.midi.Sequence)
+ */
+ public int[] getMidiFileTypes(Sequence sequence)
+ {
+ if (sequence.getTracks().length == 1)
+ return new int[]{0};
+ else
+ return new int[]{1};
+ }
+
+ /* Write a sequence to an output stream in standard midi format.
+ * @see javax.sound.midi.spi.MidiFileWriter#write(javax.sound.midi.Sequence, int, java.io.OutputStream)
+ */
+ public int write(Sequence in, int fileType, OutputStream out)
+ throws IOException
+ {
+ MidiDataOutputStream dos = new MidiDataOutputStream (out);
+ Track[] tracks = in.getTracks();
+ dos.writeInt(0x4d546864); // MThd
+ dos.writeInt(6);
+ dos.writeShort(fileType);
+ dos.writeShort(tracks.length);
+ float divisionType = in.getDivisionType();
+ int resolution = in.getResolution();
+ // FIXME: division computation is incomplete.
+ int division = 0;
+ if (divisionType == Sequence.PPQ)
+ division = resolution & 0x7fff;
+ dos.writeShort(division);
+ int length = 14;
+ for (int i = 0; i < tracks.length; i++)
+ length += writeTrack(tracks[i], dos);
+ return length;
+ }
+
+ /**
+ * Compute the length of a track as it will be written to the
+ * output stream.
+ *
+ * @param track the track to measure
+ * @param dos a MidiDataOutputStream used for helper method
+ * @return the length of the track
+ */
+ private int computeTrackLength(Track track, MidiDataOutputStream dos)
+ {
+ int count = 0, length = 0, i = 0, eventCount = track.size();
+ long ptick = 0;
+ while (i < eventCount)
+ {
+ MidiEvent me = track.get(i);
+ long tick = me.getTick();
+ length += dos.variableLengthIntLength((int) (tick - ptick));
+ ptick = tick;
+ length += me.getMessage().getLength();
+ i++;
+ }
+ return length;
+ }
+
+ /**
+ * Write a track to an output stream.
+ *
+ * @param track the track to write
+ * @param dos a MidiDataOutputStream to write to
+ * @return the number of bytes written
+ */
+ private int writeTrack(Track track, MidiDataOutputStream dos)
+ throws IOException
+ {
+ int i = 0, elength = track.size(), trackLength;
+ MidiEvent pme = null;
+ dos.writeInt(0x4d54726b); // "MTrk"
+ trackLength = computeTrackLength(track, dos);
+ dos.writeInt(trackLength);
+ while (i < elength)
+ {
+ MidiEvent me = track.get(i);
+ int dtime = 0;
+ if (pme != null)
+ dtime = (int) (me.getTick() - pme.getTick());
+ dos.writeVariableLengthInt(dtime);
+ // FIXME: use running status byte
+ byte msg[] = me.getMessage().getMessage();
+ dos.write(msg);
+ pme = me;
+ i++;
+ }
+
+ // We're done if the last event was an End of Track meta message.
+ if (pme != null && (pme.getMessage() instanceof MetaMessage))
+ {
+ MetaMessage mm = (MetaMessage) pme.getMessage();
+ if (mm.getType() == 0x2f) // End of Track message
+ return trackLength + 8;
+ }
+
+ // Write End of Track meta message
+ dos.writeVariableLengthInt(0); // Delta time of 0
+ dos.writeByte(0xff); // Meta Message
+ dos.writeByte(0x2f); // End of Track message
+ dos.writeVariableLengthInt(0); // Length of 0
+
+ return trackLength + 8 + 4;
+ }
+
+ /* Write a Sequence to a file.
+ * @see javax.sound.midi.spi.MidiFileWriter#write(javax.sound.midi.Sequence, int, java.io.File)
+ */
+ public int write(Sequence in, int fileType, File out) throws IOException
+ {
+ OutputStream os = new FileOutputStream(out);
+ try
+ {
+ return write(in, fileType, os);
+ }
+ finally
+ {
+ os.close();
+ }
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java b/libjava/classpath/gnu/javax/sound/sampled/AU/AUReader.java
new file mode 100644
index 00000000000..c9035df7338
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java b/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java
new file mode 100644
index 00000000000..0cf3c137797
--- /dev/null
+++ b/libjava/classpath/gnu/javax/sound/sampled/WAV/WAVReader.java
@@ -0,0 +1,236 @@
+/* WAVReader.java -- Read WAV 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.WAV;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.net.URL;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.sound.sampled.spi.AudioFileReader;
+
+/**
+ * A WAV file reader.
+ *
+ * This code reads WAV files.
+ *
+ * There are many decent documents on the web describing the WAV file
+ * format. I didn't bother looking for the official document. If it
+ * exists, I'm not even sure if it is freely available. We should
+ * update this comment if we find out anything helpful here. I used
+ * http://www.sonicspot.com/guide/wavefiles.html
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class WAVReader extends AudioFileReader
+{
+ private static long readUnsignedIntLE (DataInputStream is)
+ throws IOException
+ {
+ byte[] buf = new byte[4];
+ is.readFully(buf);
+ return (buf[0] & 0xFF
+ | ((buf[1] & 0xFF) << 8)
+ | ((buf[2] & 0xFF) << 16)
+ | ((buf[3] & 0xFF) << 24));
+ }
+
+ private static short readUnsignedShortLE (DataInputStream is)
+ throws IOException
+ {
+ byte[] buf = new byte[2];
+ is.readFully(buf);
+ return (short) (buf[0] & 0xFF
+ | ((buf[1] & 0xFF) << 8));
+ }
+
+ /* Get an AudioFileFormat from the given File.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.io.File)
+ */
+ public AudioFileFormat getAudioFileFormat(File file)
+ throws UnsupportedAudioFileException, IOException
+ {
+ InputStream is = new FileInputStream(file);
+ try
+ {
+ return getAudioFileFormat(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /* Get an AudioFileFormat from the given InputStream.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.io.InputStream)
+ */
+ public AudioFileFormat getAudioFileFormat(InputStream in)
+ throws UnsupportedAudioFileException, IOException
+ {
+ DataInputStream din;
+
+ if (in instanceof DataInputStream)
+ din = (DataInputStream) in;
+ else
+ din = new DataInputStream(in);
+
+ if (din.readInt() != 0x52494646) // "RIFF"
+ throw new UnsupportedAudioFileException("Invalid WAV chunk header.");
+
+ // Read the length of this RIFF thing.
+ readUnsignedIntLE(din);
+
+ if (din.readInt() != 0x57415645) // "WAVE"
+ throw new UnsupportedAudioFileException("Invalid WAV chunk header.");
+
+ boolean foundFmt = false;
+ boolean foundData = false;
+
+ short compressionCode = 0, numberChannels = 0, blockAlign = 0, bitsPerSample = 0;
+ long sampleRate = 0, bytesPerSecond = 0;
+ long chunkLength = 0;
+
+ while (! foundData)
+ {
+ int chunkId = din.readInt();
+ chunkLength = readUnsignedIntLE(din);
+ switch (chunkId)
+ {
+ case 0x666D7420: // "fmt "
+ foundFmt = true;
+ compressionCode = readUnsignedShortLE(din);
+ numberChannels = readUnsignedShortLE(din);
+ sampleRate = readUnsignedIntLE(din);
+ bytesPerSecond = readUnsignedIntLE(din);
+ blockAlign = readUnsignedShortLE(din);
+ bitsPerSample = readUnsignedShortLE(din);
+ din.skip(chunkLength - 16);
+ break;
+ case 0x66616374: // "fact"
+ // FIXME: hold compression format dependent data.
+ din.skip(chunkLength);
+ break;
+ case 0x64617461: // "data"
+ if (! foundFmt)
+ throw new UnsupportedAudioFileException("This implementation requires WAV fmt chunks precede data chunks.");
+ foundData = true;
+ break;
+ default:
+ // Unrecognized chunk. Skip it.
+ din.skip(chunkLength);
+ }
+ }
+
+ AudioFormat.Encoding encoding;
+
+ switch (compressionCode)
+ {
+ case 1: // PCM/uncompressed
+ if (bitsPerSample <= 8)
+ encoding = AudioFormat.Encoding.PCM_UNSIGNED;
+ else
+ encoding = AudioFormat.Encoding.PCM_SIGNED;
+ break;
+
+ default:
+ throw new UnsupportedAudioFileException("Unrecognized WAV compression code: 0x"
+ + Integer.toHexString(compressionCode));
+ }
+
+ return new AudioFileFormat (AudioFileFormat.Type.WAVE,
+ new AudioFormat(encoding,
+ (float) sampleRate,
+ bitsPerSample,
+ numberChannels,
+ ((bitsPerSample + 7) / 8) * numberChannels,
+ (float) bytesPerSecond, false),
+ (int) chunkLength);
+ }
+
+ /* Get an AudioFileFormat from the given URL.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioFileFormat(java.net.URL)
+ */
+ public AudioFileFormat getAudioFileFormat(URL url)
+ throws UnsupportedAudioFileException, IOException
+ {
+ InputStream is = url.openStream();
+ try
+ {
+ return getAudioFileFormat(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /* Get an AudioInputStream from the given File.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.io.File)
+ */
+ public AudioInputStream getAudioInputStream(File file)
+ throws UnsupportedAudioFileException, IOException
+ {
+ return getAudioInputStream(new FileInputStream(file));
+ }
+
+ /* Get an AudioInputStream from the given InputStream.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.io.InputStream)
+ */
+ public AudioInputStream getAudioInputStream(InputStream stream)
+ throws UnsupportedAudioFileException, IOException
+ {
+ AudioFileFormat aff = getAudioFileFormat(stream);
+ return new AudioInputStream(stream, aff.getFormat(), (long) aff.getFrameLength());
+ }
+
+ /* Get an AudioInputStream from the given URL.
+ * @see javax.sound.sampled.spi.AudioFileReader#getAudioInputStream(java.net.URL)
+ */
+ public AudioInputStream getAudioInputStream(URL url)
+ throws UnsupportedAudioFileException, IOException
+ {
+ return getAudioInputStream(url.openStream());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
index 67d6332df58..a9b504a387e 100644
--- a/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
+++ b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
@@ -71,6 +71,7 @@ public class GNULookAndFeel extends BasicLookAndFeel
"ScrollBar.background", new ColorUIResource(blueGray),
"CheckBox.icon", new CheckBoxIcon(),
"RadioButton.icon", new RadioButtonIcon(),
+ "Tree.hash", new ColorUIResource(Color.black),
"Tree.closedIcon",
new IconUIResource(new ImageIcon
diff --git a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
index 5f7309583ea..06732e401fe 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
+++ b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
@@ -83,7 +83,7 @@ public class CharacterAttributeTranslator
* @param colorName the color to convert.
* @return the matching java.awt.color
*/
- private static Color getColor(String colorName)
+ public static Color getColor(String colorName)
{
colorName = colorName.toLowerCase();
try
diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java b/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java
new file mode 100644
index 00000000000..841db667e84
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java
index 1ed42a2ab98..c3c347e36e3 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java
new file mode 100644
index 00000000000..9c934f647de
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
index 45e1dce7b04..930a324f9b7 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
+++ b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
@@ -100,8 +100,6 @@ public class SmallHtmlAttributeSet
key = en.nextElement();
keys[i] = key;
value = copyFrom.getAttribute(key);
- if (value instanceof String)
- value = ((String) value).toLowerCase();
values[i] = value;
}
}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java
index 1f9eee03a91..4d287a67763 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java
+++ b/libjava/classpath/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/libjava/classpath/gnu/xml/dom/DomIterator.java b/libjava/classpath/gnu/xml/dom/DomIterator.java
index 472c6e80585..31f9982467b 100644
--- a/libjava/classpath/gnu/xml/dom/DomIterator.java
+++ b/libjava/classpath/gnu/xml/dom/DomIterator.java
@@ -1,5 +1,5 @@
/* DomIterator.java --
- Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -253,7 +253,13 @@ public final class DomIterator
{
return here.getFirstChild();
}
-
+
+ // There's no way up or sideways from the root, so if we
+ // couldn't move down to a child, there's nowhere to go.
+ //
+ if (here == root)
+ return null;
+
//
// Siblings ... if forward, we visit them, if backwards
// we visit their children first.
@@ -297,7 +303,9 @@ public final class DomIterator
{
next = next.getParentNode();
}
- if (next == root)
+
+ // If we have exceeded the root node then stop traversing.
+ if (next == root.getParentNode())
{
return null;
}
diff --git a/libjava/classpath/gnu/xml/stream/SAXParser.java b/libjava/classpath/gnu/xml/stream/SAXParser.java
index fd768a43da3..e58d5fb52ff 100644
--- a/libjava/classpath/gnu/xml/stream/SAXParser.java
+++ b/libjava/classpath/gnu/xml/stream/SAXParser.java
@@ -976,10 +976,56 @@ public class SAXParser
public static void main(String[] args)
throws Exception
{
- SAXParser parser = new SAXParser();
- InputSource input = new InputSource(args[0]);
- parser.parse(input, new org.xml.sax.helpers.DefaultHandler());
-
+ boolean validating = false;
+ boolean namespaceAware = false;
+ boolean xIncludeAware = false;
+ boolean expectCallbackClass = false;
+ String callbackClass = null;
+ int pos = 0;
+ while (pos < args.length && (args[pos].startsWith("-") || expectCallbackClass))
+ {
+ if ("-x".equals(args[pos]))
+ xIncludeAware = true;
+ else if ("-v".equals(args[pos]))
+ validating = true;
+ else if ("-n".equals(args[pos]))
+ namespaceAware = true;
+ else if ("-c".equals(args[pos]))
+ expectCallbackClass = true;
+ else if (expectCallbackClass)
+ {
+ callbackClass = args[pos];
+ expectCallbackClass = false;
+ }
+ pos++;
+ }
+ if (pos >= args.length || expectCallbackClass)
+ {
+ System.out.println("Syntax: SAXParser [-n] [-v] [-x] [-c <class>] <file> [<file2> [...]]");
+ System.out.println("\t-n: use namespace aware mode");
+ System.out.println("\t-v: use validating parser");
+ System.out.println("\t-x: use XInclude aware mode");
+ System.out.println("\t-c <class>: use specified class as callback handler (must have a no-arg public constructor)");
+ System.exit(2);
+ }
+ while (pos < args.length)
+ {
+ ContentHandler handler = null;
+ if (callbackClass != null)
+ {
+ Class t = Class.forName(callbackClass);
+ handler = (ContentHandler) t.newInstance();
+ }
+ else
+ handler = new org.xml.sax.helpers.DefaultHandler();
+ SAXParser parser = new SAXParser(validating, namespaceAware,
+ xIncludeAware);
+ InputSource input = new InputSource(args[pos]);
+ XMLReader reader = parser.getXMLReader();
+ reader.setContentHandler(handler);
+ reader.parse(input);
+ pos++;
+ }
}
}
diff --git a/libjava/classpath/gnu/xml/stream/XMLParser.java b/libjava/classpath/gnu/xml/stream/XMLParser.java
index 87096eecf9e..ef3779944c3 100644
--- a/libjava/classpath/gnu/xml/stream/XMLParser.java
+++ b/libjava/classpath/gnu/xml/stream/XMLParser.java
@@ -56,6 +56,8 @@ package gnu.xml.stream;
import java.io.BufferedInputStream;
import java.io.EOFException;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -86,6 +88,8 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import gnu.java.net.CRLFInputStream;
+import gnu.classpath.debug.TeeInputStream;
+import gnu.classpath.debug.TeeReader;
/**
* An XML parser.
@@ -420,6 +424,21 @@ public class XMLParser
ids = new HashSet();
idrefs = new HashSet();
}
+ String debug = System.getProperty("gnu.xml.debug.input");
+ if (debug != null)
+ {
+ try
+ {
+ File file = File.createTempFile(debug, ".xml");
+ in = new TeeInputStream(in, new FileOutputStream(file));
+ }
+ catch (IOException e)
+ {
+ RuntimeException e2 = new RuntimeException();
+ e2.initCause(e);
+ throw e2;
+ }
+ }
pushInput(new Input(in, null, null, systemId, null, null, false, true));
}
@@ -479,6 +498,21 @@ public class XMLParser
ids = new HashSet();
idrefs = new HashSet();
}
+ String debug = System.getProperty("gnu.xml.debug.input");
+ if (debug != null)
+ {
+ try
+ {
+ File file = File.createTempFile(debug, ".xml");
+ reader = new TeeReader(reader, new FileWriter(file));
+ }
+ catch (IOException e)
+ {
+ RuntimeException e2 = new RuntimeException();
+ e2.initCause(e);
+ throw e2;
+ }
+ }
pushInput(new Input(null, reader, null, systemId, null, null, false, true));
}
@@ -1332,6 +1366,15 @@ public class XMLParser
return false;
}
count += l2;
+ // check the characters we received first before doing additional reads
+ for (int i = 0; i < count; i++)
+ {
+ if (chars[i] != tmpBuf[i])
+ {
+ reset();
+ return false;
+ }
+ }
while (count < len)
{
// force read
@@ -1341,15 +1384,14 @@ public class XMLParser
reset();
return false;
}
- tmpBuf[count++] = (char) c;
- }
- for (int i = 0; i < len; i++)
- {
- if (chars[i] != tmpBuf[i])
+ tmpBuf[count] = (char) c;
+ // check each character as it is read
+ if (chars[count] != tmpBuf[count])
{
reset();
return false;
}
+ count++;
}
return true;
}
@@ -4250,97 +4292,131 @@ public class XMLParser
public static void main(String[] args)
throws Exception
{
+ boolean validating = false;
+ boolean namespaceAware = false;
boolean xIncludeAware = false;
- if (args.length > 1 && "-x".equals(args[1]))
- xIncludeAware = true;
- XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]),
- absolutize(null, args[0]),
- true, // validating
- true, // namespaceAware
- true, // coalescing,
- true, // replaceERefs
- true, // externalEntities
- true, // supportDTD
- true, // baseAware
- true, // stringInterning
- true, // extendedEventTypes
- null,
- null);
- XMLStreamReader reader = p;
- if (xIncludeAware)
- reader = new XIncludeFilter(p, args[0], true, true, true);
- try
+ int pos = 0;
+ while (pos < args.length && args[pos].startsWith("-"))
{
- int event;
- //do
- while (reader.hasNext())
+ if ("-x".equals(args[pos]))
+ xIncludeAware = true;
+ else if ("-v".equals(args[pos]))
+ validating = true;
+ else if ("-n".equals(args[pos]))
+ namespaceAware = true;
+ pos++;
+ }
+ if (pos >= args.length)
+ {
+ System.out.println("Syntax: XMLParser [-n] [-v] [-x] <file> [<file2> [...]]");
+ System.out.println("\t-n: use namespace aware mode");
+ System.out.println("\t-v: use validating parser");
+ System.out.println("\t-x: use XInclude aware mode");
+ System.exit(2);
+ }
+ while (pos < args.length)
+ {
+ XMLParser p = new XMLParser(new java.io.FileInputStream(args[pos]),
+ absolutize(null, args[pos]),
+ validating, // validating
+ namespaceAware, // namespaceAware
+ true, // coalescing,
+ true, // replaceERefs
+ true, // externalEntities
+ true, // supportDTD
+ true, // baseAware
+ true, // stringInterning
+ true, // extendedEventTypes
+ null,
+ null);
+ XMLStreamReader reader = p;
+ if (xIncludeAware)
+ reader = new XIncludeFilter(p, args[pos], true, true, true);
+ try
{
- event = reader.next();
- Location loc = reader.getLocation();
- System.out.print(loc.getLineNumber()+":"+loc.getColumnNumber()+" ");
- switch (event)
+ int event;
+ //do
+ while (reader.hasNext())
{
- case XMLStreamConstants.START_DOCUMENT:
- System.out.println("START_DOCUMENT version="+reader.getVersion()+
- " encoding="+reader.getEncoding());
- break;
- case XMLStreamConstants.END_DOCUMENT:
- System.out.println("END_DOCUMENT");
- break;
- case XMLStreamConstants.START_ELEMENT:
- System.out.println("START_ELEMENT "+reader.getName());
- int l = reader.getNamespaceCount();
- for (int i = 0; i < l; i++)
- System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+
- "='"+reader.getNamespaceURI(i)+"'");
- l = reader.getAttributeCount();
- for (int i = 0; i < l; i++)
- System.out.println("\tattribute "+reader.getAttributeName(i)+
- "='"+reader.getAttributeValue(i)+"'");
- break;
- case XMLStreamConstants.END_ELEMENT:
- System.out.println("END_ELEMENT "+reader.getName());
- break;
- case XMLStreamConstants.CHARACTERS:
- System.out.println("CHARACTERS '"+encodeText(reader.getText())+"'");
- break;
- case XMLStreamConstants.CDATA:
- System.out.println("CDATA '"+encodeText(reader.getText())+"'");
- break;
- case XMLStreamConstants.SPACE:
- System.out.println("SPACE '"+encodeText(reader.getText())+"'");
- break;
- case XMLStreamConstants.DTD:
- System.out.println("DTD "+reader.getText());
- break;
- case XMLStreamConstants.ENTITY_REFERENCE:
- System.out.println("ENTITY_REFERENCE "+reader.getText());
- break;
- case XMLStreamConstants.COMMENT:
- System.out.println("COMMENT '"+encodeText(reader.getText())+"'");
- break;
- case XMLStreamConstants.PROCESSING_INSTRUCTION:
- System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+
- " "+reader.getPIData());
- break;
- case START_ENTITY:
- System.out.println("START_ENTITY "+reader.getText());
- break;
- case END_ENTITY:
- System.out.println("END_ENTITY "+reader.getText());
- break;
- default:
- System.out.println("Unknown event: "+event);
+ event = reader.next();
+ Location loc = reader.getLocation();
+ System.out.print(loc.getLineNumber() + ":" +
+ loc.getColumnNumber() + " ");
+ switch (event)
+ {
+ case XMLStreamConstants.START_DOCUMENT:
+ System.out.println("START_DOCUMENT version=" +
+ reader.getVersion() +
+ " encoding=" +
+ reader.getEncoding());
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ System.out.println("END_DOCUMENT");
+ break;
+ case XMLStreamConstants.START_ELEMENT:
+ System.out.println("START_ELEMENT " +
+ reader.getName());
+ int l = reader.getNamespaceCount();
+ for (int i = 0; i < l; i++)
+ System.out.println("\tnamespace " +
+ reader.getNamespacePrefix(i) + "='" +
+ reader.getNamespaceURI(i)+"'");
+ l = reader.getAttributeCount();
+ for (int i = 0; i < l; i++)
+ System.out.println("\tattribute " +
+ reader.getAttributeName(i) + "='" +
+ reader.getAttributeValue(i) + "'");
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ System.out.println("END_ELEMENT " + reader.getName());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ System.out.println("CHARACTERS '" +
+ encodeText(reader.getText()) + "'");
+ break;
+ case XMLStreamConstants.CDATA:
+ System.out.println("CDATA '" +
+ encodeText(reader.getText()) + "'");
+ break;
+ case XMLStreamConstants.SPACE:
+ System.out.println("SPACE '" +
+ encodeText(reader.getText()) + "'");
+ break;
+ case XMLStreamConstants.DTD:
+ System.out.println("DTD " + reader.getText());
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ System.out.println("ENTITY_REFERENCE " + reader.getText());
+ break;
+ case XMLStreamConstants.COMMENT:
+ System.out.println("COMMENT '" +
+ encodeText(reader.getText()) + "'");
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ System.out.println("PROCESSING_INSTRUCTION " +
+ reader.getPITarget() + " " +
+ reader.getPIData());
+ break;
+ case START_ENTITY:
+ System.out.println("START_ENTITY " + reader.getText());
+ break;
+ case END_ENTITY:
+ System.out.println("END_ENTITY " + reader.getText());
+ break;
+ default:
+ System.out.println("Unknown event: " + event);
+ }
}
}
- }
- catch (XMLStreamException e)
- {
- Location l = reader.getLocation();
- System.out.println("At line "+l.getLineNumber()+
- ", column "+l.getColumnNumber()+
- " of "+l.getSystemId());
- throw e;
+ catch (XMLStreamException e)
+ {
+ Location l = reader.getLocation();
+ System.out.println("At line "+l.getLineNumber()+
+ ", column "+l.getColumnNumber()+
+ " of "+l.getSystemId());
+ throw e;
+ }
+ pos++;
}
}
@@ -5039,7 +5115,6 @@ public class XMLParser
void mark(int len)
throws IOException
{
- //System.out.println(" mark:"+len);
markOffset = offset;
markLine = line;
markColumn = column;
@@ -5082,7 +5157,9 @@ public class XMLParser
{
int ret;
if (unicodeReader != null)
- ret = unicodeReader.read(b, off, len);
+ {
+ ret = unicodeReader.read(b, off, len);
+ }
else
{
byte[] b2 = new byte[len];
diff --git a/libjava/classpath/gnu/xml/transform/ApplyTemplatesNode.java b/libjava/classpath/gnu/xml/transform/ApplyTemplatesNode.java
index 38b605a07ed..041809bdf1a 100644
--- a/libjava/classpath/gnu/xml/transform/ApplyTemplatesNode.java
+++ b/libjava/classpath/gnu/xml/transform/ApplyTemplatesNode.java
@@ -80,7 +80,7 @@ final class ApplyTemplatesNode
List sortKeys2 = new ArrayList(len);
for (int i = 0; i < len; i++)
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
- len = withParams.size();
+ len = withParams != null ? withParams.size() : 0;
List withParams2 = new ArrayList(len);
for (int i = 0; i < len; i++)
withParams2.add(((WithParam) withParams.get(i)).clone(stylesheet));
diff --git a/libjava/classpath/gnu/xml/transform/ForEachNode.java b/libjava/classpath/gnu/xml/transform/ForEachNode.java
index c8f51a6febb..25b824534c9 100644
--- a/libjava/classpath/gnu/xml/transform/ForEachNode.java
+++ b/libjava/classpath/gnu/xml/transform/ForEachNode.java
@@ -67,7 +67,7 @@ final class ForEachNode
TemplateNode clone(Stylesheet stylesheet)
{
- int len = sortKeys.size();
+ int len = sortKeys != null ? sortKeys.size() : 0;
List sortKeys2 = new ArrayList(len);
for (int i = 0; i < len; i++)
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
diff --git a/libjava/classpath/gnu/xml/transform/TransformerImpl.java b/libjava/classpath/gnu/xml/transform/TransformerImpl.java
index 6a0a5be1643..732a911bd8c 100644
--- a/libjava/classpath/gnu/xml/transform/TransformerImpl.java
+++ b/libjava/classpath/gnu/xml/transform/TransformerImpl.java
@@ -238,7 +238,7 @@ class TransformerImpl
outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS);
boolean indent =
"yes".equals(outputProperties.getProperty(OutputKeys.INDENT));
- if (created)
+ if (created && parent instanceof DomDocument)
{
// Discover document element
DomDocument resultDoc = (DomDocument) parent;
@@ -320,7 +320,7 @@ class TransformerImpl
}
if (indent)
{
- if (created)
+ if (created && parent instanceof DomDocument)
{
DomDocument domDoc = (DomDocument) parent;
domDoc.setBuilding(true);
@@ -332,7 +332,7 @@ class TransformerImpl
(Document) parent :
parent.getOwnerDocument();
reindent(resultDoc, parent, 0);
- if (created)
+ if (created && parent instanceof DomDocument)
{
DomDocument domDoc = (DomDocument) parent;
domDoc.setBuilding(false);
@@ -576,6 +576,19 @@ class TransformerImpl
}
catch (IOException e)
{
+ if (errorListener != null)
+ {
+ try
+ {
+ errorListener.error(new TransformerException(e));
+ }
+ catch (TransformerException e2)
+ {
+ e2.printStackTrace(System.err);
+ }
+ }
+ else
+ e.printStackTrace(System.err);
}
}
}
diff --git a/libjava/classpath/include/GtkDragSourceContextPeer.h b/libjava/classpath/include/GtkDragSourceContextPeer.h
new file mode 100644
index 00000000000..4a43d811a1e
--- /dev/null
+++ b/libjava/classpath/include/GtkDragSourceContextPeer.h
@@ -0,0 +1,23 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __GtkDragSourceContextPeer__
+#define __GtkDragSourceContextPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeStartDrag (JNIEnv *env, jobject, jobject, jint, jint, jint, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_connectSignals (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_create (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeSetCursor (JNIEnv *env, jobject, jint) ;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GtkDragSourceContextPeer__ */
diff --git a/libjava/classpath/include/Makefile.am b/libjava/classpath/include/Makefile.am
index c0397566eb3..cc8c963708f 100644
--- a/libjava/classpath/include/Makefile.am
+++ b/libjava/classpath/include/Makefile.am
@@ -38,16 +38,18 @@ $(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformer.h \
$(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformerFactory.h
GTKPEER_H_FILES = \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_CairoSurface.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_ComponentGraphics.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkFontPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkRobotPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkTextLayout.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.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_GtkCheckboxGroupPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkChoicePeer.h \
@@ -73,7 +75,9 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkTextAreaPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkToolkit.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h \
+$(top_srcdir)/include/GtkDragSourceContextPeer.h
QTPEER_H_FILES = \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtCheckboxPeer.h \
@@ -113,14 +117,19 @@ $(top_srcdir)/include/gnu_java_awt_peer_qt_QtFileDialogPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtContainerPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h
+GCONF_PREFS_FILES = \
+$(top_srcdir)/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
+
H_FILES = \
$(SOUND_H_FILES) \
$(XMLJ_H_FILES) \
$(GTKPEER_H_FILES) \
$(QTPEER_H_FILES) \
+$(GCONF_PREFS_FILES) \
$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
+$(top_srcdir)/include/gnu_java_nio_VMChannel.h \
$(top_srcdir)/include/gnu_java_nio_VMPipe.h \
$(top_srcdir)/include/gnu_java_nio_VMSelector.h \
$(top_srcdir)/include/gnu_java_nio_channels_FileChannelImpl.h \
@@ -137,6 +146,7 @@ $(top_srcdir)/include/java_lang_VMSystem.h \
$(top_srcdir)/include/java_lang_reflect_VMArray.h \
$(top_srcdir)/include/java_net_VMInetAddress.h \
$(top_srcdir)/include/java_net_VMNetworkInterface.h \
+$(top_srcdir)/include/java_net_VMURLConnection.h \
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h \
$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h \
$(top_srcdir)/include/java_util_VMTimeZone.h
@@ -166,12 +176,17 @@ $(top_srcdir)/include/gnu_javax_sound_midi_alsa_%.h: $(top_builddir)/$(CLASSDIR)
$(top_srcdir)/include/gnu_javax_sound_midi_dssi_%.h: $(top_builddir)/$(CLASSDIR)/gnu/javax/sound/midi/dssi/%.class
$(JAVAH) -o $@ gnu.javax.sound.midi.dssi.$*
+$(top_srcdir)/include/gnu_java_util_prefs_gconf_%.h: $(top_builddir)/$(CLASSDIR)/gnu/java/util/prefs/gconf/%.class
+ $(JAVAH) -o $@ gnu.java.util.prefs.gconf.$*
+
$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
$(JAVAH) -o $@ gnu.java.net.VMPlainDatagramSocketImpl
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainSocketImpl.java
$(JAVAH) -o $@ gnu.java.net.VMPlainSocketImpl
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h: $(top_srcdir)/gnu/java/net/local/LocalSocketImpl.java
$(JAVAH) -o $@ gnu.java.net.local.LocalSocketImpl
+$(top_srcdir)/include/gnu_java_nio_VMChannel.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMChannel.java
+ $(JAVAH) -o $@ gnu.java.nio.VMChannel
$(top_srcdir)/include/gnu_java_nio_VMPipe.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMPipe.java
$(JAVAH) -o $@ gnu.java.nio.VMPipe
$(top_srcdir)/include/gnu_java_nio_VMSelector.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMSelector.java
@@ -198,6 +213,8 @@ $(top_srcdir)/include/java_net_VMInetAddress.h: $(top_srcdir)/vm/reference/java/
$(JAVAH) -o $@ java.net.VMInetAddress
$(top_srcdir)/include/java_net_VMNetworkInterface.h: $(top_srcdir)/vm/reference/java/net/VMNetworkInterface.java
$(JAVAH) -o $@ java.net.VMNetworkInterface
+$(top_srcdir)/include/java_net_VMURLConnection.h: $(top_srcdir)/vm/reference/java/net/VMURLConnection.java
+ $(JAVAH) -o $@ java.net.VMURLConnection
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h: $(top_srcdir)/vm/reference/java/nio/VMDirectByteBuffer.java
$(JAVAH) -o $@ java.nio.VMDirectByteBuffer
$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h: $(top_srcdir)/java/nio/MappedByteBufferImpl.java
diff --git a/libjava/classpath/include/Makefile.in b/libjava/classpath/include/Makefile.in
index 2d172d75019..47889b71d03 100644
--- a/libjava/classpath/include/Makefile.in
+++ b/libjava/classpath/include/Makefile.in
@@ -85,6 +85,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -105,6 +107,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -135,6 +138,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -185,6 +192,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -205,6 +213,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -304,16 +314,18 @@ $(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformer.h \
$(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformerFactory.h
GTKPEER_H_FILES = \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_CairoSurface.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_ComponentGraphics.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkFontPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkRobotPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkTextLayout.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.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_GtkCheckboxGroupPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkChoicePeer.h \
@@ -339,7 +351,9 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkTextAreaPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkToolkit.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h \
+$(top_srcdir)/include/GtkDragSourceContextPeer.h
QTPEER_H_FILES = \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtCheckboxPeer.h \
@@ -379,14 +393,19 @@ $(top_srcdir)/include/gnu_java_awt_peer_qt_QtFileDialogPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtContainerPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h
+GCONF_PREFS_FILES = \
+$(top_srcdir)/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
+
H_FILES = \
$(SOUND_H_FILES) \
$(XMLJ_H_FILES) \
$(GTKPEER_H_FILES) \
$(QTPEER_H_FILES) \
+$(GCONF_PREFS_FILES) \
$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
+$(top_srcdir)/include/gnu_java_nio_VMChannel.h \
$(top_srcdir)/include/gnu_java_nio_VMPipe.h \
$(top_srcdir)/include/gnu_java_nio_VMSelector.h \
$(top_srcdir)/include/gnu_java_nio_channels_FileChannelImpl.h \
@@ -403,6 +422,7 @@ $(top_srcdir)/include/java_lang_VMSystem.h \
$(top_srcdir)/include/java_lang_reflect_VMArray.h \
$(top_srcdir)/include/java_net_VMInetAddress.h \
$(top_srcdir)/include/java_net_VMNetworkInterface.h \
+$(top_srcdir)/include/java_net_VMURLConnection.h \
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h \
$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h \
$(top_srcdir)/include/java_util_VMTimeZone.h
@@ -612,12 +632,17 @@ uninstall-am: uninstall-info-am
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_javax_sound_midi_dssi_%.h: $(top_builddir)/$(CLASSDIR)/gnu/javax/sound/midi/dssi/%.class
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.javax.sound.midi.dssi.$*
+@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_util_prefs_gconf_%.h: $(top_builddir)/$(CLASSDIR)/gnu/java/util/prefs/gconf/%.class
+@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.util.prefs.gconf.$*
+
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.net.VMPlainDatagramSocketImpl
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainSocketImpl.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.net.VMPlainSocketImpl
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h: $(top_srcdir)/gnu/java/net/local/LocalSocketImpl.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.net.local.LocalSocketImpl
+@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_nio_VMChannel.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMChannel.java
+@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.nio.VMChannel
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_nio_VMPipe.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMPipe.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ gnu.java.nio.VMPipe
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/gnu_java_nio_VMSelector.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMSelector.java
@@ -644,6 +669,8 @@ uninstall-am: uninstall-info-am
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ java.net.VMInetAddress
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/java_net_VMNetworkInterface.h: $(top_srcdir)/vm/reference/java/net/VMNetworkInterface.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ java.net.VMNetworkInterface
+@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/java_net_VMURLConnection.h: $(top_srcdir)/vm/reference/java/net/VMURLConnection.java
+@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ java.net.VMURLConnection
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h: $(top_srcdir)/vm/reference/java/nio/VMDirectByteBuffer.java
@CREATE_JNI_HEADERS_TRUE@ $(JAVAH) -o $@ java.nio.VMDirectByteBuffer
@CREATE_JNI_HEADERS_TRUE@$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h: $(top_srcdir)/java/nio/MappedByteBufferImpl.java
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
index 363d6c0ba07..a54c7117ed9 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+++ b/libjava/classpath/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);
@@ -37,6 +41,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClip (JNI
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoPreserveClip (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoResetClip (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jlong, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawLine (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFillRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
#ifdef __cplusplus
}
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
index 4fd597effe6..fbd5f6a93b2 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
@@ -16,8 +16,9 @@ JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVol
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing (JNIEnv *env, jobject);
JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender (JNIEnv *env, jclass);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_nativeGrab (JNIEnv *env, jclass, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env, jobject, jobject, jlong, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env, jobject, jobject, jlong, jint, jint, jint, jint, jint, jint, jint, jint);
#ifdef __cplusplus
}
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
index 2a619c60951..6177a6fb939 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
+++ b/libjava/classpath/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/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
deleted file mode 100644
index fae4d775b2e..00000000000
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_awt_peer_gtk_GdkTextLayout__
-#define __gnu_java_awt_peer_gtk_GdkTextLayout__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText (JNIEnv *env, jobject, jstring);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_setFont (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_getExtents (JNIEnv *env, jobject, jdoubleArray, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos (JNIEnv *env, jobject, jint, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout (JNIEnv *env, jobject, jlong, jfloat, jfloat);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState (JNIEnv *env, jclass);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline (JNIEnv *env, jobject, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_awt_peer_gtk_GdkTextLayout__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h
deleted file mode 100644
index 2fa36868847..00000000000
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer__
-#define __gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_dispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove (JNIEnv *env, jobject, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h
index 88a45f07cf3..b54412be6eb 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCheckboxPeer.h
@@ -10,8 +10,11 @@ extern "C"
{
#endif
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createCheckButton (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createRadioButton (JNIEnv *env, jobject, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_addToGroup (JNIEnv *env, jobject, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_removeFromGroup (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_switchToGroup (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont (JNIEnv *env, jobject, jstring, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel (JNIEnv *env, jobject, jstring);
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
index f2014595fe8..f2b9ffe773e 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
@@ -26,6 +26,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetS
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent (JNIEnv *env, jobject, jint, jlong, jint, jint, jint);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetHasFocus (JNIEnv *env, jobject);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetCanFocus (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_realize (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (JNIEnv *env, jobject);
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
index 485509075d8..3a0d35c7374 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h
@@ -13,7 +13,7 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create (JNIEnv *env, jobject, jstring, jfloat);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont (JNIEnv *env, jobject, jstring, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_nativeSetAlignment (JNIEnv *env, jobject, jfloat);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeText (JNIEnv *env, jobject, jstring);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetGetPreferredDimensions (JNIEnv *env, jobject, jintArray);
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h
index ffeb3993575..6cdcc622aab 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h
+++ b/libjava/classpath/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/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
index ad447f16a3a..c9a629a8241 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
@@ -13,6 +13,8 @@ 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 jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowHasFocus (JNIEnv *env, jobject);
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/libjava/classpath/include/gnu_java_net_local_LocalSocketImpl.h b/libjava/classpath/include/gnu_java_net_local_LocalSocketImpl.h
index 3309053f133..b1f1fcd84cb 100644
--- a/libjava/classpath/include/gnu_java_net_local_LocalSocketImpl.h
+++ b/libjava/classpath/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/libjava/classpath/include/gnu_java_nio_VMChannel.h b/libjava/classpath/include/gnu_java_nio_VMChannel.h
new file mode 100644
index 00000000000..28f9048d254
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_nio_VMChannel.h
@@ -0,0 +1,24 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_nio_VMChannel__
+#define __gnu_java_nio_VMChannel__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env, jobject, jint, jboolean);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read (JNIEnv *env, jobject, jint, jobject);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env, jobject, jint, jobjectArray, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_write (JNIEnv *env, jobject, jint, jobject);
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env, jobject, jint, jobjectArray, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_nio_VMChannel__ */
diff --git a/libjava/classpath/include/gnu_java_util_prefs_gconf_GConfNativePeer.h b/libjava/classpath/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
new file mode 100644
index 00000000000..ec902cbb8df
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
@@ -0,0 +1,30 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_util_prefs_gconf_GConfNativePeer__
+#define __gnu_java_util_prefs_gconf_GConfNativePeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class (JNIEnv *env, jclass);
+JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists (JNIEnv *env, jclass, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir (JNIEnv *env, jclass, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir (JNIEnv *env, jclass, jstring);
+JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string (JNIEnv *env, jclass, jstring, jstring);
+JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string (JNIEnv *env, jclass, jstring);
+JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset (JNIEnv *env, jclass, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync (JNIEnv *env, jclass);
+JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes (JNIEnv *env, jclass, jstring);
+JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys (JNIEnv *env, jclass, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_util_prefs_gconf_GConfNativePeer__ */
diff --git a/libjava/classpath/include/java_io_VMFile.h b/libjava/classpath/include/java_io_VMFile.h
index 0ab188fb023..fa1079f121e 100644
--- a/libjava/classpath/include/java_io_VMFile.h
+++ b/libjava/classpath/include/java_io_VMFile.h
@@ -24,6 +24,7 @@ JNIEXPORT jboolean JNICALL Java_java_io_VMFile_isFile (JNIEnv *env, jclass, jstr
JNIEXPORT jboolean JNICALL Java_java_io_VMFile_canWrite (JNIEnv *env, jclass, jstring);
JNIEXPORT jboolean JNICALL Java_java_io_VMFile_canRead (JNIEnv *env, jclass, jstring);
JNIEXPORT jboolean JNICALL Java_java_io_VMFile_isDirectory (JNIEnv *env, jclass, jstring);
+JNIEXPORT jstring JNICALL Java_java_io_VMFile_toCanonicalForm (JNIEnv *env, jclass, jstring);
#undef java_io_VMFile_IS_CASE_SENSITIVE
#define java_io_VMFile_IS_CASE_SENSITIVE 1L
#undef java_io_VMFile_IS_DOS_8_3
diff --git a/libjava/classpath/include/java_lang_VMSystem.h b/libjava/classpath/include/java_lang_VMSystem.h
index 11b89ba27c4..1bc55cf9d5a 100644
--- a/libjava/classpath/include/java_lang_VMSystem.h
+++ b/libjava/classpath/include/java_lang_VMSystem.h
@@ -15,7 +15,7 @@ JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode (JNIEnv *env, jc
JNIEXPORT void JNICALL Java_java_lang_VMSystem_setIn (JNIEnv *env, jclass, jobject);
JNIEXPORT void JNICALL Java_java_lang_VMSystem_setOut (JNIEnv *env, jclass, jobject);
JNIEXPORT void JNICALL Java_java_lang_VMSystem_setErr (JNIEnv *env, jclass, jobject);
-JNIEXPORT jlong JNICALL Java_java_lang_VMSystem_currentTimeMillis (JNIEnv *env, jclass);
+JNIEXPORT jlong JNICALL Java_java_lang_VMSystem_nanoTime (JNIEnv *env, jclass);
JNIEXPORT jobject JNICALL Java_java_lang_VMSystem_environ (JNIEnv *env, jclass);
JNIEXPORT jstring JNICALL Java_java_lang_VMSystem_getenv (JNIEnv *env, jclass, jstring);
diff --git a/libjava/classpath/include/java_net_VMURLConnection.h b/libjava/classpath/include/java_net_VMURLConnection.h
new file mode 100644
index 00000000000..270a14a75f6
--- /dev/null
+++ b/libjava/classpath/include/java_net_VMURLConnection.h
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __java_net_VMURLConnection__
+#define __java_net_VMURLConnection__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_java_net_VMURLConnection_init (JNIEnv *env, jclass);
+JNIEXPORT jstring JNICALL Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env, jclass, jbyteArray, jint);
+#undef java_net_VMURLConnection_LENGTH
+#define java_net_VMURLConnection_LENGTH 1024L
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __java_net_VMURLConnection__ */
diff --git a/libjava/classpath/include/jni.h b/libjava/classpath/include/jni.h
index 8ebf3f7f7e9..3a0d9c31ec3 100644
--- a/libjava/classpath/include/jni.h
+++ b/libjava/classpath/include/jni.h
@@ -1,5 +1,5 @@
/* jni.h
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -1584,6 +1584,45 @@ typedef struct JavaVMInitArgs
jboolean ignoreUnrecognized;
} JavaVMInitArgs;
+typedef struct JDK1_1InitArgs
+{
+ /* VM version. Should be JNI_VERSION_1_1. Note that before JDK
+ 1.1.2, this field was named 'reserved0'. (I don't know what the
+ current 'reserved0' field was named then.) */
+ jint version;
+
+ /* A null-terminated array of environment strings, each of the form
+ "KEY=VALUE". This is used to set system properties. Note that
+ before JDK 1.1.2, this field was named 'reserved1'. */
+ char **properties;
+
+ jint checkSource;
+ jint nativeStackSize;
+ jint javaStackSize;
+ jint minHeapSize;
+ jint maxHeapSize;
+ jint verifyMode;
+ const char *classpath;
+
+ jint (JNICALL *vfprintf) (FILE *file, const char *fmt, va_list args);
+ void (JNICALL *exit) (jint value);
+ void (JNICALL *abort) (void);
+
+ jint enableClassGC;
+ jint enableVerboseGC;
+ jint disableAsyncGC;
+
+ jint reserved0;
+ jint reserved1;
+ jint reserved2;
+} JDK1_1InitArgs;
+
+typedef struct JDK1_1AttachArgs
+{
+ /* Dummy field since C cannot have empty structs. The name and type
+ are chosen to comply with the spec. */
+ void *__padding;
+} JDK1_1AttachArgs;
/* Keep c-font-lock-extra-types in alphabetical order. */
diff --git a/libjava/classpath/java/awt/AWTEvent.java b/libjava/classpath/java/awt/AWTEvent.java
index d10433cb3c3..a6151b424c1 100644
--- a/libjava/classpath/java/awt/AWTEvent.java
+++ b/libjava/classpath/java/awt/AWTEvent.java
@@ -103,6 +103,11 @@ public abstract class AWTEvent extends EventObject
*/
byte[] bdata;
+ /**
+ * Indicates if this event is dispatched by the KeyboardFocusManager.
+ */
+ boolean isFocusManagerEvent = false;
+
/** Mask for selecting component events. */
public static final long COMPONENT_EVENT_MASK = 0x00001;
diff --git a/libjava/classpath/java/awt/BasicStroke.java b/libjava/classpath/java/awt/BasicStroke.java
index 3e259216fa7..160a3eb0f74 100644
--- a/libjava/classpath/java/awt/BasicStroke.java
+++ b/libjava/classpath/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;
@@ -118,6 +117,7 @@ public class BasicStroke implements Stroke
/** The dash phase. */
private final float phase;
+ // The inner and outer paths of the stroke
private Segment start, end;
/**
@@ -260,7 +260,7 @@ public class BasicStroke implements Stroke
*/
public Shape createStrokedShape(Shape s)
{
- PathIterator pi = s.getPathIterator( new AffineTransform() );
+ PathIterator pi = s.getPathIterator(null);
if( dash == null )
return solidStroke( pi );
@@ -435,8 +435,8 @@ public class BasicStroke implements Stroke
else
addSegments(p);
- x = coords[0];
- y = coords[1];
+ x = coords[2];
+ y = coords[3];
break;
case PathIterator.SEG_CUBICTO:
@@ -452,17 +452,25 @@ public class BasicStroke implements Stroke
else
addSegments(p);
- x = coords[0];
- y = coords[1];
+ x = coords[4];
+ y = coords[5];
break;
case PathIterator.SEG_CLOSE:
- p = (new LineSegment(x, y, x0, y0)).getDisplacedSegments(width/2.0);
- addSegments(p);
+ if (x == x0 && y == y0)
+ {
+ joinSegments(new Segment[] { start.first, end.first });
+ }
+ else
+ {
+ p = (new LineSegment(x, y, x0, y0)).getDisplacedSegments(width / 2.0);
+ addSegments(p);
+ }
convertPath(output, start);
convertPath(output, end);
start = end = null;
pathOpen = false;
+ output.setWindingRule(GeneralPath.WIND_EVEN_ODD);
break;
}
pi.next();
@@ -499,7 +507,7 @@ public class BasicStroke implements Stroke
}
/**
- * Convert and add the linked list of Segments in s to a GeneralPath p.
+ * Append the Segments in s to the GeneralPath p
*/
private void convertPath(GeneralPath p, Segment s)
{
@@ -527,18 +535,28 @@ public class BasicStroke implements Stroke
p.closePath();
}
-
+
/**
- * Add to segments to start and end, joining the outer pair and
+ * Add the segments to start and end (the inner and outer edges of the stroke)
*/
private void addSegments(Segment[] segments)
{
- double[] p0 = start.last.last();
+ joinSegments(segments);
+ start.add(segments[0]);
+ end.add(segments[1]);
+ }
+
+ private void joinSegments(Segment[] segments)
+ {
+ double[] p0 = start.last.cp2();
double[] p1 = new double[]{start.last.P2.getX(), start.last.P2.getY()};
- double[] p2 = new double[]{segments[0].P1.getX(), segments[0].P1.getY()};
- double[] p3 = segments[0].first();
+ double[] p2 = new double[]{segments[0].first.P1.getX(), segments[0].first.P1.getY()};
+ double[] p3 = segments[0].cp1();
Point2D p;
+ p = lineIntersection(p0[0],p0[1],p1[0],p1[1],
+ p2[0],p2[1],p3[0],p3[1], false);
+
double det = (p1[0] - p0[0])*(p3[1] - p2[1]) -
(p3[0] - p2[0])*(p1[1] - p0[1]);
@@ -546,42 +564,14 @@ public class BasicStroke implements Stroke
{
// start and segment[0] form the 'inner' part of a join,
// connect the overlapping segments
- p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], false);
- if( p == null )
- {
- // Dodgy.
- start.add(new LineSegment(start.last.P2, segments[0].P1));
- p = new Point2D.Double((segments[0].P1.getX()+ start.last.P2.getX())/2.0,
- (segments[0].P1.getY()+ start.last.P2.getY())/2.0);
- }
- else
- segments[0].P1 = start.last.P2 = p;
-
- start.add( segments[0] );
- joinSegments(end, segments[1], p);
+ joinInnerSegments(start, segments[0], p);
+ joinOuterSegments(end, segments[1], p);
}
else
{
// end and segment[1] form the 'inner' part
- p0 = end.last.last();
- p1 = new double[]{end.last.P2.getX(), end.last.P2.getY()};
- p2 = new double[]{segments[1].P1.getX(), segments[1].P1.getY()};
- p3 = segments[1].first();
-
- p = lineIntersection(p0[0],p0[1],p1[0],p1[1],
- p2[0],p2[1],p3[0],p3[1], false);
- if( p == null )
- {
- // Dodgy.
- end.add(new LineSegment(end.last.P2, segments[1].P1));
- p = new Point2D.Double((segments[1].P1.getX()+ end.last.P2.getX())/2.0,
- (segments[1].P1.getY()+ end.last.P2.getY())/2.0);
- }
- else
- segments[1].P1 = end.last.P2 = p;
-
- end.add( segments[1] );
- joinSegments(start, segments[0], p);
+ joinInnerSegments(end, segments[1], p);
+ joinOuterSegments(start, segments[0], p);
}
}
@@ -602,7 +592,7 @@ public class BasicStroke implements Stroke
break;
case CAP_SQUARE:
- p0 = a.last.last();
+ p0 = a.last.cp2();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
dx = p1[0] - p0[0];
dy = p1[1] - p0[1];
@@ -617,7 +607,7 @@ public class BasicStroke implements Stroke
break;
case CAP_ROUND:
- p0 = a.last.last();
+ p0 = a.last.cp2();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
dx = p1[0] - p0[0];
dy = p1[1] - p0[1];
@@ -676,7 +666,7 @@ public class BasicStroke implements Stroke
* insideP is the inside intersection point of the join, needed for
* calculating miter lengths.
*/
- private void joinSegments(Segment a, Segment b, Point2D insideP)
+ private void joinOuterSegments(Segment a, Segment b, Point2D insideP)
{
double[] p0, p1;
double dx, dy, l;
@@ -685,10 +675,10 @@ public class BasicStroke implements Stroke
switch( join )
{
case JOIN_MITER:
- p0 = a.last.last();
+ p0 = a.last.cp2();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
double[] p2 = new double[]{b.P1.getX(), b.P1.getY()};
- double[] p3 = b.first();
+ double[] p3 = b.cp1();
Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true);
if( p == null || insideP == null )
a.add(new LineSegment(a.last.P2, b.P1));
@@ -705,7 +695,7 @@ public class BasicStroke implements Stroke
break;
case JOIN_ROUND:
- p0 = a.last.last();
+ p0 = a.last.cp2();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
dx = p1[0] - p0[0];
dy = p1[1] - p0[1];
@@ -715,7 +705,7 @@ public class BasicStroke implements Stroke
c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
p0 = new double[]{b.P1.getX(), b.P1.getY()};
- p1 = b.first();
+ p1 = b.cp1();
dx = p0[0] - p1[0]; // backwards direction.
dy = p0[1] - p1[1];
@@ -730,6 +720,29 @@ public class BasicStroke implements Stroke
a.add(new LineSegment(a.last.P2, b.P1));
break;
}
- a.add(b);
}
-}
+
+ /**
+ * Join a and b segments, removing any overlap
+ */
+ private void joinInnerSegments(Segment a, Segment b, Point2D p)
+ {
+ double[] p0 = a.last.cp2();
+ double[] p1 = new double[] { a.last.P2.getX(), a.last.P2.getY() };
+ double[] p2 = new double[] { b.P1.getX(), b.P1.getY() };
+ double[] p3 = b.cp1();
+
+ if (p == null)
+ {
+ // Dodgy.
+ a.add(new LineSegment(a.last.P2, b.P1));
+ p = new Point2D.Double((b.P1.getX() + a.last.P2.getX()) / 2.0,
+ (b.P1.getY() + a.last.P2.getY()) / 2.0);
+ }
+ else
+ // This assumes segments a and b are single segments, which is
+ // incorrect - if they are a linked list of segments (ie, passed in
+ // from a flattening operation), this produces strange results!!
+ a.last.P2 = b.P1 = p;
+ }
+}
diff --git a/libjava/classpath/java/awt/Canvas.java b/libjava/classpath/java/awt/Canvas.java
index b599582ba93..843fded44db 100644
--- a/libjava/classpath/java/awt/Canvas.java
+++ b/libjava/classpath/java/awt/Canvas.java
@@ -68,6 +68,11 @@ public class Canvas
* Compatible with Sun's JDK.
*/
private static final long serialVersionUID = -2284879212465893870L;
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_canvas_number;
/**
* The graphics configuration associated with the canvas.
@@ -343,4 +348,19 @@ public class Canvas
/* Call the paint method */
paint(graphics);
}
+
+ /**
+ * Generate a unique name for this <code>Canvas</code>.
+ *
+ * @return A unique name for this <code>Canvas</code>.
+ */
+ String generateName()
+ {
+ return "canvas" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_canvas_number++;
+ }
}
diff --git a/libjava/classpath/java/awt/CardLayout.java b/libjava/classpath/java/awt/CardLayout.java
index 8b3fea2ca23..fcb05215af9 100644
--- a/libjava/classpath/java/awt/CardLayout.java
+++ b/libjava/classpath/java/awt/CardLayout.java
@@ -350,6 +350,7 @@ public class CardLayout implements LayoutManager2, Serializable
}
}
((Component) target).setVisible (true);
+ parent.validate();
}
}
diff --git a/libjava/classpath/java/awt/CheckboxMenuItem.java b/libjava/classpath/java/awt/CheckboxMenuItem.java
index 197065f6535..2df621b71b7 100644
--- a/libjava/classpath/java/awt/CheckboxMenuItem.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Choice.java b/libjava/classpath/java/awt/Choice.java
index 90a8d3141c8..f1da94bbeb8 100644
--- a/libjava/classpath/java/awt/Choice.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Component.java b/libjava/classpath/java/awt/Component.java
index 3d3dcc319cc..44f277ac783 100644
--- a/libjava/classpath/java/awt/Component.java
+++ b/libjava/classpath/java/awt/Component.java
@@ -70,6 +70,7 @@ import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
@@ -213,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.
/**
@@ -427,6 +434,24 @@ public abstract class Component
Dimension minSize;
/**
+ * Flag indicating whether the minimum size for the component has been set
+ * by a call to {@link #setMinimumSize(Dimension)} with a non-null value.
+ */
+ boolean minSizeSet;
+
+ /**
+ * The maximum size for the component.
+ * @see #setMaximumSize(Dimension)
+ */
+ Dimension maxSize;
+
+ /**
+ * A flag indicating whether the maximum size for the component has been set
+ * by a call to {@link #setMaximumSize(Dimension)} with a non-null value.
+ */
+ boolean maxSizeSet;
+
+ /**
* Cached information on the preferred size. Should have been transient.
*
* @serial ignore
@@ -434,6 +459,12 @@ public abstract class Component
Dimension prefSize;
/**
+ * Flag indicating whether the preferred size for the component has been set
+ * by a call to {@link #setPreferredSize(Dimension)} with a non-null value.
+ */
+ boolean prefSizeSet;
+
+ /**
* Set to true if an event is to be handled by this component, false if
* it is to be passed up the hierarcy.
*
@@ -563,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.
*/
@@ -607,16 +649,19 @@ public abstract class Component
}
/**
- * Sets the name of this component to the specified name.
+ * Sets the name of this component to the specified name (this is a bound
+ * property with the name 'name').
*
- * @param name the new name of this component
+ * @param name the new name (<code>null</code> permitted).
* @see #getName()
* @since 1.1
*/
public void setName(String name)
{
nameExplicitlySet = true;
+ String old = this.name;
this.name = name;
+ firePropertyChange("name", old, name);
}
/**
@@ -718,7 +763,9 @@ public abstract class Component
*/
public boolean isValid()
{
- return valid;
+ // Tests show that components are invalid as long as they are not showing, even after validate()
+ // has been called on them.
+ return peer != null && valid;
}
/**
@@ -804,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();
+ }
+ }
}
/**
@@ -831,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();
+ }
+ }
}
/**
@@ -898,16 +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.
@@ -915,9 +1000,6 @@ public abstract class Component
if (currentParent != null)
currentParent.invalidate();
- ComponentEvent ce =
- new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
@@ -945,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);
}
}
@@ -1088,16 +1188,13 @@ public abstract class Component
*/
public void setFont(Font newFont)
{
- if((newFont != null && (font == null || !font.equals(newFont)))
- || newFont == null)
- {
- Font oldFont = font;
- font = newFont;
- if (peer != null)
- peer.setFont(font);
- firePropertyChange("font", oldFont, newFont);
- invalidate();
- }
+ Font oldFont = font;
+ font = newFont;
+ if (peer != null)
+ peer.setFont(font);
+ firePropertyChange("font", oldFont, newFont);
+ if (valid)
+ invalidate();
}
/**
@@ -1189,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();
+ }
}
/**
@@ -1384,53 +1488,98 @@ 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;
+ boolean resized = oldwidth != width || oldheight != height;
+ boolean moved = oldx != x || oldy != y;
- invalidate();
-
- 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)
+ if (resized || moved)
{
- 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);
+ // Update the fields.
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+
+ if (peer != null)
+ {
+ peer.setBounds (x, y, width, height);
+ if (resized)
+ invalidate();
+ if (parent != null && parent.valid)
+ parent.invalidate();
+ }
+
+ // Send some events to interested listeners.
+ notifyReshape(resized, moved);
+
+ // Repaint this component and the parent if appropriate.
+ if (parent != null && peer instanceof LightweightPeer
+ && isShowing())
+ {
+ // The parent repaints the area that we occupied before.
+ parent.repaint(oldx, oldy, oldwidth, oldheight);
+ // This component repaints the area that we occupy now.
+ repaint();
+ }
}
}
+ }
- // Only post event if this component is visible and has changed size.
- if (isShowing ()
- && (oldx != x || oldy != y))
+ private void notifyReshape(boolean resized, boolean moved)
+ {
+ // 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_MOVED);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ // Fire component event on this component.
+ if (moved)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_MOVED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ if (resized)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_RESIZED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
}
- if (isShowing ()
- && (oldwidth != width || oldheight != height))
+ else
{
- ComponentEvent ce = new ComponentEvent(this,
- ComponentEvent.COMPONENT_RESIZED);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ // 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);
+ }
+ }
+ }
}
}
@@ -1584,6 +1733,7 @@ public abstract class Component
*
* @return the component's preferred size
* @see #getMinimumSize()
+ * @see #setPreferredSize(Dimension)
* @see LayoutManager
*/
public Dimension getPreferredSize()
@@ -1592,6 +1742,40 @@ public abstract class Component
}
/**
+ * Sets the preferred size that will be returned by
+ * {@link #getPreferredSize()} always, and sends a
+ * {@link PropertyChangeEvent} (with the property name 'preferredSize') to
+ * all registered listeners.
+ *
+ * @param size the preferred size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getPreferredSize()
+ */
+ public void setPreferredSize(Dimension size)
+ {
+ Dimension old = prefSizeSet ? prefSize : null;
+ prefSize = size;
+ prefSizeSet = (size != null);
+ firePropertyChange("preferredSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current preferred size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setPreferredSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isPreferredSizeSet()
+ {
+ return prefSizeSet;
+ }
+
+ /**
* Returns the component's preferred size.
*
* @return the component's preferred size
@@ -1599,14 +1783,36 @@ public abstract class Component
*/
public Dimension preferredSize()
{
- if (prefSize == null)
+ // 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;
}
/**
@@ -1614,6 +1820,7 @@ public abstract class Component
*
* @return the component's minimum size
* @see #getPreferredSize()
+ * @see #setMinimumSize(Dimension)
* @see LayoutManager
*/
public Dimension getMinimumSize()
@@ -1622,6 +1829,39 @@ public abstract class Component
}
/**
+ * Sets the minimum size that will be returned by {@link #getMinimumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'minimumSize') to all registered listeners.
+ *
+ * @param size the minimum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMinimumSize()
+ */
+ public void setMinimumSize(Dimension size)
+ {
+ Dimension old = minSizeSet ? minSize : null;
+ minSize = size;
+ minSizeSet = (size != null);
+ firePropertyChange("minimumSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current minimum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMinimumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMinimumSizeSet()
+ {
+ return minSizeSet;
+ }
+
+ /**
* Returns the component's minimum size.
*
* @return the component's minimum size
@@ -1629,10 +1869,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;
}
/**
@@ -1640,15 +1906,66 @@ public abstract class Component
*
* @return the component's maximum size
* @see #getMinimumSize()
+ * @see #setMaximumSize(Dimension)
* @see #getPreferredSize()
* @see LayoutManager
*/
public Dimension getMaximumSize()
{
- return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+ 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)
+ size = maxSize;
+ else
+ size = DEFAULT_MAX_SIZE;
+ return size;
+ }
+
+ /**
+ * Sets the maximum size that will be returned by {@link #getMaximumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'maximumSize') to all registered listeners.
+ *
+ * @param size the maximum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMaximumSize()
+ */
+ public void setMaximumSize(Dimension size)
+ {
+ Dimension old = maxSizeSet ? maxSize : null;
+ maxSize = size;
+ maxSizeSet = (size != null);
+ firePropertyChange("maximumSize", old, size);
}
/**
+ * Returns <code>true</code> if the current maximum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMaximumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMaximumSizeSet()
+ {
+ return maxSizeSet;
+ }
+
+ /**
* Returns the preferred horizontal alignment of this component. The value
* returned will be between {@link #LEFT_ALIGNMENT} and
* {@link #RIGHT_ALIGNMENT}, inclusive.
@@ -1716,11 +2033,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();
+ }
}
/**
@@ -1826,11 +2157,9 @@ public abstract class Component
}
/**
- * Updates this component. This is called in response to
- * <code>repaint</code>. This method fills the component with the
- * background color, then sets the foreground color of the specified
- * graphics context to the foreground color of this component and calls
- * the <code>paint()</code> method. The coordinates of the graphics are
+ * Updates this component. This is called for heavyweight components in
+ * response to {@link #repaint()}. The default implementation simply forwards
+ * to {@link #paint(Graphics)}. The coordinates of the graphics are
* relative to this component. Subclasses should call either
* <code>super.update(g)</code> or <code>paint(g)</code>.
*
@@ -1838,27 +2167,17 @@ public abstract class Component
*
* @see #paint(Graphics)
* @see #repaint()
- *
- * @specnote In contrast to what the spec says, tests show that the exact
- * behaviour is to clear the background on lightweight and
- * top-level components only. Heavyweight components are not
- * affected by this method and only call paint().
*/
public void update(Graphics g)
{
- // Tests show that the clearing of the background is only done in
- // two cases:
- // - If the component is lightweight (yes this is in contrast to the spec).
- // or
- // - If the component is a toplevel container.
- if (isLightweight() || getParent() == null)
- {
- Rectangle clip = g.getClipBounds();
- if (clip == null)
- g.clearRect(0, 0, width, height);
- else
- g.clearRect(clip.x, clip.y, clip.width, clip.height);
- }
+ // Note 1: We used to clear the background here for lightweights and
+ // toplevel components. Tests show that this is not what the JDK does
+ // here. Note that there is some special handling and background
+ // clearing code in Container.update(Graphics).
+
+ // Note 2 (for peer implementors): The JDK doesn't seem call update() for
+ // toplevel components, even when an UPDATE event is sent (as a result
+ // of repaint).
paint(g);
}
@@ -1934,11 +2253,46 @@ public abstract class Component
*/
public void repaint(long tm, int x, int y, int width, int height)
{
- if (isShowing())
+ // The repaint() call has previously been delegated to
+ // {@link ComponentPeer.repaint()}. Testing on the JDK using some
+ // dummy peers show that this methods is never called. I think it makes
+ // sense to actually perform the tasks below here, since it's pretty
+ // much peer independent anyway, and makes sure only heavyweights are
+ // bothered by this.
+ ComponentPeer p = peer;
+
+ // Let the nearest heavyweight parent handle repainting for lightweight
+ // components.
+ // This goes up the hierarchy until we hit
+ // a heavyweight component that handles this and translates the
+ // rectangle while doing so.
+
+ // We perform some boundary checking to restrict the paint
+ // region to this component.
+ int px = (x < 0 ? 0 : x);
+ int py = (y < 0 ? 0 : y);
+ int pw = width;
+ int ph = height;
+ Component par = this;
+ while (par != null && p instanceof LightweightPeer)
+ {
+ px += par.x;
+ py += par.y;
+ // We perform some boundary checking to restrict the paint
+ // region to this component.
+ pw = Math.min(pw, par.width);
+ ph = Math.min(ph, par.height);
+ par = par.parent;
+ p = par.peer;
+ }
+
+ // Now send an UPDATE event to the heavyweight component that we've found.
+ if (par != null && par.isVisible() && p != null && pw > 0 && ph > 0)
{
- ComponentPeer p = peer;
- if (p != null)
- p.repaint(tm, x, y, width, height);
+ assert ! (p instanceof LightweightPeer);
+ PaintEvent pe = new PaintEvent(par, PaintEvent.UPDATE,
+ new Rectangle(px, py, pw, ph));
+ getToolkit().getSystemEventQueue().postEvent(pe);
}
}
@@ -1957,10 +2311,7 @@ public abstract class Component
}
/**
- * Prints this component, including all sub-components. This method is
- * provided so that printing can be done in a different manner from
- * painting. However, the implementation in this class simply calls the
- * <code>paintAll()</code> method.
+ * Prints this component, including all sub-components.
*
* @param g the graphics context of the print device
*
@@ -1968,7 +2319,9 @@ public abstract class Component
*/
public void printAll(Graphics g)
{
- paintAll(g);
+ if( peer != null )
+ peer.print( g );
+ paintAll( g );
}
/**
@@ -2318,6 +2671,17 @@ public abstract class Component
}
/**
+ * By default, no old mouse events should be ignored.
+ * This can be overridden by subclasses.
+ *
+ * @return false, no mouse events are ignored.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return false;
+ }
+
+ /**
* AWT 1.0 event handler.
*
* This method simply calls handleEvent and returns the result.
@@ -2449,6 +2813,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);
+ }
}
/**
@@ -2464,6 +2836,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);
+ }
}
/**
@@ -2499,6 +2880,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);
+ }
}
/**
@@ -2516,6 +2907,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);
+ }
}
/**
@@ -2534,6 +2935,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.
@@ -3435,18 +3870,24 @@ 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. */
+ if (dropTarget != null)
+ dropTarget.addNotify(peer);
+ }
}
/**
@@ -3460,17 +3901,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();
+ }
}
}
@@ -3791,56 +4236,7 @@ public abstract class Component
*/
public void requestFocus ()
{
- if (isDisplayable ()
- && isShowing ()
- && isFocusable ())
- {
- synchronized (getTreeLock ())
- {
- // Find this Component's top-level ancestor.
- Container parent = (this instanceof Container) ? (Container) this
- : getParent();
- while (parent != null
- && !(parent instanceof Window))
- parent = parent.getParent ();
-
- if (parent == null)
- return;
-
- Window toplevel = (Window) parent;
- if (toplevel.isFocusableWindow ())
- {
- if (peer != null && !isLightweight())
- // This call will cause a FOCUS_GAINED event to be
- // posted to the system event queue if the native
- // windowing system grants the focus request.
- peer.requestFocus ();
- else
- {
- // Either our peer hasn't been created yet or we're a
- // lightweight component. In either case we want to
- // post a FOCUS_GAINED event.
- EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
- synchronized (eq)
- {
- KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
- Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
- if (currentFocusOwner != null)
- {
- eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
- false, this));
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false,
- currentFocusOwner));
- }
- else
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false));
- }
- }
- }
- else
- pendingFocusRequest = new FocusEvent(this, FocusEvent.FOCUS_GAINED);
- }
- }
+ requestFocusImpl(false, true);
}
/**
@@ -3880,61 +4276,7 @@ public abstract class Component
*/
protected boolean requestFocus (boolean temporary)
{
- if (isDisplayable ()
- && isShowing ()
- && isFocusable ())
- {
- synchronized (getTreeLock ())
- {
- // Find this Component's top-level ancestor.
- Container parent = getParent ();
-
- while (parent != null
- && !(parent instanceof Window))
- parent = parent.getParent ();
-
- Window toplevel = (Window) parent;
- if (toplevel.isFocusableWindow ())
- {
- if (peer != null && !isLightweight())
- // This call will cause a FOCUS_GAINED event to be
- // posted to the system event queue if the native
- // windowing system grants the focus request.
- peer.requestFocus ();
- else
- {
- // Either our peer hasn't been created yet or we're a
- // lightweight component. In either case we want to
- // post a FOCUS_GAINED event.
- EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
- synchronized (eq)
- {
- KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
- Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
- if (currentFocusOwner != null)
- {
- eq.postEvent (new FocusEvent(currentFocusOwner,
- FocusEvent.FOCUS_LOST,
- temporary, this));
- eq.postEvent (new FocusEvent(this,
- FocusEvent.FOCUS_GAINED,
- temporary,
- currentFocusOwner));
- }
- else
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
- }
- }
- }
- else
- // FIXME: need to add a focus listener to our top-level
- // ancestor, so that we can post this event when it becomes
- // the focused window.
- pendingFocusRequest = new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary);
- }
- }
- // Always return true.
- return true;
+ return requestFocusImpl(temporary, true);
}
/**
@@ -3962,7 +4304,7 @@ public abstract class Component
*/
public boolean requestFocusInWindow ()
{
- return requestFocusInWindow (false);
+ return requestFocusImpl(false, false);
}
/**
@@ -3993,65 +4335,84 @@ public abstract class Component
*/
protected boolean requestFocusInWindow (boolean temporary)
{
- KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
-
- Window focusedWindow = manager.getFocusedWindow ();
+ return requestFocusImpl(temporary, false);
+ }
- if (isDisplayable ()
- && isShowing ()
- && isFocusable ())
+ /**
+ * Helper method for all 4 requestFocus variants.
+ *
+ * @param temporary indicates if the focus change is temporary
+ * @param focusWindow indicates if the window focus may be changed
+ *
+ * @return <code>false</code> if the request has been definitely denied,
+ * <code>true</code> otherwise
+ */
+ private boolean requestFocusImpl(boolean temporary, boolean focusWindow)
+ {
+ boolean retval = false;
+
+ // Don't try to focus non-focusable and non-visible components.
+ if (isFocusable() && isVisible())
{
- if (focusedWindow != null)
+ ComponentPeer myPeer = peer;
+ if (peer != null)
{
- synchronized (getTreeLock ())
+ // Find Window ancestor and find out if we're showing while
+ // doing this.
+ boolean showing = true;
+ Component window = this;
+ while (! (window instanceof Window))
{
- Container parent = getParent ();
-
- while (parent != null
- && !(parent instanceof Window))
- parent = parent.getParent ();
-
- Window toplevel = (Window) parent;
-
- // Check if top-level ancestor is currently focused window.
- if (focusedWindow == toplevel)
+ if (! window.isVisible())
+ showing = false;
+ window = window.parent;
+ }
+ // Don't allow focus when there is no window or the window
+ // is not focusable.
+ if (window != null && ((Window) window).isFocusableWindow()
+ && showing)
+ {
+ // Search for nearest heavy ancestor (including this
+ // component).
+ Component heavyweightParent = this;
+ while (heavyweightParent.peer instanceof LightweightPeer)
+ heavyweightParent = heavyweightParent.parent;
+
+ // Don't allow focus on lightweight components without
+ // visible heavyweight ancestor
+ if (heavyweightParent != null && heavyweightParent.isVisible())
{
- if (peer != null
- && !isLightweight()
- && !(this instanceof Window))
- // This call will cause a FOCUS_GAINED event to be
- // posted to the system event queue if the native
- // windowing system grants the focus request.
- peer.requestFocus ();
- else
+ // Don't allow focus when heavyweightParent has no peer.
+ myPeer = heavyweightParent.peer;
+ if (myPeer != null)
{
- // Either our peer hasn't been created yet or we're a
- // lightweight component. In either case we want to
- // post a FOCUS_GAINED event.
- EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
- synchronized (eq)
+ // Register lightweight focus request.
+ if (heavyweightParent != this)
+ {
+ KeyboardFocusManager
+ .addLightweightFocusRequest(heavyweightParent,
+ this);
+ }
+
+ // Try to focus the component.
+ long time = EventQueue.getMostRecentEventTime();
+ boolean success = myPeer.requestFocus(this, temporary,
+ focusWindow,
+ time);
+ if (! success)
{
- Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
- if (currentFocusOwner != null)
- {
- eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
- temporary, this));
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary,
- currentFocusOwner));
- }
- else
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
+ // Dequeue key events if focus request failed.
+ KeyboardFocusManager kfm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.dequeueKeyEvents(time, this);
}
+ retval = success;
}
}
- else
- return false;
}
}
-
- return true;
}
- return false;
+ return retval;
}
/**
@@ -4552,7 +4913,7 @@ p * <li>the set of backward traversal keys
Object newValue)
{
if (changeSupport != null)
- changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
@@ -4693,14 +5054,12 @@ p * <li>the set of backward traversal keys
* {@link #applyComponentOrientation(ComponentOrientation)} affects the
* entire hierarchy.
*
- * @param o the new orientation
- * @throws NullPointerException if o is null
+ * @param o the new orientation (<code>null</code> is accepted)
* @see #getComponentOrientation()
*/
public void setComponentOrientation(ComponentOrientation o)
{
- if (o == null)
- throw new NullPointerException();
+
ComponentOrientation oldOrientation = orientation;
orientation = o;
firePropertyChange("componentOrientation", oldOrientation, o);
@@ -4709,7 +5068,7 @@ p * <li>the set of backward traversal keys
/**
* Determines the text layout orientation used by this component.
*
- * @return the component orientation
+ * @return the component orientation (this can be <code>null</code>)
* @see #setComponentOrientation(ComponentOrientation)
*/
public ComponentOrientation getComponentOrientation()
@@ -4864,7 +5223,7 @@ p * <li>the set of backward traversal keys
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
oldMods |= Event.ALT_MASK;
- if (e instanceof MouseEvent)
+ if (e instanceof MouseEvent && !ignoreOldMouseEvents())
{
if (id == MouseEvent.MOUSE_PRESSED)
oldID = Event.MOUSE_DOWN;
@@ -5045,52 +5404,26 @@ p * <li>the set of backward traversal keys
void dispatchEventImpl(AWTEvent e)
{
- // This boolean tells us not to process focus events when the focus
- // opposite component is the same as the focus component.
- boolean ignoreFocus =
- (e instanceof FocusEvent &&
- ((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
-
- if (eventTypeEnabled (e.id))
+ // Retarget focus events before dispatching it to the KeyboardFocusManager
+ // in order to handle lightweight components properly.
+ boolean dispatched = false;
+ if (! e.isFocusManagerEvent)
{
- if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE
- && !ignoreFocus)
- processEvent(e);
-
- // the trick we use to communicate between dispatch and redispatch
- // is to have KeyboardFocusManager.redispatch synchronize on the
- // object itself. we then do not redispatch to KeyboardFocusManager
- // if we are already holding the lock.
- if (! Thread.holdsLock(e))
+ e = KeyboardFocusManager.retargetFocusEvent(e);
+ dispatched = KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .dispatchEvent(e);
+ }
+
+ if (! dispatched)
+ {
+ if (eventTypeEnabled (e.id))
{
- switch (e.id)
- {
- case WindowEvent.WINDOW_GAINED_FOCUS:
- case WindowEvent.WINDOW_LOST_FOCUS:
- case KeyEvent.KEY_PRESSED:
- case KeyEvent.KEY_RELEASED:
- case KeyEvent.KEY_TYPED:
- case FocusEvent.FOCUS_GAINED:
- case FocusEvent.FOCUS_LOST:
- if (KeyboardFocusManager
- .getCurrentKeyboardFocusManager()
- .dispatchEvent(e))
- return;
- case MouseEvent.MOUSE_PRESSED:
- // A mouse click on an enabled lightweight component
- // which has not yet been marked as consumed by any
- // other mouse listener results in a focus traversal
- // to that component.
- if (isLightweight()
- && isEnabled() && !e.isConsumed())
- requestFocus();
- break;
- }
+ if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
+ processEvent(e);
}
+ if (peer != null)
+ peer.handleEvent(e);
}
-
- if (peer != null)
- peer.handleEvent(e);
}
/**
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index 85a68ce13c2..409d164a13c 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/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;
@@ -88,14 +89,16 @@ public class Container extends Component
Dimension maxSize;
/**
- * Keeps track if the Container was cleared during a paint/update.
+ * @since 1.4
*/
- private boolean backCleared;
+ boolean focusCycleRoot;
/**
- * @since 1.4
+ * Indicates if this container provides a focus traversal policy.
+ *
+ * @since 1.5
*/
- boolean focusCycleRoot;
+ private boolean focusTraversalPolicyProvider;
int containerSerializedDataVersion;
@@ -341,7 +344,7 @@ public class Container extends Component
if (component == null)
component = new Component[4]; // FIXME, better initial size?
-
+
// This isn't the most efficient implementation. We could do less
// copying when growing the array. It probably doesn't matter.
if (ncomponents >= component.length)
@@ -362,6 +365,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)
{
@@ -388,6 +401,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);
}
}
@@ -412,6 +429,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)
@@ -423,10 +450,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);
}
}
@@ -517,7 +548,8 @@ public class Container extends Component
public void setLayout(LayoutManager mgr)
{
layoutMgr = mgr;
- invalidate();
+ if (valid)
+ invalidate();
}
/**
@@ -572,19 +604,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);
+ }
}
}
@@ -671,21 +706,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;
}
/**
@@ -707,17 +746,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;
}
/**
@@ -727,18 +774,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;
}
/**
@@ -754,8 +808,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();
@@ -775,8 +832,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();
@@ -794,13 +854,10 @@ public class Container extends Component
*/
public void paint(Graphics g)
{
- if (!isShowing())
- return;
-
- // Visit heavyweights if the background was cleared
- // for this container.
- visitChildren(g, GfxPaintVisitor.INSTANCE, !backCleared);
- backCleared = false;
+ if (isShowing())
+ {
+ visitChildren(g, GfxPaintVisitor.INSTANCE, true);
+ }
}
/**
@@ -830,14 +887,15 @@ public class Container extends Component
// that overrides isLightweight() to return false, the background is
// also not cleared. So we do a check on !(peer instanceof LightweightPeer)
// instead.
- ComponentPeer p = peer;
- if (p != null && ! (p instanceof LightweightPeer))
+ if (isShowing())
{
- g.clearRect(0, 0, getWidth(), getHeight());
- backCleared = true;
+ ComponentPeer p = peer;
+ if (! (p instanceof LightweightPeer))
+ {
+ g.clearRect(0, 0, getWidth(), getHeight());
+ }
+ paint(g);
}
-
- paint(g);
}
/**
@@ -1173,8 +1231,11 @@ public class Container extends Component
*/
public void addNotify()
{
- super.addNotify();
- addNotifyContainerChildren();
+ synchronized (getTreeLock())
+ {
+ super.addNotify();
+ addNotifyContainerChildren();
+ }
}
/**
@@ -1549,6 +1610,42 @@ public class Container extends Component
}
/**
+ * Set to <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used.
+ *
+ * @return <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used
+ *
+ * @see #setFocusTraversalPolicyProvider(boolean)
+ *
+ * @since 1.5
+ */
+ public final boolean isFocusTraversalPolicyProvider()
+ {
+ return focusTraversalPolicyProvider;
+ }
+
+ /**
+ * Set to <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used.
+ *
+ * @param b <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used
+ *
+ * @see #isFocusTraversalPolicyProvider()
+ *
+ * @since 1.5
+ */
+ public final void setFocusTraversalPolicyProvider(boolean b)
+ {
+ focusTraversalPolicyProvider = b;
+ }
+
+ /**
* Check whether this Container is a focus cycle root.
*
* @return true if this is a focus cycle root, false otherwise
@@ -1594,7 +1691,16 @@ public class Container extends Component
public void applyComponentOrientation (ComponentOrientation orientation)
{
if (orientation == null)
- throw new NullPointerException ();
+ throw new NullPointerException();
+
+ setComponentOrientation(orientation);
+ for (int i = 0; i < ncomponents; i++)
+ {
+ if (component[i] instanceof Container)
+ ((Container) component[i]).applyComponentOrientation(orientation);
+ else
+ component[i].setComponentOrientation(orientation);
+ }
}
public void addPropertyChangeListener (PropertyChangeListener listener)
@@ -1646,24 +1752,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;
}
}
@@ -1682,19 +1791,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 < component.length; 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.
@@ -1850,6 +1962,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/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java b/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
index 23b4ac2e8d3..14afd364876 100644
--- a/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
+++ b/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
@@ -346,28 +346,30 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
|| !root.isDisplayable ())
return null;
- if (root.visible && root.isDisplayable() && root.enabled
- && root.focusable)
+ if (accept(root))
return root;
- Component[] componentArray = root.getComponents ();
-
- for (int i = 0; i < componentArray.length; i++)
+ int ncomponents = root.getComponentCount();
+ for (int i = 0; i < ncomponents; i++)
{
- Component component = componentArray [i];
-
- if (component.visible && component.isDisplayable() && component.enabled
- && component.focusable)
- return component;
-
- if (component instanceof Container)
+ Component component = root.getComponent(i);
+ if (component instanceof Container
+ && !((Container) component).isFocusCycleRoot())
{
- Component result = getFirstComponent ((Container) component);
-
- if (result != null
- && (result.visible && result.isDisplayable() && result.enabled && result.focusable))
- return result;
+ Component first = null;
+ Container cont = (Container) component;
+ if (cont.isFocusTraversalPolicyProvider())
+ {
+ FocusTraversalPolicy childPol = cont.getFocusTraversalPolicy();
+ first = childPol.getFirstComponent(cont);
+ }
+ else
+ first = getFirstComponent(cont);
+ if (first != null)
+ return first;
}
+ else if (accept(component))
+ return component;
}
return null;
diff --git a/libjava/classpath/java/awt/Cursor.java b/libjava/classpath/java/awt/Cursor.java
index 0ff987cd9ed..4d339b7211a 100644
--- a/libjava/classpath/java/awt/Cursor.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
index 037cb834c40..9fea99b7839 100644
--- a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
@@ -163,7 +163,13 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
if (e.id == WindowEvent.WINDOW_ACTIVATED)
setGlobalActiveWindow (target);
else if (e.id == WindowEvent.WINDOW_GAINED_FOCUS)
- setGlobalFocusedWindow (target);
+ {
+ setGlobalFocusedWindow (target);
+ FocusTraversalPolicy p = target.getFocusTraversalPolicy();
+ Component toFocus = p.getInitialComponent(target);
+ if (toFocus != null)
+ toFocus.requestFocusInWindow();
+ }
else if (e.id != WindowEvent.WINDOW_LOST_FOCUS
&& e.id != WindowEvent.WINDOW_DEACTIVATED)
return false;
@@ -173,51 +179,18 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
}
else if (e instanceof FocusEvent)
{
- Component target = (Component) e.getSource ();
+ FocusEvent fe = (FocusEvent) e;
+ Component target = fe.getComponent ();
+ boolean retval = false;
if (e.id == FocusEvent.FOCUS_GAINED)
{
- if (! (target instanceof Window))
- {
- if (((FocusEvent) e).isTemporary ())
- setGlobalFocusOwner (target);
- else
- setGlobalPermanentFocusOwner (target);
- }
-
- // Keep track of this window's focus owner.
-
- // Find the target Component's top-level ancestor. target
- // may be a window.
- Container parent = target.getParent ();
-
- while (parent != null
- && !(parent instanceof Window))
- parent = parent.getParent ();
-
- // If the parent is null and target is not a window, then target is an
- // unanchored component and so we don't want to set the focus owner.
- if (! (parent == null && ! (target instanceof Window)))
- {
- Window toplevel = parent == null ?
- (Window) target : (Window) parent;
-
- Component focusOwner = getFocusOwner ();
- if (focusOwner != null
- && ! (focusOwner instanceof Window))
- toplevel.setFocusOwner (focusOwner);
- }
+ retval = handleFocusGained(fe);
}
else if (e.id == FocusEvent.FOCUS_LOST)
{
- if (((FocusEvent) e).isTemporary ())
- setGlobalFocusOwner (null);
- else
- setGlobalPermanentFocusOwner (null);
+ retval = handleFocusLost(fe);
}
-
- redispatchEvent(target, e);
-
return true;
}
else if (e instanceof KeyEvent)
@@ -256,6 +229,95 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
return false;
}
+ /**
+ * Handles FOCUS_GAINED events in {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ */
+ private boolean handleFocusGained(FocusEvent fe)
+ {
+ Component target = fe.getComponent ();
+
+ // If old focus owner != new focus owner, notify old focus
+ // owner that it has lost focus.
+ Component oldFocusOwner = getGlobalFocusOwner();
+ if (oldFocusOwner != null && oldFocusOwner != target)
+ {
+ FocusEvent lost = new FocusEvent(oldFocusOwner,
+ FocusEvent.FOCUS_LOST,
+ fe.isTemporary(), target);
+ oldFocusOwner.dispatchEvent(lost);
+ }
+
+ setGlobalFocusOwner (target);
+ if (target != getGlobalFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner (target);
+ if (target != getGlobalPermanentFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ redispatchEvent(target, fe);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Handles FOCUS_LOST events for {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ *
+ * @return if the event has been handled
+ */
+ private boolean handleFocusLost(FocusEvent fe)
+ {
+ Component currentFocus = getGlobalFocusOwner();
+ if (currentFocus != fe.getOppositeComponent())
+ {
+ setGlobalFocusOwner(null);
+ if (getGlobalFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to restore
+ // the focus.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner(null);
+ if (getGlobalPermanentFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to
+ // restore the focus.
+ }
+ else
+ {
+ fe.setSource(currentFocus);
+ redispatchEvent(currentFocus, fe);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
private boolean enqueueKeyEvent (KeyEvent e)
{
Iterator i = delayRequests.iterator ();
diff --git a/libjava/classpath/java/awt/EventDispatchThread.java b/libjava/classpath/java/awt/EventDispatchThread.java
index 7cb8af831bf..074a84975ac 100644
--- a/libjava/classpath/java/awt/EventDispatchThread.java
+++ b/libjava/classpath/java/awt/EventDispatchThread.java
@@ -82,17 +82,7 @@ class EventDispatchThread extends Thread
try
{
AWTEvent evt = queue.getNextEvent();
-
- KeyboardFocusManager manager;
- manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
-
- // Try to dispatch this event to the current keyboard focus
- // manager. It will dispatch all FocusEvents, all
- // WindowEvents related to focus, and all KeyEvents,
- // returning true. Otherwise, it returns false and we
- // dispatch the event normally.
- if (!manager.dispatchEvent (evt))
- queue.dispatchEvent(evt);
+ queue.dispatchEvent(evt);
}
catch (ThreadDeath death)
{
diff --git a/libjava/classpath/java/awt/FileDialog.java b/libjava/classpath/java/awt/FileDialog.java
index 7f2723e7e9a..f02d06be2c9 100644
--- a/libjava/classpath/java/awt/FileDialog.java
+++ b/libjava/classpath/java/awt/FileDialog.java
@@ -101,6 +101,58 @@ private int mode;
* Constructors
*/
+ /**
+ * Initializes a new instance of <code>FileDialog</code> with the specified
+ * parent. This dialog will have no title and will be for loading a file.
+ *
+ * @param parent The parent dialog for this.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent)
+ {
+ this(parent, "", LOAD);
+ }
+
+ /**
+ * Initialized a new instance of <code>FileDialog</code> with the
+ * specified parent and title. This dialog will be for opening a file.
+ *
+ * @param parent The parent dialog for this.
+ * @param title The title for this dialog.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent, String title)
+ {
+ this(parent, title, LOAD);
+ }
+
+ /**
+ * Initialized a new instance of <code>FileDialog</code> with the specified
+ * parent, title, and mode.
+ *
+ * @param parent The parent dialog for this.
+ * @param title The title for this dialog.
+ * @param mode The mode of the dialog, either <code>LOAD</code> or
+ * <code>SAVE</code>.
+ * @throws IllegalArgumentException - if illegal mode, if
+ * GraphicsEnvironment.isHeadless or if parent is null.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent, String title, int mode)
+ {
+ super(parent, title, true);
+
+ // Other IllegalArgumentException cases are taken care of in Window.java
+ if (mode != LOAD && mode != SAVE)
+ throw new IllegalArgumentException (
+ "Mode argument must be either LOAD or SAVE");
+
+ setMode(mode);
+ }
+
/**
* Initializes a new instance of <code>FileDialog</code> with the
* specified parent. This dialog will have no title and will be for
diff --git a/libjava/classpath/java/awt/FlowLayout.java b/libjava/classpath/java/awt/FlowLayout.java
index 7d0771d915b..8c99195289a 100644
--- a/libjava/classpath/java/awt/FlowLayout.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index a52f63408da..1c22ce7b48f 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -48,6 +48,8 @@ import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -114,7 +116,14 @@ public class Font implements Serializable
* @since 1.3
*/
public static final int TRUETYPE_FONT = 0;
-
+
+ /**
+ * Indicates to <code>createFont</code> that the supplied font data
+ * is in Type1 format.
+ *
+ * @since 1.5
+ */
+ public static final int TYPE1_FONT = 1;
/**
* A flag for <code>layoutGlyphVector</code>, indicating that the
@@ -576,6 +585,34 @@ public class Font implements Serializable
}
/**
+ * Creates a new font from a File object.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ *
+ * @param fontFormat - Integer code indicating the format the font data is
+ * in.Currently this can only be {@link #TRUETYPE_FONT}.
+ * @param file - a {@link File} from which font data will be read.
+ *
+ * @return A new {@link Font} of the format indicated.
+ *
+ * @throws IllegalArgumentException if <code>fontType</code> is not
+ * recognized.
+ * @throws NullPointerException if <code>file</code> is <code>null</code>.
+ * @throws FontFormatException if data in the file is invalid or cannot be read..
+ * @throws SecurityException if the caller has no read permission for the file.
+ * @throws IOException if the file cannot be read
+ *
+ * @since 1.5
+ */
+ public static Font createFont (int fontFormat, File file)
+ throws FontFormatException, IOException
+ {
+ if( file == null )
+ throw new NullPointerException("Null file argument");
+ return tk().createFont(fontFormat, new FileInputStream( file ));
+ }
+
+ /**
* Maps characters to glyphs in a one-to-one relationship, returning a new
* {@link GlyphVector} with a mapped glyph for each input character. This
* sort of mapping is often sufficient for some scripts such as Roman, but
diff --git a/libjava/classpath/java/awt/Graphics2D.java b/libjava/classpath/java/awt/Graphics2D.java
index b3ecbc58a98..ada13edc512 100644
--- a/libjava/classpath/java/awt/Graphics2D.java
+++ b/libjava/classpath/java/awt/Graphics2D.java
@@ -53,23 +53,21 @@ import java.util.Map;
/**
* An abstract class defining a device independent two-dimensional vector
* graphics API. Concrete subclasses implement this API for output of
- * vector graphics to: (*)
+ * vector graphics to:
* <p>
* <ul>
* <li>a {@link javax.swing.JComponent} - in the
* {@link javax.swing.JComponent#paint(Graphics)} method, the incoming
* {@link Graphics} should always be an instance of
- * <code>Graphics2D</code> (*);</li>
+ * <code>Graphics2D</code>;</li>
* <li>a {@link BufferedImage} - see
- * {@link BufferedImage#createGraphics()} (*);</li>
+ * {@link BufferedImage#createGraphics()};</li>
* <li>a {@link java.awt.print.PrinterJob} - in the
* {@link Printable#print(Graphics, PageFormat, int)} method, the incoming
- * {@link Graphics} should always be an instance of <code>Graphics2D</code>
- * (*).</li>
+ * {@link Graphics} should always be an instance of
+ * <code>Graphics2D</code>.</li>
* </ul>
* <p>
- * (*) Support for this API is not fully implemented in GNU Classpath yet.
- * <p>
* Third party libraries provide support for output to other formats via this
* API, including encapsulated postscript (EPS), portable document format (PDF),
* and scalable vector graphics (SVG).
diff --git a/libjava/classpath/java/awt/GridBagConstraints.java b/libjava/classpath/java/awt/GridBagConstraints.java
index 8d8b4fae534..a6a64c3bb8b 100644
--- a/libjava/classpath/java/awt/GridBagConstraints.java
+++ b/libjava/classpath/java/awt/GridBagConstraints.java
@@ -48,62 +48,99 @@ public class GridBagConstraints implements Cloneable, Serializable
{
static final long serialVersionUID = -1000070633030801713L;
- /** Fill in both directions. */
- public static final int BOTH = 1;
- /** Don't fill. */
+ // Fill values.
+ /**
+ * Don't fill.
+ */
public static final int NONE = 0;
- /** Fill horizontally. */
+
+ /**
+ * Fill in both directions.
+ */
+ public static final int BOTH = 1;
+
+ /**
+ * Fill horizontally.
+ */
public static final int HORIZONTAL = 2;
- /** Fill vertically. */
+
+ /**
+ * Fill vertically.
+ */
public static final int VERTICAL = 3;
- /** Position in the center. */
+ // Anchor values.
+ /**
+ * Position in the center.
+ */
public static final int CENTER = 10;
- /** Position to the east. */
- public static final int EAST = 13;
- /** Position to the north. */
+
+ /**
+ * Position to the north.
+ */
public static final int NORTH = 11;
- /** Position to the northeast. */
+
+ /**
+ * Position to the northeast.
+ */
public static final int NORTHEAST = 12;
- /** Position to the northwest. */
- public static final int NORTHWEST = 18;
- /** Position to the south. */
- public static final int SOUTH = 15;
- /** Position to the southeast. */
+
+ /**
+ * Position to the east.
+ */
+ public static final int EAST = 13;
+
+ /**
+ * Position to the southeast.
+ */
public static final int SOUTHEAST = 14;
- /** Position to the southwest. */
+
+ /**
+ * Position to the south.
+ */
+ public static final int SOUTH = 15;
+
+ /**
+ * Position to the southwest.
+ */
public static final int SOUTHWEST = 16;
- /** Position to the west. */
+
+ /**
+ * Position to the west.
+ */
public static final int WEST = 17;
- /** Occupy all remaining cells except last cell. */
+ /**
+ * Position to the northwest.
+ */
+ public static final int NORTHWEST = 18;
+
+ // gridx and gridy values.
+ /**
+ * Occupy all remaining cells except last cell.
+ */
public static final int RELATIVE = -1;
- /** Occupy all remaining cells. */
- public static final int REMAINDER = 0;
/**
- * Position to where the first text line would end. Equals to NORTHEAST for
- * horizontal left-to-right orientations.
+ * Occupy all remaining cells.
*/
- public static final int FIRST_LINE_END = 24;
+ public static final int REMAINDER = 0;
/**
- * Position to where the first text line would start. Equals to NORTHWEST for
- * horizontal left-to-right orientations.
+ * Position to where a page starts. Equals NORTH for horizontal orientations.
*/
- public static final int FIRST_LINE_START = 23;
+ public static final int PAGE_START = 19;
/**
- * Position to where the last text line would end. Equals to SOUTHEAST for
- * horizontal left-to-right orientations.
+ * Position to where a page ends. Equals SOUTH for horizontal orientations.
*/
- public static final int LAST_LINE_END = 26;
+ public static final int PAGE_END = 20;
/**
- * Position to where the last text line would start. Equals to SOUTHWEST for
- * horizontal left-to-right orientations.
+ * Position to where a text line would start. Equals to WEST for
+ * left-to-right orientations.
*/
- public static final int LAST_LINE_START = 25;
+ public static final int LINE_START = 21;
/**
* Position to where a text line would end. Equals to EAST for
@@ -112,20 +149,28 @@ public class GridBagConstraints implements Cloneable, Serializable
public static final int LINE_END = 22;
/**
- * Position to where a text line would start. Equals to WEST for
- * left-to-right orientations.
+ * Position to where the first text line would start. Equals to NORTHWEST for
+ * horizontal left-to-right orientations.
*/
- public static final int LINE_START = 21;
+ public static final int FIRST_LINE_START = 23;
/**
- * Position to where a page ends. Equals SOUTH for horizontal orientations.
+ * Position to where the first text line would end. Equals to NORTHEAST for
+ * horizontal left-to-right orientations.
*/
- public static final int PAGE_END = 20;
+ public static final int FIRST_LINE_END = 24;
/**
- * Position to where a page starts. Equals NORTH for horizontal orientations.
+ * Position to where the last text line would start. Equals to SOUTHWEST for
+ * horizontal left-to-right orientations.
*/
- public static final int PAGE_START = 19;
+ public static final int LAST_LINE_START = 25;
+
+ /**
+ * Position to where the last text line would end. Equals to SOUTHEAST for
+ * horizontal left-to-right orientations.
+ */
+ public static final int LAST_LINE_END = 26;
public int anchor;
public int fill;
@@ -139,7 +184,9 @@ public class GridBagConstraints implements Cloneable, Serializable
public double weightx;
public double weighty;
- /** Create a copy of this object. */
+ /**
+ * Create a copy of this object.
+ */
public Object clone ()
{
try
@@ -155,8 +202,10 @@ public class GridBagConstraints implements Cloneable, Serializable
}
}
- /** Create a new GridBagConstraints object with the default
- * parameters. */
+ /**
+ * Create a new GridBagConstraints object with the default
+ * parameters.
+ */
public GridBagConstraints ()
{
this.anchor = CENTER;
@@ -172,8 +221,10 @@ public class GridBagConstraints implements Cloneable, Serializable
this.weighty = 0;
}
- /** Create a new GridBagConstraints object with the indicated
- * parameters. */
+ /**
+ * Create a new GridBagConstraints object with the indicated
+ * parameters.
+ */
public GridBagConstraints (int gridx, int gridy,
int gridwidth, int gridheight,
double weightx, double weighty,
diff --git a/libjava/classpath/java/awt/GridBagLayout.java b/libjava/classpath/java/awt/GridBagLayout.java
index f827d21ca6a..d84b7d6df6c 100644
--- a/libjava/classpath/java/awt/GridBagLayout.java
+++ b/libjava/classpath/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.
@@ -38,8 +38,6 @@ exception statement from your version. */
package java.awt;
-import gnu.classpath.NotImplementedException;
-
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -322,13 +320,24 @@ public class GridBagLayout
}
/**
- * Obsolete.
+ * Move and resize a rectangle according to a set of grid bag
+ * constraints. The x, y, width and height fields of the
+ * rectangle argument are adjusted to the new values.
+ *
+ * @param constraints position and size constraints
+ * @param r rectangle to be moved and resized
*/
- protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect)
- throws NotImplementedException
+ protected void AdjustForGravity (GridBagConstraints constraints,
+ Rectangle r)
{
- // FIXME
- throw new Error ("Not implemented");
+ 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;
+ }
}
/**
@@ -353,10 +362,9 @@ public class GridBagLayout
// layoutInfo. So we wait until after this for loop to set
// layoutInfo.
Component lastComp = null;
- int cellx = 0;
- int celly = 0;
- int cellw = 0;
- int cellh = 0;
+
+ Rectangle cell = new Rectangle();
+
for (int i = 0; i < components.length; i++)
{
Component component = components[i];
@@ -370,29 +378,23 @@ public class GridBagLayout
if (lastComp != null
&& constraints.gridheight == GridBagConstraints.REMAINDER)
- celly += cellh;
+ cell.y += cell.height;
else
- celly = sumIntArray(info.rowHeights, constraints.gridy);
+ cell.y = sumIntArray(info.rowHeights, constraints.gridy);
if (lastComp != null
&& constraints.gridwidth == GridBagConstraints.REMAINDER)
- cellx += cellw;
+ cell.x += cell.width;
else
- cellx = sumIntArray(info.colWidths, constraints.gridx);
+ cell.x = sumIntArray(info.colWidths, constraints.gridx);
- cellw = sumIntArray(info.colWidths, constraints.gridx
- + constraints.gridwidth) - cellx;
- cellh = sumIntArray(info.rowHeights, constraints.gridy
- + constraints.gridheight) - celly;
-
- Insets insets = constraints.insets;
- if (insets != null)
- {
- cellx += insets.left;
- celly += insets.top;
- cellw -= insets.left + insets.right;
- cellh -= insets.top + insets.bottom;
- }
+ cell.width = sumIntArray(info.colWidths, constraints.gridx
+ + constraints.gridwidth) - cell.x;
+ cell.height = sumIntArray(info.rowHeights, constraints.gridy
+ + constraints.gridheight) - cell.y;
+
+ // Adjust for insets.
+ AdjustForGravity( constraints, cell );
// Note: Documentation says that padding is added on both sides, but
// visual inspection shows that the Sun implementation only adds it
@@ -403,14 +405,14 @@ public class GridBagLayout
switch (constraints.fill)
{
case GridBagConstraints.HORIZONTAL:
- dim.width = cellw;
+ dim.width = cell.width;
break;
case GridBagConstraints.VERTICAL:
- dim.height = cellh;
+ dim.height = cell.height;
break;
case GridBagConstraints.BOTH:
- dim.width = cellw;
- dim.height = cellh;
+ dim.width = cell.width;
+ dim.height = cell.height;
break;
}
@@ -420,40 +422,40 @@ public class GridBagLayout
switch (constraints.anchor)
{
case GridBagConstraints.NORTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly;
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y;
break;
case GridBagConstraints.SOUTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + cellh - dim.height;
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y + cell.height - dim.height;
break;
case GridBagConstraints.WEST:
- x = cellx;
- y = celly + (cellh - dim.height) / 2;
+ x = cell.x;
+ y = cell.y + (cell.height - dim.height) / 2;
break;
case GridBagConstraints.EAST:
- x = cellx + cellw - dim.width;
- y = celly + (cellh - dim.height) / 2;
+ x = cell.x + cell.width - dim.width;
+ y = cell.y + (cell.height - dim.height) / 2;
break;
case GridBagConstraints.NORTHEAST:
- x = cellx + cellw - dim.width;
- y = celly;
+ x = cell.x + cell.width - dim.width;
+ y = cell.y;
break;
case GridBagConstraints.NORTHWEST:
- x = cellx;
- y = celly;
+ x = cell.x;
+ y = cell.y;
break;
case GridBagConstraints.SOUTHEAST:
- x = cellx + cellw - dim.width;
- y = celly + cellh - dim.height;
+ x = cell.x + cell.width - dim.width;
+ y = cell.y + cell.height - dim.height;
break;
case GridBagConstraints.SOUTHWEST:
- x = cellx;
- y = celly + cellh - dim.height;
+ x = cell.x;
+ y = cell.y + cell.height - dim.height;
break;
default:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + (cellh - dim.height) / 2;
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y + (cell.height - dim.height) / 2;
break;
}
component.setBounds(info.pos_x + x, info.pos_y + y, dim.width,
@@ -1082,10 +1084,18 @@ public class GridBagLayout
}
/**
+ * Move and resize a rectangle according to a set of grid bag
+ * constraints. The x, y, width and height fields of the
+ * rectangle argument are adjusted to the new values.
+ *
+ * @param constraints position and size constraints
+ * @param r rectangle to be moved and resized
+ *
* @since 1.4
*/
- protected void adjustForGravity (GridBagConstraints gbc, Rectangle rect)
+ protected void adjustForGravity (GridBagConstraints constraints,
+ Rectangle r)
{
- AdjustForGravity (gbc, rect);
+ AdjustForGravity (constraints, r);
}
}
diff --git a/libjava/classpath/java/awt/GridLayout.java b/libjava/classpath/java/awt/GridLayout.java
index 80d96414249..a6836681da5 100644
--- a/libjava/classpath/java/awt/GridLayout.java
+++ b/libjava/classpath/java/awt/GridLayout.java
@@ -254,14 +254,11 @@ public class GridLayout implements LayoutManager, Serializable
this.cols = newCols;
}
- /** Set the horizontal gap
+ /** Set the horizontal gap. An Exception is not thrown if hgap < 0.
* @param hgap The horizontal gap
- * @exception IllegalArgumentException If the hgap value is less than zero.
*/
public void setHgap (int hgap)
{
- if (hgap < 0)
- throw new IllegalArgumentException ("horizontal gap must be nonnegative");
this.hgap = hgap;
}
@@ -280,21 +277,18 @@ public class GridLayout implements LayoutManager, Serializable
this.rows = newRows;
}
- /** Set the vertical gap.
+ /** Set the vertical gap. An Exception is not thrown if vgap < 0.
* @param vgap The vertical gap
- * @exception IllegalArgumentException If the vgap value is less than zero.
*/
public void setVgap (int vgap)
{
- if (vgap < 0)
- throw new IllegalArgumentException ("vertical gap must be nonnegative");
this.vgap = vgap;
}
/** Return String description of this object. */
public String toString ()
{
- return ("[" + getClass ().getName ()
+ return (getClass ().getName () + "["
+ ",hgap=" + hgap + ",vgap=" + vgap
+ ",rows=" + rows + ",cols=" + cols
+ "]");
diff --git a/libjava/classpath/java/awt/Image.java b/libjava/classpath/java/awt/Image.java
index 6ade302a147..8a1cc0f0039 100644
--- a/libjava/classpath/java/awt/Image.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Insets.java b/libjava/classpath/java/awt/Insets.java
index 6d5bd122e9d..762b6975b3f 100644
--- a/libjava/classpath/java/awt/Insets.java
+++ b/libjava/classpath/java/awt/Insets.java
@@ -1,5 +1,5 @@
/* Insets.java -- information about a container border
- Copyright (C) 1999, 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -149,14 +149,13 @@ public class Insets implements Cloneable, Serializable
/**
* Returns a string representation of this object, which will be non-null.
- * The format is unspecified, but appears to be <code>XXX what is it?</code>.
*
* @return a string representation of this object
*/
public String toString()
{
- return getClass().getName() + "(top=" + top + ",bottom=" + bottom +
- ",left=" + left + ",right=" + right + ')';
+ return getClass().getName() + "[top=" + top + ",left=" + left
+ + ",bottom=" + bottom + ",right=" + right + ']';
}
/**
diff --git a/libjava/classpath/java/awt/KeyboardFocusManager.java b/libjava/classpath/java/awt/KeyboardFocusManager.java
index 371ea9bdf8a..eacbceb7d50 100644
--- a/libjava/classpath/java/awt/KeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/KeyboardFocusManager.java
@@ -304,10 +304,7 @@ public abstract class KeyboardFocusManager
*/
public Component getFocusOwner ()
{
- Component owner = (Component) getObject (currentFocusOwners);
- if (owner == null)
- owner = (Component) getObject (currentPermanentFocusOwners);
- return owner;
+ return (Component) getObject (currentFocusOwners);
}
/**
@@ -323,10 +320,7 @@ public abstract class KeyboardFocusManager
*/
protected Component getGlobalFocusOwner ()
{
- // Check if there is a temporary focus owner.
- Component focusOwner = (Component) getGlobalObject (currentFocusOwners);
-
- return (focusOwner == null) ? getGlobalPermanentFocusOwner () : focusOwner;
+ return (Component) getGlobalObject(currentFocusOwners, true);
}
/**
@@ -409,7 +403,7 @@ public abstract class KeyboardFocusManager
*/
protected Component getGlobalPermanentFocusOwner ()
{
- return (Component) getGlobalObject (currentPermanentFocusOwners);
+ return (Component) getGlobalObject (currentPermanentFocusOwners, true);
}
/**
@@ -455,7 +449,7 @@ public abstract class KeyboardFocusManager
*/
protected Window getGlobalFocusedWindow ()
{
- return (Window) getGlobalObject (currentFocusedWindows);
+ return (Window) getGlobalObject (currentFocusedWindows, true);
}
/**
@@ -497,7 +491,7 @@ public abstract class KeyboardFocusManager
*/
protected Window getGlobalActiveWindow()
{
- return (Window) getGlobalObject (currentActiveWindows);
+ return (Window) getGlobalObject (currentActiveWindows, true);
}
/**
@@ -663,7 +657,7 @@ public abstract class KeyboardFocusManager
*/
protected Container getGlobalCurrentFocusCycleRoot ()
{
- return (Container) getGlobalObject (currentFocusCycleRoots);
+ return (Container) getGlobalObject (currentFocusCycleRoots, true);
}
/**
@@ -1105,11 +1099,9 @@ public abstract class KeyboardFocusManager
*/
public final void redispatchEvent (Component target, AWTEvent e)
{
- synchronized (e)
- {
- e.setSource (target);
- target.dispatchEvent (e);
- }
+ e.isFocusManagerEvent = true;
+ target.dispatchEvent (e);
+ e.isFocusManagerEvent = false;
}
/**
@@ -1355,17 +1347,19 @@ public abstract class KeyboardFocusManager
* @see #getGlobalActiveWindow()
* @see #getGlobalCurrentFocusCycleRoot()
*/
- private Object getGlobalObject (Map globalMap)
+ private Object getGlobalObject (Map globalMap, boolean checkThread)
{
- ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
- KeyboardFocusManager managerForCallingThread
- = (KeyboardFocusManager) currentKeyboardFocusManagers.get (currentGroup);
-
- if (this != managerForCallingThread)
- throw new SecurityException ("Attempted to retrieve an object from a "
- + "keyboard focus manager that isn't "
- + "associated with the current thread group.");
+ if (checkThread)
+ {
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+ KeyboardFocusManager managerForCallingThread =
+ (KeyboardFocusManager) currentKeyboardFocusManagers.get(currentGroup);
+ if (this != managerForCallingThread)
+ throw new SecurityException ("Attempted to retrieve an object from a "
+ + "keyboard focus manager that isn't "
+ + "associated with the current thread group.");
+ }
synchronized (globalMap)
{
Collection globalObjects = globalMap.values ();
@@ -1406,7 +1400,7 @@ public abstract class KeyboardFocusManager
synchronized (globalMap)
{
// Save old object.
- Object oldObject = getGlobalObject (globalMap);
+ Object oldObject = getGlobalObject(globalMap, false);
// Nullify old object.
Collection threadGroups = globalMap.keySet ();
@@ -1436,4 +1430,48 @@ public abstract class KeyboardFocusManager
}
}
}
+
+
+ /**
+ * Maps focus requests from heavyweight to lightweight components.
+ */
+ private static HashMap focusRequests = new HashMap();
+
+ /**
+ * Retargets focus events that come from the peer (which only know about
+ * heavyweight components) to go to the correct lightweight component
+ * if appropriate.
+ *
+ * @param ev the event to check
+ *
+ * @return the retargetted event
+ */
+ static AWTEvent retargetFocusEvent(AWTEvent ev)
+ {
+ if (ev instanceof FocusEvent)
+ {
+ FocusEvent fe = (FocusEvent) ev;
+ Component target = fe.getComponent();
+ if (focusRequests.containsKey(target))
+ {
+ Component lightweight = (Component) focusRequests.get(target);
+ ev = new FocusEvent(lightweight, fe.id, fe.isTemporary());
+ focusRequests.remove(target);
+ }
+ }
+ return ev;
+ }
+
+ /**
+ * Adds a lightweight focus request for a heavyweight component.
+ *
+ * @param heavyweight the heavyweight from which we will receive a focus
+ * event soon
+ * @param lightweight the lightweight that ultimately receives the request
+ */
+ static void addLightweightFocusRequest(Component heavyweight,
+ Component lightweight)
+ {
+ focusRequests.put(heavyweight, lightweight);
+ }
}
diff --git a/libjava/classpath/java/awt/Label.java b/libjava/classpath/java/awt/Label.java
index d6db329106f..71614da6482 100644
--- a/libjava/classpath/java/awt/Label.java
+++ b/libjava/classpath/java/awt/Label.java
@@ -1,5 +1,6 @@
/* Label.java -- Java label widget
- Copyright (C) 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, Free Software
+ Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,275 +46,250 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
- * This component is used for displaying simple text strings that cannot
- * be edited by the user.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Tom Tromey (tromey@cygnus.com)
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- */
+ * This component is used for displaying simple text strings that cannot
+ * be edited by the user.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ */
public class Label extends Component implements Accessible
{
-/*
- * Static Variables
- */
-
-/**
- * Alignment constant aligning the text to the left of its window.
- */
-public static final int LEFT = 0;
-
-/**
- * Alignment constant aligning the text in the center of its window.
- */
-public static final int CENTER = 1;
-
-/**
- * Alignment constant aligning the text to the right of its window.
- */
-public static final int RIGHT = 2;
-
-// Serialization version constant:
-private static final long serialVersionUID = 3094126758329070636L;
-
-/*************************************************************************/
+ /**
+ * Alignment constant aligning the text to the left of its window.
+ */
+ public static final int LEFT = 0;
-/*
- * Instance Variables
- */
+ /**
+ * Alignment constant aligning the text in the center of its window.
+ */
+ public static final int CENTER = 1;
-/**
- * @serial Indicates the alignment of the text within this label's window.
- * This is one of the constants in this class. The default value is
- * <code>LEFT</code>.
- */
-private int alignment;
+ /**
+ * Alignment constant aligning the text to the right of its window.
+ */
+ public static final int RIGHT = 2;
-/**
- * @serial The text displayed in the label
- */
-private String text;
+ // Serialization version constant:
+ private static final long serialVersionUID = 3094126758329070636L;
-/*************************************************************************/
+ /**
+ * @serial Indicates the alignment of the text within this label's window.
+ * This is one of the constants in this class. The default value is
+ * <code>LEFT</code>.
+ */
+ private int alignment;
-/*
- * Constructors
- */
+ /**
+ * @serial The text displayed in the label
+ */
+ private String text;
-/**
- * Initializes a new instance of <code>Label</code> with no text.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Label()
-{
- this("", LEFT);
-}
+ /**
+ * Initializes a new instance of <code>Label</code> with no text.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label()
+ {
+ this("", LEFT);
+ }
-/*************************************************************************/
+ /**
+ * Initializes a new instance of <code>Label</code> with the specified
+ * text that is aligned to the left.
+ *
+ * @param text The text of the label.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label(String text)
+ {
+ this(text, LEFT);
+ }
-/**
- * Initializes a new instance of <code>Label</code> with the specified
- * text that is aligned to the left.
- *
- * @param text The text of the label.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Label(String text)
-{
- this(text, LEFT);
-}
+ /**
+ * Initializes a new instance of <code>Label</code> with the specified
+ * text and alignment.
+ *
+ * @param text The text of the label.
+ * @param alignment The desired alignment for the text in this label,
+ * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
+ * <code>RIGHT</code>.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label(String text, int alignment)
+ {
+ setAlignment(alignment);
+ setText(text);
-/*************************************************************************/
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
-/**
- * Initializes a new instance of <code>Label</code> with the specified
- * text and alignment.
- *
- * @param text The text of the label.
- * @param alignment The desired alignment for the text in this label,
- * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
- * <code>RIGHT</code>.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Label(String text, int alignment)
-{
- setAlignment (alignment);
- setText (text);
+ /**
+ * Returns the constant indicating the alignment of the text in this
+ * label. The value returned will be one of the alignment constants
+ * from this class.
+ *
+ * @return The alignment of the text in the label.
+ */
+ public int getAlignment()
+ {
+ return(alignment);
+ }
- if (GraphicsEnvironment.isHeadless())
- throw new HeadlessException ();
-}
+ /**
+ * Sets the text alignment of this label to the specified value.
+ *
+ * @param alignment The desired alignment for the text in this label,
+ * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
+ * <code>RIGHT</code>.
+ */
+ public synchronized void setAlignment(int alignment)
+ {
+ if (alignment != CENTER && alignment != LEFT && alignment != RIGHT)
+ throw new IllegalArgumentException("invalid alignment: " + alignment);
+ this.alignment = alignment;
+ if (peer != null)
+ {
+ LabelPeer lp = (LabelPeer) peer;
+ lp.setAlignment(alignment);
+ }
+ }
-/*************************************************************************/
+ /**
+ * Returns the text displayed in this label.
+ *
+ * @return The text for this label.
+ */
+ public String getText()
+ {
+ return text;
+ }
-/*
- * Instance Variables
- */
+ /**
+ * Sets the text in this label to the specified value.
+ *
+ * @param text The new text for this label.
+ */
+ public synchronized void setText(String text)
+ {
+ if ((this.text == null && text != null)
+ || (this.text != null && ! this.text.equals(text)))
+ {
+ this.text = text;
+
+ if (peer != null)
+ {
+ LabelPeer lp = (LabelPeer) peer;
+ lp.setText(text);
+ }
+ invalidate();
+ }
+ }
-/**
- * Returns the constant indicating the alignment of the text in this
- * label. The value returned will be one of the alignment constants
- * from this class.
- *
- * @return The alignment of the text in the label.
- */
-public int
-getAlignment()
-{
- return(alignment);
-}
+ /**
+ * Notifies this label that it has been added to a container, causing
+ * the peer to be created. This method is called internally by the AWT
+ * system.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createLabel(this);
+ super.addNotify();
+ }
-/*************************************************************************/
+ /**
+ * Returns a parameter string useful for debugging.
+ *
+ * @return A debugging string.
+ */
+ protected String paramString()
+ {
+ return ("text=" + getText() + ",alignment=" +
+ getAlignment() + "," + super.paramString());
+ }
-/**
- * Sets the text alignment of this label to the specified value.
- *
- * @param alignment The desired alignment for the text in this label,
- * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
- * <code>RIGHT</code>.
- */
-public synchronized void
-setAlignment(int alignment)
-{
- if (alignment != CENTER && alignment != LEFT && alignment != RIGHT)
- throw new IllegalArgumentException ("invalid alignment: " + alignment);
- this.alignment = alignment;
- if (peer != null)
+ /**
+ * This class provides accessibility support for the label.
+ */
+ protected class AccessibleAWTLabel
+ extends AccessibleAWTComponent
+ {
+ /**
+ * For compatability with Sun's JDK 1.4.2 rev. 5
+ */
+ private static final long serialVersionUID = -3568967560160480438L;
+
+ /**
+ * Constructor for the accessible label.
+ */
+ public AccessibleAWTLabel()
{
- LabelPeer lp = (LabelPeer) peer;
- lp.setAlignment (alignment);
}
-}
-
-/*************************************************************************/
-
-/**
- * Returns the text displayed in this label.
- *
- * @return The text for this label.
- */
-public String
-getText()
-{
- return(text);
-}
-
-/*************************************************************************/
-/**
- * Sets the text in this label to the specified value.
- *
- * @param text The new text for this label.
- */
-public synchronized void
-setText(String text)
-{
- if ((this.text == null && text != null)
- || (this.text != null && ! this.text.equals(text)))
+ /**
+ * Returns the accessible name for the label. This is
+ * the text used in the label.
+ *
+ * @return a <code>String</code> containing the accessible
+ * name for this label.
+ */
+ public String getAccessibleName()
{
- this.text = text;
-
- if (peer != null)
- {
- LabelPeer lp = (LabelPeer) peer;
- lp.setText (text);
- }
- invalidate();
+ return getText();
}
-}
-
-/*************************************************************************/
-
-/**
- * Notifies this label that it has been added to a container, causing
- * the peer to be created. This method is called internally by the AWT
- * system.
- */
-public void
-addNotify()
-{
- if (peer == null)
- peer = getToolkit ().createLabel (this);
- super.addNotify ();
-}
-/*************************************************************************/
-
-/**
- * Returns a parameter string useful for debugging.
- *
- * @return A debugging string.
- */
-protected String
-paramString()
-{
- return ("text=" + getText() + ",alignment=" +
- getAlignment() + "," + super.paramString());
-}
+ /**
+ * Returns the accessible role for the label.
+ *
+ * @return an instance of <code>AccessibleRole</code>, describing
+ * the role of the label.
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.LABEL;
+ }
-/**
- * This class provides accessibility support for the label.
- */
-protected class AccessibleAWTLabel
- extends AccessibleAWTComponent
-{
- /**
- * For compatability with Sun's JDK 1.4.2 rev. 5
- */
- private static final long serialVersionUID = -3568967560160480438L;
+ }
/**
- * Constructor for the accessible label.
+ * Gets the AccessibleContext associated with this <code>Label</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
*/
- public AccessibleAWTLabel()
+ public AccessibleContext getAccessibleContext()
{
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTLabel();
+ return accessibleContext;
}
/**
- * Returns the accessible name for the label. This is
- * the text used in the label.
+ * Generate a unique name for this button.
*
- * @return a <code>String</code> containing the accessible
- * name for this label.
+ * @return A unique name for this button.
*/
- public String getAccessibleName()
+ String generateName()
{
- return getText();
+ return "label" + getUniqueLong();
}
-
+
/**
- * Returns the accessible role for the label.
- *
- * @return an instance of <code>AccessibleRole</code>, describing
- * the role of the label.
+ * The number used to generate the name returned by getName.
*/
- public AccessibleRole getAccessibleRole()
+ private static transient long nextLabelNumber;
+
+ private static synchronized long getUniqueLong()
{
- return AccessibleRole.LABEL;
+ return nextLabelNumber++;
}
}
-/**
- * Gets the AccessibleContext associated with this <code>Label</code>.
- * The context is created, if necessary.
- *
- * @return the associated context
- */
-public AccessibleContext getAccessibleContext()
-{
- /* Create the context if this is the first request */
- if (accessibleContext == null)
- accessibleContext = new AccessibleAWTLabel();
- return accessibleContext;
-}
-
-} // class Label
-
diff --git a/libjava/classpath/java/awt/LightweightDispatcher.java b/libjava/classpath/java/awt/LightweightDispatcher.java
index 7e33bd4e9ce..3ea3f90a643 100644
--- a/libjava/classpath/java/awt/LightweightDispatcher.java
+++ b/libjava/classpath/java/awt/LightweightDispatcher.java
@@ -152,8 +152,11 @@ class LightweightDispatcher
target = findTarget(parent, loc);
while (target == null && parent != null)
{
- if (parent.getMouseListeners().length > 0
- || parent.getMouseMotionListeners().length > 0)
+ if (parent.mouseListener != null
+ || parent.mouseMotionListener != null
+ || (parent.eventMask
+ & (AWTEvent.MOUSE_EVENT_MASK
+ | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0)
{
target = parent;
}
@@ -175,24 +178,22 @@ class LightweightDispatcher
new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
ev.getClickCount(), ev.isPopupTrigger());
+ //System.err.println("event: " + mouseExited);
lastTarget.dispatchEvent(mouseExited);
}
- // If a target exists dispatch the MOUSE_ENTERED event only if
- // there is currently no component from which a drag operation
- // started (dragTarget == null) or the target is that component
- // (dragTarget == target)
- // That way a user can click and hold on a button (putting it into
- // the armed state), move the cursor above other buttons without
- // affecting their rollover state and get back to the initial
- // button.
- if (target != null && (dragTarget == null || dragTarget == target))
+ // If a target exists dispatch the MOUSE_ENTERED event.
+ // Experimenting shows that the MOUSE_ENTERED is also dispatched
+ // when the mouse is dragging.
+ if (target != null)
{
Point p = convertPointToChild(window, ev.getPoint(), target);
MouseEvent mouseEntered =
- new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
+ new MouseEvent(target,
+ MouseEvent.MOUSE_ENTERED, ev.getWhen(),
ev.getModifiers(), p.x, p.y, ev.getClickCount(),
ev.isPopupTrigger());
+ //System.err.println("event: " + mouseEntered);
target.dispatchEvent(mouseEntered);
}
}
@@ -219,7 +220,11 @@ class LightweightDispatcher
// it was released.
if (dragTarget != null && dragButton == ev.getButton())
{
- target = dragTarget;
+ // Only post MOUSE_RELEASED to dragTarget (set in
+ // MOUSE_PRESSED) when the dragTarget is actually visible.
+ // Otherwise post the event to the normal target.
+ if (dragTarget.isVisible())
+ target = dragTarget;
dragTarget = null;
}
@@ -287,18 +292,21 @@ class LightweightDispatcher
*/
private Component findTarget(Container c, Point loc)
{
- Component[] children = c.getComponents();
+ int numComponents = c.getComponentCount();
Component target = null;
if (c != null)
{
- for (int i = 0; i < children.length; i++)
+ for (int i = 0; i < numComponents; i++)
{
- Component child = children[i];
+ Component child = c.getComponent(i);
if (child.isShowing())
{
if (child.contains(loc.x - child.getX(), loc.y - child.getY())
- && (child.getMouseListeners().length > 0
- || child.getMouseMotionListeners().length > 0))
+ && (child.mouseListener != null
+ || child.mouseMotionListener != null
+ || (child.eventMask
+ & (AWTEvent.MOUSE_EVENT_MASK
+ | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0))
{
target = child;
break;
diff --git a/libjava/classpath/java/awt/List.java b/libjava/classpath/java/awt/List.java
index b28e2016d2e..86270234345 100644
--- a/libjava/classpath/java/awt/List.java
+++ b/libjava/classpath/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;
@@ -161,7 +166,11 @@ List(int rows)
public
List(int rows, boolean multipleMode)
{
- this.rows = rows;
+ if (rows == 0)
+ this.rows = 4;
+ else
+ this.rows = rows;
+
this.multipleMode = multipleMode;
selected = new int[0];
@@ -645,13 +654,13 @@ clear()
* @param item The new item value.
* @param index The index of the item to replace.
*
- * @exception IllegalArgumentException If the index is not valid.
+ * @exception ArrayIndexOutOfBoundsException If the index is not valid.
*/
public synchronized void
-replaceItem(String item, int index) throws IllegalArgumentException
+replaceItem(String item, int index) throws ArrayIndexOutOfBoundsException
{
if ((index < 0) || (index >= items.size()))
- throw new IllegalArgumentException("Bad list index: " + index);
+ throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);
items.insertElementAt(item, index + 1);
items.removeElementAt (index);
@@ -818,15 +827,11 @@ isSelected(int index)
/**
* This method ensures that the item at the specified index is visible.
*
- * @exception IllegalArgumentException If the specified index is out of
- * range.
+ * @param index The index of the item to be made visible.
*/
public synchronized void
makeVisible(int index) throws IllegalArgumentException
{
- if ((index < 0) || (index >= items.size()))
- throw new IllegalArgumentException("Bad list index: " + index);
-
visibleIndex = index;
if (peer != null)
{
@@ -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/libjava/classpath/java/awt/Menu.java b/libjava/classpath/java/awt/Menu.java
index 6daec72cf44..f900d929574 100644
--- a/libjava/classpath/java/awt/Menu.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/MenuBar.java b/libjava/classpath/java/awt/MenuBar.java
index 3c6b915649f..bd658cde6e3 100644
--- a/libjava/classpath/java/awt/MenuBar.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/MenuComponent.java b/libjava/classpath/java/awt/MenuComponent.java
index 9bb875069e0..163092685e7 100644
--- a/libjava/classpath/java/awt/MenuComponent.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/MenuItem.java b/libjava/classpath/java/awt/MenuItem.java
index a7ac79643be..7cbc9219f54 100644
--- a/libjava/classpath/java/awt/MenuItem.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/MouseInfo.java b/libjava/classpath/java/awt/MouseInfo.java
new file mode 100644
index 00000000000..957b6bccbef
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Point.java b/libjava/classpath/java/awt/Point.java
index 31b72e2cc75..64bc07eaf72 100644
--- a/libjava/classpath/java/awt/Point.java
+++ b/libjava/classpath/java/awt/Point.java
@@ -1,5 +1,5 @@
/* Point.java -- represents a point in 2-D space
- Copyright (C) 1999, 2002 Free Software Foundation
+ Copyright (C) 1999, 2002, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -83,7 +83,7 @@ public class Point extends Point2D implements Serializable
/**
* Initializes a new instance of <code>Point</code> representing the
- * coordiates (0,0).
+ * coordinates (0, 0).
*
* @since 1.1
*/
@@ -93,7 +93,7 @@ public class Point extends Point2D implements Serializable
/**
* Initializes a new instance of <code>Point</code> with coordinates
- * identical to the coordinates of the specified points.
+ * identical to the coordinates of the specified point.
*
* @param p the point to copy the coordinates from
* @throws NullPointerException if p is null
@@ -178,15 +178,16 @@ public class Point extends Point2D implements Serializable
/**
* Sets this object's coordinates to the specified values. This method
- * performs normal casting from double to int, so you may lose precision.
+ * rounds to the nearest integer coordinates by adding 0.5 and calling
+ * {@link Math#floor(double)}.
*
* @param x the new X coordinate
* @param y the new Y coordinate
*/
public void setLocation(double x, double y)
{
- this.x = (int) x;
- this.y = (int) y;
+ this.x = (int) Math.floor(x + 0.5);
+ this.y = (int) Math.floor(y + 0.5);
}
/**
diff --git a/libjava/classpath/java/awt/PointerInfo.java b/libjava/classpath/java/awt/PointerInfo.java
new file mode 100644
index 00000000000..14d44a69b3f
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/java/awt/PopupMenu.java b/libjava/classpath/java/awt/PopupMenu.java
index 540fffda718..9268678026d 100644
--- a/libjava/classpath/java/awt/PopupMenu.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/ScrollPane.java b/libjava/classpath/java/awt/ScrollPane.java
index 525d9d3e7da..65ce484b88d 100644
--- a/libjava/classpath/java/awt/ScrollPane.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/Shape.java b/libjava/classpath/java/awt/Shape.java
index bd8a4343528..d76bbaba69d 100644
--- a/libjava/classpath/java/awt/Shape.java
+++ b/libjava/classpath/java/awt/Shape.java
@@ -1,5 +1,5 @@
/* Shape.java -- the classic Object-Oriented shape interface
- Copyright (C) 1999, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -176,7 +176,8 @@ public interface Shape
* not required, that the Shape isolate iterations from future changes to
* the boundary, and document this fact.
*
- * @param transform an optional transform to apply to the iterator
+ * @param transform an optional transform to apply to the
+ * iterator (<code>null</code> permitted).
* @return a new iterator over the boundary
* @since 1.2
*/
@@ -185,7 +186,7 @@ public interface Shape
/**
* Return an iterator along the flattened version of the shape boundary.
* Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE points are returned in the
- * iterator. The flatness paramter controls how far points are allowed to
+ * iterator. The flatness parameter controls how far points are allowed to
* differ from the real curve; although a limit on accuracy may cause this
* parameter to be enlarged if needed.
*
@@ -194,10 +195,11 @@ public interface Shape
* use. It is recommended, but not required, that the Shape isolate
* iterations from future changes to the boundary, and document this fact.
*
- * @param transform an optional transform to apply to the iterator
+ * @param transform an optional transform to apply to the
+ * iterator (<code>null</code> permitted).
* @param flatness the maximum distance for deviation from the real boundary
* @return a new iterator over the boundary
* @since 1.2
*/
PathIterator getPathIterator(AffineTransform transform, double flatness);
-} // interface Shape
+}
diff --git a/libjava/classpath/java/awt/TextArea.java b/libjava/classpath/java/awt/TextArea.java
index b04cdc89204..7e3463ab849 100644
--- a/libjava/classpath/java/awt/TextArea.java
+++ b/libjava/classpath/java/awt/TextArea.java
@@ -125,9 +125,11 @@ public class TextArea extends TextComponent implements java.io.Serializable
* the specified text. Conceptually the <code>TextArea</code> has 0
* rows and 0 columns but its initial bounds are defined by its peer
* or by the container in which it is packed. Both horizontal and
- * veritcal scrollbars will be displayed.
+ * veritcal scrollbars will be displayed. The TextArea initially contains
+ * the specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
@@ -156,9 +158,10 @@ public class TextArea extends TextComponent implements java.io.Serializable
* Initialize a new instance of <code>TextArea</code> that can
* display the specified number of rows and columns of text, without
* the need to scroll. The TextArea initially contains the
- * specified text.
+ * specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
@@ -174,9 +177,10 @@ public class TextArea extends TextComponent implements java.io.Serializable
* contains the specified text. The TextArea can display the
* specified number of rows and columns of text, without the need to
* scroll. This constructor allows specification of the scroll bar
- * display policy.
+ * display policy. The TextArea initially contains the specified text.
+ * If text specified as <code>null<code>, it will be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
* @param scrollbarVisibility The scroll bar display policy. One of
@@ -192,18 +196,20 @@ public class TextArea extends TextComponent implements java.io.Serializable
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
- if (rows < 0 || columns < 0)
- throw new IllegalArgumentException ("Bad row or column value");
-
- if (scrollbarVisibility != SCROLLBARS_BOTH
- && scrollbarVisibility != SCROLLBARS_VERTICAL_ONLY
- && scrollbarVisibility != SCROLLBARS_HORIZONTAL_ONLY
- && scrollbarVisibility != SCROLLBARS_NONE)
- throw new IllegalArgumentException ("Bad scrollbar visibility value");
+ if (rows < 0)
+ this.rows = 0;
+ else
+ this.rows = rows;
+
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
- this.rows = rows;
- this.columns = columns;
- this.scrollbarVisibility = scrollbarVisibility;
+ if (scrollbarVisibility < 0 || scrollbarVisibility > 4)
+ this.scrollbarVisibility = SCROLLBARS_BOTH;
+ else
+ this.scrollbarVisibility = scrollbarVisibility;
// TextAreas need to receive tab key events so we override the
// default forward and backward traversal key sets.
@@ -478,6 +484,8 @@ public class TextArea extends TextComponent implements java.io.Serializable
if (peer != null)
peer.insert (str, peer.getText().length ());
+ else
+ setText(getText() + str);
}
/**
@@ -504,10 +512,19 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public void insertText (String str, int pos)
{
+ String tmp1 = null;
+ String tmp2 = null;
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer != null)
peer.insert (str, pos);
+ else
+ {
+ tmp1 = getText().substring(0, pos);
+ tmp2 = getText().substring(pos, getText().length());
+ setText(tmp1 + str + tmp2);
+ }
}
/**
@@ -544,10 +561,19 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public void replaceText (String str, int start, int end)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ String tmp1 = null;
+ String tmp2 = null;
+
+ TextAreaPeer peer = (TextAreaPeer) getPeer();
if (peer != null)
- peer.replaceRange (str, start, end);
+ peer.replaceRange(str, start, end);
+ else
+ {
+ tmp1 = getText().substring(0, start);
+ tmp2 = getText().substring(end, getText().length());
+ setText(tmp1 + str + tmp2);
+ }
}
/**
diff --git a/libjava/classpath/java/awt/TextComponent.java b/libjava/classpath/java/awt/TextComponent.java
index f08e59c9fc9..f811122f2b2 100644
--- a/libjava/classpath/java/awt/TextComponent.java
+++ b/libjava/classpath/java/awt/TextComponent.java
@@ -1,5 +1,5 @@
/* TextComponent.java -- Widgets for entering text
- Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,54 +54,45 @@ import javax.accessibility.AccessibleText;
import javax.swing.text.AttributeSet;
/**
- * This class provides common functionality for widgets than
- * contain text.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
+ * This class provides common functionality for widgets than
+ * contain text.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public class TextComponent extends Component
implements Serializable, Accessible
{
-/*
- * Static Variables
- */
-
-// Constant for serialization
-private static final long serialVersionUID = -2214773872412987419L;
+ private static final long serialVersionUID = -2214773872412987419L;
-/*
- * Instance Variables
- */
-
-/**
- * @serial Indicates whether or not this component is editable.
- * This is package-private to avoid an accessor method.
- */
-boolean editable;
+ /**
+ * @serial Indicates whether or not this component is editable.
+ * This is package-private to avoid an accessor method.
+ */
+ boolean editable;
-/**
- * @serial The starting position of the selected text region.
- * This is package-private to avoid an accessor method.
- */
-int selectionStart;
+ /**
+ * @serial The starting position of the selected text region.
+ * This is package-private to avoid an accessor method.
+ */
+ int selectionStart;
-/**
- * @serial The ending position of the selected text region.
- * This is package-private to avoid an accessor method.
- */
-int selectionEnd;
+ /**
+ * @serial The ending position of the selected text region.
+ * This is package-private to avoid an accessor method.
+ */
+ int selectionEnd;
-/**
- * @serial The text in the component
- * This is package-private to avoid an accessor method.
- */
-String text;
+ /**
+ * @serial The text in the component
+ * This is package-private to avoid an accessor method.
+ */
+ String text;
-/**
- * A list of listeners that will receive events from this object.
- */
-protected transient TextListener textListener;
+ /**
+ * A list of listeners that will receive events from this object.
+ */
+ protected transient TextListener textListener;
protected class AccessibleAWTTextComponent
extends AccessibleAWTComponent
@@ -318,360 +309,298 @@ protected transient TextListener textListener;
}
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-TextComponent(String text)
-{
- this.text = text;
- this.editable = true;
-}
-
-/*************************************************************************/
-/*
- * Instance Methods
- */
-
-/**
- * Returns the text in this component
- *
- * @return The text in this component.
- */
-public synchronized String
-getText()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- text = tcp.getText();
+ TextComponent(String text)
+ {
+ if (text == null)
+ this.text = "";
+ else
+ this.text = text;
+
+ this.editable = true;
+ }
- return(text);
-}
-/*************************************************************************/
+ /**
+ * Returns the text in this component
+ *
+ * @return The text in this component.
+ */
+ public synchronized String getText()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ text = tcp.getText();
-/**
- * Sets the text in this component to the specified string.
- *
- * @param text The new text for this component.
- */
-public synchronized void
-setText(String text)
-{
- if (text == null)
- text = "";
+ return(text);
+ }
- this.text = text;
+ /**
+ * Sets the text in this component to the specified string.
+ *
+ * @param text The new text for this component.
+ */
+ public synchronized void setText(String text)
+ {
+ if (text == null)
+ text = "";
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- tcp.setText(text);
- setCaretPosition(0);
-}
+ this.text = text;
-/*************************************************************************/
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setText(text);
+ setCaretPosition(0);
+ }
-/**
- * Returns a string that contains the text that is currently selected.
- *
- * @return The currently selected text region.
- */
-public synchronized String
-getSelectedText()
-{
- String alltext = getText();
- int start = getSelectionStart();
- int end = getSelectionEnd();
+ /**
+ * Returns a string that contains the text that is currently selected.
+ *
+ * @return The currently selected text region.
+ */
+ public synchronized String getSelectedText()
+ {
+ String alltext = getText();
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
- return(alltext.substring(start, end));
-}
-
-/*************************************************************************/
-
-/**
- * Returns the starting position of the selected text region.
- * If the text is not selected then caret position is returned.
- *
- * @return The starting position of the selected text region.
- */
-public synchronized int
-getSelectionStart()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- selectionStart = tcp.getSelectionStart();
-
- return(selectionStart);
-}
-
-/*************************************************************************/
-
-/**
- * Sets the starting position of the selected region to the
- * specified value. If the specified value is out of range, then it
- * will be silently changed to the nearest legal value.
- *
- * @param selectionStart The new start position for selected text.
- */
-public synchronized void
-setSelectionStart(int selectionStart)
-{
- select(selectionStart, getSelectionEnd());
-}
-
-/*************************************************************************/
-
-/**
- * Returns the ending position of the selected text region.
- * If the text is not selected, then caret position is returned
- *
- * @return The ending position of the selected text region.
- */
-public synchronized int
-getSelectionEnd()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- selectionEnd = tcp.getSelectionEnd();
-
- return(selectionEnd);
-}
+ return(alltext.substring(start, end));
+ }
-/*************************************************************************/
+ /**
+ * Returns the starting position of the selected text region.
+ * If the text is not selected then caret position is returned.
+ *
+ * @return The starting position of the selected text region.
+ */
+ public synchronized int getSelectionStart()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ selectionStart = tcp.getSelectionStart();
-/**
- * Sets the ending position of the selected region to the
- * specified value. If the specified value is out of range, then it
- * will be silently changed to the nearest legal value.
- *
- * @param selectionEnd The new start position for selected text.
- */
-public synchronized void
-setSelectionEnd(int selectionEnd)
-{
- select(getSelectionStart(), selectionEnd);
-}
+ return(selectionStart);
+ }
-/*************************************************************************/
+ /**
+ * Sets the starting position of the selected region to the
+ * specified value. If the specified value is out of range, then it
+ * will be silently changed to the nearest legal value.
+ *
+ * @param selectionStart The new start position for selected text.
+ */
+ public synchronized void setSelectionStart(int selectionStart)
+ {
+ select(selectionStart, getSelectionEnd());
+ }
-/**
- * This method sets the selected text range to the text between the
- * specified start and end positions. Illegal values for these
- * positions are silently fixed.
- *
- * @param selectionStart The new start position for the selected text.
- * @param selectionEnd The new end position for the selected text.
- */
-public synchronized void
-select(int selectionStart, int selectionEnd)
-{
- if (selectionStart < 0)
- selectionStart = 0;
+ /**
+ * Returns the ending position of the selected text region.
+ * If the text is not selected, then caret position is returned
+ *
+ * @return The ending position of the selected text region.
+ */
+ public synchronized int getSelectionEnd()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ selectionEnd = tcp.getSelectionEnd();
- if (selectionStart > getText().length())
- selectionStart = text.length();
+ return(selectionEnd);
+ }
- if (selectionEnd > text.length())
- selectionEnd = text.length();
+ /**
+ * Sets the ending position of the selected region to the
+ * specified value. If the specified value is out of range, then it
+ * will be silently changed to the nearest legal value.
+ *
+ * @param selectionEnd The new start position for selected text.
+ */
+ public synchronized void setSelectionEnd(int selectionEnd)
+ {
+ select(getSelectionStart(), selectionEnd);
+ }
- if (selectionStart > selectionEnd)
- selectionStart = selectionEnd;
+ /**
+ * This method sets the selected text range to the text between the
+ * specified start and end positions. Illegal values for these
+ * positions are silently fixed.
+ *
+ * @param selectionStart The new start position for the selected text.
+ * @param selectionEnd The new end position for the selected text.
+ */
+ public synchronized void select(int selectionStart, int selectionEnd)
+ {
+ if (selectionStart < 0)
+ selectionStart = 0;
- this.selectionStart = selectionStart;
- this.selectionEnd = selectionEnd;
+ if (selectionStart > getText().length())
+ selectionStart = text.length();
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- tcp.select(selectionStart, selectionEnd);
-}
+ if (selectionEnd > text.length())
+ selectionEnd = text.length();
-/*************************************************************************/
+ if (selectionStart > selectionEnd)
+ selectionStart = selectionEnd;
-/**
- * Selects all of the text in the component.
- */
-public synchronized void
-selectAll()
-{
- select(0, getText().length());
-}
-
-/*************************************************************************/
+ this.selectionStart = selectionStart;
+ this.selectionEnd = selectionEnd;
+
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.select(selectionStart, selectionEnd);
+ }
-/**
- * Returns the current caret position in the text.
- *
- * @return The caret position in the text.
- */
-public synchronized int
-getCaretPosition()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- return(tcp.getCaretPosition());
- else
- return(0);
-}
+ /**
+ * Selects all of the text in the component.
+ */
+ public synchronized void selectAll()
+ {
+ select(0, getText().length());
+ }
-/*************************************************************************/
+ /**
+ * Returns the current caret position in the text.
+ *
+ * @return The caret position in the text.
+ */
+ public synchronized int getCaretPosition()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ return(tcp.getCaretPosition());
+ else
+ return(0);
+ }
-/**
- * Sets the caret position to the specified value.
- *
- * @param caretPosition The new caret position.
- *
- * @exception IllegalArgumentException If the value supplied for position
- * is less than zero.
- *
- * @since 1.1
- */
-public synchronized void
-setCaretPosition(int caretPosition)
-{
- if (caretPosition < 0)
- throw new IllegalArgumentException ();
+ /**
+ * Sets the caret position to the specified value.
+ *
+ * @param caretPosition The new caret position.
+ *
+ * @exception IllegalArgumentException If the value supplied for position
+ * is less than zero.
+ *
+ * @since 1.1
+ */
+ public synchronized void setCaretPosition(int caretPosition)
+ {
+ if (caretPosition < 0)
+ throw new IllegalArgumentException();
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- tcp.setCaretPosition(caretPosition);
-}
-
-/*************************************************************************/
-
-/**
- * Tests whether or not this component's text can be edited.
- *
- * @return <code>true</code> if the text can be edited, <code>false</code>
- * otherwise.
- */
-public boolean
-isEditable()
-{
- return(editable);
-}
-
-/*************************************************************************/
-
-/**
- * Sets whether or not this component's text can be edited.
- *
- * @param editable <code>true</code> to enable editing of the text,
- * <code>false</code> to disable it.
- */
-public synchronized void
-setEditable(boolean editable)
-{
- this.editable = editable;
-
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
- if (tcp != null)
- tcp.setEditable(editable);
-}
-
-/*************************************************************************/
-
-/**
- * Notifies the component that it should destroy its native peer.
- */
-public void
-removeNotify()
-{
- super.removeNotify();
-}
-
-/*************************************************************************/
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setCaretPosition(caretPosition);
+ }
-/**
- * Adds a new listener to the list of text listeners for this
- * component.
- *
- * @param listener The listener to be added.
- */
-public synchronized void
-addTextListener(TextListener listener)
-{
- textListener = AWTEventMulticaster.add(textListener, listener);
+ /**
+ * Tests whether or not this component's text can be edited.
+ *
+ * @return <code>true</code> if the text can be edited, <code>false</code>
+ * otherwise.
+ */
+ public boolean isEditable()
+ {
+ return(editable);
+ }
- enableEvents(AWTEvent.TEXT_EVENT_MASK);
-}
+ /**
+ * Sets whether or not this component's text can be edited.
+ *
+ * @param editable <code>true</code> to enable editing of the text,
+ * <code>false</code> to disable it.
+ */
+ public synchronized void setEditable(boolean editable)
+ {
+ this.editable = editable;
-/*************************************************************************/
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setEditable(editable);
+ }
-/**
- * Removes the specified listener from the list of listeners
- * for this component.
- *
- * @param listener The listener to remove.
- */
-public synchronized void
-removeTextListener(TextListener listener)
-{
- textListener = AWTEventMulticaster.remove(textListener, listener);
-}
+ /**
+ * Notifies the component that it should destroy its native peer.
+ */
+ public void removeNotify()
+ {
+ super.removeNotify();
+ }
-/*************************************************************************/
+ /**
+ * Adds a new listener to the list of text listeners for this
+ * component.
+ *
+ * @param listener The listener to be added.
+ */
+ public synchronized void addTextListener(TextListener listener)
+ {
+ textListener = AWTEventMulticaster.add(textListener, listener);
-/**
- * Processes the specified event for this component. Text events are
- * processed by calling the <code>processTextEvent()</code> method.
- * All other events are passed to the superclass method.
- *
- * @param event The event to process.
- */
-protected void
-processEvent(AWTEvent event)
-{
- if (event instanceof TextEvent)
- processTextEvent((TextEvent)event);
- else
- super.processEvent(event);
-}
+ enableEvents(AWTEvent.TEXT_EVENT_MASK);
+ }
-/*************************************************************************/
+ /**
+ * Removes the specified listener from the list of listeners
+ * for this component.
+ *
+ * @param listener The listener to remove.
+ */
+ public synchronized void removeTextListener(TextListener listener)
+ {
+ textListener = AWTEventMulticaster.remove(textListener, listener);
+ }
-/**
- * Processes the specified text event by dispatching it to any listeners
- * that are registered. Note that this method will only be called
- * if text event's are enabled. This will be true if there are any
- * registered listeners, or if the event has been specifically
- * enabled using <code>enableEvents()</code>.
- *
- * @param event The text event to process.
- */
-protected void
-processTextEvent(TextEvent event)
-{
- if (textListener != null)
- textListener.textValueChanged(event);
-}
+ /**
+ * Processes the specified event for this component. Text events are
+ * processed by calling the <code>processTextEvent()</code> method.
+ * All other events are passed to the superclass method.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof TextEvent)
+ processTextEvent((TextEvent)event);
+ else
+ super.processEvent(event);
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
- if (e.id <= TextEvent.TEXT_LAST
- && e.id >= TextEvent.TEXT_FIRST
- && (textListener != null
- || (eventMask & AWTEvent.TEXT_EVENT_MASK) != 0))
- processEvent(e);
- else
- super.dispatchEventImpl(e);
-}
+ /**
+ * Processes the specified text event by dispatching it to any listeners
+ * that are registered. Note that this method will only be called
+ * if text event's are enabled. This will be true if there are any
+ * registered listeners, or if the event has been specifically
+ * enabled using <code>enableEvents()</code>.
+ *
+ * @param event The text event to process.
+ */
+ protected void processTextEvent(TextEvent event)
+ {
+ if (textListener != null)
+ textListener.textValueChanged(event);
+ }
-/*************************************************************************/
+ void dispatchEventImpl(AWTEvent e)
+ {
+ if (e.id <= TextEvent.TEXT_LAST
+ && e.id >= TextEvent.TEXT_FIRST
+ && (textListener != null
+ || (eventMask & AWTEvent.TEXT_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
-/**
- * Returns a debugging string.
- *
- * @return A debugging string.
- */
-protected String
-paramString()
-{
- return(getClass().getName() + "(text=" + getText() + ")");
-}
+ /**
+ * Returns a debugging string.
+ *
+ * @return A debugging string.
+ */
+ protected String paramString()
+ {
+ return(getClass().getName() + "(text=" + getText() + ")");
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -681,20 +610,20 @@ paramString()
* @exception ClassCastException If listenerType doesn't specify a class or
* interface that implements java.util.EventListener.
*/
- public EventListener[] getListeners (Class listenerType)
+ public EventListener[] getListeners(Class listenerType)
{
if (listenerType == TextListener.class)
- return AWTEventMulticaster.getListeners (textListener, listenerType);
+ return AWTEventMulticaster.getListeners(textListener, listenerType);
- return super.getListeners (listenerType);
+ return super.getListeners(listenerType);
}
/**
* Returns all text listeners registered to this object.
*/
- public TextListener[] getTextListeners ()
+ public TextListener[] getTextListeners()
{
- return (TextListener[]) getListeners (TextListener.class);
+ return (TextListener[]) getListeners(TextListener.class);
}
/**
@@ -712,30 +641,35 @@ paramString()
}
- /*******************************/
// Provide AccessibleAWTTextComponent access to several peer functions that
// aren't publicly exposed. This is package-private to avoid an accessor
// method.
- synchronized int
- getIndexAtPoint(Point p)
+ synchronized int getIndexAtPoint(Point p)
{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return tcp.getIndexAtPoint(p.x, p.y);
return -1;
}
- synchronized Rectangle
- getCharacterBounds(int i)
+ synchronized Rectangle getCharacterBounds(int i)
{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return tcp.getCharacterBounds(i);
return null;
}
-
-
+ /**
+ * All old mouse events for this component should
+ * be ignored.
+ *
+ * @return true to ignore all old mouse events.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return true;
+ }
} // class TextComponent
diff --git a/libjava/classpath/java/awt/TextField.java b/libjava/classpath/java/awt/TextField.java
index 23d3d918ff4..b76f393a0b6 100644
--- a/libjava/classpath/java/awt/TextField.java
+++ b/libjava/classpath/java/awt/TextField.java
@@ -1,5 +1,5 @@
/* TextField.java -- A one line text entry field
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,450 +48,369 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleStateSet;
/**
- * This class implements a single line text entry field widget
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public class TextField extends TextComponent
-{
-
-/*
- * Static Variables
- */
-
-// Serialization constant
-private static final long serialVersionUID = -2966288784432217853L;
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * @serial The number of columns in the text entry field.
- */
-private int columns;
-
-/**
- * @serial The character that is echoed when doing protected input
- */
-private char echoChar;
-
-// List of registered ActionListener's for this object.
-private ActionListener action_listeners;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Initializes a new instance of <code>TextField</code> that is empty
- * and has one column.
+ * This class implements a single line text entry field widget
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
- */
-public
-TextField()
-{
- this("", 1);
-}
-
-/*************************************************************************/
-
-/**
- * Initializes a new instance of <code>TextField</code> containing
- * the specified text. The number of columns will be equal to the
- * length of the text string.
- *
- * @param text The text to display in the field.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
- */
-public
-TextField(String text)
-{
- this(text, text.length());
-}
-
-/*************************************************************************/
-
-/**
- * Initializes a new instance of <code>TextField</code> that is empty
- * and has the specified number of columns.
- *
- * @param columns The number of columns in the text field.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
- */
-public
-TextField(int columns)
-{
- this("", columns);
-}
-
-/*************************************************************************/
-
-/**
- * Initializes a new instance of <code>TextField</code> with the
- * specified text and number of columns.
- *
- * @param text The text to display in the field.
- * @param columns The number of columns in the field.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
- */
-public
-TextField(String text, int columns)
-{
- super(text);
- this.columns = columns;
-
- if (GraphicsEnvironment.isHeadless())
- throw new HeadlessException ();
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/**
- * Returns the number of columns in the field.
- *
- * @return The number of columns in the field.
- */
-public int
-getColumns()
-{
- return(columns);
-}
-
-/*************************************************************************/
-
-/**
- * Sets the number of columns in this field to the specified value.
- *
- * @param columns The new number of columns in the field.
- *
- * @exception IllegalArgumentException If columns is less than zero.
- */
-public synchronized void
-setColumns(int columns)
-{
- if (columns < 0)
- throw new IllegalArgumentException("Value is less than zero: " +
- columns);
-
- this.columns = columns;
- // FIXME: How to we communicate this to our peer?
-}
-
-/*************************************************************************/
-
-/**
- * Returns the character that is echoed to the screen when a text
- * field is protected (such as when a password is being entered).
- *
- * @return The echo character for this text field.
- */
-public char
-getEchoChar()
-{
- return(echoChar);
-}
-
-/*************************************************************************/
-
-/**
- * Sets the character that is echoed when protected input such as
- * a password is displayed.
- *
- * @param echoChar The new echo character.
- */
-public void
-setEchoChar(char echoChar)
+public class TextField extends TextComponent
{
- setEchoCharacter (echoChar);
-}
-
-/*************************************************************************/
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_textfield_number;
-/**
- * Sets the character that is echoed when protected input such as
- * a password is displayed.
- *
- * @param echoChar The new echo character.
- *
- * @deprecated This method is deprecated in favor of
- * <code>setEchoChar()</code>
- */
-public void
-setEchoCharacter(char echoChar)
-{
- this.echoChar = echoChar;
+
+ private static final long serialVersionUID = -2966288784432217853L;
- TextFieldPeer peer = (TextFieldPeer) getPeer ();
- if (peer != null)
- peer.setEchoChar (echoChar);
-}
-/*************************************************************************/
+ /**
+ * @serial The number of columns in the text entry field.
+ */
+ private int columns;
-/**
- * Tests whether or not this text field has an echo character set
- * so that characters the user type are not echoed to the screen.
- *
- * @return <code>true</code> if an echo character is set,
- * <code>false</code> otherwise.
- */
-public boolean
-echoCharIsSet()
-{
- if (echoChar == '\u0000')
- return(false);
- else
- return(true);
-}
+ /**
+ * @serial The character that is echoed when doing protected input
+ */
+ private char echoChar;
-/*************************************************************************/
+ // List of registered ActionListener's for this object.
+ private ActionListener action_listeners;
-/**
- * Returns the minimum size for this text field.
- *
- * @return The minimum size for this text field.
- */
-public Dimension
-getMinimumSize()
-{
- return getMinimumSize (getColumns ());
-}
+ /**
+ * Initializes a new instance of <code>TextField</code> that is empty
+ * and has one column.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField()
+ {
+ this("", 0);
+ }
-/*************************************************************************/
+ /**
+ * Initializes a new instance of <code>TextField</code> containing
+ * the specified text. The number of columns will be equal to the
+ * length of the text string.
+ *
+ * @param text The text to display in the field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(String text)
+ {
+ this(text, (text == null) ? 0 : text.length());
+ }
-/**
- * Returns the minimum size of a text field with the specified number
- * of columns.
- *
- * @param columns The number of columns to get the minimum size for.
- */
-public Dimension
-getMinimumSize(int columns)
-{
- return minimumSize (columns);
-}
+ /**
+ * Initializes a new instance of <code>TextField</code> that is empty
+ * and has the specified number of columns.
+ *
+ * @param columns The number of columns in the text field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(int columns)
+ {
+ this("", columns);
+ }
-/*************************************************************************/
+ /**
+ * Initializes a new instance of <code>TextField</code> with the
+ * specified text and number of columns.
+ *
+ * @param text The text to display in the field.
+ * @param columns The number of columns in the field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(String text, int columns)
+ {
+ super(text);
+
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
-/**
- * Returns the minimum size for this text field.
- *
- * @return The minimum size for this text field.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getMinimumSize()</code>.
- */
-public Dimension
-minimumSize()
-{
- return minimumSize (getColumns ());
-}
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+ }
-/*************************************************************************/
+ /**
+ * Returns the number of columns in the field.
+ *
+ * @return The number of columns in the field.
+ */
+ public int getColumns()
+ {
+ return(columns);
+ }
-/**
- * Returns the minimum size of a text field with the specified number
- * of columns.
- *
- * @param columns The number of columns to get the minimum size for.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getMinimumSize(int)</code>.
- */
-public Dimension
-minimumSize(int columns)
-{
- TextFieldPeer peer = (TextFieldPeer) getPeer ();
- if (peer == null)
- return null; // FIXME: What do we do if there is no peer?
+ /**
+ * Sets the number of columns in this field to the specified value.
+ *
+ * @param columns The new number of columns in the field.
+ *
+ * @exception IllegalArgumentException If columns is less than zero.
+ */
+ public synchronized void setColumns(int columns)
+ {
+ if (columns < 0)
+ throw new IllegalArgumentException("Value is less than zero: " +
+ columns);
- return peer.getMinimumSize (columns);
-}
+ this.columns = columns;
+ // FIXME: How to we communicate this to our peer?
+ }
-/*************************************************************************/
+ /**
+ * Returns the character that is echoed to the screen when a text
+ * field is protected (such as when a password is being entered).
+ *
+ * @return The echo character for this text field.
+ */
+ public char getEchoChar()
+ {
+ return(echoChar);
+ }
-/**
- * Returns the preferred size for this text field.
- *
- * @return The preferred size for this text field.
- */
-public Dimension
-getPreferredSize()
-{
- return getPreferredSize (getColumns ());
-}
+ /**
+ * Sets the character that is echoed when protected input such as
+ * a password is displayed.
+ *
+ * @param echoChar The new echo character.
+ */
+ public void setEchoChar(char echoChar)
+ {
+ setEchoCharacter(echoChar);
+ }
-/*************************************************************************/
+ /**
+ * Sets the character that is echoed when protected input such as
+ * a password is displayed.
+ *
+ * @param echoChar The new echo character.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>setEchoChar()</code>
+ */
+ public void setEchoCharacter(char echoChar)
+ {
+ this.echoChar = echoChar;
-/**
- * Returns the preferred size of a text field with the specified number
- * of columns.
- *
- * @param columns The number of columns to get the preferred size for.
- */
-public Dimension
-getPreferredSize(int columns)
-{
- return preferredSize (columns);
-}
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer != null)
+ peer.setEchoChar (echoChar);
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this text field has an echo character set
+ * so that characters the user type are not echoed to the screen.
+ *
+ * @return <code>true</code> if an echo character is set,
+ * <code>false</code> otherwise.
+ */
+ public boolean echoCharIsSet()
+ {
+ if (echoChar == '\u0000')
+ return(false);
+ else
+ return(true);
+ }
-/**
- * Returns the preferred size for this text field.
- *
- * @return The preferred size for this text field.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getPreferredSize()</code>.
- */
-public Dimension
-preferredSize()
-{
- return preferredSize (getColumns ());
-}
+ /**
+ * Returns the minimum size for this text field.
+ *
+ * @return The minimum size for this text field.
+ */
+ public Dimension getMinimumSize()
+ {
+ return getMinimumSize (getColumns ());
+ }
-/*************************************************************************/
+ /**
+ * Returns the minimum size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the minimum size for.
+ */
+ public Dimension getMinimumSize(int columns)
+ {
+ return minimumSize(columns);
+ }
-/**
- * Returns the preferred size of a text field with the specified number
- * of columns.
- *
- * @param columns The number of columns to get the preferred size for.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getPreferredSize(int)</code>.
- */
-public Dimension
-preferredSize(int columns)
-{
- TextFieldPeer peer = (TextFieldPeer) getPeer ();
- if (peer == null)
- return new Dimension (0, 0);
+ /**
+ * Returns the minimum size for this text field.
+ *
+ * @return The minimum size for this text field.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize()</code>.
+ */
+ public Dimension minimumSize()
+ {
+ return minimumSize(getColumns ());
+ }
- return peer.getPreferredSize (columns);
-}
+ /**
+ * Returns the minimum size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the minimum size for.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize(int)</code>.
+ */
+ public Dimension minimumSize(int columns)
+ {
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return null; // FIXME: What do we do if there is no peer?
-/*************************************************************************/
+ return peer.getMinimumSize (columns);
+ }
-/**
- * Notifies this object that it should create its native peer.
- */
-public void
-addNotify()
-{
- if (getPeer() != null)
- return;
+ /**
+ * Returns the preferred size for this text field.
+ *
+ * @return The preferred size for this text field.
+ */
+ public Dimension getPreferredSize()
+ {
+ return getPreferredSize(getColumns ());
+ }
- setPeer((ComponentPeer)getToolkit().createTextField(this));
- super.addNotify();
-}
+ /**
+ * Returns the preferred size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the preferred size for.
+ */
+ public Dimension getPreferredSize(int columns)
+ {
+ return preferredSize(columns);
+ }
-/*************************************************************************/
+ /**
+ * Returns the preferred size for this text field.
+ *
+ * @return The preferred size for this text field.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize()</code>.
+ */
+ public Dimension preferredSize()
+ {
+ return preferredSize(getColumns ());
+ }
-/**
- * Addes a new listener to the list of action listeners for this
- * object.
- *
- * @param listener The listener to add to the list.
- */
-public synchronized void
-addActionListener(ActionListener listener)
-{
- action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+ /**
+ * Returns the preferred size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the preferred size for.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize(int)</code>.
+ */
+ public Dimension preferredSize(int columns)
+ {
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return new Dimension (0, 0);
- enableEvents(AWTEvent.ACTION_EVENT_MASK);
-}
+ return peer.getPreferredSize (columns);
+ }
-/*************************************************************************/
+ /**
+ * Notifies this object that it should create its native peer.
+ */
+ public void addNotify()
+ {
+ if (getPeer() != null)
+ return;
-/**
- * Removes the specified listener from the list of action listeners
- * for this object.
- *
- * @param listener The listener to remove from the list.
- */
-public synchronized void
-removeActionListener(ActionListener listener)
-{
- action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
-}
+ setPeer((ComponentPeer)getToolkit().createTextField(this));
+ super.addNotify();
+ }
-/*************************************************************************/
+ /**
+ * Addes a new listener to the list of action listeners for this
+ * object.
+ *
+ * @param listener The listener to add to the list.
+ */
+ public synchronized void addActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
-/**
- * Processes the specified event. If the event is an instance of
- * <code>ActionEvent</code> then <code>processActionEvent()</code> is
- * called to process it, otherwise the event is sent to the
- * superclass.
- *
- * @param event The event to process.
- */
-protected void
-processEvent(AWTEvent event)
-{
- if (event instanceof ActionEvent)
- processActionEvent((ActionEvent)event);
- else
- super.processEvent(event);
-}
+ enableEvents(AWTEvent.ACTION_EVENT_MASK);
+ }
-/*************************************************************************/
+ /**
+ * Removes the specified listener from the list of action listeners
+ * for this object.
+ *
+ * @param listener The listener to remove from the list.
+ */
+ public synchronized void removeActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
+ }
-/**
- * Processes an action event by calling any registered listeners.
- * Note to subclasses: This method is not called unless action events
- * are enabled on this object. This will be true if any listeners
- * are registered, or if action events were specifically enabled
- * using <code>enableEvents()</code>.
- *
- * @param event The event to process.
- */
-protected void
-processActionEvent(ActionEvent event)
-{
- if (action_listeners != null)
- action_listeners.actionPerformed(event);
-}
+ /**
+ * Processes the specified event. If the event is an instance of
+ * <code>ActionEvent</code> then <code>processActionEvent()</code> is
+ * called to process it, otherwise the event is sent to the
+ * superclass.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+ else
+ super.processEvent(event);
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
- if (e.id <= ActionEvent.ACTION_LAST
- && e.id >= ActionEvent.ACTION_FIRST
- && (action_listeners != null
- || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
- processEvent(e);
- else
- super.dispatchEventImpl(e);
-}
+ /**
+ * Processes an action event by calling any registered listeners.
+ * Note to subclasses: This method is not called unless action events
+ * are enabled on this object. This will be true if any listeners
+ * are registered, or if action events were specifically enabled
+ * using <code>enableEvents()</code>.
+ *
+ * @param event The event to process.
+ */
+ protected void processActionEvent(ActionEvent event)
+ {
+ if (action_listeners != null)
+ action_listeners.actionPerformed(event);
+ }
-/*************************************************************************/
+ void dispatchEventImpl(AWTEvent e)
+ {
+ if (e.id <= ActionEvent.ACTION_LAST
+ && e.id >= ActionEvent.ACTION_FIRST
+ && (action_listeners != null
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
-/**
+ /**
* Returns a debug string for this object.
*
* @return A debug string for this object.
*/
-protected String
-paramString()
-{
- return(getClass().getName() + "(columns=" + getColumns() + ",echoChar=" +
- getEchoChar());
-}
+ protected String paramString()
+ {
+ return(getClass().getName() + "(columns=" + getColumns() + ",echoChar=" +
+ getEchoChar());
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -521,6 +440,21 @@ paramString()
{
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
{
@@ -541,4 +475,4 @@ paramString()
return new AccessibleAWTTextField();
}
-} // class TextField
+}
diff --git a/libjava/classpath/java/awt/Toolkit.java b/libjava/classpath/java/awt/Toolkit.java
index 282e50d2c50..2842091c139 100644
--- a/libjava/classpath/java/awt/Toolkit.java
+++ b/libjava/classpath/java/awt/Toolkit.java
@@ -70,6 +70,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;
@@ -332,6 +333,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.
@@ -695,6 +708,14 @@ public abstract class Toolkit
public PrintJob getPrintJob(Frame frame, String title,
JobAttributes jobAttr, PageAttributes pageAttr)
{
+ // FIXME: it is possible this check may be removed
+ // if this method, when written, always delegates to
+ // getPrintJob(Frame, String, Properties).
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
return null;
}
diff --git a/libjava/classpath/java/awt/Window.java b/libjava/classpath/java/awt/Window.java
index 8bc4715aed5..8885821811d 100644
--- a/libjava/classpath/java/awt/Window.java
+++ b/libjava/classpath/java/awt/Window.java
@@ -39,8 +39,6 @@ exception statement from your version. */
package java.awt;
import java.awt.event.ComponentEvent;
-import java.awt.event.FocusEvent;
-import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
@@ -80,6 +78,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();
@@ -130,7 +130,6 @@ public class Window extends Container implements Accessible
// cycle roots.
focusCycleRoot = true;
setLayout(new BorderLayout());
- addWindowFocusListener();
GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
@@ -142,67 +141,6 @@ public class Window extends Container implements Accessible
graphicsConfiguration = gc;
}
- private void addWindowFocusListener()
- {
- addWindowFocusListener(new WindowAdapter()
- {
- public void windowGainedFocus(WindowEvent event)
- {
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- if (windowFocusOwner != null)
- {
- synchronized (eq)
- {
- KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- Component currentFocusOwner = manager.getGlobalPermanentFocusOwner();
- if (currentFocusOwner != null)
- {
- eq.postEvent(new FocusEvent(currentFocusOwner,
- FocusEvent.FOCUS_LOST, false,
- windowFocusOwner));
- eq.postEvent(new FocusEvent(windowFocusOwner,
- FocusEvent.FOCUS_GAINED, false,
- currentFocusOwner));
- }
- else
- eq.postEvent(new FocusEvent(windowFocusOwner,
- FocusEvent.FOCUS_GAINED, false));
- }
- }
- else
- eq.postEvent(new FocusEvent(Window.this, FocusEvent.FOCUS_GAINED,
- false));
- }
-
- public void windowLostFocus(WindowEvent event)
- {
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- if (windowFocusOwner != null)
- {
- synchronized (eq)
- {
- KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- Component currentFocusOwner = manager.getGlobalPermanentFocusOwner();
- if (currentFocusOwner != null)
- {
- eq.postEvent(new FocusEvent(currentFocusOwner,
- FocusEvent.FOCUS_GAINED, false,
- windowFocusOwner));
- eq.postEvent(new FocusEvent(windowFocusOwner,
- FocusEvent.FOCUS_LOST, false,
- currentFocusOwner));
- }
- else
- eq.postEvent(new FocusEvent(windowFocusOwner,
- FocusEvent.FOCUS_LOST, false));
- }
- }
- else
- eq.postEvent(new FocusEvent(Window.this, FocusEvent.FOCUS_LOST, false));
- }
- });
- }
-
/**
* Initializes a new instance of <code>Window</code> with the specified
* parent. The window will initially be invisible.
@@ -420,13 +358,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();
}
}
@@ -437,10 +379,7 @@ public class Window extends Container implements Accessible
public void toFront()
{
if (peer != null)
- {
- WindowPeer wp = (WindowPeer) peer;
- wp.toFront();
- }
+ ( (WindowPeer) peer ).toFront();
}
/**
@@ -1236,6 +1175,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/libjava/classpath/java/awt/datatransfer/Clipboard.java b/libjava/classpath/java/awt/datatransfer/Clipboard.java
index 5fa1d1ab134..2029e2c351b 100644
--- a/libjava/classpath/java/awt/datatransfer/Clipboard.java
+++ b/libjava/classpath/java/awt/datatransfer/Clipboard.java
@@ -1,5 +1,5 @@
/* Clipboard.java -- Class for transferring data via cut and paste.
- Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -182,6 +182,9 @@ public class Clipboard
public void addFlavorListener(FlavorListener listener)
{
+ if (listener == null)
+ return;
+
synchronized(listeners)
{
listeners.add(listener);
@@ -190,6 +193,9 @@ public class Clipboard
public void removeFlavorListener(FlavorListener listener)
{
+ if (listener == null)
+ return;
+
synchronized(listeners)
{
listeners.remove(listener);
diff --git a/libjava/classpath/java/awt/datatransfer/DataFlavor.java b/libjava/classpath/java/awt/datatransfer/DataFlavor.java
index 5944c2eb7ec..0228cd5786d 100644
--- a/libjava/classpath/java/awt/datatransfer/DataFlavor.java
+++ b/libjava/classpath/java/awt/datatransfer/DataFlavor.java
@@ -1,5 +1,5 @@
/* DataFlavor.java -- A type of data to transfer via the clipboard.
- Copyright (C) 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,6 +47,7 @@ import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Reader;
+import java.io.Serializable;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
@@ -197,31 +198,37 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
throw new ClassNotFoundException(className);
}
- private static Class getRepresentationClassFromMime(String mimeString,
+ private static Class getRepresentationClassFromMimeThrows(String mimeString,
ClassLoader classLoader)
+ throws ClassNotFoundException
{
String classname = getParameter("class", mimeString);
if (classname != null)
- {
- try
- {
- return tryToLoadClass(classname, classLoader);
- }
- catch(Exception e)
- {
- IllegalArgumentException iae;
- iae = new IllegalArgumentException("mimeString: "
- + mimeString
- + " classLoader: "
- + classLoader);
- iae.initCause(e);
- throw iae;
- }
- }
+ return tryToLoadClass(classname, classLoader);
else
return java.io.InputStream.class;
}
-
+
+ // Same as above, but wraps any ClassNotFoundExceptions
+ private static Class getRepresentationClassFromMime(String mimeString,
+ ClassLoader classLoader)
+ {
+ try
+ {
+ return getRepresentationClassFromMimeThrows(mimeString, classLoader);
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ IllegalArgumentException iae;
+ iae = new IllegalArgumentException("mimeString: "
+ + mimeString
+ + " classLoader: "
+ + classLoader);
+ iae.initCause(cnfe);
+ throw iae;
+ }
+ }
+
/**
* Returns the value of the named MIME type parameter, or <code>null</code>
* if the parameter does not exist. Given the parameter name and the mime
@@ -240,7 +247,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
String value = mimeString.substring(idx + paramName.length() + 1);
- idx = value.indexOf(" ");
+ idx = value.indexOf(";");
if (idx == -1)
return(value);
else
@@ -328,6 +335,14 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
{
this.representationClass = representationClass;
this.mimeType = mimeType;
+
+ // Do some simple validity checks
+ String type = getPrimaryType() + "/" + getSubType();
+ if (type.indexOf(' ') != -1
+ || type.indexOf('=') != -1
+ || type.indexOf(';') != -1)
+ throw new IllegalArgumentException(mimeType);
+
if (humanPresentableName != null)
this.humanPresentableName = humanPresentableName;
else
@@ -375,7 +390,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
ClassLoader classLoader)
throws ClassNotFoundException
{
- this(getRepresentationClassFromMime(mimeType, classLoader),
+ this(getRepresentationClassFromMimeThrows(mimeType, classLoader),
mimeType, humanPresentableName);
}
@@ -417,7 +432,8 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
*/
public DataFlavor(String mimeType) throws ClassNotFoundException
{
- this(mimeType, null);
+ this(getRepresentationClassFromMimeThrows(mimeType, null),
+ mimeType, null);
}
/**
@@ -567,7 +583,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
*/
public boolean isRepresentationClassInputStream()
{
- return representationClass.getName().equals("java.io.InputStream");
+ return InputStream.class.isAssignableFrom(representationClass);
}
/**
@@ -579,17 +595,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
*/
public boolean isRepresentationClassSerializable()
{
- Class[] interfaces = representationClass.getInterfaces();
-
- int i = 0;
- while (i < interfaces.length)
- {
- if (interfaces[i].getName().equals("java.io.Serializable"))
- return true;
- ++i;
- }
-
- return false;
+ return Serializable.class.isAssignableFrom(representationClass);
}
/**
@@ -634,8 +640,10 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
*/
public boolean isFlavorJavaFileListType()
{
- if (mimeType.equals(javaFileListFlavor.mimeType)
- && representationClass.equals(javaFileListFlavor.representationClass))
+ if (getPrimaryType().equals(javaFileListFlavor.getPrimaryType())
+ && getSubType().equals(javaFileListFlavor.getSubType())
+ && javaFileListFlavor.representationClass
+ .isAssignableFrom(representationClass))
return true;
return false ;
@@ -666,7 +674,11 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
/**
* This method test the specified <code>DataFlavor</code> for equality
* against this object. This will be true if the MIME type and
- * representation type are the equal.
+ * representation class are the equal. If the primary type is 'text'
+ * then also the value of the charset parameter is compared. In such a
+ * case when the charset parameter isn't given then the charset is
+ * assumed to be equal to the default charset of the platform. All
+ * other parameters are ignored.
*
* @param flavor The <code>DataFlavor</code> to test against.
*
@@ -677,12 +689,34 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
{
if (flavor == null)
return false;
-
- if (! this.mimeType.toLowerCase().equals(flavor.mimeType.toLowerCase()))
+
+ String primary = getPrimaryType();
+ if (! primary.equals(flavor.getPrimaryType()))
return false;
-
+
+ String sub = getSubType();
+ if (! sub.equals(flavor.getSubType()))
+ return false;
+
if (! this.representationClass.equals(flavor.representationClass))
return false;
+
+ if (primary.equals("text"))
+ if (! isRepresentationClassCharBuffer()
+ && ! isRepresentationClassReader()
+ && representationClass != java.lang.String.class
+ && ! (representationClass.isArray()
+ && representationClass.getComponentType() == Character.TYPE))
+ {
+ String charset = getParameter("charset");
+ String otherset = flavor.getParameter("charset");
+ String defaultset = Charset.defaultCharset().name();
+
+ if (charset == null || charset.equals(defaultset))
+ return (otherset == null || otherset.equals(defaultset));
+
+ return charset.equals(otherset);
+ }
return true;
}
diff --git a/libjava/classpath/java/awt/dnd/DragGestureEvent.java b/libjava/classpath/java/awt/dnd/DragGestureEvent.java
index 9f2bc7c98b8..351ae540072 100644
--- a/libjava/classpath/java/awt/dnd/DragGestureEvent.java
+++ b/libjava/classpath/java/awt/dnd/DragGestureEvent.java
@@ -48,13 +48,6 @@ import java.util.EventObject;
import java.util.Iterator;
import java.util.List;
-/**
- * STUBBED
- * @see DragGestureRecognizer
- * @see DragGestureListener
- * @see DragSource
- * @since 1.2
- */
public class DragGestureEvent extends EventObject
{
/**
@@ -66,52 +59,121 @@ public class DragGestureEvent extends EventObject
private Component component;
private final Point origin;
private final int action;
+ private List events;
+ private DragGestureRecognizer dgr;
+ /**
+ * Constructs a new DragGestureEvent.
+ * @param dgr - DragGestureRecognizer firing this event
+ * @param action - user's preferred action
+ * @param origin - origin of the drag
+ * @param events - List of events that make up the gesture
+ * @throws IllegalArgumentException - if input parameters are null
+ */
public DragGestureEvent(DragGestureRecognizer dgr, int action, Point origin,
List events)
- {
+ {
super(dgr);
- if (origin == null || events == null)
+ if (origin == null || events == null || dgr == null)
throw new IllegalArgumentException();
+
this.origin = origin;
this.action = action;
+ this.events = events;
+ this.dgr = dgr;
+ this.component = dgr.getComponent();
+ this.dragSource = dgr.getDragSource();
}
+ /**
+ * Returns the source casted as a DragGestureRecognizer.
+ *
+ * @return the source casted as a DragGestureRecognizer.
+ */
public DragGestureRecognizer getSourceAsDragGestureRecognizer()
{
- return (DragGestureRecognizer) source;
+ return (DragGestureRecognizer) getSource();
}
+
+ /**
+ * Returns the Component corresponding to this.
+ *
+ * @return the Component corresponding to this.
+ */
public Component getComponent()
{
- return null;
+ return component;
}
+
+ /**
+ * Gets the DragSource corresponding to this.
+ *
+ * @return the DragSource corresponding to this.
+ */
public DragSource getDragSource()
{
- return null;
+ return dragSource;
}
+
+ /**
+ * Returns the origin of the drag.
+ *
+ * @return the origin of the drag.
+ */
public Point getDragOrigin()
{
return origin;
}
+
+ /**
+ * Gets an iterator representation of the List of events.
+ *
+ * @return an iterator representation of the List of events.
+ */
public Iterator iterator()
{
- return null;
+ return events.iterator();
}
+
+ /**
+ * Gets an array representation of the List of events.
+ *
+ * @return an array representation of the List of events.
+ */
public Object[] toArray()
{
- return null;
+ return events.toArray();
}
+
+ /**
+ * Gets an array representation of the List of events.
+ *
+ * @param array - the array to store the events in.
+ * @return an array representation of the List of events.
+ */
public Object[] toArray(Object[] array)
{
- return array;
+ return events.toArray(array);
}
+
+ /**
+ * Gets the user's preferred action.
+ *
+ * @return the user's preferred action.
+ */
public int getDragAction()
{
- return 0;
+ return action;
}
+
+ /**
+ * Get the event that triggered this gesture.
+ *
+ * @return the event that triggered this gesture.
+ */
public InputEvent getTriggerEvent()
{
- return null;
+ return dgr.getTriggerEvent();
}
/**
@@ -152,5 +214,6 @@ public class DragGestureEvent extends EventObject
public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset,
Transferable trans, DragSourceListener l)
{
+ dragSource.startDrag(this, dragCursor, dragImage, imageOffset, trans, l);
}
} // class DragGestureEvent
diff --git a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
index 145a24a3850..32bbc56da5d 100644
--- a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
+++ b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
@@ -131,6 +131,7 @@ public abstract class DragGestureRecognizer implements Serializable
throws NotImplementedException
{
events = new ArrayList();
+ // FIXME: Not implemented fully.
}
/**
diff --git a/libjava/classpath/java/awt/dnd/DragSource.java b/libjava/classpath/java/awt/dnd/DragSource.java
index 05eb6709d47..48fa2388ee2 100644
--- a/libjava/classpath/java/awt/dnd/DragSource.java
+++ b/libjava/classpath/java/awt/dnd/DragSource.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.dnd;
+import gnu.classpath.NotImplementedException;
+
import java.awt.Component;
import java.awt.Cursor;
import java.awt.GraphicsEnvironment;
@@ -70,9 +72,12 @@ public class DragSource implements Serializable
public static final Cursor DefaultLinkNoDrop = null;
private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap ();
-
private transient DragSourceListener dragSourceListener;
private transient DragSourceMotionListener dragSourceMotionListener;
+
+ private static DragSource ds;
+ private DragSourceContextPeer peer;
+ private DragSourceContext context;
/**
* Initializes the drag source.
@@ -82,19 +87,34 @@ public class DragSource implements Serializable
public DragSource()
{
if (GraphicsEnvironment.isHeadless())
- throw new HeadlessException ();
+ {
+ ds = null;
+ throw new HeadlessException();
+ }
}
/**
+ * Gets the default drag source.
+ *
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
*/
public static DragSource getDefaultDragSource()
{
- return new DragSource();
+ if (GraphicsEnvironment.isHeadless())
+ {
+ ds = null;
+ throw new HeadlessException();
+ }
+
+ if (ds == null)
+ ds = new DragSource();
+ return ds;
}
public static boolean isDragImageSupported()
+ throws NotImplementedException
{
+ // FIXME: Implement this
return false;
}
@@ -110,6 +130,43 @@ public class DragSource implements Serializable
Transferable trans, DragSourceListener dsl,
FlavorMap map)
{
+ // http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html
+
+ // This function creates a DragSourceContext object. This object tracks the
+ // state of the operation by listening to a native peer. In this situation,
+ // the DragSource may be obtained from the event or by an instance variable.
+ // This function also creates a new DragSourceContextPeer.
+
+ // This function sends the same message to the context, which then forwards
+ // it to the peer, passing itself as a parameter. Now, the native system has
+ // access to the Transferable through the context.
+
+ // FIXME: Add check to determine if dragging.
+
+ try
+ {
+ flavorMap = map;
+
+ if (peer == null)
+ peer = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
+
+ if (context == null)
+ context = createDragSourceContext(peer, trigger,
+ dragCursor,
+ dragImage,
+ imageOffset, trans,
+ dsl);
+
+ if (peer == null)
+ throw new InvalidDnDOperationException();
+
+ peer.startDrag(context, dragCursor, dragImage, imageOffset);
+ }
+ catch (Exception e)
+ {
+ throw new InvalidDnDOperationException("Drag and Drop system is "
+ + "unable to initiate a drag operation.");
+ }
}
/**
@@ -156,7 +213,7 @@ public class DragSource implements Serializable
/**
* Creates the DragSourceContext to handle this drag.
*
- * @exception IllegalArgumentException FIXME
+ * @exception IllegalArgumentException
* @exception NullPointerException If dscp, dgl, dragImage or t is null.
*/
protected DragSourceContext
@@ -164,7 +221,7 @@ public class DragSource implements Serializable
Cursor cursor, Image image, Point offset,
Transferable t, DragSourceListener dsl)
{
- return null;
+ return new DragSourceContext(peer, dge, cursor, image, offset, t, dsl);
}
public FlavorMap getFlavorMap()
@@ -172,42 +229,22 @@ public class DragSource implements Serializable
return flavorMap;
}
- /**
- * Dummy DragGestureRecognizer when Toolkit doesn't support drag and drop.
- */
- static class NoDragGestureRecognizer extends DragGestureRecognizer
- {
- NoDragGestureRecognizer(DragSource ds, Component c, int actions,
- DragGestureListener dgl)
- {
- super(ds, c, actions, dgl);
- }
-
- protected void registerListeners() { }
- protected void unregisterListeners() { }
- }
-
- public DragGestureRecognizer
- createDragGestureRecognizer(Class recognizer, Component c, int actions,
- DragGestureListener dgl)
+ public DragGestureRecognizer createDragGestureRecognizer(Class recognizer,
+ Component c,
+ int actions,
+ DragGestureListener dgl)
{
- DragGestureRecognizer dgr;
- dgr = Toolkit.getDefaultToolkit ()
- .createDragGestureRecognizer (recognizer, this, c, actions,
- dgl);
-
- if (dgr == null)
- dgr = new NoDragGestureRecognizer(this, c, actions, dgl);
-
- return dgr;
+ return Toolkit.getDefaultToolkit().createDragGestureRecognizer(recognizer,
+ this, c,
+ actions, dgl);
}
- public DragGestureRecognizer
- createDefaultDragGestureRecognizer(Component c, int actions,
- DragGestureListener dgl)
+ public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c,
+ int actions,
+ DragGestureListener dgl)
{
- return createDragGestureRecognizer (MouseDragGestureRecognizer.class, c,
- actions, dgl);
+ return createDragGestureRecognizer(MouseDragGestureRecognizer.class, c,
+ actions, dgl);
}
/**
@@ -275,4 +312,17 @@ public class DragSource implements Serializable
// Return an empty EventListener array.
return new EventListener [0];
}
+
+ /**
+ * TODO
+ * @return
+ *
+ * @since 1.5
+ */
+ public static int getDragThreshold()
+ throws NotImplementedException
+ {
+ // FIXME: Not implemented.
+ return 4;
+ }
} // class DragSource
diff --git a/libjava/classpath/java/awt/dnd/DragSourceContext.java b/libjava/classpath/java/awt/dnd/DragSourceContext.java
index 88607b090ea..1fee5c0c304 100644
--- a/libjava/classpath/java/awt/dnd/DragSourceContext.java
+++ b/libjava/classpath/java/awt/dnd/DragSourceContext.java
@@ -70,8 +70,8 @@ public class DragSourceContext
private Transferable transferable;
private DragGestureEvent trigger;
private DragSourceListener dragSourceListener;
- private boolean useCustomCursor; // FIXME: currently unused but needed for serialization.
- private int sourceActions; // FIXME: currently unused but needed for serialization.
+ private boolean useCustomCursor;
+ private int sourceActions;
private Image image;
private Point offset;
@@ -82,16 +82,17 @@ public class DragSourceContext
* are null, the drag action for the trigger event is DnDConstants.ACTION_NONE
* or if the source actions for the DragGestureRecognizer associated with the
* trigger event are equal to DnDConstants.ACTION_NONE.
- * @exception NullPointerException If peer or trigger is null.
+ * @exception NullPointerException If peer, trans or trigger is null or if the
+ * image is not null but the offset is.
*/
public DragSourceContext (DragSourceContextPeer peer,
DragGestureEvent trigger, Cursor cursor,
Image image, Point offset, Transferable trans,
DragSourceListener dsl)
- throws NotImplementedException
- {
+ {
if (peer == null
- || trigger == null)
+ || trigger == null || trans == null
+ || (image != null && offset == null))
throw new NullPointerException ();
if (trigger.getComponent () == null
@@ -108,37 +109,77 @@ public class DragSourceContext
this.offset = offset;
this.transferable = trans;
this.dragSourceListener = dsl;
+ this.sourceActions = trigger.getSourceAsDragGestureRecognizer().getSourceActions();
- throw new Error ("not implemented");
+ setCursor(cursor);
+ updateCurrentCursor(trigger.getDragAction(), sourceActions, DEFAULT);
}
+ /**
+ * Returns the DragSource object associated with the
+ * DragGestureEvent.
+ *
+ * @return the DragSource associated with the trigger.
+ */
public DragSource getDragSource()
{
return trigger.getDragSource ();
}
+ /**
+ * Returns the component associated with this.
+ *
+ * @return the component associated with the trigger.
+ */
public Component getComponent()
{
return trigger.getComponent ();
}
+ /**
+ * Gets the trigger associated with this.
+ *
+ * @return the trigger.
+ */
public DragGestureEvent getTrigger()
{
return trigger;
}
+ /**
+ * Returns the source actions for the DragGestureRecognizer.
+ *
+ * @return the source actions for DragGestureRecognizer.
+ */
public int getSourceActions()
{
- return trigger.getSourceAsDragGestureRecognizer ().getSourceActions ();
+ if (sourceActions == 0)
+ sourceActions = trigger.getSourceAsDragGestureRecognizer().getSourceActions();
+ return sourceActions;
}
- public void setCursor (Cursor cursor)
- throws NotImplementedException
+ /**
+ * Sets the cursor for this drag operation to the specified cursor.
+ *
+ * @param cursor c - the Cursor to use, or null to use the default drag
+ * cursor.
+ */
+ public void setCursor(Cursor cursor)
{
+ if (cursor == null)
+ useCustomCursor = false;
+ else
+ useCustomCursor = true;
this.cursor = cursor;
- // FIXME: Check if we need to do more here
+ peer.setCursor(cursor);
}
+ /**
+ * Returns the current cursor or null if the default
+ * drag cursor is used.
+ *
+ * @return the current cursor or null.
+ */
public Cursor getCursor()
{
return cursor;
@@ -165,48 +206,160 @@ public class DragSourceContext
dragSourceListener = null;
}
+ /**
+ * This function tells the peer that the DataFlavors have been modified.
+ */
public void transferablesFlavorsChanged()
- throws NotImplementedException
{
+ peer.transferablesFlavorsChanged();
}
+ /**
+ * Calls dragEnter on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
public void dragEnter(DragSourceDragEvent e)
- throws NotImplementedException
{
+ if (dragSourceListener != null)
+ dragSourceListener.dragEnter(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragEnter(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), ENTER);
}
+ /**
+ * Calls dragOver on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
public void dragOver(DragSourceDragEvent e)
- throws NotImplementedException
{
+ if (dragSourceListener != null)
+ dragSourceListener.dragOver(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragOver(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), OVER);
}
-
+
+ /**
+ * Calls dragExit on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceEvent
+ */
public void dragExit(DragSourceEvent e)
- throws NotImplementedException
{
+ if (dragSourceListener != null)
+ dragSourceListener.dragExit(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragExit(e);
+
+ updateCurrentCursor(0, 0, DEFAULT);
}
+ /**
+ * Calls dropActionChanged on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
public void dropActionChanged(DragSourceDragEvent e)
- throws NotImplementedException
{
+ if (dragSourceListener != null)
+ dragSourceListener.dropActionChanged(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dropActionChanged(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), CHANGED);
}
+ /**
+ * Calls dragDropEnd on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDropEvent
+ */
public void dragDropEnd(DragSourceDropEvent e)
- throws NotImplementedException
{
+ if (dragSourceListener != null)
+ dragSourceListener.dragDropEnd(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragDropEnd(e);
}
+ /**
+ * Calls dragMouseMoved on the listeners registered with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
public void dragMouseMoved(DragSourceDragEvent e)
- throws NotImplementedException
{
+ DragSource ds = getDragSource();
+ DragSourceMotionListener[] dsml = ds.getDragSourceMotionListeners();
+ for (int i = 0; i < dsml.length; i++)
+ dsml[i].dragMouseMoved(e);
}
+ /**
+ * Returns the Transferable set with this object.
+ *
+ * @return the transferable.
+ */
public Transferable getTransferable()
{
return transferable;
}
+ /**
+ * This function sets the drag cursor for the specified operation, actions and
+ * status if the default drag cursor is active. Otherwise, the cursor is not
+ * updated in any way.
+ *
+ * @param dropOp - the current operation.
+ * @param targetAct - the supported actions.
+ * @param status - the status of the cursor (constant).
+ */
protected void updateCurrentCursor(int dropOp, int targetAct, int status)
throws NotImplementedException
{
+ // FIXME: Not implemented fully
+ if (!useCustomCursor)
+ {
+ Cursor cursor = null;
+ switch (status)
+ {
+ case ENTER:
+ break;
+ case CHANGED:
+ break;
+ case OVER:
+ break;
+ default:
+ break;
+ }
+
+ this.cursor = cursor;
+ peer.setCursor(cursor);
+ }
}
} // class DragSourceContext
diff --git a/libjava/classpath/java/awt/dnd/DropTarget.java b/libjava/classpath/java/awt/dnd/DropTarget.java
index b0d4c2ae7a1..a3650567f09 100644
--- a/libjava/classpath/java/awt/dnd/DropTarget.java
+++ b/libjava/classpath/java/awt/dnd/DropTarget.java
@@ -38,13 +38,18 @@ exception statement from your version. */
package java.awt.dnd;
+import gnu.classpath.NotImplementedException;
+
import java.awt.Component;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.datatransfer.FlavorMap;
+import java.awt.dnd.peer.DropTargetPeer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
import java.io.Serializable;
import java.util.EventListener;
import java.util.TooManyListenersException;
@@ -79,19 +84,25 @@ public class DropTarget
}
protected void stop ()
+ throws NotImplementedException
{
+ // FIXME: implement this
}
public void actionPerformed (ActionEvent e)
+ throws NotImplementedException
{
+ // FIXME: implement this
}
}
private Component component;
private FlavorMap flavorMap;
private int actions;
+ private DropTargetPeer peer;
private DropTargetContext dropTargetContext;
private DropTargetListener dropTargetListener;
+ private DropTarget.DropTargetAutoScroller autoscroller;
private boolean active = true;
/**
@@ -150,12 +161,15 @@ public class DropTarget
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
- component = c;
- actions = i;
+ setComponent(c);
+ setDefaultActions(i);
dropTargetListener = dtl;
flavorMap = fm;
setActive (b);
+
+ if (c != null)
+ c.setDropTarget(this);
}
/**
@@ -211,33 +225,46 @@ public class DropTarget
public void addDropTargetListener (DropTargetListener dtl)
throws TooManyListenersException
{
+ if (dropTargetListener != null)
+ throw new TooManyListenersException ();
+
dropTargetListener = dtl;
}
public void removeDropTargetListener(DropTargetListener dtl)
{
- // FIXME: Do we need to do something with dtl ?
- dropTargetListener = null;
+ if (dropTargetListener != null)
+ dropTargetListener = null;
}
public void dragEnter(DropTargetDragEvent dtde)
{
+ if (dropTargetListener != null)
+ dropTargetListener.dragEnter(dtde);
}
public void dragOver(DropTargetDragEvent dtde)
{
+ if (dropTargetListener != null)
+ dropTargetListener.dragOver(dtde);
}
public void dropActionChanged(DropTargetDragEvent dtde)
{
+ if (dropTargetListener != null)
+ dropTargetListener.dropActionChanged(dtde);
}
public void dragExit(DropTargetEvent dte)
{
+ if (dropTargetListener != null)
+ dropTargetListener.dragExit(dte);
}
public void drop(DropTargetDropEvent dtde)
{
+ if (dropTargetListener != null)
+ dropTargetListener.drop(dtde);
}
public FlavorMap getFlavorMap()
@@ -250,12 +277,29 @@ public class DropTarget
flavorMap = fm;
}
- public void addNotify(java.awt.peer.ComponentPeer peer)
+ public void addNotify(ComponentPeer p)
{
+ Component c = component;
+ while (c != null && p instanceof LightweightPeer)
+ {
+ p = c.getPeer();
+ c = c.getParent();
+ }
+
+ if (p instanceof DropTargetPeer)
+ {
+ peer = ((DropTargetPeer) p);
+ peer.addDropTarget(this);
+ }
+ else
+ peer = null;
}
- public void removeNotify(java.awt.peer.ComponentPeer peer)
+ public void removeNotify(ComponentPeer p)
{
+ ((DropTargetPeer) peer).removeDropTarget(this);
+ peer = null;
+ p = null;
}
public DropTargetContext getDropTargetContext()
@@ -268,24 +312,34 @@ public class DropTarget
protected DropTargetContext createDropTargetContext()
{
- return new DropTargetContext (this);
+ if (dropTargetContext == null)
+ dropTargetContext = new DropTargetContext (this);
+
+ return dropTargetContext;
}
protected DropTarget.DropTargetAutoScroller createDropTargetAutoScroller
(Component c, Point p)
{
- return new DropTarget.DropTargetAutoScroller (c, p);
+ if (autoscroller == null)
+ autoscroller = new DropTarget.DropTargetAutoScroller (c, p);
+
+ return autoscroller;
}
protected void initializeAutoscrolling(Point p)
{
+ createDropTargetAutoScroller (component, p);
}
protected void updateAutoscroll(Point dragCursorLocn)
{
+ if (autoscroller != null)
+ autoscroller.updateLocation(dragCursorLocn);
}
protected void clearAutoscroll()
{
+ autoscroller = null;
}
} // class DropTarget
diff --git a/libjava/classpath/java/awt/dnd/DropTargetContext.java b/libjava/classpath/java/awt/dnd/DropTargetContext.java
index 4a26d904880..31945c34bb1 100644
--- a/libjava/classpath/java/awt/dnd/DropTargetContext.java
+++ b/libjava/classpath/java/awt/dnd/DropTargetContext.java
@@ -37,12 +37,11 @@ exception statement from your version. */
package java.awt.dnd;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Component;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.peer.DropTargetContextPeer;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
@@ -86,7 +85,7 @@ public class DropTargetContext implements Serializable
private DropTarget dropTarget;
private int targetActions;
- private java.awt.dnd.peer.DropTargetContextPeer dtcp;
+ private DropTargetContextPeer dtcp;
// package private
DropTargetContext(DropTarget dropTarget)
@@ -104,7 +103,7 @@ public class DropTargetContext implements Serializable
return dropTarget.getComponent();
}
- public void addNotify(java.awt.dnd.peer.DropTargetContextPeer dtcp)
+ public void addNotify(DropTargetContextPeer dtcp)
{
this.dtcp = dtcp;
}
@@ -130,39 +129,39 @@ public class DropTargetContext implements Serializable
* @exception InvalidDnDOperationException If a drop is not outstanding.
*/
public void dropComplete(boolean success)
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.dropComplete(success);
}
protected void acceptDrag(int dragOperation)
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.acceptDrag(dragOperation);
}
protected void rejectDrag()
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.rejectDrag();
}
protected void acceptDrop(int dropOperation)
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.acceptDrop(dropOperation);
}
protected void rejectDrop()
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.rejectDrop();
}
protected DataFlavor[] getCurrentDataFlavors()
- throws NotImplementedException
{
- // FIXME: implement this
+ if (dtcp != null)
+ dtcp.getTransferDataFlavors();
return null;
}
@@ -182,9 +181,11 @@ public class DropTargetContext implements Serializable
* @exception InvalidDnDOperationException If a drag is not outstanding.
*/
protected Transferable getTransferable()
- throws InvalidDnDOperationException, NotImplementedException
+ throws InvalidDnDOperationException
{
- // FIXME: implement this
+ // FIXME: Implement this
+ if (dtcp != null)
+ return dtcp.getTransferable();
return null;
}
diff --git a/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java b/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java
index 6cdc3a292be..89bf1778a71 100644
--- a/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java
+++ b/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java
@@ -40,6 +40,7 @@ package java.awt.dnd;
import java.awt.Point;
import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
import java.util.List;
/**
@@ -114,8 +115,7 @@ public class DropTargetDragEvent extends DropTargetEvent
public int getDropAction()
{
- return 0;
- //return dropAction & ((DropTargetContext) source).getTargetActions();
+ return dropAction & ((DropTargetContext) source).getTargetActions();
}
public Point getLocation ()
@@ -137,4 +137,17 @@ public class DropTargetDragEvent extends DropTargetEvent
{
context.rejectDrag ();
}
+
+ /**
+ * TODO
+ *
+ * @return
+ *
+ * @since 1.5
+ */
+ public Transferable getTransferable()
+ {
+ // FIXME: Not implemented
+ return null;
+ }
} // class DropTargetDragEvent
diff --git a/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java b/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java
index a745bd256f8..9754bb11ef5 100644
--- a/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java
+++ b/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java
@@ -37,8 +37,6 @@ exception statement from your version. */
package java.awt.dnd;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Point;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
@@ -161,9 +159,8 @@ public class DropTargetDropEvent extends DropTargetEvent
}
public void dropComplete(boolean success)
- throws NotImplementedException
{
- // FIXME: implement this
+ context.dropComplete(success);
}
public boolean isLocalTransfer()
diff --git a/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java b/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java
index 2fd9767e03d..4a75610bf61 100644
--- a/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java
+++ b/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java
@@ -59,6 +59,7 @@ public class InvalidDnDOperationException extends IllegalStateException
*/
public InvalidDnDOperationException()
{
+ super();
}
/**
diff --git a/libjava/classpath/java/awt/event/KeyEvent.java b/libjava/classpath/java/awt/event/KeyEvent.java
index d4b93ba3e0b..42084d7333e 100644
--- a/libjava/classpath/java/awt/event/KeyEvent.java
+++ b/libjava/classpath/java/awt/event/KeyEvent.java
@@ -993,6 +993,27 @@ public class KeyEvent extends InputEvent
public static final int VK_ALT_GRAPH = 65406;
/**
+ * The 'begin' key VK_BEGIN
+ *
+ * @since 1.5
+ */
+ public static final int VK_BEGIN = 65368;
+
+ /**
+ * The context-menu key VK_CONTEXT_MENU
+ *
+ * @since 1.5
+ */
+ public static final int VK_CONTEXT_MENU = 525;
+
+ /**
+ * The 'Windows' key VK_WINDOWS
+ *
+ * @since 1.5
+ */
+ public static final int VK_WINDOWS = 524;
+
+ /**
* The virtual key VK_UNDEFINED. This is used for key typed events, which
* do not have a virtual key.
*/
diff --git a/libjava/classpath/java/awt/font/FontRenderContext.java b/libjava/classpath/java/awt/font/FontRenderContext.java
index 78564a647da..c50e5e5092a 100644
--- a/libjava/classpath/java/awt/font/FontRenderContext.java
+++ b/libjava/classpath/java/awt/font/FontRenderContext.java
@@ -83,7 +83,15 @@ public class FontRenderContext
public boolean equals (FontRenderContext rhs)
{
- return (affineTransform.equals (rhs.getTransform ())
+ if (rhs == null)
+ return false;
+
+ if (affineTransform == null && rhs.affineTransform != null
+ || affineTransform != null && rhs.affineTransform == null)
+ return false;
+
+ return ((affineTransform == rhs.affineTransform
+ || affineTransform.equals (rhs.getTransform ()))
&& isAntiAliased == rhs.isAntiAliased ()
&& usesFractionalMetrics == rhs.usesFractionalMetrics ());
}
diff --git a/libjava/classpath/java/awt/font/LineBreakMeasurer.java b/libjava/classpath/java/awt/font/LineBreakMeasurer.java
index c2a6d45d9f5..816c7745c2b 100644
--- a/libjava/classpath/java/awt/font/LineBreakMeasurer.java
+++ b/libjava/classpath/java/awt/font/LineBreakMeasurer.java
@@ -41,57 +41,41 @@ package java.awt.font;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
import java.text.BreakIterator;
-import java.awt.font.TextLayout;
-import java.awt.font.FontRenderContext;
import java.awt.Shape;
public final class LineBreakMeasurer
{
private AttributedCharacterIterator text;
private int position;
- private FontRenderContext frc;
- private TextLayout totalLayout;
+ private TextMeasurer tm;
private int numChars;
public LineBreakMeasurer(AttributedCharacterIterator text,
BreakIterator breakIter, FontRenderContext frc)
{
- this.text = text;
- this.frc = frc;
- position = 0;
- totalLayout = new TextLayout(text, frc);
- numChars = totalLayout.getCharacterCount();
+ this( text, frc );
}
public LineBreakMeasurer(AttributedCharacterIterator text,
FontRenderContext frc)
{
this.text = text;
- this.frc = frc;
position = 0;
- totalLayout = new TextLayout(text, frc);
- numChars = totalLayout.getCharacterCount();
+ numChars = text.getEndIndex();
+ tm = new TextMeasurer( text, frc );
}
public void deleteChar(AttributedCharacterIterator newParagraph,
int deletePos)
{
- totalLayout = new TextLayout(newParagraph, frc);
- if( deletePos < 0 || deletePos > totalLayout.getCharacterCount() )
- throw new NullPointerException("Invalid deletePos:"+deletePos);
- numChars = totalLayout.getCharacterCount();
- text = newParagraph;
+ tm.deleteChar( newParagraph, deletePos );
position = 0;
}
public void insertChar(AttributedCharacterIterator newParagraph,
int insertPos)
{
- totalLayout = new TextLayout(newParagraph, frc);
- if( insertPos < 0 || insertPos > totalLayout.getCharacterCount() )
- throw new NullPointerException("Invalid insertPos:"+insertPos);
- numChars = totalLayout.getCharacterCount();
- text = newParagraph;
+ tm.insertChar( newParagraph, insertPos );
position = 0;
}
@@ -104,11 +88,9 @@ public final class LineBreakMeasurer
boolean requireNextWord)
{
int next = nextOffset( wrappingWidth, offsetLimit, requireNextWord );
- AttributedCharacterIterator aci = (new AttributedString( text,
- position, next )
- ).getIterator();
+ TextLayout tl = tm.getLayout( position, next );
position = next;
- return new TextLayout( aci, frc );
+ return tl;
}
public int nextOffset(float wrappingWidth)
@@ -119,69 +101,40 @@ public final class LineBreakMeasurer
public int nextOffset(float wrappingWidth, int offsetLimit,
boolean requireNextWord)
{
- Shape s = totalLayout.getBlackBoxBounds( position, offsetLimit );
- double remainingLength = s.getBounds2D().getWidth();
+ int guessOffset = tm.getLineBreakIndex(position, wrappingWidth);
+ if( offsetLimit > numChars )
+ offsetLimit = numChars;
- int guessOffset = (int)( ( (double)wrappingWidth / (double)remainingLength)
- * ( (double)numChars - (double)position ) );
- guessOffset += position;
if( guessOffset > offsetLimit )
- guessOffset = offsetLimit;
-
- s = totalLayout.getBlackBoxBounds( position, guessOffset );
- double guessLength = s.getBounds2D().getWidth();
-
- boolean makeSmaller = ( guessLength > wrappingWidth );
- int inc = makeSmaller ? -1 : 1;
- boolean keepGoing = true;
-
- do
{
- guessOffset = guessOffset + inc;
- if( guessOffset <= position || guessOffset > offsetLimit )
- {
- keepGoing = false;
- }
- else
- {
- s = totalLayout.getBlackBoxBounds( position, guessOffset );
- guessLength = s.getBounds2D().getWidth();
- if( makeSmaller && ( guessLength <= wrappingWidth) )
- keepGoing = false;
- if( !makeSmaller && ( guessLength >= wrappingWidth) )
- keepGoing = false;
- }
+ text.setIndex( offsetLimit );
+ return offsetLimit;
}
- while( keepGoing );
- if( !makeSmaller )
- guessOffset--;
+ text.setIndex( guessOffset );
- if( guessOffset >= offsetLimit )
- return offsetLimit;
+ // If we're on a breaking character, return directly
+ if( Character.isWhitespace( text.current() ) )
+ return guessOffset;
- text.setIndex( guessOffset );
+ // Otherwise jump forward or backward to the last such char.
if( !requireNextWord )
- {
- char c = text.previous();
- while( !Character.isWhitespace( c ) && c != '-' &&
- guessOffset > position )
- {
- guessOffset--;
- c = text.previous();
- }
- }
+ while( !Character.isWhitespace( text.previous() ) &&
+ guessOffset > position )
+ guessOffset--;
else
+ while( !Character.isWhitespace( text.next() ) &&
+ guessOffset < offsetLimit )
+ guessOffset++;
+
+ if( guessOffset > offsetLimit )
{
- char c = text.next();
- while( !Character.isWhitespace( c ) && c != '-' &&
- guessOffset < offsetLimit )
- {
- guessOffset++;
- c = text.next();
- }
+ text.setIndex( offsetLimit );
+ return offsetLimit;
}
+ text.setIndex( guessOffset );
+
return guessOffset;
}
diff --git a/libjava/classpath/java/awt/font/TextLayout.java b/libjava/classpath/java/awt/font/TextLayout.java
index 4f8c1c644c1..b1473f25564 100644
--- a/libjava/classpath/java/awt/font/TextLayout.java
+++ b/libjava/classpath/java/awt/font/TextLayout.java
@@ -43,13 +43,12 @@ import gnu.classpath.NotImplementedException;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Shape;
-import java.awt.Toolkit;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
+import java.text.CharacterIterator;
import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
import java.text.Bidi;
import java.util.Map;
@@ -73,6 +72,12 @@ public final class TextLayout implements Cloneable
private int[][] runIndices;
/**
+ * Character indices.
+ * Fixt index is the glyphvector, second index is the (first) glyph.
+ */
+ private int[][] charIndices;
+
+ /**
* Base directionality, determined from the first char.
*/
private boolean leftToRight;
@@ -85,7 +90,7 @@ public final class TextLayout implements Cloneable
/**
* The default caret policy.
*/
- static TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy();
+ public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy();
/**
* Constructs a TextLayout.
@@ -139,6 +144,7 @@ public final class TextLayout implements Cloneable
Font.LAYOUT_LEFT_TO_RIGHT :
Font.LAYOUT_RIGHT_TO_LEFT );
}
+ setCharIndices();
}
public TextLayout (String string, Map attributes, FontRenderContext frc)
@@ -147,9 +153,97 @@ public final class TextLayout implements Cloneable
}
public TextLayout (AttributedCharacterIterator text, FontRenderContext frc)
- throws NotImplementedException
{
- throw new Error ("not implemented");
+ // FIXME: Very rudimentary.
+ this(getText(text), getFont(text), frc);
+ }
+
+ /**
+ * Package-private constructor to make a textlayout from an existing one.
+ * This is used by TextMeasurer for returning sub-layouts, and it
+ * saves a lot of time in not having to relayout the text.
+ */
+ TextLayout(TextLayout t, int startIndex, int endIndex)
+ {
+ font = t.font;
+ frc = t.frc;
+ boundsCache = null;
+ lm = t.lm;
+ leftToRight = t.leftToRight;
+
+ if( endIndex > t.getCharacterCount() )
+ endIndex = t.getCharacterCount();
+ string = t.string.substring( startIndex, endIndex );
+
+ int startingRun = t.charIndices[startIndex][0];
+ int nRuns = 1 + t.charIndices[endIndex - 1][0] - startingRun;
+ runIndices = new int[ nRuns ][2];
+
+ runs = new GlyphVector[ nRuns ];
+ for( int i = 0; i < nRuns; i++ )
+ {
+ GlyphVector run = t.runs[ i + startingRun ];
+ // Copy only the relevant parts of the first and last runs.
+ int beginGlyphIndex = (i > 0) ? 0 : t.charIndices[startIndex][1];
+ int numEntries = ( i < nRuns - 1) ? run.getNumGlyphs() :
+ 1 + t.charIndices[endIndex - 1][1] - beginGlyphIndex;
+
+ int[] codes = run.getGlyphCodes(beginGlyphIndex, numEntries, null);
+ runs[ i ] = font.createGlyphVector( frc, codes );
+ runIndices[ i ][0] = t.runIndices[i + startingRun][0] - startIndex;
+ runIndices[ i ][1] = t.runIndices[i + startingRun][1] - startIndex;
+ }
+ runIndices[ nRuns - 1 ][1] = endIndex - 1;
+
+ setCharIndices();
+ determineWhiteSpace();
+ }
+
+ private void setCharIndices()
+ {
+ charIndices = new int[ getCharacterCount() ][2];
+ int i = 0;
+ int currentChar = 0;
+ for(int run = 0; run < runs.length; run++)
+ {
+ currentChar = -1;
+ for( int gi = 0; gi < runs[ run ].getNumGlyphs(); gi++)
+ {
+ if( runs[ run ].getGlyphCharIndex( gi ) != currentChar )
+ {
+ charIndices[ i ][0] = run;
+ charIndices[ i ][1] = gi;
+ currentChar = runs[ run ].getGlyphCharIndex( gi );
+ i++;
+ }
+ }
+ }
+ }
+
+ private static String getText(AttributedCharacterIterator iter)
+ {
+ StringBuffer sb = new StringBuffer();
+ int idx = iter.getIndex();
+ for(char c = iter.first(); c != CharacterIterator.DONE; c = iter.next())
+ sb.append(c);
+ iter.setIndex( idx );
+ return sb.toString();
+ }
+
+ private static Font getFont(AttributedCharacterIterator iter)
+ {
+ Font f = (Font)iter.getAttribute(TextAttribute.FONT);
+ if( f == null )
+ {
+ int size;
+ Float i = (Float)iter.getAttribute(TextAttribute.SIZE);
+ if( i != null )
+ size = (int)i.floatValue();
+ else
+ size = 14;
+ f = new Font("Dialog", Font.PLAIN, size );
+ }
+ return f;
}
/**
@@ -179,10 +273,14 @@ public final class TextLayout implements Cloneable
gotDirection = true;
break;
}
+ determineWhiteSpace();
+ }
+ private void determineWhiteSpace()
+ {
// Determine if there's whitespace in the thing.
// Ignore trailing chars.
- i = string.length() - 1;
+ int i = string.length() - 1;
hasWhitespace = false;
while( i >= 0 && Character.isWhitespace( string.charAt(i) ) )
i--;
@@ -251,56 +349,42 @@ public final class TextLayout implements Cloneable
public Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint)
{
- if( firstEndpoint < 0 || secondEndpoint > getCharacterCount() )
+ if( secondEndpoint - firstEndpoint <= 0 )
+ return new Rectangle2D.Float(); // Hmm?
+
+ if( firstEndpoint < 0 || secondEndpoint > getCharacterCount())
return new Rectangle2D.Float();
GeneralPath gp = new GeneralPath();
- int i = 0; // run index
- double advance = 0;
-
- // go to first run
- while( runIndices[i + 1][1] < firstEndpoint )
- {
- advance += runs[i].getLogicalBounds().getWidth();
- i++;
- }
+
+ int ri = charIndices[ firstEndpoint ][0];
+ int gi = charIndices[ firstEndpoint ][1];
- int j = 0; // index into the run.
- if( runIndices[i][1] - runIndices[i][0] > 1 )
+ double advance = 0;
+
+ for( int i = 0; i < ri; i++ )
+ advance += runs[i].getLogicalBounds().getWidth();
+
+ for( int i = ri; i <= charIndices[ secondEndpoint - 1 ][0]; i++ )
{
- while( runs[i].getGlyphCharIndex( j + 1 ) <
- (firstEndpoint - runIndices[i][0] ) )j++;
- }
-
- gp.append(runs[i].getGlyphVisualBounds( j ), false);
- boolean keepGoing = true;;
+ int dg;
+ if( i == charIndices[ secondEndpoint - 1 ][0] )
+ dg = charIndices[ secondEndpoint - 1][1];
+ else
+ dg = runs[i].getNumGlyphs() - 1;
- do
- {
- while( j < runs[i].getNumGlyphs() &&
- runs[i].getGlyphCharIndex( j ) + runIndices[i][0] <
- secondEndpoint )
+ for( int j = 0; j <= dg; j++ )
{
Rectangle2D r2 = (runs[i].getGlyphVisualBounds( j )).
getBounds2D();
Point2D p = runs[i].getGlyphPosition( j );
- r2.setRect( advance + p.getX(), r2.getY(),
+ r2.setRect( advance + r2.getX(), r2.getY(),
r2.getWidth(), r2.getHeight() );
gp.append(r2, false);
- j++;
}
- if( j >= runs[i].getNumGlyphs() )
- {
- advance += runs[i].getLogicalBounds().getWidth();
- i++;
- j = 0;
- }
- else
- keepGoing = false;
+ advance += runs[i].getLogicalBounds().getWidth();
}
- while( keepGoing );
-
return gp;
}
@@ -384,55 +468,42 @@ public final class TextLayout implements Cloneable
public Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
Rectangle2D bounds)
{
- if( firstEndpoint < 0 || secondEndpoint > getCharacterCount() )
+ if( secondEndpoint - firstEndpoint <= 0 )
+ return new Rectangle2D.Float(); // Hmm?
+
+ if( firstEndpoint < 0 || secondEndpoint > getCharacterCount())
return new Rectangle2D.Float();
- int i = 0; // run index
- double advance = 0;
+ Rectangle2D r = null;
+ int ri = charIndices[ firstEndpoint ][0];
+ int gi = charIndices[ firstEndpoint ][1];
- // go to first run
- if( i > 0 )
- while( runIndices[i + 1][1] < firstEndpoint )
- {
- advance += runs[i].getLogicalBounds().getWidth();
- i++;
- }
+ double advance = 0;
+
+ for( int i = 0; i < ri; i++ )
+ advance += runs[i].getLogicalBounds().getWidth();
- int j = 0; // index into the run.
- if( runIndices[i][1] - runIndices[i][0] > 1 )
+ for( int i = ri; i <= charIndices[ secondEndpoint - 1 ][0]; i++ )
{
- while( runs[i].getGlyphCharIndex( j + 1 ) <
- (firstEndpoint - runIndices[i][0] ) )j++;
- }
-
- Rectangle2D r = (runs[i].getGlyphLogicalBounds( j )).getBounds2D();
- boolean keepGoing = true;;
+ int dg; // last index in this run to use.
+ if( i == charIndices[ secondEndpoint - 1 ][0] )
+ dg = charIndices[ secondEndpoint - 1][1];
+ else
+ dg = runs[i].getNumGlyphs() - 1;
- do
- {
- while( j < runs[i].getNumGlyphs() &&
- runs[i].getGlyphCharIndex( j ) + runIndices[i][0] <
- secondEndpoint )
+ for(; gi <= dg; gi++ )
{
- Rectangle2D r2 = (runs[i].getGlyphLogicalBounds( j )).
+ Rectangle2D r2 = (runs[i].getGlyphLogicalBounds( gi )).
getBounds2D();
- Point2D p = runs[i].getGlyphPosition( j );
- r2.setRect( advance + p.getX(), r2.getY(),
- r2.getWidth(), r2.getHeight() );
- r = r.createUnion( r2 );
- j++;
+ if( r == null )
+ r = r2;
+ else
+ r = r.createUnion(r2);
}
+ gi = 0; // reset glyph index into run for next run.
- if( j >= runs[i].getNumGlyphs() )
- {
- advance += runs[i].getLogicalBounds().getWidth();
- i++;
- j = 0;
- }
- else
- keepGoing = false;
+ advance += runs[i].getLogicalBounds().getWidth();
}
- while( keepGoing );
return r;
}
@@ -593,8 +664,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/libjava/classpath/java/awt/font/TextMeasurer.java b/libjava/classpath/java/awt/font/TextMeasurer.java
index 18c286c57c1..00cab8a878d 100644
--- a/libjava/classpath/java/awt/font/TextMeasurer.java
+++ b/libjava/classpath/java/awt/font/TextMeasurer.java
@@ -1,5 +1,5 @@
/* TextMeasurer.java
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,67 +38,154 @@ exception statement from your version. */
package java.awt.font;
-import gnu.classpath.NotImplementedException;
-
import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+import java.awt.Shape;
/**
- * @author Michael Koch
+ * TextMeasurer is a small utility class for measuring the length of laid-out
+ * text objects.
+ *
+ * @author Sven de Marothy
* @since 1.3
*/
public final class TextMeasurer implements Cloneable
{
- private AttributedCharacterIterator ci;
+ private AttributedCharacterIterator text;
private FontRenderContext frc;
-
+ private TextLayout totalLayout;
+ private int numChars;
+
+ /**
+ * Creates a TextMeasurer from a given text in the form of an
+ * <code>AttributedCharacterIterator</code> and a
+ * <code>FontRenderContext</code>.
+ */
public TextMeasurer (AttributedCharacterIterator text, FontRenderContext frc)
{
- this.ci = text;
+ this.text = text;
this.frc = frc;
+ totalLayout = new TextLayout( text, frc );
+ numChars = totalLayout.getCharacterCount();
}
+ /**
+ * Clones the TextMeasurer object
+ */
protected Object clone ()
{
- try
- {
- return super.clone ();
- }
- catch (CloneNotSupportedException e)
- {
- // This may never occur
- throw new InternalError ();
- }
+ return new TextMeasurer( text, frc );
}
+ /**
+ * Update the text if a character is deleted at the position deletePos
+ * @param newParagraph - the updated paragraph.
+ * @param deletePos - the deletion position
+ */
public void deleteChar (AttributedCharacterIterator newParagraph,
int deletePos)
- throws NotImplementedException
{
- throw new Error ("not implemented");
+ totalLayout = new TextLayout(newParagraph, frc);
+ if( deletePos < 0 || deletePos > totalLayout.getCharacterCount() )
+ throw new NullPointerException("Invalid deletePos:"+deletePos);
+ numChars = totalLayout.getCharacterCount();
+ text = newParagraph;
+ }
+
+ /**
+ * Update the text if a character is inserted at the position insertPos
+ * @param newParagraph - the updated paragraph.
+ * @param insertPos - the insertion position
+ */
+ public void insertChar (AttributedCharacterIterator newParagraph,
+ int insertPos)
+ {
+ totalLayout = new TextLayout(newParagraph, frc);
+ if( insertPos < 0 || insertPos > totalLayout.getCharacterCount() )
+ throw new NullPointerException("Invalid insertPos:"+insertPos);
+ numChars = totalLayout.getCharacterCount();
+ text = newParagraph;
}
+ /***
+ * Returns the total advance between two positions in the paragraph.
+ * Characters from start to limit-1 (inclusive) are included in this count.
+ *
+ * @param start - the starting character index.
+ * @param limit - the limiting index.
+ */
public float getAdvanceBetween (int start, int limit)
- throws NotImplementedException
{
- throw new Error ("not implemented");
+ Shape s = totalLayout.getLogicalHighlightShape( start, limit );
+ return (float)s.getBounds2D().getWidth();
}
+ /**
+ * Returns a <code>TextLayout</code> object corresponding to the characters
+ * from text to limit.
+ * @param start - the starting character index.
+ * @param limit - the limiting index.
+ */
public TextLayout getLayout (int start, int limit)
- throws NotImplementedException
{
- throw new Error ("not implemented");
+ if( start >= limit )
+ throw new IllegalArgumentException("Start position must be < limit.");
+ return new TextLayout( totalLayout, start, limit );
}
+ /**
+ * Returns the line-break index from a given starting index and a maximum
+ * advance. The index returned is the first character outside the given
+ * advance (or the limit of the string, if all remaining characters fit.)
+ *
+ * @param start - the starting index.
+ * @param maxAdvance - the maximum advance allowed.
+ * @return the index of the first character beyond maxAdvance, or the
+ * index of the last character + 1.
+ */
public int getLineBreakIndex (int start, float maxAdvance)
- throws NotImplementedException
- {
- throw new Error ("not implemented");
- }
+ {
+ if( start < 0 )
+ throw new IllegalArgumentException("Start parameter must be > 0.");
+
+ double remainingLength = getAdvanceBetween( start, numChars );
+
+ int guessOffset = (int)( ( (double)maxAdvance / (double)remainingLength)
+ * ( (double)numChars - (double)start ) );
+ guessOffset += start;
+ if( guessOffset > numChars )
+ guessOffset = numChars;
+
+ double guessLength = getAdvanceBetween( start, guessOffset );
+ boolean makeSmaller = ( guessLength > maxAdvance );
+ int inc = makeSmaller ? -1 : 1;
+ boolean keepGoing = true;
+
+ do
+ {
+ guessOffset = guessOffset + inc;
+ if( guessOffset <= start || guessOffset > numChars )
+ {
+ keepGoing = false;
+ }
+ else
+ {
+ guessLength = getAdvanceBetween( start, guessOffset );
+ if( makeSmaller && ( guessLength <= maxAdvance) )
+ keepGoing = false;
+ if( !makeSmaller && ( guessLength >= maxAdvance) )
+ keepGoing = false;
+ }
+ }
+ while( keepGoing );
- public void insertChar (AttributedCharacterIterator newParagraph,
- int insertPos)
- throws NotImplementedException
- {
- throw new Error ("not implemented");
+ // Return first index that doesn't fit.
+ if( !makeSmaller )
+ guessOffset--;
+
+ if( guessOffset > numChars )
+ return numChars;
+
+ return guessOffset;
}
}
diff --git a/libjava/classpath/java/awt/geom/GeneralPath.java b/libjava/classpath/java/awt/geom/GeneralPath.java
index 123833b118b..e0ca8e18357 100644
--- a/libjava/classpath/java/awt/geom/GeneralPath.java
+++ b/libjava/classpath/java/awt/geom/GeneralPath.java
@@ -65,8 +65,8 @@ import java.awt.Shape;
* &#x2019;up&#x2019;
* direction, one in the &#x2019;down&#x2019; direction) Point <b>B</b> in
* the image is inside (one intersection &#x2019;down&#x2019;)
- * Point <b>C</b> in the image is outside (two intersections
- * &#x2019;down&#x2019;)
+ * Point <b>C</b> in the image is inside (two intersections in the
+ * &#x2019;down&#x2019; direction)
*
* @see Line2D
* @see CubicCurve2D
@@ -247,10 +247,12 @@ public final class GeneralPath implements Shape, Cloneable
/**
* Closes the current subpath by drawing a line
- * back to the point of the last moveTo.
+ * back to the point of the last moveTo, unless the path is already closed.
*/
public void closePath()
{
+ if (index >= 1 && types[index - 1] == PathIterator.SEG_CLOSE)
+ return;
ensureSize(index + 1);
types[index] = PathIterator.SEG_CLOSE;
xpoints[index] = xpoints[subpath];
diff --git a/libjava/classpath/java/awt/image/BandedSampleModel.java b/libjava/classpath/java/awt/image/BandedSampleModel.java
index 24d315a1c35..afe62bdc4bd 100644
--- a/libjava/classpath/java/awt/image/BandedSampleModel.java
+++ b/libjava/classpath/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.
@@ -36,10 +36,11 @@ exception statement from your version. */
package java.awt.image;
+import gnu.java.awt.Buffers;
+
/**
- * 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 +62,61 @@ 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 data buffer that is compatible with this sample model.
+ *
+ * @return The new data buffer.
+ */
+ public DataBuffer createDataBuffer()
+ {
+ int size = scanlineStride * height;
+ return Buffers.createBuffer(getDataType(), size, numBanks);
+ }
+ /**
+ * 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, must be greater than zero).
+ * @param h the height (in pixels, must be greater than zero).
+ *
+ * @return The new sample model.
+ *
+ * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is
+ * not greater than zero.
+ * @throws IllegalArgumentException if <code>w * h</code> exceeds
+ * <code>Integer.MAX_VALUE</code>.
+ */
public SampleModel createCompatibleSampleModel(int w, int h)
{
// NOTE: blackdown 1.4.1 sets all offsets to 0. Sun's 1.4.2 docs
@@ -80,32 +125,32 @@ 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++)
- if (bankIndices[order[i]] > bankIndices[order[j]]
- || (bankIndices[order[i]] == bankIndices[order[j]]
- && bandOffsets[order[i]] > bandOffsets[order[j]]))
- {
- int t = order[i]; order[i] = order[j]; order[j] = t;
- }
+ for (int i = 0; i < bandOffsets.length; i++)
+ for (int j = i + 1; j < bandOffsets.length; j++)
+ if (bankIndices[order[i]] > bankIndices[order[j]]
+ || (bankIndices[order[i]] == bankIndices[order[j]]
+ && bandOffsets[order[i]] > bandOffsets[order[j]]))
+ {
+ int t = order[i]; order[i] = order[j]; order[j] = t;
+ }
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)
- {
- bank = bankIndices[order[i]];
- offset = 0;
- }
- newoffsets[order[i]] = offset;
- offset += w * scanlineStride;
+ if (bankIndices[order[i]] != bank)
+ {
+ bank = bankIndices[order[i]];
+ offset = 0;
+ }
+ newoffsets[order[i]] = offset;
+ offset += w * scanlineStride;
}
- return new BandedSampleModel(dataType, w, h, scanlineStride, bankIndices, newoffsets);
+ return new BandedSampleModel(dataType, w, h, w, bankIndices, newoffsets);
}
@@ -117,7 +162,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 +179,64 @@ 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)
{
+ if (x < 0 || y < 0)
+ throw new ArrayIndexOutOfBoundsException(
+ "x and y must not be less than 0.");
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 +247,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 +297,11 @@ 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 (x < 0 || y < 0)
+ throw new ArrayIndexOutOfBoundsException(
+ "x and y must not be less than 0.");
+ if (iArray == null)
+ iArray = new int[w * h * numBands];
int outOffset = 0;
int maxX = x + w;
int maxY = y + h;
@@ -247,18 +320,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 +407,11 @@ 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 (x < 0 || y < 0)
+ throw new ArrayIndexOutOfBoundsException(
+ "x and y must not be less than 0.");
+ if (iArray == null)
+ iArray = new int[w * h];
int outOffset = 0;
int maxX = x + w;
int maxY = y + h;
@@ -304,7 +427,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 +460,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 +468,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 +476,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 +484,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 +492,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 +500,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 +510,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 +567,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,24 +575,83 @@ 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)
{
+ if (x < 0 || y < 0)
+ throw new ArrayIndexOutOfBoundsException(
+ "x and y must not be less than 0.");
int inOffset = 0;
switch (getTransferType())
@@ -537,9 +746,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/libjava/classpath/java/awt/image/BufferedImage.java b/libjava/classpath/java/awt/image/BufferedImage.java
index 77b8d6cc174..76848db0833 100644
--- a/libjava/classpath/java/awt/image/BufferedImage.java
+++ b/libjava/classpath/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,
@@ -504,7 +530,10 @@ public class BufferedImage extends Image
int[] pixels = getRGB(x, y,
width, height,
(int[])null, offset, stride);
- ColorModel model = getColorModel();
+ // We already convert the color to RGB in the getRGB call, so
+ // we pass a simple RGB color model to the consumers.
+ ColorModel model = new DirectColorModel(32, 0xff0000, 0xff00, 0xff,
+ 0xff000000);
consumers.add(ic);
diff --git a/libjava/classpath/java/awt/image/BufferedImageOp.java b/libjava/classpath/java/awt/image/BufferedImageOp.java
index 2ecbec056a0..f6a24c976ab 100644
--- a/libjava/classpath/java/awt/image/BufferedImageOp.java
+++ b/libjava/classpath/java/awt/image/BufferedImageOp.java
@@ -1,5 +1,5 @@
/* BufferedImageOp.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,13 +43,65 @@ import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
/**
- * NEEDS DOCUMENTATION
+ * An operation that is performed on one <code>BufferedImage</code> (the
+ * source) producing a new <code>BufferedImage</code> (the destination).
*/
public interface BufferedImageOp
{
+ /**
+ * Performs an operation on the source image, returning the result in a
+ * <code>BufferedImage</code>. If <code>dest</code> is <code>null</code>, a
+ * new <code>BufferedImage</code> will be created by calling the
+ * {@link #createCompatibleDestImage} method. If <code>dest</code>
+ * is not <code>null</code>, the result is written to <code>dest</code> then
+ * returned (this avoids creating a new <code>BufferedImage</code> each
+ * time this method is called).
+ *
+ * @param src the source image.
+ * @param dst the destination image (<code>null</code> permitted).
+ *
+ * @return The filterd image.
+ */
BufferedImage filter(BufferedImage src, BufferedImage dst);
+
+ /**
+ * Returns the bounds of the destination image on the basis of this
+ * <code>BufferedImageOp</code> being applied to the specified source image.
+ *
+ * @param src the source image.
+ *
+ * @return The destination bounds.
+ */
Rectangle2D getBounds2D(BufferedImage src);
+
+ /**
+ * Returns a new <code>BufferedImage</code> that can be used by this
+ * <code>BufferedImageOp</code> as the destination image when filtering
+ * the specified source image.
+ *
+ * @param src the source image.
+ * @param dstCM the color model for the destination image.
+ *
+ * @return A new image that can be used as the destination image.
+ */
BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM);
+
+ /**
+ * Returns the point on the destination image that corresponds to the given
+ * point on the source image.
+ *
+ * @param src the source point.
+ * @param dst the destination point (<code>null</code> permitted).
+ *
+ * @return The destination point.
+ */
Point2D getPoint2D(Point2D src, Point2D dst);
+
+ /**
+ * Returns the rendering hints for this operation.
+ *
+ * @return The rendering hints.
+ */
RenderingHints getRenderingHints();
-} // interface BufferedImageOp
+
+}
diff --git a/libjava/classpath/java/awt/image/ByteLookupTable.java b/libjava/classpath/java/awt/image/ByteLookupTable.java
index df02d0a1bf7..ecc0023aff6 100644
--- a/libjava/classpath/java/awt/image/ByteLookupTable.java
+++ b/libjava/classpath/java/awt/image/ByteLookupTable.java
@@ -1,5 +1,5 @@
/* ByteLookupTable.java -- Java class for a pixel translation table.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,14 +60,20 @@ public class ByteLookupTable extends LookupTable
* components.
*
* @param offset Offset to be subtracted.
- * @param data Array of lookup tables.
+ * @param data Array of lookup tables (<code>null</code> not permitted).
* @exception IllegalArgumentException if offset &lt; 0 or data.length &lt; 1.
*/
public ByteLookupTable(int offset, byte[][] data)
throws IllegalArgumentException
{
super(offset, data.length);
- this.data = data;
+
+ // tests show that Sun's implementation creates a new array to store the
+ // references from the incoming 'data' array - not sure why, but we'll
+ // match that behaviour just in case it matters...
+ this.data = new byte[data.length][];
+ for (int i = 0; i < data.length; i++)
+ this.data[i] = data[i];
}
/**
@@ -77,13 +83,16 @@ public class ByteLookupTable extends LookupTable
* table. The same table is applied to all pixel components.
*
* @param offset Offset to be subtracted.
- * @param data Lookup table for all components.
+ * @param data Lookup table for all components (<code>null</code> not
+ * permitted).
* @exception IllegalArgumentException if offset &lt; 0.
*/
public ByteLookupTable(int offset, byte[] data)
throws IllegalArgumentException
{
super(offset, 1);
+ if (data == null)
+ throw new NullPointerException("Null 'data' argument.");
this.data = new byte[][] {data};
}
diff --git a/libjava/classpath/java/awt/image/ColorConvertOp.java b/libjava/classpath/java/awt/image/ColorConvertOp.java
index 18609e0c4b0..1f85a5ecd99 100644
--- a/libjava/classpath/java/awt/image/ColorConvertOp.java
+++ b/libjava/classpath/java/awt/image/ColorConvertOp.java
@@ -1,5 +1,5 @@
-/* ColorModel.java --
- Copyright (C) 2004 Free Software Foundation
+/* ColorConvertOp.java --
+ Copyright (C) 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -177,8 +177,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp
ColorModel scm = src.getColorModel();
for (int i = 0; i < spaces.length; i++)
{
- ColorModel cm = scm.cloneColorModel(spaces[i]);
- BufferedImage tmp = createCompatibleDestImage(src, cm);
+ BufferedImage tmp = createCompatibleDestImage(src, scm);
copyimage(src, tmp);
src = tmp;
}
@@ -189,6 +188,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp
// Apply final conversion
copyimage(src, dst);
+
return dst;
}
@@ -287,7 +287,12 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp
private void copyimage(BufferedImage src, BufferedImage dst)
{
Graphics2D gg = dst.createGraphics();
- gg.setRenderingHints(hints);
+
+ // If no hints are set there is no need to call
+ // setRenderingHints on the Graphics2D object.
+ if (hints != null)
+ gg.setRenderingHints(hints);
+
gg.drawImage(src, 0, 0, null);
gg.dispose();
}
diff --git a/libjava/classpath/java/awt/image/ColorModel.java b/libjava/classpath/java/awt/image/ColorModel.java
index e2f5378b4da..9e559db37d8 100644
--- a/libjava/classpath/java/awt/image/ColorModel.java
+++ b/libjava/classpath/java/awt/image/ColorModel.java
@@ -1,5 +1,5 @@
/* ColorModel.java --
- Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.java.awt.Buffers;
import java.awt.Point;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
-import java.lang.reflect.Constructor;
import java.util.Arrays;
/**
@@ -163,32 +162,6 @@ public abstract class ColorModel implements Transparency
this.transparency = transparency;
this.transferType = transferType;
}
-
- // This is a hook for ColorConvertOp to create a colormodel with
- // a new colorspace
- ColorModel cloneColorModel(ColorSpace cspace)
- {
- Class cls = this.getClass();
- ColorModel cm;
- try {
- // This constructor will exist.
- Constructor ctor =
- cls.getConstructor(new Class[]{int.class, int[].class,
- ColorSpace.class, boolean.class,
- boolean.class, int.class, int.class});
- cm = (ColorModel)ctor.
- newInstance(new Object[]{new Integer(pixel_bits),
- bits, cspace, Boolean.valueOf(hasAlpha),
- Boolean.valueOf(isAlphaPremultiplied),
- new Integer(transparency),
- new Integer(transferType)});
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException();
- }
- return cm;
- }
public void finalize()
{
diff --git a/libjava/classpath/java/awt/image/ComponentSampleModel.java b/libjava/classpath/java/awt/image/ComponentSampleModel.java
index b4e9450b060..bccabbbcadb 100644
--- a/libjava/classpath/java/awt/image/ComponentSampleModel.java
+++ b/libjava/classpath/java/awt/image/ComponentSampleModel.java
@@ -272,9 +272,7 @@ public class ComponentSampleModel extends SampleModel
// Maybe this value should be precalculated in the constructor?
int highestOffset = 0;
for (int b = 0; b < numBands; b++)
- {
- highestOffset = Math.max(highestOffset, bandOffsets[b]);
- }
+ highestOffset = Math.max(highestOffset, bandOffsets[b]);
int size = pixelStride * (width - 1) + scanlineStride * (height - 1)
+ highestOffset + 1;
@@ -678,6 +676,9 @@ public class ComponentSampleModel extends SampleModel
*/
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
+ if (x < 0 || x >= width || y < 0 || y >= height)
+ throw new ArrayIndexOutOfBoundsException("Pixel (" + x + ", " + y
+ + ") is out of bounds.");
int offset = pixelStride * x + scanlineStride * y;
if (iArray == null)
iArray = new int[numBands];
@@ -736,10 +737,16 @@ public class ComponentSampleModel extends SampleModel
*
* @return The sample value.
*
+ * @throws ArrayIndexOutOfBoundsException if <code>(x, y)</code> is outside
+ * the bounds <code>[0, 0, width, height]</code>.
+ *
* @see #setSample(int, int, int, int, DataBuffer)
*/
public int getSample(int x, int y, int b, DataBuffer data)
{
+ if (x < 0 || x >= width || y < 0 || y >= height)
+ throw new ArrayIndexOutOfBoundsException("Sample (" + x + ", " + y
+ + ") is out of bounds.");
return data.getElem(bankIndices[b], getOffset(x, y, b));
}
diff --git a/libjava/classpath/java/awt/image/ConvolveOp.java b/libjava/classpath/java/awt/image/ConvolveOp.java
index 1f73f75b233..ffb834874fa 100644
--- a/libjava/classpath/java/awt/image/ConvolveOp.java
+++ b/libjava/classpath/java/awt/image/ConvolveOp.java
@@ -1,5 +1,5 @@
/* ConvolveOp.java --
- Copyright (C) 2004, 2005 Free Software Foundation -- ConvolveOp
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation -- ConvolveOp
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import java.util.Arrays;
/**
* Convolution filter.
@@ -190,112 +189,101 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster,
* java.awt.image.WritableRaster)
*/
- public final WritableRaster filter(Raster src, WritableRaster dest) {
+ public final WritableRaster filter(Raster src, WritableRaster dest)
+ {
if (src == dest)
- throw new IllegalArgumentException();
- if (src.getWidth() < kernel.getWidth() ||
- src.getHeight() < kernel.getHeight())
- throw new ImagingOpException(null);
-
+ throw new IllegalArgumentException("src == dest is not allowed.");
+ if (kernel.getWidth() > src.getWidth()
+ || kernel.getHeight() > src.getHeight())
+ throw new ImagingOpException("The kernel is too large.");
if (dest == null)
dest = createCompatibleDestRaster(src);
- else if (src.numBands != dest.numBands)
- throw new ImagingOpException(null);
+ else if (src.getNumBands() != dest.getNumBands())
+ throw new ImagingOpException("src and dest have different band counts.");
- // Deal with bottom edge
- if (edge == EDGE_ZERO_FILL)
- {
- float[] zeros = new float[src.getNumBands() * src.getWidth()
- * (kernel.getYOrigin() - 1)];
- Arrays.fill(zeros, 0);
- dest.setPixels(src.getMinX(), src.getMinY(), src.getWidth(),
- kernel.getYOrigin() - 1, zeros);
- }
- else
- {
- float[] vals = new float[src.getNumBands() * src.getWidth()
- * (kernel.getYOrigin() - 1)];
- src.getPixels(src.getMinX(), src.getMinY(), src.getWidth(),
- kernel.getYOrigin() - 1, vals);
- dest.setPixels(src.getMinX(), src.getMinY(), src.getWidth(),
- kernel.getYOrigin() - 1, vals);
- }
+ // calculate the borders that the op can't reach...
+ int kWidth = kernel.getWidth();
+ int kHeight = kernel.getHeight();
+ int left = kernel.getXOrigin();
+ int right = Math.max(kWidth - left - 1, 0);
+ int top = kernel.getYOrigin();
+ int bottom = Math.max(kHeight - top - 1, 0);
- // Handle main section
+ // process the region that is reachable...
+ int regionW = src.width - left - right;
+ int regionH = src.height - top - bottom;
float[] kvals = kernel.getKernelData(null);
+ float[] tmp = new float[kWidth * kHeight];
- float[] tmp = new float[kernel.getWidth() * kernel.getHeight()];
- for (int y = src.getMinY() + kernel.getYOrigin();
- y < src.getMinY() + src.getHeight() - kernel.getYOrigin() / 2; y++)
- {
- // Handle unfiltered edge pixels at start of line
- float[] t1 = new float[(kernel.getXOrigin() - 1) * src.getNumBands()];
- if (edge == EDGE_ZERO_FILL)
- Arrays.fill(t1, 0);
- else
- src.getPixels(src.getMinX(), y, kernel.getXOrigin() - 1, 1, t1);
- dest.setPixels(src.getMinX(), y, kernel.getXOrigin() - 1, 1, t1);
-
- for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
+ for (int x = 0; x < regionW; x++)
{
- // FIXME: This needs a much more efficient implementation
- for (int b = 0; b < src.getNumBands(); b++)
- {
- float v = 0;
- src.getSamples(x, y, kernel.getWidth(), kernel.getHeight(), b, tmp);
- for (int i=0; i < tmp.length; i++)
- v += tmp[i] * kvals[i];
- dest.setSample(x, y, b, v);
- }
+ for (int y = 0; y < regionH; y++)
+ {
+ // FIXME: This needs a much more efficient implementation
+ for (int b = 0; b < src.getNumBands(); b++)
+ {
+ float v = 0;
+ src.getSamples(x, y, kWidth, kHeight, b, tmp);
+ for (int i = 0; i < tmp.length; i++)
+ v += tmp[tmp.length - i - 1] * kvals[i];
+ // FIXME: in the above line, I've had to reverse the order of
+ // the samples array to make the tests pass. I haven't worked
+ // out why this is necessary.
+ dest.setSample(x + kernel.getXOrigin(), y + kernel.getYOrigin(),
+ b, v);
+ }
+ }
}
-
- // Handle unfiltered edge pixels at end of line
- float[] t2 = new float[(kernel.getWidth() / 2) * src.getNumBands()];
- if (edge == EDGE_ZERO_FILL)
- Arrays.fill(t2, 0);
- else
- src.getPixels(src.getMinX() + src.getWidth()
- - (kernel.getWidth() / 2),
- y, kernel.getWidth() / 2, 1, t2);
- dest.setPixels(src.getMinX() + src.getWidth() - (kernel.getWidth() / 2),
- y, kernel.getWidth() / 2, 1, t2);
- }
- for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
- for (int x = src.getMinX(); x< src.getWidth() + src.getMinX(); x++)
+
+ // fill in the top border
+ fillEdge(src, dest, 0, 0, src.width, top, edge);
+
+ // fill in the bottom border
+ fillEdge(src, dest, 0, src.height - bottom, src.width, bottom, edge);
+
+ // fill in the left border
+ fillEdge(src, dest, 0, top, left, regionH, edge);
+
+ // fill in the right border
+ fillEdge(src, dest, src.width - right, top, right, regionH, edge);
+
+ return dest;
+ }
+
+ /**
+ * Fills a range of pixels (typically at the edge of a raster) with either
+ * zero values (if <code>edgeOp</code> is <code>EDGE_ZERO_FILL</code>) or the
+ * corresponding pixel values from the source raster (if <code>edgeOp</code>
+ * is <code>EDGE_NO_OP</code>). This utility method is called by the
+ * {@link #fillEdge(Raster, WritableRaster, int, int, int, int, int)} method.
+ *
+ * @param src the source raster.
+ * @param dest the destination raster.
+ * @param x the x-coordinate of the top left pixel in the range.
+ * @param y the y-coordinate of the top left pixel in the range.
+ * @param w the width of the pixel range.
+ * @param h the height of the pixel range.
+ * @param edgeOp indicates how to determine the values for the range
+ * (either {@link #EDGE_ZERO_FILL} or {@link #EDGE_NO_OP}).
+ */
+ private void fillEdge(Raster src, WritableRaster dest, int x, int y, int w,
+ int h, int edgeOp)
+ {
+ if (w <= 0)
+ return;
+ if (h <= 0)
+ return;
+ if (edgeOp == EDGE_ZERO_FILL) // fill region with zeroes
{
-
+ float[] zeros = new float[src.getNumBands() * w * h];
+ dest.setPixels(x, y, w, h, zeros);
}
- for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
- for (int x = src.getMinX(); x< src.getWidth() + src.getMinX(); x++)
+ else // copy pixels from source
{
-
+ float[] pixels = new float[src.getNumBands() * w * h];
+ src.getPixels(x, y, w, h, pixels);
+ dest.setPixels(x, y, w, h, pixels);
}
-
- // Handle top edge
- if (edge == EDGE_ZERO_FILL)
- {
- float[] zeros = new float[src.getNumBands() * src.getWidth() *
- (kernel.getHeight() / 2)];
- Arrays.fill(zeros, 0);
- dest.setPixels(src.getMinX(),
- src.getHeight() + src.getMinY() - (kernel.getHeight() / 2),
- src.getWidth(), kernel.getHeight() / 2, zeros);
- }
- else
- {
- float[] vals = new float[src.getNumBands() * src.getWidth() *
- (kernel.getHeight() / 2)];
- src.getPixels(src.getMinX(),
- src.getHeight() + src.getMinY()
- - (kernel.getHeight() / 2),
- src.getWidth(), kernel.getHeight() / 2, vals);
- dest.setPixels(src.getMinX(),
- src.getHeight() + src.getMinY()
- - (kernel.getHeight() / 2),
- src.getWidth(), kernel.getHeight() / 2, vals);
- }
-
- return dest;
}
/* (non-Javadoc)
diff --git a/libjava/classpath/java/awt/image/DataBuffer.java b/libjava/classpath/java/awt/image/DataBuffer.java
index 9e4f714180a..5a2cfd3b0e5 100644
--- a/libjava/classpath/java/awt/image/DataBuffer.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/image/Kernel.java b/libjava/classpath/java/awt/image/Kernel.java
index f7c29c3cde9..8361c0cf97d 100644
--- a/libjava/classpath/java/awt/image/Kernel.java
+++ b/libjava/classpath/java/awt/image/Kernel.java
@@ -1,5 +1,5 @@
/* Kernel.java -- Java class for an image processing kernel
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,21 +44,32 @@ package java.awt.image;
* values representing a 2-dimensional array in row-major order.
*
* @author Jerry Quinn (jlquinn@optonline.net)
- * @version 1.0
*/
public class Kernel implements Cloneable
{
+ /** The kernel width. */
private final int width;
+
+ /** The kernel height. */
private final int height;
+
+ /** Internal storage for the kernel's values. */
private final float[] data;
/**
- * Creates a new <code>Kernel</code> instance.
+ * Creates a new <code>Kernel</code> instance with the specified dimensions
+ * and values. The first <code>width * height</code> values in the specified
+ * <code>data</code> array are copied to internal storage.
*
- * @param width The 2D width of data.
- * @param height The 2D height of data.
- * @param data The source data array.
- * @exception IllegalArgumentException if width * height < data.length.
+ * @param width the kernel width.
+ * @param height the kernel height.
+ * @param data the source data array (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>data.length</code> is less than
+ * <code>width * height</code>.
+ * @throws IllegalArgumentException if <code>width</code> or
+ * <code>height</code> is less than zero.
+ * @throws NullPointerException if <code>data</code> is <code>null</code>.
*/
public Kernel(int width, int height, float[] data)
throws IllegalArgumentException
@@ -72,7 +83,10 @@ public class Kernel implements Cloneable
}
/**
- * Return the X origin: (width - 1) / 2
+ * Returns the x-origin for the kernel, which is calculated as
+ * <code>(width - 1) / 2</code>.
+ *
+ * @return The x-origin for the kernel.
*/
public final int getXOrigin()
{
@@ -80,7 +94,10 @@ public class Kernel implements Cloneable
}
/**
- * Return the Y origin: (height - 1) / 2
+ * Returns the y-origin for the kernel, which is calculated as
+ * <code>(height - 1) / 2</code>.
+ *
+ * @return The y-origin for the kernel.
*/
public final int getYOrigin()
{
@@ -88,6 +105,8 @@ public class Kernel implements Cloneable
}
/**
+ * Returns the kernel width (as supplied to the constructor).
+ *
* @return The kernel width.
*/
public final int getWidth()
@@ -96,6 +115,8 @@ public class Kernel implements Cloneable
}
/**
+ * Returns the kernel height (as supplied to the constructor).
+ *
* @return The kernel height.
*/
public final int getHeight()
@@ -104,20 +125,25 @@ public class Kernel implements Cloneable
}
/**
- * Return the kernel data.
+ * Returns an array containing a copy of the kernel data. If the
+ * <code>data</code> argument is non-<code>null</code>, the kernel values
+ * are copied into it and then <code>data</code> is returned as the result.
+ * If the <code>data</code> argument is <code>null</code>, this method
+ * allocates a new array then populates and returns it.
*
- * If data is null, allocates a new array and returns it. Otherwise, the
- * kernel values are copied into data.
- *
- * @param data Array to copy values into, or null.
+ * @param data an array to copy the return values into (if
+ * <code>null</code>, a new array is allocated).
+ *
* @return The array with copied values.
- * @exception IllegalArgumentException if data != null and too small.
+ *
+ * @throws IllegalArgumentException if <code>data.length</code> is less than
+ * the kernel's <code>width * height</code>.
*/
public final float[] getKernelData(float[] data)
throws IllegalArgumentException
{
if (data == null)
- return (float[])this.data.clone();
+ return (float[]) this.data.clone();
if (data.length < this.data.length)
throw new IllegalArgumentException();
@@ -127,13 +153,15 @@ public class Kernel implements Cloneable
}
/**
+ * Returns a clone of this kernel.
+ *
* @return a clone of this Kernel.
*/
public Object clone()
{
try
{
- return super.clone();
+ return super.clone();
}
catch (CloneNotSupportedException e)
{
diff --git a/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java b/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java
index 18a6e555205..8732e57659e 100644
--- a/libjava/classpath/java/awt/image/MultiPixelPackedSampleModel.java
+++ b/libjava/classpath/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,163 @@ 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).
+ *
+ * @see #getBitOffset(int)
+ */
public int getOffset(int x, int y)
{
- return scanlineStride * y + ((dataBitOffset + x*numberOfBits) / elemBits);
+ 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;
+ 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);
}
/**
@@ -207,68 +333,82 @@ public class MultiPixelPackedSampleModel extends SampleModel
* array obj, since there is only one band. 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, Object,
+ * 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:
- if (obj == null) obj = new byte[1];
- ((byte[])obj)[0] = (byte)pixel;
- return obj;
- case DataBuffer.TYPE_USHORT:
- if (obj == null) obj = new short[1];
- ((short[])obj)[0] = (short)pixel;
- return obj;
- case DataBuffer.TYPE_INT:
- if (obj == null) obj = new int[1];
- ((int[])obj)[0] = pixel;
- return obj;
- default:
- // Seems like the only sensible thing to do.
- throw new ClassCastException();
- }
+ {
+ case DataBuffer.TYPE_BYTE:
+ if (obj == null)
+ obj = new byte[1];
+ ((byte[]) obj)[0] = (byte) pixel;
+ return obj;
+ case DataBuffer.TYPE_USHORT:
+ if (obj == null)
+ obj = new short[1];
+ ((short[]) obj)[0] = (short) pixel;
+ return obj;
+ case DataBuffer.TYPE_INT:
+ if (obj == null)
+ obj = new int[1];
+ ((int[]) obj)[0] = pixel;
+ return obj;
+ default:
+ // Seems like the only sensible thing to do.
+ throw new ClassCastException();
+ }
}
+ /**
+ * 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];
+ if (iArray == null)
+ iArray = new int[1];
iArray[0] = getSample(x, y, 0, data);
-
return iArray;
}
- public int[] getPixels(int x, int y, int w, int h, int[] iArray,
- DataBuffer data)
- {
- int offset = getOffset(x, y);
- if (iArray == null) iArray = new int[w*h];
- int outOffset = 0;
- for (y=0; y<h; y++)
- {
- int lineOffset = offset;
- for (x=0; x<w;)
- {
- int samples = data.getElem(lineOffset++);
- for (int b=0; b<numElems && x<w; b++)
- {
- iArray[outOffset++] = (samples & bitMasks[b]) >>> bitOffsets[b];
- x++;
- }
- }
- offset += scanlineStride;
- }
- 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 =
@@ -286,72 +426,82 @@ public class MultiPixelPackedSampleModel extends SampleModel
* @param y The y-coordinate 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)
*/
public void setDataElements(int x, int y, Object obj, DataBuffer data)
{
int transferType = getTransferType();
- if (getTransferType() != data.getDataType())
- {
- throw new IllegalArgumentException("transfer type ("+
- getTransferType()+"), "+
- "does not match data "+
- "buffer type (" +
- data.getDataType() +
- ").");
- }
-
- int offset = getOffset(x, y);
-
try
{
- switch (transferType)
- {
- case DataBuffer.TYPE_BYTE:
- {
- DataBufferByte out = (DataBufferByte) data;
- byte[] in = (byte[]) obj;
- out.getData()[offset] = in[0];
- return;
- }
- case DataBuffer.TYPE_USHORT:
- {
- DataBufferUShort out = (DataBufferUShort) data;
- short[] in = (short[]) obj;
- out.getData()[offset] = in[0];
- return;
- }
- case DataBuffer.TYPE_INT:
- {
- DataBufferInt out = (DataBufferInt) data;
- int[] in = (int[]) obj;
- out.getData()[offset] = in[0];
- return;
- }
- default:
- throw new ClassCastException("Unsupported data type");
- }
+ switch (transferType)
+ {
+ case DataBuffer.TYPE_BYTE:
+ {
+ byte[] in = (byte[]) obj;
+ setSample(x, y, 0, in[0] & 0xFF, data);
+ return;
+ }
+ case DataBuffer.TYPE_USHORT:
+ {
+ short[] in = (short[]) obj;
+ setSample(x, y, 0, in[0] & 0xFFFF, data);
+ return;
+ }
+ case DataBuffer.TYPE_INT:
+ {
+ int[] in = (int[]) obj;
+ setSample(x, y, 0, in[0], data);
+ return;
+ }
+ default:
+ throw new ClassCastException("Unsupported data type");
+ }
}
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;
- throw new ArrayIndexOutOfBoundsException(msg);
+ String msg = "While writing data elements" +
+ ", x=" + x + ", y=" + y +
+ ", width=" + width + ", height=" + height +
+ ", scanlineStride=" + scanlineStride +
+ ", offset=" + getOffset(x, y) +
+ ", data.getSize()=" + data.getSize() +
+ ", data.getOffset()=" + data.getOffset() +
+ ": " + aioobe;
+ throw new ArrayIndexOutOfBoundsException(msg);
}
- }
+ }
+ /**
+ * 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 +517,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/libjava/classpath/java/awt/image/Raster.java b/libjava/classpath/java/awt/image/Raster.java
index 4af958a17c7..160f8be8b51 100644
--- a/libjava/classpath/java/awt/image/Raster.java
+++ b/libjava/classpath/java/awt/image/Raster.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation
+/* Copyright (C) 2000, 2002, 2003, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -41,39 +41,80 @@ import java.awt.Point;
import java.awt.Rectangle;
/**
+ * A rectangular collection of pixels composed from a {@link DataBuffer} which
+ * stores the pixel values, and a {@link SampleModel} which is used to retrieve
+ * the pixel values.
+ *
* @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
*/
public class Raster
{
+ /** The sample model used to access the pixel values. */
protected SampleModel sampleModel;
+
+ /** The data buffer used to store the pixel values. */
protected DataBuffer dataBuffer;
+
+ /** The x-coordinate of the top left corner of the raster. */
protected int minX;
+
+ /** The y-coordinate of the top left corner of the raster. */
protected int minY;
+
+ /** The width of the raster. */
protected int width;
+
+ /** The height of the raster. */
protected int height;
+
protected int sampleModelTranslateX;
+
protected int sampleModelTranslateY;
+
+ /** The number of bands. */
protected int numBands;
+
protected int numDataElements;
+
+ /** The raster's parent. */
protected Raster parent;
+ /**
+ * Creates a new raster.
+ *
+ * @param sampleModel the sample model.
+ * @param origin the origin.
+ */
protected Raster(SampleModel sampleModel, Point origin)
{
this(sampleModel, sampleModel.createDataBuffer(), origin);
}
+ /**
+ * Creates a new raster.
+ *
+ * @param sampleModel the sample model.
+ * @param dataBuffer the data buffer.
+ * @param origin the origin.
+ */
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
- Point origin)
+ Point origin)
{
- this(sampleModel, dataBuffer,
- new Rectangle(origin.x, origin.y,
- sampleModel.getWidth(), sampleModel.getHeight()),
- origin, null);
+ this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y,
+ sampleModel.getWidth(), sampleModel.getHeight()), origin, null);
}
+ /**
+ * Creates a new raster.
+ *
+ * @param sampleModel the sample model.
+ * @param dataBuffer the data buffer.
+ * @param aRegion the raster's bounds.
+ * @param sampleModelTranslate the translation (<code>null</code> permitted).
+ * @param parent the raster's parent.
+ */
protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
- Rectangle aRegion,
- Point sampleModelTranslate, Raster parent)
+ Rectangle aRegion, Point sampleModelTranslate, Raster parent)
{
this.sampleModel = sampleModel;
this.dataBuffer = dataBuffer;
@@ -95,70 +136,127 @@ public class Raster
this.parent = parent;
}
+ /**
+ * Creates an interleaved raster using the specified data type.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param bands the number of bands.
+ * @param location
+ *
+ * @return The new raster.
+ */
public static WritableRaster createInterleavedRaster(int dataType,
- int w, int h,
- int bands,
- Point location)
+ int w, int h, int bands, Point location)
{
int[] bandOffsets = new int[bands];
// TODO: Maybe not generate this every time.
- for (int b=0; b<bands; b++) bandOffsets[b] = b;
+ for (int b = 0; b < bands; b++)
+ bandOffsets[b] = b;
- int scanlineStride = bands*w;
+ int scanlineStride = bands * w;
return createInterleavedRaster(dataType, w, h, scanlineStride, bands,
- bandOffsets, location);
+ bandOffsets, location);
}
- public static WritableRaster createInterleavedRaster(int dataType,
- int w, int h,
- int scanlineStride,
- int pixelStride,
- int[] bandOffsets,
- Point location)
- {
- SampleModel sm = new ComponentSampleModel(dataType,
- w, h,
- pixelStride,
- scanlineStride,
- bandOffsets);
+ /**
+ * Creates an interleaved raster.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param scanlineStride the number of data elements from a sample on one
+ * row to the corresponding sample on the next row.
+ * @param pixelStride the number of elements from a sample in one pixel to
+ * the corresponding sample in the next pixel.
+ * @param bandOffsets the band offsets.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createInterleavedRaster(int dataType,
+ int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets,
+ Point location)
+ {
+ SampleModel sm = new ComponentSampleModel(dataType, w, h, pixelStride,
+ scanlineStride, bandOffsets);
return createWritableRaster(sm, location);
}
- public static WritableRaster createBandedRaster(int dataType,
- int w, int h, int bands,
- Point location)
+ /**
+ * Creates a new banded raster.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param bands the number of bands.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createBandedRaster(int dataType, int w, int h,
+ int bands, Point location)
{
SampleModel sm = new BandedSampleModel(dataType, w, h, bands);
return createWritableRaster(sm, location);
}
- public static WritableRaster createBandedRaster(int dataType,
- int w, int h,
- int scanlineStride,
- int[] bankIndices,
- int[] bandOffsets,
- Point location)
+ /**
+ * Creates a new banded raster.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param scanlineStride the number of data elements from a sample on one
+ * row to the corresponding sample on the next row.
+ * @param bankIndices the index for each bank.
+ * @param bandOffsets the offset for each band.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createBandedRaster(int dataType, int w, int h,
+ int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location)
{
SampleModel sm = new BandedSampleModel(dataType, w, h, scanlineStride,
- bankIndices, bandOffsets);
+ bankIndices, bandOffsets);
return createWritableRaster(sm, location);
}
- public static WritableRaster createPackedRaster(int dataType,
- int w, int h,
- int[] bandMasks,
- Point location)
+ /**
+ * Creates a new packed raster.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param bandMasks the bit mask for each band.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createPackedRaster(int dataType, int w, int h,
+ int[] bandMasks, Point location)
{
- SampleModel sm = new SinglePixelPackedSampleModel(dataType,
- w, h,
- bandMasks);
+ SampleModel sm = new SinglePixelPackedSampleModel(dataType, w, h,
+ bandMasks);
return createWritableRaster(sm, location);
}
+ /**
+ * Creates a new raster.
+ *
+ * @param dataType the data type.
+ * @param w the width.
+ * @param h the height.
+ * @param bands the number of bands.
+ * @param bitsPerBand the number of bits per band.
+ * @param location
+ *
+ * @return The new raster.
+ */
public static WritableRaster createPackedRaster(int dataType,
- int w, int h,
- int bands, int bitsPerBand,
- Point location)
+ int w, int h, int bands, int bitsPerBand, Point location)
{
if (bands <= 0 || (bands * bitsPerBand > getTypeBits(dataType)))
throw new IllegalArgumentException();
@@ -166,135 +264,238 @@ public class Raster
SampleModel sm;
if (bands == 1)
- sm = new MultiPixelPackedSampleModel(dataType, w, h, bitsPerBand);
+ sm = new MultiPixelPackedSampleModel(dataType, w, h, bitsPerBand);
else
{
- int[] bandMasks = new int[bands];
- int mask = 0x1;
- for (int bits = bitsPerBand; --bits != 0;)
- mask = (mask << 1) | 0x1;
- for (int i = 0; i < bands; i++)
- {
- bandMasks[i] = mask;
- mask <<= bitsPerBand;
- }
-
- sm = new SinglePixelPackedSampleModel(dataType, w, h, bandMasks);
+ int[] bandMasks = new int[bands];
+ int mask = 0x1;
+ for (int bits = bitsPerBand; --bits != 0;)
+ mask = (mask << 1) | 0x1;
+ for (int i = 0; i < bands; i++)
+ {
+ bandMasks[i] = mask;
+ mask <<= bitsPerBand;
+ }
+
+ sm = new SinglePixelPackedSampleModel(dataType, w, h, bandMasks);
}
return createWritableRaster(sm, location);
}
- public static WritableRaster
- createInterleavedRaster(DataBuffer dataBuffer, int w, int h,
- int scanlineStride, int pixelStride,
- int[] bandOffsets, Point location)
+ /**
+ * Creates a new interleaved raster.
+ *
+ * @param dataBuffer the data buffer.
+ * @param w the width.
+ * @param h the height.
+ * @param scanlineStride the number of data elements from a sample on one
+ * row to the corresponding sample on the next row.
+ * @param pixelStride the number of elements from a sample in one pixel to
+ * the corresponding sample in the next pixel.
+ * @param bandOffsets the offset for each band.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
+ int w, int h, int scanlineStride, int pixelStride, int[] bandOffsets,
+ Point location)
{
SampleModel sm = new ComponentSampleModel(dataBuffer.getDataType(),
- w, h,
- scanlineStride,
- pixelStride,
- bandOffsets);
+ w, h, scanlineStride, pixelStride, bandOffsets);
return createWritableRaster(sm, dataBuffer, location);
}
- public static
- WritableRaster createBandedRaster(DataBuffer dataBuffer,
- int w, int h,
- int scanlineStride,
- int[] bankIndices,
- int[] bandOffsets,
- Point location)
+ /**
+ * Creates a new banded raster.
+ *
+ * @param dataBuffer the data buffer.
+ * @param w the width.
+ * @param h the height.
+ * @param scanlineStride the number of data elements from a sample on one
+ * row to the corresponding sample on the next row.
+ * @param bankIndices the index for each bank.
+ * @param bandOffsets the band offsets.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
+ int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets,
+ Point location)
{
SampleModel sm = new BandedSampleModel(dataBuffer.getDataType(),
- w, h, scanlineStride,
- bankIndices, bandOffsets);
+ w, h, scanlineStride, bankIndices, bandOffsets);
return createWritableRaster(sm, dataBuffer, location);
}
- public static WritableRaster
- createPackedRaster(DataBuffer dataBuffer,
- int w, int h,
- int scanlineStride,
- int[] bandMasks,
- Point location)
+ /**
+ * Creates a new packed raster.
+ *
+ * @param dataBuffer the data buffer.
+ * @param w the width.
+ * @param h the height.
+ * @param scanlineStride the number of data elements from a sample on one
+ * row to the corresponding sample on the next row.
+ * @param bandMasks the bit mask for each band.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
+ int w, int h, int scanlineStride, int[] bandMasks, Point location)
{
- SampleModel sm =
- new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
- w, h,
- scanlineStride,
- bandMasks);
+ SampleModel sm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
+ w, h, scanlineStride, bandMasks);
return createWritableRaster(sm, dataBuffer, location);
}
- public static WritableRaster
- createPackedRaster(DataBuffer dataBuffer,
- int w, int h,
- int bitsPerPixel,
- Point location)
- {
- SampleModel sm =
- new MultiPixelPackedSampleModel(dataBuffer.getDataType(),
- w, h,
- bitsPerPixel);
+ /**
+ * Creates a new packed raster.
+ *
+ * @param dataBuffer the data buffer.
+ * @param w the width.
+ * @param h the height.
+ * @param bitsPerPixel the number of bits per pixel.
+ * @param location
+ *
+ * @return The new raster.
+ */
+ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
+ int w, int h, int bitsPerPixel, Point location)
+ {
+ SampleModel sm = new MultiPixelPackedSampleModel(dataBuffer.getDataType(),
+ w, h, bitsPerPixel);
return createWritableRaster(sm, dataBuffer, location);
}
+ /**
+ * Creates a new raster.
+ *
+ * @param sm the sample model.
+ * @param db the data buffer.
+ * @param location
+ *
+ * @return The new raster.
+ */
public static Raster createRaster(SampleModel sm, DataBuffer db,
- Point location)
+ Point location)
{
return new Raster(sm, db, location);
}
+ /**
+ * Creates a new writable raster.
+ *
+ * @param sm the sample model.
+ * @param location
+ *
+ * @return The new writable raster.
+ */
public static WritableRaster createWritableRaster(SampleModel sm,
- Point location)
+ Point location)
{
return new WritableRaster(sm, location);
}
+ /**
+ * Creates a new writable raster.
+ *
+ * @param sm the sample model.
+ * @param db the data buffer.
+ * @param location
+ *
+ * @return The new writable raster.
+ */
public static WritableRaster createWritableRaster(SampleModel sm,
- DataBuffer db,
- Point location)
+ DataBuffer db, Point location)
{
return new WritableRaster(sm, db, location);
}
+ /**
+ * Returns the raster's parent.
+ *
+ * @return The raster's parent.
+ */
public Raster getParent()
{
return parent;
}
+ /**
+ * Returns the x-translation.
+ *
+ * @return The x-translation.
+ */
public final int getSampleModelTranslateX()
{
return sampleModelTranslateX;
}
+ /**
+ * Returns the y-translation.
+ *
+ * @return The y-translation.
+ */
public final int getSampleModelTranslateY()
{
return sampleModelTranslateY;
}
+ /**
+ * Creates a new writable raster that is compatible with this raster.
+ *
+ * @return A new writable raster.
+ */
public WritableRaster createCompatibleWritableRaster()
{
return new WritableRaster(getSampleModel(), new Point(minX, minY));
}
+ /**
+ * Creates a new writable raster that is compatible with this raster.
+ *
+ * @param w the width.
+ * @param h the height.
+ *
+ * @return A new writable raster.
+ */
public WritableRaster createCompatibleWritableRaster(int w, int h)
{
return createCompatibleWritableRaster(minX, minY, w, h);
}
+ /**
+ * Creates a new writable raster that is compatible with this raster, with
+ * the specified bounds.
+ *
+ * @param rect the raster bounds.
+ *
+ * @return A new writable raster.
+ */
public WritableRaster createCompatibleWritableRaster(Rectangle rect)
{
return createCompatibleWritableRaster(rect.x, rect.y,
- rect.width, rect.height);
+ rect.width, rect.height);
}
+ /**
+ * Creates a new writable raster that is compatible with this raster, with
+ * the specified bounds.
+ *
+ * @param x the x-coordinate of the top-left corner of the raster.
+ * @param y the y-coordinate of the top-left corner of the raster.
+ * @param w the raster width.
+ * @param h the raster height.
+ *
+ * @return A new writable raster.
+ */
public WritableRaster createCompatibleWritableRaster(int x, int y,
- int w, int h)
+ int w, int h)
{
SampleModel sm = getSampleModel().createCompatibleSampleModel(w, h);
- return new WritableRaster(sm, sm.createDataBuffer(),
- new Point(x, y));
+ return new WritableRaster(sm, sm.createDataBuffer(), new Point(x, y));
}
public Raster createTranslatedChild(int childMinX, int childMinY) {
@@ -302,15 +503,13 @@ public class Raster
int tcy = sampleModelTranslateY - minY + childMinY;
return new Raster(sampleModel, dataBuffer,
- new Rectangle(childMinX, childMinY,
- width, height),
- new Point(tcx, tcy),
- this);
+ new Rectangle(childMinX, childMinY, width, height),
+ new Point(tcx, tcy), this);
}
public Raster createChild(int parentX, int parentY, int width,
- int height, int childMinX, int childMinY,
- int[] bandList)
+ int height, int childMinX, int childMinY,
+ int[] bandList)
{
/* FIXME: Throw RasterFormatException if child bounds extends
beyond the bounds of this raster. */
@@ -343,38 +542,67 @@ public class Raster
*/
return new Raster(sm, dataBuffer,
- new Rectangle(childMinX, childMinY,
- width, height),
- new Point(sampleModelTranslateX+childMinX-parentX,
- sampleModelTranslateY+childMinY-parentY),
- this);
+ new Rectangle(childMinX, childMinY, width, height),
+ new Point(sampleModelTranslateX + childMinX - parentX,
+ sampleModelTranslateY + childMinY - parentY),
+ this);
}
+ /**
+ * Returns a new rectangle containing the bounds of this raster.
+ *
+ * @return A new rectangle containing the bounds of this raster.
+ */
public Rectangle getBounds()
{
return new Rectangle(minX, minY, width, height);
}
+ /**
+ * Returns the x-coordinate of the top left corner of the raster.
+ *
+ * @return The x-coordinate of the top left corner of the raster.
+ */
public final int getMinX()
{
return minX;
}
+ /**
+ * Returns the t-coordinate of the top left corner of the raster.
+ *
+ * @return The t-coordinate of the top left corner of the raster.
+ */
public final int getMinY()
{
return minY;
}
+ /**
+ * Returns the width of the raster.
+ *
+ * @return The width of the raster.
+ */
public final int getWidth()
{
return width;
}
+ /**
+ * Returns the height of the raster.
+ *
+ * @return The height of the raster.
+ */
public final int getHeight()
{
return height;
}
+ /**
+ * Returns the number of bands for this raster.
+ *
+ * @return The number of bands.
+ */
public final int getNumBands()
{
return numBands;
@@ -384,17 +612,34 @@ public class Raster
{
return numDataElements;
}
-
+
+ /**
+ * Returns the transfer type for the raster (this is determined by the
+ * raster's sample model).
+ *
+ * @return The transfer type.
+ */
public final int getTransferType()
{
return sampleModel.getTransferType();
}
+ /**
+ * Returns the data buffer that stores the pixel data for this raster.
+ *
+ * @return The data buffer.
+ */
public DataBuffer getDataBuffer()
{
return dataBuffer;
}
+ /**
+ * Returns the sample model that accesses the data buffer (to extract pixel
+ * data) for this raster.
+ *
+ * @return The sample model.
+ */
public SampleModel getSampleModel()
{
return sampleModel;
@@ -402,112 +647,275 @@ public class Raster
public Object getDataElements(int x, int y, Object outData)
{
- return sampleModel.getDataElements(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- outData, dataBuffer);
+ return sampleModel.getDataElements(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, outData, dataBuffer);
}
- public Object getDataElements(int x, int y, int w, int h,
- Object outData)
+ public Object getDataElements(int x, int y, int w, int h, Object outData)
{
- return sampleModel.getDataElements(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, outData, dataBuffer);
+ return sampleModel.getDataElements(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, outData, dataBuffer);
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * raster. 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).
+ *
+ * @return The pixel sample values.
+ */
public int[] getPixel(int x, int y, int[] iArray)
{
- return sampleModel.getPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- iArray, dataBuffer);
+ return sampleModel.getPixel(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, iArray, dataBuffer);
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * raster. 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).
+ *
+ * @return The pixel sample values.
+ */
public float[] getPixel(int x, int y, float[] fArray)
{
- return sampleModel.getPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- fArray, dataBuffer);
+ return sampleModel.getPixel(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, fArray, dataBuffer);
}
+ /**
+ * Returns an array containing the samples for the pixel at (x, y) in the
+ * raster. 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).
+ *
+ * @return The pixel sample values.
+ */
public double[] getPixel(int x, int y, double[] dArray)
{
- return sampleModel.getPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- dArray, dataBuffer);
+ return sampleModel.getPixel(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, dArray, dataBuffer);
}
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The pixel sample values.
+ */
public int[] getPixels(int x, int y, int w, int h, int[] iArray)
{
- return sampleModel.getPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, iArray, dataBuffer);
+ return sampleModel.getPixels(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, iArray, dataBuffer);
}
- public float[] getPixels(int x, int y, int w, int h,
- float[] fArray)
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The pixel sample values.
+ */
+ public float[] getPixels(int x, int y, int w, int h, float[] fArray)
{
- return sampleModel.getPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, fArray, dataBuffer);
+ return sampleModel.getPixels(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, fArray, dataBuffer);
}
- public double[] getPixels(int x, int y, int w, int h,
- double[] dArray)
+ /**
+ * Returns an array containing the samples for the pixels in the region
+ * specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The pixel sample values.
+ */
+ public double[] getPixels(int x, int y, int w, int h, double[] dArray)
{
- return sampleModel.getPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, dArray, dataBuffer);
+ return sampleModel.getPixels(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, dArray, dataBuffer);
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the raster.
+ *
+ * @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>).
+ *
+ * @return The sample value.
+ */
public int getSample(int x, int y, int b)
{
- return sampleModel.getSample(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, dataBuffer);
+ return sampleModel.getSample(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, b, dataBuffer);
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the raster.
+ *
+ * @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>).
+ *
+ * @return The sample value.
+ *
+ * @see #getSample(int, int, int)
+ */
public float getSampleFloat(int x, int y, int b)
{
- return sampleModel.getSampleFloat(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, dataBuffer);
+ return sampleModel.getSampleFloat(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, b, dataBuffer);
}
+ /**
+ * Returns the sample value for the pixel at (x, y) in the raster.
+ *
+ * @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>).
+ *
+ * @return The sample value.
+ *
+ * @see #getSample(int, int, int)
+ */
public double getSampleDouble(int x, int y, int b)
{
- return sampleModel.getSampleDouble(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, dataBuffer);
+ return sampleModel.getSampleDouble(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, b, dataBuffer);
}
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The sample values.
+ */
public int[] getSamples(int x, int y, int w, int h, int b,
- int[] iArray)
+ int[] iArray)
{
- return sampleModel.getSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, iArray, dataBuffer);
+ return sampleModel.getSamples(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, b, iArray, dataBuffer);
}
- public float[] getSamples(int x, int y, int w, int h, int b,
- float[] fArray)
- {
- return sampleModel.getSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, fArray, dataBuffer);
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The sample values.
+ */
+ public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray)
+ {
+ return sampleModel.getSamples(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, b, fArray, dataBuffer);
}
- public double[] getSamples(int x, int y, int w, int h, int b,
- double[] dArray)
+ /**
+ * Returns an array containing the samples from one band for the pixels in
+ * the region specified by (x, y, w, h) in the raster. 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).
+ *
+ * @return The sample values.
+ */
+ public double[] getSamples(int x, int y, int w, int h, int b,
+ double[] dArray)
{
- return sampleModel.getSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, dArray, dataBuffer);
+ return sampleModel.getSamples(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, b, dArray, dataBuffer);
}
/**
- * Create a String representing the stat of this Raster.
+ * Create a String representing the state of this Raster.
+ *
* @return A String representing the stat of this Raster.
- * @see java.lang.Object#toString()
*/
public String toString()
{
@@ -524,23 +932,39 @@ public class Raster
return result.toString();
}
- // Map from datatype to bits
+ /**
+ * Returns the number of bits used to represent the specified data type.
+ * Valid types are:
+ * <ul>
+ * <li>{@link DataBuffer#TYPE_BYTE};</li>
+ * <li>{@link DataBuffer#TYPE_USHORT};</li>
+ * <li>{@link DataBuffer#TYPE_SHORT};</li>
+ * <li>{@link DataBuffer#TYPE_INT};</li>
+ * <li>{@link DataBuffer#TYPE_FLOAT};</li>
+ * <li>{@link DataBuffer#TYPE_DOUBLE};</li>
+ * </ul>
+ * This method returns 0 for invalid data types.
+ *
+ * @param dataType the data type.
+ *
+ * @return The number of bits used to represent the specified data type.
+ */
private static int getTypeBits(int dataType)
{
switch (dataType)
{
case DataBuffer.TYPE_BYTE:
- return 8;
+ return 8;
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
- return 16;
+ return 16;
case DataBuffer.TYPE_INT:
case DataBuffer.TYPE_FLOAT:
- return 32;
+ return 32;
case DataBuffer.TYPE_DOUBLE:
- return 64;
+ return 64;
default:
- return 0;
+ return 0;
}
}
}
diff --git a/libjava/classpath/java/awt/image/RasterOp.java b/libjava/classpath/java/awt/image/RasterOp.java
index e081ca3d2ad..656370e8bcc 100644
--- a/libjava/classpath/java/awt/image/RasterOp.java
+++ b/libjava/classpath/java/awt/image/RasterOp.java
@@ -1,5 +1,5 @@
/* RasterOp.java --
- Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation
+ Copyright (C) 2000, 2002, 2004, 2005, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -42,16 +42,64 @@ import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+/**
+ * An operation that is performed on one raster (the source) producing a new
+ * raster (the destination).
+ */
public interface RasterOp
{
+ /**
+ * Performs an operation on the source raster, returning the result in a
+ * writable raster. If <code>dest</code> is <code>null</code>, a new
+ * <code>WritableRaster</code> will be created by calling the
+ * {@link #createCompatibleDestRaster(Raster)} method. If <code>dest</code>
+ * is not <code>null</code>, the result is written to <code>dest</code> then
+ * returned (this avoids creating a new <code>WritableRaster</code> each
+ * time this method is called).
+ *
+ * @param src the source raster.
+ * @param dest the destination raster (<code>null</code> permitted).
+ *
+ * @return The filtered raster.
+ */
WritableRaster filter(Raster src, WritableRaster dest);
+ /**
+ * Returns the bounds of the destination raster on the basis of this
+ * <code>RasterOp</code> being applied to the specified source raster.
+ *
+ * @param src the source raster.
+ *
+ * @return The destination bounds.
+ */
Rectangle2D getBounds2D(Raster src);
+ /**
+ * Returns a raster that can be used by this <code>RasterOp</code> as the
+ * destination raster when operating on the specified source raster.
+ *
+ * @param src the source raster.
+ *
+ * @return A new writable raster that can be used as the destination raster.
+ */
WritableRaster createCompatibleDestRaster(Raster src);
+ /**
+ * Returns the point on the destination raster that corresponds to the given
+ * point on the source raster.
+ *
+ * @param srcPoint the source point.
+ * @param destPoint the destination point (<code>null</code> permitted).
+ *
+ * @return The destination point.
+ */
Point2D getPoint2D(Point2D srcPoint, Point2D destPoint);
+ /**
+ * Returns the rendering hints for this operation.
+ *
+ * @return The rendering hints.
+ */
RenderingHints getRenderingHints();
}
diff --git a/libjava/classpath/java/awt/image/SampleModel.java b/libjava/classpath/java/awt/image/SampleModel.java
index 6e3fd4069a3..cb352bb4d85 100644
--- a/libjava/classpath/java/awt/image/SampleModel.java
+++ b/libjava/classpath/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/libjava/classpath/java/awt/image/ShortLookupTable.java b/libjava/classpath/java/awt/image/ShortLookupTable.java
index 5915a7939a3..858818cf26d 100644
--- a/libjava/classpath/java/awt/image/ShortLookupTable.java
+++ b/libjava/classpath/java/awt/image/ShortLookupTable.java
@@ -1,5 +1,5 @@
/* ShortLookupTable.java -- Java class for a pixel translation table.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -67,7 +67,13 @@ public class ShortLookupTable extends LookupTable
throws IllegalArgumentException
{
super(offset, data.length);
- this.data = data;
+
+ // tests show that Sun's implementation creates a new array to store the
+ // references from the incoming 'data' array - not sure why, but we'll
+ // match that behaviour just in case it matters...
+ this.data = new short[data.length][];
+ for (int i = 0; i < data.length; i++)
+ this.data[i] = data[i];
}
/**
@@ -77,17 +83,25 @@ public class ShortLookupTable extends LookupTable
* table. The same table is applied to all pixel components.
*
* @param offset Offset to be subtracted.
- * @param data Lookup table for all components.
+ * @param data Lookup table for all components (<code>null</code> not
+ * permitted).
* @exception IllegalArgumentException if offset &lt; 0.
*/
public ShortLookupTable(int offset, short[] data)
throws IllegalArgumentException
{
super(offset, 1);
+ if (data == null)
+ throw new NullPointerException("Null 'data' argument.");
this.data = new short[][] {data};
}
- /** Return the lookup tables. */
+ /**
+ * Return the lookup tables. This is a reference to the actual table, so
+ * modifying the contents of the returned array will modify the lookup table.
+ *
+ * @return The lookup table.
+ */
public final short[][] getTable()
{
return data;
@@ -117,11 +131,11 @@ public class ShortLookupTable extends LookupTable
dst = new int[src.length];
if (data.length == 1)
- for (int i=0; i < src.length; i++)
- dst[i] = data[0][src[i] - offset];
+ for (int i = 0; i < src.length; i++)
+ dst[i] = data[0][src[i] - offset];
else
- for (int i=0; i < src.length; i++)
- dst[i] = data[i][src[i] - offset];
+ for (int i = 0; i < src.length; i++)
+ dst[i] = data[i][src[i] - offset];
return dst;
}
@@ -142,6 +156,7 @@ public class ShortLookupTable extends LookupTable
* @param src Component values of a pixel.
* @param dst Destination array for values, or null.
* @return Translated values for the pixel.
+ *
*/
public short[] lookupPixel(short[] src, short[] dst)
throws ArrayIndexOutOfBoundsException
@@ -150,11 +165,11 @@ public class ShortLookupTable extends LookupTable
dst = new short[src.length];
if (data.length == 1)
- for (int i=0; i < src.length; i++)
- dst[i] = data[0][((int)src[i]) - offset];
+ for (int i = 0; i < src.length; i++)
+ dst[i] = data[0][((int) src[i]) - offset];
else
- for (int i=0; i < src.length; i++)
- dst[i] = data[i][((int)src[i]) - offset];
+ for (int i = 0; i < src.length; i++)
+ dst[i] = data[i][((int) src[i]) - offset];
return dst;
diff --git a/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java b/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java
index 6ccce753bd3..a37fc0bba3f 100644
--- a/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java
+++ b/libjava/classpath/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,17 +161,40 @@ 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;
+ return (int[]) sampleSize.clone();
}
+ /**
+ * 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];
}
+ /**
+ * 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 + x;
@@ -142,20 +210,40 @@ public class SinglePixelPackedSampleModel extends SampleModel
return bitMasks;
}
+ /**
+ * 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;
}
+ /**
+ * Creates a new <code>SinglePixelPackedSampleModel</code> that accesses
+ * the specified subset of bands.
+ *
+ * @param bands an array containing band indices (<code>null</code> not
+ * permitted).
+ *
+ * @return A new sample model.
+ *
+ * @throws NullPointerException if <code>bands</code> is <code>null</code>.
+ * @throws RasterFormatException if <code>bands.length</code> is greater
+ * than the number of bands in this model.
+ */
public SampleModel createSubsetSampleModel(int[] bands)
{
- // FIXME: Is this the right way to interpret bands?
+ if (bands.length > numBands)
+ throw new RasterFormatException("Too many bands.");
int numBands = bands.length;
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 +262,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 +301,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 +322,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 +391,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 +413,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 +518,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 +551,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 +565,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 +574,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 +598,76 @@ 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;
+ }
+
+ /**
+ * Returns a hash code for this <code>SinglePixelPackedSampleModel</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 + numBands;
+ result = 37 * result + scanlineStride;
+ for (int i = 0; i < bitMasks.length; i++)
+ result = 37 * result + bitMasks[i];
+ for (int i = 0; i < bitOffsets.length; i++)
+ result = 37 * result + bitOffsets[i];
+ return result;
+ }
+
+ /**
* Creates a String with some information about this SampleModel.
* @return A String describing this SampleModel.
* @see java.lang.Object#toString()
@@ -438,9 +678,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/libjava/classpath/java/awt/image/WritableRaster.java b/libjava/classpath/java/awt/image/WritableRaster.java
index 2e5462fd92e..473c6fe41f9 100644
--- a/libjava/classpath/java/awt/image/WritableRaster.java
+++ b/libjava/classpath/java/awt/image/WritableRaster.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation
+/* Copyright (C) 2000, 2002, 2003, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -41,61 +41,98 @@ import java.awt.Point;
import java.awt.Rectangle;
/**
+ * A raster with methods to support updating pixel values.
+ *
* @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
*/
public class WritableRaster extends Raster
{
+ /**
+ * Creates a new <code>WritableRaster</code>.
+ *
+ * @param sampleModel the sample model.
+ * @param origin the origin.
+ */
protected WritableRaster(SampleModel sampleModel, Point origin)
{
this(sampleModel, sampleModel.createDataBuffer(), origin);
}
- protected WritableRaster(SampleModel sampleModel,
- DataBuffer dataBuffer, Point origin)
+ /**
+ * Creates a new <code>WritableRaster</code> instance.
+ *
+ * @param sampleModel the sample model.
+ * @param dataBuffer the data buffer.
+ * @param origin the origin.
+ */
+ protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer,
+ Point origin)
{
this(sampleModel, dataBuffer,
- new Rectangle(origin != null ? origin.x : 0,
+ new Rectangle(origin != null ? origin.x : 0,
origin != null ? origin.y : 0,
- sampleModel.getWidth(), sampleModel.getHeight()),
- origin,
- null);
+ sampleModel.getWidth(), sampleModel.getHeight()),
+ origin, null);
}
+ /**
+ * Creates a new <code>WritableRaster</code> instance.
+ *
+ * @param sampleModel the sample model.
+ * @param dataBuffer the data buffer.
+ * @param aRegion the raster's bounds.
+ * @param sampleModelTranslate the translation.
+ * @param parent the parent.
+ */
protected WritableRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point sampleModelTranslate,
- WritableRaster parent)
+ DataBuffer dataBuffer,
+ Rectangle aRegion,
+ Point sampleModelTranslate,
+ WritableRaster parent)
{
- super(sampleModel, dataBuffer, aRegion, sampleModelTranslate,
- parent);
+ super(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent);
}
+ /**
+ * Returns the raster's parent, cast as a {@link WritableRaster}.
+ *
+ * @return The raster's parent.
+ */
public WritableRaster getWritableParent()
{
return (WritableRaster) getParent();
}
+ /**
+ * @param childMinX
+ * @param childMinY
+ * @return
+ */
public WritableRaster createWritableTranslatedChild(int childMinX,
- int childMinY)
+ int childMinY)
{
// This mirrors the code from the super class
int tcx = sampleModelTranslateX - minX + childMinX;
int tcy = sampleModelTranslateY - minY + childMinY;
return new WritableRaster(sampleModel, dataBuffer,
- new Rectangle(childMinX, childMinY,
- width, height),
- new Point(tcx, tcy),
- this);
+ new Rectangle(childMinX, childMinY, width, height),
+ new Point(tcx, tcy), this);
}
- public WritableRaster createWritableChild(int parentX,
- int parentY,
- int w, int h,
- int childMinX,
- int childMinY,
- int[] bandList)
+ /**
+ *
+ * @param parentX
+ * @param parentY
+ * @param w
+ * @param h
+ * @param childMinX
+ * @param childMinY
+ * @param bandList
+ * @return
+ */
+ public WritableRaster createWritableChild(int parentX, int parentY,
+ int w, int h, int childMinX, int childMinY, int[] bandList)
{
// This mirrors the code from the super class
@@ -106,51 +143,52 @@ public class WritableRaster extends Raster
sampleModel :
sampleModel.createSubsetSampleModel(bandList);
- return new
- WritableRaster(sm, dataBuffer,
- new Rectangle(childMinX, childMinY,
- w, h),
- new Point(sampleModelTranslateX+childMinX-parentX,
- sampleModelTranslateY+childMinY-parentY),
- this);
+ return new WritableRaster(sm, dataBuffer,
+ new Rectangle(childMinX, childMinY, w, h),
+ new Point(sampleModelTranslateX + childMinX - parentX,
+ sampleModelTranslateY + childMinY - parentY),
+ this);
}
public void setDataElements(int x, int y, Object inData)
{
- sampleModel.setDataElements(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- inData, dataBuffer);
+ sampleModel.setDataElements(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, inData, dataBuffer);
}
public void setDataElements(int x, int y, Raster inRaster)
{
- Object dataElements = getDataElements(0, 0,
- inRaster.getWidth(),
- inRaster.getHeight(),
- null);
+ Object dataElements = getDataElements(0, 0, inRaster.getWidth(),
+ inRaster.getHeight(), null);
setDataElements(x, y, dataElements);
}
- public void setDataElements(int x, int y, int w, int h,
- Object inData)
+ public void setDataElements(int x, int y, int w, int h, Object inData)
{
- sampleModel.setDataElements(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, inData, dataBuffer);
+ sampleModel.setDataElements(x - sampleModelTranslateX,
+ y - sampleModelTranslateY, w, h, inData, dataBuffer);
}
+ /**
+ *
+ * @param srcRaster
+ */
public void setRect(Raster srcRaster)
{
setRect(0, 0, srcRaster);
}
+ /**
+ *
+ * @param dx
+ * @param dy
+ * @param srcRaster
+ */
public void setRect(int dx, int dy, Raster srcRaster)
{
- Rectangle targetUnclipped = new Rectangle(srcRaster.getMinX()+dx,
- srcRaster.getMinY()+dy,
- srcRaster.getWidth(),
- srcRaster.getHeight());
-
+ Rectangle targetUnclipped = new Rectangle(srcRaster.getMinX() + dx,
+ srcRaster.getMinY() + dy, srcRaster.getWidth(), srcRaster.getHeight());
+
Rectangle target = getBounds().intersection(targetUnclipped);
if (target.isEmpty()) return;
@@ -169,97 +207,225 @@ public class WritableRaster extends Raster
But this is probably not the place to consider such
optimizations.*/
- int[] pixels = srcRaster.getPixels(sx, sy,
- target.width, target.height,
- (int[]) null);
+ int[] pixels = srcRaster.getPixels(sx, sy, target.width, target.height,
+ (int[]) null);
setPixels(target.x, target.y, target.width, target.height, pixels);
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the raster 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).
+ *
+ * @throws NullPointerException if <code>iArray</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, int[] iArray)
{
- sampleModel.setPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- iArray, dataBuffer);
+ sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ iArray, dataBuffer);
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the raster 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).
+ *
+ * @throws NullPointerException if <code>fArray</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, float[] fArray)
{
- sampleModel.setPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- fArray, dataBuffer);
+ sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ fArray, dataBuffer);
}
+ /**
+ * Sets the samples for the pixel at (x, y) in the raster 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).
+ *
+ * @throws NullPointerException if <code>dArray</code> is <code>null</code>.
+ */
public void setPixel(int x, int y, double[] dArray)
{
- sampleModel.setPixel(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- dArray, dataBuffer);
+ sampleModel.setPixel(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ dArray, dataBuffer);
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the raster. 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).
+ *
+ * @throws NullPointerException if <code>iArray</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, int[] iArray)
{
- sampleModel.setPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, iArray, dataBuffer);
+ sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, iArray, dataBuffer);
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the raster. 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).
+ *
+ * @throws NullPointerException if <code>fArray</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, float[] fArray)
{
- sampleModel.setPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, fArray, dataBuffer);
+ sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, fArray, dataBuffer);
}
+ /**
+ * Sets the sample values for the pixels in the region specified by
+ * (x, y, w, h) in the raster. 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).
+ *
+ * @throws NullPointerException if <code>dArray</code> is <code>null</code>.
+ */
public void setPixels(int x, int y, int w, int h, double[] dArray)
{
- sampleModel.setPixels(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, dArray, dataBuffer);
+ sampleModel.setPixels(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, dArray, dataBuffer);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the raster.
+ *
+ * @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.
+ */
public void setSample(int x, int y, int b, int s)
{
- sampleModel.setSample(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, s, dataBuffer);
+ sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ b, s, dataBuffer);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the raster.
+ *
+ * @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.
+ */
public void setSample(int x, int y, int b, float s)
{
- sampleModel.setSample(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, s, dataBuffer);
+ sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ b, s, dataBuffer);
}
+ /**
+ * Sets the sample value for a band for the pixel at (x, y) in the raster.
+ *
+ * @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.
+ */
public void setSample(int x, int y, int b, double s)
{
- sampleModel.setSample(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- b, s, dataBuffer);
+ sampleModel.setSample(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ b, s, dataBuffer);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the raster.
+ *
+ * @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).
+ *
+ * @throws NullPointerException if <code>iArray</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
- int[] iArray)
+ int[] iArray)
{
- sampleModel.setSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, iArray, dataBuffer);
+ sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, b, iArray, dataBuffer);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the raster.
+ *
+ * @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).
+ *
+ * @throws NullPointerException if <code>fArray</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
- float[] fArray)
+ float[] fArray)
{
- sampleModel.setSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, fArray, dataBuffer);
+ sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, b, fArray, dataBuffer);
}
+ /**
+ * Sets the sample values for one band for the pixels in the region
+ * specified by (x, y, w, h) in the raster.
+ *
+ * @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).
+ *
+ * @throws NullPointerException if <code>dArray</code> is <code>null</code>.
+ */
public void setSamples(int x, int y, int w, int h, int b,
- double[] dArray)
+ double[] dArray)
{
- sampleModel.setSamples(x-sampleModelTranslateX,
- y-sampleModelTranslateY,
- w, h, b, dArray, dataBuffer);
+ sampleModel.setSamples(x - sampleModelTranslateX, y - sampleModelTranslateY,
+ w, h, b, dArray, dataBuffer);
}
}
diff --git a/libjava/classpath/java/awt/peer/ComponentPeer.java b/libjava/classpath/java/awt/peer/ComponentPeer.java
index 97b96f49cdb..bc6e3a457f3 100644
--- a/libjava/classpath/java/awt/peer/ComponentPeer.java
+++ b/libjava/classpath/java/awt/peer/ComponentPeer.java
@@ -153,6 +153,12 @@ public interface ComponentPeer
* {@link Component#getMinimumSize()}.
*
* @return the minimum size for the component
+ *
+ * @specnote Presumably this method got added to replace minimumSize().
+ * However, testing shows that this is never called in the RI
+ * (tested with JDK5), but instead minimumSize() is called
+ * directly. It is advisable to implement this method to delegate
+ * to minimumSize() and put the real implementation in there.
*/
Dimension getMinimumSize();
@@ -161,6 +167,12 @@ public interface ComponentPeer
* {@link Component#getPreferredSize()}.
*
* @return the preferred size for the component
+ *
+ * @specnote Presumably this method got added to replace preferredSize().
+ * However, testing shows that this is never called in the RI
+ * (tested with JDK5), but instead preferredSize() is called
+ * directly. It is advisable to implement this method to delegate
+ * to preferredSize() and put the real implementation in there.
*/
Dimension getPreferredSize();
@@ -262,12 +274,21 @@ public interface ComponentPeer
* Requests that this component receives the focus. This is called from
* {@link Component#requestFocus()}.
*
- * @param source TODO
- * @param bool1 TODO
- * @param bool2 TODO
- * @param x TODO
- */
- boolean requestFocus(Component source, boolean bool1, boolean bool2, long x);
+ * This method is only called for heavyweight component's peers. Lightweight
+ * components ask their nearest heavyweight component to request focus.
+ * It's up to the heavyweight peer to decide if any of it's lightweight
+ * descendants are allowed to receive keyboard input focus or not. If the
+ * focus request is finally approved, then the peer must post a FOCUS_GAINED
+ * event for the requested component.
+ *
+ * @param request the component for which the focus is requested
+ * @param temporary indicates if the focus change is temporary (true) or
+ * permanent (false)
+ * @param allowWindowFocus indicates if it's allowed to change window focus
+ * @param time the timestamp
+ */
+ boolean requestFocus(Component request, boolean temporary,
+ boolean allowWindowFocus, long time);
/**
* Notifies the peer that the bounds of this component have changed. This
diff --git a/libjava/classpath/java/awt/peer/MouseInfoPeer.java b/libjava/classpath/java/awt/peer/MouseInfoPeer.java
new file mode 100644
index 00000000000..e9923a653aa
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/java/awt/peer/WindowPeer.java b/libjava/classpath/java/awt/peer/WindowPeer.java
index 6c014de0b99..00d1035791a 100644
--- a/libjava/classpath/java/awt/peer/WindowPeer.java
+++ b/libjava/classpath/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/libjava/classpath/java/beans/VetoableChangeSupport.java b/libjava/classpath/java/beans/VetoableChangeSupport.java
index dce8dffd341..12051d2ffb0 100644
--- a/libjava/classpath/java/beans/VetoableChangeSupport.java
+++ b/libjava/classpath/java/beans/VetoableChangeSupport.java
@@ -1,5 +1,6 @@
/* VetoableChangeSupport.java -- support to manage vetoable change listeners
- Copyright (C) 1998, 1999, 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006,
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -120,14 +121,15 @@ public class VetoableChangeSupport implements Serializable
* vetoable change events will be sent to this listener. The listener add
* is not unique: that is, <em>n</em> adds with the same listener will
* result in <em>n</em> events being sent to that listener for every
- * vetoable change. Adding a null listener may cause a NullPointerException
- * down the road. This method will unwrap a VetoableChangeListenerProxy,
+ * vetoable change. This method will unwrap a VetoableChangeListenerProxy,
* registering the underlying delegate to the named property list.
*
- * @param l the listener to add
+ * @param l the listener to add (<code>null</code> ignored).
*/
public synchronized void addVetoableChangeListener(VetoableChangeListener l)
{
+ if (l == null)
+ return;
if (l instanceof VetoableChangeListenerProxy)
{
VetoableChangeListenerProxy p = (VetoableChangeListenerProxy) l;
@@ -215,19 +217,19 @@ public class VetoableChangeSupport implements Serializable
* being sent to that listener when that property is changed. The effect is
* cumulative, too; if you are registered to listen to receive events on
* all vetoable changes, and then you register on a particular property,
- * you will receive change events for that property twice. Adding a null
- * listener may cause a NullPointerException down the road. This method
+ * you will receive change events for that property twice. This method
* will unwrap a VetoableChangeListenerProxy, registering the underlying
* delegate to the named property list if the names match, and discarding
* it otherwise.
*
* @param propertyName the name of the property to listen on
* @param l the listener to add
- * @throws NullPointerException if propertyName is null
*/
public synchronized void addVetoableChangeListener(String propertyName,
VetoableChangeListener l)
{
+ if (propertyName == null || l == null)
+ return;
while (l instanceof VetoableChangeListenerProxy)
{
VetoableChangeListenerProxy p = (VetoableChangeListenerProxy) l;
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
index f3d5ff6098d..a12c078df6a 100644
--- a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
+++ b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
@@ -1,5 +1,5 @@
/* BeanContextSupport.java --
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package java.beans.beancontext;
import gnu.classpath.NotImplementedException;
+import java.beans.Beans;
import java.beans.DesignMode;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -59,7 +60,12 @@ import java.util.Iterator;
import java.util.Locale;
/**
+ * This is a helper class for implementing a bean context. It is
+ * intended to be used either by subclassing or by calling methods
+ * of this implementation from another.
+ *
* @author Michael Koch
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.2
*/
public class BeanContextSupport extends BeanContextChildSupport
@@ -180,27 +186,102 @@ public class BeanContextSupport extends BeanContextChildSupport
initialize ();
}
- public boolean add (Object targetChild)
+ /**
+ * <p>
+ * Add a child to the bean context. A child can be a simple
+ * <code>Object</code>, a <code>BeanContextChild</code>
+ * or another <code>BeanContext</code>.
+ * </p>
+ * <p>
+ * The children of a <code>BeanContext</code> form a set. As
+ * a result, this method returns <code>false</code> if the given
+ * object is already a child of this context.
+ * </p>
+ * <p>
+ * If the child is a <code>BeanContextChild</code>, or a proxy
+ * for such a child, the <code>setBeanContext()</code> method
+ * is invoked on the child. If this operation is vetoed by the
+ * child, via throwing a <code>PropertyVetoException</code>,
+ * then the current completion state of the <code>add()</code>
+ * operation is rolled back and a <code>IllegalStateException</code>
+ * is thrown. If the <code>BeanContextChild</code> is successfully
+ * added, then the context registers with its
+ * <code>PropertyChangeListener</code> and
+ * <code>VetoableChangeListener</code> for "beanContext" events.
+ * </p>
+ * <p>
+ * If the child implements <code>java.beans.Visibility</code>,
+ * then its ability to use a GUI is set based on that of
+ * this context.
+ * </p>
+ * <p>
+ * A <code>BeanContextMembershipEvent</code> is fired when the
+ * child is successfully added to the bean context.
+ * </p>
+ * <p>
+ * This method is synchronized over the global hierarchy lock.
+ * </p>
+ *
+ * @param targetChild the child to add.
+ * @return false if the child has already been added.
+ * @throws IllegalArgumentException if the child is null.
+ * @throws IllegalStateException if the child vetos the setting
+ * of its context.
+ */
+ public boolean add(Object targetChild)
{
- if (targetChild == null)
- throw new IllegalArgumentException();
-
- BCSChild child;
- synchronized (children)
- {
- if (children.containsKey(targetChild)
- || ! validatePendingAdd(targetChild))
- return false;
- child = createBCSChild(targetChild, beanContextChildPeer);
- children.put(targetChild, child);
- }
- synchronized (targetChild)
+ synchronized (globalHierarchyLock)
{
- childJustAddedHook(targetChild, child);
+ if (targetChild == null)
+ throw new IllegalArgumentException();
+
+ BCSChild child;
+ synchronized (children)
+ {
+ if (children.containsKey(targetChild)
+ || ! validatePendingAdd(targetChild))
+ return false;
+ child = createBCSChild(targetChild, beanContextChildPeer);
+ children.put(targetChild, child);
+ }
+ synchronized (targetChild)
+ {
+ BeanContextChild bcChild = null;
+ if (targetChild instanceof BeanContextChild)
+ bcChild = (BeanContextChild) targetChild;
+ if (targetChild instanceof BeanContextProxy)
+ bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy();
+ if (bcChild != null)
+ try
+ {
+ bcChild.setBeanContext(this);
+ bcChild.addVetoableChangeListener("beanContext", this);
+ bcChild.addPropertyChangeListener("beanContext", this);
+ }
+ catch (PropertyVetoException e)
+ {
+ synchronized (children)
+ {
+ children.remove(targetChild);
+ }
+ throw new IllegalStateException("The child refused to " +
+ "associate itself with " +
+ "this context.", e);
+ }
+ if (targetChild instanceof Visibility)
+ {
+ Visibility visibleChild = (Visibility) targetChild;
+ if (okToUseGui)
+ visibleChild.okToUseGui();
+ else
+ visibleChild.dontUseGui();
+ }
+ childJustAddedHook(targetChild, child);
+ }
+ fireChildrenAdded(new BeanContextMembershipEvent(this,
+ new Object[]{ targetChild }));
+ return true;
}
- fireChildrenAdded(new BeanContextMembershipEvent(this,
- new Object[] { targetChild }));
- return true;
}
public boolean addAll (Collection c)
@@ -219,10 +300,18 @@ public class BeanContextSupport extends BeanContextChildSupport
}
}
- public boolean avoidingGui ()
+ /**
+ * Returns true if this bean needs a GUI
+ * but is being prevented from using one.
+ *
+ * @return true if <code>needsGui()</code>
+ * is true but the bean has been
+ * told not to use it.
+ */
+ public boolean avoidingGui()
throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return needsGui() && (!okToUseGui);
}
protected Iterator bcsChildren ()
@@ -321,10 +410,13 @@ public class BeanContextSupport extends BeanContextChildSupport
throw new Error ("Not implemented");
}
- public void dontUseGui ()
- throws NotImplementedException
+ /**
+ * Informs this bean that is should not make
+ * use of the GUI.
+ */
+ public void dontUseGui()
{
- throw new Error ("Not implemented");
+ okToUseGui = false;
}
protected final void fireChildrenAdded (BeanContextMembershipEvent bcme)
@@ -426,10 +518,20 @@ public class BeanContextSupport extends BeanContextChildSupport
children = new HashMap();
}
+ /**
+ * This is a convenience method for instantiating a bean inside this
+ * context. It delegates to the appropriate method in
+ * <code>java.beans.Beans</code> using the context's classloader.
+ *
+ * @param beanName the name of the class of bean to instantiate.
+ * @throws IOException if an I/O error occurs in loading the class.
+ * @throws ClassNotFoundException if the class, <code>beanName</code>,
+ * can not be found.
+ */
public Object instantiateChild (String beanName)
- throws IOException, ClassNotFoundException, NotImplementedException
+ throws IOException, ClassNotFoundException
{
- throw new Error ("Not implemented");
+ return Beans.instantiate(getClass().getClassLoader(), beanName, this);
}
public boolean isDesignTime ()
@@ -437,6 +539,11 @@ public class BeanContextSupport extends BeanContextChildSupport
return designTime;
}
+ /**
+ * Returns true if this bean context has no children.
+ *
+ * @return true if there are no children.
+ */
public boolean isEmpty ()
{
synchronized (children)
@@ -459,22 +566,38 @@ public class BeanContextSupport extends BeanContextChildSupport
}
}
- public boolean needsGui ()
- throws NotImplementedException
+ /**
+ * Returns false as this bean does not a
+ * GUI for its operation.
+ *
+ * @return false
+ */
+ public boolean needsGui()
{
- throw new Error ("Not implemented");
+ return false;
}
+ /**
+ * Informs this bean that it is okay to make use of
+ * the GUI.
+ */
public void okToUseGui ()
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ okToUseGui = true;
}
+ /**
+ * Subclasses may use this method to catch property changes
+ * arising from the children of this context. At present,
+ * we just listen for the beans being assigned to a different
+ * context and remove them from here if such an event occurs.
+ *
+ * @param pce the property change event.
+ */
public void propertyChange (PropertyChangeEvent pce)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ if (pce.getNewValue() != this)
+ remove(pce.getSource(), false);
}
public final void readChildren (ObjectInputStream ois)
@@ -483,18 +606,100 @@ public class BeanContextSupport extends BeanContextChildSupport
throw new Error ("Not implemented");
}
+ /**
+ * Remove the specified child from the context. This is
+ * the same as calling <code>remove(Object,boolean)</code>
+ * with a request for the <code>setBeanContext()</code> method
+ * of the child to be called (i.e. the second argument is true).
+ *
+ * @param targetChild the child to remove.
+ */
public boolean remove (Object targetChild)
{
return remove(targetChild, true);
}
+ /**
+ * <p>
+ * Removes a child from the bean context. A child can be a simple
+ * <code>Object</code>, a <code>BeanContextChild</code>
+ * or another <code>BeanContext</code>. If the given child is not
+ * a child of this context, this method returns <code>false</code>.
+ * </p>
+ * <p>
+ * If the child is a <code>BeanContextChild</code>, or a proxy
+ * for such a child, the <code>setBeanContext()</code> method
+ * is invoked on the child (if specified). If this operation is vetoed
+ * by the child, via throwing a <code>PropertyVetoException</code>,
+ * then the current completion state of the <code>remove()</code>
+ * operation is rolled back and a <code>IllegalStateException</code>
+ * is thrown. If the <code>BeanContextChild</code> is successfully
+ * removed, then the context deregisters with its
+ * <code>PropertyChangeListener</code> and
+ * <code>VetoableChangeListener</code> for "beanContext" events.
+ * </p>
+ * <p>
+ * A <code>BeanContextMembershipEvent</code> is fired when the
+ * child is successfully removed from the bean context.
+ * </p>
+ * <p>
+ * This method is synchronized over the global hierarchy lock.
+ * </p>
+ *
+ * @param targetChild the child to add.
+ * @param callChildSetBC true if the <code>setBeanContext()</code>
+ * method of the child should be called.
+ * @return false if the child doesn't exist.
+ * @throws IllegalArgumentException if the child is null.
+ * @throws IllegalStateException if the child vetos the setting
+ * of its context.
+ */
protected boolean remove (Object targetChild, boolean callChildSetBC)
- throws NotImplementedException
{
- if (targetChild == null)
- throw new IllegalArgumentException();
-
- throw new Error ("Not implemented");
+ synchronized (globalHierarchyLock)
+ {
+ if (targetChild == null)
+ throw new IllegalArgumentException();
+
+ BCSChild child;
+ synchronized (children)
+ {
+ if (!children.containsKey(targetChild)
+ || !validatePendingRemove(targetChild))
+ return false;
+ child = (BCSChild) children.remove(targetChild);
+ }
+ synchronized (targetChild)
+ {
+ BeanContextChild bcChild = null;
+ if (targetChild instanceof BeanContextChild)
+ bcChild = (BeanContextChild) targetChild;
+ if (targetChild instanceof BeanContextProxy)
+ bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy();
+ if (bcChild != null)
+ try
+ {
+ if (callChildSetBC)
+ bcChild.setBeanContext(null);
+ bcChild.removeVetoableChangeListener("beanContext", this);
+ bcChild.removePropertyChangeListener("beanContext", this);
+ }
+ catch (PropertyVetoException e)
+ {
+ synchronized (children)
+ {
+ children.put(targetChild, child);
+ }
+ throw new IllegalStateException("The child refused to " +
+ "disassociate itself with " +
+ "this context.", e);
+ }
+ childJustRemovedHook(targetChild, child);
+ }
+ fireChildrenRemoved(new BeanContextMembershipEvent(this,
+ new Object[]{ targetChild }));
+ return true;
+ }
}
public boolean removeAll (Collection c)
@@ -578,10 +783,16 @@ public class BeanContextSupport extends BeanContextChildSupport
return true;
}
+ /**
+ * Subclasses may use this method to veto changes arising
+ * from the children of this context.
+ *
+ * @param pce the vetoable property change event fired.
+ */
public void vetoableChange (PropertyChangeEvent pce)
- throws PropertyVetoException, NotImplementedException
+ throws PropertyVetoException
{
- throw new Error ("Not implemented");
+ /* Purposefully left empty */
}
public final void writeChildren (ObjectOutputStream oos)
diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java
index 43e8e5ded6c..ce56876cc22 100644
--- a/libjava/classpath/java/io/File.java
+++ b/libjava/classpath/java/io/File.java
@@ -1,5 +1,5 @@
/* File.java -- Class representing a file on disk
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -82,7 +82,7 @@ public class File implements Serializable, Comparable
/**
* This is the string that is used to separate the host name from the
- * path name in paths than include the host name. It is the value of
+ * path name in paths that include the host name. It is the value of
* the <code>path.separator</code> system property.
*/
public static final String pathSeparator
@@ -484,9 +484,9 @@ public class File implements Serializable, Comparable
/**
* This method returns a canonical representation of the pathname of
* this file. The actual form of the canonical representation is
- * different. On the GNU system, the canonical form differs from the
- * absolute form in that all relative file references to "." and ".."
- * are resolved and removed.
+ * system-dependent. On the GNU system, conversion to canonical
+ * form involves the removal of redundant separators, references to
+ * "." and "..", and symbolic links.
* <p>
* Note that this method, unlike the other methods which return path
* names, can throw an IOException. This is because native method
@@ -542,7 +542,8 @@ public class File implements Serializable, Comparable
/**
* This method returns a <code>String</code> the represents this file's
* parent. <code>null</code> is returned if the file has no parent. The
- * parent is determined via a simple operation which removes the
+ * parent is determined via a simple operation which removes the name
+ * after the last file separator character, as determined by the platform.
*
* @return The parent directory of this file
*/
@@ -1199,7 +1200,38 @@ public class File implements Serializable, Comparable
*/
public static File[] listRoots()
{
- return VMFile.listRoots();
+ File[] roots = VMFile.listRoots();
+
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ {
+ // Only return roots to which the security manager permits read access.
+ int count = roots.length;
+ for (int i = 0; i < roots.length; i++)
+ {
+ try
+ {
+ s.checkRead (roots[i].path);
+ }
+ catch (SecurityException sx)
+ {
+ roots[i] = null;
+ count--;
+ }
+ }
+ if (count != roots.length)
+ {
+ File[] newRoots = new File[count];
+ int k = 0;
+ for (int i = 0; i < roots.length; i++)
+ {
+ if (roots[i] != null)
+ newRoots[k++] = roots[i];
+ }
+ roots = newRoots;
+ }
+ }
+ return roots;
}
/**
diff --git a/libjava/classpath/java/io/FilePermission.java b/libjava/classpath/java/io/FilePermission.java
index 9a83efba621..0872a378bc3 100644
--- a/libjava/classpath/java/io/FilePermission.java
+++ b/libjava/classpath/java/io/FilePermission.java
@@ -274,12 +274,7 @@ public final class FilePermission extends Permission implements Serializable
break;
default:
- if (f2.charAt(f2.length() - 1) == File.separatorChar)
- {
- if (! f1.equals(f2.substring(0, f2.length() - 1)))
- return false;
- }
- else if (!f1.equals(f2))
+ if (!f1.equals(f2))
return false;
break;
}
diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java
index 91832f94e2c..a37ad73fd86 100644
--- a/libjava/classpath/java/io/ObjectInputStream.java
+++ b/libjava/classpath/java/io/ObjectInputStream.java
@@ -424,7 +424,23 @@ public class ObjectInputStream extends InputStream
clearHandles();
throw new WriteAbortedException("Exception thrown during writing of stream", e);
}
-
+
+ case TC_ENUM:
+ {
+ /* TC_ENUM classDesc newHandle enumConstantName */
+ if (dump)
+ dumpElementln("ENUM=");
+ ObjectStreamClass osc = (ObjectStreamClass) readObject();
+ String constantName = (String) readObject();
+ if (dump)
+ dumpElementln("CONSTANT NAME = " + constantName);
+ Class clazz = osc.forClass();
+ Enum instance = Enum.valueOf(clazz, constantName);
+ assignNewHandle(instance);
+ ret_val = instance;
+ break;
+ }
+
default:
throw new IOException("Unknown marker on stream: " + marker);
}
diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java
index 61f07bc7cfb..80d196bce1b 100644
--- a/libjava/classpath/java/io/ObjectOutputStream.java
+++ b/libjava/classpath/java/io/ObjectOutputStream.java
@@ -253,7 +253,17 @@ public class ObjectOutputStream extends OutputStream
ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(clazz);
if (osc == null)
throw new NotSerializableException(clazz.getName());
-
+
+ if (osc.isEnum())
+ {
+ /* TC_ENUM classDesc newHandle enumConstantName */
+ realOutput.writeByte(TC_ENUM);
+ writeObject(osc);
+ assignNewHandle(obj);
+ writeObject(((Enum) obj).name());
+ break;
+ }
+
if ((replacementEnabled || obj instanceof Serializable)
&& ! replaceDone)
{
@@ -432,7 +442,10 @@ public class ObjectOutputStream extends OutputStream
{
realOutput.writeByte(TC_CLASSDESC);
realOutput.writeUTF(osc.getName());
- realOutput.writeLong(osc.getSerialVersionUID());
+ if (osc.isEnum())
+ realOutput.writeLong(0L);
+ else
+ realOutput.writeLong(osc.getSerialVersionUID());
assignNewHandle(osc);
int flags = osc.getFlags();
diff --git a/libjava/classpath/java/io/ObjectStreamClass.java b/libjava/classpath/java/io/ObjectStreamClass.java
index 203e4a5abaa..abb26d839ad 100644
--- a/libjava/classpath/java/io/ObjectStreamClass.java
+++ b/libjava/classpath/java/io/ObjectStreamClass.java
@@ -219,6 +219,12 @@ public class ObjectStreamClass implements Serializable
return (flags & ObjectStreamConstants.SC_EXTERNALIZABLE) != 0;
}
+ // Returns true iff the class that this ObjectStreamClass represents
+ // implements Externalizable.
+ boolean isEnum()
+ {
+ return (flags & ObjectStreamConstants.SC_ENUM) != 0;
+ }
// Returns the <code>ObjectStreamClass</code> that represents the
// class that is the superclass of the class this
@@ -587,6 +593,9 @@ outer:
if (writeObjectMethod != null)
flags |= ObjectStreamConstants.SC_WRITE_METHOD;
+
+ if (cl.isEnum() || cl == Enum.class)
+ flags |= ObjectStreamConstants.SC_ENUM;
}
@@ -596,7 +605,7 @@ outer:
{
SetAccessibleAction setAccessible = new SetAccessibleAction();
- if (!isSerializable() || isExternalizable())
+ if (!isSerializable() || isExternalizable() || isEnum())
{
fields = NO_FIELDS;
return;
diff --git a/libjava/classpath/java/io/ObjectStreamConstants.java b/libjava/classpath/java/io/ObjectStreamConstants.java
index 04cf79bed3e..a29db2a0e2c 100644
--- a/libjava/classpath/java/io/ObjectStreamConstants.java
+++ b/libjava/classpath/java/io/ObjectStreamConstants.java
@@ -50,8 +50,6 @@ package java.io;
*/
public interface ObjectStreamConstants
{
- // FIXME: Javadoc comment these values.
-
/**
* The serialization stream protocol version 1. This version was
* the default serialization protocol before JDK 1.2.
@@ -70,37 +68,159 @@ public interface ObjectStreamConstants
*/
int PROTOCOL_VERSION_2 = 2;
+ /**
+ * The magic number that is written as part of the stream header.
+ */
short STREAM_MAGIC = (short)0xaced;
+
+ /**
+ * The stream version number that is written as part of the stream header.
+ * Note that this is different from the protocol version that specifies
+ * the data format for the stream.
+ */
short STREAM_VERSION = 5;
+ /**
+ * Token value to designate a <code>null</code> reference in the stream.
+ */
byte TC_NULL = (byte)112; //0x70
+
+ /**
+ * Token value to designate a reference to an already serialized object.
+ */
byte TC_REFERENCE = (byte)113; //0x71
+
+ /**
+ * Token value to designate a class descriptor is next in the stream.
+ */
byte TC_CLASSDESC = (byte)114; //0x72
+
+ /**
+ * Token value to designate a new object is next in the stream.
+ */
byte TC_OBJECT = (byte)115; //0x73
+
+ /**
+ * Token value to designate a new string is next in the stream.
+ */
byte TC_STRING = (byte)116; //0x74
+
+ /**
+ * Token value to designate a new array is next in the stream.
+ */
byte TC_ARRAY = (byte)117; //0x75
+
+ /**
+ * Token reference to designate a reference to a class.
+ */
byte TC_CLASS = (byte)118; //0x76
+
+ /**
+ * Token value to designate a block of primitive data is next in the stream.
+ * The next byte in the stream holds the size of the block (in bytes).
+ */
byte TC_BLOCKDATA = (byte)119; //0x77
+
+ /**
+ * Token value to designate the end of a block of primitve data.
+ */
byte TC_ENDBLOCKDATA = (byte)120; //0x78
+
+ /**
+ * Token value to designate a reset of the stream state.
+ */
byte TC_RESET = (byte)121; //0x79
+
+ /**
+ * Token value to designate a long block of primitive data is next in the
+ * stream. The next long in the stream holds the size of the block
+ * (in bytes).
+ */
byte TC_BLOCKDATALONG = (byte)122; //0x7A
+
+ /**
+ * Token value to designate an exception occured during serialization.
+ */
byte TC_EXCEPTION = (byte)123; //0x7B
+
+ /**
+ * Token value to designate a long string is next in the stream.
+ */
byte TC_LONGSTRING = (byte)124; //0x7C
+
+ /**
+ * Token value to designate a proxy class descriptor is next in the stream.
+ */
byte TC_PROXYCLASSDESC = (byte)125; //0x7D
+ /**
+ * Token value to designate an enum constant is next in the stream.
+ *
+ * @since 1.5
+ */
+ byte TC_ENUM = (byte)126; //0x7E
+
+ /**
+ * The first token value.
+ */
byte TC_BASE = TC_NULL;
- byte TC_MAX = TC_PROXYCLASSDESC;
+
+ /**
+ * The last token value.
+ */
+ byte TC_MAX = TC_ENUM;
+ /**
+ * The first handle that will be assigned to an object, for later references.
+ */
int baseWireHandle = 0x7e0000;
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * defines the <code>writeObject</code> method.
+ */
byte SC_WRITE_METHOD = 0x01;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is serializeable.
+ */
byte SC_SERIALIZABLE = 0x02;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is externalizable.
+ */
byte SC_EXTERNALIZABLE = 0x04;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that
+ * externalizable data is written in block data mode.
+ *
+ * @since 1.2
+ */
byte SC_BLOCK_DATA = 0x08;
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is an enum constant.
+ *
+ * @since 1.5
+ */
+ byte SC_ENUM = 0x10;
+
+ /**
+ * Constant for use with a <code>SecurityManager</code> to check if
+ * substitution of objects is allowed.
+ */
SerializablePermission SUBSTITUTION_PERMISSION
= new SerializablePermission("enableSubstitution");
+ /**
+ * Constant for use with a <code>SecurityManager</code> to check if
+ * overriding of the <code>writeObject</code> and <code>readObject</code>
+ * methods is allowed.
+ */
SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION
= new SerializablePermission("enableSubclassImplementation");
}
diff --git a/libjava/classpath/java/io/OutputStream.java b/libjava/classpath/java/io/OutputStream.java
index 8608daaa161..e3caa70f19c 100644
--- a/libjava/classpath/java/io/OutputStream.java
+++ b/libjava/classpath/java/io/OutputStream.java
@@ -1,5 +1,5 @@
/* OutputStream.java -- Base class for byte output streams
- Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@ package java.io;
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey (tromey@cygnus.com)
*/
-public abstract class OutputStream
+public abstract class OutputStream implements Closeable, Flushable
{
/**
* This is the default no-argument constructor for this class. This method
diff --git a/libjava/classpath/java/io/PrintStream.java b/libjava/classpath/java/io/PrintStream.java
index 99af25583b0..98461db2ba8 100644
--- a/libjava/classpath/java/io/PrintStream.java
+++ b/libjava/classpath/java/io/PrintStream.java
@@ -87,8 +87,76 @@ public class PrintStream extends FilterOutputStream
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.
*/
@@ -98,7 +166,7 @@ public class PrintStream extends FilterOutputStream
}
/**
- * 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
@@ -127,7 +195,7 @@ public class PrintStream extends FilterOutputStream
}
/**
- * 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
diff --git a/libjava/classpath/java/lang/Iterable.java b/libjava/classpath/java/lang/Iterable.java
index 8223bcf8c93..35c426484bb 100644
--- a/libjava/classpath/java/lang/Iterable.java
+++ b/libjava/classpath/java/lang/Iterable.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package java.lang;
-import java.util.Iterator;
+// We only need Iterator, but we import * to support lib/mkcollections.pl
+import java.util.*;
/**
* This interface is used to indicate that a given class can be
diff --git a/libjava/classpath/java/lang/SecurityManager.java b/libjava/classpath/java/lang/SecurityManager.java
index 30ee1be086f..999fe83dda1 100644
--- a/libjava/classpath/java/lang/SecurityManager.java
+++ b/libjava/classpath/java/lang/SecurityManager.java
@@ -421,7 +421,7 @@ public class SecurityManager
public void checkAccess(Thread thread)
{
if (thread.getThreadGroup() != null
- && thread.getThreadGroup().getParent() == null)
+ && thread.getThreadGroup().parent == null)
checkPermission(new RuntimePermission("modifyThread"));
}
@@ -454,7 +454,7 @@ public class SecurityManager
*/
public void checkAccess(ThreadGroup g)
{
- if (g.getParent() == null)
+ if (g.parent == null)
checkPermission(new RuntimePermission("modifyThreadGroup"));
}
diff --git a/libjava/classpath/java/lang/StrictMath.java b/libjava/classpath/java/lang/StrictMath.java
index 548a6f1c16e..0f066216787 100644
--- a/libjava/classpath/java/lang/StrictMath.java
+++ b/libjava/classpath/java/lang/StrictMath.java
@@ -1,5 +1,5 @@
/* java.lang.StrictMath -- common mathematical functions, strict Java
- Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -633,6 +633,227 @@ public final strictfp class StrictMath
}
/**
+ * Returns the hyperbolic cosine of <code>x</code>, which is defined as
+ * (exp(x) + exp(-x)) / 2.
+ *
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, the result is NaN</li>
+ * <li>If the argument is positive infinity, the result is positive
+ * infinity.</li>
+ * <li>If the argument is negative infinity, the result is positive
+ * infinity.</li>
+ * <li>If the argument is zero, the result is one.</li>
+ * </ul>
+ *
+ * @param x the argument to <em>cosh</em>
+ * @return the hyperbolic cosine of <code>x</code>
+ *
+ * @since 1.5
+ */
+ public static double cosh(double x)
+ {
+ // Method :
+ // mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
+ // 1. Replace x by |x| (cosh(x) = cosh(-x)).
+ // 2.
+ // [ exp(x) - 1 ]^2
+ // 0 <= x <= ln2/2 : cosh(x) := 1 + -------------------
+ // 2*exp(x)
+ //
+ // exp(x) + 1/exp(x)
+ // ln2/2 <= x <= 22 : cosh(x) := ------------------
+ // 2
+ // 22 <= x <= lnovft : cosh(x) := exp(x)/2
+ // lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2)
+ // ln2ovft < x : cosh(x) := +inf (overflow)
+
+ double t, w;
+ long bits;
+ int hx;
+ int lx;
+
+ // handle special cases
+ if (x != x)
+ return Double.NaN;
+ if (x == Double.POSITIVE_INFINITY)
+ return Double.POSITIVE_INFINITY;
+ if (x == Double.NEGATIVE_INFINITY)
+ return Double.POSITIVE_INFINITY;
+
+ bits = Double.doubleToLongBits(x);
+ hx = getHighDWord(bits) & 0x7fffffff; // ignore sign
+ lx = getLowDWord(bits);
+
+ // |x| in [0, 0.5 * ln(2)], return 1 + expm1(|x|)^2 / (2 * exp(|x|))
+ if (hx < 0x3fd62e43)
+ {
+ t = expm1(abs(x));
+ w = 1.0 + t;
+
+ // for tiny arguments return 1.
+ if (hx < 0x3c800000)
+ return w;
+
+ return 1.0 + (t * t) / (w + w);
+ }
+
+ // |x| in [0.5 * ln(2), 22], return exp(|x|)/2 + 1 / (2 * exp(|x|))
+ if (hx < 0x40360000)
+ {
+ t = exp(abs(x));
+
+ return 0.5 * t + 0.5 / t;
+ }
+
+ // |x| in [22, log(Double.MAX_VALUE)], return 0.5 * exp(|x|)
+ if (hx < 0x40862e42)
+ return 0.5 * exp(abs(x));
+
+ // |x| in [log(Double.MAX_VALUE), overflowthreshold],
+ // return exp(x/2)/2 * exp(x/2)
+
+ // we need to force an unsigned <= compare, thus can not use lx.
+ if ((hx < 0x408633ce)
+ || ((hx == 0x408633ce)
+ && ((bits & 0x00000000ffffffffL) <= 0x8fb9f87dL)))
+ {
+ w = exp(0.5 * abs(x));
+ t = 0.5 * w;
+
+ return t * w;
+ }
+
+ // |x| > overflowthreshold
+ return Double.POSITIVE_INFINITY;
+ }
+
+ /**
+ * Returns the lower two words of a long. This is intended to be
+ * used like this:
+ * <code>getLowDWord(Double.doubleToLongBits(x))</code>.
+ */
+ private static int getLowDWord(long x)
+ {
+ return (int) (x & 0x00000000ffffffffL);
+ }
+
+ /**
+ * Returns the higher two words of a long. This is intended to be
+ * used like this:
+ * <code>getHighDWord(Double.doubleToLongBits(x))</code>.
+ */
+ private static int getHighDWord(long x)
+ {
+ return (int) ((x & 0xffffffff00000000L) >> 32);
+ }
+
+ /**
+ * Returns a double with the IEEE754 bit pattern given in the lower
+ * and higher two words <code>lowDWord</code> and <code>highDWord</code>.
+ */
+ private static double buildDouble(int lowDWord, int highDWord)
+ {
+ return Double.longBitsToDouble((((long) highDWord & 0xffffffffL) << 32)
+ | ((long) lowDWord & 0xffffffffL));
+ }
+
+ /**
+ * Returns the cube root of <code>x</code>. The sign of the cube root
+ * is equal to the sign of <code>x</code>.
+ *
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, the result is NaN</li>
+ * <li>If the argument is positive infinity, the result is positive
+ * infinity.</li>
+ * <li>If the argument is negative infinity, the result is negative
+ * infinity.</li>
+ * <li>If the argument is zero, the result is zero with the same
+ * sign as the argument.</li>
+ * </ul>
+ *
+ * @param x the number to take the cube root of
+ * @return the cube root of <code>x</code>
+ * @see #sqrt(double)
+ *
+ * @since 1.5
+ */
+ public static double cbrt(double x)
+ {
+ boolean negative = (x < 0);
+ double r;
+ double s;
+ double t;
+ double w;
+
+ long bits;
+ int l;
+ int h;
+
+ // handle the special cases
+ if (x != x)
+ return Double.NaN;
+ if (x == Double.POSITIVE_INFINITY)
+ return Double.POSITIVE_INFINITY;
+ if (x == Double.NEGATIVE_INFINITY)
+ return Double.NEGATIVE_INFINITY;
+ if (x == 0)
+ return x;
+
+ x = abs(x);
+ bits = Double.doubleToLongBits(x);
+
+ if (bits < 0x0010000000000000L) // subnormal number
+ {
+ t = TWO_54;
+ t *= x;
+
+ // __HI(t)=__HI(t)/3+B2;
+ bits = Double.doubleToLongBits(t);
+ h = getHighDWord(bits);
+ l = getLowDWord(bits);
+
+ h = h / 3 + CBRT_B2;
+
+ t = buildDouble(l, h);
+ }
+ else
+ {
+ // __HI(t)=__HI(x)/3+B1;
+ h = getHighDWord(bits);
+ l = 0;
+
+ h = h / 3 + CBRT_B1;
+ t = buildDouble(l, h);
+ }
+
+ // new cbrt to 23 bits
+ r = t * t / x;
+ s = CBRT_C + r * t;
+ t *= CBRT_G + CBRT_F / (s + CBRT_E + CBRT_D / s);
+
+ // chopped to 20 bits and make it larger than cbrt(x)
+ bits = Double.doubleToLongBits(t);
+ h = getHighDWord(bits);
+
+ // __LO(t)=0;
+ // __HI(t)+=0x00000001;
+ l = 0;
+ h += 1;
+ t = buildDouble(l, h);
+
+ // one step newton iteration to 53 bits with error less than 0.667 ulps
+ s = t * t; // t * t is exact
+ r = x / s;
+ w = t + t;
+ r = (r - t) / (w + r); // r - s is exact
+ t = t + t * r;
+
+ return negative ? -t : t;
+ }
+
+ /**
* Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the
* argument is NaN, the result is NaN; if the argument is positive infinity,
* the result is positive infinity; and if the argument is negative
@@ -694,6 +915,254 @@ public final strictfp class StrictMath
}
/**
+ * Returns <em>e</em><sup>x</sup> - 1.
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, the result is NaN.</li>
+ * <li>If the argument is positive infinity, the result is positive
+ * infinity</li>
+ * <li>If the argument is negative infinity, the result is -1.</li>
+ * <li>If the argument is zero, the result is zero.</li>
+ * </ul>
+ *
+ * @param x the argument to <em>e</em><sup>x</sup> - 1.
+ * @return <em>e</em> raised to the power <code>x</code> minus one.
+ * @see #exp(double)
+ */
+ public static double expm1(double x)
+ {
+ // Method
+ // 1. Argument reduction:
+ // Given x, find r and integer k such that
+ //
+ // x = k * ln(2) + r, |r| <= 0.5 * ln(2)
+ //
+ // Here a correction term c will be computed to compensate
+ // the error in r when rounded to a floating-point number.
+ //
+ // 2. Approximating expm1(r) by a special rational function on
+ // the interval [0, 0.5 * ln(2)]:
+ // Since
+ // r*(exp(r)+1)/(exp(r)-1) = 2 + r^2/6 - r^4/360 + ...
+ // we define R1(r*r) by
+ // r*(exp(r)+1)/(exp(r)-1) = 2 + r^2/6 * R1(r*r)
+ // That is,
+ // R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+ // = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+ // = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+ // We use a special Remes algorithm on [0, 0.347] to generate
+ // a polynomial of degree 5 in r*r to approximate R1. The
+ // maximum error of this polynomial approximation is bounded
+ // by 2**-61. In other words,
+ // R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+ // where Q1 = -1.6666666666666567384E-2,
+ // Q2 = 3.9682539681370365873E-4,
+ // Q3 = -9.9206344733435987357E-6,
+ // Q4 = 2.5051361420808517002E-7,
+ // Q5 = -6.2843505682382617102E-9;
+ // (where z=r*r, and Q1 to Q5 are called EXPM1_Qx in the source)
+ // with error bounded by
+ // | 5 | -61
+ // | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2
+ // | |
+ //
+ // expm1(r) = exp(r)-1 is then computed by the following
+ // specific way which minimize the accumulation rounding error:
+ // 2 3
+ // r r [ 3 - (R1 + R1*r/2) ]
+ // expm1(r) = r + --- + --- * [--------------------]
+ // 2 2 [ 6 - r*(3 - R1*r/2) ]
+ //
+ // To compensate the error in the argument reduction, we use
+ // expm1(r+c) = expm1(r) + c + expm1(r)*c
+ // ~ expm1(r) + c + r*c
+ // Thus c+r*c will be added in as the correction terms for
+ // expm1(r+c). Now rearrange the term to avoid optimization
+ // screw up:
+ // ( 2 2 )
+ // ({ ( r [ R1 - (3 - R1*r/2) ] ) } r )
+ // expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+ // ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 )
+ // ( )
+ //
+ // = r - E
+ // 3. Scale back to obtain expm1(x):
+ // From step 1, we have
+ // expm1(x) = either 2^k*[expm1(r)+1] - 1
+ // = or 2^k*[expm1(r) + (1-2^-k)]
+ // 4. Implementation notes:
+ // (A). To save one multiplication, we scale the coefficient Qi
+ // to Qi*2^i, and replace z by (x^2)/2.
+ // (B). To achieve maximum accuracy, we compute expm1(x) by
+ // (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+ // (ii) if k=0, return r-E
+ // (iii) if k=-1, return 0.5*(r-E)-0.5
+ // (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E)
+ // else return 1.0+2.0*(r-E);
+ // (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+ // (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+ // (vii) return 2^k(1-((E+2^-k)-r))
+
+ boolean negative = (x < 0);
+ double y, hi, lo, c, t, e, hxs, hfx, r1;
+ int k;
+
+ long bits;
+ int h_bits;
+ int l_bits;
+
+ c = 0.0;
+ y = abs(x);
+
+ bits = Double.doubleToLongBits(y);
+ h_bits = getHighDWord(bits);
+ l_bits = getLowDWord(bits);
+
+ // handle special cases and large arguments
+ if (h_bits >= 0x4043687a) // if |x| >= 56 * ln(2)
+ {
+ if (h_bits >= 0x40862e42) // if |x| >= EXP_LIMIT_H
+ {
+ if (h_bits >= 0x7ff00000)
+ {
+ if (((h_bits & 0x000fffff) | (l_bits & 0xffffffff)) != 0)
+ return Double.NaN; // exp(NaN) = NaN
+ else
+ return negative ? -1.0 : x; // exp({+-inf}) = {+inf, -1}
+ }
+
+ if (x > EXP_LIMIT_H)
+ return Double.POSITIVE_INFINITY; // overflow
+ }
+
+ if (negative) // x <= -56 * ln(2)
+ return -1.0;
+ }
+
+ // argument reduction
+ if (h_bits > 0x3fd62e42) // |x| > 0.5 * ln(2)
+ {
+ if (h_bits < 0x3ff0a2b2) // |x| < 1.5 * ln(2)
+ {
+ if (negative)
+ {
+ hi = x + LN2_H;
+ lo = -LN2_L;
+ k = -1;
+ }
+ else
+ {
+ hi = x - LN2_H;
+ lo = LN2_L;
+ k = 1;
+ }
+ }
+ else
+ {
+ k = (int) (INV_LN2 * x + (negative ? - 0.5 : 0.5));
+ t = k;
+ hi = x - t * LN2_H;
+ lo = t * LN2_L;
+ }
+
+ x = hi - lo;
+ c = (hi - x) - lo;
+
+ }
+ else if (h_bits < 0x3c900000) // |x| < 2^-54 return x
+ return x;
+ else
+ k = 0;
+
+ // x is now in primary range
+ hfx = 0.5 * x;
+ hxs = x * hfx;
+ r1 = 1.0 + hxs * (EXPM1_Q1
+ + hxs * (EXPM1_Q2
+ + hxs * (EXPM1_Q3
+ + hxs * (EXPM1_Q4
+ + hxs * EXPM1_Q5))));
+ t = 3.0 - r1 * hfx;
+ e = hxs * ((r1 - t) / (6.0 - x * t));
+
+ if (k == 0)
+ {
+ return x - (x * e - hxs); // c == 0
+ }
+ else
+ {
+ e = x * (e - c) - c;
+ e -= hxs;
+
+ if (k == -1)
+ return 0.5 * (x - e) - 0.5;
+
+ if (k == 1)
+ {
+ if (x < - 0.25)
+ return -2.0 * (e - (x + 0.5));
+ else
+ return 1.0 + 2.0 * (x - e);
+ }
+
+ if (k <= -2 || k > 56) // sufficient to return exp(x) - 1
+ {
+ y = 1.0 - (e - x);
+
+ bits = Double.doubleToLongBits(y);
+ h_bits = getHighDWord(bits);
+ l_bits = getLowDWord(bits);
+
+ h_bits += (k << 20); // add k to y's exponent
+
+ y = buildDouble(l_bits, h_bits);
+
+ return y - 1.0;
+ }
+
+ t = 1.0;
+ if (k < 20)
+ {
+ bits = Double.doubleToLongBits(t);
+ h_bits = 0x3ff00000 - (0x00200000 >> k);
+ l_bits = getLowDWord(bits);
+
+ t = buildDouble(l_bits, h_bits); // t = 1 - 2^(-k)
+ y = t - (e - x);
+
+ bits = Double.doubleToLongBits(y);
+ h_bits = getHighDWord(bits);
+ l_bits = getLowDWord(bits);
+
+ h_bits += (k << 20); // add k to y's exponent
+
+ y = buildDouble(l_bits, h_bits);
+ }
+ else
+ {
+ bits = Double.doubleToLongBits(t);
+ h_bits = (0x000003ff - k) << 20;
+ l_bits = getLowDWord(bits);
+
+ t = buildDouble(l_bits, h_bits); // t = 2^(-k)
+
+ y = x - (e + t);
+ y += 1.0;
+
+ bits = Double.doubleToLongBits(y);
+ h_bits = getHighDWord(bits);
+ l_bits = getLowDWord(bits);
+
+ h_bits += (k << 20); // add k to y's exponent
+
+ y = buildDouble(l_bits, h_bits);
+ }
+ }
+
+ return y;
+ }
+
+ /**
* Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the
* argument is NaN or negative, the result is NaN; if the argument is
* positive infinity, the result is positive infinity; and if the argument
@@ -1429,6 +1898,33 @@ public final strictfp class StrictMath
AT10 = 0.016285820115365782; // Long bits 0x3f90ad3ae322da11L.
/**
+ * Constants for computing {@link #cbrt(double)}.
+ */
+ private static final int
+ CBRT_B1 = 715094163, // B1 = (682-0.03306235651)*2**20
+ CBRT_B2 = 696219795; // B2 = (664-0.03306235651)*2**20
+
+ /**
+ * Constants for computing {@link #cbrt(double)}.
+ */
+ private static final double
+ CBRT_C = 5.42857142857142815906e-01, // Long bits 0x3fe15f15f15f15f1L
+ CBRT_D = -7.05306122448979611050e-01, // Long bits 0xbfe691de2532c834L
+ CBRT_E = 1.41428571428571436819e+00, // Long bits 0x3ff6a0ea0ea0ea0fL
+ CBRT_F = 1.60714285714285720630e+00, // Long bits 0x3ff9b6db6db6db6eL
+ CBRT_G = 3.57142857142857150787e-01; // Long bits 0x3fd6db6db6db6db7L
+
+ /**
+ * Constants for computing {@link #expm1(double)}
+ */
+ private static final double
+ EXPM1_Q1 = -3.33333333333331316428e-02, // Long bits 0xbfa11111111110f4L
+ EXPM1_Q2 = 1.58730158725481460165e-03, // Long bits 0x3f5a01a019fe5585L
+ EXPM1_Q3 = -7.93650757867487942473e-05, // Long bits 0xbf14ce199eaadbb7L
+ EXPM1_Q4 = 4.00821782732936239552e-06, // Long bits 0x3ed0cfca86e65239L
+ EXPM1_Q5 = -2.01099218183624371326e-07; // Long bits 0xbe8afdb76e09c32dL
+
+ /**
* Helper function for reducing an angle to a multiple of pi/2 within
* [-pi/4, pi/4].
*
diff --git a/libjava/classpath/java/lang/String.java b/libjava/classpath/java/lang/String.java
index 199dfba3545..dbc3f7d8bf4 100644
--- a/libjava/classpath/java/lang/String.java
+++ b/libjava/classpath/java/lang/String.java
@@ -1820,7 +1820,7 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public synchronized int codePointCount(int start, int end)
{
- if (start < 0 || end >= count || start > end)
+ if (start < 0 || end > count || start > end)
throw new StringIndexOutOfBoundsException();
start += offset;
diff --git a/libjava/classpath/java/lang/System.java b/libjava/classpath/java/lang/System.java
index b538b795b95..19278aa32cd 100644
--- a/libjava/classpath/java/lang/System.java
+++ b/libjava/classpath/java/lang/System.java
@@ -222,6 +222,36 @@ public final class System
return VMSystem.currentTimeMillis();
}
+ /**
+ * <p>
+ * Returns the current value of a nanosecond-precise system timer.
+ * The value of the timer is an offset relative to some arbitrary fixed
+ * time, which may be in the future (making the value negative). This
+ * method is useful for timing events where nanosecond precision is
+ * required. This is achieved by calling this method before and after the
+ * event, and taking the difference betweent the two times:
+ * </p>
+ * <p>
+ * <code>long startTime = System.nanoTime();</code><br />
+ * <code>... <emph>event code</emph> ...</code><br />
+ * <code>long endTime = System.nanoTime();</code><br />
+ * <code>long duration = endTime - startTime;</code><br />
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63.
+ * </p>
+ *
+ * @return the time of a system timer in nanoseconds.
+ * @since 1.5
+ */
+ public static long nanoTime()
+ {
+ return VMSystem.nanoTime();
+ }
+
/**
* Copy one array onto another from <code>src[srcStart]</code> ...
* <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
@@ -319,6 +349,7 @@ public final class System
* <dt>gnu.java.io.encoding_scheme_alias.iso-latin-_?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.latin?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.utf-8</dt> <dd>UTF8</dd>
+ * <dt>gnu.javax.print.server</dt> <dd>Hostname of external CUPS server.</dd>
* </dl>
*
* @return the system properties, will never be null
diff --git a/libjava/classpath/java/lang/Thread.java b/libjava/classpath/java/lang/Thread.java
index 23620543aef..36b7c3303a9 100644
--- a/libjava/classpath/java/lang/Thread.java
+++ b/libjava/classpath/java/lang/Thread.java
@@ -38,8 +38,16 @@ exception statement from your version. */
package java.lang;
+import gnu.classpath.VMStackWalker;
import gnu.java.util.WeakIdentityHashMap;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
import java.security.Permission;
+
+import java.util.HashMap;
import java.util.Map;
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
@@ -131,15 +139,16 @@ public class Thread implements Runnable
/** The context classloader for this Thread. */
private ClassLoader contextClassLoader;
-
+ private boolean contextClassLoaderIsSystemClassLoader;
+
/** This thread's ID. */
private final long threadId;
/** The next thread number to use. */
private static int numAnonymousThreadsCreated;
- /** The next thread ID to use. */
- private static long nextThreadId;
+ /** Used to generate the next thread ID to use. */
+ private static long totalThreadsCreated;
/** The default exception handler. */
private static UncaughtExceptionHandler defaultHandler;
@@ -248,7 +257,7 @@ public class Thread implements Runnable
*/
public Thread(ThreadGroup group, Runnable target)
{
- this(group, target, "Thread-" + ++numAnonymousThreadsCreated, 0);
+ this(group, target, createAnonymousThreadName(), 0);
}
/**
@@ -347,8 +356,8 @@ public class Thread implements Runnable
if (group == null)
group = current.group;
}
- else if (sm != null)
- sm.checkAccess(group);
+ if (sm != null)
+ sm.checkAccess(group);
this.group = group;
// Use toString hack to detect null.
@@ -358,12 +367,14 @@ public class Thread implements Runnable
synchronized (Thread.class)
{
- this.threadId = nextThreadId++;
+ this.threadId = ++totalThreadsCreated;
}
priority = current.priority;
daemon = current.daemon;
contextClassLoader = current.contextClassLoader;
+ contextClassLoaderIsSystemClassLoader =
+ current.contextClassLoaderIsSystemClassLoader;
group.addThread(this);
InheritableThreadLocal.newChildThread(this);
@@ -373,6 +384,9 @@ public class Thread implements Runnable
* Used by the VM to create thread objects for threads started outside
* of Java. Note: caller is responsible for adding the thread to
* a group and InheritableThreadLocal.
+ * Note: This constructor should not call any methods that could result
+ * in a call to Thread.currentThread(), because that makes life harder
+ * for the VM.
*
* @param vmThread the native thread
* @param name the thread name or null to use the default naming scheme
@@ -384,16 +398,32 @@ public class Thread implements Runnable
this.vmThread = vmThread;
this.runnable = null;
if (name == null)
- name = "Thread-" + ++numAnonymousThreadsCreated;
+ name = createAnonymousThreadName();
this.name = name;
this.priority = priority;
this.daemon = daemon;
- this.contextClassLoader = ClassLoader.getSystemClassLoader();
+ // By default the context class loader is the system class loader,
+ // we set a flag to signal this because we don't want to call
+ // ClassLoader.getSystemClassLoader() at this point, because on
+ // VMs that lazily create the system class loader that might result
+ // in running user code (when a custom system class loader is specified)
+ // and that user code could call Thread.currentThread().
+ // ClassLoader.getSystemClassLoader() can also return null, if the system
+ // is currently in the process of constructing the system class loader
+ // (and, as above, the constructiong sequence calls Thread.currenThread()).
+ contextClassLoaderIsSystemClassLoader = true;
synchronized (Thread.class)
{
- this.threadId = nextThreadId++;
+ this.threadId = ++totalThreadsCreated;
}
+ }
+ /**
+ * Generate a name for an anonymous thread.
+ */
+ private static synchronized String createAnonymousThreadName()
+ {
+ return "Thread-" + ++numAnonymousThreadsCreated;
}
/**
@@ -746,12 +776,18 @@ public class Thread implements Runnable
*/
public synchronized ClassLoader getContextClassLoader()
{
- // Bypass System.getSecurityManager, for bootstrap efficiency.
+ ClassLoader loader = contextClassLoaderIsSystemClassLoader ?
+ ClassLoader.getSystemClassLoader() : contextClassLoader;
+ // Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
- if (sm != null)
- // XXX Don't check this if the caller's class loader is an ancestor.
- sm.checkPermission(new RuntimePermission("getClassLoader"));
- return contextClassLoader;
+ if (loader != null && sm != null)
+ {
+ // Get the calling classloader
+ ClassLoader cl = VMStackWalker.getCallingClassLoader();
+ if (cl != null && !cl.isAncestorOf(loader))
+ sm.checkPermission(new RuntimePermission("getClassLoader"));
+ }
+ return loader;
}
/**
@@ -772,6 +808,7 @@ public class Thread implements Runnable
if (sm != null)
sm.checkPermission(new RuntimePermission("setContextClassLoader"));
this.contextClassLoader = classloader;
+ contextClassLoaderIsSystemClassLoader = false;
}
/**
@@ -1173,7 +1210,7 @@ public class Thread implements Runnable
* @author Andrew John Hughes <gnu_andrew@member.fsf.org>
* @since 1.5
* @see Thread#getUncaughtExceptionHandler()
- * @see Thread#setUncaughtExceptionHander(java.lang.Thread.UncaughtExceptionHandler)
+ * @see Thread#setUncaughtExceptionHandler(UncaughtExceptionHandler)
* @see Thread#getDefaultUncaughtExceptionHandler()
* @see
* Thread#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
@@ -1191,4 +1228,119 @@ public class Thread implements Runnable
*/
void uncaughtException(Thread thr, Throwable exc);
}
+
+ /**
+ * Returns the current state of the thread. This
+ * is designed for monitoring thread behaviour, rather
+ * than for synchronization control.
+ *
+ * @return the current thread state.
+ */
+ public String getState()
+ {
+ VMThread t = vmThread;
+ if (t != null)
+ return t.getState();
+ if (group == null)
+ return "TERMINATED";
+ return "NEW";
+ }
+
+ /**
+ * <p>
+ * Returns a map of threads to stack traces for each
+ * live thread. The keys of the map are {@link Thread}
+ * objects, which map to arrays of {@link StackTraceElement}s.
+ * The results obtained from Calling this method are
+ * equivalent to calling {@link getStackTrace()} on each
+ * thread in succession. Threads may be executing while
+ * this takes place, and the results represent a snapshot
+ * of the thread at the time its {@link getStackTrace()}
+ * method is called.
+ * </p>
+ * <p>
+ * The stack trace information contains the methods called
+ * by the thread, with the most recent method forming the
+ * first element in the array. The array will be empty
+ * if the virtual machine can not obtain information on the
+ * thread.
+ * </p>
+ * <p>
+ * To execute this method, the current security manager
+ * (if one exists) must allow both the
+ * <code>"getStackTrace"</code> and
+ * <code>"modifyThreadGroup"</code> {@link RuntimePermission}s.
+ * </p>
+ *
+ * @return a map of threads to arrays of {@link StackTraceElement}s.
+ * @throws SecurityException if a security manager exists, and
+ * prevents either or both the runtime
+ * permissions specified above.
+ * @since 1.5
+ * @see #getStackTrace()
+ */
+ public static Map getAllStackTraces()
+ {
+ ThreadGroup group = currentThread().group;
+ while (group.getParent() != null)
+ group = group.getParent();
+ int arraySize = group.activeCount();
+ Thread[] threadList = new Thread[arraySize];
+ int filled = group.enumerate(threadList);
+ while (filled == arraySize)
+ {
+ arraySize *= 2;
+ threadList = new Thread[arraySize];
+ filled = group.enumerate(threadList);
+ }
+ Map traces = new HashMap();
+ for (int a = 0; a < filled; ++a)
+ traces.put(threadList[a],
+ threadList[a].getStackTrace());
+ return traces;
+ }
+
+ /**
+ * <p>
+ * Returns an array of {@link StackTraceElement}s
+ * representing the current stack trace of this thread.
+ * The first element of the array is the most recent
+ * method called, and represents the top of the stack.
+ * The elements continue in this order, with the last
+ * element representing the bottom of the stack.
+ * </p>
+ * <p>
+ * A zero element array is returned for threads which
+ * have not yet started (and thus have not yet executed
+ * any methods) or for those which have terminated.
+ * Where the virtual machine can not obtain a trace for
+ * the thread, an empty array is also returned. The
+ * virtual machine may also omit some methods from the
+ * trace in non-zero arrays.
+ * </p>
+ * <p>
+ * To execute this method, the current security manager
+ * (if one exists) must allow both the
+ * <code>"getStackTrace"</code> and
+ * <code>"modifyThreadGroup"</code> {@link RuntimePermission}s.
+ * </p>
+ *
+ * @return a stack trace for this thread.
+ * @throws SecurityException if a security manager exists, and
+ * prevents the use of the
+ * <code>"getStackTrace"</code>
+ * permission.
+ * @since 1.5
+ * @see #getAllStackTraces()
+ */
+ public StackTraceElement[] getStackTrace()
+ {
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("getStackTrace"));
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ ThreadInfo info = bean.getThreadInfo(threadId, Integer.MAX_VALUE);
+ return info.getStackTrace();
+ }
+
}
diff --git a/libjava/classpath/java/lang/ThreadGroup.java b/libjava/classpath/java/lang/ThreadGroup.java
index 7fbef88f4d6..00f2f8ec47c 100644
--- a/libjava/classpath/java/lang/ThreadGroup.java
+++ b/libjava/classpath/java/lang/ThreadGroup.java
@@ -66,7 +66,7 @@ public class ThreadGroup implements UncaughtExceptionHandler
static boolean had_uncaught_exception;
/** The parent thread group. */
- private final ThreadGroup parent;
+ final ThreadGroup parent;
/** The group name, non-null. */
final String name;
@@ -749,4 +749,43 @@ public class ThreadGroup implements UncaughtExceptionHandler
parent.removeGroup(this);
}
}
+
+ /*
+ * Helper method for the VM. Find a Thread by its Id.
+ *
+ * @param id The Thread Id.
+ * @return Thread object or null if thread doesn't exist.
+ */
+ static Thread getThreadFromId(long id)
+ {
+ return root.getThreadFromIdImpl(id);
+ }
+
+ private Thread getThreadFromIdImpl(long id)
+ {
+ synchronized (threads)
+ {
+ for (int i = 0; i < threads.size(); i++)
+ {
+ Thread t = (Thread) threads.get(i);
+ if (t.getId() == id)
+ return t;
+ }
+ }
+ Vector groups = this.groups;
+ if (groups != null)
+ {
+ synchronized (groups)
+ {
+ for (int i = 0; i < groups.size(); i++)
+ {
+ ThreadGroup g = (ThreadGroup) groups.get(i);
+ Thread t = g.getThreadFromIdImpl(id);
+ if (t != null)
+ return t;
+ }
+ }
+ }
+ return null;
+ }
} // class ThreadGroup
diff --git a/libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java b/libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java
new file mode 100644
index 00000000000..a35df0c09b8
--- /dev/null
+++ b/libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java
@@ -0,0 +1,106 @@
+/* IncompleteAnnotationException.java - Thrown when annotation has changed
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.annotation;
+
+/**
+ * Thrown when accessing an element within an annotation which
+ * was added since compilation or serialization took place, and
+ * does not have a default value.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IncompleteAnnotationException extends RuntimeException
+{
+
+ /**
+ * Constructs a new <code>IncompleteAnnotationException</code>
+ * which indicates that the element, <code>name</code>, was missing
+ * from the annotation, <code>type</code> at compile time and does
+ * not have a default value.
+ *
+ * @param type the type of annotation from which an element is missing.
+ * @param name the name of the missing element.
+ */
+ public IncompleteAnnotationException(Class type, String name)
+ {
+ this.annotationType = type;
+ this.elementName = name;
+ }
+
+ /**
+ * Returns the class representing the type of annotation
+ * from which an element was missing.
+ *
+ * @return the type of annotation.
+ */
+ public Class annotationType()
+ {
+ return annotationType;
+ }
+
+ /**
+ * Returns the name of the missing annotation element.
+ *
+ * @return the element name.
+ */
+ public String elementName()
+ {
+ return elementName;
+ }
+
+ // Names are chosen from serialization spec.
+
+ /**
+ * The class representing the type of annotation from
+ * which an element was found to be missing.
+ *
+ * @serial the type of the annotation from which an
+ * element was missing.
+ */
+ private Class annotationType;
+
+ /**
+ * The name of the missing element.
+ *
+ * @serial the name of the missing element.
+ */
+ private String elementName;
+
+}
diff --git a/libjava/classpath/java/lang/management/ClassLoadingMXBean.java b/libjava/classpath/java/lang/management/ClassLoadingMXBean.java
new file mode 100644
index 00000000000..2a8651b9c81
--- /dev/null
+++ b/libjava/classpath/java/lang/management/ClassLoadingMXBean.java
@@ -0,0 +1,103 @@
+/* ClassLoadingMXBean.java - Interface for a class loading bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface ClassLoadingMXBean
+{
+
+ /**
+ * Returns the number of classes currently loaded by
+ * the virtual machine.
+ *
+ * @return the number of loaded classes.
+ */
+ int getLoadedClassCount();
+
+ /**
+ * Returns the total number of classes loaded by the
+ * virtual machine since it was started. This is the
+ * sum of the currently loaded classes and those that
+ * have been unloaded.
+ *
+ * @return the total number of classes that have been
+ * loaded by the virtual machine since it started.
+ */
+ long getTotalLoadedClassCount();
+
+ /**
+ * Returns the number of classes that have been unloaded
+ * by the virtual machine since it was started.
+ *
+ * @return the number of unloaded classes.
+ */
+ long getUnloadedClassCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when classes are loaded and unloaded. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when classes are loaded and unloaded. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ */
+ void setVerbose(boolean verbose);
+
+}
+
diff --git a/libjava/classpath/java/lang/management/CompilationMXBean.java b/libjava/classpath/java/lang/management/CompilationMXBean.java
new file mode 100644
index 00000000000..7f666f2c64b
--- /dev/null
+++ b/libjava/classpath/java/lang/management/CompilationMXBean.java
@@ -0,0 +1,85 @@
+/* CompilationMXBean.java - Interface for a compilation bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the Just-In-Time
+ * (JIT) compiler provided by the virtual machine, if one
+ * exists. An instance of this bean is obtainable by
+ * calling {@link ManagementFactory#getCompilationMXBean()}
+ * if a JIT is available. Otherwise, the method returns
+ * <code>null</code>.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface CompilationMXBean
+{
+
+ /**
+ * Returns the name of the Just-In-Time (JIT) compiler.
+ *
+ * @return the name of the JIT compiler.
+ */
+ String getName();
+
+ /**
+ * Returns true if the virtual machine's JIT compiler
+ * supports monitoring of the time spent compiling.
+ *
+ * @return true if the JIT compiler can be monitored
+ * for time spent compiling.
+ */
+ boolean isCompilationTimeMonitoringSupported();
+
+ /**
+ * Returns the accumulated time, in milliseconds, that
+ * the JIT compiler has spent compiling Java bytecodes
+ * to native machine code. This value represents a single
+ * time measurement for the whole virtual machine, including
+ * all multiple threads of operation. The value is not
+ * intended as a performance measurement.
+ *
+ * @return the accumulated number of milliseconds the JIT
+ * compiler has spent compiling.
+ * @throws UnsupportedOperationException if time monitoring
+ * is not supported.
+ */
+ long getTotalCompilationTime();
+
+}
diff --git a/libjava/classpath/java/lang/management/GarbageCollectorMXBean.java b/libjava/classpath/java/lang/management/GarbageCollectorMXBean.java
new file mode 100644
index 00000000000..5bb0a18d386
--- /dev/null
+++ b/libjava/classpath/java/lang/management/GarbageCollectorMXBean.java
@@ -0,0 +1,79 @@
+/* GarbageCollectorMXBean.java - Interface for a garbage collector bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the garbage collectors
+ * of the virtual machine. Garbage collectors are responsible
+ * for removing unreferenced objects from memory. A garbage
+ * collector is a type of memory manager, so this interface
+ * is combined with that of generic memory managers. An instance
+ * of this bean for each garbage collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface GarbageCollectorMXBean
+ extends MemoryManagerMXBean
+{
+
+ /**
+ * Returns the number of collections the garbage collector
+ * represented by this bean has made. -1 is returned if the
+ * collection count is undefined.
+ *
+ * @return the number of collections made, or -1 if this is
+ * undefined.
+ */
+ long getCollectionCount();
+
+ /**
+ * Returns the accumulated number of milliseconds this garbage
+ * collector has spent freeing the memory used by unreferenced
+ * objects. -1 is returned if the collection time is undefined.
+ * Note that the accumulated time may not change, even when the
+ * collection count increases, if the time taken is sufficiently
+ * short; this depends on the resolution of the timer used.
+ *
+ * @return the accumulated number of milliseconds spent collecting,
+ * or -1 if this is undefined.
+ */
+ long getCollectionTime();
+
+}
diff --git a/libjava/classpath/java/lang/management/ManagementFactory.java b/libjava/classpath/java/lang/management/ManagementFactory.java
new file mode 100644
index 00000000000..6e7af0f274e
--- /dev/null
+++ b/libjava/classpath/java/lang/management/ManagementFactory.java
@@ -0,0 +1,331 @@
+/* ManagementFactory.java - Factory for obtaining system beans.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import gnu.java.lang.management.ClassLoadingMXBeanImpl;
+import gnu.java.lang.management.CompilationMXBeanImpl;
+import gnu.java.lang.management.GarbageCollectorMXBeanImpl;
+import gnu.java.lang.management.OperatingSystemMXBeanImpl;
+import gnu.java.lang.management.MemoryMXBeanImpl;
+import gnu.java.lang.management.MemoryManagerMXBeanImpl;
+import gnu.java.lang.management.MemoryPoolMXBeanImpl;
+import gnu.java.lang.management.RuntimeMXBeanImpl;
+import gnu.java.lang.management.ThreadMXBeanImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * <p>
+ * Provides access to the system's management beans via a series
+ * of static methods.
+ * </p>
+ * <p>
+ * An instance of a system management bean can be obtained by
+ * using one of the following methods:
+ * </p>
+ * <ol>
+ * <li>Calling the appropriate static method of this factory.
+ * </li>
+ * </ol>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ManagementFactory
+{
+
+ /**
+ * The operating system management bean.
+ */
+ private static OperatingSystemMXBean osBean;
+
+ /**
+ * The runtime management bean.
+ */
+ private static RuntimeMXBean runtimeBean;
+
+ /**
+ * The class loading management bean.
+ */
+ private static ClassLoadingMXBean classLoadingBean;
+
+ /**
+ * The thread bean.
+ */
+ private static ThreadMXBean threadBean;
+
+ /**
+ * The memory bean.
+ */
+ private static MemoryMXBean memoryBean;
+
+ /**
+ * The compilation bean (may remain null).
+ */
+ private static CompilationMXBean compilationBean;
+
+ /**
+ * Private constructor to prevent instance creation.
+ */
+ private ManagementFactory() {}
+
+ /**
+ * Returns the operating system management bean for the
+ * operating system on which the virtual machine is running.
+ *
+ * @return an instance of {@link OperatingSystemMXBean} for
+ * the underlying operating system.
+ */
+ public static OperatingSystemMXBean getOperatingSystemMXBean()
+ {
+ if (osBean == null)
+ try
+ {
+ osBean = new OperatingSystemMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "operating system bean is not a " +
+ "compliant management bean.");
+ }
+ return osBean;
+ }
+
+ /**
+ * Returns the runtime management bean for the
+ * running virtual machine.
+ *
+ * @return an instance of {@link RuntimeMXBean} for
+ * this virtual machine.
+ */
+ public static RuntimeMXBean getRuntimeMXBean()
+ {
+ if (runtimeBean == null)
+ try
+ {
+ runtimeBean = new RuntimeMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "runtime bean is not a compliant " +
+ "management bean.");
+ }
+ return runtimeBean;
+ }
+
+ /**
+ * Returns the class loading management bean for the
+ * running virtual machine.
+ *
+ * @return an instance of {@link ClassLoadingMXBean} for
+ * this virtual machine.
+ */
+ public static ClassLoadingMXBean getClassLoadingMXBean()
+ {
+ if (classLoadingBean == null)
+ try
+ {
+ classLoadingBean = new ClassLoadingMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "class loading bean is not a " +
+ "compliant management bean.");
+ }
+ return classLoadingBean;
+ }
+
+ /**
+ * Returns the thread management bean for the running
+ * virtual machine.
+ *
+ * @return an instance of {@link ThreadMXBean} for
+ * this virtual machine.
+ */
+ public static ThreadMXBean getThreadMXBean()
+ {
+ if (threadBean == null)
+ try
+ {
+ threadBean = new ThreadMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "thread bean is not a compliant " +
+ "management bean.");
+ }
+ return threadBean;
+ }
+
+ /**
+ * Returns the memory management bean for the running
+ * virtual machine.
+ *
+ * @return an instance of {@link MemoryMXBean} for
+ * this virtual machine.
+ */
+ public static MemoryMXBean getMemoryMXBean()
+ {
+ if (memoryBean == null)
+ try
+ {
+ memoryBean = new MemoryMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory bean is not a compliant " +
+ "management bean.");
+ }
+ return memoryBean;
+ }
+
+ /**
+ * Returns the compilation bean for the running
+ * virtual machine, if supported. Otherwise,
+ * it returns <code>null</code>.
+ *
+ * @return an instance of {@link CompilationMXBean} for
+ * this virtual machine, or <code>null</code>
+ * if the virtual machine doesn't include
+ * a Just-In-Time (JIT) compiler.
+ */
+ public static CompilationMXBean getCompilationMXBean()
+ {
+ if (compilationBean == null &&
+ SystemProperties.getProperty("gnu.java.compiler.name") != null)
+ try
+ {
+ compilationBean = new CompilationMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "compilation bean is not a compliant " +
+ "management bean.");
+ }
+ return compilationBean;
+ }
+
+ /**
+ * Returns the memory pool beans for the running
+ * virtual machine. These may change during the course
+ * of execution.
+ *
+ * @return a list of memory pool beans, one for each pool.
+ */
+ public static List getMemoryPoolMXBeans()
+ {
+ List poolBeans = new ArrayList();
+ String[] names = VMManagementFactory.getMemoryPoolNames();
+ for (int a = 0; a < names.length; ++a)
+ try
+ {
+ poolBeans.add(new MemoryPoolMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory pool bean, " + a + ", is " +
+ "not a compliant management bean.");
+ }
+ return poolBeans;
+ }
+
+ /**
+ * Returns the memory manager beans for the running
+ * virtual machine. These may change during the course
+ * of execution.
+ *
+ * @return a list of memory manager beans, one for each manager.
+ */
+ public static List getMemoryManagerMXBeans()
+ {
+ List managerBeans = new ArrayList();
+ String[] names = VMManagementFactory.getMemoryManagerNames();
+ for (int a = 0; a < names.length; ++a)
+ try
+ {
+ managerBeans.add(new MemoryManagerMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory manager bean, " + a + ", is " +
+ "not a compliant management bean.");
+ }
+ managerBeans.addAll(getGarbageCollectorMXBeans());
+ return managerBeans;
+ }
+
+ /**
+ * Returns the garbage collector beans for the running
+ * virtual machine. These may change during the course
+ * of execution.
+ *
+ * @return a list of garbage collector beans, one for each pool.
+ */
+ public static List getGarbageCollectorMXBeans()
+ {
+ List gcBeans = new ArrayList();
+ String[] names = VMManagementFactory.getGarbageCollectorNames();
+ for (int a = 0; a < names.length; ++a)
+ try
+ {
+ gcBeans.add(new GarbageCollectorMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "garbage collector bean, " + a +
+ ", is not a compliant management " +
+ "bean.");
+ }
+ return gcBeans;
+ }
+
+}
diff --git a/libjava/classpath/java/lang/management/ManagementPermission.java b/libjava/classpath/java/lang/management/ManagementPermission.java
new file mode 100644
index 00000000000..0e6bd06126f
--- /dev/null
+++ b/libjava/classpath/java/lang/management/ManagementPermission.java
@@ -0,0 +1,132 @@
+/* ManagementPermission.java - Permissions for system management.
+ 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 java.security.BasicPermission;
+
+/**
+ * <p>
+ * Represents the permission to view or modify the data
+ * which forms part of the system management interfaces.
+ * Calls to methods of the system management beans,
+ * provided by the {@link ManagementFactory}, may perform
+ * checks against the current {@link java.lang.SecurityManager}
+ * (if any) before allowing the operation to proceed.
+ * Instances of this object are supplied to the
+ * {@link java.lang.SecurityManager} in order to perform
+ * these checks. It is not normal for instances of this
+ * class to be created outside the use of the
+ * {@link java.lang.SecurityManager}.
+ * </p>
+ * <p>
+ * This object can represent two types of management
+ * permission:
+ * </p>
+ * <ul>
+ * <li><strong>monitor</strong> &mdash; this allows access
+ * to information such as the arguments supplied to the
+ * virtual machine, the currently loaded classes and the
+ * stack traces of running threads. Malicious code may
+ * use this to obtain information about the system and
+ * exploit any vulnerabilities found.</li>
+ * <li><strong>control</strong> &mdash; this allows the
+ * information stored by the management beans to be altered.
+ * For example, additional debugging information (such
+ * as class loading traces) may be turned on or memory
+ * usage limits changed. Malicious code could use
+ * this to alter the behaviour of the system.</li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class ManagementPermission
+ extends BasicPermission
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 1897496590799378737L;
+
+ /**
+ * Constructs a new <code>ManagementPermission</code>
+ * for one of the two permission targets, "monitor"
+ * and "control".
+ *
+ * @param name the name of the permission this instance
+ * should represent; either "monitor" or
+ * "control".
+ * @throws IllegalArgumentException if the name is not
+ * either "monitor"
+ * or "control".
+ */
+ public ManagementPermission(String name)
+ {
+ super(name);
+ if (!(name.equals("monitor") || name.equals("control")))
+ throw new IllegalArgumentException("Invalid permission.");
+ }
+
+ /**
+ * Constructs a new <code>ManagementPermission</code>
+ * for one of the two permission targets, "monitor"
+ * and "control". Actions are not supported, so
+ * this value should be either <code>null</code>
+ * or the empty string.
+ *
+ * @param name the name of the permission this instance
+ * should represent; either "monitor" or
+ * "control".
+ * @param actions either <code>null</code> or the
+ * empty string.
+ * @throws IllegalArgumentException if the name is not
+ * either "monitor"
+ * or "control", or
+ * a value for actions
+ * is specified.
+ */
+ public ManagementPermission(String name, String actions)
+ {
+ this(name);
+ if (!(actions == null || actions.equals("")))
+ throw new IllegalArgumentException("Invalid actions.");
+ }
+
+}
+
diff --git a/libjava/classpath/java/lang/management/MemoryMXBean.java b/libjava/classpath/java/lang/management/MemoryMXBean.java
new file mode 100644
index 00000000000..4d9e5ff1cfd
--- /dev/null
+++ b/libjava/classpath/java/lang/management/MemoryMXBean.java
@@ -0,0 +1,172 @@
+/* MemoryMXBean.java - Interface for a memory bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about the memory used
+ * by the virtual machine. An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ * </p>
+ * <p>
+ * The Java virtual machine uses two types of memory:
+ * heap memory and non-heap memory. The heap is the
+ * storage location for class and array instances, and is
+ * thus the main source of memory associated with running
+ * Java programs. The heap is created when the virtual
+ * machine is started, and is periodically scanned by the
+ * garbage collector(s), in order to reclaim memory which
+ * is no longer used (e.g. because an object reference has
+ * gone out of scope).
+ * </p>
+ * <p>
+ * Non-heap memory is used by the virtual machine in order to
+ * perform its duties. Thus, it mainly acts as the storage
+ * location for structures created as a result of parsing Java
+ * bytecode, such as the constant pool and constructor/method
+ * declarations. When a Just-In-Time (JIT) compiler is in
+ * operation, this will use non-heap memory to store compiled
+ * bytecode.
+ * </p>
+ * <p>
+ * Both types of memory may be non-contiguous. During the
+ * lifetime of the virtual machine, the size of both may
+ * either change (either expanding or contracting) or stay
+ * the same.
+ * </p>
+ * <h2>Notifications</h2>
+ * <p>
+ * Implementations of this interface also conform to the
+ * {@link javax.management.NotificationEmitter} interface,
+ * and supply two notifications reflecting memory usage.
+ * These notifications occur when a usage threshold is
+ * exceeded; for more details of these, see the documentation
+ * of {@link MemoryPoolMXBean}. If threshold monitoring
+ * is supported, then a notification will be emitted each time
+ * the threshold is crossed. Another notification will not
+ * be emitted unless the usage level has dropped below the
+ * threshold again in the meantime.
+ * </p>
+ * <p>
+ * The emitted notifications are instances of
+ * {@link javax.management.Notification}, with a type of
+ * either
+ * {@link java.lang.management.MemoryNotificationInfo#MEMORY_THRESHOLD_EXCEEDED}
+ * or
+ * {@link java.lang.management.MemoryNotificationInfo#MEMORY_COLLECTION_THRESHOLD_EXCEEDED}
+ * (depending on whether the notification refers to the general
+ * usage threshold or the garbage collection threshold) and an instance
+ * of {@link java.lang.management.MemoryNotificationInfo} contained
+ * in the user data section. This is wrapped inside an instance
+ * of {@link javax.management.openmbean.CompositeData}, as explained
+ * in the documentation for
+ * {@link java.lang.management.MemoryNotificationInfo}.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryMXBean
+{
+
+ /**
+ * Instigates a garbage collection cycle. The virtual
+ * machine's garbage collector should make the best
+ * attempt it can at reclaiming unused memory. This
+ * is equivalent to invoking {@link java.lang.System.gc()}.
+ *
+ * @see java.lang.System#gc()
+ */
+ void gc();
+
+ /**
+ * Returns a {@link MemoryUsage} object representing the
+ * current state of the heap. This incorporates various
+ * statistics on both the initial and current memory
+ * allocations used by the heap.
+ *
+ * @return a {@link MemoryUsage} object for the heap.
+ */
+ MemoryUsage getHeapMemoryUsage();
+
+ /**
+ * Returns a {@link MemoryUsage} object representing the
+ * current state of non-heap memory. This incorporates
+ * various statistics on both the initial and current
+ * memory allocations used by non-heap memory..
+ *
+ * @return a {@link MemoryUsage} object for non-heap
+ * memory.
+ */
+ MemoryUsage getNonHeapMemoryUsage();
+
+ /**
+ * Returns the number of objects which are waiting to
+ * be garbage collected (finalized). An object is
+ * finalized when the garbage collector determines that
+ * there are no more references to that object are in
+ * use.
+ *
+ * @return the number of objects awaiting finalization.
+ */
+ int getObjectPendingFinalizationCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when memory is allocated and deallocated. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose memory output is on.
+ */
+ boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when memory is allocated and deallocated. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose memory output.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ */
+ void setVerbose(boolean verbose);
+
+}
diff --git a/libjava/classpath/java/lang/management/MemoryManagerMXBean.java b/libjava/classpath/java/lang/management/MemoryManagerMXBean.java
new file mode 100644
index 00000000000..9210705394e
--- /dev/null
+++ b/libjava/classpath/java/lang/management/MemoryManagerMXBean.java
@@ -0,0 +1,77 @@
+/* MemoryManagerMXBean.java - Interface for a memory manager bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the memory managers
+ * of the virtual machine. An instance of this bean for each
+ * memory manager is obtained by calling
+ * {@link ManagementFactory#getMemoryManagerMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryManagerMXBean
+{
+
+ /**
+ * Returns an array containing the names of the memory pools
+ * this memory manager manages.
+ *
+ * @return an array containing the name of each memory pool
+ * this manager is responsible for.
+ */
+ String[] getMemoryPoolNames();
+
+ /**
+ * Returns the name of the memory manager.
+ *
+ * @return the memory manager name.
+ */
+ String getName();
+
+ /**
+ * Returns true if this memory manager is still valid. A memory
+ * manager becomes invalid when it is removed by the virtual machine
+ * and no longer used.
+ *
+ * @return true if this memory manager is valid.
+ */
+ boolean isValid();
+
+}
diff --git a/libjava/classpath/java/lang/management/MemoryNotificationInfo.java b/libjava/classpath/java/lang/management/MemoryNotificationInfo.java
new file mode 100644
index 00000000000..adb38b06fd7
--- /dev/null
+++ b/libjava/classpath/java/lang/management/MemoryNotificationInfo.java
@@ -0,0 +1,215 @@
+/* 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 gnu.java.lang.management.MemoryMXBeanImpl;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+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);
+ ThreadInfo.checkAttribute(type, "usage", MemoryMXBeanImpl.usageType);
+ 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/libjava/classpath/java/lang/management/MemoryPoolMXBean.java b/libjava/classpath/java/lang/management/MemoryPoolMXBean.java
new file mode 100644
index 00000000000..5b04c64d3b8
--- /dev/null
+++ b/libjava/classpath/java/lang/management/MemoryPoolMXBean.java
@@ -0,0 +1,318 @@
+/* MemoryPoolMXBean.java - Interface for a memory pool bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about one of the memory
+ * resources or pools used by the virtual machine. Instances
+ * of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryPoolMXBeans()}. One
+ * bean is returned for each memory pool provided.
+ * </p>
+ * <p>
+ * The memory pool bean allows the usage of the pool to be
+ * monitored. The bean can provide statistics on the current
+ * and peak usage of the pool, and on the threshold levels the
+ * pool uses.
+ * </p>
+ * <p>
+ * {@link getUsage()} returns an approximation of the current
+ * usage of the pool. Calls to this method are expected to be
+ * generally quick to perform; if the call is expensive, the
+ * documentation of the bean should specify so. For memory
+ * pool beans that represent the memory used by garbage
+ * collectors, the usage level includes both referenced and
+ * unreferenced objects.
+ * </p>
+ * <p>
+ * {@link getPeakUsage()} and {@link resetPeakUsage()} enable
+ * the retrieval of the peak usage level and setting it to the
+ * current usage level, respectively. Initially, the peak usage
+ * level is relative to the start of the virtual machine.
+ * </p>
+ * <p>
+ * Memory pools may also include optional support for usage thresholds.
+ * The usage threshold is a particular level of memory usage. When this
+ * value is crossed (the current memory usage becomes equal to or greater
+ * than this threshold level), the usage threshold count is increased.
+ * This feature is designed for monitoring the trend in memory usage.
+ * Support for a collection usage threshold is also provided, for
+ * particular garbage collectors. This is used to monitor the amount
+ * of memory left uncollected after a garbage collection cycle. There
+ * is no need to make special garbage collection runs to support this;
+ * the level following collection just needs to be monitored.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryPoolMXBean
+{
+
+ /**
+ * Returns memory usage statistics after a best-effort attempt
+ * has been made to remove unused objects from the pool. This
+ * method is designed for use by the pools of garbage collectors,
+ * in order to monitor the amount of memory used after collections.
+ * It will return <code>null</code> if such functionality is
+ * unsupported by the memory pool represented by this bean.
+ *
+ * @return the memory usage of the memory pool after the most
+ * recent garbage collection cycle, or <code>null</code>
+ * if this operation is not supported.
+ */
+ MemoryUsage getCollectionUsage();
+
+ /**
+ * Returns the collection usage threshold level in bytes. This
+ * value is initially zero.
+ *
+ * @return the collection usage threshold in bytes.
+ * @throws UnsupportedOperationException if the collection usage
+ * threshold is not supported.
+ * @see #getCollectionUsageThresholdCount()
+ * @see #isCollectionUsageThresholdExceeded()
+ * @see #isCollectionUsageThresholdSupported()
+ * @see #setCollectionUsageThreshold(long)
+ */
+ long getCollectionUsageThreshold();
+
+ /**
+ * Returns the number of times the usage level has matched or
+ * exceeded the collection usage threshold.
+ *
+ * @return the number of times the usage level has matched
+ * or exceeded the collection usage threshold.
+ * @throws UnsupportedOperationException if the collection usage
+ * threshold is not supported.
+ * @see #getCollectionUsageThreshold()
+ * @see #isCollectionUsageThresholdExceeded()
+ * @see #isCollectionUsageThresholdSupported()
+ * @see #setCollectionUsageThreshold(long)
+ */
+ long getCollectionUsageThresholdCount();
+
+ /**
+ * Returns the names of the memory managers associated with this
+ * pool. Each pool has at least one memory manager.
+ *
+ * @return an array containing the name of each memory manager
+ * responsible for this pool.
+ */
+ String[] getMemoryManagerNames();
+
+ /**
+ * Returns the name of the memory pool.
+ *
+ * @return the memory pool name.
+ */
+ String getName();
+
+ /**
+ * Returns memory usage statistics for the peak memory usage
+ * of the pool. The peak is the maximum memory usage occurring
+ * since the virtual machine was started or since the peak
+ * was reset by {@link #resetPeakUsage()}. The return value
+ * may be <code>null</code> if this pool is no longer valid.
+ *
+ * @return the memory usage of the memory pool at its peak,
+ * or <code>null</code> if this pool is no longer valid.
+ */
+ MemoryUsage getPeakUsage();
+
+ /**
+ * Returns the type of memory used by this pool. This can be
+ * either heap or non-heap memory.
+ *
+ * @return the type of this pool.
+ */
+ String getType();
+
+ /**
+ * Returns memory usage statistics for the current memory usage
+ * of the pool. The return value may be <code>null</code> if
+ * this pool is no longer valid. Obtaining these values is
+ * expected to be a relatively quick operation; if this will
+ * instead be an expensive operation to perform, the documentation
+ * of the implementating bean should specify that this is the
+ * case. The values are intended to be an estimate for monitoring
+ * purposes.
+ *
+ * @return the memory usage of the memory pool at present,
+ * or <code>null</code> if this pool is no longer valid.
+ */
+ MemoryUsage getUsage();
+
+ /**
+ * Returns the usage threshold level in bytes. This
+ * value is initially defined by the virtual machine.
+ *
+ * @return the usage threshold in bytes.
+ * @throws UnsupportedOperationException if the usage threshold
+ * is not supported.
+ * @see #getUsageThresholdCount()
+ * @see #isUsageThresholdExceeded()
+ * @see #isUsageThresholdSupported()
+ * @see #setUsageThreshold(long)
+ */
+ long getUsageThreshold();
+
+ /**
+ * Returns the number of times the usage level has matched or
+ * exceeded the usage threshold.
+ *
+ * @return the number of times the usage level has matched
+ * or exceeded the usage threshold.
+ * @throws UnsupportedOperationException if the usage threshold
+ * is not supported.
+ * @see #getUsageThreshold()
+ * @see #isUsageThresholdExceeded()
+ * @see #isUsageThresholdSupported()
+ * @see #setUsageThreshold(long)
+ */
+ long getUsageThresholdCount();
+
+ /**
+ * Returns true if the collection usage level is equal to
+ * or greater than the collection usage threshold.
+ *
+ * @return true if the collection usage threshold has been
+ * matched or exceeded.
+ * @throws UnsupportedOperationException if the collection usage
+ * threshold is not supported.
+ * @see #getCollectionUsageThreshold()
+ * @see #getCollectionUsageThresholdCount()
+ * @see #isCollectionUsageThresholdSupported()
+ * @see #setCollectionUsageThreshold(long)
+ */
+ boolean isCollectionUsageThresholdExceeded();
+
+ /**
+ * Returns true if this memory pool supports a collection usage
+ * level threshold.
+ *
+ * @return true if a collection usage level threshold is supported.
+ * @see #getCollectionUsageThreshold()
+ * @see #getCollectionUsageThresholdCount()
+ * @see #isCollectionUsageThresholdExceeded()
+ * @see #setCollectionUsageThreshold(long)
+ */
+ boolean isCollectionUsageThresholdSupported();
+
+ /**
+ * Returns true if the usage level is equal to
+ * or greater than the usage threshold.
+ *
+ * @return true if the usage threshold has been
+ * matched or exceeded.
+ * @throws UnsupportedOperationException if the usage threshold
+ * is not supported.
+ * @see #getUsageThreshold()
+ * @see #getUsageThresholdCount()
+ * @see #isUsageThresholdSupported()
+ * @see #setUsageThreshold(long)
+ */
+ boolean isUsageThresholdExceeded();
+
+ /**
+ * Returns true if this memory pool supports a usage level threshold.
+ *
+ * @return true if a usage level threshold is supported.
+ * @see #getUsageThreshold()
+ * @see #getUsageThresholdCount()
+ * @see #isUsageThresholdExceeded()
+ * @see #setUsageThreshold(long)
+ */
+ boolean isUsageThresholdSupported();
+
+ /**
+ * Returns true if this memory pool is still valid. A memory pool
+ * becomes invalid when it is removed by the virtual machine and
+ * no longer used.
+ *
+ * @return true if this memory pool is valid.
+ */
+ boolean isValid();
+
+ /**
+ * Resets the peak memory usage level to the current memory usage
+ * level.
+ *
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ */
+ void resetPeakUsage();
+
+ /**
+ * Sets the collection threshold usage level to the given value.
+ * A value of zero disables the collection threshold.
+ *
+ * @param threshold the new threshold level.
+ * @throws IllegalArgumentException if the threshold hold level
+ * is negative.
+ * @throws UnsupportedOperationException if the collection usage
+ * threshold is not supported.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ * @see #getCollectionUsageThreshold()
+ * @see #getCollectionUsageThresholdCount()
+ * @see #isCollectionUsageThresholdExceeded()
+ * @see #isCollectionUsageThresholdSupported()
+ */
+ void setCollectionUsageThreshold(long threshold);
+
+ /**
+ * Sets the threshold usage level to the given value. A value of
+ * zero disables the threshold.
+ *
+ * @param threshold the new threshold level.
+ * @throws IllegalArgumentException if the threshold hold level
+ * is negative.
+ * @throws UnsupportedOperationException if the usage threshold
+ * is not supported.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ * @see #getUsageThreshold()
+ * @see #getUsageThresholdCount()
+ * @see #isUsageThresholdExceeded()
+ * @see #isUsageThresholdSupported()
+ */
+ void setUsageThreshold(long threshold);
+
+}
diff --git a/libjava/classpath/java/lang/management/MemoryUsage.java b/libjava/classpath/java/lang/management/MemoryUsage.java
new file mode 100644
index 00000000000..3c2a4cba6e9
--- /dev/null
+++ b/libjava/classpath/java/lang/management/MemoryUsage.java
@@ -0,0 +1,265 @@
+/* MemoryUsage.java - Information on the usage of a memory pool.
+ 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.SimpleType;
+/**
+ * <p>
+ * Retains information on the usage of a particular memory
+ * pool, or heap/non-heap memory as a whole. Memory usage
+ * is represented by four values (all in bytes):
+ * </p>
+ * <ul>
+ * <li><strong>Initial Level</strong>: This is the initial
+ * amount of memory allocated for the pool by the operating
+ * system. This value may be undefined.</li>
+ * <li><strong>Used Level</strong>: This is the amount of
+ * memory currently in use.</li>
+ * <li><strong>Committed Level</strong>: This is the current
+ * amount of memory allocated for the pool by the operating
+ * system. This value will always be equal to or greater than
+ * the current amount of memory in use. It may drop below
+ * the initial amount, if the virtual machine judges this to
+ * be practical.</li>
+ * <li><strong>Maximum Level</strong>: This is the maximum
+ * amount of memory that may be allocated for the pool by
+ * the operating system. Like the initial amount, it may
+ * be undefined. If it is defined, it will be greater than
+ * or equal to the used and committed amounts and may change
+ * over time. It is not guaranteed that the maximum amount
+ * of memory may actually be allocated to the pool. For
+ * example, a request for an amount of memory greater than
+ * the current committed level, but less than the maximum,
+ * may still fail due to resources at the operating system
+ * level not being sufficient to fulfill the demand.</li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ * @see MemoryMXBean
+ * @see MemoryPoolMXBean
+ */
+public class MemoryUsage
+{
+
+ /**
+ * The initial amount of memory allocated.
+ */
+ private long init;
+
+ /**
+ * The amount of memory used.
+ */
+ private long used;
+
+ /**
+ * The amount of memory committed for use.
+ */
+ private long committed;
+
+ /**
+ * The maximum amount of memory available.
+ */
+ private long maximum;
+
+ /**
+ * Constructs a new {@link MemoryUsage} object with
+ * the specified allocation levels.
+ *
+ * @param init the initial amount of memory allocated,
+ * or -1 if this value is undefined. Must
+ * be >= -1.
+ * @param used the amount of memory used. Must be >= 0,
+ * and <= committed.
+ * @param committed the amount of memory committed for use
+ * at present. Must be >= 0 and <=
+ * maximum (if defined).
+ * @param maximum the maximum amount of memory that may be
+ * used, or -1 if this value is undefined.
+ * Must be >= -1.
+ * @throws IllegalArgumentException if the values break any
+ * of the limits specified
+ * above.
+ */
+ public MemoryUsage(long init, long used, long committed,
+ long maximum)
+ {
+ if (init < -1)
+ throw new IllegalArgumentException("Initial value of "
+ + init + " is too small.");
+ if (used < 0)
+ throw new IllegalArgumentException("Used value of "
+ + used + " is too small.");
+ if (committed < 0)
+ throw new IllegalArgumentException("Committed value of "
+ + committed + " is too small.");
+ if (committed < used)
+ throw new IllegalArgumentException("Committed value of "
+ + committed + " is below "
+ + used + ", the amount used.");
+ if (maximum < -1)
+ throw new IllegalArgumentException("Maximum value of "
+ + maximum + " is too small.");
+ if (maximum != -1 && maximum < committed)
+ throw new IllegalArgumentException("Maximum value of "
+ + maximum + " is below "
+ + committed + ", the amount "
+ + "committed.");
+ this.init = init;
+ this.used = used;
+ this.committed = committed;
+ this.maximum = maximum;
+ }
+
+ /**
+ * <p>
+ * Returns a {@link MemoryUsage} instance using the values
+ * given in the supplied
+ * {@link javax.management.openmbean.CompositeData} object.
+ * The composite data instance should contain the following
+ * attributes:
+ * </p>
+ * <ul>
+ * <li>init</li>
+ * <li>used</li>
+ * <li>committed</li>
+ * <li>max</li>
+ * </ul>
+ * <p>
+ * All should have the type, <code>java.lang.Long</code>.
+ * </p>
+ *
+ * @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, or the values
+ * are invalid.
+ */
+ public static MemoryUsage from(CompositeData data)
+ {
+ if (data == null)
+ return null;
+ CompositeType type = data.getCompositeType();
+ ThreadInfo.checkAttribute(type, "init", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "used", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "committed", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "max", SimpleType.LONG);
+ return new MemoryUsage(((Long) data.get("init")).longValue(),
+ ((Long) data.get("used")).longValue(),
+ ((Long) data.get("committed")).longValue(),
+ ((Long) data.get("max")).longValue());
+ }
+
+ /**
+ * Returns the amount of memory committed for use by this
+ * memory pool (in bytes). This amount is guaranteed to
+ * be available, unlike the maximum.
+ *
+ * @return the committed amount of memory.
+ */
+ public long getCommitted()
+ {
+ return committed;
+ }
+
+ /**
+ * Returns the initial amount of memory allocated to the
+ * pool (in bytes). This method may return -1, if the
+ * value is undefined.
+ *
+ * @return the initial amount of memory allocated, or -1
+ * if this value is undefined.
+ */
+ public long getInit()
+ {
+ return init;
+ }
+
+ /**
+ * Returns the maximum amount of memory available for this
+ * pool (in bytes). This amount is not guaranteed to
+ * actually be usable. This method may return -1, if the
+ * value is undefined.
+ *
+ * @return the maximum amount of memory available, or -1
+ * if this value is undefined.
+ */
+ public long getMax()
+ {
+ return maximum;
+ }
+
+ /**
+ * Returns the amount of memory used (in bytes).
+ *
+ * @return the amount of used memory.
+ */
+ public long getUsed()
+ {
+ return used;
+ }
+
+ /**
+ * Returns a {@link java.lang.String} representation of
+ * this {@link MemoryUsage} object. This takes the form
+ * <code>java.lang.management.MemoryUsage[init=i, used=u,
+ * committed=c, maximum=m]</code>, where <code>i</code>
+ * is the initial level, <code>u</code> is the used level,
+ * <code>c</code> is the committed level and <code>m</code>
+ * is the maximum level.
+ *
+ * @return the string specified above.
+ */
+ public String toString()
+ {
+ int megabyte = 1024 * 1024;
+ return getClass().getName() +
+ "[init=" + init + " bytes (~" + (init / megabyte) +
+ "MB), used=" + used + " bytes (~" + (used / megabyte) +
+ "MB), committed=" + committed + " bytes (~" + (committed / megabyte) +
+ "MB), maximum=" + maximum + " bytes (~" + (maximum / megabyte) +
+ "MB)]";
+ }
+
+}
+
diff --git a/libjava/classpath/java/lang/management/OperatingSystemMXBean.java b/libjava/classpath/java/lang/management/OperatingSystemMXBean.java
new file mode 100644
index 00000000000..2430a9fbf5c
--- /dev/null
+++ b/libjava/classpath/java/lang/management/OperatingSystemMXBean.java
@@ -0,0 +1,103 @@
+/* OperatingSystemMXBean.java - Interface for an operating system bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the underlying operating
+ * system. An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getOperatingSystemMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OperatingSystemMXBean
+{
+
+ /**
+ * Returns the name of the underlying system architecture. This
+ * is equivalent to obtaining the <code>os.arch</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the name of the underlying system architecture on which
+ * the VM is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getArch();
+
+ /**
+ * Returns the number of processors currently available to the
+ * virtual machine. This number is subject to change during
+ * execution of the virtual machine, and will always be >= 1.
+ * The call is equivalent to {@link Runtime#availableProcessors()}.
+ *
+ * @return the number of processors available to the VM.
+ */
+ int getAvailableProcessors();
+
+ /**
+ * Returns the name of the underlying operating system. This
+ * is equivalent to obtaining the <code>os.name</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the name of the operating system on which the VM
+ * is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getName();
+
+ /**
+ * Returns the version of the underlying operating system. This
+ * is equivalent to obtaining the <code>os.version</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the version of the operating system on which the VM
+ * is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getVersion();
+
+}
diff --git a/libjava/classpath/java/lang/management/RuntimeMXBean.java b/libjava/classpath/java/lang/management/RuntimeMXBean.java
new file mode 100644
index 00000000000..cee1d805f89
--- /dev/null
+++ b/libjava/classpath/java/lang/management/RuntimeMXBean.java
@@ -0,0 +1,278 @@
+/* RuntimeMXBean.java - Interface for a runtime bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Provides access to information about the underlying virtual
+ * machine. An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getRuntimeMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface RuntimeMXBean
+{
+
+ /**
+ * <p>
+ * Returns the boot classpath used by the virtual machine. This
+ * value follows the standard path syntax used by the underlying
+ * operating system (e.g. directories separated by ':' on UNIX
+ * or ';' on Windows).
+ * </p>
+ * <p>
+ * Supplying this value is optional. Users should check the
+ * return value of {@link isBootClassPathSupported()} prior to
+ * calling this method.
+ * </p>
+ *
+ * @return the boot classpath of the virtual machine, if supported.
+ * @throws UnsupportedOperationException in cases where this
+ * functionality is not
+ * supported by the VM.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ * @see #isBootClassPathSupported()
+ * @see java.lang.management.ManagementPermission
+ */
+ String getBootClassPath();
+
+ /**
+ * Returns the classpath used by the system classloader. This
+ * is equivalent to obtaining the <code>java.class.path</code>
+ * property via {@link System#getProperty(String)}. This value
+ * follows the standard path syntax used by the underlying operating
+ * system (e.g. directories separated by ':' on UNIX or ';' on
+ * Windows).
+ *
+ * @return the classpath used by the system class loader.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the classpath
+ * property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getClassPath();
+
+ /**
+ * Returns a list of the arguments given to the virtual machine,
+ * excluding those that apply to the <code>main()</code> method
+ * of the class file being executed. These may not just be those
+ * specified at the command line, but may also include arguments
+ * from environment variables, configuration files, etc. All
+ * command line arguments may not reach the virtual machine, so
+ * these are not included in this list.
+ *
+ * @return a list of arguments passed to the virtual machine.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ * @see java.lang.management.ManagementPermission
+ */
+ List getInputArguments();
+
+ /**
+ * Returns the library path. This is equivalent to obtaining the
+ * <code>java.library.path</code> property via
+ * {@link System#getProperty(String)}. This value follows the
+ * standard path syntax used by the underlying operating
+ * system (e.g. directories separated by ':' on UNIX or ';' on
+ * Windows).
+ *
+ * @return the library path.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the library path
+ * property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getLibraryPath();
+
+ /**
+ * Returns the version of the management specification
+ * implemented by the virtual machine.
+ *
+ * @return the version of the management specification
+ * implemented.
+ */
+ String getManagementSpecVersion();
+
+ /**
+ * Returns the name of this virtual machine. The content
+ * of this property is left up to the developer of the
+ * virtual machine. It may include a number of system
+ * attributes and may differ between instances of the
+ * same virtual machine (for example, it might include
+ * the process identifier or the host name of the machine
+ * on which it is running). The intention is that this
+ * name refers to the precise entity that the other data
+ * supplied by this bean refers to, rather than the VM
+ * in general.
+ *
+ * @return the name of this virtual machine.
+ */
+ String getName();
+
+ /**
+ * Returns the specification name of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.specification.name</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the specification name of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM
+ * specification name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getSpecName();
+
+ /**
+ * Returns the specification vendor of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.specification.vendor</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the specification vendor of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM
+ * specification vendor property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getSpecVendor();
+
+ /**
+ * Returns the specification version of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.specification.version</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the specification version of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM
+ * specification version property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getSpecVersion();
+
+ /**
+ * Returns the approximate start time of the virtual machine
+ * in milliseconds.
+ *
+ * @return the start time of the virtual machine.
+ */
+ long getStartTime();
+
+ /**
+ * Returns a map containing the keys and values of the system
+ * properties. This gives largely the same result as calling
+ * {@link System#getProperties()}, but the resulting map
+ * is filtered so as to only provide keys and values that
+ * are <code>String</code>s.
+ *
+ * @return the map of system properties.
+ */
+ Map getSystemProperties();
+
+ /**
+ * Returns the uptime of the virtual machine in milliseconds.
+ *
+ * @return the uptime of the virtual machine.
+ */
+ long getUptime();
+
+ /**
+ * Returns the implementation name of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.name</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the implementation name of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM name
+ * property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getVmName();
+
+ /**
+ * Returns the implementation vendor of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.vendor</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the implementation vendor of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM vendor
+ * property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getVmVendor();
+
+ /**
+ * Returns the implementation version of the virtual machine.
+ * This is equivalent to obtaining the
+ * <code>java.vm.version</code> property via
+ * {@link System#getProperty(String)}.
+ *
+ * @return the implementation version of the VM.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the VM version
+ * property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getVmVersion();
+
+ /**
+ * Returns true if the virtual machine supports the boot classpath
+ * mechanism.
+ *
+ * @return true if the boot classpath property is supported by the
+ * virtual machine.
+ */
+ boolean isBootClassPathSupported();
+
+}
diff --git a/libjava/classpath/java/lang/management/ThreadInfo.java b/libjava/classpath/java/lang/management/ThreadInfo.java
new file mode 100644
index 00000000000..4bf35a4cbeb
--- /dev/null
+++ b/libjava/classpath/java/lang/management/ThreadInfo.java
@@ -0,0 +1,704 @@
+/* ThreadInfo.java - Information on a thread
+ 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.ArrayType;
+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>
+ * A class which maintains information about a particular
+ * thread. This information includes:
+ * </p>
+ * <ul>
+ * <li><strong>General Thread Information:</strong>
+ * <ul>
+ * <li>The identifier of the thread.</li>
+ * <li>The name of the thread.</li>
+ * </ul>
+ * </li>
+ * <li><strong>Execution Information:</strong>
+ * <ul>
+ * <li>The current state of the thread (e.g. blocked, runnable)</li>
+ * <li>The object upon which the thread is blocked, either because
+ * the thread is waiting to obtain the monitor of that object to enter
+ * one of its synchronized monitor, or because
+ * {@link java.lang.Object#wait()} has been called while the thread
+ * was within a method of that object.</li>
+ * <li>The thread identifier of the current thread holding an object's
+ * monitor, upon which the thread described here is blocked.</li>
+ * <li>The stack trace of the thread (if requested on creation
+ * of this object</li>
+ * </ul>
+ * <li><strong>Synchronization Statistics</strong>
+ * <ul>
+ * <li>The number of times the thread has been blocked waiting for
+ * an object's monitor or in a {@link java.lang.Object#wait()} call.</li>
+ * <li>The accumulated time the thread has been blocked waiting for
+ * an object's monitor on in a {@link java.lang.Object#wait()} call.
+ * The availability of these statistics depends on the virtual machine's
+ * support for thread contention monitoring (see
+ * {@link ThreadMXBean#isThreadContentionMonitoringSupported()}.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+ */
+public class ThreadInfo
+{
+
+ /**
+ * The id of the thread which this instance concerns.
+ */
+ private long threadId;
+
+ /**
+ * The name of the thread which this instance concerns.
+ */
+ private String threadName;
+
+ /**
+ * The state of the thread which this instance concerns.
+ */
+ private String threadState;
+
+ /**
+ * The number of times the thread has been blocked.
+ */
+ private long blockedCount;
+
+ /**
+ * The accumulated number of milliseconds the thread has
+ * been blocked (used only with thread contention monitoring
+ * support).
+ */
+ private long blockedTime;
+
+ /**
+ * The name of the monitor lock on which this thread
+ * is blocked (if any).
+ */
+ private String lockName;
+
+ /**
+ * The id of the thread which owns the monitor lock on
+ * which this thread is blocked, or <code>-1</code>
+ * if there is no owner.
+ */
+ private long lockOwnerId;
+
+ /**
+ * The name of the thread which owns the monitor lock on
+ * which this thread is blocked, or <code>null</code>
+ * if there is no owner.
+ */
+ private String lockOwnerName;
+
+ /**
+ * The number of times the thread has been in a waiting
+ * state.
+ */
+ private long waitedCount;
+
+ /**
+ * The accumulated number of milliseconds the thread has
+ * been waiting (used only with thread contention monitoring
+ * support).
+ */
+ private long waitedTime;
+
+ /**
+ * True if the thread is in a native method.
+ */
+ private boolean isInNative;
+
+ /**
+ * True if the thread is suspended.
+ */
+ private boolean isSuspended;
+
+ /**
+ * The stack trace of the thread.
+ */
+ private StackTraceElement[] trace;
+
+ /**
+ * Cache a local reference to the thread management bean.
+ */
+ private static ThreadMXBean bean = null;
+
+ /**
+ * Constructs a new {@link ThreadInfo} corresponding
+ * to the thread specified.
+ *
+ * @param thread the thread on which the new instance
+ * will be based.
+ * @param blockedCount the number of times the thread
+ * has been blocked.
+ * @param blockedTime the accumulated number of milliseconds
+ * the specified thread has been blocked
+ * (only used with contention monitoring enabled)
+ * @param lock the monitor lock the thread is waiting for
+ * (only used if blocked)
+ * @param lockOwner the thread which owns the monitor lock, or
+ * <code>null</code> if it doesn't have an owner
+ * (only used if blocked)
+ * @param waitedCount the number of times the thread has been in a
+ * waiting state.
+ * @param waitedTime the accumulated number of milliseconds the
+ * specified thread has been waiting
+ * (only used with contention monitoring enabled)
+ * @param isInNative true if the thread is in a native method.
+ * @param isSuspended true if the thread is suspended.
+ * @param trace the stack trace of the thread to a pre-determined
+ * depth (see VMThreadMXBeanImpl)
+ */
+ private ThreadInfo(Thread thread, long blockedCount, long blockedTime,
+ Object lock, Thread lockOwner, long waitedCount,
+ long waitedTime, boolean isInNative, boolean isSuspended,
+ StackTraceElement[] trace)
+ {
+ this(thread.getId(), thread.getName(), thread.getState(), blockedCount,
+ blockedTime, lock.getClass().getName() + "@" +
+ Integer.toHexString(System.identityHashCode(lock)), lockOwner.getId(),
+ lockOwner.getName(), waitedCount, waitedTime, isInNative, isSuspended,
+ trace);
+ }
+
+ /**
+ * Constructs a new {@link ThreadInfo} corresponding
+ * to the thread details specified.
+ *
+ * @param threadId the id of the thread on which this
+ * new instance will be based.
+ * @param threadName the name of the thread on which
+ * this new instance will be based.
+ * @param threadState the state of the thread on which
+ * this new instance will be based.
+ * @param blockedCount the number of times the thread
+ * has been blocked.
+ * @param blockedTime the accumulated number of milliseconds
+ * the specified thread has been blocked
+ * (only used with contention monitoring enabled)
+ * @param lockName the name of the monitor lock the thread is waiting for
+ * (only used if blocked)
+ * @param lockOwnerId the id of the thread which owns the monitor
+ * lock, or <code>-1</code> if it doesn't have an owner
+ * (only used if blocked)
+ * @param lockOwnerName the name of the thread which owns the monitor
+ * lock, or <code>null</code> if it doesn't have an
+ * owner (only used if blocked)
+ * @param waitedCount the number of times the thread has been in a
+ * waiting state.
+ * @param waitedTime the accumulated number of milliseconds the
+ * specified thread has been waiting
+ * (only used with contention monitoring enabled)
+ * @param isInNative true if the thread is in a native method.
+ * @param isSuspended true if the thread is suspended.
+ * @param trace the stack trace of the thread to a pre-determined
+ * depth (see VMThreadMXBeanImpl)
+ */
+ private ThreadInfo(long threadId, String threadName, String threadState,
+ long blockedCount, long blockedTime, String lockName,
+ long lockOwnerId, String lockOwnerName, long waitedCount,
+ long waitedTime, boolean isInNative, boolean isSuspended,
+ StackTraceElement[] trace)
+ {
+ this.threadId = threadId;
+ this.threadName = threadName;
+ this.threadState = threadState;
+ this.blockedCount = blockedCount;
+ this.blockedTime = blockedTime;
+ this.lockName = lockName;
+ this.lockOwnerId = lockOwnerId;
+ this.lockOwnerName = lockOwnerName;
+ this.waitedCount = waitedCount;
+ this.waitedTime = waitedTime;
+ this.isInNative = isInNative;
+ this.isSuspended = isSuspended;
+ this.trace = trace;
+ }
+
+ /**
+ * Checks for an attribute in a {@link CompositeData} structure
+ * with the correct type.
+ *
+ * @param ctype the composite data type to check.
+ * @param name the name of the attribute.
+ * @param type the type to check for.
+ * @throws IllegalArgumentException if the attribute is absent
+ * or of the wrong type.
+ */
+ static void checkAttribute(CompositeType ctype, String name,
+ OpenType type)
+ throws IllegalArgumentException
+ {
+ OpenType foundType = ctype.getType(name);
+ if (foundType == null)
+ throw new IllegalArgumentException("Could not find a field named " +
+ name);
+ if (!(foundType.equals(type)))
+ throw new IllegalArgumentException("Field " + name + " is not of " +
+ "type " + type.getClassName());
+ }
+
+ /**
+ * <p>
+ * Returns a {@link ThreadInfo} 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>threadId</td><td>java.lang.Long</td></tr>
+ * <tr><td>threadName</td><td>java.lang.String</td></tr>
+ * <tr><td>threadState</td><td>java.lang.String</td></tr>
+ * <tr><td>suspended</td><td>java.lang.Boolean</td></tr>
+ * <tr><td>inNative</td><td>java.lang.Boolean</td></tr>
+ * <tr><td>blockedCount</td><td>java.lang.Long</td></tr>
+ * <tr><td>blockedTime</td><td>java.lang.Long</td></tr>
+ * <tr><td>waitedCount</td><td>java.lang.Long</td></tr>
+ * <tr><td>waitedTime</td><td>java.lang.Long</td></tr>
+ * <tr><td>lockName</td><td>java.lang.String</td></tr>
+ * <tr><td>lockOwnerId</td><td>java.lang.Long</td></tr>
+ * <tr><td>lockOwnerName</td><td>java.lang.String</td></tr>
+ * <tr><td>stackTrace</td><td>javax.management.openmbean.CompositeData[]
+ * </td></tr>
+ * </table>
+ * <p>
+ * The stack trace is further described as:
+ * </p>
+ * <table>
+ * <th><td>Name</td><td>Type</td></th>
+ * <tr><td>className</td><td>java.lang.String</td></tr>
+ * <tr><td>methodName</td><td>java.lang.String</td></tr>
+ * <tr><td>fileName</td><td>java.lang.String</td></tr>
+ * <tr><td>lineNumber</td><td>java.lang.Integer</td></tr>
+ * <tr><td>nativeMethod</td><td>java.lang.Boolean</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 ThreadInfo from(CompositeData data)
+ {
+ if (data == null)
+ return null;
+ CompositeType type = data.getCompositeType();
+ checkAttribute(type, "threadId", SimpleType.LONG);
+ checkAttribute(type, "threadName", SimpleType.STRING);
+ checkAttribute(type, "threadState", SimpleType.STRING);
+ checkAttribute(type, "suspended", SimpleType.BOOLEAN);
+ checkAttribute(type, "inNative", SimpleType.BOOLEAN);
+ checkAttribute(type, "blockedCount", SimpleType.LONG);
+ checkAttribute(type, "blockedTime", SimpleType.LONG);
+ checkAttribute(type, "waitedCount", SimpleType.LONG);
+ checkAttribute(type, "waitedTime", SimpleType.LONG);
+ checkAttribute(type, "lockName", SimpleType.STRING);
+ checkAttribute(type, "lockOwnerId", SimpleType.LONG);
+ checkAttribute(type, "lockOwnerName", SimpleType.STRING);
+ try
+ {
+ CompositeType seType =
+ new CompositeType(StackTraceElement.class.getName(),
+ "An element of a stack trace",
+ new String[] { "className", "methodName",
+ "fileName", "lineNumber",
+ "nativeMethod"
+ },
+ new String[] { "Name of the class",
+ "Name of the method",
+ "Name of the source code file",
+ "Line number",
+ "True if this is a native method"
+ },
+ new OpenType[] {
+ SimpleType.STRING, SimpleType.STRING,
+ SimpleType.STRING, SimpleType.INTEGER,
+ SimpleType.BOOLEAN
+ });
+ checkAttribute(type, "stackTrace", new ArrayType(1, seType));
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalStateException("Something went wrong in creating " +
+ "the composite data type for the " +
+ "stack trace element.", e);
+ }
+ CompositeData[] dTraces = (CompositeData[]) data.get("stackTrace");
+ StackTraceElement[] traces = new StackTraceElement[dTraces.length];
+ for (int a = 0; a < dTraces.length; ++a)
+ /* FIXME: We can't use the boolean as there is no available
+ constructor. */
+ traces[a] =
+ new StackTraceElement((String) dTraces[a].get("className"),
+ (String) dTraces[a].get("methodName"),
+ (String) dTraces[a].get("fileName"),
+ ((Integer)
+ dTraces[a].get("lineNumber")).intValue());
+ return new ThreadInfo(((Long) data.get("threadId")).longValue(),
+ (String) data.get("threadName"),
+ (String) data.get("threadState"),
+ ((Long) data.get("blockedCount")).longValue(),
+ ((Long) data.get("blockedTime")).longValue(),
+ (String) data.get("lockName"),
+ ((Long) data.get("lockOwnerId")).longValue(),
+ (String) data.get("lockOwnerName"),
+ ((Long) data.get("waitedCount")).longValue(),
+ ((Long) data.get("waitedTime")).longValue(),
+ ((Boolean) data.get("inNative")).booleanValue(),
+ ((Boolean) data.get("suspended")).booleanValue(),
+ traces);
+ }
+
+ /**
+ * Returns the number of times this thread has been
+ * in the {@link java.lang.Thread.State#BLOCKED} state.
+ * A thread enters this state when it is waiting to
+ * obtain an object's monitor. This may occur either
+ * on entering a synchronized method for the first time,
+ * or on re-entering it following a call to
+ * {@link java.lang.Object#wait()}.
+ *
+ * @return the number of times this thread has been blocked.
+ */
+ public long getBlockedCount()
+ {
+ return blockedCount;
+ }
+
+ /**
+ * <p>
+ * Returns the accumulated number of milliseconds this
+ * thread has been in the
+ * {@link java.lang.Thread.State#BLOCKED} state
+ * since thread contention monitoring was last enabled.
+ * A thread enters this state when it is waiting to
+ * obtain an object's monitor. This may occur either
+ * on entering a synchronized method for the first time,
+ * or on re-entering it following a call to
+ * {@link java.lang.Object#wait()}.
+ * </p>
+ * <p>
+ * Use of this method requires virtual machine support
+ * for thread contention monitoring and for this support
+ * to be enabled.
+ * </p>
+ *
+ * @return the accumulated time (in milliseconds) that this
+ * thread has spent in the blocked state, since
+ * thread contention monitoring was enabled, or -1
+ * if thread contention monitoring is disabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support contention
+ * monitoring.
+ * @see ThreadMXBean#isThreadContentionMonitoringEnabled()
+ * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+ */
+ public long getBlockedTime()
+ {
+ if (bean == null)
+ bean = ManagementFactory.getThreadMXBean();
+ // Will throw UnsupportedOperationException for us
+ if (bean.isThreadContentionMonitoringEnabled())
+ return blockedTime;
+ else
+ return -1;
+ }
+
+ /**
+ * <p>
+ * Returns a {@link java.lang.String} representation of
+ * the monitor lock on which this thread is blocked. If
+ * the thread is not blocked, this method returns
+ * <code>null</code>.
+ * </p>
+ * <p>
+ * The returned {@link java.lang.String} is constructed
+ * using the class name and identity hashcode (usually
+ * the memory address of the object) of the lock. The
+ * two are separated by the '@' character, and the identity
+ * hashcode is represented in hexadecimal. Thus, for a
+ * lock, <code>l</code>, the returned value is
+ * the result of concatenating
+ * <code>l.getClass().getName()</code>, <code>"@"</code>
+ * and
+ * <code>Integer.toHexString(System.identityHashCode(l))</code>.
+ * The value is only unique to the extent that the identity
+ * hash code is also unique.
+ * </p>
+ *
+ * @return a string representing the lock on which this
+ * thread is blocked, or <code>null</code> if
+ * the thread is not blocked.
+ */
+ public String getLockName()
+ {
+ if (threadState.equals("BLOCKED"))
+ return null;
+ return lockName;
+ }
+
+ /**
+ * Returns the identifier of the thread which owns the
+ * monitor lock this thread is waiting for. -1 is returned
+ * if either this thread is not blocked, or the lock is
+ * not held by any other thread.
+ *
+ * @return the thread identifier of thread holding the lock
+ * this thread is waiting for, or -1 if the thread
+ * is not blocked or the lock is not held by another
+ * thread.
+ */
+ public long getLockOwnerId()
+ {
+ if (threadState.equals("BLOCKED"))
+ return -1;
+ return lockOwnerId;
+ }
+
+ /**
+ * Returns the name of the thread which owns the
+ * monitor lock this thread is waiting for. <code>null</code>
+ * is returned if either this thread is not blocked,
+ * or the lock is not held by any other thread.
+ *
+ * @return the thread identifier of thread holding the lock
+ * this thread is waiting for, or <code>null</code>
+ * if the thread is not blocked or the lock is not
+ * held by another thread.
+ */
+ public String getLockOwnerName()
+ {
+ if (threadState.equals("BLOCKED"))
+ return null;
+ return lockOwnerName;
+ }
+
+ /**
+ * <p>
+ * Returns the stack trace of this thread to the depth
+ * specified on creation of this {@link ThreadInfo}
+ * object. If the depth is zero, an empty array will
+ * be returned. For non-zero arrays, the elements
+ * start with the most recent trace at position zero.
+ * The bottom of the stack represents the oldest method
+ * invocation which meets the depth requirements.
+ * </p>
+ * <p>
+ * Some virtual machines may not be able to return
+ * stack trace information for a thread. In these
+ * cases, an empty array will also be returned.
+ * </p>
+ *
+ * @return an array of {@link java.lang.StackTraceElement}s
+ * representing the trace of this thread.
+ */
+ public StackTraceElement[] getStackTrace()
+ {
+ return trace;
+ }
+
+ /**
+ * Returns the identifier of the thread associated with
+ * this instance of {@link ThreadInfo}.
+ *
+ * @return the thread's identifier.
+ */
+ public long getThreadId()
+ {
+ return threadId;
+ }
+
+ /**
+ * Returns the name of the thread associated with
+ * this instance of {@link ThreadInfo}.
+ *
+ * @return the thread's name.
+ */
+ public String getThreadName()
+ {
+ return threadName;
+ }
+
+ /**
+ * Returns the state of the thread associated with
+ * this instance of {@link ThreadInfo}.
+ *
+ * @return the thread's state.
+ */
+ public String getThreadState()
+ {
+ return threadState;
+ }
+
+ /**
+ * Returns the number of times this thread has been
+ * in the {@link java.lang.Thread.State#WAITING}
+ * or {@link java.lang.Thread.State#TIMED_WAITING} state.
+ * A thread enters one of these states when it is waiting
+ * due to a call to {@link java.lang.Object.wait()},
+ * {@link java.lang.Object.join()} or
+ * {@link java.lang.concurrent.locks.LockSupport.park()},
+ * either with an infinite or timed delay, respectively.
+ *
+ * @return the number of times this thread has been waiting.
+ */
+ public long getWaitedCount()
+ {
+ return waitedCount;
+ }
+
+ /**
+ * <p>
+ * Returns the accumulated number of milliseconds this
+ * thread has been in the
+ * {@link java.lang.Thread.State#WAITING} or
+ * {@link java.lang.Thread.State#TIMED_WAITING} state,
+ * since thread contention monitoring was last enabled.
+ * A thread enters one of these states when it is waiting
+ * due to a call to {@link java.lang.Object.wait()},
+ * {@link java.lang.Object.join()} or
+ * {@link java.lang.concurrent.locks.LockSupport.park()},
+ * either with an infinite or timed delay, respectively.
+ * </p>
+ * <p>
+ * Use of this method requires virtual machine support
+ * for thread contention monitoring and for this support
+ * to be enabled.
+ * </p>
+ *
+ * @return the accumulated time (in milliseconds) that this
+ * thread has spent in one of the waiting states, since
+ * thread contention monitoring was enabled, or -1
+ * if thread contention monitoring is disabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support contention
+ * monitoring.
+ * @see ThreadMXBean#isThreadContentionMonitoringEnabled()
+ * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+ */
+ public long getWaitedTime()
+ {
+ if (bean == null)
+ bean = ManagementFactory.getThreadMXBean();
+ // Will throw UnsupportedOperationException for us
+ if (bean.isThreadContentionMonitoringEnabled())
+ return waitedTime;
+ else
+ return -1;
+ }
+
+ /**
+ * Returns true if the thread is in a native method. This
+ * excludes native code which forms part of the virtual
+ * machine itself, or which results from Just-In-Time
+ * compilation.
+ *
+ * @return true if the thread is in a native method, false
+ * otherwise.
+ */
+ public boolean isInNative()
+ {
+ return isInNative;
+ }
+
+ /**
+ * Returns true if the thread has been suspended using
+ * {@link java.lang.Thread#suspend()}.
+ *
+ * @return true if the thread is suspended, false otherwise.
+ */
+ public boolean isSuspended()
+ {
+ return isSuspended;
+ }
+
+ /**
+ * Returns a {@link java.lang.String} representation of
+ * this {@link ThreadInfo} object. This takes the form
+ * <code>java.lang.management.ThreadInfo[id=tid, name=n,
+ * state=s, blockedCount=bc, waitedCount=wc, isInNative=iin,
+ * isSuspended=is]</code>, where <code>tid</code> is
+ * the thread identifier, <code>n</code> is the
+ * thread name, <code>s</code> is the thread state,
+ * <code>bc</code> is the blocked state count,
+ * <code>wc</code> is the waiting state count and
+ * <code>iin</code> and <code>is</code> are boolean
+ * flags to indicate the thread is in native code or
+ * suspended respectively. If the thread is blocked,
+ * <code>lock=l, lockOwner=lo</code> is also included,
+ * where <code>l</code> is the lock waited for, and
+ * <code>lo</code> is the thread which owns the lock
+ * (or null if there is no owner).
+ *
+ * @return the string specified above.
+ */
+ public String toString()
+ {
+ return getClass().getName() +
+ "[id=" + threadId +
+ ", name=" + threadName +
+ ", state=" + threadState +
+ ", blockedCount=" + blockedCount +
+ ", waitedCount=" + waitedCount +
+ ", isInNative=" + isInNative +
+ ", isSuspended=" + isSuspended +
+ (threadState.equals("BLOCKED") ?
+ ", lockOwnerId=" + lockOwnerId +
+ ", lockOwnerName=" + lockOwnerName : "") +
+ "]";
+ }
+
+}
diff --git a/libjava/classpath/java/lang/management/ThreadMXBean.java b/libjava/classpath/java/lang/management/ThreadMXBean.java
new file mode 100644
index 00000000000..669cb3cd8d2
--- /dev/null
+++ b/libjava/classpath/java/lang/management/ThreadMXBean.java
@@ -0,0 +1,497 @@
+/* ThreadMXBean.java - Interface for a thread bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about the threads
+ * of the virtual machine. An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * </p>
+ * <p>
+ * Each thread within the virtual machine is given an
+ * identifier, which is guaranteed to be unique to a
+ * particular thread over its lifetime (after which it
+ * may be reused). The identifier for a thread may be
+ * obtained by calling {@link java.lang.Thread#getId()}.
+ * This identifier is used within implementations of this
+ * interface to obtain information about a particular thread
+ * (or series of threads, in the case of an array of identifiers).
+ * </p>
+ * <p>
+ * This bean supports some optional behaviour, which all
+ * virtual machines may not choose to implement. Specifically,
+ * this includes the monitoring of the CPU time used by a
+ * thread, and the monitoring of thread contention. The former
+ * is further subdivided into the monitoring of either just
+ * the current thread or all threads. The methods
+ * {@link #isThreadCpuTimeSupported()},
+ * {@link #isCurrentThreadCpuTimeSupported()} and
+ * {@link #isThreadContentionMonitoringSupported()} may be
+ * used to determine whether or not this functionality is
+ * supported.
+ * </p>
+ * <p>
+ * Furthermore, both these facilities may be disabled.
+ * In fact, thread contention monitoring is disabled by
+ * default, and must be explictly turned on by calling
+ * the {@link #setThreadContentionMonitoringEnabled(boolean)}
+ * method.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface ThreadMXBean
+{
+
+ /**
+ * <p>
+ * This method obtains a list of threads which are deadlocked
+ * waiting to obtain monitor ownership. On entering a synchronized
+ * method of an object, or re-entering it after returning from an
+ * {@link java.lang.Object#wait()} call, a thread obtains ownership
+ * of the object's monitor.
+ * </p>
+ * <p>
+ * Deadlocks can occur in this situation if one or more threads end up
+ * waiting for a monitor, P, while also retaining ownership of a monitor,
+ * Q, required by the thread that currently owns P. To give a simple
+ * example, imagine thread A calls a synchronized method, R, obtaining the
+ * monitor, P. It then sleeps within that method, allowing thread B
+ * to run, but still retaining ownership of P. B calls another
+ * synchronized method, S, which causes it to obtain the monitor, Q,
+ * of a different object. While in that method, it then wants to
+ * call the original synchronized method, R, called by A. Doing so
+ * requires ownership of P, which is still held by A. Hence, it
+ * becomes blocked.
+ * </p>
+ * <p>
+ * A then finishes its sleep, becomes runnable, and is then allowed
+ * to run, being the only eligible thread in this scenario. A tries
+ * to call the synchronized method, S. It also gets blocked, because
+ * B still holds the monitor, Q. Hence, the two threads, A and B,
+ * are deadlocked, as neither can give up its monitor without first
+ * obtaining the monitor held by the other thread.
+ * </p>
+ * <p>
+ * Calling this method in this scenario would return the thread IDs
+ * of A and B. Note that this method is not designed for controlling
+ * synchronization, but for troubleshooting problems which cause such
+ * deadlocks; it may be prohibitively expensive to use in normal
+ * operation.
+ * </p>
+ *
+ * @return an array of thread identifiers, corresponding to threads
+ * which are currently in a deadlocked situation.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ long[] findMonitorDeadlockedThreads();
+
+ /**
+ * Returns all live thread identifiers at the time of initial
+ * execution. Some thread identifiers in the returned array
+ * may refer to terminated threads, if this occurs during the
+ * lifetime of this method.
+ *
+ * @return an array of thread identifiers, corresponding to
+ * current live threads.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ long[] getAllThreadIds();
+
+ /**
+ * <p>
+ * Returns the total number of nanoseconds of CPU time
+ * the current thread has used. This is equivalent to calling
+ * <code>{@link #getThreadCpuTime()}(Thread.currentThread.getId())</code>.
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63. The use of this method depends on virtual machine
+ * support for measurement of the CPU time of the current thread,
+ * and on this functionality being enabled.
+ * </p>
+ *
+ * @return the total number of nanoseconds of CPU time the current
+ * thread has used, or -1 if CPU time monitoring is disabled.
+ * @throws UnsupportedOperationException if CPU time monitoring is not
+ * supported.
+ * @see #getCurrentThreadUserTime()
+ * @see #isCurrentThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ long getCurrentThreadCpuTime();
+
+ /**
+ * <p>
+ * Returns the total number of nanoseconds of CPU time
+ * the current thread has executed in user mode. This is
+ * equivalent to calling
+ * <code>{@link #getThreadUserTime()}(Thread.currentThread.getId())</code>.
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63. The use of this method depends on virtual machine
+ * support for measurement of the CPU time of the current thread,
+ * and on this functionality being enabled.
+ * </p>
+ *
+ * @return the total number of nanoseconds of CPU time the current
+ * thread has executed in user mode, or -1 if CPU time
+ * monitoring is disabled.
+ * @throws UnsupportedOperationException if CPU time monitoring is not
+ * supported.
+ * @see #getCurrentThreadCpuTime()
+ * @see #isCurrentThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ long getCurrentThreadUserTime();
+
+ /**
+ * Returns the number of live daemon threads.
+ *
+ * @return the number of live daemon threads.
+ */
+ int getDaemonThreadCount();
+
+ /**
+ * Returns the peak number of live threads since
+ * the virtual machine was started or the count
+ * reset using {@link #resetPeakThreadCount()}.
+ *
+ * @return the peak live thread count.
+ * @see #resetPeakThreadCount()
+ */
+ int getPeakThreadCount();
+
+ /**
+ * Returns the number of live threads, including
+ * both daemon threads and non-daemon threads.
+ *
+ * @return the current number of live threads.
+ */
+ int getThreadCount();
+
+ /**
+ * <p>
+ * Returns the total number of nanoseconds of CPU time
+ * the specified thread has used.
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63. The use of this method depends on virtual machine
+ * support for measurement of the CPU time of the current thread,
+ * and on this functionality being enabled.
+ * </p>
+ *
+ * @param id the thread identifier of the thread whose CPU time is being
+ * monitored.
+ * @return the total number of nanoseconds of CPU time the specified
+ * thread has used, or -1 if CPU time monitoring is disabled.
+ * @throws IllegalArgumentException if <code>id</code> <= 0.
+ * @throws UnsupportedOperationException if CPU time monitoring is not
+ * supported.
+ * @see #getThreadUserTime(long)
+ * @see #isThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ long getThreadCpuTime(long id);
+
+ /**
+ * Returns information on the specified thread without any
+ * stack trace information. This is equivalent to
+ * <code>{@link #getThreadInfo}(id, 0)</code>. If the
+ * identifier specifies a thread which is either non-existant
+ * or not alive, then the method returns <code>null</code>.
+ *
+ * @param id the identifier of the thread to return information
+ * on.
+ * @return a {@link ThreadInfo} object pertaining to the specified
+ * thread, or <code>null</code> if the identifier specifies
+ * a thread that doesn't exist or is not alive.
+ * @throws IllegalArgumentException if <code>id</code> <= 0.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ ThreadInfo getThreadInfo(long id);
+
+ /**
+ * Returns information on the specified threads without any
+ * stack trace information. This is equivalent to
+ * <code>{@link #getThreadInfo}(ids, 0)</code>. If an
+ * identifier specifies a thread which is either non-existant
+ * or not alive, then the corresponding element in the returned
+ * array is <code>null</code>.
+ *
+ * @param ids an array of thread identifiers to return information
+ * on.
+ * @return an array of {@link ThreadInfo} objects matching the
+ * specified threads. The corresponding element is
+ * <code>null</code> if the identifier specifies
+ * a thread that doesn't exist or is not alive.
+ * @throws IllegalArgumentException if an identifier in the array is
+ * <= 0.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ ThreadInfo[] getThreadInfo(long[] ids);
+
+ /**
+ * Returns information on the specified thread with
+ * stack trace information to the supplied depth. If the
+ * identifier specifies a thread which is either non-existant
+ * or not alive, then the method returns <code>null</code>.
+ * A maximum depth of 0 corresponds to an empty stack trace
+ * (an empty array is returned by the appropriate
+ * {@link ThreadInfo} method). A maximum depth of
+ * <code>Integer.MAX_VALUE</code> returns the full stack trace.
+ *
+ * @param id the identifier of the thread to return information
+ * on.
+ * @param maxDepth the maximum depth of the stack trace.
+ * Values of 0 or <code>Integer.MAX_VALUE</code>
+ * correspond to an empty and full stack trace
+ * respectively.
+ * @return a {@link ThreadInfo} object pertaining to the specified
+ * thread, or <code>null</code> if the identifier specifies
+ * a thread that doesn't exist or is not alive.
+ * @throws IllegalArgumentException if <code>id</code> <= 0.
+ * @throws IllegalArgumentException if <code>maxDepth</code> < 0.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ ThreadInfo getThreadInfo(long id, int maxDepth);
+
+ /**
+ * Returns information on the specified threads with
+ * stack trace information to the supplied depth. If an
+ * identifier specifies a thread which is either non-existant
+ * or not alive, then the corresponding element in the returned
+ * array is <code>null</code>. A maximum depth of 0 corresponds
+ * to an empty stack trace (an empty array is returned by the
+ * appropriate {@link ThreadInfo} method). A maximum depth of
+ * <code>Integer.MAX_VALUE</code> returns the full stack trace.
+ *
+ * @param ids an array of thread identifiers to return information
+ * on.
+ * @param maxDepth the maximum depth of the stack trace.
+ * Values of 0 or <code>Integer.MAX_VALUE</code>
+ * correspond to an empty and full stack trace
+ * respectively.
+ * @return an array of {@link ThreadInfo} objects matching the
+ * specified threads. The corresponding element is
+ * <code>null</code> if the identifier specifies
+ * a thread that doesn't exist or is not alive.
+ * @throws IllegalArgumentException if an identifier in the array is
+ * <= 0.
+ * @throws IllegalArgumentException if <code>maxDepth</code> < 0.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("monitor").
+ */
+ ThreadInfo[] getThreadInfo(long[] ids, int maxDepth);
+
+ /**
+ * <p>
+ * Returns the total number of nanoseconds of CPU time
+ * the specified thread has executed in user mode.
+ * </p>
+ * <p>
+ * Note that the value is only nanosecond-precise, and not accurate; there
+ * is no guarantee that the difference between two values is really a
+ * nanosecond. Also, the value is prone to overflow if the offset
+ * exceeds 2^63. The use of this method depends on virtual machine
+ * support for measurement of the CPU time of the current thread,
+ * and on this functionality being enabled.
+ * </p>
+ *
+ * @param id the thread identifier of the thread whose CPU time is being
+ * monitored.
+ * @return the total number of nanoseconds of CPU time the specified
+ * thread has executed in user mode, or -1 if CPU time monitoring
+ * is disabled.
+ * @throws IllegalArgumentException if <code>id</code> <= 0.
+ * @throws UnsupportedOperationException if CPU time monitoring is not
+ * supported.
+ * @see #getThreadCpuTime(long)
+ * @see #isThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ long getThreadUserTime(long id);
+
+ /**
+ * Returns the total number of threads that have been
+ * created and started during the lifetime of the virtual
+ * machine.
+ *
+ * @return the total number of started threads.
+ */
+ long getTotalStartedThreadCount();
+
+ /**
+ * Returns true if the virtual machine supports the monitoring
+ * of the CPU time used by the current thread. This is implied
+ * by {@link isThreadCpuTimeSupported()} returning true.
+ *
+ * @return true if monitoring of the CPU time used by the current
+ * thread is supported by the virtual machine.
+ * @see #isThreadCpuTimeEnabled()
+ * @see #isThreadCpuTimeSupported()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ boolean isCurrentThreadCpuTimeSupported();
+
+ /**
+ * Returns true if thread contention monitoring is currently
+ * enabled.
+ *
+ * @return true if thread contention monitoring is enabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support contention
+ * monitoring.
+ * @see #isThreadContentionMonitoringSupported()
+ * @see #setThreadContentionMonitoringEnabled(boolean)
+ */
+ boolean isThreadContentionMonitoringEnabled();
+
+ /**
+ * Returns true if thread contention monitoring is supported
+ * by the virtual machine.
+ *
+ * @return true if thread contention monitoring is supported
+ * by the virtual machine.
+ * @see #isThreadContentionMonitoringEnabled()
+ * @see #setThreadContentionMonitoringEnabled(boolean)
+ */
+ boolean isThreadContentionMonitoringSupported();
+
+ /**
+ * Returns true if monitoring of the CPU time used by a thread
+ * is currently enabled.
+ *
+ * @return true if thread CPU time monitoring is enabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support CPU time
+ * monitoring.
+ * @see #isCurrentThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeSupported()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ boolean isThreadCpuTimeEnabled();
+
+ /**
+ * Returns true if the virtual machine supports the monitoring
+ * of the CPU time used by all threads. This implies
+ * that {@link isCurrentThreadCpuTimeSupported()} returns true.
+ *
+ * @return true if monitoring of the CPU time used by the current
+ * thread is supported by the virtual machine.
+ * @see #isCurrentThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #setThreadCpuTimeEnabled(boolean)
+ */
+ boolean isThreadCpuTimeSupported();
+
+ /**
+ * Resets the peak live thread count to the
+ * current number of live threads, as returned
+ * by {@link #getThreadCount()}.
+ *
+ * @see #getPeakThreadCount()
+ * @see #getThreadCount()
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ */
+ void resetPeakThreadCount();
+
+ /**
+ * Toggles the monitoring of thread contention. Thread
+ * contention monitoring is disabled by default. Each
+ * time contention monitoring is re-enabled, the times
+ * it maintains are reset.
+ *
+ * @param enable true if monitoring should be enabled,
+ * false if it should be disabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support contention
+ * monitoring.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ * @see #isThreadContentionMonitoringEnabled()
+ * @see #isThreadContentionMonitoringSupported()
+ */
+ void setThreadContentionMonitoringEnabled(boolean enable);
+
+ /**
+ * Toggles the monitoring of CPU time used by threads. The
+ * initial setting is dependent on the underlying virtual
+ * machine. On enabling CPU time monitoring, the virtual
+ * machine may take any value up to and including the current
+ * time as the start time for monitoring.
+ *
+ * @param enable true if monitoring should be enabled,
+ * false if it should be disabled.
+ * @throws UnsupportedOperationException if the virtual
+ * machine does not
+ * support CPU time
+ * monitoring.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ * @see #isCurrentThreadCpuTimeSupported()
+ * @see #isThreadCpuTimeEnabled()
+ * @see #isThreadCpuTimeSupported()
+ */
+ void setThreadCpuTimeEnabled(boolean enable);
+
+}
diff --git a/libjava/classpath/java/lang/management/package.html b/libjava/classpath/java/lang/management/package.html
new file mode 100644
index 00000000000..1b37cc1a529
--- /dev/null
+++ b/libjava/classpath/java/lang/management/package.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.lang.management package.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.lang.management</title></head>
+
+<body>
+
+<p>
+A series of management beans which provide access to information about the
+virtual machine and its underlying operating system.
+</p>
+<p>The following beans are provided:</p>
+<ul>
+<li>
+<span style="font-weight: bold;">{@link java.lang.management.OperatingSystemMXBean} </span>
+&mdash; Information about the underlying operating system.
+</li>
+</ul>
+<h2>Accessing the Beans</h2>
+<p>
+An instance of a bean can be obtained by using one of the following methods:
+</p>
+<ol>
+<li>Calling the appropriate static method of the {@link java.lang.management.ManagementFactory}
+</li>
+</ol>
+</body>
+</html>
diff --git a/libjava/classpath/java/math/BigDecimal.java b/libjava/classpath/java/math/BigDecimal.java
index 94b373b04be..bca9b12c28b 100644
--- a/libjava/classpath/java/math/BigDecimal.java
+++ b/libjava/classpath/java/math/BigDecimal.java
@@ -1,5 +1,5 @@
/* java.math.BigDecimal -- Arbitrary precision decimals.
- Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ public class BigDecimal extends Number implements Comparable
{
private BigInteger intVal;
private int scale;
+ private int precision = 0;
private static final long serialVersionUID = 6108874887143696463L;
/**
@@ -48,21 +49,21 @@ public class BigDecimal extends Number implements Comparable
* @since 1.5
*/
public static final BigDecimal ZERO =
- new BigDecimal (BigInteger.valueOf (0), 0);
+ new BigDecimal (BigInteger.ZERO, 0);
/**
* The constant one as a BigDecimal with scale zero.
* @since 1.5
*/
public static final BigDecimal ONE =
- new BigDecimal (BigInteger.valueOf (1), 0);
+ new BigDecimal (BigInteger.ONE, 0);
/**
* The constant ten as a BigDecimal with scale zero.
* @since 1.5
*/
public static final BigDecimal TEN =
- new BigDecimal (BigInteger.valueOf (10), 0);
+ new BigDecimal (BigInteger.TEN, 0);
public static final int ROUND_UP = 0;
public static final int ROUND_DOWN = 1;
@@ -73,19 +74,181 @@ public class BigDecimal extends Number implements Comparable
public static final int ROUND_HALF_EVEN = 6;
public static final int ROUND_UNNECESSARY = 7;
+ /**
+ * Constructs a new BigDecimal whose unscaled value is val and whose
+ * scale is zero.
+ * @param val the value of the new BigDecimal
+ * @since 1.5
+ */
+ public BigDecimal (int val)
+ {
+ this.intVal = BigInteger.valueOf(val);
+ this.scale = 0;
+ }
+
+ /**
+ * Constructs a BigDecimal using the BigDecimal(int) constructor and then
+ * rounds according to the MathContext.
+ * @param val the value for the initial (unrounded) BigDecimal
+ * @param mc the MathContext specifying the rounding
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal (int val, MathContext mc)
+ {
+ this (val);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+
+ /**
+ * Constructs a new BigDecimal whose unscaled value is val and whose
+ * scale is zero.
+ * @param val the value of the new BigDecimal
+ */
+ public BigDecimal (long val)
+ {
+ this.intVal = BigInteger.valueOf(val);
+ this.scale = 0;
+ }
+
+ /**
+ * Constructs a BigDecimal from the long in the same way as BigDecimal(long)
+ * and then rounds according to the MathContext.
+ * @param val the long from which we create the initial BigDecimal
+ * @param mc the MathContext that specifies the rounding behaviour
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal (long val, MathContext mc)
+ {
+ this(val);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+
+ /**
+ * Constructs a BigDecimal whose value is given by num rounded according to
+ * mc. Since num is already a BigInteger, the rounding refers only to the
+ * precision setting in mc, if mc.getPrecision() returns an int lower than
+ * the number of digits in num, then rounding is necessary.
+ * @param num the unscaledValue, before rounding
+ * @param mc the MathContext that specifies the precision
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * * @since 1.5
+ */
+ public BigDecimal (BigInteger num, MathContext mc)
+ {
+ this (num, 0);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+
+ /**
+ * Constructs a BigDecimal from the String val according to the same
+ * rules as the BigDecimal(String) constructor and then rounds
+ * according to the MathContext mc.
+ * @param val the String from which we construct the initial BigDecimal
+ * @param mc the MathContext that specifies the rounding
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal (String val, MathContext mc)
+ {
+ this (val);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+
+ /**
+ * Constructs a BigDecimal whose unscaled value is num and whose
+ * scale is zero.
+ * @param num the value of the new BigDecimal
+ */
public BigDecimal (BigInteger num)
{
this (num, 0);
}
- public BigDecimal (BigInteger num, int scale) throws NumberFormatException
+ /**
+ * Constructs a BigDecimal whose unscaled value is num and whose
+ * scale is scale.
+ * @param num
+ * @param scale
+ */
+ public BigDecimal (BigInteger num, int scale)
{
- if (scale < 0)
- throw new NumberFormatException ("scale of " + scale + " is < 0");
this.intVal = num;
this.scale = scale;
}
+
+ /**
+ * Constructs a BigDecimal using the BigDecimal(BigInteger, int)
+ * constructor and then rounds according to the MathContext.
+ * @param num the unscaled value of the unrounded BigDecimal
+ * @param scale the scale of the unrounded BigDecimal
+ * @param mc the MathContext specifying the rounding
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal (BigInteger num, int scale, MathContext mc)
+ {
+ this (num, scale);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+ /**
+ * Constructs a BigDecimal in the same way as BigDecimal(double) and then
+ * rounds according to the MathContext.
+ * @param num the double from which the initial BigDecimal is created
+ * @param mc the MathContext that specifies the rounding behaviour
+ * @throws ArithmeticException if the result is inexact but the rounding type
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal (double num, MathContext mc)
+ {
+ this (num);
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal result = this.round(mc);
+ this.intVal = result.intVal;
+ this.scale = result.scale;
+ this.precision = result.precision;
+ }
+ }
+
public BigDecimal (double num) throws NumberFormatException
{
if (Double.isInfinite (num) || Double.isNaN (num))
@@ -103,8 +266,10 @@ public class BigDecimal extends Number implements Comparable
long mantissa = bits & mantMask;
long exponent = (bits >>> mantissaBits) & expMask;
boolean denormal = exponent == 0;
+
// Correct the exponent for the bias.
exponent -= denormal ? 1022 : 1023;
+
// Now correct the exponent to account for the bits to the right
// of the decimal.
exponent -= mantissaBits;
@@ -136,6 +301,209 @@ public class BigDecimal extends Number implements Comparable
}
}
+ /**
+ * Constructs a BigDecimal from the char subarray and rounding
+ * according to the MathContext.
+ * @param in the char array
+ * @param offset the start of the subarray
+ * @param len the length of the subarray
+ * @param mc the MathContext for rounding
+ * @throws NumberFormatException if the char subarray is not a valid
+ * BigDecimal representation
+ * @throws ArithmeticException if the result is inexact but the rounding
+ * mode is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal(char[] in, int offset, int len, MathContext mc)
+ {
+ this(in, offset, len);
+ // If mc has precision other than zero then we must round.
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal temp = this.round(mc);
+ this.intVal = temp.intVal;
+ this.scale = temp.scale;
+ this.precision = temp.precision;
+ }
+ }
+
+ /**
+ * Constructs a BigDecimal from the char array and rounding according
+ * to the MathContext.
+ * @param in the char array
+ * @param mc the MathContext
+ * @throws NumberFormatException if <code>in</code> is not a valid BigDecimal
+ * representation
+ * @throws ArithmeticException if the result is inexact but the rounding mode
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal(char[] in, MathContext mc)
+ {
+ this(in, 0, in.length);
+ // If mc has precision other than zero then we must round.
+ if (mc.getPrecision() != 0)
+ {
+ BigDecimal temp = this.round(mc);
+ this.intVal = temp.intVal;
+ this.scale = temp.scale;
+ this.precision = temp.precision;
+ }
+ }
+
+ /**
+ * Constructs a BigDecimal from the given char array, accepting the same
+ * sequence of characters as the BigDecimal(String) constructor.
+ * @param in the char array
+ * @throws NumberFormatException if <code>in</code> is not a valid BigDecimal
+ * representation
+ * @since 1.5
+ */
+ public BigDecimal(char[] in)
+ {
+ this(in, 0, in.length);
+ }
+
+ /**
+ * Constructs a BigDecimal from a char subarray, accepting the same sequence
+ * of characters as the BigDecimal(String) constructor.
+ * @param in the char array
+ * @param offset the start of the subarray
+ * @param len the length of the subarray
+ * @throws NumberFormatException if <code>in</code> is not a valid
+ * BigDecimal representation.
+ * @since 1.5
+ */
+ public BigDecimal(char[] in, int offset, int len)
+ {
+ // start is the index into the char array where the significand starts
+ int start = offset;
+ // end is one greater than the index of the last character used
+ int end = offset + len;
+ // point is the index into the char array where the exponent starts
+ // (or, if there is no exponent, this is equal to end)
+ int point = offset;
+ // dot is the index into the char array where the decimal point is
+ // found, or -1 if there is no decimal point
+ int dot = -1;
+
+ // The following examples show what these variables mean. Note that
+ // point and dot don't yet have the correct values, they will be
+ // properly assigned in a loop later on in this method.
+ //
+ // Example 1
+ //
+ // + 1 0 2 . 4 6 9
+ // __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+ //
+ // offset = 2, len = 8, start = 3, dot = 6, point = end = 10
+ //
+ // Example 2
+ //
+ // + 2 3 4 . 6 1 3 E - 1
+ // __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+ //
+ // offset = 2, len = 11, start = 3, dot = 6, point = 10, end = 13
+ //
+ // Example 3
+ //
+ // - 1 2 3 4 5 e 7
+ // __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+ //
+ // offset = 2, len = 8, start = 3, dot = -1, point = 8, end = 10
+
+ // Determine the sign of the number.
+ boolean negative = false;
+ if (in[offset] == '+')
+ {
+ ++start;
+ ++point;
+ }
+ else if (in[offset] == '-')
+ {
+ ++start;
+ ++point;
+ negative = true;
+ }
+
+ // Check each character looking for the decimal point and the
+ // start of the exponent.
+ while (point < end)
+ {
+ char c = in[point];
+ if (c == '.')
+ {
+ // If dot != -1 then we've seen more than one decimal point.
+ if (dot != -1)
+ throw new NumberFormatException("multiple `.'s in number");
+ dot = point;
+ }
+ // Break when we reach the start of the exponent.
+ else if (c == 'e' || c == 'E')
+ break;
+ // Throw an exception if the character was not a decimal or an
+ // exponent and is not a digit.
+ else if (!Character.isDigit(c))
+ throw new NumberFormatException("unrecognized character at " + point
+ + ": " + c);
+ ++point;
+ }
+
+ // val is a StringBuilder from which we'll create a BigInteger
+ // which will be the unscaled value for this BigDecimal
+ StringBuilder val = new StringBuilder(point - start - 1);
+ if (dot != -1)
+ {
+ // If there was a decimal we must combine the two parts that
+ // contain only digits and we must set the scale properly.
+ val.append(in, start, dot - start);
+ val.append(in, dot + 1, point - dot - 1);
+ scale = point - 1 - dot;
+ }
+ else
+ {
+ // If there was no decimal then the unscaled value is just the number
+ // formed from all the digits and the scale is zero.
+ val.append(in, start, point - start);
+ scale = 0;
+ }
+ if (val.length() == 0)
+ throw new NumberFormatException("no digits seen");
+
+ // Prepend a negative sign if necessary.
+ if (negative)
+ val.insert(0, '-');
+ intVal = new BigInteger(val.toString());
+
+ // Now parse exponent.
+ // If point < end that means we broke out of the previous loop when we
+ // saw an 'e' or an 'E'.
+ if (point < end)
+ {
+ point++;
+ // Ignore a '+' sign.
+ if (in[point] == '+')
+ point++;
+
+ // Throw an exception if there were no digits found after the 'e'
+ // or 'E'.
+ if (point >= end)
+ throw new NumberFormatException("no exponent following e or E");
+
+ try
+ {
+ // Adjust the scale according to the exponent.
+ // Remember that the value of a BigDecimal is
+ // unscaledValue x Math.pow(10, -scale)
+ scale -= Integer.parseInt(new String(in, point, end - point));
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new NumberFormatException("malformed exponent");
+ }
+ }
+ }
+
public BigDecimal (String num) throws NumberFormatException
{
int len = num.length();
@@ -199,18 +567,8 @@ public class BigDecimal extends Number implements Comparable
throw new NumberFormatException ("no exponent following e or E");
try
- {
- int exp = Integer.parseInt (num.substring (point));
- exp -= scale;
- if (signum () == 0)
- scale = 0;
- else if (exp > 0)
- {
- intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp));
- scale = 0;
- }
- else
- scale = - exp;
+ {
+ scale -= Integer.parseInt (num.substring (point));
}
catch (NumberFormatException ex)
{
@@ -247,29 +605,74 @@ public class BigDecimal extends Number implements Comparable
BigInteger op1 = intVal;
BigInteger op2 = val.intVal;
if (scale < val.scale)
- op1 = op1.multiply (BigInteger.valueOf (10).pow (val.scale - scale));
+ op1 = op1.multiply (BigInteger.TEN.pow (val.scale - scale));
else if (scale > val.scale)
- op2 = op2.multiply (BigInteger.valueOf (10).pow (scale - val.scale));
+ op2 = op2.multiply (BigInteger.TEN.pow (scale - val.scale));
return new BigDecimal (op1.add (op2), Math.max (scale, val.scale));
}
+
+ /**
+ * Returns a BigDecimal whose value is found first by calling the
+ * method add(val) and then by rounding according to the MathContext mc.
+ * @param val the augend
+ * @param mc the MathContext for rounding
+ * @throws ArithmeticException if the value is inexact but the rounding is
+ * RoundingMode.UNNECESSARY
+ * @return <code>this</code> + <code>val</code>, rounded if need be
+ * @since 1.5
+ */
+ public BigDecimal add (BigDecimal val, MathContext mc)
+ {
+ return add(val).round(mc);
+ }
public BigDecimal subtract (BigDecimal val)
{
return this.add(val.negate());
}
+ /**
+ * Returns a BigDecimal whose value is found first by calling the
+ * method subtract(val) and then by rounding according to the MathContext mc.
+ * @param val the subtrahend
+ * @param mc the MathContext for rounding
+ * @throws ArithmeticException if the value is inexact but the rounding is
+ * RoundingMode.UNNECESSARY
+ * @return <code>this</code> - <code>val</code>, rounded if need be
+ * @since 1.5
+ */
+ public BigDecimal subtract (BigDecimal val, MathContext mc)
+ {
+ return subtract(val).round(mc);
+ }
+
public BigDecimal multiply (BigDecimal val)
{
return new BigDecimal (intVal.multiply (val.intVal), scale + val.scale);
}
+
+ /**
+ * Returns a BigDecimal whose value is (this x val) before it is rounded
+ * according to the MathContext mc.
+ * @param val the multiplicand
+ * @param mc the MathContext for rounding
+ * @return a new BigDecimal with value approximately (this x val)
+ * @throws ArithmeticException if the value is inexact but the rounding mode
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal multiply (BigDecimal val, MathContext mc)
+ {
+ return multiply(val).round(mc);
+ }
public BigDecimal divide (BigDecimal val, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
return divide (val, scale, roundingMode);
}
-
+
public BigDecimal divide(BigDecimal val, int newScale, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
@@ -277,9 +680,6 @@ public class BigDecimal extends Number implements Comparable
throw
new IllegalArgumentException("illegal rounding mode: " + roundingMode);
- if (newScale < 0)
- throw new ArithmeticException ("scale is negative: " + newScale);
-
if (intVal.signum () == 0) // handle special case of 0.0/0.0
return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale);
@@ -290,11 +690,11 @@ public class BigDecimal extends Number implements Comparable
{
// Effectively increase the scale of val to avoid an
// ArithmeticException for a negative power.
- valIntVal = valIntVal.multiply (BigInteger.valueOf (10).pow (-power));
+ valIntVal = valIntVal.multiply (BigInteger.TEN.pow (-power));
power = 0;
}
- BigInteger dividend = intVal.multiply (BigInteger.valueOf (10).pow (power));
+ BigInteger dividend = intVal.multiply (BigInteger.TEN.pow (power));
BigInteger parts[] = dividend.divideAndRemainder (valIntVal);
@@ -303,7 +703,7 @@ public class BigDecimal extends Number implements Comparable
return new BigDecimal (unrounded, newScale);
if (roundingMode == ROUND_UNNECESSARY)
- throw new ArithmeticException ("newScale is not large enough");
+ throw new ArithmeticException ("Rounding necessary");
int sign = intVal.signum () * valIntVal.signum ();
@@ -348,16 +748,95 @@ public class BigDecimal extends Number implements Comparable
// roundingMode == ROUND_DOWN
return new BigDecimal (unrounded, newScale);
}
+
+ /**
+ * Performs division, if the resulting quotient requires rounding
+ * (has a nonterminating decimal expansion),
+ * an ArithmeticException is thrown.
+ * #see divide(BigDecimal, int, int)
+ * @since 1.5
+ */
+ public BigDecimal divide(BigDecimal divisor)
+ throws ArithmeticException, IllegalArgumentException
+ {
+ return divide(divisor, scale, ROUND_UNNECESSARY);
+ }
+
+ /**
+ * Returns a BigDecimal whose value is the remainder in the quotient
+ * this / val. This is obtained by
+ * subtract(divideToIntegralValue(val).multiply(val)).
+ * @param val the divisor
+ * @return a BigDecimal whose value is the remainder
+ * @throws ArithmeticException if val == 0
+ * @since 1.5
+ */
+ public BigDecimal remainder(BigDecimal val)
+ {
+ return subtract(divideToIntegralValue(val).multiply(val));
+ }
+
+ /**
+ * Returns a BigDecimal array, the first element of which is the integer part
+ * of this / val, and the second element of which is the remainder of
+ * that quotient.
+ * @param val the divisor
+ * @return the above described BigDecimal array
+ * @throws ArithmeticException if val == 0
+ * @since 1.5
+ */
+ public BigDecimal[] divideAndRemainder(BigDecimal val)
+ {
+ BigDecimal[] result = new BigDecimal[2];
+ result[0] = divideToIntegralValue(val);
+ result[1] = subtract(result[0].multiply(val));
+ return result;
+ }
+
+ /**
+ * Returns a BigDecimal whose value is the integer part of the quotient
+ * this / val. The preferred scale is this.scale - val.scale.
+ * @param val the divisor
+ * @return a BigDecimal whose value is the integer part of this / val.
+ * @throws ArithmeticException if val == 0
+ * @since 1.5
+ */
+ public BigDecimal divideToIntegralValue(BigDecimal val)
+ {
+ return divide(val, ROUND_DOWN).floor().setScale(scale - val.scale, ROUND_DOWN);
+ }
+
+ /**
+ * Mutates this BigDecimal into one with no fractional part, whose value is
+ * equal to the largest integer that is <= to this BigDecimal. Note that
+ * since this method is private it is okay to mutate this BigDecimal.
+ * @return the BigDecimal obtained through the floor operation on this
+ * BigDecimal.
+ */
+ private BigDecimal floor()
+ {
+ if (scale <= 0)
+ return this;
+ String intValStr = intVal.toString();
+ intValStr = intValStr.substring(0, intValStr.length() - scale);
+ intVal = new BigInteger(intValStr).multiply(BigInteger.TEN.pow(scale));
+ return this;
+ }
- public int compareTo (BigDecimal val)
+ public int compareTo (Object obj)
+ {
+ return compareTo((BigDecimal) obj);
+ }
+
+ public int compareTo (BigDecimal val)
{
if (scale == val.scale)
return intVal.compareTo (val.intVal);
BigInteger thisParts[] =
- intVal.divideAndRemainder (BigInteger.valueOf (10).pow (scale));
+ intVal.divideAndRemainder (BigInteger.TEN.pow (scale));
BigInteger valParts[] =
- val.intVal.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale));
+ val.intVal.divideAndRemainder (BigInteger.TEN.pow (val.scale));
int compare;
if ((compare = thisParts[0].compareTo (valParts[0])) != 0)
@@ -377,11 +856,6 @@ public class BigDecimal extends Number implements Comparable
return thisParts[1].compareTo (valParts[1]);
}
- public int compareTo (Object val)
- {
- return(compareTo((BigDecimal)val));
- }
-
public boolean equals (Object o)
{
return (o instanceof BigDecimal
@@ -430,7 +904,7 @@ public class BigDecimal extends Number implements Comparable
return new BigDecimal (intVal, scale - n);
return new BigDecimal (intVal.multiply
- (BigInteger.valueOf (10).pow (n - scale)), 0);
+ (BigInteger.TEN.pow (n - scale)), 0);
}
public int signum ()
@@ -457,21 +931,296 @@ public class BigDecimal extends Number implements Comparable
{
return new BigDecimal (intVal.negate (), scale);
}
+
+ /**
+ * Returns a BigDecimal whose value is found first by negating this via
+ * the negate() method, then by rounding according to the MathContext mc.
+ * @param mc the MathContext for rounding
+ * @return a BigDecimal whose value is approximately (-this)
+ * @throws ArithmeticException if the value is inexact but the rounding mode
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal negate(MathContext mc)
+ {
+ BigDecimal result = negate();
+ if (mc.getPrecision() != 0)
+ result = result.round(mc);
+ return result;
+ }
+
+ /**
+ * Returns this BigDecimal. This is included for symmetry with the
+ * method negate().
+ * @return this
+ * @since 1.5
+ */
+ public BigDecimal plus()
+ {
+ return this;
+ }
+
+ /**
+ * Returns a BigDecimal whose value is found by rounding <code>this</code>
+ * according to the MathContext. This is the same as round(MathContext).
+ * @param mc the MathContext for rounding
+ * @return a BigDecimal whose value is <code>this</code> before being rounded
+ * @throws ArithmeticException if the value is inexact but the rounding mode
+ * is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal plus(MathContext mc)
+ {
+ return round(mc);
+ }
+
+ /**
+ * Returns a BigDecimal which is this BigDecimal rounded according to the
+ * MathContext rounding settings.
+ * @param mc the MathContext that tells us how to round
+ * @return the rounded BigDecimal
+ */
+ public BigDecimal round(MathContext mc)
+ {
+ int mcPrecision = mc.getPrecision();
+ int numToChop = precision() - mcPrecision;
+ // If mc specifies not to chop any digits or if we've already chopped
+ // enough digits (say by using a MathContext in the constructor for this
+ // BigDecimal) then just return this.
+ if (mcPrecision == 0 || numToChop <= 0)
+ return this;
+
+ // Make a new BigDecimal which is the correct power of 10 to chop off
+ // the required number of digits and then call divide.
+ BigDecimal div = new BigDecimal(BigInteger.TEN.pow(numToChop));
+ BigDecimal rounded = divide(div, scale, 4);
+ rounded.scale -= numToChop;
+ rounded.precision = mcPrecision;
+ return rounded;
+ }
+
+ /**
+ * Returns the precision of this BigDecimal (the number of digits in the
+ * unscaled value). The precision of a zero value is 1.
+ * @return the number of digits in the unscaled value, or 1 if the value
+ * is zero.
+ */
+ public int precision()
+ {
+ if (precision == 0)
+ {
+ String s = intVal.toString();
+ precision = s.length() - (( s.charAt(0) == '-' ) ? 1 : 0);
+ }
+ return precision;
+ }
+
+ /**
+ * Returns the String representation of this BigDecimal, using scientific
+ * notation if necessary. The following steps are taken to generate
+ * the result:
+ *
+ * 1. the BigInteger unscaledValue's toString method is called and if
+ * <code>scale == 0<code> is returned.
+ * 2. an <code>int adjExp</code> is created which is equal to the negation
+ * of <code>scale</code> plus the number of digits in the unscaled value,
+ * minus one.
+ * 3. if <code>scale >= 0 && adjExp >= -6</code> then we represent this
+ * BigDecimal without scientific notation. A decimal is added if the
+ * scale is positive and zeros are prepended as necessary.
+ * 4. if scale is negative or adjExp is less than -6 we use scientific
+ * notation. If the unscaled value has more than one digit, a decimal
+ * as inserted after the first digit, the character 'E' is appended
+ * and adjExp is appended.
+ */
+ public String toString()
+ {
+ // bigStr is the String representation of the unscaled value. If
+ // scale is zero we simply return this.
+ String bigStr = intVal.toString();
+ if (scale == 0)
+ return bigStr;
+
+ boolean negative = (bigStr.charAt(0) == '-');
+ int point = bigStr.length() - scale - (negative ? 1 : 0);
+
+ StringBuilder val = new StringBuilder();
+
+ if (scale >= 0 && (point - 1) >= -6)
+ {
+ // Convert to character form without scientific notation.
+ if (point <= 0)
+ {
+ // Zeros need to be prepended to the StringBuilder.
+ if (negative)
+ val.append('-');
+ // Prepend a '0' and a '.' and then as many more '0's as necessary.
+ val.append('0').append('.');
+ while (point < 0)
+ {
+ val.append('0');
+ point++;
+ }
+ // Append the unscaled value.
+ val.append(bigStr.substring(negative ? 1 : 0));
+ }
+ else
+ {
+ // No zeros need to be prepended so the String is simply the
+ // unscaled value with the decimal point inserted.
+ val.append(bigStr);
+ val.insert(point + (negative ? 1 : 0), '.');
+ }
+ }
+ else
+ {
+ // We must use scientific notation to represent this BigDecimal.
+ val.append(bigStr);
+ // If there is more than one digit in the unscaled value we put a
+ // decimal after the first digit.
+ if (bigStr.length() > 1)
+ val.insert( ( negative ? 2 : 1 ), '.');
+ // And then append 'E' and the exponent = (point - 1).
+ val.append('E');
+ if (point - 1 >= 0)
+ val.append('+');
+ val.append( point - 1 );
+ }
+ return val.toString();
+ }
+
+ /**
+ * Returns the String representation of this BigDecimal, using engineering
+ * notation if necessary. This is similar to toString() but when exponents
+ * are used the exponent is made to be a multiple of 3 such that the integer
+ * part is between 1 and 999.
+ *
+ * @return a String representation of this BigDecimal in engineering notation
+ * @since 1.5
+ */
+ public String toEngineeringString()
+ {
+ // bigStr is the String representation of the unscaled value. If
+ // scale is zero we simply return this.
+ String bigStr = intVal.toString();
+ if (scale == 0)
+ return bigStr;
- public String toString ()
+ boolean negative = (bigStr.charAt(0) == '-');
+ int point = bigStr.length() - scale - (negative ? 1 : 0);
+
+ // This is the adjusted exponent described above.
+ int adjExp = point - 1;
+ StringBuilder val = new StringBuilder();
+
+ if (scale >= 0 && adjExp >= -6)
+ {
+ // Convert to character form without scientific notation.
+ if (point <= 0)
+ {
+ // Zeros need to be prepended to the StringBuilder.
+ if (negative)
+ val.append('-');
+ // Prepend a '0' and a '.' and then as many more '0's as necessary.
+ val.append('0').append('.');
+ while (point < 0)
+ {
+ val.append('0');
+ point++;
+ }
+ // Append the unscaled value.
+ val.append(bigStr.substring(negative ? 1 : 0));
+ }
+ else
+ {
+ // No zeros need to be prepended so the String is simply the
+ // unscaled value with the decimal point inserted.
+ val.append(bigStr);
+ val.insert(point + (negative ? 1 : 0), '.');
+ }
+ }
+ else
+ {
+ // We must use scientific notation to represent this BigDecimal.
+ // The exponent must be a multiple of 3 and the integer part
+ // must be between 1 and 999.
+ val.append(bigStr);
+ int zeros = adjExp % 3;
+ int dot = 1;
+ if (adjExp > 0)
+ {
+ // If the exponent is positive we just move the decimal to the
+ // right and decrease the exponent until it is a multiple of 3.
+ dot += zeros;
+ adjExp -= zeros;
+ }
+ else
+ {
+ // If the exponent is negative then we move the dot to the right
+ // and decrease the exponent (increase its magnitude) until
+ // it is a multiple of 3. Note that this is not adjExp -= zeros
+ // because the mod operator doesn't give us the distance to the
+ // correct multiple of 3. (-5 mod 3) is -2 but the distance from
+ // -5 to the correct multiple of 3 (-6) is 1, not 2.
+ if (zeros == -2)
+ {
+ dot += 1;
+ adjExp -= 1;
+ }
+ else if (zeros == -1)
+ {
+ dot += 2;
+ adjExp -= 2;
+ }
+ }
+
+ // Either we have to append zeros because, for example, 1.1E+5 should
+ // be 110E+3, or we just have to put the decimal in the right place.
+ if (dot > val.length())
+ {
+ while (dot > val.length())
+ val.append('0');
+ }
+ else if (bigStr.length() > dot)
+ val.insert(dot + (negative ? 1 : 0), '.');
+
+ // And then append 'E' and the exponent (adjExp).
+ val.append('E');
+ if (adjExp >= 0)
+ val.append('+');
+ val.append(adjExp);
+ }
+ return val.toString();
+ }
+
+ /**
+ * Returns a String representation of this BigDecimal without using
+ * scientific notation. This is how toString() worked for releases 1.4
+ * and previous. Zeros may be added to the end of the String. For
+ * example, an unscaled value of 1234 and a scale of -3 would result in
+ * the String 1234000, but the toString() method would return
+ * 1.234E+6.
+ * @return a String representation of this BigDecimal
+ * @since 1.5
+ */
+ public String toPlainString()
{
+ // If the scale is zero we simply return the String representation of the
+ // unscaled value.
String bigStr = intVal.toString();
- if (scale == 0)
+ if (scale == 0)
return bigStr;
+ // Remember if we have to put a negative sign at the start.
boolean negative = (bigStr.charAt(0) == '-');
int point = bigStr.length() - scale - (negative ? 1 : 0);
- StringBuffer sb = new StringBuffer(bigStr.length() + 2 +
- (point <= 0 ? (-point + 1) : 0));
+ StringBuffer sb = new StringBuffer(bigStr.length() + 2
+ + (point <= 0 ? (-point + 1) : 0));
if (point <= 0)
{
+ // We have to prepend zeros and a decimal point.
if (negative)
sb.append('-');
sb.append('0').append('.');
@@ -482,24 +1231,95 @@ public class BigDecimal extends Number implements Comparable
}
sb.append(bigStr.substring(negative ? 1 : 0));
}
+ else if (point < bigStr.length())
+ {
+ // No zeros need to be prepended or appended, just put the decimal
+ // in the right place.
+ sb.append(bigStr);
+ sb.insert(point + (negative ? 1 : 0), '.');
+ }
else
{
- sb.append(bigStr);
- sb.insert(point + (negative ? 1 : 0), '.');
+ // We must append zeros instead of using scientific notation.
+ sb.append(bigStr);
+ for (int i = bigStr.length(); i < point; i++)
+ sb.append('0');
}
return sb.toString();
}
-
+
+ /**
+ * Converts this BigDecimal to a BigInteger. Any fractional part will
+ * be discarded.
+ * @return a BigDecimal whose value is equal to floor[this]
+ */
public BigInteger toBigInteger ()
{
- return scale == 0 ? intVal :
- intVal.divide (BigInteger.valueOf (10).pow (scale));
+ // If scale > 0 then we must divide, if scale > 0 then we must multiply,
+ // and if scale is zero then we just return intVal;
+ if (scale > 0)
+ return intVal.divide (BigInteger.TEN.pow (scale));
+ else if (scale < 0)
+ return intVal.multiply(BigInteger.TEN.pow(-scale));
+ return intVal;
+ }
+
+ /**
+ * Converts this BigDecimal into a BigInteger, throwing an
+ * ArithmeticException if the conversion is not exact.
+ * @return a BigInteger whose value is equal to the value of this BigDecimal
+ * @since 1.5
+ */
+ public BigInteger toBigIntegerExact()
+ {
+ if (scale > 0)
+ {
+ // If we have to divide, we must check if the result is exact.
+ BigInteger[] result =
+ intVal.divideAndRemainder(BigInteger.TEN.pow(scale));
+ if (result[1].equals(BigInteger.ZERO))
+ return result[0];
+ throw new ArithmeticException("No exact BigInteger representation");
+ }
+ else if (scale < 0)
+ // If we're multiplying instead, then we needn't check for exactness.
+ return intVal.multiply(BigInteger.TEN.pow(-scale));
+ // If the scale is zero we can simply return intVal.
+ return intVal;
}
public int intValue ()
{
return toBigInteger ().intValue ();
}
+
+ /**
+ * Returns a BigDecimal which is numerically equal to this BigDecimal but
+ * with no trailing zeros in the representation. For example, if this
+ * BigDecimal has [unscaledValue, scale] = [6313000, 4] this method returns
+ * a BigDecimal with [unscaledValue, scale] = [6313, 1]. As another
+ * example, [12400, -2] would become [124, -4].
+ * @return a numerically equal BigDecimal with no trailing zeros
+ */
+ public BigDecimal stripTrailingZeros()
+ {
+ String intValStr = intVal.toString();
+ int newScale = scale;
+ int pointer = intValStr.length() - 1;
+ // This loop adjusts pointer which will be used to give us the substring
+ // of intValStr to use in our new BigDecimal, and also accordingly
+ // adjusts the scale of our new BigDecimal.
+ while (intValStr.charAt(pointer) == '0')
+ {
+ pointer --;
+ newScale --;
+ }
+ // Create a new BigDecimal with the appropriate substring and then
+ // set its scale.
+ BigDecimal result = new BigDecimal(intValStr.substring(0, pointer + 1));
+ result.scale = newScale;
+ return result;
+ }
public long longValue ()
{
@@ -524,6 +1344,171 @@ public class BigDecimal extends Number implements Comparable
public BigDecimal setScale (int scale, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
+ // NOTE: The 1.5 JRE doesn't throw this, ones prior to it do and
+ // the spec says it should. Nevertheless, if 1.6 doesn't fix this
+ // we should consider removing it.
+ if( scale < 0 ) throw new ArithmeticException("Scale parameter < 0.");
return divide (ONE, scale, roundingMode);
}
+
+ /**
+ * Returns a new BigDecimal constructed from the BigDecimal(String)
+ * constructor using the Double.toString(double) method to obtain
+ * the String.
+ * @param val the double value used in Double.toString(double)
+ * @return a BigDecimal representation of val
+ * @throws NumberFormatException if val is NaN or infinite
+ * @since 1.5
+ */
+ public static BigDecimal valueOf(double val)
+ {
+ if (Double.isInfinite(val) || Double.isNaN(val))
+ throw new NumberFormatException("argument cannot be NaN or infinite.");
+ return new BigDecimal(Double.toString(val));
+ }
+
+ /**
+ * Returns a BigDecimal whose numerical value is the numerical value
+ * of this BigDecimal multiplied by 10 to the power of <code>n</code>.
+ * @param n the power of ten
+ * @return the new BigDecimal
+ * @since 1.5
+ */
+ public BigDecimal scaleByPowerOfTen(int n)
+ {
+ BigDecimal result = new BigDecimal(intVal, scale - n);
+ result.precision = precision;
+ return result;
+ }
+
+ /**
+ * Returns a BigDecimal whose value is <code>this</code> to the power of
+ * <code>n</code>.
+ * @param n the power
+ * @return the new BigDecimal
+ * @since 1.5
+ */
+ public BigDecimal pow(int n)
+ {
+ if (n < 0 || n > 999999999)
+ throw new ArithmeticException("n must be between 0 and 999999999");
+ BigDecimal result = new BigDecimal(intVal.pow(n), scale * n);
+ return result;
+ }
+
+ /**
+ * Returns a BigDecimal whose value is determined by first calling pow(n)
+ * and then by rounding according to the MathContext mc.
+ * @param n the power
+ * @param mc the MathContext
+ * @return the new BigDecimal
+ * @throws ArithmeticException if n < 0 or n > 999999999 or if the result is
+ * inexact but the rounding is RoundingMode.UNNECESSARY
+ * @since 1.5
+ */
+ public BigDecimal pow(int n, MathContext mc)
+ {
+ // FIXME: The specs claim to use the X3.274-1996 algorithm. We
+ // currently do not.
+ return pow(n).round(mc);
+ }
+
+ /**
+ * Returns a BigDecimal whose value is the absolute value of this BigDecimal
+ * with rounding according to the given MathContext.
+ * @param mc the MathContext
+ * @return the new BigDecimal
+ */
+ public BigDecimal abs(MathContext mc)
+ {
+ BigDecimal result = abs();
+ result = result.round(mc);
+ return result;
+ }
+
+ /**
+ * Returns the size of a unit in the last place of this BigDecimal. This
+ * returns a BigDecimal with [unscaledValue, scale] = [1, this.scale()].
+ * @return the size of a unit in the last place of <code>this</code>.
+ * @since 1.5
+ */
+ public BigDecimal ulp()
+ {
+ return new BigDecimal(BigInteger.ONE, scale);
+ }
+
+ /**
+ * Converts this BigDecimal to a long value.
+ * @return the long value
+ * @throws ArithmeticException if rounding occurs or if overflow occurs
+ * @since 1.5
+ */
+ public long longValueExact()
+ {
+ // Set scale will throw an exception if rounding occurs.
+ BigDecimal temp = setScale(0, ROUND_UNNECESSARY);
+ BigInteger tempVal = temp.intVal;
+ // Check for overflow.
+ long result = intVal.longValue();
+ if (tempVal.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 1
+ || (result < 0 && signum() == 1) || (result > 0 && signum() == -1))
+ throw new ArithmeticException("this BigDecimal is too " +
+ "large to fit into the return type");
+
+ return intVal.longValue();
+ }
+
+ /**
+ * Converts this BigDecimal into an int by first calling longValueExact
+ * and then checking that the <code>long</code> returned from that
+ * method fits into an <code>int</code>.
+ * @return an int whose value is <code>this</code>
+ * @throws ArithmeticException if this BigDecimal has a fractional part
+ * or is too large to fit into an int.
+ * @since 1.5
+ */
+ public int intValueExact()
+ {
+ long temp = longValueExact();
+ int result = (int)temp;
+ if (result != temp)
+ throw new ArithmeticException ("this BigDecimal cannot fit into an int");
+ return result;
+ }
+
+ /**
+ * Converts this BigDecimal into a byte by first calling longValueExact
+ * and then checking that the <code>long</code> returned from that
+ * method fits into a <code>byte</code>.
+ * @return a byte whose value is <code>this</code>
+ * @throws ArithmeticException if this BigDecimal has a fractional part
+ * or is too large to fit into a byte.
+ * @since 1.5
+ */
+ public byte byteValueExact()
+ {
+ long temp = longValueExact();
+ byte result = (byte)temp;
+ if (result != temp)
+ throw new ArithmeticException ("this BigDecimal cannot fit into a byte");
+ return result;
+ }
+
+ /**
+ * Converts this BigDecimal into a short by first calling longValueExact
+ * and then checking that the <code>long</code> returned from that
+ * method fits into a <code>short</code>.
+ * @return a short whose value is <code>this</code>
+ * @throws ArithmeticException if this BigDecimal has a fractional part
+ * or is too large to fit into a short.
+ * @since 1.5
+ */
+ public short shortValueExact()
+ {
+ long temp = longValueExact();
+ short result = (short)temp;
+ if (result != temp)
+ throw new ArithmeticException ("this BigDecimal cannot fit into a short");
+ return result;
+ }
}
diff --git a/libjava/classpath/java/math/BigInteger.java b/libjava/classpath/java/math/BigInteger.java
index 86d6924af02..b57cf607e34 100644
--- a/libjava/classpath/java/math/BigInteger.java
+++ b/libjava/classpath/java/math/BigInteger.java
@@ -1168,7 +1168,7 @@ public class BigInteger extends Number implements Comparable
throw new ArithmeticException("non-positive modulo");
if (exponent.isNegative())
- return modInverse(m);
+ return modInverse(m).modPow(exponent.negate(), m);
if (exponent.isOne())
return mod(m);
diff --git a/libjava/classpath/java/math/MathContext.java b/libjava/classpath/java/math/MathContext.java
new file mode 100644
index 00000000000..417d9c2e270
--- /dev/null
+++ b/libjava/classpath/java/math/MathContext.java
@@ -0,0 +1,144 @@
+/* MathContext.java --
+ Copyright (C) 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.math;
+
+import java.io.Serializable;
+
+/**
+ * Immutable objects describing settings such as rounding mode and digit
+ * precision for numerical operations such as those in the BigDecimal class.
+ * @author Anthony Balkissoon abalkiss at redhat dot com
+ *
+ */
+public final class MathContext implements Serializable
+{
+
+ /**
+ * This is the serialVersionUID reported here:
+ * java.sun.com/j2se/1.5.0/docs/api/serialized-form.html#java.math.MathContext
+ */
+ private static final long serialVersionUID = 5579720004786848255L;
+
+ private int precision;
+
+ /**
+ * Constructs a new MathContext with the specified precision and with HALF_UP
+ * rounding.
+ * @param setPrecision the precision for the new MathContext
+ *
+ * @throws IllegalArgumentException if precision is < 0.
+ */
+ public MathContext(int setPrecision)
+ {
+ if (setPrecision < 0)
+ throw new IllegalArgumentException("Precision cannot be less than zero.");
+ precision = setPrecision;
+ }
+
+ /**
+ * Constructs a MathContext from a String that has the same form as one
+ * produced by the toString() method.
+ * @param val
+ *
+ * @throws IllegalArgumentException if the String is not in the correct
+ * format or if the precision specified is < 0.
+ */
+ public MathContext(String val)
+ {
+ try
+ {
+ int roundingModeIndex = val.indexOf("roundingMode", 10);
+ precision = Integer.parseInt(val.substring(10, roundingModeIndex - 1));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new IllegalArgumentException("String not in correct format");
+ }
+ catch (IllegalArgumentException iae)
+ {
+ throw new IllegalArgumentException("String not in correct format");
+ }
+ if (precision < 0)
+ throw new IllegalArgumentException("Precision cannot be less than 0.");
+ }
+
+ /**
+ * Returns true if x is a MathContext and has the same precision setting
+ * and rounding mode as this MathContext.
+ *
+ * @return true if the above conditions hold
+ */
+ public boolean equals(Object x)
+ {
+ if (!(x instanceof MathContext))
+ return false;
+ MathContext mc = (MathContext)x;
+ return mc.precision == this.precision;
+ }
+
+ /**
+ * Returns the precision setting.
+ * @return the precision setting.
+ */
+ public int getPrecision()
+ {
+ return precision;
+ }
+
+ /**
+ * Returns "precision=p roundingMode=MODE" where p is an int giving the
+ * precision and MODE is UP, DOWN, HALF_UP, HALF_DOWN, HALF_EVEN, CEILING,
+ * FLOOR, or UNNECESSARY corresponding to rounding modes.
+ *
+ * @return a String describing this MathContext
+ */
+ public String toString()
+ {
+ return "precision="+precision;
+ }
+
+ /**
+ * Returns the hashcode for this MathContext.
+ * @return the hashcode for this MathContext.
+ */
+ public int hashCode()
+ {
+ return precision;
+ }
+}
diff --git a/libjava/classpath/java/net/Inet6Address.java b/libjava/classpath/java/net/Inet6Address.java
index 0d62fe919a0..8d834a6fd28 100644
--- a/libjava/classpath/java/net/Inet6Address.java
+++ b/libjava/classpath/java/net/Inet6Address.java
@@ -39,13 +39,16 @@ exception statement from your version. */
package java.net;
import java.util.Arrays;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
/*
* Written using on-line Java Platform 1.4 API Specification and
* RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
*
* @author Michael Koch
- * @status Believed complete and correct.
+ * @status Updated to 1.5. Serialization compatibility is tested.
*/
public final class Inet6Address extends InetAddress
{
@@ -57,6 +60,39 @@ public final class Inet6Address extends InetAddress
byte[] ipaddress;
/**
+ * The scope ID, if any.
+ * @since 1.5
+ * @serial
+ */
+ private int scope_id;
+
+ /**
+ * The scope ID, if any.
+ * @since 1.5
+ * @serial
+ */
+ private boolean scope_id_set;
+
+ /**
+ * Whether ifname is set or not.
+ * @since 1.5
+ * @serial
+ */
+ private boolean scope_ifname_set;
+
+ /**
+ * Name of the network interface, used only by the serialization methods
+ * @since 1.5
+ * @serial
+ */
+ private String ifname;
+
+ /**
+ * Scope network interface, or <code>null</code>.
+ */
+ private transient NetworkInterface nif;
+
+ /**
* Create an Inet6Address object
*
* @param addr The IP address
@@ -67,6 +103,10 @@ public final class Inet6Address extends InetAddress
super(addr, host);
// Super constructor clones the addr. Get a reference to the clone.
this.ipaddress = this.addr;
+ ifname = null;
+ scope_ifname_set = scope_id_set = false;
+ scope_id = 0;
+ nif = null;
}
/**
@@ -199,6 +239,75 @@ public final class Inet6Address extends InetAddress
}
/**
+ * Creates a scoped Inet6Address where the scope has an integer id.
+ *
+ * @throws UnkownHostException if the address is an invalid number of bytes.
+ * @since 1.5
+ */
+ public static Inet6Address getByAddress(String host, byte[] addr,
+ int scopeId)
+ throws UnknownHostException
+ {
+ if( addr.length != 16 )
+ throw new UnknownHostException("Illegal address length: " + addr.length
+ + " bytes.");
+ Inet6Address ip = new Inet6Address( addr, host );
+ ip.scope_id = scopeId;
+ ip.scope_id_set = true;
+ return ip;
+ }
+
+ /**
+ * Creates a scoped Inet6Address where the scope is a given
+ * NetworkInterface.
+ *
+ * @throws UnkownHostException if the address is an invalid number of bytes.
+ * @since 1.5
+ */
+ public static Inet6Address getByAddress(String host, byte[] addr,
+ NetworkInterface nif)
+ throws UnknownHostException
+ {
+ if( addr.length != 16 )
+ throw new UnknownHostException("Illegal address length: " + addr.length
+ + " bytes.");
+ Inet6Address ip = new Inet6Address( addr, host );
+ ip.nif = nif;
+
+ return ip;
+ }
+
+ /**
+ * Returns the <code>NetworkInterface</code> of the address scope
+ * if it is a scoped address and the scope is given in the form of a
+ * NetworkInterface.
+ * (I.e. the address was created using the
+ * getByAddress(String, byte[], NetworkInterface) method)
+ * Otherwise this method returns <code>null</code>.
+ * @since 1.5
+ */
+ public NetworkInterface getScopedInterface()
+ {
+ return nif;
+ }
+
+ /**
+ * Returns the scope ID of the address scope if it is a scoped adress using
+ * an integer to identify the scope.
+ *
+ * Otherwise this method returns 0.
+ * @since 1.5
+ */
+ public int getScopeId()
+ {
+ // check scope_id_set because some JDK-serialized objects seem to have
+ // scope_id set to a nonzero value even when scope_id_set == false
+ if( scope_id_set )
+ return scope_id;
+ return 0;
+ }
+
+ /**
* Returns the IP address string in textual presentation
*/
public String getHostAddress()
@@ -214,12 +323,17 @@ public final class Inet6Address extends InetAddress
sbuf.append(Integer.toHexString(x));
}
+ if( nif != null )
+ sbuf.append( "%" + nif.getName() );
+ else if( scope_id_set )
+ sbuf.append( "%" + scope_id );
return sbuf.toString();
}
/**
* Returns a hashcode for this IP address
+ * (The hashcode is independent of scope)
*/
public int hashCode()
{
@@ -234,10 +348,23 @@ public final class Inet6Address extends InetAddress
if (! (obj instanceof Inet6Address))
return false;
- // this.ipaddress is never set in this class except to
- // the value of the super class' addr. The super classes
- // equals(Object) will do the compare.
- return super.equals(obj);
+ Inet6Address ip = (Inet6Address)obj;
+ if (ipaddress.length != ip.ipaddress.length)
+ return false;
+
+ for (int i = 0; i < ip.ipaddress.length; i++)
+ if (ipaddress[i] != ip.ipaddress[i])
+ return false;
+
+ if( ip.nif != null && nif != null )
+ return nif.equals( ip.nif );
+ if( ip.nif != nif )
+ return false;
+ if( ip.scope_id_set != scope_id_set )
+ return false;
+ if( scope_id_set )
+ return (scope_id == ip.scope_id);
+ return true;
}
/**
@@ -258,4 +385,38 @@ public final class Inet6Address extends InetAddress
return true;
}
+
+ /**
+ * Required for 1.5-compatible serialization.
+ * @since 1.5
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException
+ {
+ s.defaultReadObject();
+ try
+ {
+ if( scope_ifname_set )
+ nif = NetworkInterface.getByName( ifname );
+ }
+ catch( SocketException se )
+ {
+ // FIXME: Ignore this? or throw an IOException?
+ }
+ }
+
+ /**
+ * Required for 1.5-compatible serialization.
+ * @since 1.5
+ */
+ private void writeObject(ObjectOutputStream s)
+ throws IOException
+ {
+ if( nif != null )
+ {
+ ifname = nif.getName();
+ scope_ifname_set = true;
+ }
+ s.defaultWriteObject();
+ }
}
diff --git a/libjava/classpath/java/net/InetSocketAddress.java b/libjava/classpath/java/net/InetSocketAddress.java
index 91254575265..5267cc11a5d 100644
--- a/libjava/classpath/java/net/InetSocketAddress.java
+++ b/libjava/classpath/java/net/InetSocketAddress.java
@@ -86,7 +86,6 @@ public class InetSocketAddress extends SocketAddress
this.addr = addr;
this.port = port;
- this.hostname = addr.getHostName();
}
/**
@@ -186,7 +185,7 @@ public class InetSocketAddress extends SocketAddress
if (addr == null && sa.addr != null)
return false;
- else if (addr == null && sa.addr == null)
+ else if (addr == null && sa.addr == null) // we know hostname != null
return hostname.equals(sa.hostname) && sa.port == port;
else
return addr.equals(sa.addr) && sa.port == port;
@@ -213,6 +212,9 @@ public class InetSocketAddress extends SocketAddress
*/
public final String getHostName()
{
+ if (hostname == null) // we know addr != null
+ hostname = addr.getHostName();
+
return hostname;
}
@@ -249,10 +251,11 @@ public class InetSocketAddress extends SocketAddress
/**
* Returns the <code>InetSocketAddress</code> as string
*
- * @return A string represenation of this address.
+ * @return A string representation of this address.
*/
public String toString()
{
+ // Note: if addr is null, then hostname != null.
return (addr == null ? hostname : addr.toString()) + ":" + port;
}
}
diff --git a/libjava/classpath/java/net/URL.java b/libjava/classpath/java/net/URL.java
index 967cc80f69b..ed7decc7992 100644
--- a/libjava/classpath/java/net/URL.java
+++ b/libjava/classpath/java/net/URL.java
@@ -482,7 +482,17 @@ public final class URL implements Serializable
}
catch (URLParseError e)
{
- throw new MalformedURLException(e.getMessage());
+ MalformedURLException mue = new MalformedURLException(e.getMessage());
+ mue.initCause(e);
+ throw mue;
+ }
+ catch (RuntimeException e)
+ {
+ // This isn't documented, but the JDK also catches
+ // RuntimeExceptions here.
+ MalformedURLException mue = new MalformedURLException(e.getMessage());
+ mue.initCause(e);
+ throw mue;
}
if (hashAt >= 0)
@@ -535,8 +545,7 @@ public final class URL implements Serializable
*/
public Object getContent(Class[] classes) throws IOException
{
- // FIXME: implement this
- return getContent();
+ return openConnection().getContent(classes);
}
/**
diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java
index 183e645c85f..403f7485c79 100644
--- a/libjava/classpath/java/net/URLClassLoader.java
+++ b/libjava/classpath/java/net/URLClassLoader.java
@@ -39,15 +39,21 @@ exception statement from your version. */
package java.net;
-import java.io.BufferedReader;
+import gnu.java.net.loader.FileURLLoader;
+import gnu.java.net.loader.JarURLLoader;
+import gnu.java.net.loader.RemoteURLLoader;
+import gnu.java.net.loader.Resource;
+import gnu.java.net.loader.URLLoader;
+import gnu.java.net.loader.URLStreamHandlerCache;
+
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.CodeSource;
@@ -55,14 +61,10 @@ import java.security.PermissionCollection;
import java.security.PrivilegedAction;
import java.security.SecureClassLoader;
import java.security.cert.Certificate;
+import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.StringTokenizer;
import java.util.Vector;
import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -128,19 +130,17 @@ public class URLClassLoader extends SecureClassLoader
// Class Variables
/**
- * A global cache to store mappings between URLLoader and URL,
- * so we can avoid do all the homework each time the same URL
- * comes.
- * XXX - Keeps these loaders forever which prevents garbage collection.
+ * A cache to store mappings between handler factory and its
+ * private protocol handler cache (also a HashMap), so we can avoid
+ * creating handlers each time the same protocol comes.
*/
- private static HashMap urlloaders = new HashMap();
+ private static URLStreamHandlerCache factoryCache
+ = new URLStreamHandlerCache();
/**
- * A cache to store mappings between handler factory and its
- * private protocol handler cache (also a HashMap), so we can avoid
- * create handlers each time the same protocol comes.
+ * The prefix for URL loaders.
*/
- private static HashMap factoryCache = new HashMap(5);
+ private static final String URL_LOADER_PREFIX = "gnu.java.net.loader.Load_";
// Instance variables
@@ -168,516 +168,6 @@ public class URLClassLoader extends SecureClassLoader
// Helper classes
/**
- * A <code>URLLoader</code> contains all logic to load resources from a
- * given base <code>URL</code>.
- */
- abstract static class URLLoader
- {
- /**
- * Our classloader to get info from if needed.
- */
- final URLClassLoader classloader;
-
- /**
- * The base URL from which all resources are loaded.
- */
- final URL baseURL;
-
- /**
- * A <code>CodeSource</code> without any associated certificates.
- * It is common for classes to not have certificates associated
- * with them. If they come from the same <code>URLLoader</code>
- * then it is safe to share the associated <code>CodeSource</code>
- * between them since <code>CodeSource</code> is immutable.
- */
- final CodeSource noCertCodeSource;
-
- URLLoader(URLClassLoader classloader, URL baseURL)
- {
- this(classloader, baseURL, baseURL);
- }
-
- URLLoader(URLClassLoader classloader, URL baseURL, URL overrideURL)
- {
- this.classloader = classloader;
- this.baseURL = baseURL;
- this.noCertCodeSource = new CodeSource(overrideURL, null);
- }
-
- /**
- * Returns a <code>Resource</code> loaded by this
- * <code>URLLoader</code>, or <code>null</code> when no
- * <code>Resource</code> with the given name exists.
- */
- abstract Resource getResource(String s);
-
- /**
- * Returns the <code>Manifest</code> associated with the
- * <code>Resource</code>s loaded by this <code>URLLoader</code> or
- * <code>null</code> there is no such <code>Manifest</code>.
- */
- Manifest getManifest()
- {
- return null;
- }
-
- Vector getClassPath()
- {
- return null;
- }
- }
-
- /**
- * A <code>Resource</code> represents a resource in some
- * <code>URLLoader</code>. It also contains all information (e.g.,
- * <code>URL</code>, <code>CodeSource</code>, <code>Manifest</code> and
- * <code>InputStream</code>) that is necessary for loading resources
- * and creating classes from a <code>URL</code>.
- */
- abstract static class Resource
- {
- final URLLoader loader;
-
- Resource(URLLoader loader)
- {
- this.loader = loader;
- }
-
- /**
- * Returns the non-null <code>CodeSource</code> associated with
- * this resource.
- */
- CodeSource getCodeSource()
- {
- Certificate[] certs = getCertificates();
- if (certs == null)
- return loader.noCertCodeSource;
- else
- return new CodeSource(loader.baseURL, certs);
- }
-
- /**
- * Returns <code>Certificates</code> associated with this
- * resource, or null when there are none.
- */
- Certificate[] getCertificates()
- {
- return null;
- }
-
- /**
- * Return a <code>URL</code> that can be used to access this resource.
- */
- abstract URL getURL();
-
- /**
- * Returns the size of this <code>Resource</code> in bytes or
- * <code>-1</code> when unknown.
- */
- abstract int getLength();
-
- /**
- * Returns the non-null <code>InputStream</code> through which
- * this resource can be loaded.
- */
- abstract InputStream getInputStream() throws IOException;
- }
-
- /**
- * A <code>JarURLLoader</code> is a type of <code>URLLoader</code>
- * only loading from jar url.
- */
- static final class JarURLLoader extends URLLoader
- {
- final JarFile jarfile; // The jar file for this url
- final URL baseJarURL; // Base jar: url for all resources loaded from jar
-
- Vector classPath; // The "Class-Path" attribute of this Jar's manifest
-
- public JarURLLoader(URLClassLoader classloader, URL baseURL,
- URL absoluteUrl)
- {
- super(classloader, baseURL, absoluteUrl);
-
- // Cache url prefix for all resources in this jar url.
- String external = baseURL.toExternalForm();
- StringBuffer sb = new StringBuffer(external.length() + 6);
- sb.append("jar:");
- sb.append(external);
- sb.append("!/");
- String jarURL = sb.toString();
-
- this.classPath = null;
- URL baseJarURL = null;
- JarFile jarfile = null;
- try
- {
- baseJarURL =
- new URL(null, jarURL, classloader.getURLStreamHandler("jar"));
-
- jarfile =
- ((JarURLConnection) baseJarURL.openConnection()).getJarFile();
-
- Manifest manifest;
- Attributes attributes;
- String classPathString;
-
- this.classPath = new Vector();
-
- // This goes through the cached jar files listed
- // in the INDEX.LIST file. All the jars found are added
- // to the classPath vector so they can be loaded.
- String dir = "META-INF/INDEX.LIST";
- if (jarfile.getEntry(dir) != null)
- {
- BufferedReader br = new BufferedReader(new InputStreamReader(new URL(baseJarURL,
- dir).openStream()));
- String line = br.readLine();
- while (line != null)
- {
- if (line.endsWith(".jar"))
- {
- try
- {
- this.classPath.add(new URL(baseURL, line));
- }
- catch (java.net.MalformedURLException xx)
- {
- // Give up
- }
- }
- line = br.readLine();
- }
- }
- else if ((manifest = jarfile.getManifest()) != null
- && (attributes = manifest.getMainAttributes()) != null
- && ((classPathString
- = attributes.getValue(Attributes.Name.CLASS_PATH))
- != null))
- {
- StringTokenizer st = new StringTokenizer(classPathString, " ");
- while (st.hasMoreElements ())
- {
- String e = st.nextToken ();
- try
- {
- this.classPath.add(new URL(baseURL, e));
- }
- catch (java.net.MalformedURLException xx)
- {
- // Give up
- }
- }
- }
- }
- catch (IOException ioe)
- {
- /* ignored */
- }
-
- this.baseJarURL = baseJarURL;
- this.jarfile = jarfile;
- }
-
- /** get resource with the name "name" in the jar url */
- Resource getResource(String name)
- {
- if (jarfile == null)
- return null;
-
- if (name.startsWith("/"))
- name = name.substring(1);
-
- JarEntry je = jarfile.getJarEntry(name);
- if (je != null)
- return new JarURLResource(this, name, je);
- else
- return null;
- }
-
- Manifest getManifest()
- {
- try
- {
- return (jarfile == null) ? null : jarfile.getManifest();
- }
- catch (IOException ioe)
- {
- return null;
- }
- }
-
- Vector getClassPath()
- {
- return classPath;
- }
- }
-
- static final class JarURLResource extends Resource
- {
- private final JarEntry entry;
- private final String name;
-
- JarURLResource(JarURLLoader loader, String name, JarEntry entry)
- {
- super(loader);
- this.entry = entry;
- this.name = name;
- }
-
- InputStream getInputStream() throws IOException
- {
- return ((JarURLLoader) loader).jarfile.getInputStream(entry);
- }
-
- int getLength()
- {
- return (int) entry.getSize();
- }
-
- Certificate[] getCertificates()
- {
- // We have to get the entry from the jar file again, because the
- // certificates will not be available until the entire entry has
- // been read.
- return ((JarEntry) ((JarURLLoader) loader).jarfile.getEntry(name))
- .getCertificates();
- }
-
- URL getURL()
- {
- try
- {
- return new URL(((JarURLLoader) loader).baseJarURL, name,
- loader.classloader.getURLStreamHandler("jar"));
- }
- catch (MalformedURLException e)
- {
- InternalError ie = new InternalError();
- ie.initCause(e);
- throw ie;
- }
- }
- }
-
- /**
- * Loader for remote directories.
- */
- static final class RemoteURLLoader extends URLLoader
- {
- private final String protocol;
-
- RemoteURLLoader(URLClassLoader classloader, URL url)
- {
- super(classloader, url);
- protocol = url.getProtocol();
- }
-
- /**
- * Get a remote resource.
- * Returns null if no such resource exists.
- */
- Resource getResource(String name)
- {
- try
- {
- URL url =
- new URL(baseURL, name, classloader.getURLStreamHandler(protocol));
- URLConnection connection = url.openConnection();
-
- // Open the connection and check the stream
- // just to be sure it exists.
- int length = connection.getContentLength();
- InputStream stream = connection.getInputStream();
-
- // We can do some extra checking if it is a http request
- if (connection instanceof HttpURLConnection)
- {
- int response =
- ((HttpURLConnection) connection).getResponseCode();
- if (response / 100 != 2)
- return null;
- }
-
- if (stream != null)
- return new RemoteResource(this, name, url, stream, length);
- else
- return null;
- }
- catch (IOException ioe)
- {
- return null;
- }
- }
- }
-
- /**
- * A resource from some remote location.
- */
- static final class RemoteResource extends Resource
- {
- private final URL url;
- private final InputStream stream;
- private final int length;
-
- RemoteResource(RemoteURLLoader loader, String name, URL url,
- InputStream stream, int length)
- {
- super(loader);
- this.url = url;
- this.stream = stream;
- this.length = length;
- }
-
- InputStream getInputStream() throws IOException
- {
- return stream;
- }
-
- public int getLength()
- {
- return length;
- }
-
- public URL getURL()
- {
- return url;
- }
- }
-
- /**
- * A <code>FileURLLoader</code> is a type of <code>URLLoader</code>
- * only loading from file url.
- */
- static final class FileURLLoader extends URLLoader
- {
- File dir; //the file for this file url
-
- FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl)
- {
- super(classloader, url, absoluteUrl);
- dir = new File(absoluteUrl.getFile());
- }
-
- /** get resource with the name "name" in the file url */
- Resource getResource(String name)
- {
- try
- {
- // Make sure that all components in name are valid by walking through
- // them
- File file = walkPathComponents(name);
-
- if (file == null)
- return null;
-
- return new FileResource(this, file);
- }
- catch (IOException e)
- {
- // Fall through...
- }
- return null;
- }
-
- /**
- * Walk all path tokens and check them for validity. At no moment, we are
- * allowed to reach a directory located "above" the root directory, stored
- * in "dir" property. We are also not allowed to enter a non existing
- * directory or a non directory component (plain file, symbolic link, ...).
- * An empty or null path is valid. Pathnames components are separated by
- * <code>File.separatorChar</code>
- *
- * @param resourceFileName the name to be checked for validity.
- * @return the canonical file pointed by the resourceFileName or null if the
- * walking failed
- * @throws IOException in case of issue when creating the canonical
- * resulting file
- * @see File#separatorChar
- */
- private File walkPathComponents(String resourceFileName) throws IOException
- {
- StringTokenizer stringTokenizer = new StringTokenizer(resourceFileName, File.separator);
- File currentFile = dir;
- int tokenCount = stringTokenizer.countTokens();
-
- for (int i = 0; i < tokenCount - 1; i++)
- {
- String currentToken = stringTokenizer.nextToken();
-
- // If we are at the root directory and trying to go up, the walking is
- // finished with an error
- if ("..".equals(currentToken) && currentFile.equals(dir))
- return null;
-
- currentFile = new File(currentFile, currentToken);
-
- // If the current file doesn't exist or is not a directory, the walking is
- // finished with an error
- if (! (currentFile.exists() && currentFile.isDirectory()))
- return null;
-
- }
-
- // Treat the last token differently, if it exists, because it does not need
- // to be a directory
- if (tokenCount > 0)
- {
- String currentToken = stringTokenizer.nextToken();
-
- if ("..".equals(currentToken) && currentFile.equals(dir))
- return null;
-
- currentFile = new File(currentFile, currentToken);
-
- // If the current file doesn't exist, the walking is
- // finished with an error
- if (! currentFile.exists())
- return null;
- }
-
- return currentFile.getCanonicalFile();
- }
- }
-
- static final class FileResource extends Resource
- {
- final File file;
-
- FileResource(FileURLLoader loader, File file)
- {
- super(loader);
- this.file = file;
- }
-
- InputStream getInputStream() throws IOException
- {
- return new FileInputStream(file);
- }
-
- public int getLength()
- {
- return (int) file.length();
- }
-
- public URL getURL()
- {
- try
- {
- return file.toURL();
- }
- catch (MalformedURLException e)
- {
- InternalError ie = new InternalError();
- ie.initCause(e);
- throw ie;
- }
- }
- }
-
- // Constructors
-
- /**
* Creates a URLClassLoader that gets classes from the supplied URLs.
* To determine if this classloader may be created the constructor of
* the super class (<code>SecureClassLoader</code>) is called first, which
@@ -774,14 +264,8 @@ public class URLClassLoader extends SecureClassLoader
this.factory = factory;
addURLs(urls);
- // If this factory is still not in factoryCache, add it,
- // since we only support three protocols so far, 5 is enough
- // for cache initial size
- synchronized (factoryCache)
- {
- if (factory != null && factoryCache.get(factory) == null)
- factoryCache.put(factory, new HashMap(5));
- }
+ // If this factory is still not in factoryCache, add it.
+ factoryCache.add(factory);
}
// Methods
@@ -806,72 +290,114 @@ public class URLClassLoader extends SecureClassLoader
// Reset the toString() value.
thisString = null;
- // Check global cache to see if there're already url loader
- // for this url.
- URLLoader loader = (URLLoader) urlloaders.get(newUrl);
- if (loader == null)
+ // Create a loader for this URL.
+ URLLoader loader = null;
+ String file = newUrl.getFile();
+ String protocol = newUrl.getProtocol();
+
+ // If we have a file: URL, we want to make it absolute
+ // here, before we decide whether it is really a jar.
+ URL absoluteURL;
+ if ("file".equals (protocol))
+ {
+ File dir = new File(file);
+ URL absUrl;
+ try
+ {
+ absoluteURL = dir.getCanonicalFile().toURL();
+ }
+ catch (IOException ignore)
+ {
+ try
+ {
+ absoluteURL = dir.getAbsoluteFile().toURL();
+ }
+ catch (MalformedURLException _)
+ {
+ // This really should not happen.
+ absoluteURL = newUrl;
+ }
+ }
+ }
+ else
{
- String file = newUrl.getFile();
- String protocol = newUrl.getProtocol();
+ // This doesn't hurt, and it simplifies the logic a
+ // little.
+ absoluteURL = newUrl;
+ }
- // If we have a file: URL, we want to make it absolute
- // here, before we decide whether it is really a jar.
- URL absoluteURL;
- if ("file".equals (protocol))
- {
- File dir = new File(file);
- URL absUrl;
- try
- {
- absoluteURL = dir.getCanonicalFile().toURL();
- }
- catch (IOException ignore)
- {
- try
- {
- absoluteURL = dir.getAbsoluteFile().toURL();
- }
- catch (MalformedURLException _)
- {
- // This really should not happen.
- absoluteURL = newUrl;
- }
- }
- }
- else
- {
- // This doesn't hurt, and it simplifies the logic a
- // little.
- absoluteURL = newUrl;
- }
+ // First see if we can find a handler with the correct name.
+ try
+ {
+ Class handler = Class.forName(URL_LOADER_PREFIX + protocol);
+ Class[] argTypes = new Class[] { URLClassLoader.class,
+ URLStreamHandlerCache.class,
+ URLStreamHandlerFactory.class,
+ URL.class,
+ URL.class };
+ Constructor k = handler.getDeclaredConstructor(argTypes);
+ loader
+ = (URLLoader) k.newInstance(new Object[] { this,
+ factoryCache,
+ factory,
+ newUrl,
+ absoluteURL });
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // Fall through.
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("couldn't find URLLoader constructor");
+ vme.initCause(nsme);
+ throw vme;
+ }
+ catch (InstantiationException inste)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("couldn't instantiate URLLoader");
+ vme.initCause(inste);
+ throw vme;
+ }
+ catch (InvocationTargetException ite)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("error instantiating URLLoader");
+ vme.initCause(ite);
+ throw vme;
+ }
+ catch (IllegalAccessException illae)
+ {
+ // Programming error in the class library.
+ InternalError vme
+ = new InternalError("invalid access to URLLoader");
+ vme.initCause(illae);
+ throw vme;
+ }
- // Check that it is not a directory
+ if (loader == null)
+ {
+ // If it is not a directory, use the jar loader.
if (! (file.endsWith("/") || file.endsWith(File.separator)))
- loader = new JarURLLoader(this, newUrl, absoluteURL);
+ loader = new JarURLLoader(this, factoryCache, factory,
+ newUrl, absoluteURL);
else if ("file".equals(protocol))
- loader = new FileURLLoader(this, newUrl, absoluteURL);
+ loader = new FileURLLoader(this, factoryCache, factory,
+ newUrl, absoluteURL);
else
- loader = new RemoteURLLoader(this, newUrl);
-
- // Cache it.
- urlloaders.put(newUrl, loader);
+ loader = new RemoteURLLoader(this, factoryCache, factory,
+ newUrl);
}
urlinfos.add(loader);
-
- Vector extraUrls = loader.getClassPath();
- if (extraUrls != null)
- {
- Iterator it = extraUrls.iterator();
- while (it.hasNext())
- {
- URL url = (URL)it.next();
- URLLoader extraLoader = (URLLoader) urlloaders.get(url);
- if (! urlinfos.contains (extraLoader))
- addURLImpl(url);
- }
- }
-
+ ArrayList extra = loader.getClassPath();
+ if (extra != null)
+ urlinfos.addAll(extra);
}
}
@@ -987,7 +513,20 @@ public class URLClassLoader extends SecureClassLoader
{
// Just try to find the resource by the (almost) same name
String resourceName = className.replace('.', '/') + ".class";
- Resource resource = findURLResource(resourceName);
+ int max = urlinfos.size();
+ Resource resource = null;
+ for (int i = 0; i < max && resource == null; i++)
+ {
+ URLLoader loader = (URLLoader)urlinfos.elementAt(i);
+ if (loader == null)
+ continue;
+
+ Class k = loader.getClass(className);
+ if (k != null)
+ return k;
+
+ resource = loader.getResource(resourceName);
+ }
if (resource == null)
throw new ClassNotFoundException(className + " not found in " + this);
@@ -1049,12 +588,13 @@ public class URLClassLoader extends SecureClassLoader
if (packageName != null && getPackage(packageName) == null)
{
// define the package
- Manifest manifest = resource.loader.getManifest();
+ Manifest manifest = resource.getLoader().getManifest();
if (manifest == null)
definePackage(packageName, null, null, null, null, null, null,
null);
else
- definePackage(packageName, manifest, resource.loader.baseURL);
+ definePackage(packageName, manifest,
+ resource.getLoader().getBaseURL());
}
// And finally construct the class!
@@ -1166,34 +706,6 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * If the URLStreamHandlerFactory has been set this return the appropriate
- * URLStreamHandler for the given protocol, if not set returns null.
- *
- * @param protocol the protocol for which we need a URLStreamHandler
- * @return the appropriate URLStreamHandler or null
- */
- URLStreamHandler getURLStreamHandler(String protocol)
- {
- if (factory == null)
- return null;
-
- URLStreamHandler handler;
- synchronized (factoryCache)
- {
- // Check if there're handler for the same protocol in cache.
- HashMap cache = (HashMap) factoryCache.get(factory);
- handler = (URLStreamHandler) cache.get(protocol);
- if (handler == null)
- {
- // Add it to cache.
- handler = factory.createURLStreamHandler(protocol);
- cache.put(protocol, handler);
- }
- }
- return handler;
- }
-
- /**
* Finds all the resources with a particular name from all the locations.
*
* @param resourceName the name of the resource to lookup
diff --git a/libjava/classpath/java/net/URLConnection.java b/libjava/classpath/java/net/URLConnection.java
index 1f78dd8e8dd..28142b10aad 100644
--- a/libjava/classpath/java/net/URLConnection.java
+++ b/libjava/classpath/java/net/URLConnection.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.net;
-import gnu.classpath.NotImplementedException;
import gnu.classpath.SystemProperties;
import java.io.IOException;
@@ -173,6 +172,11 @@ public abstract class URLConnection
private static SimpleDateFormat[] dateFormats;
private static boolean dateformats_initialized;
+
+ /**
+ * The timeout period.
+ */
+ private int timeout;
/* Cached ParsePosition, used when parsing dates. */
private ParsePosition position;
@@ -212,6 +216,38 @@ public abstract class URLConnection
}
/**
+ * Returns the connection timeout speed, in milliseconds, or zero if the timeout
+ * is infinite or not set.
+ *
+ * @return The timeout.
+ *
+ * @since 1.5
+ */
+ public int getConnectTimeout()
+ {
+ return timeout;
+ }
+
+ /**
+ * Set the connection timeout speed, in milliseconds, or zero if the timeout
+ * is to be considered infinite. Note that in certain socket
+ * implementations/platforms this method may not have any effect.
+ *
+ * Throws an <code>IllegalArgumentException</code> if timeout < 0.
+ *
+ * @param timeout - The timeout, in milliseconds.
+ *
+ * @since 1.5
+ */
+ public void setConnectTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ if( timeout < 0 )
+ throw new IllegalArgumentException("Timeout must be 0 or positive.");
+ this.timeout = timeout;
+ }
+
+ /**
* Returns the value of the content-length header field or -1 if the value
* is not known or not present.
*
@@ -934,11 +970,12 @@ public abstract class URLConnection
* @exception IOException If an error occurs
*/
public static String guessContentTypeFromStream(InputStream is)
- throws IOException, NotImplementedException
+ throws IOException
{
- // See /etc/gnome-vfs-mime-magic or /etc/mime-magic for a reasonable
- // idea of how to handle this.
- return "application/octet-stream";
+ String result = VMURLConnection.guessContentTypeFromStream(is);
+ if (result == null)
+ return "application/octet-stream";
+ return result;
}
/**
diff --git a/libjava/classpath/java/net/URLStreamHandler.java b/libjava/classpath/java/net/URLStreamHandler.java
index ed95092219e..9a5d73ad0d0 100644
--- a/libjava/classpath/java/net/URLStreamHandler.java
+++ b/libjava/classpath/java/net/URLStreamHandler.java
@@ -369,13 +369,11 @@ public abstract class URLStreamHandler
}
/**
- * Provides the default equals calculation. May be overidden by handlers for
- * other protocols that have different requirements for equals(). This method
- * requires that none of its arguments is null. This is guaranteed by the
- * fact that it is only called by java.net.URL class.
+ * This is the default method for computing whether two URLs are
+ * equivalent. This method assumes that neither URL is null.
*
* @param url1 An URL object
- * @param url2 An URL object
+ * @param url2 Another URL object
*
* @return True if both given URLs are equal, false otherwise.
*/
@@ -383,16 +381,21 @@ public abstract class URLStreamHandler
{
// This comparison is very conservative. It assumes that any
// field can be null.
- return (url1.getPort() == url2.getPort()
+ int port1 = url1.getPort();
+ if (port1 == -1)
+ port1 = url1.getDefaultPort();
+ int port2 = url2.getPort();
+ if (port2 == -1)
+ port2 = url2.getDefaultPort();
+ // Note that we don't bother checking the 'authority'; it is
+ // redundant.
+ return (port1 == port2
&& ((url1.getProtocol() == null && url2.getProtocol() == null)
|| (url1.getProtocol() != null
&& url1.getProtocol().equals(url2.getProtocol())))
&& ((url1.getUserInfo() == null && url2.getUserInfo() == null)
|| (url1.getUserInfo() != null
&& url1.getUserInfo().equals(url2.getUserInfo())))
- && ((url1.getAuthority() == null && url2.getAuthority() == null)
- || (url1.getAuthority() != null
- && url1.getAuthority().equals(url2.getAuthority())))
&& ((url1.getHost() == null && url2.getHost() == null)
|| (url1.getHost() != null && url1.getHost().equals(url2.getHost())))
&& ((url1.getPath() == null && url2.getPath() == null)
diff --git a/libjava/classpath/java/nio/CharBuffer.java b/libjava/classpath/java/nio/CharBuffer.java
index 6551555e20b..356a920eea0 100644
--- a/libjava/classpath/java/nio/CharBuffer.java
+++ b/libjava/classpath/java/nio/CharBuffer.java
@@ -107,14 +107,12 @@ public abstract class CharBuffer extends Buffer
{
// FIXME: implement better handling of java.lang.String.
// Probably share data with String via reflection.
-
- if ((start < 0)
- || (start > seq.length())
- || (end < start)
- || (end > (seq.length() - start)))
- throw new IndexOutOfBoundsException();
-
+
int len = end - start;
+
+ if( len < 0 )
+ throw new IndexOutOfBoundsException();
+
char[] buffer = new char[len];
for (int i = 0; i < len; i++)
diff --git a/libjava/classpath/java/nio/DirectByteBufferImpl.java b/libjava/classpath/java/nio/DirectByteBufferImpl.java
index 53bb668aacf..3a9036f3148 100644
--- a/libjava/classpath/java/nio/DirectByteBufferImpl.java
+++ b/libjava/classpath/java/nio/DirectByteBufferImpl.java
@@ -232,6 +232,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
private ByteBuffer duplicate(boolean readOnly)
{
int pos = position();
+ if (this.mark != -1)
reset();
int mark = position();
position(pos);
diff --git a/libjava/classpath/java/nio/channels/FileChannel.java b/libjava/classpath/java/nio/channels/FileChannel.java
index 0eefffbe97b..3aa19990917 100644
--- a/libjava/classpath/java/nio/channels/FileChannel.java
+++ b/libjava/classpath/java/nio/channels/FileChannel.java
@@ -114,12 +114,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
*/
public final long write(ByteBuffer[] srcs) throws IOException
{
- long result = 0;
-
- for (int i = 0; i < srcs.length; i++)
- result += write(srcs[i]);
-
- return result;
+ return write(srcs, 0, srcs.length);
}
/**
@@ -169,12 +164,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
*/
public final long read(ByteBuffer[] dsts) throws IOException
{
- long result = 0;
-
- for (int i = 0; i < dsts.length; i++)
- read(dsts[i]);
-
- return result;
+ return read(dsts, 0, dsts.length);
}
/**
diff --git a/libjava/classpath/java/nio/channels/SelectionKey.java b/libjava/classpath/java/nio/channels/SelectionKey.java
index 5219b6bff84..9723faf5262 100644
--- a/libjava/classpath/java/nio/channels/SelectionKey.java
+++ b/libjava/classpath/java/nio/channels/SelectionKey.java
@@ -1,5 +1,5 @@
/* SelectionKey.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public abstract class SelectionKey
/**
* Attaches obj to the key and returns the old attached object.
*/
- public final Object attach(Object obj)
+ public final synchronized Object attach(Object obj)
{
Object old = attached;
attached = obj;
@@ -70,7 +70,7 @@ public abstract class SelectionKey
/**
* Returns the object attached to the key.
*/
- public final Object attachment()
+ public final synchronized Object attachment()
{
return attached;
}
diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java b/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
index 5ab8468bf2e..02d09ce10ad 100644
--- a/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
+++ b/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
@@ -1,5 +1,5 @@
/* AbstractSelectionKey.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,7 +57,7 @@ public abstract class AbstractSelectionKey extends SelectionKey
/**
* Cancels this key.
*/
- public final void cancel()
+ public final synchronized void cancel()
{
if (isValid())
{
@@ -71,7 +71,7 @@ public abstract class AbstractSelectionKey extends SelectionKey
*
* @return true if this key is valid, false otherwise
*/
- public final boolean isValid()
+ public final synchronized boolean isValid()
{
return ! cancelled;
}
diff --git a/libjava/classpath/java/rmi/server/UID.java b/libjava/classpath/java/rmi/server/UID.java
index 35963042211..940339e813a 100644
--- a/libjava/classpath/java/rmi/server/UID.java
+++ b/libjava/classpath/java/rmi/server/UID.java
@@ -94,23 +94,23 @@ public final class UID
* The time stamp, when the UID was created.
*/
private long time;
-
+
/**
* Create the new UID that would have the described features of the
* uniqueness.
*/
public UID()
{
- time = System.currentTimeMillis();
- unique = machineId;
- if (time > last)
- {
- last = time;
- count = uidCounter = Short.MIN_VALUE;
- }
- else
+ synchronized (UID.class)
{
- synchronized (UID.class)
+ time = System.currentTimeMillis();
+ unique = machineId;
+ if (time > last)
+ {
+ last = time;
+ count = uidCounter = Short.MIN_VALUE;
+ }
+ else
{
if (uidCounter == Short.MAX_VALUE)
{
@@ -126,8 +126,7 @@ public final class UID
uidCounter = Short.MIN_VALUE;
time = last = System.currentTimeMillis();
}
-
- count = uidCounter++;
+ count = ++uidCounter;
}
}
}
@@ -210,7 +209,7 @@ public final class UID
^ hostIpHash;
}
- /**
+ /**
* Get the string representation of this UID.
*
* @return a string, uniquely identifying this id.
@@ -219,9 +218,8 @@ public final class UID
{
int max = Character.MAX_RADIX;
// Translate into object count, counting from 0.
- long lc = (count + Short.MIN_VALUE) & 0xFFFF;
- return Long.toString(time, max) + ":"
- + Long.toString(unique, max) + ":"
+ long lc = (count - Short.MIN_VALUE) & 0xFFFF;
+ return Long.toString(unique, max) + ":" + Long.toString(time, max) + "."
+ Long.toString(lc, max);
}
}
diff --git a/libjava/classpath/java/security/Provider.java b/libjava/classpath/java/security/Provider.java
index 4ffaa55bcb1..ea1dd9d3ff2 100644
--- a/libjava/classpath/java/security/Provider.java
+++ b/libjava/classpath/java/security/Provider.java
@@ -1,5 +1,5 @@
/* Provider.java -- Security provider information
- Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,20 +41,19 @@ import java.io.Serializable;
import java.util.Properties;
/**
- * This class represents a Java security architecture service provider.
- * The services provided by a such a provider can range from security
- * algorithms to key generation.
+ * This class represents a Java security architecture service provider. The
+ * services provided by a such a provider can range from security algorithms to
+ * key generation.
* <p>
- * Providers are installed by name and version number. There is one
- * standard provider supplied with the class library. This is the
- * "GNU" provider, which can also be accessed by the alias "SUN" for
- * compatibility with the JDK.
- *
- * @version 0.0
- *
+ * Providers are installed by name and version number. See the static
+ * initializer of the {@link java.security.Security} class for the default
+ * security providers installed by this class library.
+ *
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public abstract class Provider extends Properties implements Serializable
+public abstract class Provider
+ extends Properties
+ implements Serializable
{
private static final long serialVersionUID = -4298000515446427739L;
@@ -119,36 +118,34 @@ public abstract class Provider extends Properties implements Serializable
}
/**
- * Sets the key property to have the specified value.
+ * Maps a key property to a designated value.
* <p>
- * <bold>NOT IMPLEMENTED YET</bold>[
- * First, if there is a security manager, its <code>checkSecurityAccess</code>
- * method is called with the string "putProviderProperty."+name, where name is
- * the provider name, to see if it's ok to set this provider's property
- * values.
- * If the default implementation of <code>checkSecurityAccess</code> is used
- * (that is, that method is not overriden), then this results in a call to the
- * security manager's <code>checkPermission</code> method with a
- * <code>SecurityPermission("putProviderProperty."+name)</code>
- * permission.<br>]
- *
+ * If there is an installed {@link SecurityManager} object in the underlying
+ * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is
+ * called with the string <code>"putProviderProperty." + name</code>, where
+ * <code>name</code> is this provider's name. For the default implementation
+ * this translates into a {@link SecurityManager#checkPermission(Permission)}
+ * for a <code>SecurityPermission("putProviderProperty." + name)</code>.
+ *
* @param key The property key.
* @param value The property value.
- *
* @return The previous value of the specified property (<code>key</code>),
* or <code>null</code> if it did not have one.
- * @throws SecurityException If a security manager exists and its
- * {@link java.lang.SecurityManager.checkSecurityAccess(java.lang.String)}
- * method denies access to set property values.
+ * @throws SecurityException If a security manager is installed and its
+ * {@link SecurityManager#checkSecurityAccess(String)} method
+ * disallows adding properties at run-time.
* @since Classpath 0.4+cvs, JDK 1.2
- * @see java.lang.Object.equals(Object)
- * @see java.util.Hashtable.get(Object)
+ * @see java.lang.Object#equals(Object)
+ * @see java.util.Hashtable#get(Object)
*/
public Object put(Object key, Object value)
{
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("putProviderProperty." + this.name);
return super.put(toCanonicalKey(key), value);
}
-
+
// overrides same in java.util.Hashtable
public Object get(Object key)
{
@@ -157,25 +154,45 @@ public abstract class Provider extends Properties implements Serializable
/**
* This method removes the specified key entry (and its associated value)
- * from the property mapping list.
+ * from the property mapping collection.
+ * <p>
+ * If there is an installed {@link SecurityManager} object in the underlying
+ * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is
+ * called with the string <code>"removeProviderProperty." + name</code>, where
+ * <code>name</code> is this provider's name. For the default implementation
+ * this translates into a {@link SecurityManager#checkPermission(Permission)}
+ * for a <code>SecurityPermission("removeProviderProperty." + name)</code>.
*
* @param key The key to remove
- *
* @return The previous value for this key, or <code>null</code> if no
* previous value.
*/
public Object remove(Object key)
{
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("removeProviderProperty." + this.name);
return super.remove(toCanonicalKey(key));
}
/**
- * This method clears the entire property list such that it no longer
+ * This method clears the entire property collection such that it no longer
* contains the properties used to look up the services provided by
- * the <code>Provider</code>.
+ * this <code>Provider</code>.
+ * <p>
+ * If there is an installed {@link SecurityManager} object in the underlying
+ * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is
+ * called with the string <code>"clearProviderProperties." + name</code>,
+ * where <code>name</code> is this provider's name. For the default
+ * implementation this translates into a
+ * {@link SecurityManager#checkPermission(Permission)} for a
+ * <code>SecurityPermission("clearProviderProperties." + name)</code>.
*/
public void clear()
{
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("clearProviderProperties." + this.name);
super.clear();
}
@@ -191,12 +208,11 @@ public abstract class Provider extends Properties implements Serializable
return (getClass().getName() + ": name=" + getName() + " version=" +
version);
}
-
+
private Object toCanonicalKey(Object key)
{
if (key.getClass().isAssignableFrom(String.class)) // is it ours?
return ((String) key).toUpperCase(); // use default locale
- else
- return key;
+ return key;
}
}
diff --git a/libjava/classpath/java/security/SecureRandom.java b/libjava/classpath/java/security/SecureRandom.java
index d403d496428..c66963e8f96 100644
--- a/libjava/classpath/java/security/SecureRandom.java
+++ b/libjava/classpath/java/security/SecureRandom.java
@@ -374,14 +374,9 @@ public class SecureRandom extends Random
if (numBits == 0)
return 0;
- byte[] tmp = new byte[numBits / 8 + (1 * (numBits % 8))];
-
- secureRandomSpi.engineNextBytes(tmp);
- randomBytesUsed += tmp.length;
- counter++;
-
+ byte[] tmp = new byte[(numBits + 7) / 8];
+ this.nextBytes(tmp);
int ret = 0;
-
for (int i = 0; i < tmp.length; i++)
ret |= (tmp[i] & 0xFF) << (8 * i);
diff --git a/libjava/classpath/java/security/UnresolvedPermission.java b/libjava/classpath/java/security/UnresolvedPermission.java
index d3f671a9c06..449454aaf85 100644
--- a/libjava/classpath/java/security/UnresolvedPermission.java
+++ b/libjava/classpath/java/security/UnresolvedPermission.java
@@ -201,6 +201,47 @@ public final class UnresolvedPermission extends Permission
{
return new UnresolvedPermissionCollection();
}
+
+ /**
+ * Return the name of the class of the unresolved permission.
+ * @since 1.5
+ */
+ public String getUnresolvedType()
+ {
+ return type;
+ }
+
+ /**
+ * Return the name of the unresolved permission.
+ * @since 1.5
+ */
+ public String getUnresolvedName()
+ {
+ return name;
+ }
+
+ /**
+ * Return the actions of the unresolved permission, or null
+ * if there are no actions.
+ * @since 1.5
+ */
+ public String getUnresolvedActions()
+ {
+ return actions;
+ }
+
+ /**
+ * Return the certificates of the unresolved permission.
+ * If there are no certificates, null is returned. Otherwise,
+ * a new array is returned.
+ * @since 1.5
+ */
+ public Certificate[] getUnresolvedCerts()
+ {
+ if (certs == null)
+ return null;
+ return (Certificate[]) certs.clone();
+ }
} // class UnresolvedPermission
/**
diff --git a/libjava/classpath/java/security/cert/X509CertSelector.java b/libjava/classpath/java/security/cert/X509CertSelector.java
index a46d2288b8d..175e4c673c9 100644
--- a/libjava/classpath/java/security/cert/X509CertSelector.java
+++ b/libjava/classpath/java/security/cert/X509CertSelector.java
@@ -695,7 +695,7 @@ public class X509CertSelector implements CertSelector, Cloneable
if (altNames == null)
altNames = new LinkedList();
ArrayList l = new ArrayList(2);
- l.add(new Integer(id));
+ l.add(Integer.valueOf(id));
l.add(name);
altNames.add(l);
}
@@ -714,7 +714,7 @@ public class X509CertSelector implements CertSelector, Cloneable
if (altNames == null)
altNames = new LinkedList();
ArrayList l = new ArrayList(2);
- l.add(new Integer(id));
+ l.add(Integer.valueOf(id));
l.add(name);
altNames.add(l);
}
diff --git a/libjava/classpath/java/text/AttributedString.java b/libjava/classpath/java/text/AttributedString.java
index c751ab43cf8..497b557fcf3 100644
--- a/libjava/classpath/java/text/AttributedString.java
+++ b/libjava/classpath/java/text/AttributedString.java
@@ -221,16 +221,13 @@ public class AttributedString
// If the attribute run starts before the beginning index, we
// need to junk it if it is an Annotation.
Object attrib_obj = aci.getAttribute(attrib);
- if (rs < begin)
+ rs -= begin;
+ if (rs < 0)
{
if (attrib_obj instanceof Annotation)
continue;
- rs = begin;
- }
- else
- {
- rs -= begin;
+ rs = 0;
}
// Create a map object. Yes this will only contain one attribute
@@ -243,7 +240,7 @@ public class AttributedString
c = aci.next();
}
- while(c != CharacterIterator.DONE);
+ while( aci.getIndex() < end );
attribs = new AttributeRange[accum.size()];
attribs = (AttributeRange[]) accum.toArray(attribs);
diff --git a/libjava/classpath/java/util/Arrays.java b/libjava/classpath/java/util/Arrays.java
index 29134467b2b..1fa59594193 100644
--- a/libjava/classpath/java/util/Arrays.java
+++ b/libjava/classpath/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.
@@ -97,7 +97,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final byte d = a[mid];
if (d == key)
return mid;
@@ -131,7 +131,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final char d = a[mid];
if (d == key)
return mid;
@@ -165,7 +165,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final short d = a[mid];
if (d == key)
return mid;
@@ -199,7 +199,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final int d = a[mid];
if (d == key)
return mid;
@@ -233,7 +233,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final long d = a[mid];
if (d == key)
return mid;
@@ -268,7 +268,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final int r = Float.compare(a[mid], key);
if (r == 0)
return mid;
@@ -303,7 +303,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final int r = Double.compare(a[mid], key);
if (r == 0)
return mid;
@@ -369,7 +369,7 @@ public class Arrays
int mid = 0;
while (low <= hi)
{
- mid = (low + hi) >> 1;
+ mid = (low + hi) >>> 1;
final int d = Collections.compare(key, a[mid], c);
if (d == 0)
return mid;
@@ -2341,8 +2341,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/libjava/classpath/java/util/Calendar.java b/libjava/classpath/java/util/Calendar.java
index a324f5adabf..d4bbcd08e76 100644
--- a/libjava/classpath/java/util/Calendar.java
+++ b/libjava/classpath/java/util/Calendar.java
@@ -877,6 +877,7 @@ public abstract class Calendar implements Serializable, Cloneable
1, 1970, JANUARY, 1, 1, 1, 1, THURSDAY, 1, AM, 0, 0, 0,
0, 0, zone.getRawOffset(), 0
};
+ complete();
isTimeSet = false;
areFieldsSet = false;
isSet[field] = false;
diff --git a/libjava/classpath/java/util/Collections.java b/libjava/classpath/java/util/Collections.java
index dc37bad8a93..a2538cf1db8 100644
--- a/libjava/classpath/java/util/Collections.java
+++ b/libjava/classpath/java/util/Collections.java
@@ -1,5 +1,5 @@
/* Collections.java -- Utility class with methods to operate on collections
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -655,7 +655,7 @@ public class Collections
boolean forward = true;
while (low <= hi)
{
- pos = (low + hi) >> 1;
+ pos = (low + hi) >>> 1;
if (i < pos)
{
if (!forward)
@@ -684,7 +684,7 @@ public class Collections
{
while (low <= hi)
{
- pos = (low + hi) >> 1;
+ pos = (low + hi) >>> 1;
final int d = compare(l.get(pos), key, c);
if (d == 0)
return pos;
@@ -4817,6 +4817,87 @@ public class Collections
private static final class UnmodifiableEntrySet extends UnmodifiableSet
implements Serializable
{
+ // Unmodifiable implementation of Map.Entry used as return value for
+ // UnmodifiableEntrySet accessors (iterator, toArray, toArray(Object[]))
+ private static final class UnmodifiableMapEntry
+ implements Map.Entry
+ {
+ private final Map.Entry e;
+
+ private UnmodifiableMapEntry(Map.Entry e)
+ {
+ super();
+ this.e = e;
+ }
+
+ /**
+ * Returns <code>true</code> if the object, o, is also a map entry
+ * with an identical key and value.
+ *
+ * @param o the object to compare.
+ * @return <code>true</code> if o is an equivalent map entry.
+ */
+ public boolean equals(Object o)
+ {
+ return e.equals(o);
+ }
+
+ /**
+ * Returns the key of this map entry.
+ *
+ * @return the key.
+ */
+ public Object getKey()
+ {
+ return e.getKey();
+ }
+
+ /**
+ * Returns the value of this map entry.
+ *
+ * @return the value.
+ */
+ public Object getValue()
+ {
+ return e.getValue();
+ }
+
+ /**
+ * Computes the hash code of this map entry. The computation is
+ * described in the <code>Map</code> interface documentation.
+ *
+ * @return the hash code of this entry.
+ * @see Map#hashCode()
+ */
+ public int hashCode()
+ {
+ return e.hashCode();
+ }
+
+ /**
+ * Blocks the alteration of the value of this map entry. This method
+ * never returns, throwing an exception instead.
+ *
+ * @param value The new value.
+ * @throws UnsupportedOperationException as an unmodifiable map entry
+ * does not support the <code>setValue()</code> operation.
+ */
+ public Object setValue(Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns a textual representation of the map entry.
+ *
+ * @return The map entry as a <code>String</code>.
+ */
+ public String toString()
+ {
+ return e.toString();
+ }
+ }
+
/**
* Compatible with JDK 1.4.
*/
@@ -4846,80 +4927,46 @@ public class Collections
public Object next()
{
final Map.Entry e = (Map.Entry) super.next();
- return new Map.Entry()
- {
- /**
- * Returns <code>true</code> if the object, o, is also a map entry with an
- * identical key and value.
- *
- * @param o the object to compare.
- * @return <code>true</code> if o is an equivalent map entry.
- */
- public boolean equals(Object o)
- {
- return e.equals(o);
- }
-
- /**
- * Returns the key of this map entry.
- *
- * @return the key.
- */
- public Object getKey()
- {
- return e.getKey();
- }
+ return new UnmodifiableMapEntry(e);
+ }
+ };
+ }
- /**
- * Returns the value of this map entry.
- *
- * @return the value.
- */
- public Object getValue()
- {
- return e.getValue();
- }
+ // The array returned is an array of UnmodifiableMapEntry instead of
+ // Map.Entry
+ public Object[] toArray()
+ {
+ Object[] mapEntryResult = super.toArray();
+ UnmodifiableMapEntry result[] = null;
- /**
- * Computes the hash code of this map entry.
- * The computation is described in the <code>Map</code>
- * interface documentation.
- *
- * @return the hash code of this entry.
- * @see Map#hashCode()
- */
- public int hashCode()
+ if (mapEntryResult != null)
+ {
+ result = new UnmodifiableMapEntry[mapEntryResult.length];
+ for (int i = 0; i < mapEntryResult.length; i++)
{
- return e.hashCode();
+ Map.Entry r = (Map.Entry) mapEntryResult[i];
+ result[i] = new UnmodifiableMapEntry(r);
}
+ }
+ return result;
+ }
- /**
- * Blocks the alteration of the value of this map entry.
- * This method never returns, throwing an exception instead.
- *
- * @param value The new value.
- * @throws UnsupportedOperationException as an unmodifiable
- * map entry does not support the <code>setValue()</code>
- * operation.
- */
- public Object setValue(Object value)
- {
- throw new UnsupportedOperationException();
- }
+ // The array returned is an array of UnmodifiableMapEntry instead of
+ // Map.Entry
+ public Object[] toArray(Object[] array)
+ {
+ super.toArray(array);
- /**
- * Returns a textual representation of the map entry.
- *
- * @return The map entry as a <code>String</code>.
- */
- public String toString()
+ if (array != null)
+ {
+ for (int i = 0; i < array.length; i++)
{
- return e.toString();
+ array[i] = new UnmodifiableMapEntry((Map.Entry) array[i]);
}
- };
}
- };
+ return array;
}
+
} // class UnmodifiableEntrySet
/**
diff --git a/libjava/classpath/java/util/DuplicateFormatFlagsException.java b/libjava/classpath/java/util/DuplicateFormatFlagsException.java
new file mode 100644
index 00000000000..c180605cdc5
--- /dev/null
+++ b/libjava/classpath/java/util/DuplicateFormatFlagsException.java
@@ -0,0 +1,88 @@
+/* DuplicateFormatFlagsException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the flags supplied to the {@link Formatter#format()}
+ * method of a {@link Formatter} contain duplicates.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class DuplicateFormatFlagsException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 18890531L;
+
+ /**
+ * The flags which contain a duplicate.
+ *
+ * @serial the flags containing a duplicate.
+ */
+ // Note: name fixed by serialization.
+ private String flags;
+
+ /**
+ * Constructs a new <code>DuplicateFormatFlagsException</code>
+ * which specifies that the supplied set of flags contains a
+ * duplicate.
+ *
+ * @param flags the flags containing a duplicate.
+ * @throws NullPointerException if <code>flags</code> is null.
+ */
+ public DuplicateFormatFlagsException(String flags)
+ {
+ super("Duplicate flag passed in " + flags);
+ if (flags == null)
+ throw new
+ NullPointerException("Null flags value passed to constructor.");
+ this.flags = flags;
+ }
+
+ /**
+ * Returns the flags which contain a duplicate.
+ *
+ * @return the flags.
+ */
+ public String getFlags()
+ {
+ return flags;
+ }
+}
diff --git a/libjava/classpath/java/util/FormatFlagsConversionMismatchException.java b/libjava/classpath/java/util/FormatFlagsConversionMismatchException.java
new file mode 100644
index 00000000000..ec317730503
--- /dev/null
+++ b/libjava/classpath/java/util/FormatFlagsConversionMismatchException.java
@@ -0,0 +1,111 @@
+/* FormatFlagsConversionMismatchException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the flags supplied to the {@link Formatter#format()}
+ * method of a {@link Formatter} contains a flag that does not match
+ * the conversion character specified for it.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class FormatFlagsConversionMismatchException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 19120414L;
+
+ /**
+ * The mismatching flag.
+ *
+ * @serial the mismatching flag.
+ */
+ // Note: name fixed by serialization.
+ private String f;
+
+ /**
+ * The conversion character which doesn't match the
+ * appropriate flag.
+ *
+ * @serial the conversion character which doesn't match its flag.
+ */
+ // Note: name fixed by serialization.
+ private char c;
+
+ /**
+ * Constructs a new <code>FormatFlagsConversionMismatchException</code>
+ * which specifies that the flag, <code>f</code>, does
+ * not match its appropriate conversion character, <code>c</code>.
+ *
+ * @param f the mismatching flag.
+ * @param c the conversion character which doesn't match its flag.
+ * @throws NullPointerException if <code>f</code> is null.
+ */
+ public FormatFlagsConversionMismatchException(String f, char c)
+ {
+ super("Invalid flag " + f + " for conversion " + c);
+ if (f == null)
+ throw new
+ NullPointerException("Null flag value passed to constructor.");
+ this.f = f;
+ this.c = c;
+ }
+
+ /**
+ * Returns the conversion character which doesn't
+ * match the flag.
+ *
+ * @return the conversion character.
+ */
+ public char getConversion()
+ {
+ return c;
+ }
+
+ /**
+ * Returns the mismatching flag.
+ *
+ * @return the mismatching flag.
+ */
+ public String getFlags()
+ {
+ return f;
+ }
+}
diff --git a/libjava/classpath/java/util/Formattable.java b/libjava/classpath/java/util/Formattable.java
new file mode 100644
index 00000000000..27e26a701e4
--- /dev/null
+++ b/libjava/classpath/java/util/Formattable.java
@@ -0,0 +1,92 @@
+/* Formattable.java -- Objects which can be passed to a Formatter
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * <p>
+ * The <code>Formattable</code> interface is used to provide customised
+ * formatting to arbitrary objects via the {@link Formatter}. The
+ * {@link #formatTo} method is called for <code>Formattable</code>
+ * objects used with the 's' conversion operator, allowing the object
+ * to provide its own formatting of its internal data.
+ * </p>
+ * <p>
+ * Thread safety is left up to the implementing class. Thus,
+ * {@link Formattable} objects are not guaranteed to be thread-safe,
+ * and users should make their own provisions for multiple thread access.
+ * </p>
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface Formattable
+{
+
+ /**
+ * Formats the object using the supplied formatter to the specification
+ * provided by the given flags, width and precision.
+ *
+ * @param formatter the formatter to use for formatting the object.
+ * The formatter gives access to the output stream
+ * and locale via {@link Formatter#out()} and
+ * {@link Formatter#locale()} respectively.
+ * @param flags a bit mask constructed from the flags in the
+ * {@link FormattableFlags} class. When no flags
+ * are set, the implementing class should use its
+ * defaults.
+ * @param width the minimum number of characters to include.
+ * A value of -1 indicates no minimum. The remaining
+ * space is padded with ' ' either on the left
+ * (the default) or right (if left justification is
+ * specified by the flags).
+ * @param precision the maximum number of characters to include.
+ * A value of -1 indicates no maximum. This value
+ * is applied prior to the minimum (the width). Thus,
+ * a value may meet the minimum width initially, but
+ * not when the width value is applied, due to
+ * characters being removed by the precision value.
+ * @throws IllegalFormatException if there is a problem with
+ * the syntax of the format
+ * specification or a mismatch
+ * between it and the arguments.
+ */
+ public void formatTo(Formatter formatter, int flags, int width,
+ int precision);
+}
diff --git a/libjava/classpath/java/util/FormattableFlags.java b/libjava/classpath/java/util/FormattableFlags.java
new file mode 100644
index 00000000000..648b3c03839
--- /dev/null
+++ b/libjava/classpath/java/util/FormattableFlags.java
@@ -0,0 +1,123 @@
+/* FormattableFlags.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * This class contains a set of flags used
+ * by the {@link Formattable#formatTo()} method.
+ * They are used to modify the output of the
+ * {@link Formattable}. The interpretation and
+ * validation of the flags is left to the
+ * particular {@link Formattable}.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class FormattableFlags
+{
+
+ /**
+ * Requires the output to be left-justified. Any spaces
+ * required to meet the specified width will be added to
+ * the right of the output. The default output is
+ * right-justified, where spaces are added to the left.
+ * The output is as for the format specifier
+ * '-' ('\u002d').
+ */
+ public static final int LEFT_JUSTIFY = 1;
+
+ /**
+ * Requires the output to be in uppercase. The output
+ * should be the same as the result from calling
+ * {@link String#toUpperCase(java.util.Locale)} with
+ * the formatting locale. The output is as for the
+ * format specifier '^' ('\u005e').
+ */
+ public static final int UPPERCASE = 2;
+
+ /**
+ * Requires the use of an alternate form, as specified
+ * in the documentation of {@link Formattable}.
+ * The output is as for the format specifier
+ * '#' ('\u0023').
+ */
+ public static final int ALTERNATE = 4;
+
+ // Used internally by Formatter.
+ // Changes here must be reflected in the FLAGS string there.
+
+ /**
+ * Requires the output to always include a '+' sign.
+ * The output is as for the format specifier '+'.
+ */
+ static final int PLUS = 8;
+
+ /**
+ * Requires the output to include a leading space on
+ * positive value. The output is as for the format
+ * specifier ' '.
+ */
+ static final int SPACE = 16;
+
+ /**
+ * Requires the output to be zero-padded. The output
+ * is as for the format specifier '0'.
+ */
+ static final int ZERO = 32;
+
+ /**
+ * Requires the output to include locale-specific
+ * grouping operators. The output is as for the
+ * format specifier ','.
+ */
+ static final int COMMA = 64;
+
+ /**
+ * Requires the output to include negative numbers
+ * enclosed in parentheses. The output is as for
+ * the format specifier '('.
+ */
+ static final int PAREN = 128;
+
+ // Not instantiable.
+ private FormattableFlags()
+ {
+ }
+}
diff --git a/libjava/classpath/java/util/Formatter.java b/libjava/classpath/java/util/Formatter.java
new file mode 100644
index 00000000000..01d54631508
--- /dev/null
+++ b/libjava/classpath/java/util/Formatter.java
@@ -0,0 +1,1294 @@
+/* Formatter.java -- printf-style formatting
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.text.DateFormatSymbols;
+import java.text.DecimalFormatSymbols;
+
+import gnu.classpath.SystemProperties;
+
+/**
+ * <p>
+ * A Java formatter for <code>printf</code>-style format strings,
+ * as seen in the C programming language. This differs from the
+ * C interpretation of such strings by performing much stricter
+ * checking of format specifications and their corresponding
+ * arguments. While unknown conversions will be ignored in C,
+ * and invalid conversions will only produce compiler warnings,
+ * the Java version utilises a full range of run-time exceptions to
+ * handle these cases. The Java version is also more customisable
+ * by virtue of the provision of the {@link Formattable} interface,
+ * which allows an arbitrary class to be formatted by the formatter.
+ * </p>
+ * <p>
+ * The formatter is accessible by more convienient static methods.
+ * For example, streams now have appropriate format methods
+ * (the equivalent of <code>fprintf</code>) as do <code>String</code>
+ * objects (the equivalent of <code>sprintf</code>).
+ * </p>
+ * <p>
+ * <strong>Note</strong>: the formatter is not thread-safe. For
+ * multi-threaded access, external synchronization should be provided.
+ * </p>
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class Formatter
+ implements Closeable, Flushable
+{
+
+ /**
+ * The output of the formatter.
+ */
+ private StringBuilder out;
+
+ /**
+ * The locale used by the formatter.
+ */
+ private Locale locale;
+
+ /**
+ * Whether or not the formatter is closed.
+ */
+ private boolean closed;
+
+ /**
+ * The last I/O exception thrown by the output stream.
+ */
+ private IOException ioException;
+
+ // Some state used when actually formatting.
+ /**
+ * The format string.
+ */
+ private String format;
+
+ /**
+ * The current index into the string.
+ */
+ private int index;
+
+ /**
+ * The length of the format string.
+ */
+ private int length;
+
+ /**
+ * The formatting locale.
+ */
+ private Locale fmtLocale;
+
+ // Note that we include '-' twice. The flags are ordered to
+ // correspond to the values in FormattableFlags, and there is no
+ // flag (in the sense of this field used when parsing) for
+ // UPPERCASE; the second '-' serves as a placeholder.
+ /**
+ * A string used to index into the formattable flags.
+ */
+ private static final String FLAGS = "--#+ 0,(";
+
+ /**
+ * The system line separator.
+ */
+ private static final String lineSeparator
+ = SystemProperties.getProperty("line.separator");
+
+ /**
+ * Constructs a new <code>Formatter</code> using the default
+ * locale and a {@link StringBuilder} as the output stream.
+ */
+ public Formatter()
+ {
+ this(null, Locale.getDefault());
+ }
+
+ /**
+ * Constructs a new <code>Formatter</code> using the specified
+ * locale and a {@link StringBuilder} as the output stream.
+ * If the locale is <code>null</code>, then no localization
+ * is applied.
+ *
+ * @param loc the locale to use.
+ */
+ public Formatter(Locale loc)
+ {
+ this(null, loc);
+ }
+
+ /**
+ * Constructs a new <code>Formatter</code> using the default
+ * locale and the specified output stream.
+ *
+ * @param app the output stream to use.
+ */
+ public Formatter(StringBuilder app)
+ {
+ this(app, Locale.getDefault());
+ }
+
+ /**
+ * Constructs a new <code>Formatter</code> using the specified
+ * locale and the specified output stream. If the locale is
+ * <code>null</code>, then no localization is applied.
+ *
+ * @param app the output stream to use.
+ * @param loc the locale to use.
+ */
+ public Formatter(StringBuilder app, Locale loc)
+ {
+ this.out = app == null ? new StringBuilder() : app;
+ this.locale = loc;
+ }
+
+ /**
+ * Closes the formatter, so as to release used resources.
+ * If the underlying output stream supports the {@link Closeable}
+ * interface, then this is also closed. Attempts to use
+ * a formatter instance, via any method other than
+ * {@link #ioException()}, after closure results in a
+ * {@link FormatterClosedException}.
+ */
+ public void close()
+ {
+ if (closed)
+ return;
+ closed = true;
+ }
+
+ /**
+ * Flushes the formatter, writing any cached data to the output
+ * stream. If the underlying output stream supports the
+ * {@link Flushable} interface, it is also flushed.
+ *
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public void flush()
+ {
+ if (closed)
+ throw new FormatterClosedException();
+ }
+
+ /**
+ * Return the name corresponding to a flag.
+ *
+ * @param flags the flag to return the name of.
+ * @return the name of the flag.
+ */
+ private String getName(int flags)
+ {
+ // FIXME: do we want all the flags in here?
+ // Or should we redo how this is reported?
+ int bit = Integer.numberOfTrailingZeros(flags);
+ return FLAGS.substring(bit, bit + 1);
+ }
+
+ /**
+ * Verify the flags passed to a conversion.
+ *
+ * @param flags the flags to verify.
+ * @param allowed the allowed flags mask.
+ * @param conversion the conversion character.
+ */
+ private void checkFlags(int flags, int allowed, char conversion)
+ {
+ flags &= ~allowed;
+ if (flags != 0)
+ throw new FormatFlagsConversionMismatchException(getName(flags),
+ conversion);
+ }
+
+ /**
+ * Throw an exception if a precision was specified.
+ *
+ * @param precision the precision value (-1 indicates not specified).
+ */
+ private void noPrecision(int precision)
+ {
+ if (precision != -1)
+ throw new IllegalFormatPrecisionException(precision);
+ }
+
+ /**
+ * Apply the numeric localization algorithm to a StringBuilder.
+ *
+ * @param builder the builder to apply to.
+ * @param flags the formatting flags to use.
+ * @param width the width of the numeric value.
+ * @param isNegative true if the value is negative.
+ */
+ private void applyLocalization(StringBuilder builder, int flags, int width,
+ boolean isNegative)
+ {
+ DecimalFormatSymbols dfsyms;
+ if (fmtLocale == null)
+ dfsyms = new DecimalFormatSymbols();
+ else
+ dfsyms = new DecimalFormatSymbols(fmtLocale);
+
+ // First replace each digit.
+ char zeroDigit = dfsyms.getZeroDigit();
+ int decimalOffset = -1;
+ for (int i = builder.length() - 1; i >= 0; --i)
+ {
+ char c = builder.charAt(i);
+ if (c >= '0' && c <= '9')
+ builder.setCharAt(i, (char) (c - '0' + zeroDigit));
+ else if (c == '.')
+ {
+ assert decimalOffset == -1;
+ decimalOffset = i;
+ }
+ }
+
+ // Localize the decimal separator.
+ if (decimalOffset != -1)
+ {
+ builder.deleteCharAt(decimalOffset);
+ builder.insert(decimalOffset, dfsyms.getDecimalSeparator());
+ }
+
+ // Insert the grouping separators.
+ if ((flags & FormattableFlags.COMMA) != 0)
+ {
+ char groupSeparator = dfsyms.getGroupingSeparator();
+ int groupSize = 3; // FIXME
+ int offset = (decimalOffset == -1) ? builder.length() : decimalOffset;
+ // We use '>' because we don't want to insert a separator
+ // before the first digit.
+ for (int i = offset - groupSize; i > 0; i -= groupSize)
+ builder.insert(i, groupSeparator);
+ }
+
+ if ((flags & FormattableFlags.ZERO) != 0)
+ {
+ // Zero fill. Note that according to the algorithm we do not
+ // insert grouping separators here.
+ for (int i = width - builder.length(); i > 0; --i)
+ builder.insert(0, zeroDigit);
+ }
+
+ if (isNegative)
+ {
+ if ((flags & FormattableFlags.PAREN) != 0)
+ {
+ builder.insert(0, '(');
+ builder.append(')');
+ }
+ else
+ builder.insert(0, '-');
+ }
+ else if ((flags & FormattableFlags.PLUS) != 0)
+ builder.insert(0, '+');
+ else if ((flags & FormattableFlags.SPACE) != 0)
+ builder.insert(0, ' ');
+ }
+
+ /**
+ * A helper method that handles emitting a String after applying
+ * precision, width, justification, and upper case flags.
+ *
+ * @param arg the string to emit.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void genericFormat(String arg, int flags, int width, int precision)
+ throws IOException
+ {
+ if ((flags & FormattableFlags.UPPERCASE) != 0)
+ {
+ if (fmtLocale == null)
+ arg = arg.toUpperCase();
+ else
+ arg = arg.toUpperCase(fmtLocale);
+ }
+
+ if (precision >= 0 && arg.length() > precision)
+ arg = arg.substring(0, precision);
+
+ boolean leftJustify = (flags & FormattableFlags.LEFT_JUSTIFY) != 0;
+ if (leftJustify && width == -1)
+ throw new MissingFormatWidthException("fixme");
+ if (! leftJustify && arg.length() < width)
+ {
+ for (int i = width - arg.length(); i > 0; --i)
+ out.append(' ');
+ }
+ out.append(arg);
+ if (leftJustify && arg.length() < width)
+ {
+ for (int i = width - arg.length(); i > 0; --i)
+ out.append(' ');
+ }
+ }
+
+ /**
+ * Emit a boolean.
+ *
+ * @param arg the boolean to emit.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void booleanFormat(Object arg, int flags, int width, int precision,
+ char conversion)
+ throws IOException
+ {
+ checkFlags(flags,
+ FormattableFlags.LEFT_JUSTIFY | FormattableFlags.UPPERCASE,
+ conversion);
+ String result;
+ if (arg instanceof Boolean)
+ result = String.valueOf((Boolean) arg);
+ else
+ result = arg == null ? "false" : "true";
+ genericFormat(result, flags, width, precision);
+ }
+
+ /**
+ * Emit a hash code.
+ *
+ * @param arg the hash code to emit.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void hashCodeFormat(Object arg, int flags, int width, int precision,
+ char conversion)
+ throws IOException
+ {
+ checkFlags(flags,
+ FormattableFlags.LEFT_JUSTIFY | FormattableFlags.UPPERCASE,
+ conversion);
+ genericFormat(arg == null ? "null" : Integer.toHexString(arg.hashCode()),
+ flags, width, precision);
+ }
+
+ /**
+ * Emit a String or Formattable conversion.
+ *
+ * @param arg the String or Formattable to emit.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void stringFormat(Object arg, int flags, int width, int precision,
+ char conversion)
+ throws IOException
+ {
+ if (arg instanceof Formattable)
+ {
+ checkFlags(flags,
+ (FormattableFlags.LEFT_JUSTIFY
+ | FormattableFlags.UPPERCASE
+ | FormattableFlags.ALTERNATE),
+ conversion);
+ Formattable fmt = (Formattable) arg;
+ fmt.formatTo(this, flags, width, precision);
+ }
+ else
+ {
+ checkFlags(flags,
+ FormattableFlags.LEFT_JUSTIFY | FormattableFlags.UPPERCASE,
+ conversion);
+ genericFormat(arg == null ? "null" : arg.toString(), flags, width,
+ precision);
+ }
+ }
+
+ /**
+ * Emit a character.
+ *
+ * @param arg the character to emit.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void characterFormat(Object arg, int flags, int width, int precision,
+ char conversion)
+ throws IOException
+ {
+ checkFlags(flags,
+ FormattableFlags.LEFT_JUSTIFY | FormattableFlags.UPPERCASE,
+ conversion);
+ noPrecision(precision);
+
+ int theChar;
+ if (arg instanceof Character)
+ theChar = ((Character) arg).charValue();
+ else if (arg instanceof Byte)
+ theChar = (char) (((Byte) arg).byteValue ());
+ else if (arg instanceof Short)
+ theChar = (char) (((Short) arg).shortValue ());
+ else if (arg instanceof Integer)
+ {
+ theChar = ((Integer) arg).intValue();
+ if (! Character.isValidCodePoint(theChar))
+ throw new IllegalFormatCodePointException(theChar);
+ }
+ else
+ throw new IllegalFormatConversionException(conversion, arg.getClass());
+ String result = new String(Character.toChars(theChar));
+ genericFormat(result, flags, width, precision);
+ }
+
+ /**
+ * Emit a '%'.
+ *
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void percentFormat(int flags, int width, int precision)
+ throws IOException
+ {
+ checkFlags(flags, FormattableFlags.LEFT_JUSTIFY, '%');
+ noPrecision(precision);
+ genericFormat("%", flags, width, precision);
+ }
+
+ /**
+ * Emit a newline.
+ *
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void newLineFormat(int flags, int width, int precision)
+ throws IOException
+ {
+ checkFlags(flags, 0, 'n');
+ noPrecision(precision);
+ if (width != -1)
+ throw new IllegalFormatWidthException(width);
+ genericFormat(lineSeparator, flags, width, precision);
+ }
+
+ /**
+ * Helper method to do initial formatting and checking for integral
+ * conversions.
+ *
+ * @param arg the formatted argument.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param radix the radix of the number.
+ * @param conversion the conversion character.
+ * @return the result.
+ */
+ private StringBuilder basicIntegralConversion(Object arg, int flags,
+ int width, int precision,
+ int radix, char conversion)
+ {
+ assert radix == 8 || radix == 10 || radix == 16;
+ noPrecision(precision);
+
+ // Some error checking.
+ if ((flags & FormattableFlags.ZERO) != 0
+ && (flags & FormattableFlags.LEFT_JUSTIFY) == 0)
+ throw new IllegalFormatFlagsException(getName(flags));
+ if ((flags & FormattableFlags.PLUS) != 0
+ && (flags & FormattableFlags.SPACE) != 0)
+ throw new IllegalFormatFlagsException(getName(flags));
+
+ if ((flags & FormattableFlags.LEFT_JUSTIFY) != 0 && width == -1)
+ throw new MissingFormatWidthException("fixme");
+
+ // Do the base translation of the value to a string.
+ String result;
+ int basicFlags = (FormattableFlags.LEFT_JUSTIFY
+ // We already handled any possible error when
+ // parsing.
+ | FormattableFlags.UPPERCASE
+ | FormattableFlags.ZERO);
+ if (radix == 10)
+ basicFlags |= (FormattableFlags.PLUS
+ | FormattableFlags.SPACE
+ | FormattableFlags.COMMA
+ | FormattableFlags.PAREN);
+ else
+ basicFlags |= FormattableFlags.ALTERNATE;
+
+ if (arg instanceof BigInteger)
+ {
+ checkFlags(flags,
+ (basicFlags
+ | FormattableFlags.PLUS
+ | FormattableFlags.SPACE
+ | FormattableFlags.PAREN),
+ conversion);
+ BigInteger bi = (BigInteger) arg;
+ result = bi.toString(radix);
+ }
+ else if (arg instanceof Number
+ && ! (arg instanceof Float)
+ && ! (arg instanceof Double))
+ {
+ checkFlags(flags, basicFlags, conversion);
+ long value = ((Number) arg).longValue ();
+ if (radix == 8)
+ result = Long.toOctalString(value);
+ else if (radix == 16)
+ result = Long.toHexString(value);
+ else
+ result = Long.toString(value);
+ }
+ else
+ throw new IllegalFormatConversionException(conversion, arg.getClass());
+
+ return new StringBuilder(result);
+ }
+
+ /**
+ * Emit a hex or octal value.
+ *
+ * @param arg the hexadecimal or octal value.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param radix the radix of the number.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void hexOrOctalConversion(Object arg, int flags, int width,
+ int precision, int radix,
+ char conversion)
+ throws IOException
+ {
+ assert radix == 8 || radix == 16;
+
+ StringBuilder builder = basicIntegralConversion(arg, flags, width,
+ precision, radix,
+ conversion);
+ int insertPoint = 0;
+
+ // Insert the sign.
+ if (builder.charAt(0) == '-')
+ {
+ // Already inserted. Note that we don't insert a sign, since
+ // the only case where it is needed it BigInteger, and it has
+ // already been inserted by toString.
+ ++insertPoint;
+ }
+ else if ((flags & FormattableFlags.PLUS) != 0)
+ {
+ builder.insert(insertPoint, '+');
+ ++insertPoint;
+ }
+ else if ((flags & FormattableFlags.SPACE) != 0)
+ {
+ builder.insert(insertPoint, ' ');
+ ++insertPoint;
+ }
+
+ // Insert the radix prefix.
+ if ((flags & FormattableFlags.ALTERNATE) != 0)
+ {
+ builder.insert(insertPoint, radix == 8 ? "0" : "0x");
+ insertPoint += radix == 8 ? 1 : 2;
+ }
+
+ // Now justify the result.
+ int resultWidth = builder.length();
+ if (resultWidth < width)
+ {
+ char fill = ((flags & FormattableFlags.ZERO) != 0) ? '0' : ' ';
+ if ((flags & FormattableFlags.LEFT_JUSTIFY) != 0)
+ {
+ // Left justify.
+ if (fill == ' ')
+ insertPoint = builder.length();
+ }
+ else
+ {
+ // Right justify. Insert spaces before the radix prefix
+ // and sign.
+ insertPoint = 0;
+ }
+ while (resultWidth++ < width)
+ builder.insert(insertPoint, fill);
+ }
+
+ String result = builder.toString();
+ if ((flags & FormattableFlags.UPPERCASE) != 0)
+ {
+ if (fmtLocale == null)
+ result = result.toUpperCase();
+ else
+ result = result.toUpperCase(fmtLocale);
+ }
+
+ out.append(result);
+ }
+
+ /**
+ * Emit a decimal value.
+ *
+ * @param arg the hexadecimal or octal value.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void decimalConversion(Object arg, int flags, int width,
+ int precision, char conversion)
+ throws IOException
+ {
+ StringBuilder builder = basicIntegralConversion(arg, flags, width,
+ precision, 10,
+ conversion);
+ boolean isNegative = false;
+ if (builder.charAt(0) == '-')
+ {
+ // Sign handling is done during localization.
+ builder.deleteCharAt(0);
+ isNegative = true;
+ }
+
+ applyLocalization(builder, flags, width, isNegative);
+ genericFormat(builder.toString(), flags, width, precision);
+ }
+
+ /**
+ * Emit a single date or time conversion to a StringBuilder.
+ *
+ * @param builder the builder to write to.
+ * @param cal the calendar to use in the conversion.
+ * @param conversion the formatting character to specify the type of data.
+ * @param syms the date formatting symbols.
+ */
+ private void singleDateTimeConversion(StringBuilder builder, Calendar cal,
+ char conversion,
+ DateFormatSymbols syms)
+ {
+ int oldLen = builder.length();
+ int digits = -1;
+ switch (conversion)
+ {
+ case 'H':
+ builder.append(cal.get(Calendar.HOUR_OF_DAY));
+ digits = 2;
+ break;
+ case 'I':
+ builder.append(cal.get(Calendar.HOUR));
+ digits = 2;
+ break;
+ case 'k':
+ builder.append(cal.get(Calendar.HOUR_OF_DAY));
+ break;
+ case 'l':
+ builder.append(cal.get(Calendar.HOUR));
+ break;
+ case 'M':
+ builder.append(cal.get(Calendar.MINUTE));
+ digits = 2;
+ break;
+ case 'S':
+ builder.append(cal.get(Calendar.SECOND));
+ digits = 2;
+ break;
+ case 'N':
+ // FIXME: nanosecond ...
+ digits = 9;
+ break;
+ case 'p':
+ {
+ int ampm = cal.get(Calendar.AM_PM);
+ builder.append(syms.getAmPmStrings()[ampm]);
+ }
+ break;
+ case 'z':
+ {
+ int zone = cal.get(Calendar.ZONE_OFFSET) / (1000 * 60);
+ builder.append(zone);
+ digits = 4;
+ // Skip the '-' sign.
+ if (zone < 0)
+ ++oldLen;
+ }
+ break;
+ case 'Z':
+ {
+ // FIXME: DST?
+ int zone = cal.get(Calendar.ZONE_OFFSET) / (1000 * 60 * 60);
+ String[][] zs = syms.getZoneStrings();
+ builder.append(zs[zone + 12][1]);
+ }
+ break;
+ case 's':
+ {
+ long val = cal.getTime().getTime();
+ builder.append(val / 1000);
+ }
+ break;
+ case 'Q':
+ {
+ long val = cal.getTime().getTime();
+ builder.append(val);
+ }
+ break;
+ case 'B':
+ {
+ int month = cal.get(Calendar.MONTH);
+ builder.append(syms.getMonths()[month]);
+ }
+ break;
+ case 'b':
+ case 'h':
+ {
+ int month = cal.get(Calendar.MONTH);
+ builder.append(syms.getShortMonths()[month]);
+ }
+ break;
+ case 'A':
+ {
+ int day = cal.get(Calendar.DAY_OF_WEEK);
+ builder.append(syms.getWeekdays()[day]);
+ }
+ break;
+ case 'a':
+ {
+ int day = cal.get(Calendar.DAY_OF_WEEK);
+ builder.append(syms.getShortWeekdays()[day]);
+ }
+ break;
+ case 'C':
+ builder.append(cal.get(Calendar.YEAR) / 100);
+ digits = 2;
+ break;
+ case 'Y':
+ builder.append(cal.get(Calendar.YEAR));
+ digits = 4;
+ break;
+ case 'y':
+ builder.append(cal.get(Calendar.YEAR) % 100);
+ digits = 2;
+ break;
+ case 'j':
+ builder.append(cal.get(Calendar.DAY_OF_YEAR));
+ digits = 3;
+ break;
+ case 'm':
+ builder.append(cal.get(Calendar.MONTH) + 1);
+ digits = 2;
+ break;
+ case 'd':
+ builder.append(cal.get(Calendar.DAY_OF_MONTH));
+ digits = 2;
+ break;
+ case 'e':
+ builder.append(cal.get(Calendar.DAY_OF_MONTH));
+ break;
+ case 'R':
+ singleDateTimeConversion(builder, cal, 'H', syms);
+ builder.append(':');
+ singleDateTimeConversion(builder, cal, 'M', syms);
+ break;
+ case 'T':
+ singleDateTimeConversion(builder, cal, 'H', syms);
+ builder.append(':');
+ singleDateTimeConversion(builder, cal, 'M', syms);
+ builder.append(':');
+ singleDateTimeConversion(builder, cal, 'S', syms);
+ break;
+ case 'r':
+ singleDateTimeConversion(builder, cal, 'I', syms);
+ builder.append(':');
+ singleDateTimeConversion(builder, cal, 'M', syms);
+ builder.append(':');
+ singleDateTimeConversion(builder, cal, 'S', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'p', syms);
+ break;
+ case 'D':
+ singleDateTimeConversion(builder, cal, 'm', syms);
+ builder.append('/');
+ singleDateTimeConversion(builder, cal, 'd', syms);
+ builder.append('/');
+ singleDateTimeConversion(builder, cal, 'y', syms);
+ break;
+ case 'F':
+ singleDateTimeConversion(builder, cal, 'Y', syms);
+ builder.append('-');
+ singleDateTimeConversion(builder, cal, 'm', syms);
+ builder.append('-');
+ singleDateTimeConversion(builder, cal, 'd', syms);
+ break;
+ case 'c':
+ singleDateTimeConversion(builder, cal, 'a', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'b', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'd', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'T', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'Z', syms);
+ builder.append(' ');
+ singleDateTimeConversion(builder, cal, 'Y', syms);
+ break;
+ default:
+ throw new UnknownFormatConversionException(String.valueOf(conversion));
+ }
+
+ if (digits > 0)
+ {
+ int newLen = builder.length();
+ int delta = newLen - oldLen;
+ while (delta++ < digits)
+ builder.insert(oldLen, '0');
+ }
+ }
+
+ /**
+ * Emit a date or time value.
+ *
+ * @param arg the date or time value.
+ * @param flags the formatting flags to use.
+ * @param width the width to use.
+ * @param precision the precision to use.
+ * @param conversion the conversion character.
+ * @param subConversion the sub conversion character.
+ * @throws IOException if the output stream throws an I/O error.
+ */
+ private void dateTimeConversion(Object arg, int flags, int width,
+ int precision, char conversion,
+ char subConversion)
+ throws IOException
+ {
+ noPrecision(precision);
+ checkFlags(flags,
+ FormattableFlags.LEFT_JUSTIFY | FormattableFlags.UPPERCASE,
+ conversion);
+
+ Calendar cal;
+ if (arg instanceof Calendar)
+ cal = (Calendar) arg;
+ else
+ {
+ Date date;
+ if (arg instanceof Date)
+ date = (Date) arg;
+ else if (arg instanceof Long)
+ date = new Date(((Long) arg).longValue());
+ else
+ throw new IllegalFormatConversionException(conversion,
+ arg.getClass());
+ if (fmtLocale == null)
+ cal = Calendar.getInstance();
+ else
+ cal = Calendar.getInstance(fmtLocale);
+ cal.setTime(date);
+ }
+
+ // We could try to be more efficient by computing this lazily.
+ DateFormatSymbols syms;
+ if (fmtLocale == null)
+ syms = new DateFormatSymbols();
+ else
+ syms = new DateFormatSymbols(fmtLocale);
+
+ StringBuilder result = new StringBuilder();
+ singleDateTimeConversion(result, cal, subConversion, syms);
+
+ genericFormat(result.toString(), flags, width, precision);
+ }
+
+ /**
+ * Advance the internal parsing index, and throw an exception
+ * on overrun.
+ *
+ * @throws IllegalArgumentException on overrun.
+ */
+ private void advance()
+ {
+ ++index;
+ if (index >= length)
+ {
+ // FIXME: what exception here?
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Parse an integer appearing in the format string. Will return -1
+ * if no integer was found.
+ *
+ * @return the parsed integer.
+ */
+ private int parseInt()
+ {
+ int start = index;
+ while (Character.isDigit(format.charAt(index)))
+ advance();
+ if (start == index)
+ return -1;
+ return Integer.decode(format.substring(start, index)).intValue();
+ }
+
+ /**
+ * Parse the argument index. Returns -1 if there was no index, 0 if
+ * we should re-use the previous index, and a positive integer to
+ * indicate an absolute index.
+ *
+ * @return the parsed argument index.
+ */
+ private int parseArgumentIndex()
+ {
+ int result = -1;
+ int start = index;
+ if (format.charAt(index) == '<')
+ {
+ result = 0;
+ advance();
+ }
+ else if (Character.isDigit(format.charAt(index)))
+ {
+ result = parseInt();
+ if (format.charAt(index) == '$')
+ advance();
+ else
+ {
+ // Reset.
+ index = start;
+ result = -1;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Parse a set of flags and return a bit mask of values from
+ * FormattableFlags. Will throw an exception if a flag is
+ * duplicated.
+ *
+ * @return the parsed flags.
+ */
+ private int parseFlags()
+ {
+ int value = 0;
+ int start = index;
+ while (true)
+ {
+ int x = FLAGS.indexOf(format.charAt(index));
+ if (x == -1)
+ break;
+ int newValue = 1 << x;
+ if ((value & newValue) != 0)
+ throw new DuplicateFormatFlagsException(format.substring(start,
+ index + 1));
+ value |= newValue;
+ advance();
+ }
+ return value;
+ }
+
+ /**
+ * Parse the width part of a format string. Returns -1 if no width
+ * was specified.
+ *
+ * @return the parsed width.
+ */
+ private int parseWidth()
+ {
+ return parseInt();
+ }
+
+ /**
+ * If the current character is '.', parses the precision part of a
+ * format string. Returns -1 if no precision was specified.
+ *
+ * @return the parsed precision.
+ */
+ private int parsePrecision()
+ {
+ if (format.charAt(index) != '.')
+ return -1;
+ advance();
+ int precision = parseInt();
+ if (precision == -1)
+ // FIXME
+ throw new IllegalArgumentException();
+ return precision;
+ }
+
+ /**
+ * Outputs a formatted string based on the supplied specification,
+ * <code>fmt</code>, and its arguments using the specified locale.
+ * The locale of the formatter does not change as a result; the
+ * specified locale is just used for this particular formatting
+ * operation. If the locale is <code>null</code>, then no
+ * localization is applied.
+ *
+ * @param loc the locale to use for this format.
+ * @param fmt the format specification.
+ * @param args the arguments to apply to the specification.
+ * @throws IllegalFormatException if there is a problem with
+ * the syntax of the format
+ * specification or a mismatch
+ * between it and the arguments.
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public Formatter format(Locale loc, String fmt, Object[] args)
+ {
+ if (closed)
+ throw new FormatterClosedException();
+
+ // Note the arguments are indexed starting at 1.
+ int implicitArgumentIndex = 1;
+ int previousArgumentIndex = 0;
+
+ try
+ {
+ fmtLocale = loc;
+ format = fmt;
+ length = format.length();
+ for (index = 0; index < length; ++index)
+ {
+ char c = format.charAt(index);
+ if (c != '%')
+ {
+ out.append(c);
+ continue;
+ }
+
+ int start = index;
+ advance();
+
+ // We do the needed post-processing of this later, when we
+ // determine whether an argument is actually needed by
+ // this conversion.
+ int argumentIndex = parseArgumentIndex();
+
+ int flags = parseFlags();
+ int width = parseWidth();
+ int precision = parsePrecision();
+ char origConversion = format.charAt(index);
+ char conversion = origConversion;
+ if (Character.isUpperCase(conversion))
+ {
+ flags |= FormattableFlags.UPPERCASE;
+ conversion = Character.toLowerCase(conversion);
+ }
+
+ Object argument = null;
+ if (conversion == '%' || conversion == 'n')
+ {
+ if (argumentIndex != -1)
+ {
+ // FIXME: not sure about this.
+ throw new UnknownFormatConversionException("FIXME");
+ }
+ }
+ else
+ {
+ if (argumentIndex == -1)
+ argumentIndex = implicitArgumentIndex++;
+ else if (argumentIndex == 0)
+ argumentIndex = previousArgumentIndex;
+ // Argument indices start at 1 but array indices at 0.
+ --argumentIndex;
+ if (argumentIndex < 0 || argumentIndex >= args.length)
+ throw new MissingFormatArgumentException(format.substring(start, index));
+ argument = args[argumentIndex];
+ }
+
+ switch (conversion)
+ {
+ case 'b':
+ booleanFormat(argument, flags, width, precision,
+ origConversion);
+ break;
+ case 'h':
+ hashCodeFormat(argument, flags, width, precision,
+ origConversion);
+ break;
+ case 's':
+ stringFormat(argument, flags, width, precision,
+ origConversion);
+ break;
+ case 'c':
+ characterFormat(argument, flags, width, precision,
+ origConversion);
+ break;
+ case 'd':
+ checkFlags(flags & FormattableFlags.UPPERCASE, 0, 'd');
+ decimalConversion(argument, flags, width, precision,
+ origConversion);
+ break;
+ case 'o':
+ checkFlags(flags & FormattableFlags.UPPERCASE, 0, 'o');
+ hexOrOctalConversion(argument, flags, width, precision, 8,
+ origConversion);
+ break;
+ case 'x':
+ hexOrOctalConversion(argument, flags, width, precision, 16,
+ origConversion);
+ case 'e':
+ // scientificNotationConversion();
+ break;
+ case 'f':
+ // floatingDecimalConversion();
+ break;
+ case 'g':
+ // smartFloatingConversion();
+ break;
+ case 'a':
+ // hexFloatingConversion();
+ break;
+ case 't':
+ advance();
+ char subConversion = format.charAt(index);
+ dateTimeConversion(argument, flags, width, precision,
+ origConversion, subConversion);
+ break;
+ case '%':
+ percentFormat(flags, width, precision);
+ break;
+ case 'n':
+ newLineFormat(flags, width, precision);
+ break;
+ default:
+ throw new UnknownFormatConversionException(String.valueOf(origConversion));
+ }
+ }
+ }
+ catch (IOException exc)
+ {
+ ioException = exc;
+ }
+ return this;
+ }
+
+ /**
+ * Outputs a formatted string based on the supplied specification,
+ * <code>fmt</code>, and its arguments using the formatter's locale.
+ *
+ * @param fmt the format specification.
+ * @param args the arguments to apply to the specification.
+ * @throws IllegalFormatException if there is a problem with
+ * the syntax of the format
+ * specification or a mismatch
+ * between it and the arguments.
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public Formatter format(String format, Object[] args)
+ {
+ return format(locale, format, args);
+ }
+
+ /**
+ * Returns the last I/O exception thrown by the
+ * <code>append()</code> operation of the underlying
+ * output stream.
+ *
+ * @return the last I/O exception.
+ */
+ public IOException ioException()
+ {
+ return ioException;
+ }
+
+ /**
+ * Returns the locale used by this formatter.
+ *
+ * @return the formatter's locale.
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public Locale locale()
+ {
+ if (closed)
+ throw new FormatterClosedException();
+ return locale;
+ }
+
+ /**
+ * Returns the output stream used by this formatter.
+ *
+ * @return the formatter's output stream.
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public StringBuilder out()
+ {
+ if (closed)
+ throw new FormatterClosedException();
+ return out;
+ }
+
+ /**
+ * Returns the result of applying {@link Object#toString()}
+ * to the underlying output stream. The results returned
+ * depend on the particular {@link Appendable} being used.
+ * For example, a {@link StringBuilder} will return the
+ * formatted output but an I/O stream will not.
+ *
+ * @throws FormatterClosedException if the formatter is closed.
+ */
+ public String toString()
+ {
+ if (closed)
+ throw new FormatterClosedException();
+ return out.toString();
+ }
+}
diff --git a/libjava/classpath/java/util/FormatterClosedException.java b/libjava/classpath/java/util/FormatterClosedException.java
new file mode 100644
index 00000000000..c3588648e34
--- /dev/null
+++ b/libjava/classpath/java/util/FormatterClosedException.java
@@ -0,0 +1,60 @@
+/* FormatterClosedException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when a method is called on a {@link Formatter} but
+ * it has already been closed.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class FormatterClosedException
+ extends IllegalStateException
+{
+ private static final long serialVersionUID = 18111216L;
+
+ /**
+ * Constructs a new <code>FormatterClosedException</code>.
+ */
+ public FormatterClosedException()
+ {
+ }
+}
diff --git a/libjava/classpath/java/util/GregorianCalendar.java b/libjava/classpath/java/util/GregorianCalendar.java
index 5ce053a3705..83ac00e77e0 100644
--- a/libjava/classpath/java/util/GregorianCalendar.java
+++ b/libjava/classpath/java/util/GregorianCalendar.java
@@ -445,7 +445,7 @@ public class GregorianCalendar extends Calendar
if (isSet[WEEK_OF_MONTH])
{
- int weeks = (month == 1 && leap == 0) ? 4 : 5;
+ int weeks = (month == 1 && leap == 0) ? 5 : 6;
if (fields[WEEK_OF_MONTH] < 1 || fields[WEEK_OF_MONTH] > weeks)
throw new IllegalArgumentException("Illegal WEEK_OF_MONTH.");
}
@@ -1164,7 +1164,7 @@ public class GregorianCalendar extends Calendar
*/
private static final int[] maximums =
{
- AD, 5000000, 11, 53, 5, 31, 366,
+ AD, 5000000, 11, 53, 6, 31, 366,
SATURDAY, 5, PM, 12, 23, 59, 59, 999,
+(12 * 60 * 60 * 1000),
(12 * 60 * 60 * 1000)
diff --git a/libjava/classpath/java/util/IllegalFormatCodePointException.java b/libjava/classpath/java/util/IllegalFormatCodePointException.java
new file mode 100644
index 00000000000..001839fe1eb
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatCodePointException.java
@@ -0,0 +1,85 @@
+/* IllegalFormatCodePointException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when a {@link Formatter} receives a character with an
+ * invalid Unicode codepoint, as defined by
+ * {@link Character#isValidCodePoint(int)}.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatCodePointException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 19080630L;
+
+ /**
+ * The character which is an invalid Unicode code point.
+ *
+ * @serial the invalid character.
+ */
+ // Note: name fixed by serialization.
+ int c;
+
+ /**
+ * Constructs a new <code>IllegalFormatCodePointException</code>
+ * which specifies that the character, <code>c</code>, passed to
+ * a {@link Formatter} is an invalid Unicode code point.
+ *
+ * @param c the invalid character.
+ */
+ public IllegalFormatCodePointException(int c)
+ {
+ super("An invalid Unicode code point was supplied.");
+ this.c = c;
+ }
+
+ /**
+ * Returns the invalid character.
+ *
+ * @return the invalid character.
+ */
+ public int getCodePoint()
+ {
+ return c;
+ }
+}
diff --git a/libjava/classpath/java/util/IllegalFormatConversionException.java b/libjava/classpath/java/util/IllegalFormatConversionException.java
new file mode 100644
index 00000000000..2f981f26e45
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatConversionException.java
@@ -0,0 +1,110 @@
+/* IllegalFormatConversionException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the type of an argument supplied to the
+ * {@link Formatter#format()} method of a {@link Formatter}
+ * does not match the conversion character specified for it.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatConversionException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 17000126L;
+
+ /**
+ * The conversion character which doesn't match
+ * the type of the argument.
+ *
+ * @serial the conversion character.
+ */
+ // Note: name fixed by serialization.
+ char c;
+
+ /**
+ * The type of the mismatching argument.
+ *
+ * @serial the mismatching argument type.
+ */
+ // Note: name fixed by serialization.
+ Class arg;
+
+ /**
+ * Constructs a new <code>IllegalFormatConversionException</code>
+ * which specifies that the argument of type <code>arg</code> does
+ * not match the conversion character, <code>c</code>.
+ *
+ * @param c the conversion character.
+ * @param arg the type which doesn't match the conversion character.
+ * @throws NullPointerException if <code>arg</code> is null.
+ */
+ public IllegalFormatConversionException(char c, Class arg)
+ {
+ super("The type, " + arg + ", is invalid for the conversion character, " +
+ c + ".");
+ if (arg == null)
+ throw new NullPointerException("The supplied type was null.");
+ this.c = c;
+ this.arg = arg;
+ }
+
+ /**
+ * Returns the conversion character.
+ *
+ * @return the conversion character.
+ */
+ public char getConversion()
+ {
+ return c;
+ }
+
+ /**
+ * Returns the type of the mismatched argument.
+ *
+ * @return the type of the mismatched argument.
+ */
+ public Class getArgumentClass()
+ {
+ return arg;
+ }
+}
diff --git a/libjava/classpath/java/util/IllegalFormatException.java b/libjava/classpath/java/util/IllegalFormatException.java
new file mode 100644
index 00000000000..4daafca4414
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatException.java
@@ -0,0 +1,75 @@
+/* IllegalFormatException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * A general exception thrown when a format string is supplied
+ * to a {@link Formatter} that contains either invalid syntax
+ * or a mismatch between the format specification and the
+ * supplied arguments. This class is never instantiated;
+ * instead one of its subclasses is used to throw a more
+ * specific exception.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatException
+ extends IllegalArgumentException
+{
+ private static final long serialVersionUID = 18830826L;
+
+ /**
+ * Constructs a new <code>IllegalFormatException</code>.
+ */
+ IllegalFormatException()
+ {
+ }
+
+ /**
+ * Constructs a new <code>IllegalFormatException</code>
+ * with the specified message.
+ *
+ * @param msg the error message for this exception.
+ */
+ IllegalFormatException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/classpath/java/util/IllegalFormatFlagsException.java b/libjava/classpath/java/util/IllegalFormatFlagsException.java
new file mode 100644
index 00000000000..2a085c14113
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatFlagsException.java
@@ -0,0 +1,86 @@
+/* IllegalFormatFlagsException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the flags supplied to the {@link Formatter#format()}
+ * method of a {@link Formatter} form an illegal combination.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatFlagsException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 790824L;
+
+ /**
+ * The set of flags which forms an illegal combination.
+ *
+ * @serial the illegal set of flags.
+ */
+ // Note: name fixed by serialization.
+ private String flags;
+
+ /**
+ * Constructs a new <code>IllegalFormatFlagsException</code>
+ * for the specified flags.
+ *
+ * @param flags the illegal set of flags.
+ * @throws NullPointerException if <code>flags</code> is null.
+ */
+ public IllegalFormatFlagsException(String flags)
+ {
+ super("An illegal set of flags, " + flags + ", was supplied.");
+ if (flags == null)
+ throw new NullPointerException("The supplied flags are null.");
+ this.flags = flags;
+ }
+
+ /**
+ * Returns the illegal flags.
+ *
+ * @return the illegal flags.
+ */
+ public String getFlags()
+ {
+ return flags;
+ }
+}
diff --git a/libjava/classpath/java/util/IllegalFormatPrecisionException.java b/libjava/classpath/java/util/IllegalFormatPrecisionException.java
new file mode 100644
index 00000000000..a555f5df425
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatPrecisionException.java
@@ -0,0 +1,85 @@
+/* IllegalFormatPrecisionException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the specified precision for a {@link Formatter}
+ * argument is illegal. This may be because the number is
+ * a negative number (other than -1), the argument does not
+ * accept a precision or for some other reason.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatPrecisionException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 18711008L;
+
+ /**
+ * The illegal precision value.
+ *
+ * @serial the illegal precision.
+ */
+ // Note: name fixed by serialization.
+ private int p;
+
+ /**
+ * Constructs a new <code>IllegalFormatPrecisionException</code>
+ * for the precision, <code>p</code>.
+ *
+ * @param p the illegal precision.
+ */
+ public IllegalFormatPrecisionException(int p)
+ {
+ super("The precision, " + p + ", is illegal.");
+ this.p = p;
+ }
+
+ /**
+ * Returns the illegal precision.
+ *
+ * @return the illegal precision.
+ */
+ public int getPrecision()
+ {
+ return p;
+ }
+}
diff --git a/libjava/classpath/java/util/IllegalFormatWidthException.java b/libjava/classpath/java/util/IllegalFormatWidthException.java
new file mode 100644
index 00000000000..95d3e150282
--- /dev/null
+++ b/libjava/classpath/java/util/IllegalFormatWidthException.java
@@ -0,0 +1,84 @@
+/* IllegalFormatWidthException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the specified width for a {@link Formatter}
+ * argument is illegal. This may be because the number is
+ * a negative number (other than -1) or for some other reason.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IllegalFormatWidthException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 16660902L;
+
+ /**
+ * The illegal width value.
+ *
+ * @serial the illegal width.
+ */
+ // Note: name fixed by serialization.
+ private int w;
+
+ /**
+ * Constructs a new <code>IllegalFormatWidthException</code>
+ * with the specified width, <code>w</code>.
+ *
+ * @param w the illegal width.
+ */
+ public IllegalFormatWidthException(int w)
+ {
+ super("The width, " + w + ", is illegal.");
+ this.w = w;
+ }
+
+ /**
+ * Returns the illegal width.
+ *
+ * @return the illegal width.
+ */
+ public int getWidth()
+ {
+ return w;
+ }
+}
diff --git a/libjava/classpath/java/util/InputMismatchException.java b/libjava/classpath/java/util/InputMismatchException.java
new file mode 100644
index 00000000000..39326c33e0d
--- /dev/null
+++ b/libjava/classpath/java/util/InputMismatchException.java
@@ -0,0 +1,73 @@
+/* InputMismatchException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when a {@link Scanner} instance encounters a mismatch
+ * between the input data and the pattern it is trying to match it
+ * against. This could be because the input data represents an
+ * out-of-range value for the type the pattern represents, or simply
+ * because the data does not fit that particular type.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InputMismatchException
+ extends NoSuchElementException
+{
+ /**
+ * Constructs a new <code>InputMismatchException</code>
+ * with a <code>null</code> message.
+ */
+ public InputMismatchException()
+ {
+ }
+
+ /**
+ * Constructs a new <code>InputMismatchException</code>
+ * with the supplied error message.
+ *
+ * @param s the error message to report back to the user.
+ */
+ public InputMismatchException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/util/MissingFormatArgumentException.java b/libjava/classpath/java/util/MissingFormatArgumentException.java
new file mode 100644
index 00000000000..4a9385ed5b5
--- /dev/null
+++ b/libjava/classpath/java/util/MissingFormatArgumentException.java
@@ -0,0 +1,90 @@
+/* MissingFormatArgumentException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the a format specification for a {@link Formatter}
+ * refers to an argument that is non-existent, or an argument index
+ * references a non-existent argument.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MissingFormatArgumentException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 19190115L;
+
+ /**
+ * The format specification which contains the
+ * unmatched argument.
+ *
+ * @serial the format specification.
+ */
+ // Note: name fixed by serialization.
+ private String s;
+
+ /**
+ * Constructs a new <code>MissingFormatArgumentException</code>
+ * for a format specification, <code>s</code>, which refers
+ * to a non-existent argument.
+ *
+ * @param s the format specification.
+ * @throws NullPointerException if <code>s</code> is null.
+ */
+ public MissingFormatArgumentException(String s)
+ {
+ super("The specification, " + s +
+ ", refers to a non-existent argument.");
+ if (s == null)
+ throw new NullPointerException("The specification is null.");
+ this.s = s;
+ }
+
+ /**
+ * Returns the format specification.
+ *
+ * @return the format specification.
+ */
+ public String getFormatSpecifier()
+ {
+ return s;
+ }
+}
diff --git a/libjava/classpath/java/util/MissingFormatWidthException.java b/libjava/classpath/java/util/MissingFormatWidthException.java
new file mode 100644
index 00000000000..55de6202f42
--- /dev/null
+++ b/libjava/classpath/java/util/MissingFormatWidthException.java
@@ -0,0 +1,88 @@
+/* MissingFormatWidthException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when the a format specification for a {@link Formatter}
+ * does not include a width for a value where one is required.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MissingFormatWidthException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 15560123L;
+
+ /**
+ * The format specification which contains the
+ * unmatched argument.
+ *
+ * @serial the format specification.
+ */
+ // Note: name fixed by serialization.
+ private String s;
+
+ /**
+ * Constructs a new <code>MissingFormatWidthException</code>
+ * for a format specification, <code>s</code>, which excludes
+ * a required width argument.
+ *
+ * @param s the format specification.
+ * @throws NullPointerException if <code>s</code> is null.
+ */
+ public MissingFormatWidthException(String s)
+ {
+ super("The specification, " + s + ", misses a required width.");
+ if (s == null)
+ throw new NullPointerException("The specification is null.");
+ this.s = s;
+ }
+
+ /**
+ * Returns the format specification.
+ *
+ * @return the format specification.
+ */
+ public String getFormatSpecifier()
+ {
+ return s;
+ }
+}
diff --git a/libjava/classpath/java/util/UUID.java b/libjava/classpath/java/util/UUID.java
new file mode 100644
index 00000000000..6a57d27b448
--- /dev/null
+++ b/libjava/classpath/java/util/UUID.java
@@ -0,0 +1,383 @@
+/* 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 // genericizeme!
+{
+ 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(Object val)
+ {
+ return compareTo((UUID)val);
+ }
+
+ /**
+ * 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/libjava/classpath/java/util/UnknownFormatConversionException.java b/libjava/classpath/java/util/UnknownFormatConversionException.java
new file mode 100644
index 00000000000..e37d9d356b2
--- /dev/null
+++ b/libjava/classpath/java/util/UnknownFormatConversionException.java
@@ -0,0 +1,86 @@
+/* UnknownFormatConversionException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when a {@link Formatter} is supplied with an
+ * unknown conversion.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class UnknownFormatConversionException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 19060418L;
+
+ /**
+ * The unknown conversion.
+ *
+ * @serial the unknown conversion.
+ */
+ // Note: name fixed by serialization.
+ private String s;
+
+ /**
+ * Constructs a new <code>UnknownFormatConversionException</code>
+ * for the specified conversion string.
+ *
+ * @param s the conversion string.
+ * @throws NullPointerException if the conversion string is null.
+ */
+ public UnknownFormatConversionException(String s)
+ {
+ super("Unknown format conversion: " + s);
+ if (s == null)
+ throw new NullPointerException("The conversion string is null.");
+ this.s = s;
+ }
+
+ /**
+ * Returns the conversion string.
+ *
+ * @return the conversion string.
+ */
+ public String getConversion()
+ {
+ return s;
+ }
+}
diff --git a/libjava/classpath/java/util/UnknownFormatFlagsException.java b/libjava/classpath/java/util/UnknownFormatFlagsException.java
new file mode 100644
index 00000000000..b8f939ec42c
--- /dev/null
+++ b/libjava/classpath/java/util/UnknownFormatFlagsException.java
@@ -0,0 +1,88 @@
+/* UnknownFormatFlagsException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Thrown when a {@link Formatter} is supplied with an
+ * unknown flag.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class UnknownFormatFlagsException
+ extends IllegalFormatException
+{
+ private static final long serialVersionUID = 19370506L;
+
+ /**
+ * The set of flags containing the unknown flag.
+ *
+ * @serial the unknown conversion.
+ */
+ // Note: name fixed by serialization.
+ private String flags;
+
+ /**
+ * Constructs a new <code>UnknownFormatFlagsException</code>
+ * which specifies that the supplied set of flags contains a
+ * unknown.
+ *
+ * @param flags the flags containing a unknown.
+ * @throws NullPointerException if <code>flags</code> is null.
+ */
+ public UnknownFormatFlagsException(String s)
+ {
+ super("Unknown flag passed in " + s);
+ if (s == null)
+ throw new
+ NullPointerException("Null flags value passed to constructor.");
+ this.flags = s;
+ }
+
+ /**
+ * Returns the flags which contain a unknown.
+ *
+ * @return the flags.
+ */
+ public String getFlags()
+ {
+ return flags;
+ }
+}
diff --git a/libjava/classpath/java/util/Vector.java b/libjava/classpath/java/util/Vector.java
index 67549f0c47d..eb72ae49df8 100644
--- a/libjava/classpath/java/util/Vector.java
+++ b/libjava/classpath/java/util/Vector.java
@@ -1,5 +1,6 @@
/* Vector.java -- Class that provides growable arrays.
- Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005, 2006,
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,6 +38,7 @@ exception statement from your version. */
package java.util;
+
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -479,7 +481,7 @@ public class Vector extends AbstractList
}
/**
- * Removes the first (the lowestindex) occurance of the given object from
+ * Removes the first (the lowest index) occurrence of the given object from
* the Vector. If such a remove was performed (the object was found), true
* is returned. If there was no such object, false is returned.
*
diff --git a/libjava/classpath/java/util/jar/JarOutputStream.java b/libjava/classpath/java/util/jar/JarOutputStream.java
index 2c8c2f08d8f..46c71b38c4c 100644
--- a/libjava/classpath/java/util/jar/JarOutputStream.java
+++ b/libjava/classpath/java/util/jar/JarOutputStream.java
@@ -101,7 +101,7 @@ public class JarOutputStream extends ZipOutputStream
/**
* Prepares the JarOutputStream for writing the next entry.
- * This implementation just calls <code>super.putNextEntre()</code>.
+ * This implementation just calls <code>super.putNextEntry()</code>.
*
* @param entry The information for the next entry
* @exception IOException when some unexpected I/O exception occurred
diff --git a/libjava/classpath/java/util/jar/Manifest.java b/libjava/classpath/java/util/jar/Manifest.java
index aa869f4c4b0..64a0c476a91 100644
--- a/libjava/classpath/java/util/jar/Manifest.java
+++ b/libjava/classpath/java/util/jar/Manifest.java
@@ -1,4 +1,4 @@
-/* Manifest.java -- Reads, writes and manipulaties jar manifest files
+/* Manifest.java -- Reads, writes and manipulates jar manifest files
Copyright (C) 2000, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -152,7 +152,7 @@ public class Manifest implements Cloneable
}
/**
- * Read and merge a <code>Mainfest</code> from the designated input stream.
+ * Read and merge a <code>Manifest</code> from the designated input stream.
*
* @param in the input stream to read from.
* @throws IOException if an I/O related exception occurs during the process.
diff --git a/libjava/classpath/java/util/logging/FileHandler.java b/libjava/classpath/java/util/logging/FileHandler.java
index cde86191612..357d51e14fc 100644
--- a/libjava/classpath/java/util/logging/FileHandler.java
+++ b/libjava/classpath/java/util/logging/FileHandler.java
@@ -192,6 +192,42 @@ public class FileHandler
extends StreamHandler
{
/**
+ * A literal that prefixes all file-handler related properties in the
+ * logging.properties file.
+ */
+ private static final String PROPERTY_PREFIX = "java.util.logging.FileHandler";
+ /**
+ * The name of the property to set for specifying a file naming (incl. path)
+ * pattern to use with rotating log files.
+ */
+ private static final String PATTERN_KEY = PROPERTY_PREFIX + ".pattern";
+ /**
+ * The default pattern to use when the <code>PATTERN_KEY</code> property was
+ * not specified in the logging.properties file.
+ */
+ private static final String DEFAULT_PATTERN = "%h/java%u.log";
+ /**
+ * The name of the property to set for specifying an approximate maximum
+ * amount, in bytes, to write to any one log output file. A value of zero
+ * (which is the default) implies a no limit.
+ */
+ private static final String LIMIT_KEY = PROPERTY_PREFIX + ".limit";
+ private static final int DEFAULT_LIMIT = 0;
+ /**
+ * The name of the property to set for specifying how many output files to
+ * cycle through. The default value is 1.
+ */
+ private static final String COUNT_KEY = PROPERTY_PREFIX + ".count";
+ private static final int DEFAULT_COUNT = 1;
+ /**
+ * The name of the property to set for specifying whether this handler should
+ * append, or not, its output to existing files. The default value is
+ * <code>false</code> meaning NOT to append.
+ */
+ private static final String APPEND_KEY = PROPERTY_PREFIX + ".append";
+ private static final boolean DEFAULT_APPEND = false;
+
+ /**
* The number of bytes a log file is approximately allowed to reach
* before it is closed and the handler switches to the next file in
* the rotating set. A value of zero means that files can grow
@@ -252,16 +288,10 @@ public class FileHandler
public FileHandler()
throws IOException, SecurityException
{
- this(/* pattern: use configiguration */ null,
-
- LogManager.getIntProperty("java.util.logging.FileHandler.limit",
- /* default */ 0),
-
- LogManager.getIntProperty("java.util.logging.FileHandler.count",
- /* default */ 1),
-
- LogManager.getBooleanProperty("java.util.logging.FileHandler.append",
- /* default */ false));
+ this(LogManager.getLogManager().getProperty(PATTERN_KEY),
+ LogManager.getIntProperty(LIMIT_KEY, DEFAULT_LIMIT),
+ LogManager.getIntProperty(COUNT_KEY, DEFAULT_COUNT),
+ LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
}
@@ -269,10 +299,7 @@ public class FileHandler
public FileHandler(String pattern)
throws IOException, SecurityException
{
- this(pattern,
- /* limit */ 0,
- /* count */ 1,
- /* append */ false);
+ this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, DEFAULT_APPEND);
}
@@ -280,10 +307,7 @@ public class FileHandler
public FileHandler(String pattern, boolean append)
throws IOException, SecurityException
{
- this(pattern,
- /* limit */ 0,
- /* count */ 1,
- append);
+ this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, append);
}
@@ -292,9 +316,7 @@ public class FileHandler
throws IOException, SecurityException
{
this(pattern, limit, count,
- LogManager.getBooleanProperty(
- "java.util.logging.FileHandler.append",
- /* default */ false));
+ LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
}
@@ -350,7 +372,7 @@ public class FileHandler
throws IOException, SecurityException
{
super(/* output stream, created below */ null,
- "java.util.logging.FileHandler",
+ PROPERTY_PREFIX,
/* default level */ Level.ALL,
/* formatter */ null,
/* default formatter */ XMLFormatter.class);
@@ -358,14 +380,14 @@ public class FileHandler
if ((limit <0) || (count < 1))
throw new IllegalArgumentException();
- this.pattern = pattern;
+ this.pattern = pattern != null ? pattern : DEFAULT_PATTERN;
this.limit = limit;
this.count = count;
this.append = append;
this.written = 0;
this.logFiles = new LinkedList ();
- setOutputStream (createFileStream (pattern, limit, count, append,
+ setOutputStream (createFileStream (this.pattern, limit, count, append,
/* generation */ 0));
}
@@ -389,10 +411,9 @@ public class FileHandler
* LogManager configuration property.
*/
if (pattern == null)
- pattern = LogManager.getLogManager().getProperty(
- "java.util.logging.FileHandler.pattern");
+ pattern = LogManager.getLogManager().getProperty(PATTERN_KEY);
if (pattern == null)
- pattern = "%h/java%u.log";
+ pattern = DEFAULT_PATTERN;
if (count > 1 && !has (pattern, 'g'))
pattern = pattern + ".%g";
diff --git a/libjava/classpath/java/util/logging/LogManager.java b/libjava/classpath/java/util/logging/LogManager.java
index e2604815b0c..e434651f87d 100644
--- a/libjava/classpath/java/util/logging/LogManager.java
+++ b/libjava/classpath/java/util/logging/LogManager.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package java.util.logging;
+import gnu.classpath.SystemProperties;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.ByteArrayInputStream;
@@ -50,12 +52,11 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
-import gnu.classpath.SystemProperties;
-
/**
* The <code>LogManager</code> maintains a hierarchical namespace
* of Logger objects and manages properties for configuring the logging
@@ -108,11 +109,23 @@ import gnu.classpath.SystemProperties;
public class LogManager
{
/**
+ * The object name for the logging management bean.
+ * @since 1.5
+ */
+ public static final String LOGGING_MXBEAN_NAME
+ = "java.util.logging:type=Logging";
+
+ /**
* The singleton LogManager instance.
*/
private static LogManager logManager;
/**
+ * The singleton logging bean.
+ */
+ private static LoggingMXBean loggingBean;
+
+ /**
* The registered named loggers; maps the name of a Logger to
* a WeakReference to it.
*/
@@ -836,11 +849,11 @@ public class LogManager
}
catch (ClassNotFoundException e)
{
- warn(property, className, "class not found");
+ warn(property, className, "class not found", e);
}
catch (IllegalAccessException e)
{
- warn(property, className, "illegal access");
+ warn(property, className, "illegal access", e);
}
catch (InstantiationException e)
{
@@ -848,7 +861,7 @@ public class LogManager
}
catch (java.lang.LinkageError e)
{
- warn(property, className, "linkage error");
+ warn(property, className, "linkage error", e);
}
return null;
@@ -904,4 +917,63 @@ public class LogManager
}
}
+ /**
+ * Return the logging bean. There is a single logging bean per
+ * VM instance.
+ * @since 1.5
+ */
+ public static synchronized LoggingMXBean getLoggingMXBean()
+ {
+ if (loggingBean == null)
+ {
+ loggingBean = new LoggingMXBean()
+ {
+ public String getLoggerLevel(String logger)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ return null;
+ Level lev = l.getLevel();
+ if (lev == null)
+ return "";
+ return lev.getName();
+ }
+
+ public List getLoggerNames()
+ {
+ LogManager mgr = getLogManager();
+ // This is inefficient, but perhaps better for maintenance.
+ return Collections.list(mgr.getLoggerNames());
+ }
+
+ public String getParentLoggerName(String logger)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ return null;
+ l = l.getParent();
+ if (l == null)
+ return "";
+ return l.getName();
+ }
+
+ public void setLoggerLevel(String logger, String level)
+ {
+ LogManager mgr = getLogManager();
+ Logger l = mgr.getLogger(logger);
+ if (l == null)
+ throw new IllegalArgumentException("no logger named " + logger);
+ Level newLevel;
+ if (level == null)
+ newLevel = null;
+ else
+ newLevel = Level.parse(level);
+ l.setLevel(newLevel);
+ }
+ };
+ }
+ return loggingBean;
+ }
}
diff --git a/libjava/classpath/java/util/logging/Logger.java b/libjava/classpath/java/util/logging/Logger.java
index 29f19e440ca..46588e542ee 100644
--- a/libjava/classpath/java/util/logging/Logger.java
+++ b/libjava/classpath/java/util/logging/Logger.java
@@ -1209,7 +1209,7 @@ public class Logger
/**
* Reset and close handlers attached to this logger. This function is package
- * private because it must only be avaiable to the LogManager.
+ * private because it must only be available to the LogManager.
*/
void resetLogger()
{
diff --git a/libjava/classpath/java/util/logging/LoggingMXBean.java b/libjava/classpath/java/util/logging/LoggingMXBean.java
new file mode 100644
index 00000000000..5f866c980d7
--- /dev/null
+++ b/libjava/classpath/java/util/logging/LoggingMXBean.java
@@ -0,0 +1,85 @@
+/* LoggingMxBean.java -- Management interface for logging
+ 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.logging;
+
+import java.util.List;
+
+/**
+ * This interface represents the management interface for logging.
+ * There is a single logging bean per VM instance, which can be
+ * retrieved via {@link LogManager#getLoggingMXBean()}.
+ *
+ * @since 1.5
+ */
+public interface LoggingMXBean
+{
+ /**
+ * Return the name of the logging level given the name of
+ * a logger. Returns null if no such logger exists.
+ * @param logger the logger's name
+ * @return the logging level's name, or null
+ */
+ String getLoggerLevel(String logger);
+
+ /**
+ * Return a list of all logger names.
+ */
+ List/*<String>*/ getLoggerNames();
+
+ /**
+ * Return the name of the parent of the indicated logger.
+ * If no such logger exists, returns null. If the logger
+ * is the root logger, returns the empty string.
+ * @param logger the logger's name
+ * @return the name of the logger's parent, or null
+ */
+ String getParentLoggerName(String logger);
+
+ /**
+ * Sets the logging level for a particular logger.
+ *
+ * @param logger the name of the logger
+ * @param level the name of the new logging level, or null
+ * @throws IllegalArgumentException if the level is not
+ * recognized, or if the logger does not exist
+ * @throws SecurityException if access is denied;
+ * see {@link Logger#setLevel(Level)}
+ */
+ void setLoggerLevel(String logger, String level);
+}
diff --git a/libjava/classpath/java/util/prefs/Preferences.java b/libjava/classpath/java/util/prefs/Preferences.java
index a78381bfa1e..297759d88a4 100644
--- a/libjava/classpath/java/util/prefs/Preferences.java
+++ b/libjava/classpath/java/util/prefs/Preferences.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.util.prefs;
+import gnu.classpath.ServiceFactory;
import gnu.java.util.prefs.NodeReader;
import java.io.IOException;
@@ -45,6 +46,7 @@ import java.io.OutputStream;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
+import java.util.Iterator;
/**
* Preference node containing key value entries and subnodes.
@@ -205,6 +207,17 @@ public abstract class Preferences {
}
});
+ // Still no factory? Try to see if we have one defined
+ // as a System Preference
+ if (factory == null)
+ {
+ Iterator iter = ServiceFactory.lookupProviders
+ (PreferencesFactory.class, null);
+
+ if (iter != null && iter.hasNext())
+ factory = (PreferencesFactory) iter.next();
+ }
+
// Still no factory? Use our default.
if (factory == null)
{
diff --git a/libjava/classpath/java/util/regex/Matcher.java b/libjava/classpath/java/util/regex/Matcher.java
index e86be25fc41..25e73810e95 100644
--- a/libjava/classpath/java/util/regex/Matcher.java
+++ b/libjava/classpath/java/util/regex/Matcher.java
@@ -38,9 +38,9 @@ exception statement from your version. */
package java.util.regex;
-import gnu.regexp.RE;
-import gnu.regexp.REMatch;
-import gnu.regexp.CharIndexed;
+import gnu.java.util.regex.CharIndexed;
+import gnu.java.util.regex.RE;
+import gnu.java.util.regex.REMatch;
/**
* Instance of a regular expression applied to a char sequence.
diff --git a/libjava/classpath/java/util/regex/Pattern.java b/libjava/classpath/java/util/regex/Pattern.java
index 8c1998343a6..d716fa4e62d 100644
--- a/libjava/classpath/java/util/regex/Pattern.java
+++ b/libjava/classpath/java/util/regex/Pattern.java
@@ -37,9 +37,9 @@ exception statement from your version. */
package java.util.regex;
-import gnu.regexp.RE;
-import gnu.regexp.REException;
-import gnu.regexp.RESyntax;
+import gnu.java.util.regex.RE;
+import gnu.java.util.regex.REException;
+import gnu.java.util.regex.RESyntax;
import java.io.Serializable;
import java.util.ArrayList;
@@ -73,12 +73,17 @@ public final class Pattern implements Serializable
this.regex = regex;
this.flags = flags;
+ RESyntax syntax = RESyntax.RE_SYNTAX_JAVA_1_4;
int gnuFlags = 0;
gnuFlags |= RE.REG_ICASE_USASCII;
if ((flags & CASE_INSENSITIVE) != 0)
gnuFlags |= RE.REG_ICASE;
if ((flags & MULTILINE) != 0)
- gnuFlags |= RE.REG_MULTILINE;
+ {
+ gnuFlags |= RE.REG_MULTILINE;
+ syntax = new RESyntax(syntax);
+ syntax.setLineSeparator(null);
+ }
if ((flags & DOTALL) != 0)
gnuFlags |= RE.REG_DOT_NEWLINE;
if ((flags & UNICODE_CASE) != 0)
@@ -86,7 +91,6 @@ public final class Pattern implements Serializable
// not yet supported:
// if ((flags & CANON_EQ) != 0) gnuFlags =
- RESyntax syntax = RESyntax.RE_SYNTAX_JAVA_1_4;
if ((flags & UNIX_LINES) != 0)
{
// Use a syntax set with \n for linefeeds?
diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java
index 10c8365b833..47ced0fb84f 100644
--- a/libjava/classpath/java/util/zip/ZipFile.java
+++ b/libjava/classpath/java/util/zip/ZipFile.java
@@ -49,8 +49,8 @@ import java.io.InputStream;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
/**
* This class represents a Zip archive. You can ask for the contained
@@ -88,7 +88,7 @@ public class ZipFile implements ZipConstants
private final RandomAccessFile raf;
// The entries of this zip file when initialized and not yet closed.
- private HashMap entries;
+ private LinkedHashMap entries;
private boolean closed = false;
@@ -250,7 +250,7 @@ public class ZipFile implements ZipConstants
throw new EOFException(name);
int centralOffset = inp.readLeInt();
- entries = new HashMap(count+count/2);
+ entries = new LinkedHashMap(count+count/2);
inp.seek(centralOffset);
for (int i = 0; i < count; i++)
@@ -347,7 +347,7 @@ public class ZipFile implements ZipConstants
* @exception IllegalStateException when the ZipFile has already been closed.
* @exception IOException when the entries could not be read.
*/
- private HashMap getEntries() throws IOException
+ private LinkedHashMap getEntries() throws IOException
{
synchronized(raf)
{
@@ -375,7 +375,7 @@ public class ZipFile implements ZipConstants
try
{
- HashMap entries = getEntries();
+ LinkedHashMap entries = getEntries();
ZipEntry entry = (ZipEntry) entries.get(name);
// If we didn't find it, maybe it's a directory.
if (entry == null && !name.endsWith("/"))
@@ -414,7 +414,7 @@ public class ZipFile implements ZipConstants
{
checkClosed();
- HashMap entries = getEntries();
+ LinkedHashMap entries = getEntries();
String name = entry.getName();
ZipEntry zipEntry = (ZipEntry) entries.get(name);
if (zipEntry == null)
diff --git a/libjava/classpath/javax/accessibility/AccessibleContext.java b/libjava/classpath/javax/accessibility/AccessibleContext.java
index 972f4feae92..ee3a5287b42 100644
--- a/libjava/classpath/javax/accessibility/AccessibleContext.java
+++ b/libjava/classpath/javax/accessibility/AccessibleContext.java
@@ -496,7 +496,7 @@ public abstract class AccessibleContext
}
/**
- * Get any supported accessible compoent. The default implementation returns
+ * Get any supported accessible component. The default implementation returns
* null.
*
* @return the supported component, or null
diff --git a/libjava/classpath/javax/crypto/Cipher.java b/libjava/classpath/javax/crypto/Cipher.java
index 1f68ea60528..1b56a07f4aa 100644
--- a/libjava/classpath/javax/crypto/Cipher.java
+++ b/libjava/classpath/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/libjava/classpath/javax/crypto/spec/PBEKeySpec.java b/libjava/classpath/javax/crypto/spec/PBEKeySpec.java
index d17dc41eef7..54b821a79fd 100644
--- a/libjava/classpath/javax/crypto/spec/PBEKeySpec.java
+++ b/libjava/classpath/javax/crypto/spec/PBEKeySpec.java
@@ -1,5 +1,5 @@
/* PBEKeySpec.java -- Wrapper for password-based keys.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -76,47 +76,74 @@ public class PBEKeySpec implements KeySpec
/** The salt. */
private byte[] salt;
+ /** The password state */
+ private boolean passwordValid = true;
+
// Constructors.
// ------------------------------------------------------------------------
/**
* Create a new PBE key spec with just a password.
- *
+ * <p>
+ * A copy of the password argument is stored instead of the argument itself.
+ *
* @param password The password char array.
*/
public PBEKeySpec(char[] password)
{
- this(password, null, 0, 0);
+ setPassword(password);
+
+ // load the default values for unspecified variables.
+ salt = null;
+ iterationCount = 0;
+ keyLength = 0;
}
/**
* Create a PBE key spec with a password, salt, and iteration count.
- *
- * @param password The password char array.
- * @param salt The salt bytes.
+ * <p>
+ * A copy of the password and salt arguments are stored instead of the
+ * arguments themselves.
+ *
+ * @param password The password char array.
+ * @param salt The salt bytes.
* @param iterationCount The iteration count.
+ * @throws NullPointerException If salt is null
+ * @throws IllegalArgumentException If salt is an empty array, or
+ * iterationCount is negative
*/
public PBEKeySpec(char[] password, byte[] salt, int iterationCount)
{
- this(password, salt, iterationCount, 0);
+ setPassword(password);
+ setSalt(salt);
+ setIterationCount(iterationCount);
+
+ // load default values into unspecified variables.
+ keyLength = 0;
}
/**
- * Create a PBE key spec with a password, salt, iteration count, and
- * key length.
- *
- * @param password The password char array.
- * @param salt The salt bytes.
+ * Create a PBE key spec with a password, salt, iteration count, and key
+ * length.
+ * <p>
+ * A copy of the password and salt arguments are stored instead of the
+ * arguments themselves.
+ *
+ * @param password The password char array.
+ * @param salt The salt bytes.
* @param iterationCount The iteration count.
- * @param keyLength The generated key length.
+ * @param keyLength The generated key length.
+ * @throws NullPointerException If salt is null
+ * @throws IllegalArgumentException If salt is an empty array, if
+ * iterationCount or keyLength is negative
*/
public PBEKeySpec(char[] password, byte[] salt, int iterationCount,
int keyLength)
{
- this.password = password;
- this.salt = salt;
- this.iterationCount = iterationCount;
- this.keyLength = keyLength;
+ setPassword(password);
+ setSalt(salt);
+ setIterationCount(iterationCount);
+ setKeyLength(keyLength);
}
// Instance methods.
@@ -124,14 +151,19 @@ public class PBEKeySpec implements KeySpec
/**
* Clear the password array by filling it with null characters.
+ * <p>
+ * This clears the stored copy of the password, not the original char array
+ * used to create the password.
*/
public final void clearPassword()
{
- if (password == null) return;
+ if (password == null)
+ return;
for (int i = 0; i < password.length; i++)
- {
- password[i] = '\u0000';
- }
+ password[i] = '\u0000';
+
+ // since the password is cleared, it is no longer valid
+ passwordValid = false;
}
/**
@@ -155,22 +187,95 @@ public class PBEKeySpec implements KeySpec
}
/**
- * Get the password character array.
- *
- * @return The password.
+ * Get the password character array copy.
+ * <p>
+ * This returns a copy of the password, not the password itself.
+ *
+ * @return a clone of the password.
+ * @throws IllegalStateException If {@link #clearPassword()} has already been
+ * called.
*/
public final char[] getPassword()
{
- return password;
+ if (! passwordValid)
+ throw new IllegalStateException("clearPassword() has been called, the "
+ + "password is no longer valid");
+ return (char[]) password.clone();
}
/**
- * Get the salt bytes.
- *
+ * Get the salt bytes array copy.
+ * <p>
+ * This returns a copy of the salt, not the salt itself.
+ *
* @return The salt.
*/
public final byte[] getSalt()
{
- return salt;
+ if (salt != null)
+ return (byte[]) salt.clone();
+ return null;
+ }
+
+ /**
+ * Set the password char array.
+ * <p>
+ * A copy of the password argument is stored instead of the argument itself.
+ *
+ * @param password The password to be set
+ */
+ private void setPassword(char[] password)
+ {
+ if (password != null)
+ this.password = (char[]) password.clone();
+ else
+ this.password = new char[0];
+
+ passwordValid = true;
+ }
+
+ /**
+ * Set the salt byte array.
+ * <p>
+ * A copy of the salt arguments is stored instead of the argument itself.
+ *
+ * @param salt The salt to be set.
+ * @throws NullPointerException If the salt is null.
+ * @throws IllegalArgumentException If the salt is an empty array.
+ */
+ private void setSalt(byte[] salt)
+ {
+ if (salt.length == 0)
+ throw new IllegalArgumentException("salt MUST NOT be an empty byte array");
+
+ this.salt = (byte[]) salt.clone();
+ }
+
+ /**
+ * Set the iterationCount.
+ *
+ * @param iterationCount The iteration count to be set.
+ * @throws IllegalArgumentException If the iterationCount is negative.
+ */
+ private void setIterationCount(int iterationCount)
+ {
+ if (iterationCount < 0)
+ throw new IllegalArgumentException("iterationCount MUST be positive");
+
+ this.iterationCount = iterationCount;
+ }
+
+ /**
+ * Set the keyLength.
+ *
+ * @param keyLength The keyLength to be set.
+ * @throws IllegalArgumentException if the keyLength is negative.
+ */
+ private void setKeyLength(int keyLength)
+ {
+ if (keyLength < 0)
+ throw new IllegalArgumentException("keyLength MUST be positive");
+
+ this.keyLength = keyLength;
}
}
diff --git a/libjava/classpath/javax/crypto/spec/SecretKeySpec.java b/libjava/classpath/javax/crypto/spec/SecretKeySpec.java
index 4caf51a4615..86c4e05d4c9 100644
--- a/libjava/classpath/javax/crypto/spec/SecretKeySpec.java
+++ b/libjava/classpath/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/libjava/classpath/javax/imageio/spi/IIORegistry.java b/libjava/classpath/javax/imageio/spi/IIORegistry.java
index 3e9b2c289cb..e762a96279f 100644
--- a/libjava/classpath/javax/imageio/spi/IIORegistry.java
+++ b/libjava/classpath/javax/imageio/spi/IIORegistry.java
@@ -46,6 +46,11 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import gnu.javax.imageio.bmp.BMPImageReaderSpi;
+import gnu.javax.imageio.bmp.BMPImageWriterSpi;
+import gnu.javax.imageio.gif.GIFImageReaderSpi;
+import gnu.javax.imageio.png.PNGImageReaderSpi;
+
public final class IIORegistry extends ServiceRegistry
{
private static final HashSet defaultCategories = new HashSet();
@@ -81,6 +86,10 @@ public final class IIORegistry extends ServiceRegistry
super(defaultCategories.iterator());
// XXX: Register built-in Spis here.
+ registerServiceProvider(new PNGImageReaderSpi()); // Register PNG decoder.
+ registerServiceProvider(new GIFImageReaderSpi()); // Register GIF decoder.
+ registerServiceProvider(new BMPImageReaderSpi());
+ registerServiceProvider(new BMPImageWriterSpi());
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof ClasspathToolkit)
diff --git a/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java b/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
index c1a5dd404bc..71eec41a998 100644
--- a/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
+++ b/libjava/classpath/javax/imageio/stream/ImageInputStreamImpl.java
@@ -81,7 +81,8 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
protected void finalize()
throws Throwable
{
- close();
+ if (!closed)
+ close();
}
public void flush()
@@ -154,38 +155,43 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
}
catch (IOException e)
{
- // Ignored.
+ throw new RuntimeException(e);
}
}
public abstract int read()
throws IOException;
+ public abstract int read(byte[] data, int offset, int len)
+ throws IOException;
+
public int read(byte[] data)
throws IOException
{
return read(data, 0, data.length);
}
- public abstract int read(byte[] data, int offset, int len)
- throws IOException;
-
public int readBit()
throws IOException
{
checkClosed();
- // Calc new bit offset here, readByte resets it.
+ // Calculate new bit offset here as readByte clears it.
int newOffset = (bitOffset + 1) & 0x7;
+ // Clears bitOffset.
byte data = readByte();
-
- if (bitOffset != 0)
+
+ // If newOffset is 0 it means we just read the 8th bit in a byte
+ // and therefore we want to advance to the next byte. Otherwise
+ // we want to roll back the stream one byte so that future readBit
+ // calls read bits from the same current byte.
+ if (newOffset != 0)
{
- seek(getStreamPosition() - 1);
- data = (byte) (data >> (8 - newOffset));
+ seek(getStreamPosition() - 1);
+ data = (byte) (data >> (8 - newOffset));
}
-
+
bitOffset = newOffset;
return data & 0x1;
}
@@ -198,17 +204,13 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
if (numBits < 0 || numBits > 64)
throw new IllegalArgumentException();
- if (numBits == 0)
- return 0L;
-
long bits = 0L;
-
+
for (int i = 0; i < numBits; i++)
{
bits <<= 1;
bits |= readBit();
}
-
return bits;
}
@@ -216,12 +218,15 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
throws IOException
{
byte data = readByte();
+
return data != 0;
}
public byte readByte()
throws IOException
{
+ checkClosed();
+
int data = read();
if (data == -1)
@@ -233,10 +238,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
public void readBytes(IIOByteBuffer buffer, int len)
throws IOException
{
- int result = read(buffer.getData(), buffer.getOffset(), len);
-
- if (result == -1 || result < len)
- throw new EOFException();
+ readFullyPrivate(buffer.getData(), buffer.getOffset(), len);
buffer.setLength(len);
}
@@ -250,13 +252,13 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
public double readDouble()
throws IOException
{
- return (double) readLong();
+ return Double.longBitsToDouble(readLong());
}
public float readFloat()
throws IOException
{
- return (float) readInt();
+ return Float.intBitsToFloat(readInt());
}
public void readFully(byte[] data)
@@ -268,8 +270,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
public void readFully(byte[] data, int offset, int len)
throws IOException
{
- for (int i = 0; i < len; ++i)
- data[offset + i] = readByte();
+ readFullyPrivate(data, offset, len);
}
public void readFully(char[] data, int offset, int len)
@@ -317,23 +318,20 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
public int readInt()
throws IOException
{
- int result = read(buffer, 0, 4);
+ readFullyPrivate(buffer, 0, 4);
- if (result == -1)
- throw new EOFException();
-
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
- {
- return ((buffer[0] & 0xff)
- + (buffer[1] << 8)
- + (buffer[2] << 16)
- + (buffer[3] << 24));
- }
+ return (int)
+ (((int) (buffer[0] & 0xff) << 0)
+ | ((int) (buffer[1] & 0xff) << 8)
+ | ((int) (buffer[2] & 0xff) << 16)
+ | ((int) (buffer[3] & 0xff) << 24));
- return ((buffer[4] << 24)
- + (buffer[3] << 16)
- + (buffer[2] << 8)
- + (buffer[1] & 0xff));
+ return (int)
+ (((int) (buffer[0] & 0xff) << 24)
+ + ((int) (buffer[1] & 0xff) << 16)
+ + ((int) (buffer[2] & 0xff) << 8)
+ + ((int) (buffer[3] & 0xff) << 0));
}
public String readLine()
@@ -345,94 +343,101 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
boolean eol = false;
StringBuffer buffer = new StringBuffer();
- while (!eol && (c = read()) != -1)
+ c = read();
+ if (c == -1)
+ return null;
+
+ while (!eol)
{
switch(c)
{
case '\r':
- // Consume following \n'
- long oldPosition = getStreamPosition();
- if (read() != '\n')
- seek(oldPosition);
+ // Check for following '\n'.
+ long oldPosition = getStreamPosition();
+ c = read();
+ if (c == -1 || c == '\n')
+ eol = true;
+ else
+ {
+ seek(oldPosition);
+ eol = true;
+ }
+ continue;
+
case '\n':
eol = true;
- break;
+ continue;
+
default:
buffer.append((char) c);
break;
}
+ c = read();
+ if (c == -1)
+ eol = true;
}
- if (c == -1 && buffer.length() == 0)
- return null;
-
return buffer.toString();
}
public long readLong()
throws IOException
{
- int result = read(buffer, 0, 8);
+ readFullyPrivate(buffer, 0, 8);
- if (result == -1)
- throw new EOFException();
-
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
- {
- return ((buffer[0] & 0xff)
- + (((buffer[1] & 0xff)) << 8)
- + (((buffer[2] & 0xff)) << 16)
- + (((buffer[3] & 0xffL)) << 24)
- + (((buffer[4] & 0xffL)) << 32)
- + (((buffer[5] & 0xffL)) << 40)
- + (((buffer[6] & 0xffL)) << 48)
- + (((long) buffer[7]) << 56));
- }
-
- return ((((long) buffer[7]) << 56)
- + ((buffer[6] & 0xffL) << 48)
- + ((buffer[5] & 0xffL) << 40)
- + ((buffer[4] & 0xffL) << 32)
- + ((buffer[3] & 0xffL) << 24)
- + ((buffer[2] & 0xff) << 16)
- + ((buffer[1] & 0xff) << 8)
- + (buffer[0] & 0xff));
+ return (long)
+ (((long) (buffer[0] & 0xff) << 0)
+ | ((long) (buffer[1] & 0xff) << 8)
+ | ((long) (buffer[2] & 0xff) << 16)
+ | ((long) (buffer[3] & 0xff) << 24)
+ | ((long) (buffer[4] & 0xff) << 32)
+ | ((long) (buffer[5] & 0xff) << 40)
+ | ((long) (buffer[6] & 0xff) << 48)
+ | ((long) (buffer[7] & 0xff) << 56));
+
+ return (long)
+ (((long) (buffer[0] & 0xff) << 56)
+ | ((long) (buffer[1] & 0xff) << 48)
+ | ((long) (buffer[2] & 0xff) << 40)
+ | ((long) (buffer[3] & 0xff) << 32)
+ | ((long) (buffer[4] & 0xff) << 24)
+ | ((long) (buffer[5] & 0xff) << 16)
+ | ((long) (buffer[6] & 0xff) << 8)
+ | ((long) (buffer[7] & 0xff) << 0));
}
public short readShort()
throws IOException
{
- int result = read(buffer, 0, 2);
+ readFullyPrivate(buffer, 0, 2);
- if (result == -1)
- throw new EOFException();
-
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
- {
- return (short) ((buffer[0] & 0xff)
- + (buffer[1] << 8));
- }
+ return (short)
+ (((short) (buffer[0] & 0xff) << 0)
+ | ((short) (buffer[1] & 0xff) << 8));
- return (short) ((buffer[0] << 8)
- + (buffer[1] & 0xff));
+ return (short)
+ (((short) (buffer[0] & 0xff) << 8)
+ | ((short) (buffer[1] & 0xff) << 0));
}
public int readUnsignedByte()
throws IOException
{
- return readByte() & 0xff;
+ return (int) readByte() & 0xff;
}
public long readUnsignedInt()
throws IOException
{
- return readInt() & 0xffffffff;
+ return (long) readInt() & 0xffffffffL;
}
public int readUnsignedShort()
throws IOException
{
- return readShort() & 0xffff;
+ return (int) readShort() & 0xffff;
}
public String readUTF()
@@ -442,7 +447,8 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
String data;
ByteOrder old = getByteOrder();
- setByteOrder(ByteOrder.BIG_ENDIAN); // Strings are always big endian.
+ // Strings are always big endian.
+ setByteOrder(ByteOrder.BIG_ENDIAN);
try
{
@@ -483,7 +489,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
checkClosed();
if (bitOffset < 0 || bitOffset > 7)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("bitOffset not between 0 and 7 inclusive");
this.bitOffset = bitOffset;
}
@@ -512,4 +518,23 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
bitOffset = 0;
return num;
}
+
+ private void readFullyPrivate (byte[] buf, int offset, int len) throws IOException
+ {
+ checkClosed();
+
+ if (len < 0)
+ throw new IndexOutOfBoundsException("Negative length: " + len);
+
+ while (len > 0)
+ {
+ // read will block until some data is available.
+ int numread = read (buf, offset, len);
+ if (numread < 0)
+ throw new EOFException ();
+ len -= numread;
+ offset += numread;
+ }
+ bitOffset = 0;
+ }
}
diff --git a/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java b/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java
index 935408c9a00..da8a958bb64 100644
--- a/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java
+++ b/libjava/classpath/javax/imageio/stream/MemoryCacheImageInputStream.java
@@ -38,10 +38,11 @@ exception statement from your version. */
package javax.imageio.stream;
-import gnu.classpath.NotImplementedException;
-
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
/**
* @author Michael Koch (konqueror@gmx.de)
@@ -49,10 +50,15 @@ import java.io.InputStream;
public class MemoryCacheImageInputStream extends ImageInputStreamImpl
{
private InputStream stream;
+ private BufferedInputStream buffer;
+
+ private int READLIMIT = 2048;
public MemoryCacheImageInputStream(InputStream stream)
{
this.stream = stream;
+ buffer = new BufferedInputStream(stream);
+ buffer.mark(READLIMIT);
}
public void close()
@@ -63,10 +69,13 @@ public class MemoryCacheImageInputStream extends ImageInputStreamImpl
}
public void flushBefore(long position)
- throws IOException, NotImplementedException
+ throws IOException
{
- // FIXME: Implement me.
- throw new Error("not implemented");
+ long prevFlushedPosition = getFlushedPosition();
+ super.flushBefore(position);
+ buffer.reset();
+ buffer.skip(getFlushedPosition() - prevFlushedPosition);
+ buffer.mark(READLIMIT);
}
public boolean isCached()
@@ -88,13 +97,33 @@ public class MemoryCacheImageInputStream extends ImageInputStreamImpl
throws IOException
{
setBitOffset(0);
- return stream.read();
+ int retval = buffer.read();
+
+ if (retval != -1)
+ streamPos++;
+
+ return retval;
}
public int read(byte[] data, int offset, int len)
throws IOException
{
setBitOffset(0);
- return stream.read(data, offset, len);
+ int retval = buffer.read(data, offset, len);
+
+ if (retval != -1)
+ {
+ streamPos += retval;
+ }
+
+ return retval;
+ }
+
+ public void seek(long position)
+ throws IOException
+ {
+ super.seek(position);
+ buffer.reset();
+ buffer.skip(position - getFlushedPosition());
}
}
diff --git a/libjava/classpath/javax/management/Attribute.java b/libjava/classpath/javax/management/Attribute.java
index 5c4a65e4088..ece949532d0 100644
--- a/libjava/classpath/javax/management/Attribute.java
+++ b/libjava/classpath/javax/management/Attribute.java
@@ -51,6 +51,11 @@ public class Attribute
implements Serializable
{
/**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 2484220110589082382L;
+
+ /**
* The attribute name.
*/
final String m_name;
diff --git a/libjava/classpath/javax/management/AttributeList.java b/libjava/classpath/javax/management/AttributeList.java
new file mode 100644
index 00000000000..6823df3f28a
--- /dev/null
+++ b/libjava/classpath/javax/management/AttributeList.java
@@ -0,0 +1,220 @@
+/* AttributeList.java -- A list of MBean attributes.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.util.ArrayList;
+
+/**
+ * Represents a list of MBean {@link Attribute}s, with their
+ * names and values. This is implemented as an
+ * {@link java.util.ArrayList} extension, with additional
+ * methods typed to only allow the addition of {@link Attribute}s.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class AttributeList
+ extends ArrayList
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -4077085769279709076L;
+
+ /**
+ * Constructs an empty list with an initial capacity of ten.
+ *
+ * @see java.util.ArrayList#ArrayList()
+ */
+ public AttributeList()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an {@link AttributeList} using the contents
+ * of an existing list. The initial capacity is 110% of the
+ * size of the specified list.
+ *
+ * @param list the list to use to fill this list.
+ * @see java.util.ArrayList#ArrayList(java.util.Collection)
+ */
+ public AttributeList(AttributeList list)
+ {
+ super(list);
+ }
+
+ /**
+ * Constructs an empty list with the specified initial capacity.
+ *
+ * @param capacity the initial capacity of the list.
+ * @see java.util.ArrayList#ArrayList(int)
+ */
+ public AttributeList(int capacity)
+ {
+ super(capacity);
+ }
+
+ /**
+ * Adds the specified {@link Attribute} to the end of the list.
+ *
+ * @param attribute the attribute to add.
+ * @see java.util.Arraylist#add(Object)
+ */
+ public void add(Attribute attribute)
+ {
+ super.add(attribute);
+ }
+
+ /**
+ * <p>
+ * Adds the specified {@link Attribute} at the supplied index.
+ * Any attribute already at that index is moved up one place
+ * in the list to the position <code>(index + 1)</code>.
+ * Likewise, the attribute at <code>(index + 1)</code> is
+ * also moved up one place, continuing until the final
+ * attribute in the list moves to a new position, increasing
+ * the size of the list.
+ * </p>
+ * <p>
+ * If the index is invalid (i.e. it is smaller than zero, or
+ * greater than the current size of the list), a
+ * @link{RuntimeOperationsException} is thrown, which wraps
+ * the @link{IndexOutOfBoundsException} from the underlying
+ * array list.
+ * </p>
+ *
+ * @param index the index at which to place the new attribute.
+ * @param attribute the new attribute to add.
+ * @throws RuntimeOperationsException if <code>index < 0</code>
+ * or <code>index > size()</code>
+ * @see java.util.ArrayList#add(int, Object)
+ */
+ public void add(int index, Attribute attribute)
+ {
+ try
+ {
+ super.add(index, attribute);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new RuntimeOperationsException(e, "Invalid index.");
+ }
+ }
+
+ /**
+ * Adds all the {@link Attribute}s from the supplied list
+ * to the end of this list, in the order they are returned
+ * by the list's {@link java.util.Iterator}.
+ *
+ * @param list the list of attributes to add.
+ * @return true if the list changed.
+ * @see java.util.ArrayList#addAll(Collection)
+ */
+ public boolean addAll(AttributeList list)
+ {
+ return super.addAll(list);
+ }
+
+ /**
+ * <p>
+ * Adds all the {@link Attribute}s from the supplied list
+ * to this list, at the specified index. The attributes
+ * are added in the order they are returned by the
+ * list's {@link java.util.Iterator}. Any attribute already
+ * at that index is moved up one place in the list to the
+ * position <code>(index + list.size())</code>.
+ * Likewise, the attribute at <code>(index + list.size())</code>
+ * is also moved up one place, continuing until the final
+ * attribute in the original list.
+ * </p>
+ * <p>
+ * If the index is invalid (i.e. it is smaller than zero, or
+ * greater than the current size of the list), a
+ * @link{RuntimeOperationsException} is thrown, which wraps
+ * the @link{IndexOutOfBoundsException} from the underlying
+ * array list.
+ * </p>
+ *
+ * @param index the index at which to place the new attribute.
+ * @param list the list of attributes to add.
+ * @return true if the list changed.
+ * @throws RuntimeOperationsException if <code>index < 0</code>
+ * or <code>index > size()</code>
+ * @see java.util.ArrayList#addAll(int, Collection)
+ */
+ public boolean addAll(int index, AttributeList list)
+ {
+ try
+ {
+ return super.addAll(index, list);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new RuntimeOperationsException(e, "Invalid index.");
+ }
+ }
+
+ /**
+ * Replaces the attribute at the specified index with the one
+ * supplied. If the index is invalid (i.e. it is smaller than
+ * zero, or greater than the current size of the list), a
+ * @link{RuntimeOperationsException} is thrown, which wraps
+ * the @link{IndexOutOfBoundsException} from the underlying
+ * array list.
+ *
+ * @param index the index at which to place the new attribute.
+ * @param attribute the new attribute to add.
+ * @throws RuntimeOperationsException if <code>index < 0</code>
+ * or <code>index > size()</code>
+ * @see java.util.ArrayList#set(int, Object)
+ */
+ public void set(int index, Attribute attribute)
+ {
+ try
+ {
+ super.set(index, attribute);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new RuntimeOperationsException(e, "Invalid index.");
+ }
+ }
+
+}
diff --git a/libjava/classpath/javax/management/AttributeNotFoundException.java b/libjava/classpath/javax/management/AttributeNotFoundException.java
new file mode 100644
index 00000000000..2c6c698ebae
--- /dev/null
+++ b/libjava/classpath/javax/management/AttributeNotFoundException.java
@@ -0,0 +1,71 @@
+/* AttributeNotFoundException.java -- Thrown by unknown attributes.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+/**
+ * Thrown when a attribute is requested but can not be
+ * found.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class AttributeNotFoundException
+ extends OperationsException
+{
+
+ /**
+ * Constructs a new <code>AttributeNotFoundException</code>.
+ */
+ public AttributeNotFoundException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>AttributeNotFoundException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public AttributeNotFoundException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/DynamicMBean.java b/libjava/classpath/javax/management/DynamicMBean.java
new file mode 100644
index 00000000000..80ea72cf43c
--- /dev/null
+++ b/libjava/classpath/javax/management/DynamicMBean.java
@@ -0,0 +1,162 @@
+/* DynamicMBean.java -- A management bean with a dynamic interface.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+/**
+ * Represents a management bean that provides a
+ * dynamic interface. Users of a {@link DynamicMBean}
+ * may retrieve information about its attributes at
+ * runtime and use this information to dynamically
+ * obtain the corresponding values of these attributes.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface DynamicMBean
+{
+
+ /**
+ * Obtains the value of the specified attribute of the
+ * management bean. The management bean should perform
+ * a lookup for the named attribute, and return its value
+ * by calling the appropriate getter method, if possible.
+ *
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the specified attribute.
+ * @throws AttributeNotFoundException if the name does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws MBeanException if retrieving the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @see #setAttribute(String)
+ */
+ Object getAttribute(String name)
+ throws AttributeNotFoundException, MBeanException,
+ ReflectionException;
+
+ /**
+ * Obtains the values of each of the specified attributes
+ * of the management bean. The returned list includes
+ * those attributes that were retrieved and their
+ * corresponding values.
+ *
+ * @param names the names of the attributes to retrieve.
+ * @return a list of the retrieved attributes.
+ * @see #setAttributes(AttributeList)
+ */
+ AttributeList getAttributes(String[] names);
+
+ /**
+ * Returns an information object which lists the attributes
+ * and actions associated with the management bean.
+ *
+ * @return a description of the management bean, including
+ * all exposed attributes and actions.
+ */
+ MBeanInfo getMBeanInfo();
+
+ /**
+ * Invokes the specified action on the management bean using
+ * the supplied parameters. The signature of the action is
+ * specified by a {@link String} array, which lists the classes
+ * corresponding to each parameter. The class loader used to
+ * load these classes is the same as that used for loading the
+ * management bean itself.
+ *
+ * @param name the name of the action to invoke.
+ * @param params the parameters used to call the action.
+ * @param signature the signature of the action.
+ * @return the return value of the action.
+ * @throws MBeanException if the action throws an exception. The
+ * thrown exception is the cause of this
+ * exception.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to invoke the action. The
+ * thrown exception is the cause of
+ * this exception.
+ */
+ Object invoke(String name, Object[] params, String[] signature)
+ throws MBeanException, ReflectionException;
+
+ /**
+ * Sets the value of the specified attribute of the
+ * management bean. The management bean should perform
+ * a lookup for the named attribute, and sets its value
+ * using the associated setter method, if possible.
+ *
+ * @param attribute the attribute to set.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @see #getAttribute(String)
+ */
+ void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException;
+
+ /**
+ * Sets the value of each of the specified attributes
+ * to that supplied by the {@link Attribute} object.
+ * The returned list contains the attributes that were
+ * set and their new values.
+ *
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @see #getAttributes(AttributeList)
+ */
+ AttributeList setAttributes(AttributeList attributes);
+
+}
diff --git a/libjava/classpath/javax/management/IntrospectionException.java b/libjava/classpath/javax/management/IntrospectionException.java
new file mode 100644
index 00000000000..3b9d4b1ef6c
--- /dev/null
+++ b/libjava/classpath/javax/management/IntrospectionException.java
@@ -0,0 +1,78 @@
+/* IntrospectionException.java -- Thrown by bean introspection 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 javax.management;
+
+/**
+ * A general for all exceptions thrown during introspection
+ * operations on management beans. For example, such an
+ * exception may be thrown while constructing one of
+ * the <code>MBeanXXXInfo</code> classes.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class IntrospectionException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 1054516935875481725L;
+
+ /**
+ * Constructs a new <code>IntrospectionException</code>.
+ */
+ public IntrospectionException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>IntrospectionException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public IntrospectionException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/InvalidAttributeValueException.java b/libjava/classpath/javax/management/InvalidAttributeValueException.java
new file mode 100644
index 00000000000..f766eda7f3a
--- /dev/null
+++ b/libjava/classpath/javax/management/InvalidAttributeValueException.java
@@ -0,0 +1,71 @@
+/* InvalidAttributeValueException.java -- Thrown by invalid values.
+ 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 value is given for an attribute which
+ * is invalid.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InvalidAttributeValueException
+ extends OperationsException
+{
+
+ /**
+ * Constructs a new <code>InvalidAttributeValueException</code>.
+ */
+ public InvalidAttributeValueException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>InvalidAttributeValueException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public InvalidAttributeValueException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/JMException.java b/libjava/classpath/javax/management/JMException.java
new file mode 100644
index 00000000000..d05702575af
--- /dev/null
+++ b/libjava/classpath/javax/management/JMException.java
@@ -0,0 +1,71 @@
+/* JMException.java -- Thrown by the management classes.
+ 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;
+
+/**
+ * A general superclass for all non-runtime management
+ * exceptions.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class JMException
+ extends Exception
+{
+
+ /**
+ * Constructs a new <code>JMException</code>.
+ */
+ public JMException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>JMException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public JMException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/JMRuntimeException.java b/libjava/classpath/javax/management/JMRuntimeException.java
new file mode 100644
index 00000000000..ba14a19c4ce
--- /dev/null
+++ b/libjava/classpath/javax/management/JMRuntimeException.java
@@ -0,0 +1,71 @@
+/* JMRuntimeException.java -- Thrown by the management classes.
+ 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;
+
+/**
+ * A general superclass for all runtime management
+ * exceptions.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class JMRuntimeException
+ extends RuntimeException
+{
+
+ /**
+ * Constructs a new <code>JMRuntimeException</code>.
+ */
+ public JMRuntimeException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>JMRuntimeException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public JMRuntimeException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/ListenerNotFoundException.java b/libjava/classpath/javax/management/ListenerNotFoundException.java
new file mode 100644
index 00000000000..ea3cb74161b
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/MBeanAttributeInfo.java b/libjava/classpath/javax/management/MBeanAttributeInfo.java
new file mode 100644
index 00000000000..bded7e41a07
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanAttributeInfo.java
@@ -0,0 +1,301 @@
+/* MBeanAttributeInfo.java -- Information about an attribute of 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.lang.reflect.Method;
+
+/**
+ * Describes the attributes of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanAttributeInfo
+ extends MBeanFeatureInfo
+ implements Cloneable
+{
+
+ /**
+ * The type of the attribute.
+ *
+ * @serial the attribute type.
+ */
+ private String attributeType;
+
+ /**
+ * True if the attribute's value can be changed.
+ *
+ * @serial true if the value can be changed.
+ */
+ private boolean isWrite;
+
+ /**
+ * True if the attribute's value can be read.
+ *
+ * @serial true if the value can be read.
+ */
+ private boolean isRead;
+
+ /**
+ * True if the attribute is a boolean and thus
+ * has a isXXX accessor rather than a getXXX accessor.
+ *
+ * @serial true if the attribute has an isXXX accessor.
+ */
+ private boolean is;
+
+ /**
+ * Constructs a new {@link MBeanAttributeInfo} using the specified
+ * name and description, with the given accessor and mutator
+ * methods. A <code>null</code> value for the accessor method
+ * indicates that the value can not be read. A <code>null</code>
+ * value for the mutator method indicates that the value can not be
+ * changed.
+ *
+ * @param name the name of the attribute.
+ * @param desc a description of the attribute.
+ * @param getter the accessor method, or <code>null</code> if the value
+ * can not be read.
+ * @param setter the mutator method, or <code>null</code> if the value
+ * can not be changed.
+ * @throws IntrospectionException if both the accessor and mutator method
+ * are <code>null</code>.
+ */
+ public MBeanAttributeInfo(String name, String desc,
+ Method getter, Method setter)
+ throws IntrospectionException
+ {
+ super(name, desc);
+ if (getter == null && setter == null)
+ throw new IntrospectionException("Both the getter and setter methods can " +
+ "not be null.");
+ if (getter == null)
+ {
+ attributeType = setter.getParameterTypes()[0].getName();
+ isRead = false;
+ is = false;
+ }
+ else
+ {
+ attributeType = getter.getReturnType().getName();
+ isRead = true;
+ is = getter.getName().startsWith("is");
+ }
+ if (setter != null)
+ isWrite = true;
+ }
+
+ /**
+ * Constructs a new {@link MBeanAttributeInfo} using the specified
+ * name, description and type with the given settings for the accessor
+ * and mutator methods.
+ *
+ * @param name the name of the attribute.
+ * @param type the type of the attribute, in the form of its class name.
+ * @param desc a description of the attribute.
+ * @param isReadable true if the attribute's value can be read.
+ * @param isWritable true if the attribute's value can be changed.
+ * @param isIs true if the attribute uses an accessor of the form isXXX.
+ * @throws IllegalArgumentException if the attribute is both unreadable
+ * and unwritable.
+ */
+ public MBeanAttributeInfo(String name, String type, String desc,
+ boolean isReadable, boolean isWritable,
+ boolean isIs)
+ {
+ super(name, desc);
+ if (!isReadable && !isWritable)
+ throw new IllegalArgumentException("The attribute can not be both " +
+ "unreadable and unwritable.");
+ attributeType = type;
+ isRead = isReadable;
+ isWrite = isWritable;
+ is = isIs;
+ }
+
+ /**
+ * 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 MBeanAttributeInfo}, {@link Object#equals()}
+ * returns true for a comparison of both the name and
+ * description of this attribute with that of the specified
+ * object (performed by the superclass), and the type and
+ * boolean flags of the two instances are equal.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link MBeanAttributeInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>description.equals(object.getDescription())</code>,
+ * <code>attributeType.equals(object.getType())</code>,
+ * <code>isRead == object.isReadable()</code>,
+ * <code>isWrite == object.isWritable()</code>,
+ * <code>is == object.isIs()</code>
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof MBeanAttributeInfo))
+ return false;
+ if (!(super.equals(obj)))
+ return false;
+ MBeanAttributeInfo o = (MBeanAttributeInfo) obj;
+ return (attributeType.equals(o.getType()) &&
+ isRead == o.isReadable() &&
+ isWrite == o.isWritable() &&
+ is == o.isIs());
+ }
+
+ /**
+ * Returns the type of this attribute, in the form of its class name.
+ *
+ * @return the type of this attribute.
+ */
+ public String getType()
+ {
+ return attributeType;
+ }
+
+ /**
+ * Returns the hashcode of the attribute information as the sum of
+ * the hashcode of the superclass, the hashcode of the type,
+ * the hashcode of {@link #isReadable()}, twice the hashcode
+ * of {@link #isWritable()} and four times the hashcode
+ * of {@link #isIs()}.
+ *
+ * @return the hashcode of the attribute information.
+ */
+ public int hashCode()
+ {
+ return super.hashCode() + attributeType.hashCode()
+ + Boolean.valueOf(isRead).hashCode()
+ + (2 * Boolean.valueOf(isWrite).hashCode())
+ + (4 * Boolean.valueOf(is).hashCode());
+ }
+
+ /**
+ * Returns true if the accessor method of this attribute
+ * is of the form <code>isXXX</code>.
+ *
+ * @return true if the accessor takes the form <code>isXXX</code>.
+ */
+ public boolean isIs()
+ {
+ return is;
+ }
+
+ /**
+ * Returns true if value of this attribute can be read.
+ *
+ * @return true if the value of the attribute can be read.
+ */
+ public boolean isReadable()
+ {
+ return isRead;
+ }
+
+ /**
+ * Returns true if the value of this attribute can be changed.
+ *
+ * @return true if the value of the attribute can be changed.
+ */
+ public boolean isWritable()
+ {
+ return isWrite;
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanAttributeInfo</code>),
+ * the name, description and type of the attribute and the
+ * current settings of the {@link #isReadable()},
+ * {@link #isWritable()} and {@link #isIs()} properties.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ {
+ super.toString();
+ string = string.substring(0, string.length() - 1)
+ + ",type=" + attributeType
+ + ",isReadable=" + (isRead ? "yes" : "no")
+ + ",isWritable=" + (isWrite ? "yes" : "no")
+ + ",isIs=" + (is ? "yes" : "no")
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanConstructorInfo.java b/libjava/classpath/javax/management/MBeanConstructorInfo.java
new file mode 100644
index 00000000000..832a3296d6b
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanConstructorInfo.java
@@ -0,0 +1,228 @@
+/* MBeanConstructorInfo.java -- Information about a bean's constructor.
+ 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.lang.reflect.Constructor;
+
+import java.util.Arrays;
+
+/**
+ * Describes the constructors of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanConstructorInfo
+ extends MBeanFeatureInfo
+ implements Cloneable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 4433990064191844427L;
+
+ /**
+ * The signature of the constructor i.e. the argument types.
+ */
+ private MBeanParameterInfo[] signature;
+
+ /**
+ * Constructs a @link{MBeanConstructorInfo} with the specified
+ * description using the given constructor. Each parameter is
+ * described merely by its type; the name and description are
+ * <code>null</code>.
+ *
+ * @param desc a description of the attribute.
+ * @param cons the constructor.
+ */
+ public MBeanConstructorInfo(String desc, Constructor cons)
+ {
+ super(cons.getName(), desc);
+ Class[] paramTypes = cons.getParameterTypes();
+ signature = new MBeanParameterInfo[paramTypes.length];
+ for (int a = 0; a < paramTypes.length; ++a)
+ signature[a] = new MBeanParameterInfo(null,
+ paramTypes[a].getName(),
+ null);
+ }
+
+ /**
+ * Constructs a @link{MBeanConstructorInfo} with the specified
+ * name, description and parameter information. A <code>null</code>
+ * value for the parameter information is the same as passing in
+ * an empty array.
+ *
+ * @param name the name of the constructor.
+ * @param desc a description of the attribute.
+ * @param sig the signature of the constructor, as a series
+ * of {@link MBeanParameterInfo} objects, one for
+ * each parameter.
+ */
+ public MBeanConstructorInfo(String name, String desc,
+ MBeanParameterInfo[] sig)
+ {
+ super(name, desc);
+ if (sig == null)
+ signature = new MBeanParameterInfo[0];
+ else
+ signature = sig;
+ }
+
+ /**
+ * 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
+ * MBeanConstructorInfo}, {@link Object#equals()} returns true for a
+ * comparison of both the name and description of this notification
+ * with that of the specified object (performed by the superclass),
+ * and the two signature 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 MBeanConstructorInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>description.equals(object.getDescription())</code>
+ * and the corresponding elements of the signature arrays are
+ * equal.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof MBeanConstructorInfo))
+ return false;
+ if (!(super.equals(obj)))
+ return false;
+ MBeanConstructorInfo o = (MBeanConstructorInfo) obj;
+ MBeanParameterInfo[] sig = o.getSignature();
+ for (int a = 0; a < signature.length; ++a)
+ {
+ if (a == sig.length)
+ return true;
+ if (!(signature[a].equals(sig[a])))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns the constructor's signature, in the form of
+ * information on each parameter. Each parameter is
+ * described by an instance of {@link MBeanParameterInfo}.
+ * The returned array is a shallow copy of the array used
+ * by this instance, so changing which elements are stored
+ * in the array won't affect the array used by this, but
+ * changing the actual elements will affect the ones used
+ * here.
+ *
+ * @return an array of {@link MBeanParameterInfo} objects,
+ * describing the constructor parameters.
+ */
+ public MBeanParameterInfo[] getSignature()
+ {
+ return (MBeanParameterInfo[]) signature.clone();
+ }
+
+ /**
+ * Returns the hashcode of the constructor information as the sum
+ * of the hashcode of the superclass and the hashcode of the parameter
+ * array.
+ *
+ * @return the hashcode of the constructor information.
+ */
+ public int hashCode()
+ {
+ return super.hashCode() + Arrays.hashCode(signature);
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanConstructorInfo</code>),
+ * the name and description of the constructor and the
+ * contents of the array of parameters.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ {
+ super.toString();
+ string = string.substring(0, string.length() - 1)
+ + ",signature=" + Arrays.toString(signature)
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanException.java b/libjava/classpath/javax/management/MBeanException.java
new file mode 100644
index 00000000000..f082275e69b
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanException.java
@@ -0,0 +1,118 @@
+/* MBeanException.java -- A user-defined management exception.
+ 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 an arbitrary exception thrown by a management
+ * bean. When a management bean executes code that causes
+ * an exception to be thrown, the resulting exception is
+ * wrapped inside an {@link MBeanException}. Calling
+ * {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanException
+ extends JMException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 4066342430588744142L;
+
+ /* Sun re-implemented causality -- don't know why, but
+ serialization demands we do too... */
+
+ /**
+ * The target exception.
+ *
+ * @serial the target exception.
+ */
+ private Exception exception;
+
+ /**
+ * Constructs a new <code>MBeanException</code> wrapping
+ * the specified exception.
+ *
+ * @param e the exception to be wrapped.
+ */
+ public MBeanException(Exception e)
+ {
+ super();
+ exception = e;
+ }
+
+ /**
+ * Constructs a new <code>MBeanException</code> wrapping
+ * the specified exception and using the supplied message.
+ *
+ * @param e the exception to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public MBeanException(Exception e, String message)
+ {
+ super(message);
+ exception = e;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Throwable getCause()
+ {
+ return exception;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Exception getTargetException()
+ {
+ return exception;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/MBeanFeatureInfo.java b/libjava/classpath/javax/management/MBeanFeatureInfo.java
new file mode 100644
index 00000000000..4f0243e1894
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanFeatureInfo.java
@@ -0,0 +1,186 @@
+/* MBeanFeatureInfo.java -- Information about a bean feature.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.Serializable;
+
+/**
+ * A general superclass for the description of features
+ * of management beans. This allows the user to access
+ * the feature dynamically, without knowing the details
+ * beforehand. The information is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanFeatureInfo
+ implements Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 3952882688968447265L;
+
+ /**
+ * A description of the feature in human-readable form.
+ * Subclasses should access this via the {@link #getDescription()}
+ * function rather than using the value directly.
+ *
+ * @serial a description of the feature.
+ */
+ protected String description;
+
+ /**
+ * The name of the feature. Subclasses should access this
+ * via the {@link #getName()} function rather than using the
+ * value directly.
+ *
+ * @serial the name of the feature.
+ */
+ protected String name;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ protected transient String string;
+
+ /**
+ * Constructs a new {@link MBeanFeatureInfo} with the specified
+ * name and description.
+ *
+ * @param name the name of the management bean feature.
+ * @param description the description of the feature.
+ */
+ public MBeanFeatureInfo(String name, String description)
+ {
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Compares this feature with the supplied object. This
+ * returns true iff the object is an instance of
+ * {@link MBeanFeatureInfo} and {@link Object#equals()}
+ * returns true for a comparison of both the name and
+ * description of this feature with that of the specified
+ * object.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link MBeanFeatureInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code> and
+ * <code>description.equals(object.getDescription</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof MBeanFeatureInfo)
+ {
+ MBeanFeatureInfo o = (MBeanFeatureInfo) obj;
+ return ((name == null ?
+ o.getName() == null :
+ name.equals(o.getName())) &&
+ (description == null ?
+ o.getDescription() == null :
+ description.equals(o.getDescription())));
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Returns a description of this feature.
+ *
+ * @return a human-readable description.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Returns the name of this feature.
+ *
+ * @return the name of the feature.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the hashcode of the feature as
+ * the sum of the hashcodes of its name
+ * and description.
+ *
+ * @return the hashcode of this feature.
+ */
+ public int hashCode()
+ {
+ return (name == null ? -1 : name.hashCode())
+ + (description == null ? -1 : description.hashCode());
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanFeatureInfo</code>) and
+ * the name and description of the feature.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + name
+ + ",desc=" + description
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanInfo.java b/libjava/classpath/javax/management/MBeanInfo.java
new file mode 100644
index 00000000000..e6f03f0656e
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanInfo.java
@@ -0,0 +1,397 @@
+/* MBeanInfo.java -- Information about a management 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.io.Serializable;
+
+import java.util.Arrays;
+
+/**
+ * <p>
+ * Describes the interface of a management bean. This allows
+ * the user to access the bean dynamically, without knowing
+ * the details of any of its attributes, operations,
+ * constructors or notifications beforehand. The information
+ * is immutable as standard. Of course, subclasses may change
+ * this, but this behaviour is not recommended.
+ * </p>
+ * <p>
+ * The contents of this class, for standard management beans,
+ * are dynamically compiled using reflection.
+ * {@link #getClassName()} and {@link #getConstructors()}
+ * return the name of the class and its constructors, respectively.
+ * This is much the same as could be obtained by reflection on the
+ * bean. {@link #getAttributes()} and {@link #getOperations()},
+ * however, do something more in splitting the methods of the
+ * class into two sets. Those of the form, <code>getXXX</code>,
+ * <code>setXXX</code> and <code>isXXX</code> are taken to be
+ * the accessors and mutators of a series of attributes, with
+ * <code>XXX</code> being the attribute name. These are returned
+ * by {@link getAttributes()} and the {@link Attribute} class can
+ * be used to manipulate them. The remaining methods are classified
+ * as operations and returned by {@link getOperations()}.
+ * </p>
+ * <p>
+ * Beans can also broadcast notifications. If the bean provides this
+ * facility, by implementing the {@link NotificationBroadcaster}
+ * interface, then an array of {@link MBeanNotificationInfo} objects
+ * may be obtained from {@link #getNotifications()}, which describe
+ * the notifications emitted.
+ * </p>
+ * <p>
+ * Model management beans and open management beans also supply an
+ * instance of this class, as part of implementing the
+ * {@link DynamicMBean#getMBeanInfo()} method of {@link DynamicMBean}.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanInfo
+ implements Cloneable, Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -6451021435135161911L;
+
+ /**
+ * A description of the bean.
+ *
+ * @serial The bean's description.
+ */
+ private String description;
+
+ /**
+ * The class name of the management bean.
+ *
+ * @serial The bean's class name.
+ */
+ private String className;
+
+ /**
+ * Descriptions of the attributes provided by the bean.
+ */
+ private MBeanAttributeInfo[] attributes;
+
+ /**
+ * Descriptions of the operations provided by the bean.
+ */
+ private MBeanOperationInfo[] operations;
+
+ /**
+ * Descriptions of the bean's constructors.
+ */
+ private MBeanConstructorInfo[] constructors;
+
+ /**
+ * Descriptions of the notifications emitted by the bean.
+ *
+ * @serial The bean's notifications.
+ */
+ private MBeanNotificationInfo[] notifications;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ private transient String string;
+
+ /**
+ * Constructs a new {@link MBeanInfo} using the supplied
+ * class name and description with the given attributes,
+ * operations, constructors and notifications. The class
+ * name does not have to actually specify a valid class that
+ * can be loaded by the MBean server or class loader; it merely
+ * has to be a syntactically correct class name. Any of the
+ * arrays may be <code>null</code>; this will be treated as if
+ * an empty array was supplied.
+ *
+ * @param name the name of the class this instance describes.
+ * @param desc a description of the bean.
+ * @param attribs the attribute descriptions for the bean,
+ * or <code>null</code>.
+ * @param cons the constructor descriptions for the bean,
+ * or <code>null</code>.
+ * @param ops the operation descriptions for the bean,
+ * or <code>null</code>.
+ * @param notifs the notification descriptions for the bean,
+ * or <code>null</code>.
+ */
+ public MBeanInfo(String name, String desc, MBeanAttributeInfo[] attribs,
+ MBeanConstructorInfo[] cons, MBeanOperationInfo[] ops,
+ MBeanNotificationInfo[] notifs)
+ {
+ className = name;
+ description = desc;
+ if (attribs == null)
+ attributes = new MBeanAttributeInfo[0];
+ else
+ attributes = attribs;
+ if (cons == null)
+ constructors = new MBeanConstructorInfo[0];
+ else
+ constructors = cons;
+ if (ops == null)
+ operations = new MBeanOperationInfo[0];
+ else
+ operations = ops;
+ if (notifs == null)
+ notifications = new MBeanNotificationInfo[0];
+ else
+ notifications = notifs;
+ }
+
+ /**
+ * 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,
+ * as obtained by the {@link Object} implementation of
+ * {@link Object#clone()}. As the fields can not be
+ * changed, this method is only really of interest to
+ * subclasses which may add new mutable fields or make
+ * the existing ones mutable.
+ *
+ * @return a shallow clone of this {@link MBeanInfo}.
+ */
+ public Object clone()
+ {
+ MBeanInfo clone = null;
+ try
+ {
+ clone = (MBeanInfo) super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ /* This won't happen as we implement Cloneable */
+ }
+ return clone;
+ }
+
+ /**
+ * Compares this feature with the supplied object. This returns
+ * true iff the object is an instance of {@link MBeanInfo} and
+ * {@link Object#equals()} returns true for a comparison of the
+ * class name and description, and the arrays each 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 MBeanInfo}
+ * instance,
+ * <code>className.equals(object.getClassName())</code>,
+ * <code>description.equals(object.getDescription())</code>
+ * and the corresponding elements of the arrays are
+ * equal.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof MBeanInfo))
+ return false;
+ if (!(super.equals(obj)))
+ return false;
+ MBeanInfo o = (MBeanInfo) obj;
+ MBeanAttributeInfo[] attr = o.getAttributes();
+ for (int a = 0; a < attributes.length; ++a)
+ {
+ if (a == attr.length)
+ return true;
+ if (!(attributes[a].equals(attr[a])))
+ return false;
+ }
+ MBeanConstructorInfo[] cons = o.getConstructors();
+ for (int a = 0; a < constructors.length; ++a)
+ {
+ if (a == cons.length)
+ return true;
+ if (!(constructors[a].equals(cons[a])))
+ return false;
+ }
+ MBeanOperationInfo[] ops = o.getOperations();
+ for (int a = 0; a < operations.length; ++a)
+ {
+ if (a == ops.length)
+ return true;
+ if (!(operations[a].equals(ops[a])))
+ return false;
+ }
+ MBeanNotificationInfo[] notifs = o.getNotifications();
+ for (int a = 0; a < notifications.length; ++a)
+ {
+ if (a == notifs.length)
+ return true;
+ if (!(notifications[a].equals(notifs[a])))
+ return false;
+ }
+ return (className.equals(o.getClassName()) &&
+ description.equals(o.getDescription()));
+ }
+
+ /**
+ * Returns descriptions of each of the attributes provided
+ * by this management bean. The returned value is a shallow
+ * copy of the attribute array maintained by this instance.
+ * Hence, changing the elements of the returned array will not
+ * affect the attribute array, and the elements (instances
+ * of the {@link MBeanAttributeInfo} class) are immutable.
+ *
+ * @return an array of {@link MBeanAttributeInfo} objects,
+ * representing the attributes emitted by this
+ * management bean.
+ */
+ public MBeanAttributeInfo[] getAttributes()
+ {
+ return (MBeanAttributeInfo[]) attributes.clone();
+ }
+
+ /**
+ * Returns the class name of the management bean.
+ *
+ * @return the bean's class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns descriptions of each of the constructors provided
+ * by this management bean. The returned value is a shallow
+ * copy of the constructor array maintained by this instance.
+ * Hence, changing the elements of the returned array will not
+ * affect the constructor array, and the elements (instances
+ * of the {@link MBeanConstructorInfo} class) are immutable.
+ *
+ * @return an array of {@link MBeanConstructorInfo} objects,
+ * representing the constructors emitted by this
+ * management bean.
+ */
+ public MBeanConstructorInfo[] getConstructors()
+ {
+ return (MBeanConstructorInfo[]) constructors.clone();
+ }
+
+ /**
+ * Returns a description of the management bean.
+ *
+ * @return the bean's description.
+ */
+ public String getDescription()
+ {
+ 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();
+ }
+
+ /**
+ * Returns descriptions of each of the operations provided
+ * by this management bean. The returned value is a shallow
+ * copy of the operation array maintained by this instance.
+ * Hence, changing the elements of the returned array will not
+ * affect the operation array, and the elements (instances
+ * of the {@link MBeanOperationInfo} class) are immutable.
+ *
+ * @return an array of {@link MBeanOperationInfo} objects,
+ * representing the operations emitted by this
+ * management bean.
+ */
+ public MBeanOperationInfo[] getOperations()
+ {
+ return (MBeanOperationInfo[]) operations.clone();
+ }
+
+ /**
+ * Returns the hashcode of the information as the sum of the
+ * hashcode of the classname, description and each array.
+ *
+ * @return the hashcode of the information.
+ */
+ public int hashCode()
+ {
+ return className.hashCode() + description.hashCode()
+ + Arrays.hashCode(attributes) + Arrays.hashCode(constructors)
+ + Arrays.hashCode(operations) + Arrays.hashCode(notifications);
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanInfo</code>),
+ * the name and description of the bean and the contents
+ * of the four arrays.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + className
+ + ",desc=" + description
+ + ",attributes=" + Arrays.toString(attributes)
+ + ",constructors=" + Arrays.toString(constructors)
+ + ",operations=" + Arrays.toString(operations)
+ + ",notifications=" + Arrays.toString(notifications)
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanNotificationInfo.java b/libjava/classpath/javax/management/MBeanNotificationInfo.java
new file mode 100644
index 00000000000..ba4077e8fba
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanNotificationInfo.java
@@ -0,0 +1,227 @@
+/* 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);
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanNotificationInfo</code>),
+ * the name and description of the notification and the
+ * contents of the array of types.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ {
+ super.toString();
+ string = string.substring(0, string.length() - 1)
+ + ",types=" + Arrays.toString(types)
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanOperationInfo.java b/libjava/classpath/javax/management/MBeanOperationInfo.java
new file mode 100644
index 00000000000..a2db8d1b064
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanOperationInfo.java
@@ -0,0 +1,344 @@
+/* MBeanOperationInfo.java -- Information about a bean's operations.
+ 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.lang.reflect.Method;
+
+import java.util.Arrays;
+
+/**
+ * Describes the operations of a management bean.
+ * The information in this class is immutable as standard.
+ * Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanOperationInfo
+ extends MBeanFeatureInfo
+ implements Cloneable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -6178860474881375330L;
+
+ /**
+ * Used to signify that the operation merely provides information
+ * (akin to an accessor).
+ */
+ public static final int INFO = 0;
+
+ /**
+ * Used to signify that the operation makes some change to the
+ * state of the bean (akin to a mutator).
+ */
+ public static final int ACTION = 1;
+
+ /**
+ * Used to signify that the operation makes some state change
+ * to the bean and also returns information.
+ */
+ public static final int ACTION_INFO = 2;
+
+ /**
+ * Used to signify that the behaviour of the operation is
+ * unknown.
+ */
+ public static final int UNKNOWN = 3;
+
+ /**
+ * The return type of the method, in the form of its class name.
+ */
+ private String type;
+
+ /**
+ * The signature of the constructor i.e. the argument types.
+ */
+ private MBeanParameterInfo[] signature;
+
+ /**
+ * The impact of the method, as one of {@link #INFO}, {@link #ACTION},
+ * {@link #ACTION_INFO} and {@link #UNKNOWN}.
+ */
+ private int impact;
+
+ /**
+ * Constructs a @link{MBeanOperationInfo} with the specified
+ * description using the given method. Each parameter is
+ * described merely by its type; the name and description are
+ * <code>null</code>. The return type and impact of the
+ * method are determined from the {@link Method} instance.
+ *
+ * @param desc a description of the attribute.
+ * @param method the method.
+ */
+ public MBeanOperationInfo(String desc, Method method)
+ {
+ super(method.getName(), desc);
+ Class[] paramTypes = method.getParameterTypes();
+ signature = new MBeanParameterInfo[paramTypes.length];
+ for (int a = 0; a < paramTypes.length; ++a)
+ signature[a] = new MBeanParameterInfo(null,
+ paramTypes[a].getName(),
+ null);
+ type = method.getReturnType().getName();
+ if (method.getReturnType() == Void.TYPE)
+ {
+ if (paramTypes.length == 0)
+ impact = UNKNOWN;
+ else
+ impact = ACTION;
+ }
+ else
+ {
+ if (paramTypes.length == 0)
+ impact = INFO;
+ else
+ impact = ACTION_INFO;
+ }
+ }
+
+ /**
+ * Constructs a @link{MBeanOperationInfo} with the specified name,
+ * description, parameter information, return type and impact. A
+ * <code>null</code> value for the parameter information is the same
+ * as passing in an empty array.
+ *
+ * @param name the name of the constructor.
+ * @param desc a description of the attribute.
+ * @param sig the signature of the method, as a series
+ * of {@link MBeanParameterInfo} objects, one for
+ * each parameter.
+ * @param type the return type of the method, as the class name.
+ * @param impact the impact of performing the operation.
+ */
+ public MBeanOperationInfo(String name, String desc,
+ MBeanParameterInfo[] sig, String type,
+ int impact)
+ {
+ super(name, desc);
+ if (sig == null)
+ signature = new MBeanParameterInfo[0];
+ else
+ signature = sig;
+ this.type = type;
+ this.impact = impact;
+ }
+
+ /**
+ * 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
+ * MBeanConstructorInfo}, {@link Object#equals()} returns true for a
+ * comparison of both the name and description of this notification
+ * with that of the specified object (performed by the superclass),
+ * the return type and impact are equal and the two signature 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 MBeanOperationInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>description.equals(object.getDescription())</code>,
+ * <code>type.equals(object.getReturnType())</code>,
+ * <code>impact == object.getImpact()</code>,
+ * and the corresponding elements of the signature arrays are
+ * equal.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof MBeanOperationInfo))
+ return false;
+ if (!(super.equals(obj)))
+ return false;
+ MBeanOperationInfo o = (MBeanOperationInfo) obj;
+ MBeanParameterInfo[] sig = o.getSignature();
+ for (int a = 0; a < signature.length; ++a)
+ {
+ if (a == sig.length)
+ return true;
+ if (!(signature[a].equals(sig[a])))
+ return false;
+ }
+ return (type.equals(o.getReturnType()) &&
+ impact == o.getImpact());
+ }
+
+ /**
+ * <p>
+ * Returns the impact of performing this operation.
+ * The value is equal to one of the following:
+ * </p>
+ * <ol>
+ * <li>{@link #INFO} &mdash; the method just returns
+ * information (akin to an accessor).</li>
+ * <li>{@link #ACTION} &mdash; the method just alters
+ * the state of the bean, without returning a value
+ * (akin to a mutator).</li>
+ * <li>{@link #ACTION_INFO} &mdash; the method both makes
+ * state changes and returns a value.</li>
+ * <li>{@link #UNKNOWN} &mdash; the behaviour of the operation
+ * is unknown.</li>
+ * </ol>
+ *
+ * @return the impact of performing the operation.
+ */
+ public int getImpact()
+ {
+ return impact;
+ }
+
+ /**
+ * Returns the return type of the operation, as the class
+ * name.
+ *
+ * @return the return type.
+ */
+ public String getReturnType()
+ {
+ return type;
+ }
+
+ /**
+ * Returns the operation's signature, in the form of
+ * information on each parameter. Each parameter is
+ * described by an instance of {@link MBeanParameterInfo}.
+ * The returned array is a shallow copy of the array used
+ * by this instance, so changing which elements are stored
+ * in the array won't affect the array used by this, but
+ * changing the actual elements will affect the ones used
+ * here.
+ *
+ * @return an array of {@link MBeanParameterInfo} objects,
+ * describing the operation parameters.
+ */
+ public MBeanParameterInfo[] getSignature()
+ {
+ return (MBeanParameterInfo[]) signature.clone();
+ }
+
+ /**
+ * Returns the hashcode of the operation information as the sum of
+ * the hashcode of the superclass, the parameter array, the return
+ * type and the impact factor.
+ *
+ * @return the hashcode of the operation information.
+ */
+ public int hashCode()
+ {
+ return super.hashCode() + Arrays.hashCode(signature)
+ + type.hashCode() + Integer.valueOf(impact).hashCode();
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanOperationInfo</code>),
+ * the name, description, return type and impact of the
+ * operation and the contents of the array of parameters.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ {
+ String impactString;
+ switch (impact)
+ {
+ case INFO:
+ impactString = "INFO";
+ break;
+ case ACTION:
+ impactString = "ACTION";
+ break;
+ case ACTION_INFO:
+ impactString = "ACTION_INFO";
+ break;
+ case UNKNOWN:
+ impactString = "UNKNOWN";
+ break;
+ default:
+ impactString = "ERRONEOUS VALUE";
+ }
+ super.toString();
+ string = string.substring(0, string.length() - 1)
+ + ",returnType=" + type
+ + ",impact=" + impactString
+ + ",signature=" + Arrays.toString(signature)
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/MBeanParameterInfo.java b/libjava/classpath/javax/management/MBeanParameterInfo.java
new file mode 100644
index 00000000000..ee6ef99b843
--- /dev/null
+++ b/libjava/classpath/javax/management/MBeanParameterInfo.java
@@ -0,0 +1,176 @@
+/* MBeanParameterInfo.java -- Information about an operation's parameters.
+ 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;
+
+/**
+ * Describes the parameters of a constructor or operation associated
+ * with a management bean. The information in this class is immutable
+ * as standard. Of course, subclasses may change this, but this
+ * behaviour is not recommended.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanParameterInfo
+ extends MBeanFeatureInfo
+ implements Cloneable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 7432616882776782338L;
+
+ /**
+ * The type of the parameter, represented by the class name.
+ */
+ private String type;
+
+ /**
+ * Constructs a new {@link MBeanParameterInfo} using the specified
+ * name, description and type.
+ *
+ * @param name the name of the attribute.
+ * @param type the type of the attribute, in the form of its class name.
+ * @param desc a description of the attribute.
+ */
+ public MBeanParameterInfo(String name, String type, String desc)
+ {
+ super(name, desc);
+ this.type = type;
+ }
+
+ /**
+ * 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 MBeanParameterInfo},
+ * {@link Object#equals()} returns true for a comparison of both the
+ * name and description of this parameter with that of the specified
+ * object (performed by the superclass), and the type of the two
+ * instances is equal.
+ *
+ * @param obj the object to compare.
+ * @return true if the object is a {@link MBeanParameterInfo}
+ * instance,
+ * <code>name.equals(object.getName())</code>,
+ * <code>description.equals(object.getDescription())</code>,
+ * and <code>type.equals(object.getType())</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof MBeanParameterInfo))
+ return false;
+ if (!(super.equals(obj)))
+ return false;
+ MBeanParameterInfo o = (MBeanParameterInfo) obj;
+ return type.equals(o.getType());
+ }
+
+ /**
+ * Returns the type of this attribute, in the form of its class name.
+ *
+ * @return the type of this attribute.
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * Returns the hashcode of the parameter information as the sum of
+ * the hashcode of the superclass and the hashcode of the type.
+ *
+ * @return the hashcode of the parameter information.
+ */
+ public int hashCode()
+ {
+ return super.hashCode() + type.hashCode();
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.MBeanParameterInfo</code>) along
+ * with the name, description and type of the parameter.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ {
+ super.toString();
+ string = string.substring(0, string.length() - 1)
+ + ",type=" + type
+ + "]";
+ }
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/NotCompliantMBeanException.java b/libjava/classpath/javax/management/NotCompliantMBeanException.java
new file mode 100644
index 00000000000..f2252f28b3a
--- /dev/null
+++ b/libjava/classpath/javax/management/NotCompliantMBeanException.java
@@ -0,0 +1,78 @@
+/* NotCompliantMBeanException.java -- Thrown due to a non-compliant 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;
+
+/**
+ * Thrown when a management bean is passed to a method
+ * (e.g. to an MBean server to be registered) and it
+ * fails to comply with the specifications for such
+ * a bean.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class NotCompliantMBeanException
+ extends OperationsException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 5175579583207963577L;
+
+ /**
+ * Constructs a new <code>NotCompliantMBeanException</code>.
+ */
+ public NotCompliantMBeanException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>NotCompliantMBeanException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public NotCompliantMBeanException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/Notification.java b/libjava/classpath/javax/management/Notification.java
new file mode 100644
index 00000000000..52c11de06af
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/NotificationBroadcaster.java b/libjava/classpath/javax/management/NotificationBroadcaster.java
new file mode 100644
index 00000000000..139d842bb41
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/NotificationEmitter.java b/libjava/classpath/javax/management/NotificationEmitter.java
new file mode 100644
index 00000000000..002e2fe1890
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/NotificationFilter.java b/libjava/classpath/javax/management/NotificationFilter.java
new file mode 100644
index 00000000000..a8e41c93fbc
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/NotificationListener.java b/libjava/classpath/javax/management/NotificationListener.java
new file mode 100644
index 00000000000..69b08eee3b3
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/management/OperationsException.java b/libjava/classpath/javax/management/OperationsException.java
new file mode 100644
index 00000000000..cbd90d63782
--- /dev/null
+++ b/libjava/classpath/javax/management/OperationsException.java
@@ -0,0 +1,76 @@
+/* OperationsException.java -- Thrown by management operations.
+ 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;
+
+/**
+ * A general superclass for all exceptions thrown by
+ * operations on management beans.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class OperationsException
+ extends JMException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -4967597595580536216L;
+
+ /**
+ * Constructs a new <code>OperationsException</code>.
+ */
+ public OperationsException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>OperationsException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public OperationsException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/ReflectionException.java b/libjava/classpath/javax/management/ReflectionException.java
new file mode 100644
index 00000000000..0f19b5b349f
--- /dev/null
+++ b/libjava/classpath/javax/management/ReflectionException.java
@@ -0,0 +1,118 @@
+/* ReflectionException.java -- A reflection-based management exception.
+ 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 one of the reflection exceptions thrown by a
+ * management bean. When a management bean tries to perform
+ * a lookup using the reflection API and encounters an exception,
+ * it gets wrapped inside an {@link ReflectionException}.
+ * Calling {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ReflectionException
+ extends JMException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 9170809325636915553L;
+
+ /* Sun re-implemented causality -- don't know why, but
+ serialization demands we do too... */
+
+ /**
+ * The target exception.
+ *
+ * @serial the target exception.
+ */
+ private Exception exception;
+
+ /**
+ * Constructs a new <code>ReflectionException</code> wrapping
+ * the specified exception.
+ *
+ * @param e the exception to be wrapped.
+ */
+ public ReflectionException(Exception e)
+ {
+ super();
+ exception = e;
+ }
+
+ /**
+ * Constructs a new <code>ReflectionException</code> wrapping
+ * the specified exception and using the supplied message.
+ *
+ * @param e the exception to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public ReflectionException(Exception e, String message)
+ {
+ super(message);
+ exception = e;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Throwable getCause()
+ {
+ return exception;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Exception getTargetException()
+ {
+ return exception;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/RuntimeOperationsException.java b/libjava/classpath/javax/management/RuntimeOperationsException.java
new file mode 100644
index 00000000000..8a830a5e708
--- /dev/null
+++ b/libjava/classpath/javax/management/RuntimeOperationsException.java
@@ -0,0 +1,121 @@
+/* RuntimeOperationsException.java -- A wrapped run-time exception.
+ 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 runtime exception thrown by a management
+ * bean operation. When a management bean executes code
+ * that causes a runtime exception to be thrown, the
+ * resulting exception is wrapped inside an
+ * {@link RuntimeOperationsException}. Calling
+ * {@link getTargetException()} will return the wrapped
+ * exception.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class RuntimeOperationsException
+ extends JMRuntimeException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -8408923047489133588L;
+
+ /* Sun re-implemented causality -- don't know why, but
+ serialization demands we do too... */
+
+ /**
+ * The target exception.
+ *
+ * @serial the target exception.
+ */
+ private RuntimeException runtimeException;
+
+ /**
+ * Constructs a new <code>RuntimeOperationsException</code>
+ * wrapping the specified exception.
+ *
+ * @param e the exception to be wrapped.
+ */
+ public RuntimeOperationsException(RuntimeException e)
+ {
+ super();
+ runtimeException = e;
+ }
+
+ /**
+ * Constructs a new <code>RuntimeOperationsException</code>
+ * wrapping the specified exception and using the supplied
+ * message.
+ *
+ * @param e the exception to be wrapped.
+ * @param message the error message to give to the user.
+ */
+ public RuntimeOperationsException(RuntimeException e,
+ String message)
+ {
+ super(message);
+ runtimeException = e;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public Throwable getCause()
+ {
+ return runtimeException;
+ }
+
+ /**
+ * Returns the true cause of this exception, the wrapped
+ * exception.
+ *
+ * @return the wrapped exception.
+ */
+ public RuntimeException getTargetException()
+ {
+ return runtimeException;
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/StandardMBean.java b/libjava/classpath/javax/management/StandardMBean.java
new file mode 100644
index 00000000000..736192ee2ac
--- /dev/null
+++ b/libjava/classpath/javax/management/StandardMBean.java
@@ -0,0 +1,925 @@
+/* StandardMBean.java -- A standard reflection-based management 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.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Provides a dynamic management bean by using reflection on an
+ * interface and an implementing class. By default, a bean instance
+ * is paired up with its interface based on specific naming
+ * conventions (if the implementation is called X, the interface must
+ * be XMBean). Using this class removes the need to use a specific
+ * naming system to match up the two. Instead, an instance of this
+ * bean is created either via explicit construction or subclassing,
+ * and this provides access to the attributes, constructors and
+ * operations of the implementation via reflection. Various hooks are
+ * provided in order to allow customization of this process.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class StandardMBean
+ implements DynamicMBean
+{
+
+ /**
+ * The interface for this bean.
+ */
+ private Class iface;
+
+ /**
+ * The implementation of the interface.
+ */
+ private Object impl;
+
+ /**
+ * Cached bean information.
+ */
+ private MBeanInfo info;
+
+ /**
+ * Constructs a new {@link StandardMBean} using the specified
+ * interface and <code>this</code> as the instance. This should
+ * be used to create an instance via subclassing.
+ *
+ * @param iface the interface this bean implements, or <code>null</code>
+ * if the interface should be determined using the naming
+ * convention (class X has interface XMBean).
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ protected StandardMBean(Class iface)
+ throws NotCompliantMBeanException
+ {
+ if (iface == null)
+ {
+ String className = getClass().getName();
+ try
+ {
+ iface = Class.forName(className + "MBean");
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (NotCompliantMBeanException)
+ (new NotCompliantMBeanException("An interface for the class " +
+ className + " was not found.").initCause(e));
+ }
+ }
+ if (!(iface.isInstance(this)))
+ throw new NotCompliantMBeanException("The instance, " + impl +
+ ", is not an instance of " + iface);
+ impl = this;
+ this.iface = iface;
+ }
+
+ /**
+ * Constructs a new {@link StandardMBean} using the specified
+ * interface and the supplied instance as the implementation.
+ *
+ * @param impl the implementation.
+ * @param iface the interface the bean implements, or <code>null</code>
+ * if the interface should be determined using the naming
+ * convention (class X has interface XMBean).
+ * @throws IllegalArgumentException if <code>impl</code> is <code>null</code>.
+ * @throws NotCompliantMBeanException if <code>impl</code> doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public StandardMBean(Object impl, Class iface)
+ throws NotCompliantMBeanException
+ {
+ if (impl == null)
+ throw new IllegalArgumentException("The specified implementation is null.");
+ if (iface == null)
+ {
+ String className = impl.getClass().getName();
+ try
+ {
+ iface = Class.forName(className + "MBean");
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (NotCompliantMBeanException)
+ (new NotCompliantMBeanException("An interface for the class " +
+ className + " was not found.").initCause(e));
+ }
+ }
+ if (!(iface.isInstance(impl)))
+ throw new NotCompliantMBeanException("The instance, " + impl +
+ ", is not an instance of " + iface);
+ this.impl = impl;
+ this.iface = iface;
+ }
+
+ /**
+ * Caches the {@link MBeanInfo} instance for this object. This is a
+ * customization hook, so that subclasses can choose the caching policy
+ * used. The default implementation caches the value in the instance
+ * itself. Subclasses may override this so as to not cache the data
+ * at all, or so as to use a cache shared between multiple beans.
+ *
+ * @param info the {@link MBeanInfo} instance to cache, or <code>null</code>
+ * if there is no new value to cache. When the value is not
+ * <code>null</code>, the cache should replace the current value
+ * with the value supplied here.
+ * @see #getCachedMBeanInfo()
+ */
+ protected void cacheMBeanInfo(MBeanInfo info)
+ {
+ if (info != null)
+ this.info = info;
+ }
+
+ /**
+ * Obtains the value of the specified attribute of the
+ * management bean. The management bean should perform
+ * a lookup for the named attribute, and return its value
+ * by calling the appropriate getter method, if possible.
+ *
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the specified attribute.
+ * @throws AttributeNotFoundException if the name does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws MBeanException if retrieving the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @see #setAttribute(String)
+ */
+ public Object getAttribute(String name)
+ throws AttributeNotFoundException, MBeanException,
+ ReflectionException
+ {
+ Method getter;
+ try
+ {
+ getter = iface.getMethod("get" +
+ name.substring(0, 1).toUpperCase() +
+ name.substring(1), null);
+ }
+ catch (NoSuchMethodException e)
+ {
+ try
+ {
+ getter = iface.getMethod("is" +
+ name.substring(0, 1).toUpperCase() +
+ name.substring(1), null);
+ }
+ catch (NoSuchMethodException ex)
+ {
+ throw ((AttributeNotFoundException)
+ new AttributeNotFoundException("The attribute, " + name +
+ ", was not found.").initCause(ex));
+ }
+ }
+ Object result;
+ try
+ {
+ result = getter.invoke(impl, null);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ReflectionException(e, "Failed to retrieve " + name);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ReflectionException(e, "Failed to retrieve " + name);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new MBeanException((Exception) e.getCause(),
+ "The getter of " + name +
+ " threw an exception");
+ }
+ return result;
+ }
+
+ /**
+ * Obtains the values of each of the specified attributes
+ * of the management bean. The returned list includes
+ * those attributes that were retrieved and their
+ * corresponding values.
+ *
+ * @param names the names of the attributes to retrieve.
+ * @return a list of the retrieved attributes.
+ * @see #setAttributes(AttributeList)
+ */
+ public AttributeList getAttributes(String[] names)
+ {
+ AttributeList list = new AttributeList(names.length);
+ for (int a = 0; a < names.length; ++a)
+ {
+ try
+ {
+ Object value = getAttribute(names[a]);
+ list.add(new Attribute(names[a], value));
+ }
+ catch (AttributeNotFoundException e)
+ {
+ /* Ignored */
+ }
+ catch (ReflectionException e)
+ {
+ /* Ignored */
+ }
+ catch (MBeanException e)
+ {
+ /* Ignored */
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Returns the cached {@link MBeanInfo} instance for this object. This is a
+ * customization hook, so that subclasses can choose the caching policy
+ * used. The default implementation caches the value in the instance
+ * itself, and returns this value on calls to this method.
+ *
+ * @return the cached {@link MBeanInfo} instance, or <code>null</code>
+ * if no value is cached.
+ * @see #cacheMBeanInfo(javax.management.MBeanInfo)
+ */
+ protected MBeanInfo getCachedMBeanInfo()
+ {
+ return info;
+ }
+
+ /**
+ * Returns the class name that will be used in the {@link MBeanInfo}
+ * instance. This is a customization hook, so that subclasses can
+ * provide a custom class name. By default, this returns the class
+ * name from the supplied {@link MBeanInfo} instance.
+ *
+ * @param info the {@link MBeanInfo} instance constructed via
+ * reflection.
+ * @return the class name to use in the instance.
+ */
+ protected String getClassName(MBeanInfo info)
+ {
+ return info.getClassName();
+ }
+
+ /**
+ * Returns information on the constructors that will be used in
+ * the {@link MBeanInfo} instance. This is a customization hook,
+ * so that subclasses can provide their own information on the
+ * bean's constructors, if necessary. By default, this method
+ * returns <code>null</code> unless the implementation supplied
+ * is either <code>null</code> or <code>this</code>. This default
+ * implementation prevents the use of
+ * {@link MBeanServer#createMBean} in cases where the bean is
+ * not created as a subclass of {@link StandardMBean}.
+ *
+ * @param constructors the constructor information created via
+ * reflection.
+ * @param impl the implementation, or <code>null</code> if this
+ * should be ignored.
+ * @return the constructor information to use.
+ */
+ protected MBeanConstructorInfo[] getConstructors(MBeanConstructorInfo[]
+ constructors, Object impl)
+ {
+ if (impl == null || impl == this)
+ return constructors;
+ return null;
+ }
+
+ /**
+ * Returns the description of the attribute that will be used in
+ * the supplied {@link MBeanAttributeInfo} instance. This is a
+ * customization hook, so that subclasses can provide a custom
+ * description. By default, this calls
+ * {@link #getDescription(MBeanFeatureInfo)} with the supplied
+ * {@link MBeanAttributeInfo} instance.
+ *
+ * @param info the {@link MBeanAttributeInfo} instance constructed
+ * via reflection.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanAttributeInfo info)
+ {
+ return getDescription((MBeanFeatureInfo) info);
+ }
+
+ /**
+ * Returns the description of the constructor that will be used in
+ * the supplied {@link MBeanConstructorInfo} instance. This is a
+ * customization hook, so that subclasses can provide a custom
+ * description. By default, this calls
+ * {@link #getDescription(MBeanFeatureInfo)} with the supplied
+ * {@link MBeanConstructorInfo} instance.
+ *
+ * @param info the {@link MBeanConstructorInfo} instance constructed
+ * via reflection.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanConstructorInfo info)
+ {
+ return getDescription((MBeanFeatureInfo) info);
+ }
+
+ /**
+ * Returns the description of the nth parameter of the constructor
+ * that will be used in the supplied {@link MBeanParameterInfo}
+ * instance. This is a customization hook, so that subclasses
+ * can provide a custom description. By default, this calls
+ * <code>param.getDescription()</code>.
+ *
+ * @param info the {@link MBeanConstructorInfo} instance constructed
+ * via reflection.
+ * @param param the {@link MBeanParameterInfo} instance constructed
+ * via reflection.
+ * @param n the number of the parameter, in order to link it to the
+ * information on the constructor.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanConstructorInfo info,
+ MBeanParameterInfo param, int n)
+ {
+ return param.getDescription();
+ }
+
+ /**
+ * Returns the description of the supplied feature that
+ * will be used in the supplied {@link MBeanFeatureInfo}
+ * instance. This is a customization hook, so that subclasses
+ * can provide a custom description. By default, this calls
+ * <code>info.getDescription()</code>. This method is also called
+ * by default for the more specific description methods for attributes,
+ * constructors and operations.
+ *
+ * @param info the {@link MBeanFeatureInfo} instance constructed
+ * via reflection.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanFeatureInfo info)
+ {
+ return info.getDescription();
+ }
+
+ /**
+ * Returns the description of the bean that will be used in the
+ * supplied {@link MBeanInfo} instance. This is a customization
+ * hook, so that subclasses can provide a custom description. By
+ * default, this calls <code>info.getDescription()</code>.
+ *
+ * @param info the {@link MBeanInfo} instance constructed
+ * via reflection.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanInfo info)
+ {
+ return info.getDescription();
+ }
+
+ /**
+ * Returns the description of the operation that will be used in
+ * the supplied {@link MBeanOperationInfo} instance. This is a
+ * customization hook, so that subclasses can provide a custom
+ * description. By default, this calls
+ * {@link #getDescription(MBeanFeatureInfo)} with the supplied
+ * {@link MBeanOperationInfo} instance.
+ *
+ * @param info the {@link MBeanOperationInfo} instance constructed
+ * via reflection.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanOperationInfo info)
+ {
+ return getDescription((MBeanFeatureInfo) info);
+ }
+
+ /**
+ * Returns the description of the nth parameter of the operation
+ * that will be used in the supplied {@link MBeanParameterInfo}
+ * instance. This is a customization hook, so that subclasses
+ * can provide a custom description. By default, this calls
+ * <code>param.getDescription()</code>.
+ *
+ * @param info the {@link MBeanOperationInfo} instance constructed
+ * via reflection.
+ * @param param the {@link MBeanParameterInfo} instance constructed
+ * via reflection.
+ * @param n the number of the parameter, in order to link it to the
+ * information on the operation.
+ * @return the description to use in the instance.
+ */
+ protected String getDescription(MBeanOperationInfo info,
+ MBeanParameterInfo param, int n)
+ {
+ return param.getDescription();
+ }
+
+ /**
+ * Returns the impact of the operation that will be used in the
+ * supplied {@link MBeanOperationInfo} instance. This is a
+ * customization hook, so that subclasses can provide a custom
+ * impact flag. By default, this returns
+ * <code>info.getImpact()</code>.
+ *
+ * @param info the {@link MBeanOperationInfo} instance constructed
+ * via reflection.
+ * @return the impact flag to use in the instance.
+ */
+ protected int getImpact(MBeanOperationInfo info)
+ {
+ return info.getImpact();
+ }
+
+ /**
+ * Returns the instance that implements this bean.
+ *
+ * @return the implementation.
+ */
+ public Object getImplementation()
+ {
+ return impl;
+ }
+
+ /**
+ * Returns the class of the instance that implements this bean.
+ *
+ * @return the implementation class.
+ */
+ public Class getImplementationClass()
+ {
+ return impl.getClass();
+ }
+
+ /**
+ * <p>
+ * Returns an information object which lists the attributes
+ * and actions associated with the management bean. This
+ * implementation proceeds as follows:
+ * </p>
+ * <ol>
+ * <li>{@link #getCachedMBeanInfo()} is called to obtain
+ * the cached instance. If this returns a non-null value,
+ * this value is returned.</li>
+ * <li>If there is no cached value, then the method proceeds
+ * to create one. During this process, the customization hooks
+ * detailed in this class are called to allow the values used
+ * to be overrided:
+ * <ul>
+ * <li>For each attribute,
+ * {@link #getDescription(MBeanAttributeInfo)} is called.</li>
+ * <li>For each constructor,
+ * {@link #getDescription(MBeanConstructorInfo)} is called,
+ * along with {@link #getDescription(MBeanConstructorInfo,
+ * MBeanParameterInfo, int)} and
+ * {@link #getParameterName(MBeanConstructorInfo,
+ * MBeanParameterInfo, int)} for each parameter.</li>
+ * <li>The constructors may be replaced as a whole by
+ * a call to
+ * {@link #getConstructors(MBeanConstructorInfo[], Object)}.</li>
+ * <li>For each operation,
+ * {@link #getDescription(MBeanOperationInfo)} and
+ * {@link #getImpact(MBeanOperationInfo)} are called,
+ * along with {@link #getDescription(MBeanOperationInfo,
+ * MBeanParameterInfo, int)} and
+ * {@link #getParameterName(MBeanOperationInfo,
+ * MBeanParameterInfo, int)} for each parameter.</li>
+ * <li>{@link #getClassName(MBeanInfo)} and
+ * {@link #getDescription(MBeanInfo)} are called to customise
+ * the basic information about the class.</li>
+ * </ul>
+ * </li>
+ * <li>Finally, {@link #cacheMBeanInfo(MBeanInfo)} is called
+ * with the created instance before it is returned.</li>
+ * </ol>
+ *
+ * @return a description of the management bean, including
+ * all exposed attributes and actions.
+ */
+ public MBeanInfo getMBeanInfo()
+ {
+ MBeanInfo info = getCachedMBeanInfo();
+ if (info != null)
+ return info;
+ Method[] methods = iface.getMethods();
+ Map attributes = new HashMap();
+ List operations = new ArrayList();
+ for (int a = 0; a < methods.length; ++a)
+ {
+ String name = methods[a].getName();
+ if (((name.startsWith("get") &&
+ methods[a].getReturnType() != Void.TYPE) ||
+ (name.startsWith("is") &&
+ methods[a].getReturnType() == Boolean.TYPE)) &&
+ methods[a].getParameterTypes().length == 0)
+ {
+ Method[] amethods;
+ String attrib;
+ if (name.startsWith("is"))
+ attrib = name.substring(2,3).toLowerCase()
+ + name.substring(3);
+ else
+ attrib = name.substring(3,4).toLowerCase()
+ + name.substring(4);
+ if (attributes.containsKey(attrib))
+ amethods = (Method[]) attributes.get(attrib);
+ else
+ {
+ amethods = new Method[2];
+ attributes.put(attrib, amethods);
+ }
+ amethods[0] = methods[a];
+ }
+ else if (name.startsWith("set") &&
+ methods[a].getReturnType() == Void.TYPE &&
+ methods[a].getParameterTypes().length == 1)
+ {
+ Method[] amethods;
+ String attrib = name.substring(3,4).toLowerCase()
+ + name.substring(4);
+ if (attributes.containsKey(attrib))
+ amethods = (Method[]) attributes.get(attrib);
+ else
+ {
+ amethods = new Method[2];
+ attributes.put(attrib, amethods);
+ }
+ amethods[1] = methods[a];
+ }
+ else
+ operations.add(new MBeanOperationInfo("", methods[a]));
+ }
+ List attribs = new ArrayList(attributes.size());
+ Iterator it = attributes.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ Method[] amethods = (Method[]) entry.getValue();
+ try
+ {
+ attribs.add(new MBeanAttributeInfo((String) entry.getKey(), "",
+ amethods[0], amethods[1]));
+ }
+ catch (IntrospectionException e)
+ {
+ /* Shouldn't happen; both shouldn't be null */
+ throw new IllegalStateException("The two methods passed to " +
+ "the MBeanAttributeInfo " +
+ "constructor for " + entry +
+ "were null.", e);
+ }
+ }
+ MBeanAttributeInfo[] ainfo = new MBeanAttributeInfo[attribs.size()];
+ for (int a = 0; a < ainfo.length; ++a)
+ {
+ MBeanAttributeInfo oldInfo = (MBeanAttributeInfo) attribs.get(a);
+ String desc = getDescription(oldInfo);
+ ainfo[a] = new MBeanAttributeInfo(oldInfo.getName(),
+ oldInfo.getType(), desc,
+ oldInfo.isReadable(),
+ oldInfo.isWritable(),
+ oldInfo.isIs());
+ }
+ Constructor[] cons = impl.getClass().getConstructors();
+ MBeanConstructorInfo[] cinfo = new MBeanConstructorInfo[cons.length];
+ for (int a = 0; a < cinfo.length; ++a)
+ {
+ MBeanConstructorInfo oldInfo = new MBeanConstructorInfo("", cons[a]);
+ String desc = getDescription(oldInfo);
+ MBeanParameterInfo[] params = oldInfo.getSignature();
+ MBeanParameterInfo[] pinfo = new MBeanParameterInfo[params.length];
+ for (int b = 0; b < pinfo.length; ++b)
+ {
+ String pdesc = getDescription(oldInfo, params[b], b);
+ String pname = getParameterName(oldInfo, params[b], b);
+ pinfo[b] = new MBeanParameterInfo(pname, params[b].getType(),
+ pdesc);
+ }
+ cinfo[a] = new MBeanConstructorInfo(oldInfo.getName(), desc,
+ pinfo);
+ }
+ cinfo = getConstructors(cinfo, impl);
+ MBeanOperationInfo[] oinfo = new MBeanOperationInfo[operations.size()];
+ for (int a = 0; a < oinfo.length; ++a)
+ {
+ MBeanOperationInfo oldInfo = (MBeanOperationInfo) operations.get(a);
+ String desc = getDescription(oldInfo);
+ int impact = getImpact(oldInfo);
+ MBeanParameterInfo[] params = oldInfo.getSignature();
+ MBeanParameterInfo[] pinfo = new MBeanParameterInfo[params.length];
+ for (int b = 0; b < pinfo.length; ++b)
+ {
+ String pdesc = getDescription(oldInfo, params[b], b);
+ String pname = getParameterName(oldInfo, params[b], b);
+ pinfo[b] = new MBeanParameterInfo(pname, params[b].getType(),
+ pdesc);
+ }
+ oinfo[a] = new MBeanOperationInfo(oldInfo.getName(), desc, pinfo,
+ oldInfo.getReturnType(), impact);
+ }
+ info = new MBeanInfo(impl.getClass().getName(), "", ainfo, cinfo,
+ oinfo, null);
+ String cname = getClassName(info);
+ String desc = getDescription(info);
+ info = new MBeanInfo(cname, desc, ainfo, cinfo, oinfo, null);
+ cacheMBeanInfo(info);
+ return info;
+ }
+
+ /**
+ * Returns the interface for this management bean.
+ *
+ * @return the management interface.
+ */
+ public Class getMBeanInterface()
+ {
+ return iface;
+ }
+
+ /**
+ * Returns the name of the nth parameter of the constructor
+ * that will be used in the supplied {@link MBeanParameterInfo}
+ * instance. This is a customization hook, so that subclasses
+ * can provide a custom name. By default, this calls
+ * <code>param.getName()</code>.
+ *
+ * @param info the {@link MBeanConstructorInfo} instance constructed
+ * via reflection.
+ * @param param the {@link MBeanParameterInfo} instance constructed
+ * via reflection.
+ * @param n the number of the parameter, in order to link it to the
+ * information on the constructor.
+ * @return the name to use in the instance.
+ */
+ protected String getParameterName(MBeanConstructorInfo info,
+ MBeanParameterInfo param, int n)
+ {
+ return param.getName();
+ }
+
+ /**
+ * Returns the name of the nth parameter of the operation
+ * that will be used in the supplied {@link MBeanParameterInfo}
+ * instance. This is a customization hook, so that subclasses
+ * can provide a custom name. By default, this calls
+ * <code>param.getName()</code>.
+ *
+ * @param info the {@link MBeanOperationInfo} instance constructed
+ * via reflection.
+ * @param param the {@link MBeanParameterInfo} instance constructed
+ * via reflection.
+ * @param n the number of the parameter, in order to link it to the
+ * information on the operation.
+ * @return the name to use in the instance.
+ */
+ protected String getParameterName(MBeanOperationInfo info,
+ MBeanParameterInfo param, int n)
+ {
+ return param.getName();
+ }
+
+ /**
+ * Invokes the specified action on the management bean using
+ * the supplied parameters. The signature of the action is
+ * specified by a {@link String} array, which lists the classes
+ * corresponding to each parameter. The class loader used to
+ * load these classes is the same as that used for loading the
+ * management bean itself.
+ *
+ * @param name the name of the action to invoke.
+ * @param params the parameters used to call the action.
+ * @param signature the signature of the action.
+ * @return the return value of the action.
+ * @throws MBeanException if the action throws an exception. The
+ * thrown exception is the cause of this
+ * exception.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to invoke the action. The
+ * thrown exception is the cause of
+ * this exception.
+ */
+ public Object invoke(String name, Object[] params, String[] signature)
+ throws MBeanException, ReflectionException
+ {
+ Class[] sigTypes = new Class[signature.length];
+ ClassLoader loader = getClass().getClassLoader();
+ for (int a = 0; a < signature.length; ++a)
+ try
+ {
+ sigTypes[a] = Class.forName(signature[a], true, loader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ReflectionException(e, "The class, " + signature[a] +
+ ", in the method signature " +
+ "could not be loaded.");
+ }
+ Method method;
+ try
+ {
+ method = iface.getMethod(name, sigTypes);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new ReflectionException(e, "The method, " + name +
+ ", could not be found.");
+ }
+ Object result;
+ try
+ {
+ result = method.invoke(impl, params);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ReflectionException(e, "Failed to call " + name);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ReflectionException(e, "Failed to call " + name);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new MBeanException((Exception) e.getCause(), "The method "
+ + name + " threw an exception");
+ }
+ return result;
+ }
+
+ /**
+ * Sets the value of the specified attribute of the
+ * management bean. The management bean should perform
+ * a lookup for the named attribute, and sets its value
+ * using the associated setter method, if possible.
+ *
+ * @param attribute the attribute to set.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @see #getAttribute(String)
+ */
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException
+ {
+ Method setter;
+ String name = attribute.getName();
+ try
+ {
+ setter = iface.getMethod("set" +
+ name.substring(0, 1).toUpperCase() +
+ name.substring(1), null);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw ((AttributeNotFoundException)
+ new AttributeNotFoundException("The attribute, " + name +
+ ", was not found.").initCause(e));
+ }
+ try
+ {
+ setter.invoke(impl, new Object[] { attribute.getValue() });
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ReflectionException(e, "Failed to set " + name);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw ((InvalidAttributeValueException)
+ new InvalidAttributeValueException(attribute.getValue() +
+ " is an invalid value for " +
+ name).initCause(e));
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new MBeanException((Exception) e.getCause(), "The getter of "
+ + name + " threw an exception");
+ }
+ }
+
+ /**
+ * Sets the value of each of the specified attributes
+ * to that supplied by the {@link Attribute} object.
+ * The returned list contains the attributes that were
+ * set and their new values.
+ *
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @see #getAttributes(AttributeList)
+ */
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ AttributeList list = new AttributeList(attributes.size());
+ Iterator it = attributes.iterator();
+ while (it.hasNext())
+ {
+ try
+ {
+ Attribute attrib = (Attribute) it.next();
+ setAttribute(attrib);
+ list.add(attrib);
+ }
+ catch (AttributeNotFoundException e)
+ {
+ /* Ignored */
+ }
+ catch (InvalidAttributeValueException e)
+ {
+ /* Ignored */
+ }
+ catch (ReflectionException e)
+ {
+ /* Ignored */
+ }
+ catch (MBeanException e)
+ {
+ /* Ignored */
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Replaces the implementation of the interface used by this
+ * instance with the one specified. The new implementation
+ * must be non-null and implement the interface specified on
+ * construction of this instance.
+ *
+ * @throws IllegalArgumentException if <code>impl</code> is <code>null</code>.
+ * @throws NotCompliantMBeanException if <code>impl</code> doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public void setImplementation(Object impl)
+ throws NotCompliantMBeanException
+ {
+ if (impl == null)
+ throw new IllegalArgumentException("The specified implementation is null.");
+ if (!(iface.isInstance(impl)))
+ throw new NotCompliantMBeanException("The instance, " + impl +
+ ", is not an instance of " + iface);
+ this.impl = impl;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java
new file mode 100644
index 00000000000..d2fc398d623
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/ArrayType.java
@@ -0,0 +1,313 @@
+/* ArrayType.java -- Open type descriptor for an array.
+ 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.openmbean;
+
+import java.lang.reflect.Array;
+
+import java.util.Arrays;
+
+/**
+ * The open type descriptor for arrays of open data values.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ArrayType
+ extends OpenType
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 720504429830309770L;
+
+ /**
+ * The number of dimensions arrays of this type has.
+ */
+ private int dimension;
+
+ /**
+ * The element type of arrays of this type.
+ */
+ private OpenType elementType;
+
+ /**
+ * The hash code of this instance.
+ */
+ private transient Integer hashCode;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ private transient String string;
+
+ /**
+ * Returns the class name of the array, given the element
+ * class name and its dimensions.
+ *
+ * @param className the name of the class used by the
+ * array's elements.
+ * @param dim the dimensions of the array.
+ * @return the array's class name.
+ */
+ private static String getArrayClassName(String className, int dim)
+ {
+ char[] brackets = new char[dim];
+ Arrays.fill(brackets, '[');
+ return String.valueOf(brackets) + "L" + className;
+ }
+
+ /**
+ * <p>
+ * Constructs a new {@link ArrayType} instance for an array of the
+ * specified type with the supplied number of dimensions. The attributes
+ * used by the superclass, {@link OpenType}, are automatically defined,
+ * based on these values. Both the class name and type name are set
+ * to the value returned by the {@link java.lang.Class#getName()} of
+ * the array's class (i.e. the element type, preceded by n instances of
+ * '[' and an 'L', where n is the number of dimensions the array has).
+ * The description is based upon the template <code>n-dimension array
+ * of e</code>, where n is the number of dimensions of the array, and
+ * e is the element type. The class name of the actual elements is
+ * obtainable by calling {@link OpenType#getClassName()} on the result
+ * of {@link #getElementOpenType()}.
+ * </p>
+ * <p>
+ * As an example, the array type returned by
+ * <code>new ArrayType(6, SimpleType.INTEGER)</code> has the following
+ * values:
+ * </p>
+ * <table>
+ * <th><td>Attribute</td><td>Value</td></th>
+ * <tr><td>Class Name</td><td><code>[[[[[[Ljava.lang.Integer;</code>
+ * </td></tr>
+ * <tr><td>Type Name</td><td><code>[[[[[[Ljava.lang.Integer;</code>
+ * </td></tr>
+ * <tr><td>Description</td><td><code>6-dimension array of
+ * java.lang.Integer</code></td></tr>
+ * <tr><td>Element Type Class Name</td><td><code>java.lang.Integer</code>
+ * </td></tr>
+ * </table>
+ * <p>
+ * The dimensions of the array must be equal to or greater than 1. The
+ * element type must be an instance of {@link SimpleType},
+ * {@link CompositeType} or {@link TabularType}.
+ * </p>
+ *
+ * @param dim the dimensions of the array.
+ * @param elementType the type of the elements of the array.
+ * @throws IllegalArgumentException if <code>dim</code> is less than 1.
+ * @throws OpenDataException if the element type is not an instance of either
+ * {@link SimpleType}, {@link CompositeType}
+ * or {@link TabularType}.
+ */
+ public ArrayType(int dim, OpenType elementType)
+ throws OpenDataException
+ {
+ super(getArrayClassName(elementType.getClassName(), dim),
+ getArrayClassName(elementType.getClassName(), dim),
+ dim + "-dimension array of " + elementType.getClassName());
+ if (dim < 1)
+ throw new IllegalArgumentException("Dimensions must be greater " +
+ "than or equal to 1.");
+ if (!(elementType instanceof SimpleType ||
+ elementType instanceof CompositeType ||
+ elementType instanceof TabularType))
+ throw new OpenDataException("The element type must be a simple " +
+ "type, a composite type or a tabular " +
+ "type.");
+ dimension = dim;
+ this.elementType = elementType;
+ }
+
+ /**
+ * <p>
+ * Compares this array type with another object
+ * for equality. The objects are judged to be equal if:
+ * </p>
+ * <ul>
+ * <li><code>obj</code> is not null.</li>
+ * <li><code>obj</code> is an instance of
+ * {@link ArrayType}.</li>
+ * <li>The dimensions are equal.</li>
+ * <li>The element types are equal.</li>
+ * </ul>
+ *
+ * @param obj the object to compare with.
+ * @return true if the conditions above hold.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof ArrayType))
+ return false;
+ ArrayType atype = (ArrayType) obj;
+ return (atype.getDimension() == dimension &&
+ atype.getElementOpenType().equals(elementType));
+ }
+
+ /**
+ * Returns the number of dimensions used by arrays
+ * of this type.
+ *
+ * @return the number of dimensions.
+ */
+ public int getDimension()
+ {
+ return dimension;
+ }
+
+ /**
+ * Returns the open type descriptor which describes
+ * the type of the elements of this array type.
+ *
+ * @return the type of the elements.
+ */
+ public OpenType getElementOpenType()
+ {
+ return elementType;
+ }
+
+ /**
+ * <p>
+ * Returns the hash code of the array type.
+ * This is computed as the sum of the hash code of the
+ * element type together with the number of dimensions
+ * the array has. These are the same elements
+ * of the type that are compared as part of the
+ * {@link #equals(java.lang.Object)} method, thus ensuring
+ * that the hashcode is compatible with the equality
+ * test.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the hash code
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ if (hashCode == null)
+ hashCode = Integer.valueOf(dimension + elementType.hashCode());
+ return hashCode.intValue();
+ }
+
+ /**
+ * <p>
+ * Returns true if the specified object is a member of this
+ * array type. The object is judged to be so if it is
+ * non-null, an array and one of the following two conditions
+ * holds:
+ * </p>
+ * <ul>
+ * <li>This {@link ArrayType} instance has a {@link SimpleType}
+ * as its element type. Thus, the object must have the same
+ * class name as that returned by {@link SimpleType#getClassName()}
+ * for this class.</li>
+ * <li>This {@link ArrayType} instance has a {@link CompositeType}
+ * or a {@link TabularType} as its element type. Thus, the object
+ * must be assignable to such an array, and have elements which
+ * are either null or valid values for the element type.</li>
+ * </ul>
+ *
+ * @param obj the object to test for membership.
+ * @return true if the object is a member of this type.
+ */
+ public boolean isValue(Object obj)
+ {
+ if (obj == null)
+ return false;
+ Class objClass = obj.getClass();
+ if (!(objClass.isArray()))
+ return false;
+ if (elementType instanceof SimpleType)
+ return getClassName().equals(objClass.getName());
+ Class elementClass = null;
+ try
+ {
+ elementClass = Class.forName(getClassName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalStateException("The array type's element " +
+ "class could not be found.", e);
+ }
+ if (!(elementClass.isAssignableFrom(objClass)))
+ return false;
+ for (int a = 0; a < Array.getLength(obj); ++a)
+ {
+ Object elem = Array.get(obj, a);
+ if (elem != null &&
+ (!(elementType.isValue(elem))))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.ArrayType</code>)
+ * and each element of the instance which is relevant to
+ * the definition of {@link equals(java.lang.Object)} and
+ * {@link hashCode()} (i.e. the type name, the number of
+ * dimensions and the element type).
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + getTypeName()
+ + ", dimension=" + dimension
+ + ", elementType=" + elementType
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeData.java b/libjava/classpath/javax/management/openmbean/CompositeData.java
new file mode 100644
index 00000000000..08f0dc253a5
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/CompositeData.java
@@ -0,0 +1,154 @@
+/* CompositeData.java -- A composite data structure.
+ 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.openmbean;
+
+import java.util.Collection;
+
+/**
+ * Provides an interface to a composite data structure,
+ * in order to aid interoperability. The composite data
+ * structure is represented by mapping field names to
+ * values.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface CompositeData
+{
+
+ /**
+ * Returns true if this {@link CompositeData} instance contains
+ * the specified key. This method always returns false for
+ * an input key equal to <code>null</code> or the empty string.
+ *
+ * @param key the key to find in the structure.
+ * @return true if the key exists.
+ */
+ boolean containsKey(String key);
+
+ /**
+ * Returns true if this {@link CompositeData} instance has
+ * a value equal to that supplied.
+ *
+ * @param value the value to look for.
+ * @return true if the value exists.
+ */
+ boolean containsValue(Object value);
+
+ /**
+ * Compares the specified object with this object for equality.
+ * The object is judged equivalent if it is non-null, and also
+ * an instance of {@link CompositeData} with the same name-value
+ * mappings and types. The two compared instances may be
+ * equivalent even if they represent different implementations of
+ * {@link CompositeData}.
+ *
+ * @param obj the object to compare for equality.
+ * @return true if <code>obj</code> is equal to <code>this</code>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Retrieves the value for the specified key.
+ *
+ * @param key the key whose value should be returned.
+ * @return the matching value.
+ * @throws IllegalArgumentException if the key is <code>null</code>
+ * or the empty string.
+ * @throws InvalidKeyException if the key does not exist.
+ */
+ Object get(String key);
+
+ /**
+ * Returns the appropriate value for each key in the given array,
+ * using the same ordering.
+ *
+ * @param keys the keys whose values should be returned.
+ * @return the matching values.
+ * @throws IllegalArgumentException if one of the keys is
+ * <code>null</code> or the
+ * empty string.
+ * @throws InvalidKeyException if one of the keys does not exist.
+ */
+ Object[] getAll(String[] keys);
+
+ /**
+ * Returns the composite type which corresponds to this instance
+ * of {@link CompositeData}.
+ *
+ * @return the composite type for this instance.
+ */
+ CompositeType getCompositeType();
+
+ /**
+ * Returns the hash code of this instance. The hash code is
+ * computed as the sum of the hash codes of all the values plus
+ * the hash code of the composite type. As equality comparisons
+ * take place using this same information, this ensures that
+ * the property, <code>e1.equals(e2)</code> implies
+ * <code>e1.hashCode() == e2.hashCode(), holds for any pair
+ * of instances, <code>e1</code> and <code>e2</code>.
+ *
+ * @return the hash code of this {@link CompositeData}.
+ * @see Object#equals(Object)
+ */
+ int hashCode();
+
+ /**
+ * Returns a textual representation of this instance. The
+ * exact format is left up to the implementation, but it
+ * should contain the name of the implementing class,
+ * the name of the type and a mapping of the form
+ * <code>key=value</code> for each pair of key and value.
+ *
+ * @return a {@link java.lang.String} representation of the
+ * object.
+ */
+ String toString();
+
+ /**
+ * Returns a read-only collection of the values associated with
+ * this instance. The values are sorted using the lexicographic
+ * ordering of the corresponding keys.
+ *
+ * @return the values of this instance.
+ */
+ Collection values();
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
new file mode 100644
index 00000000000..5d5adb727f6
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
@@ -0,0 +1,349 @@
+/* CompositeData.java -- A composite data structure implementation.
+ 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.openmbean;
+
+import java.io.Serializable;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Provides an implementation of the {@link CompositeData}
+ * interface.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class CompositeDataSupport
+ implements CompositeData, Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 8003518976613702244L;
+
+ /**
+ * Mapping of field names to values.
+ *
+ * @serial the map of field names to values.
+ */
+ private SortedMap contents;
+
+ /**
+ * The composite type which represents this composite data instance.
+ *
+ * @serial the type information for this instance.
+ */
+ private CompositeType compositeType;
+
+ /**
+ * Constructs a new {@link CompositeDataSupport} instance with the
+ * specified type using field names and values from the supplied map.
+ * The keys of the map become the field names, while the values
+ * become the values of each respective field. This constructor simply
+ * calls the other constructor, with the two arrays formed using the
+ * keys and values of this map, respectively. Thus, the input parameters
+ * given should conform to the same requirements given there (i.e. no
+ * null values or empty strings).
+ *
+ * @param type the composite type of this composite data structure.
+ * @param items a mapping of field names to values. This should match
+ * the mappings given by the type (i.e. for each mapping
+ * in the type, there should be a corresponding field name
+ * with a value of the correct type).
+ * @throws IllegalArgumentException if the type, the map or any of the keys
+ * or values in the map are <code>null</code>,
+ * or if any key from the map is an empty
+ * string.
+ * @throws OpenDataException if a mismatch occurs between the map and the
+ * field name/type specification given by the
+ * {@link CompositeType} instance. This may be
+ * due to the two having a different size, a
+ * mismatch between keys or an incorrectly typed
+ * value.
+ * @throws ArrayStoreException if one of the keys is not a
+ * {@link java.lang.String} (thus calling a failure
+ * in converting the keys to an array of strings).
+ */
+ public CompositeDataSupport(CompositeType type, Map items)
+ throws OpenDataException
+ {
+ this(type,
+ (String[]) items.keySet().toArray(new String[items.size()]),
+ items.values().toArray());
+ }
+
+ /**
+ * Constructs a new {@link CompositeDataSupport} instance with the
+ * specified type using the supplied arrays of field names and
+ * values. Neither the type, the two arrays or any elements of the
+ * arrays may be <code>null</code>. The {@link java.lang.String}s
+ * within the <code>names</code> array must be non-empty. The
+ * arrays must match in size and order, as each element of the
+ * <code>names</code> array is matched against the corresponding
+ * value in the <code>values</code> array. Internally, the two are
+ * stored in a map, lexographically ordered using the field names.
+ * The data given should also conform to the description of the
+ * instance given by the {@link CompositeType} instance supplied.
+ *
+ * @param type the composite type of this composite data structure.
+ * @param names the field names.
+ * @param values the corresponding values of the fields.
+ * @throws IllegalArgumentException if the type, the arrays or any of the keys
+ * or values in the arrays are <code>null</code>,
+ * or if any key from <code>names</code> is
+ * an empty string. This also occurs if the
+ * arrays differ in length.
+ * @throws OpenDataException if a mismatch occurs between the arrays and the
+ * field name/type specification given by the
+ * {@link CompositeType} instance. This may be
+ * due to a differing number of field names, a
+ * mismatch between names or an incorrectly typed
+ * value.
+ */
+ public CompositeDataSupport(CompositeType type, String[] names, Object[] values)
+ throws OpenDataException
+ {
+ if (type == null)
+ throw new IllegalArgumentException("The given composite type is null.");
+ compositeType = type;
+ if (names == null)
+ throw new IllegalArgumentException("The names array is null.");
+ if (values == null)
+ throw new IllegalArgumentException("The values array is null.");
+ if (names.length != values.length)
+ throw new IllegalArgumentException("The sizes of the arrays differ.");
+ Set typeKeys = type.keySet();
+ if (typeKeys.size() != names.length)
+ throw new OpenDataException("The number of field names does not match " +
+ "the type description.");
+ contents = new TreeMap();
+ for (int a = 0; a < names.length; ++a)
+ {
+ if (names[a] == null)
+ throw new IllegalArgumentException("Element " + a + " of the names " +
+ "array is null.");
+ if (names[a].length() == 0)
+ throw new IllegalArgumentException("Element " + a + " of the names " +
+ "array is an empty string.");
+ if (values[a] == null)
+ throw new IllegalArgumentException("Element " + a + " of the values " +
+ "array is null.");
+ if (!(typeKeys.contains(names[a])))
+ throw new OpenDataException("The name, " + names[a] + ", is not a " +
+ "field in the given type description.");
+ if (!(type.getType(names[a]).isValue(values[a])))
+ throw new OpenDataException("The value, " + values[a] + ", is not a " +
+ "valid value for the " + names[a] + " field.");
+ contents.put(names[a], values[a]);
+ }
+ }
+
+ /**
+ * Returns true if this {@link CompositeData} instance contains
+ * the specified key. This method always returns false for
+ * an input key equal to <code>null</code> or the empty string.
+ *
+ * @param key the key to find in the structure.
+ * @return true if the key exists.
+ */
+ public boolean containsKey(String key)
+ {
+ if (key == null || key.length() == 0)
+ return false;
+ else
+ return contents.containsKey(key);
+ }
+
+ /**
+ * Returns true if this {@link CompositeData} instance has
+ * a value equal to that supplied.
+ *
+ * @param value the value to look for.
+ * @return true if the value exists.
+ */
+ public boolean containsValue(Object value)
+ {
+ return contents.containsValue(value);
+ }
+
+
+ /**
+ * Compares the specified object with this object for equality.
+ * The object is judged equivalent if it is non-null, and also
+ * an instance of {@link CompositeData} with the same name-value
+ * mappings and types. The two compared instances may be
+ * equivalent even if they represent different implementations of
+ * {@link CompositeData}.
+ *
+ * @param obj the object to compare for equality.
+ * @return true if <code>obj</code> is equal to <code>this</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof CompositeData))
+ return false;
+ CompositeData data = (CompositeData) obj;
+ if (!(data.getCompositeType().equals(compositeType)))
+ return false;
+ Iterator it = contents.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (!(data.containsKey(key)))
+ return false;
+ if (!(data.get(key).equals(contents.get(key))))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Retrieves the value for the specified key.
+ *
+ * @param key the key whose value should be returned.
+ * @return the matching value.
+ * @throws IllegalArgumentException if the key is <code>null</code>
+ * or the empty string.
+ * @throws InvalidKeyException if the key does not exist.
+ */
+ public Object get(String key)
+ {
+ if (key == null)
+ throw new IllegalArgumentException("The supplied key is null.");
+ if (key.length() == 0)
+ throw new IllegalArgumentException("The supplied key is the empty string.");
+ if (!(contents.containsKey(key)))
+ throw new InvalidKeyException("The supplied key does not exist.");
+ return contents.get(key);
+ }
+
+ /**
+ * Returns the appropriate value for each key in the given array,
+ * using the same ordering.
+ *
+ * @param keys the keys whose values should be returned.
+ * @return the matching values.
+ * @throws IllegalArgumentException if one of the keys is
+ * <code>null</code> or the
+ * empty string.
+ * @throws InvalidKeyException if one of the keys does not exist.
+ */
+ public Object[] getAll(String[] keys)
+ {
+ Object[] values = new Object[keys.length];
+ for (int a = 0; a < keys.length; ++a)
+ values[a] = get(keys[a]);
+ return values;
+ }
+
+
+ /**
+ * Returns the composite type which corresponds to this instance
+ * of {@link CompositeData}.
+ *
+ * @return the composite type for this instance.
+ */
+ public CompositeType getCompositeType()
+ {
+ return compositeType;
+ }
+
+ /**
+ * Returns the hash code of this instance. The hash code is
+ * computed as the sum of the hash codes of all the values plus
+ * the hash code of the composite type. As equality comparisons
+ * take place using this same information, this should ensure that
+ * the property, <code>e1.equals(e2)</code> implies
+ * <code>e1.hashCode() == e2.hashCode(), holds for any pair
+ * of instances, <code>e1</code> and <code>e2</code>. However,
+ * this relies on the other instance implementing the
+ * <code>hashCode</code> method correctly, if it is not an
+ * instance of {@link CompositeDataSupport}.
+ *
+ * @return the hash code of this {@link CompositeData}.
+ * @see Object#equals(Object)
+ */
+ public int hashCode()
+ {
+ int code = compositeType.hashCode();
+ Iterator it = values().iterator();
+ while (it.hasNext())
+ code += it.next().hashCode();
+ return code;
+ }
+
+
+ /**
+ * Returns a textual representation of this instance. The
+ * exact format is left up to the implementation, but it
+ * should contain the name of the implementing class,
+ * the name of the type and a mapping of the form
+ * <code>key=value</code> for each pair of key and value.
+ *
+ * @return a {@link java.lang.String} representation of the
+ * object.
+ */
+ public String toString()
+ {
+ return getClass().getName() +
+ "[compositeType=" + compositeType +
+ ",contents=" + contents +
+ "]";
+ }
+
+ /**
+ * Returns a read-only collection of the values associated with
+ * this instance. The values are sorted using the lexicographic
+ * ordering of the corresponding keys.
+ *
+ * @return the values of this instance.
+ */
+ public Collection values()
+ {
+ return Collections.unmodifiableCollection(contents.values());
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/CompositeType.java b/libjava/classpath/javax/management/openmbean/CompositeType.java
new file mode 100644
index 00000000000..0ae5a4e4bfe
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/CompositeType.java
@@ -0,0 +1,324 @@
+/* CompositeType.java -- Type descriptor for CompositeData instances.
+ 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.openmbean;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * The open type descriptor for instances of the
+ * {@link CompositeData} class.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class CompositeType
+ extends OpenType
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -5366242454346948798L;
+
+ /**
+ * A map of item names to their descriptions.
+ */
+ private TreeMap nameToDescription;
+
+ /**
+ * A map of item names to their types.
+ */
+ private TreeMap nameToType;
+
+ /**
+ * The hash code of this instance.
+ */
+ private transient Integer hashCode;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ private transient String string;
+
+ /**
+ * <p>
+ * Constructs a new {@link CompositeType} instance for the given
+ * type name with the specified field names, descriptions and types.
+ * All parameters, and the elements of the array parameters, must be
+ * non-null and {@link java.lang.String} values must be something other
+ * than the empty string. The arrays must be non-empty, and be of
+ * equal size.
+ * </p>
+ * <p>
+ * The result of <code>CompositeData.class.getName()</code> is adopted
+ * as the class name (see {@link OpenType}) and changes to the array
+ * elements following construction of the {@link CompositeType} instance
+ * will <strong>not</strong> affect the values used by the instance.
+ * The field names are sorted in to ascending alphanumeric order internally,
+ * and so ordering can not be used to differentiate between two instances.
+ * </p>
+ *
+ * @param name the name of this composite type.
+ * @param desc a description of this composite type.
+ * @param names the names of each field within the composite type.
+ * @param descs the descriptions of each field within the composite type.
+ * @param types the types of each field within the composite type.
+ * @throws IllegalArgumentException if any validity constraint listed above
+ * is broken.
+ * @throws OpenDataException if duplicate item names are provided. Item names
+ * are case-sensitive, but whitespace is removed
+ * before comparison.
+ */
+ public CompositeType(String name, String desc, String[] names,
+ String[] descs, OpenType[] types)
+ throws OpenDataException
+ {
+ super(CompositeData.class.getName(), name, desc);
+ if (names.length == 0
+ || names.length != descs.length
+ || names.length != types.length)
+ throw new IllegalArgumentException("Arrays must be non-empty " +
+ "and of equal size.");
+ nameToDescription = new TreeMap();
+ for (int a = 0; a < names.length; ++a)
+ {
+ if (names[a] == null)
+ throw new IllegalArgumentException("Name " + a + " is null.");
+ if (descs[a] == null)
+ throw new IllegalArgumentException("Description " + a +
+ " is null.");
+ String fieldName = names[a].trim();
+ if (fieldName.length() == 0)
+ throw new IllegalArgumentException("Name " + a + " is " +
+ "the empty string.");
+ if (descs[a].length() == 0)
+ throw new IllegalArgumentException("Description " + a + " is " +
+ "the empty string.");
+ if (nameToDescription.containsKey(fieldName))
+ throw new OpenDataException(fieldName + " appears more " +
+ "than once.");
+ nameToDescription.put(fieldName, descs[a]);
+ }
+ nameToType = new TreeMap();
+ for (int a = 0; a < names.length; ++a)
+ nameToType.put(names[a].trim(), types[a]);
+ }
+
+ /**
+ * Returns true if this composite data type has a field
+ * with the given name.
+ *
+ * @param name the name of the field to check for.
+ * @return true if a field of that name exists.
+ */
+ public boolean containsKey(String name)
+ {
+ return nameToDescription.containsKey(name);
+ }
+
+ /**
+ * <p>
+ * Compares this composite data type with another object
+ * for equality. The objects are judged to be equal if:
+ * </p>
+ * <ul>
+ * <li><code>obj</code> is not null.</li>
+ * <li><code>obj</code> is an instance of
+ * {@link CompositeType}.</li>
+ * <li>The type names are equal.</li>
+ * <li>The fields and their types match.</li>
+ * </ul>
+ *
+ * @param obj the object to compare with.
+ * @return true if the conditions above hold.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof CompositeType))
+ return false;
+ CompositeType ctype = (CompositeType) obj;
+ if (!(ctype.getTypeName().equals(getTypeName())))
+ return false;
+ Set keys = keySet();
+ if (!(ctype.keySet().equals(keys)))
+ return false;
+ Iterator it = keys.iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (!(ctype.getType(key).equals(getType(key))))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns the description for the given field name,
+ * or <code>null</code> if the field name does not
+ * exist within this composite data type.
+ *
+ * @param name the name of the field whose description
+ * should be returned.
+ * @return the description, or <code>null</code> if the
+ * field doesn't exist.
+ */
+ public String getDescription(String name)
+ {
+ return (String) nameToDescription.get(name);
+ }
+
+ /**
+ * Returns the type for the given field name,
+ * or <code>null</code> if the field name does not
+ * exist within this composite data type.
+ *
+ * @param name the name of the field whose type
+ * should be returned.
+ * @return the type, or <code>null</code> if the
+ * field doesn't exist.
+ */
+ public OpenType getType(String name)
+ {
+ return (OpenType) nameToType.get(name);
+ }
+
+ /**
+ * <p>
+ * Returns the hash code of the composite data type.
+ * This is computed as the sum of the hash codes of
+ * each field name and its type, together with the hash
+ * code of the type name. These are the same elements
+ * of the type that are compared as part of the
+ * {@link #equals(java.lang.Object)} method, thus ensuring
+ * that the hashcode is compatible with the equality
+ * test.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the hash code
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ int elementTotal = 0;
+ Iterator it = nameToType.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ elementTotal += (entry.getKey().hashCode() +
+ entry.getValue().hashCode());
+ }
+ hashCode = Integer.valueOf(elementTotal
+ + getTypeName().hashCode());
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * Returns true if the specified object is a member of this
+ * composite type. The object is judged to be so if it is
+ * an instance of {@link CompositeData} with an equivalent
+ * type, according to the definition of
+ * {@link #equals(java.lang.Object)} for {@link CompositeType}.
+ *
+ * @param obj the object to test for membership.
+ * @return true if the object is a member of this type.
+ */
+ public boolean isValue(Object obj)
+ {
+ if (obj instanceof CompositeData)
+ {
+ CompositeData data = (CompositeData) obj;
+ return equals(data.getCompositeType());
+ }
+ return false;
+ }
+
+ /**
+ * Returns an unmodifiable {@link java.util.Set}-based
+ * view of the field names that form part of this
+ * {@link CompositeType} instance. The names are stored
+ * in ascending alphanumeric order.
+ *
+ * @return a unmodifiable set containing the field
+ * name {@link java.lang.String}s.
+ */
+ public Set keySet()
+ {
+ return Collections.unmodifiableSet(nameToDescription.keySet());
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.CompositeType</code>)
+ * and each element of the instance which is relevant to
+ * the definition of {@link equals(java.lang.Object)} and
+ * {@link hashCode()} (i.e. the type name, and the name
+ * and type of each field).
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + getTypeName()
+ + ", fields=" + nameToType
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/InvalidKeyException.java b/libjava/classpath/javax/management/openmbean/InvalidKeyException.java
new file mode 100644
index 00000000000..5f0cf76036e
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/InvalidKeyException.java
@@ -0,0 +1,77 @@
+/* InvalidKeyException.java -- Thrown by an invalid composite/tabular key.
+ 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.openmbean;
+
+/**
+ * Thrown when an invalid key (a field name or row index) is
+ * passed to a method of the {@link CompositeData} or
+ * {@link TabularData} classes.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class InvalidKeyException
+ extends IllegalArgumentException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 4224269443946322062L;
+
+ /**
+ * Constructs a new <code>InvalidKeyException</code>.
+ */
+ public InvalidKeyException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>InvalidKeyException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public InvalidKeyException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/OpenDataException.java b/libjava/classpath/javax/management/openmbean/OpenDataException.java
new file mode 100644
index 00000000000..a476cc1d4d2
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenDataException.java
@@ -0,0 +1,79 @@
+/* OpenDataException.java -- Thrown by invalid open bean data.
+ 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.openmbean;
+
+import javax.management.JMException;
+
+/**
+ * Thrown when an instance of one of the open types, open
+ * data objects or open metadata information objects could
+ * not be created due to invalid construction parameters.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class OpenDataException
+ extends JMException
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 8346311255433349870L;
+
+ /**
+ * Constructs a new <code>OpenDataException</code>.
+ */
+ public OpenDataException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>OpenDataException</code>
+ * with the specified message.
+ *
+ * @param message the error message to give to the user.
+ */
+ public OpenDataException(String message)
+ {
+ super(message);
+ }
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/OpenType.java b/libjava/classpath/javax/management/openmbean/OpenType.java
new file mode 100644
index 00000000000..b08c40cccce
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/OpenType.java
@@ -0,0 +1,230 @@
+/* OpenType.java -- Superclass of all open types.
+ 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.openmbean;
+
+import java.io.Serializable;
+
+/**
+ * The superclass of all open types, which describe the
+ * applicable data values for open MBeans. An open type
+ * is defined by its name and description, and the name
+ * of the Java class it maps to.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public abstract class OpenType
+ implements Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -9195195325186646468L;
+
+ /**
+ * The name of the Java class this type represents.
+ */
+ private String className;
+
+ /**
+ * The name of this type.
+ */
+ private String typeName;
+
+ /**
+ * A description of this type.
+ */
+ private String description;
+
+ /**
+ * An array which defines the set of Java types which can be
+ * used as open types. Note that each type is also available
+ * in array form, possibly with multiple dimensions.
+ */
+ public static final String[] ALLOWED_CLASSNAMES = {
+ "java.lang.Void",
+ "java.lang.Boolean",
+ "java.lang.Character",
+ "java.lang.Byte",
+ "java.lang.Short",
+ "java.lang.Integer",
+ "java.lang.Long",
+ "java.lang.Float",
+ "java.lang.Double",
+ "java.lang.String",
+ "java.math.BigDecimal",
+ "java.math.BigInteger",
+ "java.util.Date",
+ "javax.management.ObjectName",
+ CompositeData.class.getName(),
+ TabularData.class.getName()
+ };
+
+ /**
+ * Constructs a new {@link OpenType} for the specified class
+ * with the given name and description. The name of the class
+ * must be taken from the list of {@link ALLOWED_CLASSNAMES}.
+ * Arrays are implictly included in this, and follow the usual
+ * syntax of {@link java.lang.Class#getName()} with the name
+ * preceded by n instances of '[' (where n is the number of
+ * dimensions) and an L. The name and description can not be
+ * <code>null</code> or the empty string.
+ *
+ * @param className the name of the Java class this type
+ * represents.
+ * @param name the name of the type.
+ * @param desc the description of the type.
+ * @throws IllegalArgumentException if either of <code>name</code>
+ * or <code>desc</code> are
+ * <code>null</code> or the empty
+ * string.
+ * @throws OpenDataException if the class name does not reference
+ * a listed class (from @{link ALLOWED_CLASSNAMES})
+ */
+ protected OpenType(String className, String name, String desc)
+ throws OpenDataException
+ {
+ if (name == null || name.equals(""))
+ throw new IllegalArgumentException("The name can not be null " +
+ "or the empty string.");
+ if (desc == null || desc.equals(""))
+ throw new IllegalArgumentException("The description can not " +
+ "be null or the empty string.");
+ String testString;
+ if (className.startsWith("["))
+ testString = className.substring(className.indexOf("L") + 1);
+ else
+ testString = className;
+ boolean openTypeFound = false;
+ for (int a = 0; a < ALLOWED_CLASSNAMES.length; ++a)
+ if (ALLOWED_CLASSNAMES[a].equals(className))
+ openTypeFound = true;
+ if (!openTypeFound)
+ throw new OpenDataException("The class name does not specify " +
+ "a valid open type.");
+ this.className = className;
+ typeName = name;
+ description = desc;
+ }
+
+ /**
+ * Performs an equality test on this object and the one specified.
+ *
+ * @param obj the object to test against this one.
+ * @return true if the two objects are equivalent.
+ * @see java.lang.Object#hashCode()
+ */
+ public abstract boolean equals(Object obj);
+
+ /**
+ * Returns the name of the Java class this type represents. This must
+ * be one of the {@link ALLOWED_CLASSNAMES} or an array of one of them.
+ * The specification of arrays follows the standard set by
+ * {@link java.lang.Class#getName()} i.e. the name is the class name
+ * preceded by n instances of '[' and an 'L', where n is number of
+ * dimensions used by the array.
+ *
+ * @return the class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns a description of this open type.
+ *
+ * @return the description.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Returns the name of this open type.
+ *
+ * @return the type name.
+ */
+ public String getTypeName()
+ {
+ return typeName;
+ }
+
+ /**
+ * Returns a hash code for this open type. The hash code
+ * should be consistent with the {@link equals()} method.
+ * Thus, it should continue to return the same value while
+ * the values used by the {@link equals()} method remain
+ * the same, and should return different hash codes for
+ * objects which are judged to be different using the
+ * {@link equals()} method.
+ *
+ * @return the hash code of this instance.
+ */
+ public abstract int hashCode();
+
+ /**
+ * Returns true if this open type represents an array type.
+ *
+ * @return true if this open type represents an array type.
+ */
+ public boolean isArray()
+ {
+ return className.startsWith("[");
+ }
+
+ /**
+ * Returns true if the specified object is a member of this
+ * type.
+ *
+ * @param obj the object to test for membership.
+ * @return true if the object is a member of this type.
+ */
+ public abstract boolean isValue(Object obj);
+
+ /**
+ * Returns a textual representation of this type.
+ *
+ * @return a {@link java.lang.String} representation of this
+ * type.
+ */
+ public abstract String toString();
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java
new file mode 100644
index 00000000000..3962909d4bb
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/SimpleType.java
@@ -0,0 +1,342 @@
+/* SimpleType.java -- Open type descriptor for the base types.
+ 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.openmbean;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+
+/**
+ * The open type descriptor for data values that are members
+ * of one of the simple types (such as an integer or a string).
+ * The other open types ({@link ArrayType}, {@link CompositeType},
+ * {@link TabularType}) are constructed from one or more of these
+ * types. The simple types are formed from a small subset of
+ * basic Java types. As a result, the valid instances of this
+ * class are predefined, and no constructor is given for creating
+ * new instances.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class SimpleType
+ extends OpenType
+{
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.math.BigDecimal</code>.
+ */
+ public static final SimpleType BIGDECIMAL;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.math.BigInteger</code>.
+ */
+ public static final SimpleType BIGINTEGER;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Boolean</code>.
+ */
+ public static final SimpleType BOOLEAN;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Byte</code>.
+ */
+ public static final SimpleType BYTE;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Character</code>.
+ */
+ public static final SimpleType CHARACTER;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.util.Date</code>.
+ */
+ public static final SimpleType DATE;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Double</code>.
+ */
+ public static final SimpleType DOUBLE;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Float</code>.
+ */
+ public static final SimpleType FLOAT;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Integer</code>.
+ */
+ public static final SimpleType INTEGER;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Long</code>.
+ */
+ public static final SimpleType LONG;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>javax.management.ObjectName</code>.
+ */
+ public static final SimpleType OBJECTNAME;
+
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Short</code>.
+ */
+ public static final SimpleType SHORT;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.String</code>.
+ */
+ public static final SimpleType STRING;
+
+ /**
+ * The {@link SimpleType} representation of
+ * <code>java.lang.Void</code>.
+ */
+ public static final SimpleType VOID;
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 2215577471957694503L;
+
+ /**
+ * The hash code of this instance.
+ */
+ private transient Integer hashCode;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ private transient String string;
+
+ /**
+ * Static construction of the {@link SimpleType} instances.
+ */
+ static
+ {
+ try
+ {
+ BIGDECIMAL = new SimpleType("java.math.BigDecimal");
+ BIGINTEGER = new SimpleType("java.math.BigInteger");
+ BOOLEAN = new SimpleType("java.lang.Boolean");
+ BYTE = new SimpleType("java.lang.Byte");
+ CHARACTER = new SimpleType("java.lang.Character");
+ DATE = new SimpleType("java.util.Date");
+ DOUBLE = new SimpleType("java.lang.Double");
+ FLOAT = new SimpleType("java.lang.Float");
+ INTEGER = new SimpleType("java.lang.Integer");
+ LONG = new SimpleType("java.lang.Long");
+ OBJECTNAME = new SimpleType("javax.management.ObjectName");
+ SHORT = new SimpleType("java.lang.Short");
+ STRING = new SimpleType("java.lang.String");
+ VOID = new SimpleType("java.lang.Void");
+ }
+ catch (OpenDataException e)
+ {
+ /* In normal circumstances, this shouldn't be possible. */
+ throw new IllegalStateException("A invalid class name " +
+ "was passed to the SimpleType " +
+ "constructor.");
+ }
+ }
+
+ /**
+ * Constructs a new {@link SimpleType} instance for the given
+ * class name. The class name is also used as the type name
+ * and description of the {@link OpenType} instance.
+ *
+ * @param name the name of the class this instance should
+ * represent.
+ * @throws OpenDataException if somehow the constructor of the
+ * superclass is passed an invalid
+ * class name.
+ */
+ private SimpleType(String name)
+ throws OpenDataException
+ {
+ super(name, name, name);
+ }
+
+ /**
+ * <p>
+ * Compares this simple data type with another object
+ * for equality. The objects are judged to be equal if:
+ * </p>
+ * <ul>
+ * <li><code>obj</code> is not null.</li>
+ * <li><code>obj</code> is an instance of
+ * {@link SimpleType}.</li>
+ * <li>The class names are equal.</li>
+ * </ul>
+ *
+ * @param obj the object to compare with.
+ * @return true if the conditions above hold.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof SimpleType))
+ return false;
+ SimpleType sType = (SimpleType) obj;
+ return sType.getClassName().equals(getClassName());
+ }
+
+ /**
+ * <p>
+ * Returns the hash code of the simple data type.
+ * This is simply the hash code of the class name,
+ * which is the same element of the type compared
+ * as part of the
+ * {@link #equals(java.lang.Object)} method, thus ensuring
+ * that the hashcode is compatible with the equality
+ * test.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the hash code
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ if (hashCode == null)
+ hashCode = Integer.valueOf(getClassName().hashCode());
+ return hashCode.intValue();
+ }
+
+ /**
+ * Returns true if the specified object is a member of this
+ * simple type. The object is judged to be so if it is
+ * non-null and its class name is the same as that returned
+ * by {@link SimpleType#getClassName()}.
+ *
+ * @param obj the object to test for membership.
+ * @return true if the object is a member of this type.
+ */
+ public boolean isValue(Object obj)
+ {
+ if (obj == null)
+ return false;
+ return obj.getClass().getName().equals(getClassName());
+ }
+
+ /**
+ * Replaces instances of this class read from an
+ * {@link java.io.ObjectInputStream} with one of the predefined
+ * values. This ensures that each existing instance of
+ * this class is one of these unique instances.
+ *
+ * @return the replacement object.
+ * @throws ObjectStreamException if the object can not be
+ * resolved.
+ */
+ public Object readResolve()
+ throws ObjectStreamException
+ {
+ if (equals(BIGDECIMAL))
+ return BIGDECIMAL;
+ if (equals(BIGINTEGER))
+ return BIGINTEGER;
+ if (equals(BOOLEAN))
+ return BOOLEAN;
+ if (equals(BYTE))
+ return BYTE;
+ if (equals(CHARACTER))
+ return CHARACTER;
+ if (equals(DATE))
+ return DATE;
+ if (equals(DOUBLE))
+ return DOUBLE;
+ if (equals(FLOAT))
+ return FLOAT;
+ if (equals(INTEGER))
+ return INTEGER;
+ if (equals(LONG))
+ return LONG;
+ if (equals(OBJECTNAME))
+ return OBJECTNAME;
+ if (equals(SHORT))
+ return SHORT;
+ if (equals(STRING))
+ return STRING;
+ if (equals(VOID))
+ return VOID;
+ throw new InvalidObjectException("Invalid simple type instance " +
+ "deserialized.");
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.SimpleType</code>)
+ * and the name of the class the type represents.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + getClassName()
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/TabularData.java b/libjava/classpath/javax/management/openmbean/TabularData.java
new file mode 100644
index 00000000000..17c8de98109
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/TabularData.java
@@ -0,0 +1,258 @@
+/* TabularData.java -- Tables of composite data structures.
+ 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.openmbean;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Provides an interface to a specific type of composite
+ * data structure, where keys (the columns) map to the
+ * {@link CompositeData} objects that form the rows of
+ * the table.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface TabularData
+{
+
+ /**
+ * Calculates the index the specified {@link CompositeData} value
+ * would have, if it was to be added to this {@link TabularData}
+ * instance. This method includes a check that the type of
+ * the given value is the same as the row type of this instance,
+ * but not a check for existing instances of the given value.
+ * The value must also not be <code>null</code>. Possible indices
+ * are returned by the {@link TabularType#getIndexNames()} method
+ * of this instance's tabular type.
+ *
+ * @param val the {@link CompositeData} value whose index should
+ * be calculated.
+ * @return the index the value would take on, if it were to be added.
+ * @throws NullPointerException if the value is <code>null</code>.
+ * @throws InvalidOpenTypeException if the value does not match the
+ * row type of this instance.
+ */
+ Object[] calculateIndex(CompositeData val);
+
+ /**
+ * Removes all {@link CompositeData} values from the table.
+ */
+ void clear();
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains a {@link CompositeData} value at the specified index.
+ * In any other circumstance, including if the given key
+ * is <code>null</code> or of the incorrect type, according to
+ * the {@link TabularType} of this instance, this method returns
+ * false.
+ *
+ * @param key the key to test for.
+ * @return true if the key maps to a {@link CompositeData} value.
+ */
+ boolean containsKey(Object[] key);
+
+ /**
+ * Returns true iff this instance of the {@link TabularData} class
+ * contains the specified {@link CompositeData} value.
+ * In any other circumstance, including if the given value
+ * is <code>null</code> or of the incorrect type, according to
+ * the {@link TabularType} of this instance, this method returns
+ * false.
+ *
+ * @param val the value to test for.
+ * @return true if the value exists.
+ */
+ boolean containsValue(CompositeData val);
+
+ /**
+ * Compares the specified object with this object for equality.
+ * The object is judged equivalent if it is non-null, and also
+ * an instance of {@link TabularData} with the same row type,
+ * and index to value mappings. The two compared instances may
+ * be equivalent even if they represent different implementations
+ * of {@link TabularData}.
+ *
+ * @param obj the object to compare for equality.
+ * @return true if <code>obj</code> is equal to <code>this</code>.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Retrieves the {@link CompositeData} value for the specified
+ * key, or <code>null</code> if no such mapping exists.
+ *
+ * @param key the key whose value should be returned.
+ * @return the matching {@link CompositeData} value, or
+ * <code>null</code> if one does not exist.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws InvalidOpenTypeException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ CompositeData get(Object[] key);
+
+ /**
+ * Returns the tabular type which corresponds to this instance
+ * of {@link TabularData}.
+ *
+ * @return the tabular type for this instance.
+ */
+ TabularType getTabularType();
+
+ /**
+ * Returns the hash code of the composite data type.
+ * This is computed as the sum of the hash codes of the
+ * each index and its value, together with the hash
+ * code of the tabular type. These are the same elements
+ * of the type that are compared as part of the
+ * {@link #equals(java.lang.Object)} method, thus ensuring
+ * that the hashcode is compatible with the equality
+ * test.
+ *
+ * @return the hash code of this instance.
+ */
+ int hashCode();
+
+ /**
+ * Returns true if this {@link TabularData} instance
+ * contains no {@link CompositeData} values.
+ *
+ * @return true if the instance is devoid of rows.
+ */
+ boolean isEmpty();
+
+ /**
+ * Returns a {@link java.util.Set} view of the keys or
+ * indices of this {@link TabularData} instance.
+ *
+ * @return a set containing the keys of this instance.
+ */
+ Set keySet();
+
+ /**
+ * Adds the specified {@link CompositeData} value to the
+ * table. The value must be non-null, of the same type
+ * as the row type of this instance, and must not have
+ * the same index as an existing value. The index is
+ * calculated using the index names of the
+ * {@link TabularType} for this instance.
+ *
+ * @param val the {@link CompositeData} value to add.
+ * @throws NullPointerException if <code>val</code> is
+ * <code>null</code>.
+ * @throws InvalidOpenTypeException if the type of the
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if the value has the
+ * same calculated index
+ * as an existing value.
+ */
+ void put(CompositeData val);
+
+ /**
+ * Adds each of the specified {@link CompositeData} values
+ * to the table. Each element of the array must meet the
+ * conditions given for the {@link #put(CompositeData)}
+ * method. In addition, the index of each value in the
+ * array must be distinct from the index of the other
+ * values in the array, as well as from the existing values
+ * in the table. The operation should be atomic; if one
+ * value can not be added, then none of the values should
+ * be.
+ *
+ * @param vals the {@link CompositeData} values to add.
+ * @throws NullPointerException if <code>val</code> is
+ * <code>null</code>.
+ * @throws InvalidOpenTypeException if the type of the
+ * given value does not
+ * match the row type.
+ * @throws KeyAlreadyExistsException if the value has the
+ * same calculated index
+ * as an existing value or
+ * of one of the other
+ * specified values.
+ */
+ void putAll(CompositeData[] vals);
+
+ /**
+ * Removes the {@link CompositeData} value located at the
+ * specified index. <code>null</code> is returned if the
+ * value does not exist. Otherwise, the removed value is
+ * returned.
+ *
+ * @param key the key of the value to remove.
+ * @return the removed value, or <code>null</code> if
+ * there is no value for the given key.
+ * @throws NullPointerException if the key is <code>null</code>.
+ * @throws InvalidOpenTypeException if the key does not match
+ * the {@link TabularType} of this
+ * instance.
+ */
+ CompositeData remove(Object[] key);
+
+ /**
+ * Returns the number of {@link CompositeData} values or rows
+ * in the table.
+ *
+ * @return the number of rows in the table.
+ */
+ int size();
+
+ /**
+ * Returns a textual representation of this instance. The
+ * exact format is left up to the implementation, but it
+ * should contain the name of the implementing class and
+ * the tabular type.
+ *
+ * @return a {@link java.lang.String} representation of the
+ * object.
+ */
+ String toString();
+
+ /**
+ * Returns the values associated with this instance.
+ *
+ * @return the values of this instance.
+ */
+ Collection values();
+
+}
+
diff --git a/libjava/classpath/javax/management/openmbean/TabularType.java b/libjava/classpath/javax/management/openmbean/TabularType.java
new file mode 100644
index 00000000000..c38f5ea626e
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/TabularType.java
@@ -0,0 +1,269 @@
+/* TabularType.java -- Type descriptor for TabularData instances.
+ 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.openmbean;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The open type descriptor for instances of the
+ * {@link TabularData} class.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class TabularType
+ extends OpenType
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 6554071860220659261L;
+
+ /**
+ * The composite type used by the rows of the table.
+ */
+ private CompositeType rowType;
+
+ /**
+ * The list of index names, which form the columns of the table.
+ * They are retained in the order given by the user, and is
+ * unmodifiable.
+ */
+ private List indexNames;
+
+ /**
+ * The hash code of this instance.
+ */
+ private transient Integer hashCode;
+
+ /**
+ * The <code>toString()</code> result of this instance.
+ */
+ private transient String string;
+
+ /**
+ * <p>
+ * Constructs a new {@link TabularType} instance for the given
+ * type name, description, row type and index names. All parameters
+ * (including the individual elements of the array of index names)
+ * must be non-null and those that are of type {@link java.lang.String}
+ * must be non-empty. The array of index names must also be non-empty.
+ * </p>
+ * <p>
+ * The result of <code>TabularData.class.getName()</code> is adopted
+ * as the class name (see {@link OpenType}). The ordering of the array
+ * elements is relevant in determining the indicies of the values in the
+ * table, and thus in the use of the
+ * {@link TabularData#get(java.lang.Object[])} and
+ * {@link TabularData#remove(java.lang.Object[])} methods of the
+ * {@link TabularData} class.
+ * </p>
+ *
+ * @param name the name of this tabular type.
+ * @param desc a description of this tabular type.
+ * @param rowType the type of the rows of the table.
+ * @param indexNames the names used to index the rows within the table.
+ * @throws IllegalArgumentException if any validity constraint listed above
+ * is broken.
+ * @throws OpenDataException if an index name does not match a corresponding
+ * name in the given row type.
+ */
+ public TabularType(String name, String desc, CompositeType rowType,
+ String[] indexNames)
+ throws OpenDataException
+ {
+ super(TabularData.class.getName(), name, desc);
+ if (rowType == null)
+ throw new IllegalArgumentException("A null row type was given.");
+ for (int a = 0; a < indexNames.length; ++a)
+ {
+ if (indexNames[a] == null)
+ throw new IllegalArgumentException("Name " + a +
+ " is null.");
+ if (indexNames[a].length() == 0)
+ throw new IllegalArgumentException("Name " + a +
+ " is the empty string.");
+ if (!(rowType.containsKey(indexNames[a])))
+ throw new OpenDataException("No matching key for " +
+ indexNames[a] + " was found in " +
+ "the supplied row type.");
+ }
+ this.rowType = rowType;
+ this.indexNames = Collections.unmodifiableList(Arrays.asList(indexNames));
+ }
+
+ /**
+ * <p>
+ * Compares this tabular data type with another object
+ * for equality. The objects are judged to be equal if:
+ * </p>
+ * <ul>
+ * <li><code>obj</code> is not null.</li>
+ * <li><code>obj</code> is an instance of
+ * {@link TabularType}.</li>
+ * <li>The type names are equal.</li>
+ * <li>The row types are equal.</li>
+ * <li>The index names are equal and in the same order.</li>
+ * </ul>
+ *
+ * @param obj the object to compare with.
+ * @return true if the conditions above hold.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof TabularType))
+ return false;
+ TabularType ttype = (TabularType) obj;
+ return (ttype.getTypeName().equals(getTypeName())
+ && (ttype.getRowType().equals(getRowType()))
+ && (ttype.getIndexNames().equals(getIndexNames())));
+ }
+
+ /**
+ * Returns an unmodifiable list containing the index names.
+ * The ordering of these names is used to determine the indicies
+ * of the {@link CompositeData} values, and is retained from that
+ * used in the call to this object's constructor.
+ *
+ * @return an unmodifiable list of the index names used by this
+ * tabular data structure.
+ */
+ public List getIndexNames()
+ {
+ return indexNames;
+ }
+
+ /**
+ * Returns the type of the rows used by this tabular data structure.
+ *
+ * @return the row type.
+ */
+ public CompositeType getRowType()
+ {
+ return rowType;
+ }
+
+ /**
+ * <p>
+ * Returns the hash code of the tabular data type.
+ * This is computed as the sum of the hash codes of the
+ * index names together with the hash code of the type
+ * name and row type. These are the same elements
+ * of the type that are compared as part of the
+ * {@link #equals(java.lang.Object)} method, thus ensuring
+ * that the hashcode is compatible with the equality
+ * test.
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the hash code
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ int elementTotal = 0;
+ Iterator it = indexNames.iterator();
+ while (it.hasNext())
+ elementTotal += it.next().hashCode();
+ hashCode = Integer.valueOf(elementTotal
+ + getTypeName().hashCode()
+ + rowType.hashCode());
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * Returns true if the specified object is a member of this
+ * tabular type. The object is judged to be so if it is
+ * an instance of {@link TabularData} with an equivalent
+ * type, according to the definition of
+ * {@link #equals(java.lang.Object)} for {@link TabularType}.
+ *
+ * @param obj the object to test for membership.
+ * @return true if the object is a member of this type.
+ */
+ public boolean isValue(Object obj)
+ {
+ if (obj instanceof TabularData)
+ {
+ TabularData data = (TabularData) obj;
+ return equals(data.getTabularType());
+ }
+ return false;
+ }
+
+ /**
+ * <p>
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.openmbean.TabularType</code>)
+ * and each element of the instance which is relevant to
+ * the definition of {@link equals(java.lang.Object)} and
+ * {@link hashCode()} (i.e. the type name, the row type
+ * and the index names).
+ * </p>
+ * <p>
+ * As instances of this class are immutable, the return value
+ * is computed just once for each instance and reused
+ * throughout its life.
+ * </p>
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ if (string == null)
+ string = getClass().getName()
+ + "[name=" + getTypeName()
+ + ", rowType=" + rowType
+ + ", indexNames=" + indexNames
+ + "]";
+ return string;
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/package.html b/libjava/classpath/javax/management/openmbean/package.html
new file mode 100644
index 00000000000..d915007d4ce
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/package.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.lang.management package.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.management.openmbean</title></head>
+
+<body>
+
+<p>
+Provides the data types and descriptor classes for the
+<emph>Open MBean</emph>s. Open MBeans are provided in
+order to aid interoperability with non-Java management
+systems. Unlike normal MBeans, which make use of any
+Java data type, Open MBeans use a restricted set of types
+which can then be mapped over remote connections, including
+to non-Java systems.
+</p>
+<p>
+Normal MBeans are described using an instance of
+{@link javax.management.MBeanInfo} with appropriate representations
+of the attributes, constructors and operators associated with
+the bean. Open MBeans are described in the same way, but by
+using subtypes of these entities, which type the bean data using
+instances of {@link javax.management.openmbean.OpenType}. Open
+types differ from Java types, and are explicitly specified in order
+to obtain interoperability with other systems.
+</p>
+</body>
+</html>
diff --git a/libjava/classpath/javax/naming/CompositeName.java b/libjava/classpath/javax/naming/CompositeName.java
index 6f3466ca23c..322f63279a2 100644
--- a/libjava/classpath/javax/naming/CompositeName.java
+++ b/libjava/classpath/javax/naming/CompositeName.java
@@ -47,11 +47,18 @@ import java.util.NoSuchElementException;
import java.util.Vector;
/**
+ * Represents names that may span over several namespaces. For instance,
+ * the composite name http://www.gnu.org/software/classpath/index.html spans
+ * over three namespaces (the protocol http, the web server location
+ * (www.gnu.org) and the index.html location on the server).
+ *
* @author Tom Tromey (tromey@redhat.com)
*/
public class CompositeName implements Name, Cloneable, Serializable
{
private static final long serialVersionUID = 1667768148915813118L;
+
+ private transient Vector elts;
public CompositeName ()
{
@@ -331,6 +338,4 @@ public class CompositeName implements Name, Cloneable, Serializable
for (int i = 0; i < elts.size(); i++)
s.writeObject(elts.get(i));
}
-
- private transient Vector elts;
}
diff --git a/libjava/classpath/javax/naming/CompoundName.java b/libjava/classpath/javax/naming/CompoundName.java
index b23736fa723..556edfc33f2 100644
--- a/libjava/classpath/javax/naming/CompoundName.java
+++ b/libjava/classpath/javax/naming/CompoundName.java
@@ -48,6 +48,10 @@ import java.util.Properties;
import java.util.Vector;
/**
+ * Represents hierarchical names from the single namespace. For instance,
+ * the path /home/audriusa/classpath/file.txt is the compound name, using
+ * the filesystem namespace.
+ *
* @author Tom Tromey (tromey@redhat.com)
* @date May 16, 2001
*
diff --git a/libjava/classpath/javax/naming/Context.java b/libjava/classpath/javax/naming/Context.java
index 9df82c68490..46b540304b4 100644
--- a/libjava/classpath/javax/naming/Context.java
+++ b/libjava/classpath/javax/naming/Context.java
@@ -1,5 +1,5 @@
-/* Context.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* Context.java -- A naming context
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,121 +40,453 @@ package javax.naming;
import java.util.Hashtable;
+import javax.naming.directory.InvalidAttributesException;
+
public interface Context
{
- // Property with name of the inital context factory to use
- String INITIAL_CONTEXT_FACTORY
- = "java.naming.factory.initial";
-
- // Property with colon-separated list of object factories to use.
- String OBJECT_FACTORIES
- = "java.naming.factory.object";
-
- // Property with colon-separated list of state factories to use.
- String STATE_FACTORIES
- = "java.naming.factory.state";
-
- // Property with colon-separated list of package prefixes to use.
- String URL_PKG_PREFIXES
- = "java.naming.factory.url.pkgs";
-
- // Property with URL specifying configuration for the service
- // provider to use.
- String PROVIDER_URL
- = "java.naming.provider.url";
+ /**
+ * Property with name of the inital context factory to use
+ */
+ String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";
+
+ /**
+ * Property with colon-separated list of object factories to use.
+ */
+ String OBJECT_FACTORIES = "java.naming.factory.object";
+
+ /**
+ * Property with colon-separated list of state factories to use.
+ */
+ String STATE_FACTORIES = "java.naming.factory.state";
+
+ /**
+ * Property with colon-separated list of package prefixes to use.
+ */
+ String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs";
+
+ /**
+ * Property with URL specifying configuration for the service provider to use.
+ */
+ String PROVIDER_URL = "java.naming.provider.url";
+
+ /**
+ * Property with the DNS host and domain names to use.
+ */
+ String DNS_URL = "java.naming.dns.url";
+
+ /**
+ * Property with the authoritativeness of the service requested.
+ */
+ String AUTHORITATIVE = "java.naming.authoritative";
+
+ /**
+ * Property with the batch size to use when returning data via the service's
+ * protocol.
+ */
+ String BATCHSIZE = "java.naming.batchsize";
+
+ /**
+ * Property defining how referrals encountered by the service provider are to
+ * be processed.
+ */
+ String REFERRAL = "java.naming.referral";
+
+ /**
+ * Property specifying the security protocol to use.
+ */
+ String SECURITY_PROTOCOL = "java.naming.security.protocol";
+
+ /**
+ * Property specifying the security level to use.
+ */
+ String SECURITY_AUTHENTICATION = "java.naming.security.authentication";
+
+ /**
+ * Property for the identity of the principal for authenticating the caller to
+ * the service.
+ */
+ String SECURITY_PRINCIPAL = "java.naming.security.principal";
+
+ /**
+ * Property specifying the credentials of the principal for authenticating the
+ * caller to the service.
+ */
+ String SECURITY_CREDENTIALS = "java.naming.security.credentials";
+
+ /**
+ * Property for specifying the preferred language to use with the service.
+ */
+ String LANGUAGE = "java.naming.language";
+
+ /**
+ * Property for the initial context constructor to use when searching for
+ * other properties.
+ */
+ String APPLET = "java.naming.applet";
+
+ /**
+ * Give the specified name for the specified object. The passed name must not
+ * be already bound to some other object.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws NameAlreadyBoundException if this name is already used to name some
+ * object.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void bind(Name name, Object obj) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. The passed name must not
+ * be already bound to some other object.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws NameAlreadyBoundException if this name is already used to name some
+ * object.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void bind(String name, Object obj) throws NamingException;
+
+ /**
+ * Gets the previously named object by name. If the passed name is empty, the
+ * method should return a cloned instance of this naming context.
+ *
+ * @param name the name of the object being searched in this context
+ * @return the named object
+ * @throws NamingException if the naming fails.
+ */
+ Object lookup(Name name) throws NamingException;
+
+ /**
+ * Gets the previously named object by name. If the passed name is empty, the
+ * method should return a cloned instance of this naming context.
+ *
+ * @param name the name of the object being searched in this context
+ * @return the named object
+ * @throws NamingException if the naming fails.
+ */
+ Object lookup(String name) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. Unlike bind, this method
+ * silently replaces the existing binding for this name, if one exists.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rebind(Name name, Object obj) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. Unlike bind, this method
+ * silently replaces the existing binding for this name, if one exists.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rebind(String name, Object obj) throws NamingException;
+
+ /**
+ * Removes the name - object mapping from the current context. This method
+ * returns without action if the name is not bound to an object in the
+ * terminal context, but throws {@link NameNotFoundException} if one of the
+ * intermadiate contexts does not exist.
+ *
+ * @param name the name to be removed
+ * @throws NameNotFoundException if one of the intermediate naming contexts
+ * does not exist. Will not be thrown if just the terminal binding
+ * is missing.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void unbind(Name name) throws NamingException;
+
+ /**
+ * Removes the name - object mapping from the current context. This method
+ * returns without action if the name is not bound to an object in the
+ * terminal context, but throws {@link NameNotFoundException} if one of the
+ * intermadiate contexts does not exist.
+ *
+ * @param name the name to be removed
+ * @throws NameNotFoundException if one of the intermediate naming contexts
+ * does not exist. Will not be thrown if just the terminal binding
+ * is missing.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void unbind(String name) throws NamingException;
+
+ /**
+ * Renames the existing binding, removing the existing and giving the new name
+ * for the same object.
+ *
+ * @param oldName the existing name of the known object
+ * @param newName the new name of the same object
+ * @throws NameNotFoundException if the oldName is unknown for this context
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rename(Name oldName, Name newName) throws NamingException;
+
+ /**
+ * Renames the existing binding, removing the existing and giving the new name
+ * for the same object.
+ *
+ * @param oldName the existing name of the known object
+ * @param newName the new name of the same object
+ * @throws NameNotFoundException if the oldName is unknown for this context
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rename(String oldName, String newName) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name bindings that are present
+ * the given subcontext. The enumeration elements have the type of
+ * {@link NameClassPair}, providing also information about the class of the
+ * bound object. The behaviour in the case if the bindings are added or
+ * removed later is not defined. The contents of the subcontexts are not
+ * included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration list(Name name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name bindings that are present
+ * the given subcontext. The enumeration elements have the type of
+ * {@link NameClassPair}, providing also information about the class of the
+ * bound object. The behaviour in the case if the bindings are added or
+ * removed later is not defined. The contents of the subcontexts are not
+ * included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration list(String name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name - object bindings that
+ * are present the given subcontext. The enumeration elements have the type of
+ * {@link Binding}, providing also information about the class of the bound
+ * object. The behaviour in the case if the bindings are added or removed
+ * later is not defined. The contents of the subcontexts are not included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration listBindings(Name name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name - object bindings that
+ * are present the given subcontext. The enumeration elements have the type of
+ * {@link Binding}, providing also information about the class of the bound
+ * object. The behaviour in the case if the bindings are added or removed
+ * later is not defined. The contents of the subcontexts are not included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration listBindings(String name) throws NamingException;
+
+ /**
+ * Creates the new naming subcontext and binds it to the current (this)
+ * context.
+ *
+ * @param name the name of the new context being created
+ * @return the newly created context, bound to the instance of the context on
+ * that the method has been called
+ * @throws NameAlreadyBoundException if this name is already bound
+ * @throws InvalidAttributesException if the creation of the new context
+ * requires the missing mandatory attributes
+ * @throws NamingException
+ */
+ Context createSubcontext(Name name) throws NamingException;
+
+ /**
+ * Creates the new naming subcontext and binds it to the current (this)
+ * context.
+ *
+ * @param name the name of the new context being created
+ * @return the newly created context, bound to the instance of the context on
+ * that the method has been called
+ * @throws NameAlreadyBoundException if this name is already bound
+ * @throws InvalidAttributesException if the creation of the new context
+ * requires the missing mandatory attributes
+ * @throws NamingException
+ */
+ Context createSubcontext(String name) throws NamingException;
+
+ /**
+ * Removes the naming subcontext from this naming context. Returns without
+ * action if such subcontext does not exist. The context being destroyed must
+ * be empty.
+ *
+ * @param name the name of the subcontext beig removed.
+ * @throws ContextNotEmptyException if the named context is not empty.
+ * @throws NamingException
+ */
+ void destroySubcontext(Name name) throws NamingException;
+
+ /**
+ * Removes the naming subcontext from this naming context. Returns without
+ * action if such subcontext does not exist. The context being destroyed must
+ * be empty.
+ *
+ * @param name the name of the subcontext beig removed.
+ * @throws ContextNotEmptyException if the named context is not empty.
+ * @throws NamingException
+ */
+ void destroySubcontext(String name) throws NamingException;
+
+ /**
+ * Retrieves the named object, not following the link of the terminal atomic
+ * component of the name. If the object, named by the passed name, is not a
+ * link, returns that object itself. The intermediate links, if present, are
+ * followed.
+ *
+ * @param name the name of the object that may be a link, leading to another
+ * object.
+ * @return the named object, not following the terminal link (if present).
+ * @throws NamingException
+ */
+ Object lookupLink(Name name) throws NamingException;
+
+ /**
+ * Retrieves the named object, not following the link of the terminal atomic
+ * component of the name. If the object, named by the passed name, is not a
+ * link, returns that object itself. The intermediate links, if present, are
+ * followed.
+ *
+ * @param name the name of the object that may be a link, leading to another
+ * object.
+ * @return the named object, not following the terminal link (if present).
+ * @throws NamingException
+ */
+ Object lookupLink(String name) throws NamingException;
- // Property with the DNS host and domain names to use.
- String DNS_URL
- = "java.naming.dns.url";
+ /**
+ * Obtains the name parser for parsing the names of the given naming
+ * subcontext.
+ *
+ * @param name the name of the subcontext for that the parser must be obtained
+ * @return the parser to parse the names of that context
+ * @throws NamingException
+ */
+ NameParser getNameParser(Name name) throws NamingException;
+
+ /**
+ * Obtains the name parser for parsing the names of the given naming
+ * subcontext.
+ *
+ * @param name the name of the subcontext for that the parser must be obtained
+ * @return the parser to parse the names of that context
+ * @throws NamingException
+ */
+ NameParser getNameParser(String name) throws NamingException;
- // Property with the authoritativeness of the service requested.
- String AUTHORITATIVE
- = "java.naming.authoritative";
+ /**
+ * Composes the name of this context together with another name, related to
+ * this context.
+ *
+ * @param name a name, defined in the scope of this context
+ * @param prefix a name of this context itself, defined in the scope of some
+ * ancestor
+ * @return the name of the same object as named by the first parameter, but
+ * related to the context of the specified ancestor.
+ * @throws NamingException
+ */
+ Name composeName(Name name, Name prefix) throws NamingException;
+
+ /**
+ * Composes the name of this context together with another name, related to
+ * this context.
+ *
+ * @param name a name, defined in the scope of this context
+ * @param prefix a name of this context itself, defined in the scope of some
+ * ancestor
+ * @return the name of the same object as named by the first parameter, but
+ * related to the context of the specified ancestor.
+ * @throws NamingException
+ */
+ String composeName(String name, String prefix) throws NamingException;
- // Property with the batch size to use when returning data via the
- // service's protocol.
- String BATCHSIZE
- = "java.naming.batchsize";
+ /**
+ * Add new environment property to the environment of this context. Both name
+ * and value of the new property must not be null. If the property is already
+ * defined, is current value is replaced by the propVal.
+ *
+ * @param propName the name of the new property
+ * @param propVal the value of the new property
+ * @return the previous value of this property or null if the property has not
+ * been previously defined
+ * @throws NamingException
+ */
+ Object addToEnvironment(String propName, Object propVal)
+ throws NamingException;
- // Property defining how referrals encountered by the service
- // provider are to be processed.
- String REFERRAL
- = "java.naming.referral";
-
- // Property specifying the security protocol to use.
- String SECURITY_PROTOCOL
- = "java.naming.security.protocol";
-
- // Property specifying the security level to use.
- String SECURITY_AUTHENTICATION
- = "java.naming.security.authentication";
-
- // Property for the identity of the principal for authenticating
- // the caller to the service.
- String SECURITY_PRINCIPAL
- = "java.naming.security.principal";
-
- // Property specifying the credentials of the principal for
- // authenticating the caller to the service.
- String SECURITY_CREDENTIALS
- = "java.naming.security.credentials";
-
- // Property for specifying the preferred language to use with the
- // service.
- String LANGUAGE
- = "java.naming.language";
-
- // Property for the initial context constructor to use when searching
- // for other properties.
- String APPLET
- = "java.naming.applet";
-
- void bind (Name name, Object obj) throws NamingException;
- void bind (String name, Object obj) throws NamingException;
-
- Object lookup (Name name) throws NamingException;
- Object lookup (String name) throws NamingException;
-
- void rebind (Name name, Object obj) throws NamingException;
- void rebind (String name, Object obj) throws NamingException;
-
- void unbind (Name name) throws NamingException;
- void unbind (String name) throws NamingException;
-
- void rename (Name oldName, Name newName) throws NamingException;
- void rename (String oldName, String newName) throws NamingException;
-
- NamingEnumeration list (Name name) throws NamingException;
- NamingEnumeration list (String name) throws NamingException;
-
- NamingEnumeration listBindings (Name name) throws NamingException;
- NamingEnumeration listBindings (String name) throws NamingException;
-
- void destroySubcontext (Name name) throws NamingException;
- void destroySubcontext (String name) throws NamingException;
-
- Context createSubcontext (Name name) throws NamingException;
- Context createSubcontext (String name) throws NamingException;
-
- Object lookupLink (Name name) throws NamingException;
- Object lookupLink (String name) throws NamingException;
-
- NameParser getNameParser (Name name) throws NamingException;
- NameParser getNameParser (String name) throws NamingException;
-
- Name composeName (Name name, Name prefix) throws NamingException;
- String composeName (String name,
- String prefix) throws NamingException;
-
- Object addToEnvironment (String propName,
- Object propVal) throws NamingException;
-
- Object removeFromEnvironment (String propName) throws NamingException;
-
- Hashtable getEnvironment () throws NamingException;
-
- void close () throws NamingException;
-
- String getNameInNamespace () throws NamingException;
+ /**
+ * Removes the property with the given name from the environment. Returns
+ * without action if this property is not defined.
+ *
+ * @param propName the name of the property being removed.
+ * @return the value of the property that has been removed or null if the
+ * property was not defined.
+ * @throws NamingException
+ */
+ Object removeFromEnvironment(String propName) throws NamingException;
+
+ /**
+ * Returns the environment, associated with this naming context. The returned
+ * table should never be modified by the caller. Use {@link #addToEnvironment}
+ * and {@link #removeFromEnvironment} to modify the environement, if needed.
+ *
+ * @return the table, representing the environment of this context
+ * @throws NamingException
+ */
+ Hashtable getEnvironment() throws NamingException;
+
+ /**
+ * Releases all resources, associated with this context. The close() method
+ * can be called several times, but after it has been once invoked, it is not
+ * allowed to call any other method of this context,
+ *
+ * @throws NamingException
+ */
+ void close() throws NamingException;
+
+ /**
+ * Returs the full name of this naming context. The returned string is not a
+ * JNDI composite name and should not be passed directly to the methods of the
+ * naming context.
+ *
+ * @return the full name of this naming context, in its own namespace.
+ * @throws OperationNotSupportedException if the naming system, represented by
+ * this context, does not support the notation of the full name.
+ * @throws NamingException
+ */
+ String getNameInNamespace() throws NamingException;
}
-
diff --git a/libjava/classpath/javax/naming/ContextNotEmptyException.java b/libjava/classpath/javax/naming/ContextNotEmptyException.java
index acbd46bffc4..e856341c1a8 100644
--- a/libjava/classpath/javax/naming/ContextNotEmptyException.java
+++ b/libjava/classpath/javax/naming/ContextNotEmptyException.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * This exception is thrown in response to the attempt to destroy the non
+ * empty context. Only empty contexts (without bindings) can be destroyed.
+ *
+ * @see Context#destroySubcontext
+ */
public class ContextNotEmptyException extends NamingException
{
private static final long serialVersionUID = 1090963683348219877L;
diff --git a/libjava/classpath/javax/naming/InitialContext.java b/libjava/classpath/javax/naming/InitialContext.java
index 1a9ee5a2738..d4a9587f21c 100644
--- a/libjava/classpath/javax/naming/InitialContext.java
+++ b/libjava/classpath/javax/naming/InitialContext.java
@@ -1,5 +1,5 @@
-/* InitialContext.java --
- Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* InitialContext.java -- Initial naming context.
+ Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,170 +43,291 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.spi.NamingManager;
+/**
+ * The starting context for performing naming operations. All naming operations
+ * are performed in the scope of some context. The initial context is the
+ * starting point for the name resolution.
+ */
public class InitialContext implements Context
{
+ /**
+ * Contains the default initial context. This value is returned by
+ * {@link NamingManager#getInitialContext}. It is set by this method
+ * when calling it first time. The subsequent calls return the value of
+ * this field.
+ */
protected Context defaultInitCtx;
+
+ /**
+ * Indicates if the initial context was obtained by calling
+ * {@link NamingManager#getInitialContext}.
+ */
protected boolean gotDefault = false;
+
+ /**
+ * The environment, associated with this initial context.
+ */
protected Hashtable myProps;
- public InitialContext (Hashtable environment)
- throws NamingException
+ /**
+ * The list of the properties, to that the second alternative value must
+ * be appended after the colon to the first possible value. Used in
+ * {@link #merge(Hashtable, Hashtable)}
+ */
+ static final HashSet colon_list;
+ static
+ {
+ colon_list = new HashSet();
+ colon_list.add(Context.OBJECT_FACTORIES);
+ colon_list.add(Context.URL_PKG_PREFIXES);
+ colon_list.add(Context.STATE_FACTORIES);
+ };
+
+ /**
+ * The properties that are searched in the agreed places in the
+ * {@link #init(Hashtable)} method.
+ */
+ static final String[] use_properties =
+ {
+ Context.DNS_URL,
+ Context.INITIAL_CONTEXT_FACTORY,
+ Context.OBJECT_FACTORIES,
+ Context.PROVIDER_URL,
+ Context.STATE_FACTORIES,
+ Context.URL_PKG_PREFIXES,
+ };
+
+
+ /**
+ * Creates the new initial context with the given properties.
+ *
+ * @param environment the properties, used by the initial context being
+ * created.
+ * @throws NamingException
+ */
+ public InitialContext(Hashtable environment) throws NamingException
{
- init (environment);
+ init(environment);
}
- protected InitialContext (boolean lazy)
- throws NamingException
+ /**
+ * Creates the initial context with the possibility to delay its
+ * initialisation.
+ *
+ * @param lazy specified if the initialization should not be performed by this
+ * constructor (true). If the valueis false, it works the same way as
+ * the parameterless constructor.
+ * @throws NamingException
+ */
+ protected InitialContext(boolean lazy) throws NamingException
{
if (! lazy)
- init (null);
+ init(null);
}
- public InitialContext ()
- throws NamingException
+ /**
+ * Creates teh new initial context with no properties. Same as
+ * InitialContext(null).
+ *
+ * @throws NamingException
+ */
+ public InitialContext() throws NamingException
{
- init (null);
+ init(null);
}
- /** @since 1.3 */
- protected void init (Hashtable environment)
- throws NamingException
- {
- // FIXME: Is this enough?
- final String[] properties = {
- Context.DNS_URL,
- Context.INITIAL_CONTEXT_FACTORY,
- Context.OBJECT_FACTORIES,
- Context.PROVIDER_URL,
- Context.STATE_FACTORIES,
- Context.URL_PKG_PREFIXES,
- };
-
- // Create myProps, cloning environment if needed.
+ /**
+ * <p>
+ * Initialises the context, using the properties, specified in the passed
+ * table.
+ * </p>
+ * The missing properties are additionally obtained (in order) from the
+ * following locations:
+ * <ul>
+ * <li>If the passed parameter contains the key Context.APPLET, its value
+ * must be the instance of the {@link Applet}. Then the properties are
+ * requested via {@link Applet#getParameter(String)}.</li>
+ * <li>The value of the system property is used.</li>
+ * <li>The resource "jndi.properties" is requested from the context class
+ * loader of the current thread</li>
+ * <li>The property file "jndi.properties" is read from the location,
+ * specified by the system property "gnu.classpath.home.url".
+ * </ul>
+ * </p>
+ *
+ * @param environment the table of the properties, may be null. The method
+ * modifies the table and stores the reference to it. The caller must
+ * not later reuse this structure for other purposes.
+ * @since 1.3
+ */
+ protected void init(Hashtable environment) throws NamingException
+ {
+ // If is documented that the caller should not modify the environment.
if (environment != null)
- myProps = (Hashtable) environment.clone ();
+ myProps = environment;
else
- myProps = new Hashtable ();
-
- Applet napplet = (Applet) myProps.get (Context.APPLET);
-
- for (int i = properties.length - 1; i >= 0; i--)
+ myProps = new Hashtable();
+
+ Applet napplet = (Applet) myProps.get(Context.APPLET);
+
+ Properties pApplet = null;
+ if (napplet != null)
+ pApplet = new Properties();
+ Properties pSystem = new Properties();
+ Object value;
+
+ for (int i = use_properties.length - 1; i >= 0; i--)
{
- Object o = myProps.get (properties[i]);
-
- if (o == null)
- {
- if (napplet != null)
- o = napplet.getParameter (properties[i]);
- if (o == null)
- o = System.getProperty (properties[i]);
- if (o != null)
- myProps.put (properties[i], o);
- }
+ String key = use_properties[i];
+ if (napplet != null)
+ {
+ value = napplet.getParameter(key);
+ if (value != null)
+ pApplet.put(key, value);
+ }
+
+ value = System.getProperty(key);
+ if (value != null)
+ pSystem.put(key, value);
}
+
+ merge(myProps, pSystem);
+ if (pApplet != null)
+ merge(myProps, pApplet);
try
{
- Enumeration ep = Thread.currentThread().getContextClassLoader().getResources("jndi.naming");
- while (ep.hasMoreElements ())
- {
- URL url = (URL) ep.nextElement ();
- Properties p = new Properties ();
-
- try
- {
- InputStream is = url.openStream ();
- p.load (is);
- is.close ();
- }
- catch (IOException e)
- {
- }
-
- merge (myProps, p);
- }
+ Enumeration ep = Thread.currentThread().
+ getContextClassLoader().getResources("jndi.properties");
+ while (ep.hasMoreElements())
+ {
+ URL url = (URL) ep.nextElement();
+ Properties p = new Properties();
+
+ try
+ {
+ InputStream is = url.openStream();
+ p.load(is);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // Ignore.
+ }
+
+ merge(myProps, p);
+ }
}
catch (IOException e)
{
+ // Ignore.
}
String home = System.getProperty("gnu.classpath.home.url");
if (home != null)
{
- String url = home + "/jndi.properties";
- Properties p = new Properties ();
-
- try
- {
- InputStream is = new URL(url).openStream();
- p.load (is);
- is.close ();
- }
- catch (IOException e)
- {
- // Ignore.
- }
-
- merge (myProps, p);
+ String url = home + "/jndi.properties";
+ Properties p = new Properties();
+
+ try
+ {
+ InputStream is = new URL(url).openStream();
+ p.load(is);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // Ignore.
+ }
+
+ merge(myProps, p);
}
}
-
- // FIXME: Is this enough?
- private static final String[] colon_list =
- {
- Context.OBJECT_FACTORIES,
- Context.URL_PKG_PREFIXES,
- Context.STATE_FACTORIES
- };
-
- private static void merge (Hashtable h1, Hashtable h2)
- {
- Enumeration e2 = h2.keys();
+
+ /**
+ * Merge the content of the two tables. If the second table contains the key
+ * that is missing in the first table, this key - value pair is copied to the
+ * first table. If both first and second tables contain the same key AND the
+ * {@link #colon_list} set also contains this key, the value from the second
+ * table is appended to the value from the first table after semicolon, and
+ * the resulted value replaces the value in the first table.
+ *
+ * @param primary the first table to merge. The merged result is also stored
+ * in this table.
+ * @param additional the second table, from where additional values are taken
+ */
+ static void merge (Hashtable primary, Hashtable additional)
+ {
+ Enumeration en = additional.keys();
- while (e2.hasMoreElements())
+ while (en.hasMoreElements())
{
- String key2 = (String) e2.nextElement();
- Object value1 = h1.get(key2);
- if (value1 == null)
- h1.put(key2, h2.get(key2));
- else if (key2.compareTo(colon_list[0]) == 0
- || key2.compareTo(colon_list[1]) == 0
- || key2.compareTo(colon_list[2]) == 0
- || key2.compareTo(colon_list[3]) == 0)
- {
- String value2 = (String) h2.get(key2);
- h1.put(key2, (String) value1 + ":" + value2);
- }
+ String key2 = (String) en.nextElement();
+ Object value1 = primary.get(key2);
+ if (value1 == null)
+ primary.put(key2, additional.get(key2));
+ else if (colon_list.contains(key2))
+ {
+ String value2 = (String) additional.get(key2);
+ primary.put(key2, (String) value1 + ":" + value2);
+ }
}
}
-
- protected Context getDefaultInitCtx () throws NamingException
+
+ /**
+ * Get the default initial context. If {@link #gotDefault} == false, this
+ * method obtains the initial context from the naming manager and sets
+ * gotDefault to true. Otherwise the cached value ({@link #defaultInitCtx} is
+ * returned.
+ *
+ * @return the default initial context
+ * @throws NamingException
+ */
+ protected Context getDefaultInitCtx() throws NamingException
{
if (! gotDefault)
{
- defaultInitCtx = NamingManager.getInitialContext (myProps);
- gotDefault = true;
+ defaultInitCtx = NamingManager.getInitialContext(myProps);
+ gotDefault = true;
}
return defaultInitCtx;
}
-
- protected Context getURLOrDefaultInitCtx (Name name)
- throws NamingException
- {
- if (name.size () > 0)
- return getURLOrDefaultInitCtx (name.get (0));
+ /**
+ * Obtains the context for resolving the given name. If the first component of
+ * the name is the URL string, this method tries to find the corressponding
+ * URL naming context. If it is not an URL string, or the URL context is not
+ * found, the default initial context is returned.
+ *
+ * @param name the name, for that it is required to obtain the context.
+ * @return the context for resolving the name.
+ * @throws NamingException
+ */
+ protected Context getURLOrDefaultInitCtx(Name name) throws NamingException
+ {
+ if (name.size() > 0)
+ return getURLOrDefaultInitCtx(name.get(0));
else
- return getDefaultInitCtx ();
+ return getDefaultInitCtx();
}
- protected Context getURLOrDefaultInitCtx (String name)
- throws NamingException
+ /**
+ * Obtains the context for resolving the given name. If the first component of
+ * the name is the URL string, this method tries to find the corressponding
+ * URL naming context. If it is not an URL string, or the URL context is not
+ * found, the default initial context is returned.
+ *
+ * @param name the name, for that it is required to obtain the context.
+ * @return the context for resolving the name.
+ * @throws NamingException
+ */
+ protected Context getURLOrDefaultInitCtx(String name) throws NamingException
{
String scheme = null;
@@ -214,178 +335,211 @@ public class InitialContext implements Context
return getDefaultInitCtx();
int colon = name.indexOf(':');
int slash = name.indexOf('/');
- if (colon > 0 && (slash == -1 || colon < slash))
+ if (colon > 0 && (slash == - 1 || colon < slash))
scheme = name.substring(0, colon);
- if (scheme != null)
+ if (scheme != null)
{
- Context context =
- NamingManager.getURLContext(scheme, myProps);
- if (context != null)
- return context;
+ Context context = NamingManager.getURLContext(scheme, myProps);
+ if (context != null)
+ return context;
}
-
+
return getDefaultInitCtx();
}
+ /** @inheritDoc */
public void bind (Name name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).bind (name, obj);
}
+ /** @inheritDoc */
public void bind (String name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).bind (name, obj);
}
+ /** @inheritDoc */
public Object lookup (Name name) throws NamingException
{
try
{
- return getURLOrDefaultInitCtx (name).lookup (name);
+ return getURLOrDefaultInitCtx (name).lookup (name);
}
catch (CannotProceedException cpe)
{
- Context ctx = NamingManager.getContinuationContext (cpe);
- return ctx.lookup (cpe.getRemainingName());
+ Context ctx = NamingManager.getContinuationContext (cpe);
+ return ctx.lookup (cpe.getRemainingName());
}
}
+ /** @inheritDoc */
public Object lookup (String name) throws NamingException
{
try
- {
- return getURLOrDefaultInitCtx (name).lookup (name);
- }
+ {
+ return getURLOrDefaultInitCtx (name).lookup (name);
+ }
catch (CannotProceedException cpe)
- {
- Context ctx = NamingManager.getContinuationContext (cpe);
- return ctx.lookup (cpe.getRemainingName());
- }
+ {
+ Context ctx = NamingManager.getContinuationContext (cpe);
+ return ctx.lookup (cpe.getRemainingName());
+ }
}
+ /** @inheritDoc */
public void rebind (Name name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).rebind (name, obj);
}
-
+
+ /** @inheritDoc */
public void rebind (String name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).rebind (name, obj);
}
+ /** @inheritDoc */
public void unbind (Name name) throws NamingException
{
getURLOrDefaultInitCtx (name).unbind (name);
}
+ /** @inheritDoc */
public void unbind (String name) throws NamingException
{
getURLOrDefaultInitCtx (name).unbind (name);
}
+ /** @inheritDoc */
public void rename (Name oldName, Name newName) throws NamingException
{
getURLOrDefaultInitCtx (oldName).rename (oldName, newName);
}
+ /** @inheritDoc */
public void rename (String oldName, String newName) throws NamingException
{
getURLOrDefaultInitCtx (oldName).rename (oldName, newName);
}
+ /** @inheritDoc */
public NamingEnumeration list (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).list (name);
}
+ /** @inheritDoc */
public NamingEnumeration list (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).list (name);
}
+ /** @inheritDoc */
public NamingEnumeration listBindings (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).listBindings (name);
}
+ /** @inheritDoc */
public NamingEnumeration listBindings (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).listBindings (name);
}
+ /** @inheritDoc */
public void destroySubcontext (Name name) throws NamingException
{
getURLOrDefaultInitCtx (name).destroySubcontext (name);
}
+ /** @inheritDoc */
public void destroySubcontext (String name) throws NamingException
{
getURLOrDefaultInitCtx (name).destroySubcontext (name);
}
+ /** @inheritDoc */
public Context createSubcontext (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).createSubcontext (name);
}
+ /** @inheritDoc */
public Context createSubcontext (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).createSubcontext (name);
}
+ /** @inheritDoc */
public Object lookupLink (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).lookupLink (name);
}
+ /** @inheritDoc */
public Object lookupLink (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).lookupLink (name);
}
+ /** @inheritDoc */
public NameParser getNameParser (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).getNameParser (name);
}
+ /** @inheritDoc */
public NameParser getNameParser (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).getNameParser (name);
}
+ /** @inheritDoc */
public Name composeName (Name name, Name prefix) throws NamingException
{
return getURLOrDefaultInitCtx (name).composeName (name, prefix);
}
+ /** @inheritDoc */
public String composeName (String name,
- String prefix) throws NamingException
+ String prefix) throws NamingException
{
return getURLOrDefaultInitCtx (name).composeName (name, prefix);
}
-
+
+ /** @inheritDoc */
public Object addToEnvironment (String propName,
- Object propVal) throws NamingException
+ Object propVal) throws NamingException
{
return myProps.put (propName, propVal);
}
+ /** @inheritDoc */
public Object removeFromEnvironment (String propName) throws NamingException
{
return myProps.remove (propName);
}
+ /** @inheritDoc */
public Hashtable getEnvironment () throws NamingException
{
return myProps;
}
+ /** @inheritDoc */
public void close () throws NamingException
{
myProps = null;
defaultInitCtx = null;
}
+ /**
+ * This operation is not supported for the initial naming context.
+ *
+ * @throws OperationNotSupportedException always, unless the method is
+ * overridden in the derived class.
+ */
public String getNameInNamespace () throws NamingException
{
throw new OperationNotSupportedException ();
diff --git a/libjava/classpath/javax/naming/NameParser.java b/libjava/classpath/javax/naming/NameParser.java
index 1aeaf3600c4..004b406274f 100644
--- a/libjava/classpath/javax/naming/NameParser.java
+++ b/libjava/classpath/javax/naming/NameParser.java
@@ -1,5 +1,5 @@
-/* NameParser.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* NameParser.java -- JNDI name parser interface
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,24 @@ exception statement from your version. */
package javax.naming;
+/**
+ * Parser the string representation of the given name into the {@link Name}
+ * representation.
+ *
+ * @see Context#getNameParser(String)
+ * @see Context#getNameParser(Name)
+ */
public interface NameParser
-{
+{
+ /**
+ * Parser the string name representation into the {@link Name} representation
+ *
+ * @param name the string representation of the name
+ * @return the {@link Name} representation of the name.
+ * @throws InvalidNameException if the name violates the syntax, expected by
+ * this parser
+ * @throws NamingException if some other naming exception occurs
+ */
Name parse (String name) throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/NamingEnumeration.java b/libjava/classpath/javax/naming/NamingEnumeration.java
index 3c9ee2d011d..86b1dfb414d 100644
--- a/libjava/classpath/javax/naming/NamingEnumeration.java
+++ b/libjava/classpath/javax/naming/NamingEnumeration.java
@@ -1,5 +1,5 @@
-/* NamingEnumeration.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* NamingEnumeration.java -- The JNDI enumeration
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,50 @@ package javax.naming;
import java.util.Enumeration;
+/**
+ * <p>The specific type of enumeration that supports throwing various exceptions by
+ * the hasMore method. The exceptions are only thrown if the enumeration is
+ * scanned using {@link #next()} and {@link #hasMore()}. If the inherited
+ * {@link java.util.Enumeration#nextElement()} and
+ * {@link Enumeration#hasMoreElements()} are used instead, the exceptions are
+ * not throwed, and the enumeration is just iterated over available elements.
+ * </p>
+ * <p>This enumeration becomes invalid after throwing the exception. If the
+ * exception has been thrown, not other method should be called of that
+ * enumeration.</p>
+ */
public interface NamingEnumeration extends Enumeration
{
- void close() throws NamingException;
- boolean hasMore() throws NamingException;
+ /**
+ * Returns the next element in this enumeration. The naming - specific
+ * exceptions are only throws after returning all still available elements of
+ * the enumeration.
+ *
+ * @return the next element of this enumeration
+ * @throws NamingException
+ */
Object next() throws NamingException;
+
+ /**
+ * Checks if there are more unvisited elements in the enumeration, throwing
+ * exceptions if there are some unvisited, but not available elements.
+ *
+ * @return true if there are some unvisited elements, false otherwise.
+ * @throws PartialResultException if the enumeration, returned by the
+ * {@link Context#list(Name)} or other similar method contains only
+ * partial answer.
+ * @throws SizeLimitExceededException if remaining elements are not available
+ * because of the previously specified size limit.
+ * @throws NamingException
+ */
+ boolean hasMore() throws NamingException;
+
+ /**
+ * Immediately frees all resources, owned by this enumeration. If invoked, it
+ * must be the last method called for that enumeration.
+ *
+ * @throws NamingException
+ */
+ void close() throws NamingException;
+
}
diff --git a/libjava/classpath/javax/naming/PartialResultException.java b/libjava/classpath/javax/naming/PartialResultException.java
index 61660781f68..28f0467fe57 100644
--- a/libjava/classpath/javax/naming/PartialResultException.java
+++ b/libjava/classpath/javax/naming/PartialResultException.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * Thrown from the {@link javax.naming.NamingEnumeration}, this exception
+ * indicates that the enumeration represents only part of the existing
+ * elements that would be an answer to the specified request.
+ */
public class PartialResultException extends NamingException
{
private static final long serialVersionUID = 2572144970049426786L;
diff --git a/libjava/classpath/javax/naming/Reference.java b/libjava/classpath/javax/naming/Reference.java
index 5b9883aecd4..0fdecc19ec7 100644
--- a/libjava/classpath/javax/naming/Reference.java
+++ b/libjava/classpath/javax/naming/Reference.java
@@ -43,54 +43,118 @@ import java.util.Enumeration;
import java.util.Vector;
/**
+ * This class represents a reference to an object that is located outside of the
+ * naming/directory system.
+ *
+ * @see Referenceable
+ *
* @author Tom Tromey (tromey@redhat.com)
- * @date May 16, 2001
*/
public class Reference implements Cloneable, Serializable
{
private static final long serialVersionUID = - 1673475790065791735L;
-
+
+ /**
+ * The list of addresses, stored in this reference. The object may be
+ * have by several different addresses.
+ */
+ protected Vector addrs;
+
+ /**
+ * The name of the class factory to create an instance of the object,
+ * referenced by this reference.
+ */
+ protected String classFactory;
+
+ /**
+ * The location, from where the class factory should be loaded.
+ */
+ protected String classFactoryLocation;
+
+ /**
+ * The name of the class of the object, to that this reference refers.
+ */
+ protected String className;
+
+ /**
+ * Create a new reference that is referencting to the object of the
+ * specified class.
+ */
public Reference (String className)
{
this.className = className;
addrs = new Vector ();
}
-
+
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class with the given address.
+ */
public Reference (String className, RefAddr addr)
{
this.className = className;
addrs = new Vector ();
addrs.add (addr);
}
-
- public Reference (String className, String factory, String factoryLocation)
+
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class, specifying the class and location of the factory that
+ * produces these objects.
+ *
+ * @param className the object class name
+ * @param factoryClassName the object factory class name
+ * @param factoryLocation the object factory location
+ */
+ public Reference (String className, String factoryClassName,
+ String factoryLocation)
{
this.className = className;
- this.classFactory = factory;
+ this.classFactory = factoryClassName;
this.classFactoryLocation = factoryLocation;
addrs = new Vector ();
}
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class, specifying the class and location of the factory that
+ * produces these objects and also the address of this object.
+ *
+ * @param className the object class name
+ * @param addr the address of the object
+ * @param factoryClassName the object factory class name
+ * @param factoryLocation the object factory location
+ */
public Reference (String className, RefAddr addr,
- String factory, String factoryLocation)
+ String factoryClassName, String factoryLocation)
{
this.className = className;
- this.classFactory = factory;
+ this.classFactory = factoryClassName;
this.classFactoryLocation = factoryLocation;
addrs = new Vector ();
addrs.add (addr);
}
+ /**
+ * Add the new address for this object at the given position of the
+ * address list.
+ */
public void add (int posn, RefAddr addr)
{
addrs.add (posn, addr);
}
-
+
+ /**
+ * Appends the new object address to the end of the address list.
+ */
public void add (RefAddr addr)
{
addrs.add (addr);
}
-
+
+ /**
+ * Removes all defined addresses of the object.
+ */
public void clear ()
{
addrs.clear ();
@@ -109,7 +173,10 @@ public class Reference implements Cloneable, Serializable
{
return (a == null) ? (b == null) : a.equals (b);
}
-
+
+ /**
+ * Compares two addresses for equality, by value.
+ */
public boolean equals (Object obj)
{
if (! (obj instanceof Reference))
@@ -120,12 +187,23 @@ public class Reference implements Cloneable, Serializable
&& equals (className, r.className)
&& addrs.equals (r.addrs));
}
-
+
+ /**
+ * Get the address of this object at the given position.
+ */
public RefAddr get (int posn)
{
return (RefAddr) addrs.get (posn);
}
-
+
+ /**
+ * Get the given type of address for this object.
+ *
+ * @param addrType the needed type of address
+ *
+ * @return the address of this object, having the specified type. If there
+ * is no address of such type, null is returned.
+ */
public RefAddr get (String addrType)
{
for (int i = 0; i < addrs.size (); ++i)
@@ -136,27 +214,50 @@ public class Reference implements Cloneable, Serializable
}
return null;
}
-
+
+ /**
+ * Get the enumeration over all defined addresses of the object.
+ */
public Enumeration getAll ()
{
return addrs.elements ();
}
-
+
+ /**
+ * Get the name of the class of the referenced object.
+ *
+ * @see #className
+ */
public String getClassName ()
{
return className;
}
-
+
+ /**
+ * Get the location of the factory class of the referenced object.
+ *
+ * @see #classFactoryLocation
+ */
public String getFactoryClassLocation ()
{
return classFactoryLocation;
}
+ /**
+ * Get the name of the factory class of the referenced object
+ *
+ * @see #classFactory
+ */
public String getFactoryClassName ()
{
return classFactory;
}
-
+
+ /**
+ * Get the hashcode of this reference.
+ *
+ * @return the sum of the hash codes of the addresses.
+ */
public int hashCode ()
{
// The spec says the hash code is the sum of the hash codes of the
@@ -166,17 +267,30 @@ public class Reference implements Cloneable, Serializable
h += addrs.get (i).hashCode ();
return h;
}
-
+
+ /**
+ * Remove the address at the given position.
+ *
+ * @param posn the position of the address to remove
+ *
+ * @return the removed address
+ */
public Object remove (int posn)
{
return addrs.remove (posn);
}
-
+
+ /**
+ * Return the number of the defined addresses.
+ */
public int size ()
{
return addrs.size ();
}
-
+
+ /**
+ * Return the string representation.
+ */
public String toString ()
{
String x = getClass ().toString () + "[";
@@ -189,8 +303,4 @@ public class Reference implements Cloneable, Serializable
return x + "]";
}
- protected Vector addrs;
- protected String classFactory;
- protected String classFactoryLocation;
- protected String className;
}
diff --git a/libjava/classpath/javax/naming/Referenceable.java b/libjava/classpath/javax/naming/Referenceable.java
index cf1100aab83..21c5238bc46 100644
--- a/libjava/classpath/javax/naming/Referenceable.java
+++ b/libjava/classpath/javax/naming/Referenceable.java
@@ -1,5 +1,5 @@
/* Referenceable.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,19 @@ exception statement from your version. */
package javax.naming;
+/**
+ * The object, implementing this interface, can provided the
+ * {@link Reference} about itself.
+ */
public interface Referenceable
{
+ /**
+ * Get the reference about this object.
+ *
+ * @return the reference about this object, cannot be null.
+ *
+ * @throws NamingException if the naming exception has been raised while
+ * retrieving the reference.
+ */
Reference getReference() throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/SizeLimitExceededException.java b/libjava/classpath/javax/naming/SizeLimitExceededException.java
index 3ca9a23b7b1..caffa70c3e0 100644
--- a/libjava/classpath/javax/naming/SizeLimitExceededException.java
+++ b/libjava/classpath/javax/naming/SizeLimitExceededException.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * Thrown from the {@link javax.naming.NamingEnumeration}, this exception
+ * indicates that there are more elements than the previously specified
+ * size limit. Hence the enumeration represents only part of the existing
+ * elements that would be an answer to the specified request.
+ */
public class SizeLimitExceededException extends LimitExceededException
{
private static final long serialVersionUID = 7129289564879168579L;
diff --git a/libjava/classpath/javax/naming/spi/InitialContextFactory.java b/libjava/classpath/javax/naming/spi/InitialContextFactory.java
index 7bfcf095e52..d9b3336dcc2 100644
--- a/libjava/classpath/javax/naming/spi/InitialContextFactory.java
+++ b/libjava/classpath/javax/naming/spi/InitialContextFactory.java
@@ -43,7 +43,28 @@ import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
+/**
+ * <p>
+ * Defines a factory that creates the initial context for the beginning of the
+ * name resolution. JNDI allows to specify different implementations of the
+ * initial context at runtime.
+ * </p>
+ * <p>
+ * The class, implementing this interface, must be public and have a public
+ * parameterless constructor
+ * </p>
+ */
public interface InitialContextFactory
{
- Context getInitialContext (Hashtable environment) throws NamingException;
+ /**
+ * Create a new initial context
+ *
+ * @param environment the properties, used when creating the context. The
+ * implementing class will not modify the table nor keep the
+ * reference to it. After the method returns, the caller can safely
+ * reuse the table for other purposes.
+ * @return the new initial context
+ * @throws NamingException if the naming exception has occured
+ */
+ Context getInitialContext(Hashtable environment) throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java b/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java
index 76564ab5ef9..4696cecb8e7 100644
--- a/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java
+++ b/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java
@@ -42,8 +42,25 @@ import java.util.Hashtable;
import javax.naming.NamingException;
+/**
+ * Represents the builder that creates instances of the factories that produce
+ * initial naming contexts. JNDI allows to specifiy different initial contexts
+ * at runtime. The user program can install its own initial context factory
+ * builder.
+ *
+ * @see NamingManager#setInitialContextFactoryBuilder
+ */
public interface InitialContextFactoryBuilder
{
+ /**
+ * Create the new inital context factory
+ *
+ * @param environment the properties, used for creation of the initial context
+ * factory. The parameter is owned by the caller: it is safe to reuse
+ * the table for other purposes after the method returns.
+ * @return the created initial context factory, never null.
+ * @throws NamingException on failure
+ */
InitialContextFactory createInitialContextFactory (Hashtable environment)
throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/spi/NamingManager.java b/libjava/classpath/javax/naming/spi/NamingManager.java
index cfc9dbd5f10..a36d519d75a 100644
--- a/libjava/classpath/javax/naming/spi/NamingManager.java
+++ b/libjava/classpath/javax/naming/spi/NamingManager.java
@@ -1,5 +1,6 @@
-/* NamingManager.java --
- Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* NamingManager.java -- Creates contexts and objects
+ Copyright (C) 2000, 2001, 2002, 2003, 2004,
+ 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +39,8 @@ exception statement from your version. */
package javax.naming.spi;
+import gnu.classpath.VMStackWalker;
+
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
@@ -52,8 +55,19 @@ import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
+/**
+ * Contains methods for creating contexts and objects referred to by
+ * location information. The location is specified in the scope of the
+ * certain naming or directory service. This class only contais static
+ * methods and cannot be instantiated.
+ */
public class NamingManager
{
+ /**
+ * The environment property into which getContinuationContext() stores the
+ * value of the CannotProceedException parameter. The value of this field
+ * is <i>java.naming.spi.CannotProceedException<i>.
+ */
public static final String CPE = "java.naming.spi.CannotProceedException";
private static InitialContextFactoryBuilder icfb;
@@ -65,12 +79,37 @@ public class NamingManager
NamingManager ()
{
}
-
+
+ /**
+ * Checks if the initial context factory builder has been set.
+ *
+ * @return true if the builder has been set
+ *
+ * @see #setInitialContextFactoryBuilder(InitialContextFactoryBuilder)
+ */
public static boolean hasInitialContextFactoryBuilder ()
{
return icfb != null;
}
+ /**
+ * Creates the initial context. If the initial object factory builder has
+ * been set with {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)},
+ * the work is delegated to this builder. Otherwise, the method searches
+ * for the property Context.INITIAL_CONTEXT_FACTORY first in the passed
+ * table and then in the system properties. The value of this property is
+ * uses as a class name to install the context factory. The corresponding
+ * class must exist, be public and have the public parameterless constructor.
+ *
+ * @param environment the properties, used to create the context.
+ *
+ * @return the created context
+ *
+ * @throws NoInitialContextException if the initial builder is not set,
+ * the property Context.INITIAL_CONTEXT_FACTORY is missing of the
+ * class, named by this property, cannot be instantiated.
+ * @throws NamingException if throws by the context factory
+ */
public static Context getInitialContext (Hashtable environment)
throws NamingException
{
@@ -112,77 +151,191 @@ public class NamingManager
return icf.getInitialContext (environment);
}
-
- static Context getURLContext (Object refInfo,
- Name name,
- Context nameCtx,
- String scheme,
- Hashtable environment)
- throws NamingException
+
+ /**
+ * <p>
+ * Creates the URL context for the given URL scheme id.
+ * </p>
+ * <p>
+ * The class name of the factory that creates the context has the naming
+ * pattern scheme-idURLContextFactory. For instance, the factory for the "ftp"
+ * sheme should be named "ftpURLContextFactory".
+ * </p>
+ * <p>
+ * The Context.URL_PKG_PREFIXES environment property contains the
+ * colon-separated list of the possible package prefixes. The package name is
+ * constructed concatenating the package prefix with the scheme id. This
+ * property is searched in the passed <i>environment</i> parameter and later
+ * in the system properties.
+ * </p>
+ * <p>
+ * If the factory class cannot be found in the specified packages, system will
+ * try to use the default internal factory for the given scheme.
+ * </p>
+ * <p>
+ * After the factory is instantiated, its method
+ * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
+ * is called to create and return the object instance.
+ *
+ * @param refInfo passed to the factory
+ * @param name passed to the factory
+ * @param nameCtx passed to the factory
+ * @param scheme the url scheme that must be supported by the given context
+ * @param environment the properties for creating the factory and context (may
+ * be null)
+ * @return the created context
+ * @throws NamingException if thrown by the factory when creating the context.
+ */
+ static Context getURLContext(Object refInfo, Name name, Context nameCtx,
+ String scheme, Hashtable environment)
+ throws NamingException
{
- String prefixes = null;
+ // Specified as the default in the docs. Unclear if this is
+ // right for us.
+ String defaultPrefix = "com.sun.jndi.url";
+
+ StringBuffer allPrefixes = new StringBuffer();
+
+ String prefixes;
if (environment != null)
- prefixes = (String) environment.get (Context.URL_PKG_PREFIXES);
- if (prefixes == null)
- prefixes = System.getProperty (Context.URL_PKG_PREFIXES);
- if (prefixes == null)
{
- // Specified as the default in the docs. Unclear if this is
- // right for us.
- prefixes = "com.sun.jndi.url";
+ prefixes = (String) environment.get(Context.URL_PKG_PREFIXES);
+ if (prefixes != null)
+ allPrefixes.append(prefixes);
+ }
+
+ prefixes = System.getProperty(Context.URL_PKG_PREFIXES);
+ if (prefixes != null)
+ {
+ if (allPrefixes.length() > 0)
+ allPrefixes.append(':');
+ allPrefixes.append(prefixes);
}
+ if (allPrefixes.length() > 0)
+ allPrefixes.append(':');
+ allPrefixes.append(defaultPrefix);
+
scheme = scheme + "." + scheme + "URLContextFactory";
- StringTokenizer tokens = new StringTokenizer (prefixes, ":");
- while (tokens.hasMoreTokens ())
+ StringTokenizer tokens = new StringTokenizer(allPrefixes.toString(), ":");
+ while (tokens.hasMoreTokens())
{
- String aTry = tokens.nextToken ();
- try
- {
- Class factoryClass = Class.forName (aTry + "." + scheme,
- true,
- Thread.currentThread().getContextClassLoader());
- ObjectFactory factory =
- (ObjectFactory) factoryClass.newInstance ();
- Object obj = factory.getObjectInstance (refInfo, name,
- nameCtx, environment);
- Context ctx = (Context) obj;
- if (ctx != null)
- return ctx;
- }
- catch (ClassNotFoundException _1)
- {
- // Ignore it.
- }
- catch (ClassCastException _2)
- {
- // This means that the class we found was not an
- // ObjectFactory or that the factory returned something
- // which was not a Context.
- }
- catch (InstantiationException _3)
- {
- // If we couldn't instantiate the factory we might get
- // this.
- }
- catch (IllegalAccessException _4)
- {
- // Another possibility when instantiating.
- }
- catch (NamingException _5)
- {
- throw _5;
- }
- catch (Exception _6)
- {
- // Anything from getObjectInstance.
- }
+ String aTry = tokens.nextToken();
+ try
+ {
+ String tryClass = aTry + "." + scheme;
+ Class factoryClass = forName(tryClass);
+ if (factoryClass != null)
+ {
+ ObjectFactory factory = (ObjectFactory) factoryClass.newInstance();
+ Object obj = factory.getObjectInstance(refInfo, name, nameCtx,
+ environment);
+ Context ctx = (Context) obj;
+ if (ctx != null)
+ return ctx;
+ }
+ }
+ catch (ClassNotFoundException _1)
+ {
+ // Ignore it.
+ }
+ catch (ClassCastException _2)
+ {
+ // This means that the class we found was not an
+ // ObjectFactory or that the factory returned something
+ // which was not a Context.
+ }
+ catch (InstantiationException _3)
+ {
+ // If we couldn't instantiate the factory we might get
+ // this.
+ }
+ catch (IllegalAccessException _4)
+ {
+ // Another possibility when instantiating.
+ }
+ catch (NamingException _5)
+ {
+ throw _5;
+ }
+ catch (Exception _6)
+ {
+ // Anything from getObjectInstance.
+ }
}
return null;
}
-
+
+ /**
+ * Load the class with the given name. This method tries to use the context
+ * class loader first. If this fails, it searches for the suitable class
+ * loader in the caller stack trace. This method is a central point where all
+ * requests to find a class by name are delegated.
+ */
+ static Class forName(String className)
+ {
+ try
+ {
+ return Class.forName(className, true,
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException nex)
+ {
+ /**
+ * Returns the first user defined class loader on the call stack, or
+ * null when no non-null class loader was found.
+ */
+ Class[] ctx = VMStackWalker.getClassContext();
+ for (int i = 0; i < ctx.length; i++)
+ {
+ // Since we live in a class loaded by the bootstrap
+ // class loader, getClassLoader is safe to call without
+ // needing to be wrapped in a privileged action.
+ ClassLoader cl = ctx[i].getClassLoader();
+ try
+ {
+ if (cl != null)
+ return Class.forName(className, true, cl);
+ }
+ catch (ClassNotFoundException nex2)
+ {
+ // Try next.
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * <p>
+ * Creates the URL context for the given URL scheme id.
+ * </p>
+ * <p>
+ * The class name of the factory that creates the context has the naming
+ * pattern scheme-idURLContextFactory. For instance, the factory for the "ftp"
+ * sheme should be named "ftpURLContextFactory". The Context.URL_PKG_PREFIXES
+ * environment property contains the colon-separated list of the possible
+ * package prefixes. The package name is constructed concatenating the package
+ * prefix with the scheme id.
+ * </p>
+ * <p>
+ * If the factory class cannot be found in the specified packages, system will
+ * try to use the default internal factory for the given scheme.
+ * </p>
+ * <p>
+ * After the factory is instantiated, its method
+ * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
+ * is called to create and return the object instance.
+ *
+ * @param scheme the url scheme that must be supported by the given context
+ * @param environment the properties for creating the factory and context (may
+ * be null)
+ * @return the created context
+ * @throws NamingException if thrown by the factory when creating the context.
+ */
public static Context getURLContext (String scheme,
Hashtable environment)
throws NamingException
@@ -190,6 +343,17 @@ public class NamingManager
return getURLContext (null, null, null, scheme, environment);
}
+ /**
+ * Sets the initial object factory builder.
+ *
+ * @param builder the builder to set
+ *
+ * @throws SecurityException if the builder cannot be installed due
+ * security restrictions.
+ * @throws NamingException if the builder cannot be installed due other
+ * reasons
+ * @throws IllegalStateException if setting the builder repeatedly
+ */
public static void setObjectFactoryBuilder (ObjectFactoryBuilder builder)
throws NamingException
{
@@ -198,7 +362,7 @@ public class NamingManager
sm.checkSetFactory ();
// Once the builder is installed it cannot be replaced.
if (ofb != null)
- throw new IllegalStateException ("builder already installed");
+ throw new IllegalStateException ("object factory builder already installed");
if (builder != null)
ofb = builder;
}
@@ -217,7 +381,58 @@ public class NamingManager
path += ":" + path2;
return new StringTokenizer (path != null ? path : "", ":");
}
-
+
+ /**
+ * <p>Creates an object for the specified name context, environment and
+ * referencing context object.</p>
+ * <p>
+ * If the builder factory is set by
+ * {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)}, the call is
+ * delegated to that factory. Otherwise, the object is created using the
+ * following rules:
+ * <ul>
+ * <li>If the referencing object (refInfo) contains the factory class name,
+ * the object is created by this factory. If the creation fails,
+ * the parameter refInfo is returned as the method return value.</li>
+ * <li>If the referencing object has no factory class name, and the addresses
+ * are StringRefAddrs having the address type "URL", the object is
+ * created by the URL context factory. The used factory corresponds the
+ * the naming schema of the each URL. If the attempt to create
+ * the object this way is not successful, the subsequent rule is
+ * tried.</li>
+ * <li> If the refInfo is not an instance of Reference or Referencable
+ * (for example, null), the object is created by the factories,
+ * specified in the Context.OBJECT_FACTORIES property of the
+ * environment and the provider resource file, associated with the
+ * nameCtx. The value of this property is the colon separated list
+ * of the possible factories. If none of the factories can be
+ * loaded, the refInfo is returned.
+ * </ul>
+ * </p>
+ * <p>The object factory must be public and have the public parameterless
+ * constructor.</p>
+ *
+ * @param refInfo the referencing object, for which the new object must be
+ * created (can be null). If not null, it is usually an instance of
+ * the {@link Reference} or {@link Referenceable}.
+ * @param name the name of the object. The name is relative to
+ * the nameCtx naming context. The value of this parameter can be
+ * null if the name is not specified.
+ * @param nameCtx the naming context, in which scope the name of the new
+ * object is specified. If this parameter is null, the name is
+ * specified in the scope of the initial context.
+ * @param environment contains additional information for creating the object.
+ * This paramter can be null if there is no need to provide any
+ * additional information.
+ *
+ * @return the created object. If the creation fails, in some cases
+ * the parameter refInfo may be returned.
+ *
+ * @throws NamingException if the attempt to name the new object has failed
+ * @throws Exception if the object factory throws it. The object factory
+ * only throws an exception if it does not want other factories
+ * to be used to create the object.
+ */
public static Object getObjectInstance (Object refInfo,
Name name,
Context nameCtx,
@@ -312,7 +527,21 @@ public class NamingManager
return obj == null ? refInfo : obj;
}
- public static void setInitialContextFactoryBuilder (InitialContextFactoryBuilder builder)
+ /**
+ * Sets the initial context factory builder.
+ *
+ * @param builder the builder to set
+ *
+ * @throws SecurityException if the builder cannot be installed due
+ * security restrictions.
+ * @throws NamingException if the builder cannot be installed due other
+ * reasons
+ * @throws IllegalStateException if setting the builder repeatedly
+ *
+ * @see #hasInitialContextFactoryBuilder()
+ */
+ public static void setInitialContextFactoryBuilder
+ (InitialContextFactoryBuilder builder)
throws NamingException
{
SecurityManager sm = System.getSecurityManager ();
@@ -320,11 +549,23 @@ public class NamingManager
sm.checkSetFactory ();
// Once the builder is installed it cannot be replaced.
if (icfb != null)
- throw new IllegalStateException ("builder already installed");
+ throw new IllegalStateException ("ctx factory builder already installed");
if (builder != null)
icfb = builder;
}
-
+
+ /**
+ * Creates a context in which the context operation must be continued.
+ * This method is used by operations on names that span multiple namespaces.
+ *
+ * @param cpe the exception that triggered this continuation. This method
+ * obtains the environment ({@link CannotProceedException#getEnvironment()}
+ * and sets the environment property {@link #CPE} = cpe.
+ *
+ * @return a non null context for continuing the operation
+ *
+ * @throws NamingException if the naming problems have occured
+ */
public static Context getContinuationContext (CannotProceedException cpe)
throws NamingException
{
@@ -332,7 +573,7 @@ public class NamingManager
if (env != null)
env.put (CPE, cpe);
- // It is really unclear to me if this is right.
+ // TODO: Check if this implementation matches the API specification
try
{
Object obj = getObjectInstance (cpe.getResolvedObj(),
@@ -351,7 +592,22 @@ public class NamingManager
throw cpe;
}
-
+
+ /**
+ * Get the object state for binding.
+ *
+ * @param obj the object, for that the binding state must be retrieved. Cannot
+ * be null.
+ * @param name the name of this object, related to the nameCtx. Can be null if
+ * not specified.
+ * @param nameCtx the naming context, to that the object name is related. Can
+ * be null if the name is related to the initial default context.
+ * @param environment the properties for creating the object state. Can be
+ * null if no properties are provided.
+ * @return the object state for binding, may be null if no changes are
+ * returned by the factory
+ * @throws NamingException
+ */
public static Object getStateToBind (Object obj, Name name,
Context nameCtx, Hashtable environment)
throws NamingException
diff --git a/libjava/classpath/javax/naming/spi/ObjectFactory.java b/libjava/classpath/javax/naming/spi/ObjectFactory.java
index 81648d9a8b5..27771b6cbbd 100644
--- a/libjava/classpath/javax/naming/spi/ObjectFactory.java
+++ b/libjava/classpath/javax/naming/spi/ObjectFactory.java
@@ -1,5 +1,5 @@
/* ObjectFactory.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,9 +43,33 @@ import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
+/**
+ * Represents a factory for creating the object. ObjectFactory performs the
+ * operation, that is the opposite to the operation, performed by the
+ * {@link StateFactory}. Classes, implementing this interface, must be public
+ * and have public parameterless constructor.
+ */
public interface ObjectFactory
{
- Object getObjectInstance (Object obj, Name name, Context nameCtx,
- Hashtable environment)
- throws Exception;
+ /**
+ * Creates the object, using the specified name and location information. The
+ * call of this method must be thread safe.
+ *
+ * @param refObj may provide the reference and location information. Can be null.
+ * @param name the name of the new object in the scope of the specified naming
+ * context. Can be null if the name is not specified.
+ * @param nameCtx the context, in which the object name is specified. Can be
+ * null if the name is specified in the scope of the default initial
+ * context.
+ * @param environment the properties, providing additional information on how
+ * to create an object. Can be null if not additional information is
+ * provided.
+ * @return the newly created object or null if the object cannot be created
+ * @throws Exception if this factory suggest not to try creating of this
+ * object by other alternative factories
+ *
+ * @see NamingManager#getObjectInstance(Object, Name, Context, Hashtable)
+ */
+ Object getObjectInstance(Object refObj, Name name, Context nameCtx,
+ Hashtable environment) throws Exception;
}
diff --git a/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java b/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java
index a7613931548..cb20c666e71 100644
--- a/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java
+++ b/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java
@@ -1,5 +1,5 @@
-/* ObjectFactoryBuilder.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+/* ObjectFactoryBuilder.java -- the builder that creates the object factories.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,14 +41,30 @@ package javax.naming.spi;
import java.util.Hashtable;
import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
/**
+ * Represents the builder that creates the object factories.
+ *
+ * @see NamingManager#setObjectFactoryBuilder(ObjectFactoryBuilder)
+ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
public interface ObjectFactoryBuilder
-{
- ObjectFactory createObjectFactory(Object obj,
+{
+ /**
+ * Create a new object using the supplied environment.
+ *
+ * @param refInfo the referencing object, for which the new object must be
+ * created (can be null). If not null, it is usually an instance of
+ * the {@link Reference} or {@link Referenceable}.
+ * @param environment contains the additional information about the factory
+ * being created. Can be null.
+ * @return the created object factory. The null is never returned.
+ * @throws NamingException
+ */
+ ObjectFactory createObjectFactory(Object refInfo,
Hashtable environment)
throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/spi/ResolveResult.java b/libjava/classpath/javax/naming/spi/ResolveResult.java
index 07e2df3c01c..d5051a5d4da 100644
--- a/libjava/classpath/javax/naming/spi/ResolveResult.java
+++ b/libjava/classpath/javax/naming/spi/ResolveResult.java
@@ -45,8 +45,11 @@ import javax.naming.InvalidNameException;
import javax.naming.Name;
/**
+ * Stores the partial resolution of the name. This class contains the
+ * object to which part of the name has been resolved and the remaining,
+ * unresolved part of this name.
+ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 5, 2001
*/
public class ResolveResult implements Serializable
@@ -54,51 +57,92 @@ public class ResolveResult implements Serializable
private static final long serialVersionUID = - 4552108072002407559L;
// Serialized fields.
+ /**
+ * The object, to that part of the name has been resolved.
+ */
protected Object resolvedObj;
+
+ /**
+ * The remaining, unresolved part of the name.
+ */
protected Name remainingName;
-
+
+ /**
+ * Create the unitialised instance with both parts being null.
+ */
protected ResolveResult()
{
- resolvedObj = null;
- remainingName = null;
}
-
- public ResolveResult(Object robj, String rcomp)
+
+ /**
+ * Create the initialised instance
+ *
+ * @param resolved the object, to that the name is partially resolved
+ * @param remaining the remaining unresolved part of the name.
+ */
+ public ResolveResult(Object resolved, String remaining)
{
- if (robj == null || rcomp == null)
+ if (resolved == null || remaining == null)
throw new IllegalArgumentException ();
- resolvedObj = robj;
+ resolvedObj = resolved;
remainingName = new CompositeName ();
try
{
- remainingName.add (rcomp);
+ remainingName.add (remaining);
}
catch (InvalidNameException _)
{
}
}
- public ResolveResult(Object robj, Name rname)
+ /**
+ * Create the initialised instance
+ *
+ * @param resolved the object, to that the name is partially resolved
+ * @param remaining the remaining unresolved part of the name.
+ */
+ public ResolveResult(Object resolved, Name remaining)
{
- resolvedObj = robj;
- remainingName = rname;
+ resolvedObj = resolved;
+ remainingName = remaining;
}
+ /**
+ * Get the remaining unresolved part of the name
+ *
+ * @return the remaining unresolved part of the name.
+ */
public Name getRemainingName()
{
return remainingName;
}
+ /**
+ * Get the object to that the name was partially resolved
+ *
+ * @return the object, to that the name is partially resolved
+ */
public Object getResolvedObj()
{
return resolvedObj;
}
-
+
+ /**
+ * Set the remaining unresolved name.
+ *
+ * @param name the name being set. The passed parameter is cloned, so the
+ * caller can reuse or modify it after the method returns.
+ */
public void setRemainingName(Name name)
{
remainingName = (Name) name.clone();
}
-
+
+ /**
+ * Append the name to the end of the resolved name.
+ *
+ * @param name the name to append
+ */
public void appendRemainingName(Name name)
{
try
@@ -110,6 +154,11 @@ public class ResolveResult implements Serializable
}
}
+ /**
+ * Append the name to the end of the resolved name.
+ *
+ * @param name the name to append
+ */
public void appendRemainingComponent(String name)
{
try
@@ -121,6 +170,11 @@ public class ResolveResult implements Serializable
}
}
+ /**
+ * Set the object to that the part of the name has been resolved.
+ *
+ * @param obj the object, to that the name has been partially resolved.
+ */
public void setResolvedObj(Object obj)
{
resolvedObj = obj;
diff --git a/libjava/classpath/javax/naming/spi/Resolver.java b/libjava/classpath/javax/naming/spi/Resolver.java
index d80fb616924..eb3eeb56079 100644
--- a/libjava/classpath/javax/naming/spi/Resolver.java
+++ b/libjava/classpath/javax/naming/spi/Resolver.java
@@ -1,5 +1,5 @@
/* Resolver.java --
- Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,18 +38,47 @@ exception statement from your version. */
package javax.naming.spi;
+import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
+import javax.naming.NotContextException;
/**
+ * <p>Represents the object, capable for the at least partial name resolution.
+ * The object is not necessay capable for the complete name resolution and
+ * need not implement the {@link Context}.</p>
+ * <p>
+ * Both passed parameters and returned results are owned by the caller.</p>
+ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
-
public interface Resolver
{
+ /**
+ * Partially resolve the name, stopping at the first instance of the context
+ * that is an instance of the contextType
+ *
+ * @param name the name to resolve
+ * @param contextType the class of the context, on that the resolution should
+ * be terminated
+ * @return the complete or partial name resolution
+ * @throws NotContextException if the context of the contextType is not found
+ * @throws NamingException on other failure
+ */
ResolveResult resolveToClass(Name name, Class contextType)
throws NamingException;
+
+ /**
+ * Partially resolve the name, stopping at the first instance of the context
+ * that is an instance of the contextType
+ *
+ * @param name the name to resolve
+ * @param contextType the class of the context, on that the resolution should
+ * be terminated
+ * @return the complete or partial name resolution
+ * @throws NotContextException if the context of the contextType is not found
+ * @throws NamingException on other failure
+ */
ResolveResult resolveToClass(String name, Class contextType)
throws NamingException;
}
diff --git a/libjava/classpath/javax/naming/spi/StateFactory.java b/libjava/classpath/javax/naming/spi/StateFactory.java
index 1fbdeb1fa1e..5694f8a1a09 100644
--- a/libjava/classpath/javax/naming/spi/StateFactory.java
+++ b/libjava/classpath/javax/naming/spi/StateFactory.java
@@ -1,5 +1,5 @@
/* StateFactory.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,11 +45,35 @@ import javax.naming.Name;
import javax.naming.NamingException;
/**
+ * Represents a factory, producing the object states for binding. The operation,
+ * performed by this factory, is the reverse operation with related to the
+ * operation, performed by the {@link ObjectFactory}. Classes, implementing
+ * this interface, must be public and have public parameterless constructor.
+ *
+ * @see DirStateFactory
+ * @see ObjectFactory
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
public interface StateFactory
{
+ /**
+ * Get the object state for binding.
+ *
+ * @param obj the object, for that the binding state must be retrieved. Cannot
+ * be null.
+ * @param name the name of this object, related to the nameCtx. Can be null if
+ * not specified.
+ * @param nameCtx the naming context, to that the object name is related. Can
+ * be null if the name is related to the initial default context.
+ * @param environment the properties for creating the object state. Can be
+ * null if no properties are provided.
+ * @return the object state for binding, may be null if no changes are
+ * returned by the factory
+ * @throws NamingException
+ *
+ * @see NamingManager#getStateToBind
+ * @see DirectoryManager#getStateToBind
+ */
Object getStateToBind(Object obj, Name name, Context nameCtx,
Hashtable environment) throws NamingException;
}
diff --git a/libjava/classpath/javax/rmi/ssl/SslRMIClientSocketFactory.java b/libjava/classpath/javax/rmi/ssl/SslRMIClientSocketFactory.java
new file mode 100644
index 00000000000..1fed5824cd4
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/rmi/ssl/SslRMIServerSocketFactory.java b/libjava/classpath/javax/rmi/ssl/SslRMIServerSocketFactory.java
new file mode 100644
index 00000000000..56f6de11c95
--- /dev/null
+++ b/libjava/classpath/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/libjava/classpath/javax/security/auth/login/LoginContext.java b/libjava/classpath/javax/security/auth/login/LoginContext.java
index 740e67b8baa..17641e65b55 100644
--- a/libjava/classpath/javax/security/auth/login/LoginContext.java
+++ b/libjava/classpath/javax/security/auth/login/LoginContext.java
@@ -1,5 +1,5 @@
/* LoginContext.java
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,6 +91,9 @@ public class LoginContext
Configuration config)
throws LoginException
{
+ this.name = name;
+ this.subject = subject;
+ this.cbHandler = cbHandler;
if (config == null)
config = Configuration.getConfig();
AppConfigurationEntry[] entries = config.getAppConfigurationEntry (name);
@@ -104,9 +107,6 @@ public class LoginContext
sharedState = new HashMap();
for (int i = 0; i < entries.length; i++)
modules[i] = lookupModule (entries[i], subject, sharedState);
- this.name = name;
- this.subject = subject;
- this.cbHandler = cbHandler;
}
/**
diff --git a/libjava/classpath/javax/sound/midi/SysexMessage.java b/libjava/classpath/javax/sound/midi/SysexMessage.java
index 6471a3eb217..3744e2f6bc6 100644
--- a/libjava/classpath/javax/sound/midi/SysexMessage.java
+++ b/libjava/classpath/javax/sound/midi/SysexMessage.java
@@ -86,7 +86,7 @@ public class SysexMessage extends MidiMessage
throws InvalidMidiDataException
{
if (data[0] != SYSTEM_EXCLUSIVE
- || data[0] != SPECIAL_SYSTEM_EXCLUSIVE)
+ && data[0] != SPECIAL_SYSTEM_EXCLUSIVE)
throw new InvalidMidiDataException("Sysex message starts with 0x"
+ Integer.toHexString(data[0])
+ " instead of 0xF0 or 0xF7");
@@ -105,7 +105,7 @@ public class SysexMessage extends MidiMessage
throws InvalidMidiDataException
{
if (status != SYSTEM_EXCLUSIVE
- || status != SPECIAL_SYSTEM_EXCLUSIVE)
+ && status != SPECIAL_SYSTEM_EXCLUSIVE)
throw new InvalidMidiDataException("Sysex message starts with 0x"
+ Integer.toHexString(status)
+ " instead of 0xF0 or 0xF7");
diff --git a/libjava/classpath/javax/sound/midi/Track.java b/libjava/classpath/javax/sound/midi/Track.java
index d06c8cc1dfb..eed5d4c2de0 100644
--- a/libjava/classpath/javax/sound/midi/Track.java
+++ b/libjava/classpath/javax/sound/midi/Track.java
@@ -54,10 +54,10 @@ public class Track
/**
* The list of MidiEvents for this track.
*/
- Vector events;
+ Vector events = new Vector();
// A HashSet to speed processing
- private HashSet eventSet;
+ private HashSet eventSet = new HashSet();
// This is only instantiable within this package.
Track()
diff --git a/libjava/classpath/javax/swing/AbstractButton.java b/libjava/classpath/javax/swing/AbstractButton.java
index 9b2b526f30b..63f827a1ae0 100644
--- a/libjava/classpath/javax/swing/AbstractButton.java
+++ b/libjava/classpath/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;
@@ -923,7 +923,7 @@ public abstract class AbstractButton extends JComponent
// constructor).
// This way the behavior of the JDK is matched.
if(text != null)
- this.text = text;
+ setText(text);
if (icon != null)
default_icon = icon;
@@ -1297,9 +1297,11 @@ public abstract class AbstractButton extends JComponent
* alignment is a numeric constant from {@link SwingConstants}. It must
* be one of: <code>RIGHT</code>, <code>LEFT</code>, <code>CENTER</code>,
* <code>LEADING</code> or <code>TRAILING</code>. The default is
- * <code>RIGHT</code>.
+ * <code>CENTER</code>.
*
* @return The current horizontal alignment
+ *
+ * @see #setHorizontalAlignment(int)
*/
public int getHorizontalAlignment()
{
@@ -1311,17 +1313,21 @@ public abstract class AbstractButton extends JComponent
* alignment is a numeric constant from {@link SwingConstants}. It must
* be one of: <code>RIGHT</code>, <code>LEFT</code>, <code>CENTER</code>,
* <code>LEADING</code> or <code>TRAILING</code>. The default is
- * <code>RIGHT</code>.
+ * <code>CENTER</code>.
*
* @param a The new horizontal alignment
* @throws IllegalArgumentException If alignment is not one of the legal
* constants.
+ *
+ * @see #getHorizontalAlignment()
*/
public void setHorizontalAlignment(int a)
{
if (horizontalAlignment == a)
return;
-
+ if (a != LEFT && a != CENTER && a != RIGHT && a != LEADING
+ && a != TRAILING)
+ throw new IllegalArgumentException("Invalid alignment.");
int old = horizontalAlignment;
horizontalAlignment = a;
firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a);
@@ -1358,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;
@@ -1373,6 +1382,8 @@ public abstract class AbstractButton extends JComponent
* <code>BOTTOM</code>. The default is <code>CENTER</code>.
*
* @return The current vertical alignment
+ *
+ * @see #setVerticalAlignment(int)
*/
public int getVerticalAlignment()
{
@@ -1388,12 +1399,16 @@ public abstract class AbstractButton extends JComponent
* @param a The new vertical alignment
* @throws IllegalArgumentException If alignment is not one of the legal
* constants.
+ *
+ * @see #getVerticalAlignment()
*/
public void setVerticalAlignment(int a)
{
if (verticalAlignment == a)
return;
-
+ if (a != TOP && a != CENTER && a != BOTTOM)
+ throw new IllegalArgumentException("Invalid alignment.");
+
int old = verticalAlignment;
verticalAlignment = a;
firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a);
@@ -1430,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;
@@ -1708,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;
}
/**
@@ -1729,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();
}
@@ -2092,7 +2113,8 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Set the button's rollover icon. The look and feel class should
+ * Set the button's rollover icon and sets the <code>rolloverEnabled</code>
+ * property to <code>true</code>. The look and feel class should
* paint this icon when the "rolloverEnabled" property of the button is
* <code>true</code> and the mouse rolls over the button.
*
@@ -2106,6 +2128,7 @@ public abstract class AbstractButton extends JComponent
Icon old = rolloverIcon;
rolloverIcon = r;
firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, rolloverIcon);
+ setRolloverEnabled(true);
revalidate();
repaint();
}
@@ -2124,12 +2147,13 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Set the button's rollover selected icon. The look and feel class
- * should paint this icon when the "rolloverEnabled" property of the button
- * is <code>true</code>, the "selected" property of the button's model is
- * <code>true</code>, and the mouse rolls over the button.
+ * Set the button's rollover selected icon and sets the
+ * <code>rolloverEnabled</code> property to <code>true</code>. The look and
+ * feel class should paint this icon when the "rolloverEnabled" property of
+ * the button is <code>true</code>, the "selected" property of the button's
+ * model is <code>true</code>, and the mouse rolls over the button.
*
- * @param r The new rollover selected icon
+ * @param r The new rollover selected icon.
*/
public void setRolloverSelectedIcon(Icon r)
{
@@ -2139,6 +2163,7 @@ public abstract class AbstractButton extends JComponent
Icon old = rolloverSelectedIcon;
rolloverSelectedIcon = r;
firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, r);
+ setRolloverEnabled(true);
revalidate();
repaint();
}
diff --git a/libjava/classpath/javax/swing/AbstractCellEditor.java b/libjava/classpath/javax/swing/AbstractCellEditor.java
index df0d3db12b5..e993df5cfc7 100644
--- a/libjava/classpath/javax/swing/AbstractCellEditor.java
+++ b/libjava/classpath/javax/swing/AbstractCellEditor.java
@@ -134,9 +134,9 @@ public abstract class AbstractCellEditor
*
* @param listener the CellEditorListener to add
*/
- public void addCellEditorListener (CellEditorListener listener)
+ public void addCellEditorListener(CellEditorListener listener)
{
- listenerList.add (CellEditorListener.class, listener);
+ listenerList.add(CellEditorListener.class, listener);
}
/**
@@ -145,9 +145,9 @@ public abstract class AbstractCellEditor
*
* @param listener the CellEditorListener to remove
*/
- public void removeCellEditorListener (CellEditorListener listener)
+ public void removeCellEditorListener(CellEditorListener listener)
{
- listenerList.remove (CellEditorListener.class, listener);
+ listenerList.remove(CellEditorListener.class, listener);
}
/**
@@ -161,8 +161,8 @@ public abstract class AbstractCellEditor
*/
public CellEditorListener[] getCellEditorListeners()
{
- return (CellEditorListener[]) listenerList.getListeners
- (CellEditorListener.class);
+ return (CellEditorListener[]) listenerList.getListeners(
+ CellEditorListener.class);
}
/**
diff --git a/libjava/classpath/javax/swing/AbstractSpinnerModel.java b/libjava/classpath/javax/swing/AbstractSpinnerModel.java
index 1a82f0a359d..089e2048da2 100644
--- a/libjava/classpath/javax/swing/AbstractSpinnerModel.java
+++ b/libjava/classpath/javax/swing/AbstractSpinnerModel.java
@@ -113,7 +113,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel
{
ChangeListener[] listeners = getChangeListeners();
- for(int i = 0; i < listeners.length; ++i)
+ for (int i = 0; i < listeners.length; ++i)
listeners[i].stateChanged(changeEvent);
}
}
diff --git a/libjava/classpath/javax/swing/Box.java b/libjava/classpath/javax/swing/Box.java
index 57519f6fcbd..0f984a98465 100644
--- a/libjava/classpath/javax/swing/Box.java
+++ b/libjava/classpath/javax/swing/Box.java
@@ -196,9 +196,8 @@ public class Box extends JComponent implements Accessible
*/
public static Component createGlue()
{
- Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0),
- new Dimension(Short.MAX_VALUE,Short.MAX_VALUE)
- );
+ Filler glue = new Filler(new Dimension(0, 0), new Dimension(0, 0),
+ new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
return glue;
}
@@ -216,9 +215,8 @@ public class Box extends JComponent implements Accessible
*/
public static Component createHorizontalGlue()
{
- Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0),
- new Dimension(Short.MAX_VALUE, 0)
- );
+ Filler glue = new Filler(new Dimension(0, 0), new Dimension(0, 0),
+ new Dimension(Short.MAX_VALUE, 0));
return glue;
}
diff --git a/libjava/classpath/javax/swing/BoxLayout.java b/libjava/classpath/javax/swing/BoxLayout.java
index 408dea934f8..a7f9dd61a6e 100644
--- a/libjava/classpath/javax/swing/BoxLayout.java
+++ b/libjava/classpath/javax/swing/BoxLayout.java
@@ -426,7 +426,7 @@ public class BoxLayout implements LayoutManager2, Serializable
Insets in = container.getInsets();
int width = container.getWidth() - in.left - in.right;
- int height = container.getHeight() - in.top -in.bottom;
+ int height = container.getHeight() - in.top - in.bottom;
if (isHorizontalIn(container))
{
diff --git a/libjava/classpath/javax/swing/ButtonGroup.java b/libjava/classpath/javax/swing/ButtonGroup.java
index 2f8d19831cb..efa36b5f641 100644
--- a/libjava/classpath/javax/swing/ButtonGroup.java
+++ b/libjava/classpath/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 buttons = new Vector();
/** 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/libjava/classpath/javax/swing/DefaultBoundedRangeModel.java b/libjava/classpath/javax/swing/DefaultBoundedRangeModel.java
index 10de4b94837..efca148f449 100644
--- a/libjava/classpath/javax/swing/DefaultBoundedRangeModel.java
+++ b/libjava/classpath/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/libjava/classpath/javax/swing/DefaultButtonModel.java b/libjava/classpath/javax/swing/DefaultButtonModel.java
index 2be18cc8aac..020c904a4e9 100644
--- a/libjava/classpath/javax/swing/DefaultButtonModel.java
+++ b/libjava/classpath/javax/swing/DefaultButtonModel.java
@@ -466,14 +466,14 @@ public class DefaultButtonModel implements ButtonModel, Serializable
if (s)
{
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
- null, ItemEvent.SELECTED));
+ this, ItemEvent.SELECTED));
if (group != null)
group.setSelected(this, true);
}
else
{
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
- null, ItemEvent.DESELECTED));
+ this, ItemEvent.DESELECTED));
if (group != null)
group.setSelected(this, false);
}
diff --git a/libjava/classpath/javax/swing/DefaultComboBoxModel.java b/libjava/classpath/javax/swing/DefaultComboBoxModel.java
index ab80b61f1f9..ef785f34dec 100644
--- a/libjava/classpath/javax/swing/DefaultComboBoxModel.java
+++ b/libjava/classpath/javax/swing/DefaultComboBoxModel.java
@@ -146,9 +146,9 @@ public class DefaultComboBoxModel extends AbstractListModel
if (selected == index) // choose a new selected item
{
if (selected > 0)
- selectedItem = getElementAt(selected - 1);
+ setSelectedItem(getElementAt(selected - 1));
else
- selectedItem = getElementAt(selected + 1);
+ setSelectedItem(getElementAt(selected + 1));
}
list.removeElementAt(index);
fireIntervalRemoved(this, index, index);
diff --git a/libjava/classpath/javax/swing/DefaultListModel.java b/libjava/classpath/javax/swing/DefaultListModel.java
index fdbbb562c90..2d02874a7e4 100644
--- a/libjava/classpath/javax/swing/DefaultListModel.java
+++ b/libjava/classpath/javax/swing/DefaultListModel.java
@@ -184,7 +184,7 @@ public class DefaultListModel extends AbstractListModel
/**
* Inserts an element at a particular index in the list. Each element at
- * index <code>i >= index</code> is shifted to position <code>i+1</code>.
+ * index <code>i >= index</code> is shifted to position <code>i + 1</code>.
* If <code>index</code> is equal to <code>size()</code>, this is
* equivalent to appending an element to the array. Any
* <code>index</code> greater than <code>size()</code> is illegal.
@@ -420,7 +420,7 @@ public class DefaultListModel extends AbstractListModel
/**
* Inserts an element at a particular index in the list. Each element at
- * index <code>i >= index</code> is shifted to position <code>i+1</code>.
+ * index <code>i >= index</code> is shifted to position <code>i + 1</code>.
* If <code>index</code> is equal to <code>size()</code>, this is
* equivalent to appending an element to the array. Any
* <code>index</code> greater than <code>size()</code> is illegal.
diff --git a/libjava/classpath/javax/swing/DefaultListSelectionModel.java b/libjava/classpath/javax/swing/DefaultListSelectionModel.java
index 998aee45279..482ce2cc224 100644
--- a/libjava/classpath/javax/swing/DefaultListSelectionModel.java
+++ b/libjava/classpath/javax/swing/DefaultListSelectionModel.java
@@ -150,9 +150,14 @@ public class DefaultListSelectionModel implements Cloneable,
boolean setLeadCalledFromAdd = false;
/**
- * Gets the value of the {@link #selectionMode} property.
- *
- * @return The current value of the property
+ * Returns the selection mode, which is one of {@link #SINGLE_SELECTION},
+ * {@link #SINGLE_INTERVAL_SELECTION} and
+ * {@link #MULTIPLE_INTERVAL_SELECTION}. The default value is
+ * {@link #MULTIPLE_INTERVAL_SELECTION}.
+ *
+ * @return The selection mode.
+ *
+ * @see #setSelectionMode(int)
*/
public int getSelectionMode()
{
@@ -187,13 +192,19 @@ public class DefaultListSelectionModel implements Cloneable,
/**
* Sets the value of the {@link #anchorSelectionIndex} property.
*
- * @param anchorIndex The new property value
+ * @param index The new property value
*
* @see #getAnchorSelectionIndex
*/
- public void setAnchorSelectionIndex(int anchorIndex)
+ public void setAnchorSelectionIndex(int index)
{
- anchorSelectionIndex = anchorIndex;
+ if (anchorSelectionIndex != index)
+ {
+ int old = anchorSelectionIndex;
+ anchorSelectionIndex = index;
+ if (leadAnchorNotificationEnabled)
+ fireValueChanged(index, old);
+ }
}
/**
@@ -459,12 +470,14 @@ public class DefaultListSelectionModel implements Cloneable,
if (index0 == -1 || index1 == -1)
return;
+ if (selectionMode == SINGLE_SELECTION)
+ setSelectionInterval(index0, index1);
+ else
+ {
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
oldSel = sel.clone();
- if (selectionMode == SINGLE_SELECTION)
- setSelectionInterval(index0, index1);
// COMPAT: Like Sun (but not like IBM), we allow calls to
// addSelectionInterval when selectionMode is
@@ -503,6 +516,7 @@ public class DefaultListSelectionModel implements Cloneable,
sel.set(lo, hi+1);
fireDifference(sel, (BitSet) oldSel);
}
+ }
}
@@ -588,27 +602,82 @@ public class DefaultListSelectionModel implements Cloneable,
* the current selection mode is <code>SINGLE_SELECTION</code> only the
* index <code>index2</code> is selected.
*
- * @param index0 The low end of the new selection
- * @param index1 The high end of the new selection
+ * @param anchor the anchor selection index.
+ * @param lead the lead selection index.
*/
- public void setSelectionInterval(int index0, int index1)
+ public void setSelectionInterval(int anchor, int lead)
{
- if (index0 == -1 || index1 == -1)
+ if (anchor == -1 || lead == -1)
return;
-
- BitSet oldSel = (BitSet) sel.clone();
- sel.clear();
if (selectionMode == SINGLE_SELECTION)
- index0 = index1;
-
- int lo = Math.min(index0, index1);
- int hi = Math.max(index0, index1);
- sel.set(lo, hi+1);
- // update the anchorSelectionIndex and leadSelectionIndex variables
- setAnchorSelectionIndex(index0);
- leadSelectionIndex=index1;
+ {
+ int lo = lead;
+ int hi = lead;
+ int selected = sel.nextSetBit(0);
+ if (selected == lead)
+ return; // the selection is not changing
+ if (selected >= 0)
+ {
+ lo = Math.min(lo, selected);
+ hi = Math.max(hi, selected);
+ }
+ if (anchorSelectionIndex >= 0)
+ {
+ lo = Math.min(lo, anchorSelectionIndex);
+ hi = Math.max(hi, anchorSelectionIndex);
+ }
+ sel.clear();
+ sel.set(lead);
+ leadSelectionIndex = lead;
+ anchorSelectionIndex = lead;
+ fireValueChanged(lo, hi);
+ }
+ else if (selectionMode == SINGLE_INTERVAL_SELECTION)
+ {
+ // determine the current interval
+ int first = sel.nextSetBit(0);
+ int last = first;
+ if (first >= 0)
+ last += (sel.cardinality() - 1);
+
+ // update the selection
+ int lo = Math.min(anchor, lead);
+ int hi = Math.max(anchor, lead);
+ if (lo == first && hi == last)
+ return; // selected interval is not being changed
+ sel.clear();
+ sel.set(lo, hi + 1);
+
+ // include the old selection in the event range
+ if (first >= 0)
+ lo = Math.min(lo, first);
+ if (last >= 0)
+ hi = Math.max(hi, last);
+ if (anchorSelectionIndex >= 0)
+ {
+ lo = Math.min(lo, anchorSelectionIndex);
+ hi = Math.max(hi, anchorSelectionIndex);
+ }
+ anchorSelectionIndex = anchor;
+ leadSelectionIndex = lead;
+ fireValueChanged(lo, hi);
+ }
+ else
+ {
+ BitSet oldSel = (BitSet) sel.clone();
+ sel.clear();
+ if (selectionMode == SINGLE_SELECTION)
+ anchor = lead;
+
+ int lo = Math.min(anchor, lead);
+ int hi = Math.max(anchor, lead);
+ sel.set(lo, hi+1);
+ // update the anchorSelectionIndex and leadSelectionIndex variables
+ setAnchorSelectionIndex(anchor);
+ leadSelectionIndex = lead;
- fireDifference(sel, oldSel);
+ fireDifference(sel, oldSel);
+ }
}
/**
diff --git a/libjava/classpath/javax/swing/GrayFilter.java b/libjava/classpath/javax/swing/GrayFilter.java
index b920b088a17..ef0d14718d6 100644
--- a/libjava/classpath/javax/swing/GrayFilter.java
+++ b/libjava/classpath/javax/swing/GrayFilter.java
@@ -76,9 +76,8 @@ public class GrayFilter extends RGBImageFilter
*/
public static Image createDisabledImage(Image src)
{
- return (Toolkit.getDefaultToolkit().
- createImage(new FilteredImageSource(src.getSource(),
- new GrayFilter(true, 0))));
+ return (Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(
+ src.getSource(), new GrayFilter(true, 0))));
}
/**
diff --git a/libjava/classpath/javax/swing/InputMap.java b/libjava/classpath/javax/swing/InputMap.java
index 28fccd9b9cd..19a75f4e985 100644
--- a/libjava/classpath/javax/swing/InputMap.java
+++ b/libjava/classpath/javax/swing/InputMap.java
@@ -1,5 +1,5 @@
/* InputMap.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,9 +37,6 @@ 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.Arrays;
import java.util.HashMap;
@@ -47,14 +44,13 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
/**
* Maps {@link KeyStroke}s to arbitrary objects, usually Strings. This
* is used in combination with {@link ActionMap}s.
*
* If a component receives an input event, this is looked up in
* the component's <code>InputMap</code>. The result is an object which
- * serves as a key to the components <code>ActionMap</code>. Finally
+ * serves as a key to the component's <code>ActionMap</code>. Finally
* the <code>Action</code> that is stored is executed.
*
* @author Andrew Selkirk
@@ -68,33 +64,37 @@ public class InputMap
private static final long serialVersionUID = -5429059542008604257L;
/**
- * inputMap
+ * Storage for the KeyStroke --> Object mappings.
*/
- private Map inputMap = new HashMap();
+ private Map inputMap;
/**
- * parent
+ * An optional parent map.
*/
private InputMap parent;
/**
- * Creates a new <code>InputMap</code> instance.
+ * Creates a new <code>InputMap</code> instance. This default instance
+ * contains no mappings and has no parent.
*/
public InputMap()
{
- // TODO
+ // nothing to do
}
/**
- * Returns the binding for keystroke.
+ * Returns the binding for the specified keystroke, if there is one.
*
- * @param keystroke the key of the enty
+ * @param keystroke the key of the entry (<code>null</code> is ignored).
*
- * @return the binding associated with keystroke may be null
+ * @return The binding associated with the specified keystroke (or
+ * <code>null</code>).
*/
public Object get(KeyStroke keystroke)
{
- Object result = inputMap.get(keystroke);
+ Object result = null;
+ if (inputMap != null)
+ result = inputMap.get(keystroke);
if (result == null && parent != null)
result = parent.get(keystroke);
@@ -102,14 +102,20 @@ public class InputMap
}
/**
- * Puts a new entry into the <code>InputMap</code>.
- * If actionMapKey is null an existing entry will be removed.
+ * Puts a new entry into the <code>InputMap</code>. If
+ * <code>actionMapKey</code> is <code>null</code> any existing entry will be
+ * removed.
*
- * @param keystroke the keystroke for the entry
- * @param actionMapKey the action.
+ * @param keystroke the keystroke for the entry (<code>null</code> is
+ * ignored).
+ * @param actionMapKey the action (<code>null</code> permitted).
*/
public void put(KeyStroke keystroke, Object actionMapKey)
{
+ if (keystroke == null)
+ return;
+ if (inputMap == null)
+ inputMap = new HashMap();
if (actionMapKey == null)
inputMap.remove(keystroke);
else
@@ -117,19 +123,25 @@ public class InputMap
}
/**
- * Remove an entry from the <code>InputMap</code>.
+ * Removes an entry from this <code>InputMap</code>. Note that this will
+ * not remove any entry from the parent map, if there is one.
*
- * @param keystroke the key of the entry to remove
+ * @param keystroke the key of the entry to remove (<code>null</code> is
+ * ignored).
*/
public void remove(KeyStroke keystroke)
{
- inputMap.remove(keystroke);
+ if (inputMap != null)
+ inputMap.remove(keystroke);
}
/**
- * Returns the parent of this <code>InputMap</code>.
+ * Returns the parent of this <code>InputMap</code>. The default value
+ * is <code>null</code>.
*
- * @return the parent, may be null.
+ * @return The parent map (possibly <code>null</code>).
+ *
+ * @see #setParent(InputMap)
*/
public InputMap getParent()
{
@@ -137,9 +149,13 @@ public class InputMap
}
/**
- * Sets a parent for this <code>InputMap</code>.
+ * Sets a parent for this <code>InputMap</code>. If a parent is specified,
+ * the {@link #get(KeyStroke)} method will look in the parent if it cannot
+ * find an entry in this map.
*
- * @param parentMap the new parent
+ * @param parentMap the new parent (<code>null</code> permitted).
+ *
+ * @see #getParent()
*/
public void setParent(InputMap parentMap)
{
@@ -147,31 +163,44 @@ public class InputMap
}
/**
- * Returns the number of entries in this <code>InputMap</code>.
+ * Returns the number of entries in this <code>InputMap</code>. This count
+ * does not include any entries from the parent map, if there is one.
*
- * @return the number of entries
+ * @return The number of entries.
*/
public int size()
{
- return inputMap.size();
+ int result = 0;
+ if (inputMap != null)
+ result = inputMap.size();
+ return result;
}
/**
- * Clears the <code>InputMap</code>.
+ * Clears the entries from this <code>InputMap</code>. The parent map, if
+ * there is one, is not cleared.
*/
public void clear()
{
- inputMap.clear();
+ if (inputMap != null)
+ inputMap.clear();
}
/**
- * Returns all keys of entries in this <code>InputMap</code>.
+ * Returns all keys of entries in this <code>InputMap</code>. This does not
+ * include keys defined in the parent, if there is one (use the
+ * {@link #allKeys()} method for that case).
+ * <br><br>
+ * Following the behaviour of the reference implementation, this method will
+ * return <code>null</code> when no entries have been added to the map,
+ * and a zero length array if entries have been added but subsequently
+ * removed (or cleared) from the map.
*
- * @return an array of keys
+ * @return An array of keys (may be <code>null</code> or have zero length).
*/
public KeyStroke[] keys()
{
- if (size() != 0)
+ if (inputMap != null)
{
KeyStroke[] array = new KeyStroke[size()];
return (KeyStroke[]) inputMap.keySet().toArray(array);
@@ -180,10 +209,10 @@ public class InputMap
}
/**
- * Returns all keys of entries in this <code>InputMap</code>
- * and all its parents.
+ * Returns all keys of entries in this <code>InputMap</code> and all its
+ * parents.
*
- * @return an array of keys
+ * @return An array of keys (may be <code>null</code> or have zero length).
*/
public KeyStroke[] allKeys()
{
@@ -195,36 +224,12 @@ public class InputMap
if (parentKeys != null)
set.addAll(Arrays.asList(parentKeys));
}
- set.addAll(inputMap.keySet());
+ if (inputMap != null)
+ set.addAll(inputMap.keySet());
if (set.size() == 0)
return null;
KeyStroke[] array = new KeyStroke[set.size()];
return (KeyStroke[]) set.toArray(array);
}
- /**
- * writeObject
- *
- * @param stream the stream to write to
- *
- * @exception IOException If an error occurs
- */
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- // TODO
- }
-
- /**
- * readObject
- *
- * @param stream the stream to read from
- *
- * @exception ClassNotFoundException If the serialized class cannot be found
- * @exception IOException If an error occurs
- */
- private void readObject(ObjectInputStream stream)
- throws ClassNotFoundException, IOException
- {
- // TODO
- }
}
diff --git a/libjava/classpath/javax/swing/JCheckBoxMenuItem.java b/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
index 3222d189f37..51634c93f0b 100644
--- a/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
+++ b/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
@@ -1,39 +1,39 @@
/* JCheckBoxMenuItem.java --
- Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package javax.swing;
@@ -43,20 +43,20 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
- * A menu item that displays a checkbox. Its behaviour is very similar
- * to {@link JCheckBox}. Just like the <code>JCheckBox</code>, user can check
+ * A menu item that displays a checkbox. Its behaviour is very similar to
+ * {@link JCheckBox}. Just like the <code>JCheckBox</code>, user can check
* and uncheck this menu item by clicking on it. Also
- * {@link AbstractButton#setSelected} and {@link #setState} can be use used
- * for the same purpose.
- * <code>JCheckBoxMenuItem</code> uses
+ * {@link AbstractButton#setSelected} and {@link #setState} can be use used for
+ * the same purpose. <code>JCheckBoxMenuItem</code> uses
* <code>ToggleButtonModel</code> to keep track of its selection.
- *
+ *
* @author original author unknown
*/
-public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
- Accessible
+public class JCheckBoxMenuItem
+ extends JMenuItem
+ implements SwingConstants, Accessible
{
- private static final long serialVersionUID = -6676402307973384715L;
+ private static final long serialVersionUID = - 6676402307973384715L;
/** name for the UI delegate for this menuItem. */
private static final String uiClassID = "CheckBoxMenuItemUI";
@@ -65,8 +65,8 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
private boolean state;
/**
- * This array contains text of this menu item if this menu item is in
- * checked state and null it is not.
+ * This array contains text of this menu item if this menu item is in checked
+ * state and null it is not.
*/
private Object[] selectedObjects = new Object[1];
@@ -80,7 +80,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem with given icon
- *
+ *
* @param icon Icon for this menu item
*/
public JCheckBoxMenuItem(Icon icon)
@@ -90,7 +90,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem with given label
- *
+ *
* @param text Label for this menu item
*/
public JCheckBoxMenuItem(String text)
@@ -100,7 +100,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem using given action
- *
+ *
* @param action Action for this menu item.
*/
public JCheckBoxMenuItem(Action action)
@@ -111,7 +111,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem object with given label and icon
- *
+ *
* @param text Label for this menu item
* @param icon Icon for this menu item
*/
@@ -121,12 +121,12 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * Creates a new JCheckBoxMenuItem object using specified label and
- * marked as checked if given 'state' is true.
- *
+ * Creates a new JCheckBoxMenuItem object using specified label and marked as
+ * checked if given 'state' is true.
+ *
* @param text Label for this menu item
- * @param state <code>true</code> if this item should be in checked state and
- * <code>false</code> otherwise
+ * @param state <code>true</code> if this item should be in checked state
+ * and <code>false</code> otherwise
*/
public JCheckBoxMenuItem(String text, boolean state)
{
@@ -134,26 +134,28 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * Creates a new JCheckBoxMenuItem object with given label, icon,
- * and marked as checked if given 'state' is true.
- *
+ * Creates a new JCheckBoxMenuItem object with given label, icon, and marked
+ * as checked if given 'state' is true.
+ *
* @param text Label for this menu item
* @param icon icon for this menu item
- * @param state <code>true</code> if this item should be in checked state and
- * false otherwise
+ * @param state <code>true</code> if this item should be in checked state
+ * and false otherwise
*/
public JCheckBoxMenuItem(String text, Icon icon, boolean state)
{
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
this.state = state;
- this.setVisible(true);
+ if (state == true)
+ this.setSelected(true);
+ setFocusable(false);
}
/**
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menuItem.
- *
+ *
* @return The Look and Feel classID. "JCheckBoxMenuItemUI"
*/
public String getUIClassID()
@@ -163,9 +165,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Returns checked state for this check box menu item.
- *
- * @return Returns true if this menu item is in checked state
- * and false otherwise.
+ *
+ * @return Returns true if this menu item is in checked state and false
+ * otherwise.
*/
public boolean getState()
{
@@ -173,10 +175,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * Sets state for this check box menu item. If
- * given 'state' is true, then mark menu item as checked,
- * and uncheck this menu item otherwise.
- *
+ * Sets state for this check box menu item. If given 'state' is true, then
+ * mark menu item as checked, and uncheck this menu item otherwise.
+ *
* @param state new state for this menu item
*/
public synchronized void setState(boolean state)
@@ -185,11 +186,11 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * This method returns array containing label of this
- * menu item if it is selected and null otherwise.
- *
- * @return Array containing label of this
- * menu item if this menu item is selected or null otherwise.
+ * This method returns array containing label of this menu item if it is
+ * selected and null otherwise.
+ *
+ * @return Array containing label of this menu item if this menu item is
+ * selected or null otherwise.
*/
public Object[] getSelectedObjects()
{
@@ -202,27 +203,26 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * This method overrides JComponent.requestFocus with an empty
- * implementation, since JCheckBoxMenuItems should not
- * receive focus in general.
- */
+ * This method overrides JComponent.requestFocus with an empty implementation,
+ * since JCheckBoxMenuItems should not receive focus in general.
+ */
public void requestFocus()
{
- // Should do nothing here
+ // Should do nothing here
}
/**
- * Returns a string describing the attributes for the
- * <code>JCheckBoxMenuItem</code> component, for use in debugging. The
- * return value is guaranteed to be non-<code>null</code>, but the format
+ * Returns a string describing the attributes for the
+ * <code>JCheckBoxMenuItem</code> component, for use in debugging. The
+ * return value is guaranteed to be non-<code>null</code>, but the format
* of the string may vary between implementations.
- *
- * @return A string describing the attributes of the
- * <code>JCheckBoxMenuItem</code>.
+ *
+ * @return A string describing the attributes of the
+ * <code>JCheckBoxMenuItem</code>.
*/
protected String paramString()
{
- // calling super seems to be sufficient to match the reference
+ // calling super seems to be sufficient to match the reference
// implementation here...
return super.paramString();
}
@@ -230,9 +230,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Returns the object that provides accessibility features for this
* <code>JCheckBoxMenuItem</code> component.
- *
- * @return The accessible context (an instance of
- * {@link AccessibleJCheckBoxMenuItem}).
+ *
+ * @return The accessible context (an instance of
+ * {@link AccessibleJCheckBoxMenuItem}).
*/
public AccessibleContext getAccessibleContext()
{
@@ -243,12 +243,13 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * Provides the accessibility features for the <code>JCheckBoxMenuItem</code>
+ * Provides the accessibility features for the <code>JCheckBoxMenuItem</code>
* component.
*
* @see JCheckBoxMenuItem#getAccessibleContext()
*/
- protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
+ protected class AccessibleJCheckBoxMenuItem
+ extends AccessibleJMenuItem
{
private static final long serialVersionUID = 1079958073579370777L;
@@ -261,9 +262,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
- * Returns the accessible role for the <code>JCheckBoxMenuItem</code>
+ * Returns the accessible role for the <code>JCheckBoxMenuItem</code>
* component.
- *
+ *
* @return {@link AccessibleRole#CHECK_BOX}.
*/
public AccessibleRole getAccessibleRole()
diff --git a/libjava/classpath/javax/swing/JComboBox.java b/libjava/classpath/javax/swing/JComboBox.java
index efb04592b50..c75a94bdc36 100644
--- a/libjava/classpath/javax/swing/JComboBox.java
+++ b/libjava/classpath/javax/swing/JComboBox.java
@@ -471,6 +471,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
public void setSelectedItem(Object item)
{
dataModel.setSelectedItem(item);
+ fireActionEvent();
}
/**
@@ -1028,7 +1029,8 @@ public class JComboBox extends JComponent implements ItemSelectable,
}
/**
- * This method hides combo box's popup whenever TAB key is pressed.
+ * This method is fired whenever a key is pressed with the combo box
+ * in focus
*
* @param e The KeyEvent indicating which key was pressed.
*/
@@ -1036,15 +1038,6 @@ public class JComboBox extends JComponent implements ItemSelectable,
{
if (e.getKeyCode() == KeyEvent.VK_TAB)
setPopupVisible(false);
- else if (keySelectionManager != null)
- {
- int i = keySelectionManager.selectionForKey(e.getKeyChar(),
- getModel());
- if (i >= 0)
- setSelectedIndex(i);
- else
- super.processKeyEvent(e);
- }
else
super.processKeyEvent(e);
}
@@ -1066,7 +1059,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public KeySelectionManager getKeySelectionManager()
{
- return null;
+ return keySelectionManager;
}
/**
@@ -1098,7 +1091,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
protected KeySelectionManager createDefaultKeySelectionManager()
{
- return null;
+ return new DefaultKeySelectionManager();
}
/**
@@ -1471,4 +1464,34 @@ public class JComboBox extends JComponent implements ItemSelectable,
// Nothing to do here.
}
}
+
+ private class DefaultKeySelectionManager
+ implements KeySelectionManager
+ {
+
+ public int selectionForKey(char aKey, ComboBoxModel aModel)
+ {
+ int selectedIndex = getSelectedIndex();
+
+ // Start at currently selected item and iterate to end of list
+ for (int i = selectedIndex + 1; i < aModel.getSize(); i++)
+ {
+ String nextItem = aModel.getElementAt(i).toString();
+
+ if (nextItem.charAt(0) == aKey)
+ return i;
+ }
+
+ // Wrap to start of list if no match yet
+ for (int i = 0; i <= selectedIndex; i++)
+ {
+ String nextItem = aModel.getElementAt(i).toString();
+
+ if (nextItem.charAt(0) == aKey)
+ return i;
+ }
+
+ return - 1;
+ }
+ }
}
diff --git a/libjava/classpath/javax/swing/JComponent.java b/libjava/classpath/javax/swing/JComponent.java
index 66c562d110b..fa83502946d 100644
--- a/libjava/classpath/javax/swing/JComponent.java
+++ b/libjava/classpath/javax/swing/JComponent.java
@@ -48,12 +48,10 @@ import java.awt.EventQueue;
import java.awt.FocusTraversalPolicy;
import java.awt.Font;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.Shape;
import java.awt.Window;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
@@ -69,8 +67,8 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Locale;
@@ -571,6 +569,21 @@ public abstract class JComponent extends Container implements Serializable
*/
String toolTipText;
+ /**
+ * The popup menu for the component.
+ *
+ * @see #getComponentPopupMenu()
+ * @see #setComponentPopupMenu(JPopupMenu)
+ */
+ JPopupMenu componentPopupMenu;
+
+ /**
+ * A flag that controls whether the {@link #getComponentPopupMenu()} method
+ * looks to the component's parent when the <code>componentPopupMenu</code>
+ * field is <code>null</code>.
+ */
+ boolean inheritsPopupMenu;
+
/**
* <p>Whether to double buffer this component when painting. This flag
* should generally be <code>true</code>, to ensure good painting
@@ -668,7 +681,13 @@ public abstract class JComponent extends Container implements Serializable
* Indicates whether the current paint call is already double buffered or
* not.
*/
- static boolean isPaintingDoubleBuffered = false;
+ static boolean paintingDoubleBuffered = false;
+
+ /**
+ * Indicates whether we are calling paintDoubleBuffered() from
+ * paintImmadiately (RepaintManager) or from paint() (AWT refresh).
+ */
+ static private boolean isRepainting = false;
/**
* Listeners for events other than {@link PropertyChangeEvent} are
@@ -677,6 +696,11 @@ public abstract class JComponent extends Container implements Serializable
*/
protected EventListenerList listenerList = new EventListenerList();
+ /**
+ * Handles VetoableChangeEvents.
+ */
+ private VetoableChangeSupport vetoableChangeSupport;
+
/**
* Storage for "client properties", which are key/value pairs associated
* with this component by a "client", such as a user application or a
@@ -690,7 +714,7 @@ public abstract class JComponent extends Container implements Serializable
private ComponentInputMap inputMap_whenInFocusedWindow;
private ActionMap actionMap;
/** @since 1.3 */
- private boolean verifyInputWhenFocusTarget;
+ private boolean verifyInputWhenFocusTarget = true;
private InputVerifier inputVerifier;
private TransferHandler transferHandler;
@@ -784,7 +808,7 @@ public abstract class JComponent extends Container implements Serializable
{
super();
setDropTarget(new DropTarget());
- defaultLocale = Locale.getDefault();
+ setLocale(getDefaultLocale());
debugGraphicsOptions = DebugGraphics.NONE_OPTION;
setRequestFocusEnabled(true);
}
@@ -868,7 +892,8 @@ public abstract class JComponent extends Container implements Serializable
*/
public void removeVetoableChangeListener(VetoableChangeListener listener)
{
- listenerList.remove(VetoableChangeListener.class, listener);
+ if (vetoableChangeSupport != null)
+ vetoableChangeSupport.removeVetoableChangeListener(listener);
}
/**
@@ -884,23 +909,6 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Register a <code>PropertyChangeListener</code> for a specific, named
- * property. To listen to all property changes, regardless of name, use
- * {@link #addPropertyChangeListener(PropertyChangeListener)} instead.
- *
- * @param propertyName The property name to listen to
- * @param listener The listener to register
- *
- * @see #removePropertyChangeListener(String, PropertyChangeListener)
- * @see #changeSupport
- */
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener)
- {
- listenerList.add(PropertyChangeListener.class, listener);
- }
-
- /**
* Register a <code>VetoableChangeListener</code>.
*
* @param listener The listener to register
@@ -910,7 +918,10 @@ public abstract class JComponent extends Container implements Serializable
*/
public void addVetoableChangeListener(VetoableChangeListener listener)
{
- listenerList.add(VetoableChangeListener.class, listener);
+ // Lazily instantiate this, it's rarely needed.
+ if (vetoableChangeSupport == null)
+ vetoableChangeSupport = new VetoableChangeSupport(this);
+ vetoableChangeSupport.addVetoableChangeListener(listener);
}
/**
@@ -936,6 +947,8 @@ public abstract class JComponent extends Container implements Serializable
{
if (listenerType == PropertyChangeListener.class)
return getPropertyChangeListeners();
+ else if (listenerType == VetoableChangeListener.class)
+ return getVetoableChangeListeners();
else
return listenerList.getListeners(listenerType);
}
@@ -954,84 +967,89 @@ public abstract class JComponent extends Container implements Serializable
/**
* Return all registered <code>VetoableChangeListener</code> objects.
*
- * @return The set of <code>VetoableChangeListener</code> objects in {@link
- * #listenerList}
+ * @return An array of the <code>VetoableChangeListener</code> objects
+ * registered with this component (possibly empty but never
+ * <code>null</code>).
+ *
+ * @since 1.4
*/
public VetoableChangeListener[] getVetoableChangeListeners()
- {
- return (VetoableChangeListener[]) getListeners(VetoableChangeListener.class);
+ {
+ return vetoableChangeSupport == null ? new VetoableChangeListener[0]
+ : vetoableChangeSupport.getVetoableChangeListeners();
}
/**
- * A variant of {@link #firePropertyChange(String,Object,Object)}
- * for properties with <code>boolean</code> values.
+ * Call {@link VetoableChangeListener#vetoableChange} on all listeners
+ * registered to listen to a given property. Any method which changes
+ * the specified property of this component should call this method.
+ *
+ * @param propertyName The property which changed
+ * @param oldValue The old value of the property
+ * @param newValue The new value of the property
+ *
+ * @throws PropertyVetoException if the change was vetoed by a listener
*
- * @specnote It seems that in JDK1.5 all property related methods have been
- * moved to java.awt.Component, except this and 2 others. We call
- * super here. I guess this will also be removed in one of the next
- * releases.
+ * @see #addVetoableChangeListener
+ * @see #removeVetoableChangeListener
*/
- public void firePropertyChange(String propertyName, boolean oldValue,
- boolean newValue)
+ protected void fireVetoableChange(String propertyName, Object oldValue,
+ Object newValue)
+ throws PropertyVetoException
{
- super.firePropertyChange(propertyName, oldValue, newValue);
+ if (vetoableChangeSupport != null)
+ vetoableChangeSupport.fireVetoableChange(propertyName, oldValue, newValue);
}
+
/**
- * A variant of {@link #firePropertyChange(String,Object,Object)}
- * for properties with <code>char</code> values.
+ * Fires a property change for a primitive integer property.
+ *
+ * @param property the name of the property
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
*
- * @specnote It seems that in JDK1.5 all property related methods have been
- * moved to java.awt.Component, except this and 2 others. We call
- * super here. I guess this will also be removed in one of the next
- * releases.
+ * @specnote This method is implemented in
+ * {@link Component#firePropertyChange(String, int, int)}. It is
+ * only here because it is specified to be public, whereas the
+ * Component method is protected.
*/
- public void firePropertyChange(String propertyName, char oldValue,
- char newValue)
+ public void firePropertyChange(String property, int oldValue, int newValue)
{
- super.firePropertyChange(propertyName, oldValue, newValue);
+ super.firePropertyChange(property, oldValue, newValue);
}
-
+
/**
- * A variant of {@link #firePropertyChange(String,Object,Object)}
- * for properties with <code>int</code> values.
+ * Fires a property change for a primitive boolean property.
+ *
+ * @param property the name of the property
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
*
- * @specnote It seems that in JDK1.5 all property related methods have been
- * moved to java.awt.Component, except this and 2 others. We call
- * super here. I guess this will also be removed in one of the next
- * releases.
+ * @specnote This method is implemented in
+ * {@link Component#firePropertyChange(String, boolean, boolean)}.
+ * It is only here because it is specified to be public, whereas
+ * the Component method is protected.
*/
- public void firePropertyChange(String propertyName, int oldValue,
- int newValue)
+ public void firePropertyChange(String property, boolean oldValue,
+ boolean newValue)
{
- super.firePropertyChange(propertyName, oldValue, newValue);
+ super.firePropertyChange(property, oldValue, newValue);
}
/**
- * Call {@link VetoableChangeListener#vetoableChange} on all listeners
- * registered to listen to a given property. Any method which changes
- * the specified property of this component should call this method.
- *
- * @param propertyName The property which changed
- * @param oldValue The old value of the property
- * @param newValue The new value of the property
- *
- * @throws PropertyVetoException if the change was vetoed by a listener
+ * Fires a property change for a primitive character property.
*
- * @see #addVetoableChangeListener
- * @see #removeVetoableChangeListener
+ * @param property the name of the property
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
*/
- protected void fireVetoableChange(String propertyName, Object oldValue,
- Object newValue)
- throws PropertyVetoException
+ public void firePropertyChange(String property, char oldValue,
+ char newValue)
{
- VetoableChangeListener[] listeners = getVetoableChangeListeners();
-
- PropertyChangeEvent evt =
- new PropertyChangeEvent(this, propertyName, oldValue, newValue);
-
- for (int i = 0; i < listeners.length; i++)
- listeners[i].vetoableChange(evt);
+ // FIXME - This method is already public in awt Component, but
+ // is included here to work around a compilation bug in gcj 4.1.
+ super.firePropertyChange(property, oldValue, newValue);
}
/**
@@ -1402,11 +1420,32 @@ public abstract class JComponent extends Container implements Serializable
* Return the set of {@link KeyStroke} objects which are registered
* to initiate actions on this component.
*
- * @return An array of the registered keystrokes
+ * @return An array of the registered keystrokes (possibly empty but never
+ * <code>null</code>).
*/
public KeyStroke[] getRegisteredKeyStrokes()
{
- return null;
+ KeyStroke[] ks0;
+ KeyStroke[] ks1;
+ KeyStroke[] ks2;
+ if (inputMap_whenFocused != null)
+ ks0 = inputMap_whenFocused.keys();
+ else
+ ks0 = new KeyStroke[0];
+ if (inputMap_whenAncestorOfFocused != null)
+ ks1 = inputMap_whenAncestorOfFocused.keys();
+ else
+ ks1 = new KeyStroke[0];
+ if (inputMap_whenInFocusedWindow != null)
+ ks2 = inputMap_whenInFocusedWindow.keys();
+ else
+ ks2 = new KeyStroke[0];
+ int count = ks0.length + ks1.length + ks2.length;
+ KeyStroke[] result = new KeyStroke[count];
+ System.arraycopy(ks0, 0, result, 0, ks0.length);
+ System.arraycopy(ks1, 0, result, ks0.length, ks1.length);
+ System.arraycopy(ks2, 0, result, ks0.length + ks1.length, ks2.length);
+ return result;
}
/**
@@ -1524,8 +1563,90 @@ public abstract class JComponent extends Container implements Serializable
{
return getToolTipText();
}
+
+ /**
+ * Returns the flag that controls whether or not the component inherits its
+ * parent's popup menu when no popup menu is specified for this component.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ *
+ * @see #setInheritsPopupMenu(boolean)
+ */
+ public boolean getInheritsPopupMenu()
+ {
+ return inheritsPopupMenu;
+ }
+
+ /**
+ * Sets the flag that controls whether or not the component inherits its
+ * parent's popup menu when no popup menu is specified for this component.
+ * This is a bound property with the property name 'inheritsPopupMenu'.
+ *
+ * @param inherit the new flag value.
+ *
+ * @since 1.5
+ *
+ * @see #getInheritsPopupMenu()
+ */
+ public void setInheritsPopupMenu(boolean inherit)
+ {
+ if (inheritsPopupMenu != inherit)
+ {
+ inheritsPopupMenu = inherit;
+ this.firePropertyChange("inheritsPopupMenu", ! inherit, inherit);
+ }
+ }
+
+ /**
+ * Returns the popup menu for this component. If the popup menu is
+ * <code>null</code> AND the {@link #getInheritsPopupMenu()} method returns
+ * <code>true</code>, this method will return the parent's popup menu (if it
+ * has one).
+ *
+ * @return The popup menu (possibly <code>null</code>.
+ *
+ * @since 1.5
+ *
+ * @see #setComponentPopupMenu(JPopupMenu)
+ * @see #getInheritsPopupMenu()
+ */
+ public JPopupMenu getComponentPopupMenu()
+ {
+ if (componentPopupMenu == null && getInheritsPopupMenu())
+ {
+ Container parent = getParent();
+ if (parent instanceof JComponent)
+ return ((JComponent) parent).getComponentPopupMenu();
+ else
+ return null;
+ }
+ else
+ return componentPopupMenu;
+ }
/**
+ * Sets the popup menu for this component (this is a bound property with
+ * the property name 'componentPopupMenu').
+ *
+ * @param popup the popup menu (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getComponentPopupMenu()
+ */
+ public void setComponentPopupMenu(JPopupMenu popup)
+ {
+ if (componentPopupMenu != popup)
+ {
+ JPopupMenu old = componentPopupMenu;
+ componentPopupMenu = popup;
+ firePropertyChange("componentPopupMenu", old, popup);
+ }
+ }
+
+ /**
* Return the top level ancestral container (usually a {@link
* java.awt.Window} or {@link java.applet.Applet}) which this component is
* contained within, or <code>null</code> if no ancestors exist.
@@ -1725,7 +1846,7 @@ public abstract class JComponent extends Container implements Serializable
// buffer. When this method completes, the call stack unwinds back to
// paintDoubleBuffered, where the buffer contents is finally drawn to the
// screen.
- if (!isPaintingDoubleBuffered && isDoubleBuffered()
+ if (!paintingDoubleBuffered && isDoubleBuffered()
&& rm.isDoubleBufferingEnabled())
{
Rectangle clip = g.getClipBounds();
@@ -1816,235 +1937,77 @@ public abstract class JComponent extends Container implements Serializable
{
if (getComponentCount() > 0)
{
- if (isOptimizedDrawingEnabled())
- paintChildrenOptimized(g);
- else
- paintChildrenWithOverlap(g);
- }
- }
-
- /**
- * Paints the children of this JComponent in the case when the component
- * is not marked as optimizedDrawingEnabled, that means the container cannot
- * guarantee that it's children are tiled. For this case we must
- * perform a more complex optimization to determine the minimal rectangle
- * to be painted for each child component.
- *
- * @param g the graphics context to use
- */
- private void paintChildrenWithOverlap(Graphics g)
- {
- Shape originalClip = g.getClip();
- Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache);
- g.clipRect(inner.x, inner.y, inner.width, inner.height);
- Component[] children = getComponents();
-
- // Find the rectangles that need to be painted for each child component.
- // We push on this list arrays that have the Rectangles to be painted as
- // the first elements and the component to be painted as the last one.
- // Later we go through that list in reverse order and paint the rectangles.
- ArrayList paintRegions = new ArrayList(children.length);
- ArrayList paintRectangles = new ArrayList();
- ArrayList newPaintRects = new ArrayList();
- paintRectangles.add(g.getClipBounds());
- ArrayList componentRectangles = new ArrayList();
-
- // Go through children from top to bottom and find out their paint
- // rectangles.
- for (int index = 0; paintRectangles.size() > 0 &&
- index < children.length; index++)
- {
- Component comp = children[index];
- if (! comp.isVisible())
- continue;
-
- Rectangle compBounds = comp.getBounds();
- boolean isOpaque = comp instanceof JComponent
- && ((JComponent) comp).isOpaque();
-
- // Add all the current paint rectangles that intersect with the
- // component to the component's paint rectangle array.
- for (int i = paintRectangles.size() - 1; i >= 0; i--)
+ // Need to lock the tree to avoid problems with AWT and concurrency.
+ synchronized (getTreeLock())
{
- Rectangle r = (Rectangle) paintRectangles.get(i);
- if (r.intersects(compBounds))
+ for (int i = getComponentCount() - 1; i >= 0; i--)
{
- Rectangle compRect = r.intersection(compBounds);
- componentRectangles.add(compRect);
- // If the component is opaque, split up each paint rect and
- // add paintRect - compBounds to the newPaintRects array.
- if (isOpaque)
+ Component child = getComponent(i);
+ if (child != null && child.isLightweight()
+ && child.isVisible())
{
- int x, y, w, h;
- Rectangle rect = new Rectangle();
-
- // The north retangle.
- x = Math.max(compBounds.x, r.x);
- y = r.y;
- w = Math.min(compBounds.width, r.width + r.x - x);
- h = compBounds.y - r.y;
- rect.setBounds(x, y, w, h);
- if (! rect.isEmpty())
- {
- newPaintRects.add(rect);
- rect = new Rectangle();
- }
-
- // The south rectangle.
- x = Math.max(compBounds.x, r.x);
- y = compBounds.y + compBounds.height;
- w = Math.min(compBounds.width, r.width + r.x - x);
- h = r.height - (compBounds.y - r.y) - compBounds.height;
- rect.setBounds(x, y, w, h);
- if (! rect.isEmpty())
- {
- newPaintRects.add(rect);
- rect = new Rectangle();
- }
-
- // The west rectangle.
- x = r.x;
- y = r.y;
- w = compBounds.x - r.x;
- h = r.height;
- rect.setBounds(x, y, w, h);
- if (! rect.isEmpty())
+ int cx = child.getX();
+ int cy = child.getY();
+ int cw = child.getWidth();
+ int ch = child.getHeight();
+ if (g.hitClip(cx, cy, cw, ch))
{
- newPaintRects.add(rect);
- rect = new Rectangle();
- }
-
- // The east rectangle.
- x = compBounds.x + compBounds.width;
- y = r.y;
- w = r.width - (compBounds.x - r.x) - compBounds.width;
- h = r.height;
- rect.setBounds(x, y, w, h);
- if (! rect.isEmpty())
- {
- newPaintRects.add(rect);
+ if ((! isOptimizedDrawingEnabled()) && i > 0)
+ {
+ // Check if the child is completely obscured.
+ Rectangle clip = g.getClipBounds(); // A copy.
+ SwingUtilities.computeIntersection(cx, cy, cw, ch,
+ clip);
+ if (isCompletelyObscured(i, clip))
+ continue; // Continues the for-loop.
+ }
+ Graphics cg = g.create(cx, cy, cw, ch);
+ cg.setColor(child.getForeground());
+ cg.setFont(child.getFont());
+ try
+ {
+ child.paint(cg);
+ }
+ finally
+ {
+ cg.dispose();
+ }
}
}
- else
- {
- // Not opaque, need to reuse the current paint rectangles
- // for the next component.
- newPaintRects.add(r);
- }
-
- }
- else
- {
- newPaintRects.add(r);
}
}
-
- // Replace the paintRectangles with the new split up
- // paintRectangles.
- paintRectangles.clear();
- paintRectangles.addAll(newPaintRects);
- newPaintRects.clear();
-
- // Store paint rectangles if there are any for the current component.
- int compRectsSize = componentRectangles.size();
- if (compRectsSize > 0)
- {
- componentRectangles.add(comp);
- paintRegions.add(componentRectangles);
- componentRectangles = new ArrayList();
- }
}
-
- // paintingTile becomes true just before we start painting the component's
- // children.
- paintingTile = true;
-
- // We must go through the painting regions backwards, because the
- // topmost components have been added first, followed by the components
- // below.
- int prEndIndex = paintRegions.size() - 1;
- for (int i = prEndIndex; i >= 0; i--)
- {
- // paintingTile must be set to false before we begin to start painting
- // the last tile.
- if (i == 0)
- paintingTile = false;
-
- ArrayList paintingRects = (ArrayList) paintRegions.get(i);
- // The last element is always the component.
- Component c = (Component) paintingRects.get(paintingRects.size() - 1);
- int endIndex = paintingRects.size() - 2;
- for (int j = 0; j <= endIndex; j++)
- {
- Rectangle cBounds = c.getBounds();
- Rectangle bounds = (Rectangle) paintingRects.get(j);
- Rectangle oldClip = g.getClipBounds();
- if (oldClip == null)
- oldClip = bounds;
-
- boolean translated = false;
- try
- {
- g.setClip(bounds);
- g.translate(cBounds.x, cBounds.y);
- translated = true;
- c.paint(g);
- }
- finally
- {
- if (translated)
- g.translate(-cBounds.x, -cBounds.y);
- g.setClip(oldClip);
- }
- }
- }
- g.setClip(originalClip);
}
/**
- * Paints the children of this container when it is marked as
- * optimizedDrawingEnabled. In this case the container can guarantee that
- * it's children are tiled, which allows for a much more efficient
- * algorithm to determine the minimum rectangles to be painted for
- * each child.
+ * Determines if a region of a child component is completely obscured by one
+ * of its siblings.
+ *
+ * @param index the index of the child component
+ * @param rect the region to check
*
- * @param g the graphics context to use
+ * @return <code>true</code> if the region is completely obscured by a
+ * sibling, <code>false</code> otherwise
*/
- private void paintChildrenOptimized(Graphics g)
+ private boolean isCompletelyObscured(int index, Rectangle rect)
{
- Shape originalClip = g.getClip();
- Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache);
- g.clipRect(inner.x, inner.y, inner.width, inner.height);
- Component[] children = getComponents();
-
- // paintingTile becomes true just before we start painting the component's
- // children.
- paintingTile = true;
- for (int i = children.length - 1; i >= 0; i--) //children.length; i++)
+ boolean obscured = false;
+ for (int i = index - 1; i >= 0 && obscured == false; i--)
{
- // paintingTile must be set to false before we begin to start painting
- // the last tile.
- if (i == children.length - 1)
- paintingTile = false;
-
- if (!children[i].isVisible())
- continue;
-
- Rectangle bounds = children[i].getBounds(rectCache);
- Rectangle oldClip = g.getClipBounds();
- if (oldClip == null)
- oldClip = bounds;
-
- if (!g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height))
- continue;
-
- boolean translated = false;
- Graphics g2 = g.create(bounds.x, bounds.y, bounds.width,
- bounds.height);
- children[i].paint(g2);
- g2.dispose();
+ Component sib = getComponent(i);
+ if (sib.isVisible())
+ {
+ Rectangle sibRect = sib.getBounds(rectCache);
+ if (sib.isOpaque() && rect.x >= sibRect.x
+ && (rect.x + rect.width) <= (sibRect.x + sibRect.width)
+ && rect.y >= sibRect.y
+ && (rect.y + rect.height) <= (sibRect.y + sibRect.height))
+ {
+ obscured = true;
+ }
+ }
}
- g.setClip(originalClip);
+ return obscured;
}
/**
@@ -2064,12 +2027,15 @@ public abstract class JComponent extends Container implements Serializable
{
if (ui != null)
{
- Graphics g2 = g;
- if (!(g instanceof Graphics2D))
- g2 = g.create();
- ui.update(g2, this);
- if (!(g instanceof Graphics2D))
- g2.dispose();
+ Graphics g2 = g.create();
+ try
+ {
+ ui.update(g2, this);
+ }
+ finally
+ {
+ g2.dispose();
+ }
}
}
@@ -2112,16 +2078,13 @@ public abstract class JComponent extends Container implements Serializable
Component root = findPaintRoot(r);
// If no paint root is found, then this component is completely overlapped
// by another component and we don't need repainting.
- if (root == null)
+ if (root == null|| !root.isShowing())
return;
- if (root == null || !root.isShowing())
- return;
-
- Rectangle rootClip = SwingUtilities.convertRectangle(this, r, root);
+ SwingUtilities.convertRectangleToAncestor(this, r, root);
if (root instanceof JComponent)
- ((JComponent) root).paintImmediately2(rootClip);
+ ((JComponent) root).paintImmediately2(r);
else
- root.repaint(rootClip.x, rootClip.y, rootClip.width, rootClip.height);
+ root.repaint(r.x, r.y, r.width, r.height);
}
/**
@@ -2131,40 +2094,35 @@ public abstract class JComponent extends Container implements Serializable
*/
void paintImmediately2(Rectangle r)
{
+ isRepainting = true;
RepaintManager rm = RepaintManager.currentManager(this);
- if (rm.isDoubleBufferingEnabled() && isDoubleBuffered())
+ if (rm.isDoubleBufferingEnabled() && isPaintingDoubleBuffered())
paintDoubleBuffered(r);
else
paintSimple(r);
+ isRepainting = false;
}
/**
- * Gets the root of the component given. If a parent of the
- * component is an instance of Applet, then the applet is
- * returned. The applet is considered the root for painting
- * and adding/removing components. Otherwise, the root Window
- * is returned if it exists.
- *
- * @param comp - The component to get the root for.
- * @return the parent root. An applet if it is a parent,
- * or the root window. If neither exist, null is returned.
+ * Returns true if we must paint double buffered, that is, when this
+ * component or any of it's ancestors are double buffered.
+ *
+ * @return true if we must paint double buffered, that is, when this
+ * component or any of it's ancestors are double buffered
*/
- private Component getRoot(Component comp)
+ private boolean isPaintingDoubleBuffered()
{
- Applet app = null;
-
- while (comp != null)
- {
- if (app == null && comp instanceof Window)
- return comp;
- else if (comp instanceof Applet)
- app = (Applet) comp;
- comp = comp.getParent();
- }
-
- return app;
+ boolean doubleBuffered = isDoubleBuffered();
+ Component parent = getParent();
+ while (! doubleBuffered && parent != null)
+ {
+ doubleBuffered = parent instanceof JComponent
+ && ((JComponent) parent).isDoubleBuffered();
+ parent = parent.getParent();
+ }
+ return doubleBuffered;
}
-
+
/**
* Performs double buffered repainting.
*/
@@ -2173,7 +2131,7 @@ public abstract class JComponent extends Container implements Serializable
RepaintManager rm = RepaintManager.currentManager(this);
// Paint on the offscreen buffer.
- Component root = getRoot(this);
+ Component root = SwingUtilities.getRoot(this);
Image buffer = rm.getVolatileOffscreenBuffer(this, root.getWidth(),
root.getHeight());
@@ -2183,26 +2141,30 @@ public abstract class JComponent extends Container implements Serializable
buffer = rm.getOffscreenBuffer(this, root.getWidth(), root.getHeight());
//Rectangle targetClip = SwingUtilities.convertRectangle(this, r, root);
- Point translation = SwingUtilities.convertPoint(this, 0, 0, root);
Graphics g2 = buffer.getGraphics();
clipAndTranslateGraphics(root, this, g2);
g2.clipRect(r.x, r.y, r.width, r.height);
g2 = getComponentGraphics(g2);
- isPaintingDoubleBuffered = true;
+ paintingDoubleBuffered = true;
try
{
- paint(g2);
+ if (isRepainting) // Called from paintImmediately, go through paint().
+ paint(g2);
+ else // Called from paint() (AWT refresh), don't call it again.
+ {
+ paintComponent(g2);
+ paintBorder(g2);
+ paintChildren(g2);
+ }
}
finally
{
- isPaintingDoubleBuffered = false;
+ paintingDoubleBuffered = false;
g2.dispose();
}
// Paint the buffer contents on screen.
- rm.commitBuffer(root, new Rectangle(translation.x + r.x,
- translation.y + r.y, r.width,
- r.height));
+ rm.commitBuffer(this, r);
}
/**
@@ -2217,11 +2179,16 @@ public abstract class JComponent extends Container implements Serializable
private void clipAndTranslateGraphics(Component root, Component target,
Graphics g)
{
- Component parent = target.getParent();
- if (parent != root)
- clipAndTranslateGraphics(root, parent, g);
-
- g.translate(target.getX(), target.getY());
+ Component parent = target;
+ int deltaX = 0;
+ int deltaY = 0;
+ while (parent != root)
+ {
+ deltaX += parent.getX();
+ deltaY += parent.getY();
+ parent = parent.getParent();
+ }
+ g.translate(deltaX, deltaY);
g.clipRect(0, 0, target.getWidth(), target.getHeight());
}
@@ -2271,7 +2238,13 @@ public abstract class JComponent extends Container implements Serializable
/**
* A variant of {@link
* #registerKeyboardAction(ActionListener,String,KeyStroke,int)} which
- * provides <code>null</code> for the command name.
+ * provides <code>null</code> for the command name.
+ *
+ * @param act the action listener to notify when the keystroke occurs.
+ * @param stroke the key stroke.
+ * @param cond the condition (one of {@link #WHEN_FOCUSED},
+ * {@link #WHEN_IN_FOCUSED_WINDOW} and
+ * {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}).
*/
public void registerKeyboardAction(ActionListener act,
KeyStroke stroke,
@@ -2348,9 +2321,22 @@ public abstract class JComponent extends Container implements Serializable
KeyStroke stroke,
int cond)
{
- getInputMap(cond).put(stroke, new ActionListenerProxy(act, cmd));
+ ActionListenerProxy proxy = new ActionListenerProxy(act, cmd);
+ getInputMap(cond).put(stroke, proxy);
+ getActionMap().put(proxy, proxy);
}
+ /**
+ * Sets the input map for the given condition.
+ *
+ * @param condition the condition (one of {@link #WHEN_FOCUSED},
+ * {@link #WHEN_IN_FOCUSED_WINDOW} and
+ * {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}).
+ * @param map the map.
+ *
+ * @throws IllegalArgumentException if <code>condition</code> is not one of
+ * the specified values.
+ */
public final void setInputMap(int condition, InputMap map)
{
enableEvents(AWTEvent.KEY_EVENT_MASK);
@@ -2486,13 +2472,17 @@ public abstract class JComponent extends Container implements Serializable
*/
public ActionListener getActionForKeyStroke(KeyStroke ks)
{
- Object cmd = getInputMap().get(ks);
- if (cmd != null)
+ Object key = getInputMap(JComponent.WHEN_FOCUSED).get(ks);
+ if (key == null)
+ key = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(ks);
+ if (key == null)
+ key = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(ks);
+ if (key != null)
{
- if (cmd instanceof ActionListenerProxy)
- return (ActionListenerProxy) cmd;
- else if (cmd instanceof String)
- return getActionMap().get(cmd);
+ if (key instanceof ActionListenerProxy)
+ return ((ActionListenerProxy) key).target;
+ else
+ return getActionMap().get(key);
}
return null;
}
@@ -2591,10 +2581,11 @@ public abstract class JComponent extends Container implements Serializable
if (isEnabled())
{
Action act = null;
+ Object cmd = null;
InputMap map = getInputMap(condition);
if (map != null)
{
- Object cmd = map.get(ks);
+ cmd = map.get(ks);
if (cmd != null)
{
if (cmd instanceof ActionListenerProxy)
@@ -2604,7 +2595,23 @@ public abstract class JComponent extends Container implements Serializable
}
}
if (act != null && act.isEnabled())
- return SwingUtilities.notifyAction(act, ks, e, this, e.getModifiers());
+ {
+ // Need to synchronize here so we don't get in trouble with
+ // our __command__ hack.
+ synchronized (act)
+ {
+ // We add the command as value to the action, so that
+ // the action can later determine the command with which it
+ // was called. This is undocumented, but shouldn't affect
+ // compatibility. It allows us to use only one Action instance
+ // to do the work for all components of one type, instead of
+ // having loads of small Actions. This effectivly saves startup
+ // time of Swing.
+ act.putValue("__command__", cmd);
+ return SwingUtilities.notifyAction(act, ks, e, this,
+ e.getModifiers());
+ }
+ }
}
return false;
}
@@ -2706,6 +2713,11 @@ public abstract class JComponent extends Container implements Serializable
*/
public void revalidate()
{
+ // As long as we don't have a parent we don't need to do any layout, since
+ // this is done anyway as soon as we get connected to a parent.
+ if (getParent() == null)
+ return;
+
if (! EventQueue.isDispatchThread())
SwingUtilities.invokeLater(new Runnable()
{
@@ -3089,11 +3101,29 @@ public abstract class JComponent extends Container implements Serializable
// Nothing to do here.
}
+ /**
+ * Returns the locale used as the default for all new components. The
+ * default value is {@link Locale#getDefault()} (that is, the platform
+ * default locale).
+ *
+ * @return The locale (never <code>null</code>).
+ *
+ * @see #setDefaultLocale(Locale)
+ */
public static Locale getDefaultLocale()
{
+ if (defaultLocale == null)
+ defaultLocale = Locale.getDefault();
return defaultLocale;
}
+ /**
+ * Sets the locale to be used as the default for all new components. If this
+ * is set to <code>null</code>, the {@link #getDefaultLocale()} method will
+ * return the platform default locale.
+ *
+ * @param l the locale (<code>null</code> permitted).
+ */
public static void setDefaultLocale(Locale l)
{
defaultLocale = l;
@@ -3531,12 +3561,13 @@ public abstract class JComponent extends Container implements Serializable
}
}
// Dispatch event to all children.
- Component[] children = getComponents();
- for (int i = 0; i < children.length; i++)
+ int numChildren = getComponentCount();
+ for (int i = 0; i < numChildren; i++)
{
- if (!(children[i] instanceof JComponent))
+ Component child = getComponent(i);
+ if (! (child instanceof JComponent))
continue;
- JComponent jc = (JComponent) children[i];
+ JComponent jc = (JComponent) child;
jc.fireAncestorEvent(ancestor, id);
}
}
@@ -3619,10 +3650,10 @@ public abstract class JComponent extends Container implements Serializable
! SwingUtilities.isRectangleContainingRectangle(parentRect, target);
if (! haveOverlap)
{
- Component[] children = newParent.getComponents();
- for (int i = 0; children[i] != parent && !haveOverlap; i++)
+ Component child;
+ for (int i = 0; (child = newParent.getComponent(i)) != parent && !haveOverlap; i++)
{
- Rectangle childRect = children[i].getBounds();
+ Rectangle childRect = child.getBounds();
haveOverlap = target.intersects(childRect);
}
}
@@ -3654,7 +3685,7 @@ public abstract class JComponent extends Container implements Serializable
{
if ((found instanceof JComponent) && ((JComponent) found).isOpaque())
break;
- else if (!(found instanceof JComponent))
+ else if (!(found instanceof JComponent) && !found.isLightweight())
break;
Container p = found.getParent();
if (p == null)
diff --git a/libjava/classpath/javax/swing/JFileChooser.java b/libjava/classpath/javax/swing/JFileChooser.java
index 64f9bd0f4e6..a508b8fcb20 100644
--- a/libjava/classpath/javax/swing/JFileChooser.java
+++ b/libjava/classpath/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/libjava/classpath/javax/swing/JInternalFrame.java b/libjava/classpath/javax/swing/JInternalFrame.java
index 79dcc7326be..ff3ae1faa66 100644
--- a/libjava/classpath/javax/swing/JInternalFrame.java
+++ b/libjava/classpath/javax/swing/JInternalFrame.java
@@ -38,9 +38,11 @@ exception statement from your version. */
package javax.swing;
+import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
+import java.awt.IllegalComponentStateException;
import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager;
import java.awt.Rectangle;
@@ -490,12 +492,6 @@ public class JInternalFrame extends JComponent implements Accessible,
/** Whether the JInternalFrame has become visible for the very first time. */
private transient boolean isFirstTimeVisible = true;
- /**
- * Whether the JInternalFrame is in the transition from being a maximized
- * frame back to a regular sized frame.
- */
- private transient boolean maxTransition = false;
-
/** DOCUMENT ME! */
private transient boolean wasIcon = false;
@@ -581,11 +577,12 @@ public class JInternalFrame extends JComponent implements Accessible,
this.closable = closable;
this.maximizable = maximizable;
this.iconable = iconifiable;
- storedBounds = new Rectangle();
+ isMaximum = false;
setRootPane(createRootPane());
// JInternalFrames are invisible and opaque by default.
setVisible(false);
setOpaque(true);
+ desktopIcon = new JDesktopIcon(this);
updateUI();
setRootPaneCheckingEnabled(true); // Done the init stage, now adds go to content pane.
}
@@ -643,24 +640,25 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void dispose()
{
- setVisible(false);
- JDesktopPane pane = getDesktopPane();
- if (pane != null)
- pane.setSelectedFrame(null);
- else
+ if (isVisible())
+ setVisible(false);
+ if (isSelected())
{
- try
- {
- setSelected(false);
- }
- catch (PropertyVetoException e)
- {
- // Do nothing if they don't want to be unselected.
- }
+ try
+ {
+ setSelected(false);
+ }
+ catch (PropertyVetoException e)
+ {
+ // Do nothing if they don't want to be unselected.
+ }
+ }
+ if (! isClosed)
+ {
+ firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE, Boolean.TRUE);
+ isClosed = true;
}
- isClosed = true;
fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
- removeNotify();
}
/**
@@ -799,8 +797,6 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public JDesktopIcon getDesktopIcon()
{
- if (desktopIcon == null)
- desktopIcon = new JDesktopIcon(this);
return desktopIcon;
}
@@ -904,18 +900,7 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public int getLayer()
{
- JDesktopPane pane = getDesktopPane();
- if (pane != null)
- // The cast here forces the call to the instance method getLayer()
- // instead of the static method (this would lead to infinite
- // recursion).
- return pane.getLayer((Component) this);
-
- Integer layer = (Integer) getClientProperty(JLayeredPane.LAYER_PROPERTY);
- if (layer != null)
- return layer.intValue();
-
- return JLayeredPane.DEFAULT_LAYER.intValue();
+ return JLayeredPane.getLayer(this);
}
/**
@@ -970,7 +955,7 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public Rectangle getNormalBounds()
{
- if (! isMaximum() && ! maxTransition)
+ if (storedBounds == null)
return getBounds();
else
return storedBounds;
@@ -1035,20 +1020,8 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void hide()
{
- JDesktopPane pane = getDesktopPane();
- if (pane != null)
- pane.setSelectedFrame(null);
- else
- {
- try
- {
- setSelected(false);
- }
- catch (PropertyVetoException e)
- {
- // Do nothing.
- }
- }
+ if (isIcon())
+ getDesktopIcon().hide();
super.hide();
}
@@ -1162,8 +1135,9 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void moveToBack()
{
- if (getParent() instanceof JLayeredPane)
- ((JLayeredPane) getParent()).moveToBack(this);
+ Container p = getParent();
+ if (p instanceof JLayeredPane)
+ ((JLayeredPane) p).moveToBack(this);
}
/**
@@ -1172,8 +1146,9 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void moveToFront()
{
- if (getParent() instanceof JLayeredPane)
- ((JLayeredPane) getParent()).moveToFront(this);
+ Container p = getParent();
+ if (p != null && p instanceof JLayeredPane)
+ ((JLayeredPane) p).moveToFront(this);
}
/**
@@ -1196,6 +1171,7 @@ public class JInternalFrame extends JComponent implements Accessible,
// Do nothing if they don't want to be restored first.
}
setSize(getPreferredSize());
+ validate();
}
/**
@@ -1311,7 +1287,6 @@ public class JInternalFrame extends JComponent implements Accessible,
dispose();
firePropertyChange(IS_CLOSED_PROPERTY, false, true);
- fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
}
}
@@ -1468,7 +1443,9 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setJMenuBar(JMenuBar b)
{
+ JMenuBar old = getJMenuBar();
getRootPane().setJMenuBar(b);
+ firePropertyChange(MENU_BAR_PROPERTY, old, b);
}
/**
@@ -1493,11 +1470,17 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setLayer(Integer layer)
{
- JDesktopPane p = getDesktopPane();
- if (p != null)
+ Container p = getParent();
+ if (p instanceof JLayeredPane)
{
- int pos = p.getPosition(this);
- p.setLayer(this, layer.intValue(), pos);
+ JLayeredPane lp = (JLayeredPane) p;
+ lp.setLayer(this, layer.intValue(), lp.getPosition(this));
+ }
+ else
+ {
+ JLayeredPane.putLayer(this, layer.intValue());
+ if (p != null)
+ p.repaint(getX(), getY(), getWidth(), getHeight());
}
}
@@ -1508,6 +1491,9 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setLayeredPane(JLayeredPane layered)
{
+ if (layered == null)
+ throw new IllegalComponentStateException("LayeredPane must not be null");
+
if (layered != getLayeredPane())
{
JLayeredPane old = getLayeredPane();
@@ -1561,15 +1547,11 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setMaximum(boolean b) throws PropertyVetoException
{
- if (b != isMaximum())
+ if (b != isMaximum)
{
- fireVetoableChange(IS_MAXIMUM_PROPERTY, b, isMaximum);
+ fireVetoableChange(IS_MAXIMUM_PROPERTY, isMaximum, b);
isMaximum = b;
- if (b)
- setNormalBounds(getBounds());
- maxTransition = ! b;
firePropertyChange(IS_MAXIMUM_PROPERTY, ! isMaximum, isMaximum);
- maxTransition = false;
}
}
@@ -1593,7 +1575,7 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setNormalBounds(Rectangle r)
{
- storedBounds.setBounds(r.x, r.y, r.width, r.height);
+ storedBounds = r;
}
/**
@@ -1621,8 +1603,23 @@ public class JInternalFrame extends JComponent implements Accessible,
if (rootPane != null)
remove(rootPane);
+ JRootPane old = rootPane;
rootPane = root;
- add(root);
+
+ if (rootPane != null)
+ {
+ boolean checkingEnabled = isRootPaneCheckingEnabled();
+ try
+ {
+ setRootPaneCheckingEnabled(false);
+ add(rootPane, BorderLayout.CENTER);
+ }
+ finally
+ {
+ setRootPaneCheckingEnabled(checkingEnabled);
+ }
+ }
+ firePropertyChange(ROOT_PANE_PROPERTY, old, rootPane);
}
/**
@@ -1652,27 +1649,26 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setSelected(boolean selected) throws PropertyVetoException
{
- if (selected != isSelected())
+ if (selected != isSelected
+ && (! selected || (isIcon ? desktopIcon.isShowing() : isShowing())))
{
- fireVetoableChange(IS_SELECTED_PROPERTY, selected, isSelected);
-
- if (! selected)
- defaultFocus = getMostRecentFocusOwner();
+ fireVetoableChange(IS_SELECTED_PROPERTY, isSelected, selected);
- isSelected = selected;
+ if (! selected)
+ defaultFocus = getMostRecentFocusOwner();
- if (selected)
- restoreSubcomponentFocus();
+ isSelected = selected;
+ firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected);
- if (isShowing())
- repaint();
+ if (isSelected)
+ fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
+ else
+ fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
- firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected);
+ if (selected)
+ restoreSubcomponentFocus();
- if (isSelected)
- fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
- else
- fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
+ repaint();
}
}
@@ -1687,14 +1683,9 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setTitle(String title)
{
- if (title == null && this.title == null)
- return;
- if (title == null || this.title == null || ! this.title.equals(title))
- {
- String old = this.title;
- this.title = title;
- firePropertyChange(TITLE_PROPERTY, old, this.title);
- }
+ String old = this.title;
+ this.title = title;
+ firePropertyChange(TITLE_PROPERTY, old, this.title);
}
/**
@@ -1707,12 +1698,21 @@ public class JInternalFrame extends JComponent implements Accessible,
{
if (! isVisible())
{
+ if (isFirstTimeVisible)
+ {
+ isFirstTimeVisible = false;
+ fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
+ }
+
+ getDesktopIcon().setVisible(true);
+
+ toFront();
super.show();
- JDesktopPane pane = getDesktopPane();
- if (pane != null)
- pane.setSelectedFrame(this);
- else
+ if (isIcon())
+ return;
+
+ if (! isSelected())
{
try
{
@@ -1723,11 +1723,6 @@ public class JInternalFrame extends JComponent implements Accessible,
// Do nothing. if they don't want to be selected.
}
}
- if (isFirstTimeVisible)
- {
- isFirstTimeVisible = false;
- fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
- }
}
}
diff --git a/libjava/classpath/javax/swing/JLabel.java b/libjava/classpath/javax/swing/JLabel.java
index a5fe3ba1af0..fcf0fd7cb13 100644
--- a/libjava/classpath/javax/swing/JLabel.java
+++ b/libjava/classpath/javax/swing/JLabel.java
@@ -46,6 +46,7 @@ import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@@ -57,7 +58,7 @@ import javax.swing.text.AttributeSet;
import javax.swing.text.SimpleAttributeSet;
/**
- * A swing widget that displays a text message and/or an icon.
+ * A component that displays a static text message and/or an icon.
*/
public class JLabel extends JComponent implements Accessible, SwingConstants
{
@@ -359,7 +360,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
/** The label's mnemnonic key. */
private transient int displayedMnemonic = KeyEvent.VK_UNDEFINED;
- /** The index of the menemonic character in the text. */
+ /** The index of the mnemonic character in the text. */
private transient int displayedMnemonicIndex = -1;
/** The gap between the icon and the text. */
@@ -435,11 +436,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
this.icon = icon;
this.horizontalAlignment = horizontalAlignment;
setAlignmentX(0.0F);
+ setInheritsPopupMenu(true);
updateUI();
}
/**
- * This method returns the label's UI delegate.
+ * Returns the label's UI delegate.
*
* @return The label's UI delegate.
*/
@@ -449,9 +451,9 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method sets the label's UI delegate.
+ * Sets the label's UI delegate.
*
- * @param ui The label's UI delegate.
+ * @param ui The label's UI delegate (<code>null</code> not permitted).
*/
public void setUI(LabelUI ui)
{
@@ -459,8 +461,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method resets the label's UI delegate to the default UI for the
- * current look and feel.
+ * Resets the label's UI delegate to the default UI for the current look and
+ * feel.
*/
public void updateUI()
{
@@ -468,10 +470,10 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns a name to identify which look and feel class will be
+ * Returns a name to identify which look and feel class will be
* the UI delegate for this label.
*
- * @return The UIClass identifier. "LabelUI"
+ * @return <code>"LabelUI"</code>
*/
public String getUIClassID()
{
@@ -518,9 +520,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the label text.
+ * Returns the text displayed by the label.
*
- * @return The label text.
+ * @return The label text (possibly <code>null</code>).
+ *
+ * @see #setText(String)
*/
public String getText()
{
@@ -528,31 +532,42 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "text" property. The given text will be painted
- * in the label.
+ * Sets the text for the label and sends a {@link PropertyChangeEvent} (with
+ * the name 'text') to all registered listeners. This method will also
+ * update the <code>displayedMnemonicIndex</code>, if necessary.
*
- * @param newText The label's text.
+ * @param newText The text (<code>null</code> permitted).
+ *
+ * @see #getText()
+ * @see #getDisplayedMnemonicIndex()
*/
public void setText(String newText)
{
- if (text != newText)
- {
- String oldText = text;
- text = newText;
- firePropertyChange("text", oldText, newText);
+ if (text == null && newText == null)
+ return;
+ if (text != null && text.equals(newText))
+ return;
- if (text != null && text.length() <= displayedMnemonicIndex)
- setDisplayedMnemonicIndex(text.length() - 1);
- revalidate();
- repaint();
- }
+ String oldText = text;
+ text = newText;
+ firePropertyChange("text", oldText, newText);
+
+ if (text != null)
+ setDisplayedMnemonicIndex(text.toUpperCase().indexOf(displayedMnemonic));
+ else
+ setDisplayedMnemonicIndex(-1);
+ revalidate();
+ repaint();
}
/**
- * This method returns the active icon. The active icon is painted when the
- * label is enabled.
+ * Returns the active icon. The active icon is painted when the label is
+ * enabled.
*
* @return The active icon.
+ *
+ * @see #setIcon(Icon)
+ * @see #getDisabledIcon()
*/
public Icon getIcon()
{
@@ -560,81 +575,93 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "icon" property. This icon (the active icon) will
- * be the one displayed when the label is enabled.
+ * Sets the icon for the label (this is a bound property with the name
+ * 'icon'). This icon will be displayed when the label is enabled.
*
- * @param newIcon The active icon.
+ * @param newIcon The icon (<code>null</code> permitted).
+ *
+ * @see #getIcon()
+ * @see #setDisabledIcon(Icon)
*/
public void setIcon(Icon newIcon)
{
if (icon != newIcon)
{
- Icon oldIcon = icon;
- icon = newIcon;
- firePropertyChange("icon", oldIcon, newIcon);
- repaint();
+ Icon oldIcon = icon;
+ icon = newIcon;
+ firePropertyChange("icon", oldIcon, newIcon);
+ repaint();
}
}
/**
- * This method returns the disabled icon. The disabled icon is painted when
- * the label is disabled. If the disabled icon is null and the active icon
- * is an ImageIcon, this method returns a grayed version of the icon. The
- * grayed version of the icon becomes the disabledIcon.
+ * Returns the disabled icon. The disabled icon is painted when the label is
+ * disabled. If the disabled icon is <code>null</code> and the active icon
+ * is an {@link ImageIcon}, this method returns a grayed version of the icon.
+ * The grayed version of the icon becomes the <code>disabledIcon</code>.
*
* @return The disabled icon.
+ *
+ * @see #setDisabledIcon(Icon)
*/
public Icon getDisabledIcon()
{
if (disabledIcon == null && icon instanceof ImageIcon)
- disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon)
- .getImage()));
+ disabledIcon = new ImageIcon(
+ GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
return disabledIcon;
}
/**
- * This method changes the "disabledIcon" property. This icon (the disabled
- * icon) will be the one displayed when the label is disabled.
+ * Sets the icon displayed when the label is disabled (this is a bound
+ * property with the name 'disabledIcon').
*
- * @param newIcon The disabled icon.
+ * @param newIcon The disabled icon (<code>null</code> permitted).
+ *
+ * @see #getDisabledIcon()
*/
public void setDisabledIcon(Icon newIcon)
{
if (disabledIcon != newIcon)
{
- Icon oldIcon = disabledIcon;
- disabledIcon = newIcon;
- firePropertyChange("disabledIcon", oldIcon, newIcon);
+ Icon oldIcon = disabledIcon;
+ disabledIcon = newIcon;
+ firePropertyChange("disabledIcon", oldIcon, newIcon);
}
}
/**
- * This method sets the keycode that will be the label's mnemonic. If the
- * label is used as a label for another component, the label will give
- * focus to that component when the mnemonic is activated.
+ * Sets the keycode that will be the label's mnemonic (this is a bound
+ * property with the name 'displayedMnemonic'). If the label is used as a
+ * label for another component, the label will give focus to that component
+ * when the mnemonic is activated.
*
* @param mnemonic The keycode to use for the mnemonic.
+ *
+ * @see #getDisplayedMnemonic()
*/
public void setDisplayedMnemonic(int mnemonic)
{
if (displayedMnemonic != mnemonic)
{
- firePropertyChange("displayedMnemonic",
- displayedMnemonic, mnemonic);
- displayedMnemonic = mnemonic;
-
- if (text != null)
- setDisplayedMnemonicIndex(text.toUpperCase().indexOf(mnemonic));
+ int old = displayedMnemonic;
+ displayedMnemonic = mnemonic;
+ firePropertyChange("displayedMnemonic", old, displayedMnemonic);
+ if (text != null)
+ setDisplayedMnemonicIndex(text.toUpperCase().indexOf(mnemonic));
}
}
/**
- * This method sets the character that will be the mnemonic used. If the
+ * Sets the character that will be the label's mnemonic. If the
* label is used as a label for another component, the label will give
- * focus to that component when the mnemonic is activated.
+ * focus to that component when the mnemonic is activated via the keyboard.
*
- * @param mnemonic The character to use for the mnemonic.
+ * @param mnemonic The character to use for the mnemonic (this will be
+ * converted to the equivalent upper case character).
+ *
+ * @see #getDisplayedMnemonic()
*/
public void setDisplayedMnemonic(char mnemonic)
{
@@ -642,51 +669,63 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the keycode that is used for the label's mnemonic.
+ * Returns the keycode that is used for the label's mnemonic.
*
* @return The keycode that is used for the label's mnemonic.
+ *
+ * @see #setDisplayedMnemonic(int)
*/
public int getDisplayedMnemonic()
{
- return (int) displayedMnemonic;
+ return displayedMnemonic;
}
/**
- * This method sets which character in the text will be the underlined
- * character. If the given index is -1, then this indicates that there is
- * no mnemonic. If the index is less than -1 or if the index is equal to
- * the length, this method will throw an IllegalArgumentException.
+ * Sets the index of the character in the text that will be underlined to
+ * indicate that it is the mnemonic character for the label. You only need
+ * to call this method if you wish to override the automatically calculated
+ * character index. For instance, for a label "Find Next" with the mnemonic
+ * character 'n', you might wish to underline the second occurrence of 'n'
+ * rather than the first (which is the default).
+ * <br><br>
+ * Note that this method does not validate the character at the specified
+ * index to ensure that it matches the key code returned by
+ * {@link #getDisplayedMnemonic()}.
*
* @param newIndex The index of the character to underline.
*
- * @throws IllegalArgumentException If index less than -1 or index equals
- * length.
+ * @throws IllegalArgumentException If index less than -1 or index is greater
+ * than or equal to the label length.
+ *
+ * @see #getDisplayedMnemonicIndex()
+ * @since 1.4
*/
public void setDisplayedMnemonicIndex(int newIndex)
throws IllegalArgumentException
{
- if (newIndex < -1 || (text != null && newIndex >= text.length()))
+ int maxValid = -1;
+ if (text != null)
+ maxValid = text.length() - 1;
+ if (newIndex < -1 || newIndex > maxValid)
throw new IllegalArgumentException();
- if (newIndex == -1
- || text == null
- || text.charAt(newIndex) != displayedMnemonic)
- newIndex = -1;
-
if (newIndex != displayedMnemonicIndex)
{
- int oldIndex = displayedMnemonicIndex;
- displayedMnemonicIndex = newIndex;
- firePropertyChange("displayedMnemonicIndex",
- oldIndex, newIndex);
+ int oldIndex = displayedMnemonicIndex;
+ displayedMnemonicIndex = newIndex;
+ firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex);
}
}
/**
- * This method returns which character in the text will be the underlined
- * character.
+ * Returns the index of the character in the label's text that will be
+ * underlined (to indicate that it is the mnemonic character), or -1 if no
+ * character is to be underlined.
*
* @return The index of the character that will be underlined.
+ *
+ * @see #setDisplayedMnemonicIndex(int)
+ * @since 1.4
*/
public int getDisplayedMnemonicIndex()
{
@@ -694,14 +733,16 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method ensures that the key is valid as a horizontal alignment.
- * Valid keys are: LEFT, CENTER, RIGHT, LEADING, TRAILING
+ * Checks the specified key to ensure that it is valid as a horizontal
+ * alignment, throwing an {@link IllegalArgumentException} if the key is
+ * invalid. Valid keys are {@link #LEFT}, {@link #CENTER}, {@link #RIGHT},
+ * {@link #LEADING} and {@link #TRAILING}.
*
* @param key The key to check.
* @param message The message of the exception to be thrown if the key is
* invalid.
*
- * @return The key if it's valid.
+ * @return The key if it is valid.
*
* @throws IllegalArgumentException If the key is invalid.
*/
@@ -715,14 +756,15 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method ensures that the key is valid as a vertical alignment. Valid
- * keys are: TOP, CENTER, and BOTTOM.
+ * Checks the specified key to ensure that it is valid as a vertical
+ * alignment, throwing an {@link IllegalArgumentException} if the key is
+ * invalid. Valid keys are {@link #TOP}, {@link #CENTER} and {@link #BOTTOM}.
*
* @param key The key to check.
* @param message The message of the exception to be thrown if the key is
* invalid.
*
- * @return The key if it's valid.
+ * @return The key if it is valid.
*
* @throws IllegalArgumentException If the key is invalid.
*/
@@ -735,9 +777,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the gap between the icon and the text.
+ * Returns the gap between the icon and the text.
*
* @return The gap between the icon and the text.
+ *
+ * @see #setIconTextGap(int)
*/
public int getIconTextGap()
{
@@ -745,10 +789,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "iconTextGap" property. The iconTextGap
- * determines how much space there is between the icon and the text.
+ * Sets the gap between the icon and the text, in the case that both are
+ * visible (this is a bound property with the name 'iconTextGap').
*
- * @param newGap The gap between the icon and the text.
+ * @param newGap The gap (in pixels).
+ *
+ * @see #getIconTextGap()
*/
public void setIconTextGap(int newGap)
{
@@ -760,9 +806,13 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the vertical alignment of the label.
+ * Returns the vertical alignment of the label (one of
+ * {@link #TOP}, {@link #CENTER} and {@link #BOTTOM}). The default value
+ * depends on the installed look and feel, but is usually {@link #CENTER}.
*
- * @return The vertical alignment of the label.
+ * @return The vertical alignment.
+ *
+ * @see #setVerticalAlignment(int)
*/
public int getVerticalAlignment()
{
@@ -770,12 +820,18 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "verticalAlignment" property of the label. The
- * vertical alignment determines how where the label will be placed
- * vertically. If the alignment is not valid, it will default to the
- * center.
+ * Sets the vertical alignment for the label (this is a bound property with
+ * the name 'verticalAlignment'). The vertical alignment determines where
+ * the label (icon and text) will be placed vertically within the component
+ * bounds. Valid alignment codes are {@link #TOP}, {@link #CENTER} and
+ * {@link #BOTTOM}.
*
* @param alignment The vertical alignment of the label.
+ *
+ * @throws IllegalArgumentException if <code>alignment</code> is not one of
+ * the specified values.
+ *
+ * @see #getVerticalAlignment()
*/
public void setVerticalAlignment(int alignment)
{
@@ -788,9 +844,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the horziontal alignment of the label.
+ * Returns the horizontal alignment of the label (one of {@link #LEFT},
+ * {@link #CENTER}, {@link #RIGHT}, {@link #LEADING} and {@link #TRAILING}).
+ * The default value depends on the installed look and feel, but is usually
+ * {@link #LEFT}.
*
- * @return The horizontal alignment of the label.
+ * @return The horizontal alignment.
+ *
+ * @see #setHorizontalAlignment(int)
*/
public int getHorizontalAlignment()
{
@@ -798,10 +859,18 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "horizontalAlignment" property. The horizontal
- * alignment determines where the label will be placed horizontally.
+ * Sets the horizontal alignment for the label (this is a bound property with
+ * the name 'horizontalAlignment'). The horizontal alignment determines where
+ * the label (icon and text) will be placed horizontally within the
+ * component bounds. Valid alignment codes are {@link #LEFT},
+ * {@link #CENTER}, {@link #RIGHT}, {@link #LEADING} and {@link #TRAILING}.
*
* @param alignment The horizontal alignment of the label.
+ *
+ * @throws IllegalArgumentException if <code>alignment</code> is not one of
+ * the specified values.
+ *
+ * @see #getHorizontalAlignment()
*/
public void setHorizontalAlignment(int alignment)
{
@@ -815,9 +884,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the vertical text position of the label.
- *
- * @return The vertical text position of the label.
+ * Returns the vertical position of the label's text relative to the icon.
+ * This will be one of {@link #TOP}, {@link #CENTER} and {@link #BOTTOM}.
+ *
+ * @return The vertical position of the label's text relative to the icon.
+ *
+ * @see #setVerticalTextPosition(int)
*/
public int getVerticalTextPosition()
{
@@ -825,28 +897,35 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "verticalTextPosition" property of the label. The
- * vertical text position determines where the text will be placed
- * vertically relative to the icon.
+ * Sets the vertical position of the label's text relative to the icon (this
+ * is a bound property with the name 'verticalTextPosition'). Valid
+ * positions are {@link #TOP}, {@link #CENTER} and {@link #BOTTOM}.
*
* @param textPosition The vertical text position.
+ *
+ * @throws IllegalArgumentException if <code>textPosition</code> is not one
+ * of the specified values.
*/
public void setVerticalTextPosition(int textPosition)
{
if (textPosition != verticalTextPosition)
{
- int oldPos = verticalTextPosition;
- verticalTextPosition = checkVerticalKey(textPosition,
- "verticalTextPosition");
- firePropertyChange("verticalTextPosition", oldPos,
- verticalTextPosition);
+ int oldPos = verticalTextPosition;
+ verticalTextPosition = checkVerticalKey(textPosition,
+ "verticalTextPosition");
+ firePropertyChange("verticalTextPosition", oldPos,
+ verticalTextPosition);
}
}
/**
- * This method returns the horizontal text position of the label.
- *
- * @return The horizontal text position.
+ * Returns the horizontal position of the label's text relative to the icon.
+ * This will be one of {@link #LEFT}, {@link #CENTER}, {@link #RIGHT},
+ * {@link #LEADING} and {@link #TRAILING}.
+ *
+ * @return The horizontal position of the label's text relative to the icon.
+ *
+ * @see #setHorizontalTextPosition(int)
*/
public int getHorizontalTextPosition()
{
@@ -854,28 +933,31 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "horizontalTextPosition" property of the label.
- * The horizontal text position determines where the text will be placed
- * horizontally relative to the icon.
+ * Sets the horizontal position of the label's text relative to the icon (this
+ * is a bound property with the name 'horizontalTextPosition'). Valid
+ * positions are {@link #LEFT}, {@link #CENTER}, {@link #RIGHT},
+ * {@link #LEADING} and {@link #TRAILING}.
*
* @param textPosition The horizontal text position.
+ *
+ * @throws IllegalArgumentException if <code>textPosition</code> is not one
+ * of the specified values.
*/
public void setHorizontalTextPosition(int textPosition)
{
if (textPosition != horizontalTextPosition)
{
- int oldPos = horizontalTextPosition;
- horizontalTextPosition = checkHorizontalKey(textPosition,
- "horizontalTextPosition");
- firePropertyChange("horizontalTextPosition", oldPos,
- horizontalTextPosition);
+ int oldPos = horizontalTextPosition;
+ horizontalTextPosition = checkHorizontalKey(textPosition,
+ "horizontalTextPosition");
+ firePropertyChange("horizontalTextPosition", oldPos,
+ horizontalTextPosition);
}
}
/**
- * This method simply returns false if the current icon image (current icon
- * will depend on whether the label is enabled) is not equal to the passed
- * in image.
+ * Returns false if the current icon image (current icon will depend on
+ * whether the label is enabled) is not equal to the passed in image.
*
* @param img The image to check.
* @param infoflags The bitwise inclusive OR of ABORT, ALLBITS, ERROR,
@@ -900,11 +982,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method returns the component that the label gives focus to when the
- * mnemonic is activated.
+ * Returns the component that this <code>JLabel</code> is providing the label
+ * for. This component will typically receive the focus when the label's
+ * mnemonic key is activated via the keyboard.
*
- * @return The component that gets focus when the label's mnemonic is
- * activated.
+ * @return The component (possibly <code>null</code>).
*/
public Component getLabelFor()
{
@@ -912,12 +994,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method changes the "labelFor" property. The component that the label
- * is acting as a label for will request focus when the label's mnemonic
- * is activated.
+ * Sets the component that this <code>JLabel</code> is providing the label
+ * for (this is a bound property with the name 'labelFor'). This component
+ * will typically receive the focus when the label's mnemonic key is
+ * activated via the keyboard.
*
- * @param c The component that gets focus when the label's mnemonic is
- * activated.
+ * @param c the component (<code>null</code> permitted).
+ *
+ * @see #getLabelFor()
*/
public void setLabelFor(Component c)
{
@@ -946,10 +1030,9 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
- * This method overrides setFont so that we can call for a repaint after the
- * font is changed.
+ * Sets the font for the label (this a bound property with the name 'font').
*
- * @param f The font for this label.
+ * @param f The font (<code>null</code> permitted).
*/
public void setFont(Font f)
{
diff --git a/libjava/classpath/javax/swing/JLayeredPane.java b/libjava/classpath/javax/swing/JLayeredPane.java
index 11650e721d0..ca913e97fed 100644
--- a/libjava/classpath/javax/swing/JLayeredPane.java
+++ b/libjava/classpath/javax/swing/JLayeredPane.java
@@ -43,6 +43,7 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
+import java.util.ArrayList;
import java.util.Hashtable;
import javax.accessibility.Accessible;
@@ -326,13 +327,13 @@ public class JLayeredPane extends JComponent implements Accessible
{
int pos = -1;
int index = getIndexOf(c);
- Component[] components = getComponents();
- int layer = getLayer(c);
if (index >= 0)
{
- for (int i = index; i >= 0; --i)
+ pos = 0;
+ int layer = getLayer(c);
+ for (int i = index - 1; i >= 0; --i)
{
- if (layer == getLayer(components[i]))
+ if (layer == getLayer(getComponent(i)))
pos++;
else
break;
@@ -353,9 +354,7 @@ public class JLayeredPane extends JComponent implements Accessible
*/
public void setPosition(Component c, int position)
{
- int layer = getLayer(c);
- int index = insertIndexForLayer(layer, position);
- setComponentZOrder(c, index);
+ setLayer(c, getLayer(c), position);
}
/**
@@ -478,34 +477,85 @@ public class JLayeredPane extends JComponent implements Accessible
*/
protected int insertIndexForLayer(int layer, int position)
{
- // position < 0 means insert at greatest position within layer.
- if (position < 0)
- position = Integer.MAX_VALUE;
+ return insertIndexForLayer(null, layer, position);
+ }
- Component[] components = getComponents();
- int index = 0;
+ /**
+ * Similar to {@link #insertIndexForLayer(int, int)}, only that it takes a
+ * component parameter, which should be ignored in the search. This is
+ * necessary to support {@link #setLayer(Component, int, int)} which uses
+ * Container.setComponentZOrder(), which doesn't remove the component.
+ *
+ * @param comp the component to ignore
+ * @param layer the layer
+ * @param position the position
+ *
+ * @return the insertion index
+ */
+ private int insertIndexForLayer(Component comp, int layer, int position)
+ {
+ // Create the component list to search through.
+ ArrayList l = new ArrayList();
+ int count = getComponentCount();
+ for (int i = 0; i < count; i++)
+ {
+ Component c = getComponent(i);
+ if (c != comp)
+ l.add(c);
+ }
- // Try to find the start index of the specified layer.
- int p = -1;
- for (int i = 0; i < components.length; i++)
+ count = l.size();
+ int layerStart = -1;
+ int layerEnd = -1;
+ for (int i = 0; i < count; i++)
{
- int l = getLayer(components[i]);
- if (l > layer)
- index++;
- // If we are in the layer we look for, try to find the position.
- else if (l == layer)
+ int layerOfComponent = getLayer((Component) l.get(i));
+ if (layerStart == -1 && layerOfComponent == layer)
+ layerStart = i;
+ if (layerOfComponent < layer)
{
- p++;
- if (p < position)
- index++;
+ // We are beyond the layer that we are looking for. Update the
+ // layerStart and layerEnd and exit the loop.
+ if (i == 0)
+ {
+ layerStart = 0;
+ layerEnd = 0;
+ }
else
- break;
+ layerEnd = i;
+ break;
}
- // No need to look further if the layer at i is smaller than layer.
+ }
+
+ // No layer found. The requested layer is lower than any existing layer,
+ // put the component at the end.
+ int insertIndex;
+ if (layerStart == -1 && layerEnd == -1)
+ {
+ insertIndex = count;
+ }
+ else
+ {
+ // Corner cases.
+ if (layerStart != -1 && layerEnd == -1)
+ layerEnd = count;
+ if (layerStart == -1 && layerEnd != -1)
+ layerStart = layerEnd;
+
+ // Adding to the bottom of a layer returns the end index
+ // in the layer.
+ if (position == -1)
+ insertIndex = layerEnd;
else
- break;
+ {
+ // Insert into a layer.
+ if (position > -1 && layerStart + position <= layerEnd)
+ insertIndex = layerStart + position;
+ else
+ insertIndex = layerEnd;
+ }
}
- return index;
+ return insertIndex;
}
/**
@@ -559,17 +609,29 @@ public class JLayeredPane extends JComponent implements Accessible
public void setLayer(Component c, int layer, int position)
{
Integer layerObj = getObjectForLayer(layer);
- if (c instanceof JComponent)
+
+ // Nothing to do if neither the layer nor the position is
+ // changed.
+ if (layer != getLayer(c) || position != getPosition(c))
{
- JComponent jc = (JComponent) c;
- jc.putClientProperty(LAYER_PROPERTY, layerObj);
- }
- else
- componentToLayer.put (c, layerObj);
+ // Store the layer either in the JComponent or in the hashtable
+ if (c instanceof JComponent)
+ {
+ JComponent jc = (JComponent) c;
+ jc.putClientProperty(LAYER_PROPERTY, layerObj);
+ }
+ else
+ componentToLayer.put (c, layerObj);
- // Set position only of component is already added to this layered pane.
- if (getIndexOf(c) != -1)
- setPosition(c, position);
+ // Update the component in the Z order of the Container.
+ Container parent = c.getParent();
+ if (parent == this)
+ {
+ int index = insertIndexForLayer(c, layer, position);
+ setComponentZOrder(c, index);
+ }
+ }
+ repaint(c.getX(), c.getY(), c.getWidth(), c.getHeight());
}
/**
@@ -592,14 +654,17 @@ public class JLayeredPane extends JComponent implements Accessible
{
int layer;
if (layerConstraint != null && layerConstraint instanceof Integer)
- layer = ((Integer) layerConstraint).intValue();
+ {
+ layer = ((Integer) layerConstraint).intValue();
+ setLayer(comp, layer);
+ }
else
- layer = getLayer(comp);
+ layer = getLayer(comp);
int newIdx = insertIndexForLayer(layer, index);
- setLayer(comp, layer);
super.addImpl(comp, layerConstraint, newIdx);
- repaint(comp.getX(), comp.getY(), comp.getWidth(), comp.getHeight());
+ comp.validate();
+ comp.repaint();
}
/**
diff --git a/libjava/classpath/javax/swing/JList.java b/libjava/classpath/javax/swing/JList.java
index eab6be3c30c..6a98770eeda 100644
--- a/libjava/classpath/javax/swing/JList.java
+++ b/libjava/classpath/javax/swing/JList.java
@@ -944,17 +944,6 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
ListSelectionModel selectionModel;
-
- /**
- * This property indicates that the list's selection is currently
- * "adjusting" -- perhaps due to a user actively dragging the mouse over
- * multiple list elements -- and is therefore likely to change again in
- * the near future. A {@link ListSelectionListener} might choose to delay
- * updating its view of the list's selection until this property is
- * false, meaning that the adjustment has completed.
- */
- boolean valueIsAdjusting;
-
/**
* This property indicates a <em>preference</em> for the number of rows
* displayed in the list, and will scale the
@@ -1085,8 +1074,7 @@ public class JList extends JComponent implements Accessible, Scrollable
fixedCellWidth = -1;
layoutOrientation = VERTICAL;
opaque = true;
- valueIsAdjusting = false;
- visibleRowCount = 7;
+ visibleRowCount = 8;
cellRenderer = new DefaultListCellRenderer();
listListener = new ListListener();
@@ -1196,11 +1184,13 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Gets the value of the {@link #visibleRowCount} property.
+ * Gets the value of the {@link #visibleRowCount} property. The default
+ * value is 8.
*
* @return the current value of the property.
+ *
+ * @see #setVisibleRowCount(int)
*/
-
public int getVisibleRowCount()
{
return visibleRowCount;
@@ -1210,12 +1200,19 @@ public class JList extends JComponent implements Accessible, Scrollable
* Sets the value of the {@link #visibleRowCount} property.
*
* @param vc The new property value
+ *
+ * @see #getVisibleRowCount()
*/
public void setVisibleRowCount(int vc)
{
- visibleRowCount = vc;
- revalidate();
- repaint();
+ if (visibleRowCount != vc)
+ {
+ int oldValue = visibleRowCount;
+ visibleRowCount = Math.max(vc, 0);
+ firePropertyChange("visibleRowCount", oldValue, vc);
+ revalidate();
+ repaint();
+ }
}
/**
@@ -2184,23 +2181,25 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Returns the value of the <code>valueIsAdjusting</code> property.
+ * Returns the <code>valueIsAdjusting</code> flag from the list's selection
+ * model.
*
* @return the value
*/
public boolean getValueIsAdjusting()
{
- return valueIsAdjusting;
+ return selectionModel.getValueIsAdjusting();
}
/**
- * Sets the <code>valueIsAdjusting</code> property.
+ * Sets the <code>valueIsAdjusting</code> flag in the list's selection
+ * model.
*
* @param isAdjusting the new value
*/
public void setValueIsAdjusting(boolean isAdjusting)
{
- valueIsAdjusting = isAdjusting;
+ selectionModel.setValueIsAdjusting(isAdjusting);
}
/**
@@ -2228,11 +2227,13 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Returns the layout orientation.
+ * Returns the layout orientation, which will be one of {@link #VERTICAL},
+ * {@link #VERTICAL_WRAP} and {@link #HORIZONTAL_WRAP}. The default value
+ * is {@link #VERTICAL}.
*
- * @return the orientation, one of <code>JList.VERTICAL</code>,
- * <code>JList.VERTICAL_WRAP</code> and <code>JList.HORIZONTAL_WRAP</code>
+ * @return the orientation.
*
+ * @see #setLayoutOrientation(int)
* @since 1.4
*/
public int getLayoutOrientation()
@@ -2241,15 +2242,21 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Sets the layout orientation.
+ * Sets the layout orientation (this is a bound property with the name
+ * 'layoutOrientation'). Valid orientations are {@link #VERTICAL},
+ * {@link #VERTICAL_WRAP} and {@link #HORIZONTAL_WRAP}.
*
- * @param orientation the orientation to set, one of <code>JList.VERTICAL</code>,
- * <code>JList.VERTICAL_WRAP</code> and <code>JList.HORIZONTAL_WRAP</code>
+ * @param orientation the orientation.
*
+ * @throws IllegalArgumentException if <code>orientation</code> is not one
+ * of the specified values.
* @since 1.4
+ * @see #getLayoutOrientation()
*/
public void setLayoutOrientation(int orientation)
{
+ if (orientation < JList.VERTICAL || orientation > JList.HORIZONTAL_WRAP)
+ throw new IllegalArgumentException();
if (layoutOrientation == orientation)
return;
@@ -2282,14 +2289,16 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Returns the next list element (beginning from <code>startIndex</code>
- * that starts with <code>prefix</code>. Searching is done in the direction
- * specified by <code>bias</code>.
+ * Returns the index of the next list element (beginning at
+ * <code>startIndex</code> and moving in the specified direction through the
+ * list, looping around if necessary) that starts with <code>prefix</code>
+ * (ignoring case).
*
* @param prefix the prefix to search for in the cell values
* @param startIndex the index where to start searching from
- * @param bias the search direction, either {@link Position.Bias#Forward}
- * or {@link Position.Bias#Backward}
+ * @param direction the search direction, either {@link Position.Bias#Forward}
+ * or {@link Position.Bias#Backward} (<code>null</code> is interpreted
+ * as {@link Position.Bias#Backward}.
*
* @return the index of the found element or -1 if no such element has
* been found
@@ -2299,7 +2308,8 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @since 1.4
*/
- public int getNextMatch(String prefix, int startIndex, Position.Bias bias)
+ public int getNextMatch(String prefix, int startIndex,
+ Position.Bias direction)
{
if (prefix == null)
throw new IllegalArgumentException("The argument 'prefix' must not be"
@@ -2309,37 +2319,33 @@ public class JList extends JComponent implements Accessible, Scrollable
+ " be less than zero.");
int size = model.getSize();
- if (startIndex > model.getSize())
+ if (startIndex >= model.getSize())
throw new IllegalArgumentException("The argument 'startIndex' must not"
+ " be greater than the number of"
+ " elements in the ListModel.");
- int index = -1;
- if (bias == Position.Bias.Forward)
- {
- for (int i = startIndex; i < size; i++)
- {
- String item = model.getElementAt(i).toString();
- if (item.startsWith(prefix))
- {
- index = i;
- break;
- }
- }
- }
- else
+ int result = -1;
+ int current = startIndex;
+ int delta = -1;
+ int itemCount = model.getSize();
+ boolean finished = false;
+ prefix = prefix.toUpperCase();
+
+ if (direction == Position.Bias.Forward)
+ delta = 1;
+ while (!finished)
{
- for (int i = startIndex; i >= 0; i--)
- {
- String item = model.getElementAt(i).toString();
- if (item.startsWith(prefix))
- {
- index = i;
- break;
- }
- }
+ String itemStr = model.getElementAt(current).toString().toUpperCase();
+ if (itemStr.startsWith(prefix))
+ return current;
+ current = (current + delta);
+ if (current == -1)
+ current += itemCount;
+ else
+ current = current % itemCount;
+ finished = current == startIndex;
}
- return index;
+ return result;
}
/**
diff --git a/libjava/classpath/javax/swing/JMenu.java b/libjava/classpath/javax/swing/JMenu.java
index 02cb20eab57..0840509f906 100644
--- a/libjava/classpath/javax/swing/JMenu.java
+++ b/libjava/classpath/javax/swing/JMenu.java
@@ -40,6 +40,7 @@ package javax.swing;
import java.awt.Component;
import java.awt.Point;
+import java.awt.PopupMenu;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -74,7 +75,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
private static final long serialVersionUID = 4227225638931828014L;
/** A Popup menu associated with this menu, which pops up when menu is selected */
- private JPopupMenu popupMenu = new JPopupMenu();
+ private JPopupMenu popupMenu = null;
/** Whenever menu is selected or deselected the MenuEvent is fired to
menu's registered listeners. */
@@ -98,6 +99,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
super();
setOpaque(false);
+ setDelay(200);
}
/**
@@ -108,8 +110,10 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public JMenu(String text)
{
super(text);
+ popupMenu = new JPopupMenu();
popupMenu.setInvoker(this);
setOpaque(false);
+ setDelay(200);
}
/**
@@ -122,8 +126,10 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
super(action);
createActionChangeListener(this);
+ popupMenu = new JPopupMenu();
popupMenu.setInvoker(this);
setOpaque(false);
+ setDelay(200);
}
/**
@@ -137,6 +143,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
// FIXME: tearoff not implemented
this(text);
+ setDelay(200);
}
/**
@@ -148,7 +155,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public JMenuItem add(JMenuItem item)
{
- return popupMenu.add(item);
+ return getPopupMenu().add(item);
}
/**
@@ -160,7 +167,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public Component add(Component component)
{
- popupMenu.insert(component, -1);
+ getPopupMenu().insert(component, -1);
return component;
}
@@ -174,7 +181,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public Component add(Component component, int index)
{
- return popupMenu.add(component, index);
+ return getPopupMenu().add(component, index);
}
/**
@@ -186,7 +193,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public JMenuItem add(String text)
{
- return popupMenu.add(text);
+ return getPopupMenu().add(text);
}
/**
@@ -198,7 +205,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public JMenuItem add(Action action)
{
- return popupMenu.add(action);
+ return getPopupMenu().add(action);
}
/**
@@ -209,7 +216,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public void remove(JMenuItem item)
{
- popupMenu.remove(item);
+ getPopupMenu().remove(item);
}
/**
@@ -219,7 +226,11 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public void remove(int index)
{
- popupMenu.remove(index);
+ if (index < 0 || (index > 0 && getMenuComponentCount() == 0))
+ throw new IllegalArgumentException();
+
+ if (getMenuComponentCount() > 0)
+ popupMenu.remove(index);
}
/**
@@ -229,8 +240,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public void remove(Component component)
{
- int index = popupMenu.getComponentIndex(component);
- popupMenu.remove(index);
+ int index = getPopupMenu().getComponentIndex(component);
+ if (index >= 0)
+ getPopupMenu().remove(index);
}
/**
@@ -238,7 +250,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public void removeAll()
{
- popupMenu.removeAll();
+ if (popupMenu != null)
+ popupMenu.removeAll();
}
/**
@@ -267,7 +280,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
if (index < 0)
throw new IllegalArgumentException("index less than zero");
- popupMenu.insert(item, index);
+ getPopupMenu().insert(item, index);
return item;
}
@@ -381,7 +394,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
super.setSelected(false);
super.setArmed(false);
fireMenuDeselected();
- popupMenu.setVisible(false);
+ getPopupMenu().setVisible(false);
}
}
@@ -404,7 +417,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public boolean isPopupMenuVisible()
{
- return popupMenu.isVisible();
+ return getPopupMenu().isVisible();
}
/**
@@ -415,7 +428,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public void setPopupMenuVisible(boolean popup)
{
if (getModel().isEnabled())
- popupMenu.setVisible(popup);
+ getPopupMenu().setVisible(popup);
}
/**
@@ -530,6 +543,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
if (index < 0)
throw new IllegalArgumentException("index less than 0");
+ if (getItemCount() == 0)
+ return null;
+
Component c = popupMenu.getComponentAtIndex(index);
if (c instanceof JMenuItem)
@@ -558,7 +574,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public boolean isTearOff()
{
// NOT YET IMPLEMENTED
- return false;
+ throw new Error("The method isTearOff() has not yet been implemented.");
}
/**
@@ -568,7 +584,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public int getMenuComponentCount()
{
- return popupMenu.getComponentCount();
+ return getPopupMenu().getComponentCount();
}
/**
@@ -581,6 +597,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public Component getMenuComponent(int index)
{
+ if (getPopupMenu() == null || getMenuComponentCount() == 0)
+ return null;
+
return (Component) popupMenu.getComponentAtIndex(index);
}
@@ -591,7 +610,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public Component[] getMenuComponents()
{
- return popupMenu.getComponents();
+ return getPopupMenu().getComponents();
}
/**
@@ -626,6 +645,11 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public JPopupMenu getPopupMenu()
{
+ if (popupMenu == null)
+ {
+ popupMenu = new JPopupMenu();
+ popupMenu.setInvoker(this);
+ }
return popupMenu;
}
diff --git a/libjava/classpath/javax/swing/JMenuItem.java b/libjava/classpath/javax/swing/JMenuItem.java
index 90d54b1d30a..f7f93bf00d7 100644
--- a/libjava/classpath/javax/swing/JMenuItem.java
+++ b/libjava/classpath/javax/swing/JMenuItem.java
@@ -184,7 +184,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
out statement below for now. */
//borderPainted = false;
focusPainted = false;
- horizontalAlignment = JButton.LEFT;
+ horizontalAlignment = JButton.LEADING;
horizontalTextPosition = JButton.TRAILING;
}
diff --git a/libjava/classpath/javax/swing/JOptionPane.java b/libjava/classpath/javax/swing/JOptionPane.java
index f9490553834..43caecd1a48 100644
--- a/libjava/classpath/javax/swing/JOptionPane.java
+++ b/libjava/classpath/javax/swing/JOptionPane.java
@@ -48,6 +48,8 @@ import java.awt.MenuComponent;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionAdapter;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@@ -378,11 +380,49 @@ public class JOptionPane extends JComponent implements Accessible
dialog.setResizable(false);
dialog.pack();
dialog.setLocationRelativeTo(parentComponent);
-
+
+ addPropertyChangeListener(new ValuePropertyHandler(dialog));
return dialog;
}
/**
+ * Handles changes of the value property. Whenever this property changes,
+ * the JOptionPane dialog should be closed.
+ */
+ private static class ValuePropertyHandler
+ implements PropertyChangeListener
+ {
+ /**
+ * The dialog to close.
+ */
+ JDialog dialog;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param d the dialog to be closed
+ */
+ ValuePropertyHandler(JDialog d)
+ {
+ dialog = d;
+ }
+
+ /**
+ * Receives notification when any of the properties change.
+ */
+ public void propertyChange(PropertyChangeEvent p)
+ {
+ String prop = p.getPropertyName();
+ Object val = p.getNewValue();
+ if (prop.equals(VALUE_PROPERTY) && val != null
+ && val != UNINITIALIZED_VALUE)
+ {
+ dialog.setVisible(false);
+ }
+ }
+ }
+
+ /**
* This method creates a new JInternalFrame that is in the JLayeredPane
* which contains the parentComponent given. If no suitable JLayeredPane
* can be found from the parentComponent given, a RuntimeException will be
diff --git a/libjava/classpath/javax/swing/JPopupMenu.java b/libjava/classpath/javax/swing/JPopupMenu.java
index c7890ea0e1e..d46015afdf3 100644
--- a/libjava/classpath/javax/swing/JPopupMenu.java
+++ b/libjava/classpath/javax/swing/JPopupMenu.java
@@ -120,7 +120,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
private boolean lightWeightPopupEnabled;
/** SelectionModel that keeps track of menu selection. */
- private SingleSelectionModel selectionModel;
+ protected SingleSelectionModel selectionModel;
/* Popup that is used to display JPopupMenu */
private transient Popup popup;
diff --git a/libjava/classpath/javax/swing/JRadioButtonMenuItem.java b/libjava/classpath/javax/swing/JRadioButtonMenuItem.java
index 0d7c1d10533..13ef189a514 100644
--- a/libjava/classpath/javax/swing/JRadioButtonMenuItem.java
+++ b/libjava/classpath/javax/swing/JRadioButtonMenuItem.java
@@ -144,6 +144,7 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
model.setSelected(selected);
+ setFocusable(false);
}
/**
diff --git a/libjava/classpath/javax/swing/JSplitPane.java b/libjava/classpath/javax/swing/JSplitPane.java
index 2747686a31a..5b77f5176ae 100644
--- a/libjava/classpath/javax/swing/JSplitPane.java
+++ b/libjava/classpath/javax/swing/JSplitPane.java
@@ -708,7 +708,8 @@ public class JSplitPane extends JComponent implements Accessible
throw new IllegalArgumentException
("proportion has to be between 0 and 1.");
- int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight();
+ int max = ((orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight())
+ - getDividerSize();
setDividerLocation((int) (proportionalLocation * max));
}
diff --git a/libjava/classpath/javax/swing/JTabbedPane.java b/libjava/classpath/javax/swing/JTabbedPane.java
index ee6af857ee3..5c8d0474852 100644
--- a/libjava/classpath/javax/swing/JTabbedPane.java
+++ b/libjava/classpath/javax/swing/JTabbedPane.java
@@ -990,6 +990,8 @@ public class JTabbedPane extends JComponent implements Serializable,
checkIndex(index, -1, tabs.size());
if (index != getSelectedIndex())
{
+ // Hiding and showing the involved components
+ // is done by the JTabbedPane's UI.
model.setSelectedIndex(index);
}
}
@@ -1247,7 +1249,32 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void remove(Component component)
{
- super.remove(component);
+ // Since components implementing UIResource
+ // are not added as regular tabs by the add()
+ // methods we have to take special care when
+ // removing these object. Especially
+ // Container.remove(Component) cannot be used
+ // because it will call JTabbedPane.remove(int)
+ // later which is overridden and can only
+ // handle tab components.
+ // This implementation can even cope with a
+ // situation that someone called insertTab()
+ // with a component that implements UIResource.
+ int index = indexOfComponent(component);
+
+ // If the component is not a tab component
+ // find out its Container-given index
+ // and call that class' implementation
+ // directly.
+ if (index == -1)
+ {
+ Component[] cs = getComponents();
+ for (int i = 0; i< cs.length; i++)
+ if (cs[i] == component)
+ super.remove(i);
+ }
+ else
+ removeTabAt(index);
}
/**
@@ -1257,7 +1284,6 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void remove(int index)
{
- super.remove(index);
removeTabAt(index);
}
diff --git a/libjava/classpath/javax/swing/JTable.java b/libjava/classpath/javax/swing/JTable.java
index 855530881f5..5c7bff5d019 100644
--- a/libjava/classpath/javax/swing/JTable.java
+++ b/libjava/classpath/javax/swing/JTable.java
@@ -2922,56 +2922,189 @@ public class JTable
{
// update the column model from the table model if the structure has
// changed and the flag autoCreateColumnsFromModel is set
- if ((event == null || (event.getFirstRow() == TableModelEvent.HEADER_ROW))
- && autoCreateColumnsFromModel)
+ if (event == null || (event.getFirstRow() == TableModelEvent.HEADER_ROW))
+ handleCompleteChange(event);
+ else if (event.getType() == TableModelEvent.INSERT)
+ handleInsert(event);
+ else if (event.getType() == TableModelEvent.DELETE)
+ handleDelete(event);
+ else
+ handleUpdate(event);
+ }
+
+ /**
+ * Handles a request for complete relayout. This is the case when
+ * event.getFirstRow() == TableModelEvent.HEADER_ROW.
+ *
+ * @param ev the table model event
+ */
+ private void handleCompleteChange(TableModelEvent ev)
+ {
+ clearSelection();
+ checkSelection();
+ rowHeights = null;
+ if (getAutoCreateColumnsFromModel())
+ createDefaultColumnsFromModel();
+ else
+ resizeAndRepaint();
+ }
+
+ /**
+ * Handles table model insertions.
+ *
+ * @param ev the table model event
+ */
+ private void handleInsert(TableModelEvent ev)
+ {
+ // Sync selection model with data model.
+ int first = ev.getFirstRow();
+ if (first < 0)
+ first = 0;
+ int last = ev.getLastRow();
+ if (last < 0)
+ last = getRowCount() - 1;
+ selectionModel.insertIndexInterval(first, last - first + 1, true);
+ checkSelection();
+
+ // For variable height rows we must update the SizeSequence thing.
+ if (rowHeights != null)
{
- rowHeights = null;
- if (getAutoCreateColumnsFromModel())
- createDefaultColumnsFromModel();
- resizeAndRepaint();
- return;
+ rowHeights.insertEntries(first, last - first + 1, rowHeight);
+ // TODO: We repaint the whole thing when the rows have variable
+ // heights. We might want to handle this better though.
+ repaint();
+ }
+ else
+ {
+ // Repaint the dirty region and revalidate.
+ int rowHeight = getRowHeight();
+ Rectangle dirty = new Rectangle(0, first * rowHeight,
+ getColumnModel().getTotalColumnWidth(),
+ (getRowCount() - first) * rowHeight);
+ repaint(dirty);
+ }
+ revalidate();
+ }
+
+ /**
+ * Handles table model deletions.
+ *
+ * @param ev the table model event
+ */
+ private void handleDelete(TableModelEvent ev)
+ {
+ // Sync selection model with data model.
+ int first = ev.getFirstRow();
+ if (first < 0)
+ first = 0;
+ int last = ev.getLastRow();
+ if (last < 0)
+ last = getRowCount() - 1;
+
+ selectionModel.removeIndexInterval(first, last);
+
+ checkSelection();
+
+ if (dataModel.getRowCount() == 0)
+ clearSelection();
+
+ // For variable height rows we must update the SizeSequence thing.
+ if (rowHeights != null)
+ {
+ rowHeights.removeEntries(first, last - first + 1);
+ // TODO: We repaint the whole thing when the rows have variable
+ // heights. We might want to handle this better though.
+ repaint();
+ }
+ else
+ {
+ // Repaint the dirty region and revalidate.
+ int rowHeight = getRowHeight();
+ int oldRowCount = getRowCount() + last - first + 1;
+ Rectangle dirty = new Rectangle(0, first * rowHeight,
+ getColumnModel().getTotalColumnWidth(),
+ (oldRowCount - first) * rowHeight);
+ repaint(dirty);
}
+ revalidate();
+ }
- // If the structure changes, we need to revalidate, since that might
- // affect the size parameters of the JTable. Otherwise we only need
- // to perform a repaint to update the view.
- if (event == null || event.getType() == TableModelEvent.INSERT)
+ /**
+ * Handles table model updates without structural changes.
+ *
+ * @param ev the table model event
+ */
+ private void handleUpdate(TableModelEvent ev)
+ {
+ if (rowHeights == null)
{
- // Sync selection model with data model.
- if (event != null)
+ // Some cells have been changed without changing the structure.
+ // Figure out the dirty rectangle and repaint.
+ int firstRow = ev.getFirstRow();
+ int lastRow = ev.getLastRow();
+ int col = ev.getColumn();
+ Rectangle dirty;
+ if (col == TableModelEvent.ALL_COLUMNS)
{
- int first = event.getFirstRow();
- if (first < 0)
- first = 0;
- int last = event.getLastRow();
- if (last < 0)
- last = getRowCount() - 1;
- selectionModel.insertIndexInterval(first, last - first + 1, true);
- if (rowHeights != null)
- rowHeights.insertEntries(first, last - first + 1, rowHeight);
+ // All columns changed.
+ dirty = new Rectangle(0, firstRow * getRowHeight(),
+ getColumnModel().getTotalColumnWidth(), 0);
}
- revalidate();
+ else
+ {
+ // Only one cell or column of cells changed.
+ // We need to convert to view column first.
+ int column = convertColumnIndexToModel(col);
+ dirty = getCellRect(firstRow, column, false);
+ }
+
+ // Now adjust the height of the dirty region.
+ dirty.height = (lastRow + 1) * getRowHeight();
+ // .. and repaint.
+ repaint(dirty);
}
- if (event == null || event.getType() == TableModelEvent.DELETE)
+ else
{
- // Sync selection model with data model.
- if (event != null)
+ // TODO: We repaint the whole thing when the rows have variable
+ // heights. We might want to handle this better though.
+ repaint();
+ }
+ }
+
+ /**
+ * Helper method for adjusting the lead and anchor indices when the
+ * table structure changed. This sets the lead and anchor to -1 if there's
+ * no more rows, or set them to 0 when they were at -1 and there are actually
+ * some rows now.
+ */
+ private void checkSelection()
+ {
+ TableModel m = getModel();
+ ListSelectionModel sm = selectionModel;
+ if (m != null)
+ {
+ int lead = sm.getLeadSelectionIndex();
+ int c = m.getRowCount();
+ if (c == 0 && lead != -1)
+ {
+ // No rows in the model, reset lead and anchor to -1.
+ sm.setValueIsAdjusting(true);
+ sm.setAnchorSelectionIndex(-1);
+ sm.setLeadSelectionIndex(-1);
+ sm.setValueIsAdjusting(false);
+ }
+ else if (c != 0 && lead == -1)
{
- int first = event.getFirstRow();
- if (first < 0)
- first = 0;
- int last = event.getLastRow();
- if (last < 0)
- last = getRowCount() - 1;
- selectionModel.removeIndexInterval(first, last);
- if (rowHeights != null)
- rowHeights.removeEntries(first, last - first + 1);
+ // We have rows, but no lead/anchor. Set them to 0. We
+ // do a little trick here so that the actual selection is not
+ // touched.
+ if (sm.isSelectedIndex(0))
+ sm.addSelectionInterval(0, 0);
+ else
+ sm.removeSelectionInterval(0, 0);
}
- if (dataModel.getRowCount() == 0)
- clearSelection();
- revalidate();
+ // Nothing to do in the other cases.
}
- repaint();
}
/**
@@ -3468,6 +3601,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 +3756,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 +4011,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 +4131,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();
+ }
}
/**
@@ -4014,6 +4163,7 @@ public class JTable
if (s != null)
s.addListSelectionListener(this);
selectionModel = s;
+ checkSelection();
}
/**
diff --git a/libjava/classpath/javax/swing/JTree.java b/libjava/classpath/javax/swing/JTree.java
index f7583ad69e2..fa898c5a940 100644
--- a/libjava/classpath/javax/swing/JTree.java
+++ b/libjava/classpath/javax/swing/JTree.java
@@ -1392,9 +1392,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
public static final String EXPANDS_SELECTED_PATHS_PROPERTY =
"expandsSelectedPaths";
- private static final Object EXPANDED = new Object();
+ private static final Object EXPANDED = Boolean.TRUE;
- private static final Object COLLAPSED = new Object();
+ private static final Object COLLAPSED = Boolean.FALSE;
private boolean dragEnabled;
@@ -1515,6 +1515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
// The root node appears expanded by default.
nodeStates = new Hashtable();
+ // The cell renderer gets set by the UI.
+ cellRenderer = null;
+
// Install the UI before installing the model. This way we avoid double
// initialization of lots of UI and model stuff inside the UI and related
// classes. The necessary UI updates are performed via property change
diff --git a/libjava/classpath/javax/swing/LookAndFeel.java b/libjava/classpath/javax/swing/LookAndFeel.java
index 7f59f1b5f93..be543439636 100644
--- a/libjava/classpath/javax/swing/LookAndFeel.java
+++ b/libjava/classpath/javax/swing/LookAndFeel.java
@@ -242,15 +242,15 @@ public abstract class LookAndFeel
{
if (keys == null)
return;
- for (int i = 0; i < keys.length - 1; i+= 2)
+ for (int i = 0; i < keys.length - 1; i += 2)
{
Object key = keys[i];
KeyStroke keyStroke;
if (key instanceof KeyStroke)
- keyStroke = (KeyStroke)key;
+ keyStroke = (KeyStroke) key;
else
- keyStroke = KeyStroke.getKeyStroke((String)key);
- retMap.put(keyStroke, keys[i+1]);
+ keyStroke = KeyStroke.getKeyStroke((String) key);
+ retMap.put(keyStroke, keys[i + 1]);
}
}
@@ -328,15 +328,15 @@ public abstract class LookAndFeel
{
JTextComponent.KeyBinding[] retBindings =
new JTextComponent.KeyBinding[keyBindingList.length / 2];
- for (int i = 0; i < keyBindingList.length - 1; i+= 2)
+ for (int i = 0; i < keyBindingList.length - 1; i += 2)
{
KeyStroke stroke;
if (keyBindingList[i] instanceof KeyStroke)
- stroke = (KeyStroke)keyBindingList[i];
+ stroke = (KeyStroke) keyBindingList[i];
else
- stroke = KeyStroke.getKeyStroke((String)keyBindingList[i]);
- retBindings[i/2] = new JTextComponent.KeyBinding(stroke,
- (String) keyBindingList[i+1]);
+ stroke = KeyStroke.getKeyStroke((String) keyBindingList[i]);
+ retBindings[i / 2] = new JTextComponent.KeyBinding(stroke,
+ (String) keyBindingList[i + 1]);
}
return retBindings;
}
diff --git a/libjava/classpath/javax/swing/ProgressMonitor.java b/libjava/classpath/javax/swing/ProgressMonitor.java
index 28d22e8a63e..b4c3d222349 100644
--- a/libjava/classpath/javax/swing/ProgressMonitor.java
+++ b/libjava/classpath/javax/swing/ProgressMonitor.java
@@ -142,12 +142,12 @@ public class ProgressMonitor
*/
public void close()
{
- if ( progressDialog != null )
+ if (progressDialog != null)
{
progressDialog.setVisible(false);
}
- if ( timer != null )
+ if (timer != null)
{
timer.stop();
timer = null;
@@ -173,7 +173,7 @@ public class ProgressMonitor
// Initializes and starts a timer with a task
// which measures the duration and displays
// a progress dialog if neccessary.
- if ( timer == null && progressDialog == null )
+ if (timer == null && progressDialog == null)
{
timer = new Timer(25, null);
timer.addActionListener(new TimerListener());
@@ -182,7 +182,7 @@ public class ProgressMonitor
// Cancels timer and hides progress dialog if the
// maximum value is reached.
- if ( progressBar != null && this.progress >= progressBar.getMaximum() )
+ if (progressBar != null && this.progress >= progressBar.getMaximum())
{
// The reason for using progressBar.getMaximum() instead of max is that
// we want to prevent that changes to the value have any effect after the
@@ -326,7 +326,7 @@ public class ProgressMonitor
*/
public void setNote(String note)
{
- if ( noteLabel != null )
+ if (noteLabel != null)
{
noteLabel.setText(note);
}
@@ -401,18 +401,18 @@ public class ProgressMonitor
{
long now = System.currentTimeMillis();
- if ( first )
+ if (first)
{
- if (( now - timestamp ) > millisToDecideToPopup )
+ if ((now - timestamp) > millisToDecideToPopup)
{
first = false;
- long expected = ( progress - min == 0 ) ?
- ( now - timestamp ) * ( max - min ) :
- ( now - timestamp ) * ( max - min ) / ( progress - min );
+ long expected = (progress - min == 0) ?
+ (now - timestamp) * (max - min) :
+ (now - timestamp) * (max - min) / (progress - min);
- if ( expected > millisToPopup )
+ if (expected > millisToPopup)
{
createDialog();
}
@@ -424,14 +424,14 @@ public class ProgressMonitor
return;
}
}
- else if ( progressDialog != null )
+ else if (progressDialog != null)
{
// The progress dialog is being displayed. We now calculate
// whether setting the progress bar to the current progress
// value would result in a visual difference.
int delta = progress - progressBar.getValue();
- if ( ( delta * progressBar.getWidth() / (max - min) ) > 0 )
+ if ((delta * progressBar.getWidth() / (max - min)) > 0)
{
// At least one pixel would change.
progressBar.setValue(progress);
diff --git a/libjava/classpath/javax/swing/ProgressMonitorInputStream.java b/libjava/classpath/javax/swing/ProgressMonitorInputStream.java
index fec5c2ee03b..90e721247b1 100644
--- a/libjava/classpath/javax/swing/ProgressMonitorInputStream.java
+++ b/libjava/classpath/javax/swing/ProgressMonitorInputStream.java
@@ -240,7 +240,7 @@ public class ProgressMonitorInputStream extends FilterInputStream
private void checkMonitorCanceled() throws InterruptedIOException
{
- if ( monitor.isCanceled() )
+ if (monitor.isCanceled())
{
throw new InterruptedIOException("ProgressMonitor was canceled");
}
diff --git a/libjava/classpath/javax/swing/RepaintManager.java b/libjava/classpath/javax/swing/RepaintManager.java
index f95934123ea..80f0a3481cd 100644
--- a/libjava/classpath/javax/swing/RepaintManager.java
+++ b/libjava/classpath/javax/swing/RepaintManager.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing;
-import java.applet.Applet;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -314,26 +313,45 @@ public class RepaintManager
*/
public void addInvalidComponent(JComponent component)
{
- Component ancestor = component;
-
- while (ancestor != null
- && (! (ancestor instanceof JComponent)
- || ! ((JComponent) ancestor).isValidateRoot() ))
- ancestor = ancestor.getParent();
+ Component validateRoot = null;
+ Component c = component;
+ while (c != null)
+ {
+ // Special cases we don't bother validating are when the invalidated
+ // component (or any of it's ancestors) is inside a CellRendererPane
+ // or if it doesn't have a peer yet (== not displayable).
+ if (c instanceof CellRendererPane || ! c.isDisplayable())
+ return;
+ if (c instanceof JComponent && ((JComponent) c).isValidateRoot())
+ {
+ validateRoot = c;
+ break;
+ }
- if (ancestor != null
- && ancestor instanceof JComponent
- && ((JComponent) ancestor).isValidateRoot())
- component = (JComponent) ancestor;
+ c = c.getParent();
+ }
- if (invalidComponents.contains(component))
+ // If we didn't find a validate root, then we don't validate.
+ if (validateRoot == null)
return;
- synchronized (invalidComponents)
+ // Make sure the validate root and all of it's ancestors are visible.
+ c = validateRoot;
+ while (c != null)
{
- invalidComponents.add(component);
+ if (! c.isVisible() || ! c.isDisplayable())
+ return;
+ c = c.getParent();
}
+ if (invalidComponents.contains(validateRoot))
+ return;
+
+ //synchronized (invalidComponents)
+ // {
+ invalidComponents.add(validateRoot);
+ // }
+
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
@@ -379,7 +397,7 @@ public class RepaintManager
{
if (w <= 0 || h <= 0 || !component.isShowing())
return;
-
+
Component parent = component.getParent();
component.computeVisibleRect(rectCache);
@@ -444,8 +462,7 @@ public class RepaintManager
*/
public void markCompletelyDirty(JComponent component)
{
- Rectangle r = component.getBounds();
- addDirtyRegion(component, 0, 0, r.width, r.height);
+ addDirtyRegion(component, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
@@ -483,13 +500,11 @@ public class RepaintManager
*/
public boolean isCompletelyDirty(JComponent component)
{
- boolean retVal = false;
- if (dirtyComponents.containsKey(component))
- {
- Rectangle dirtyRegion = (Rectangle) dirtyComponents.get(component);
- retVal = dirtyRegion.equals(SwingUtilities.getLocalBounds(component));
- }
- return retVal;
+ boolean dirty = false;
+ Rectangle r = getDirtyRegion(component);
+ if(r.width == Integer.MAX_VALUE && r.height == Integer.MAX_VALUE)
+ dirty = true;
+ return dirty;
}
/**
@@ -618,7 +633,7 @@ public class RepaintManager
public Image getOffscreenBuffer(Component component, int proposedWidth,
int proposedHeight)
{
- Component root = getRoot(component);
+ Component root = SwingUtilities.getWindowAncestor(component);
Image buffer = (Image) offscreenBuffers.get(root);
if (buffer == null
|| buffer.getWidth(null) < proposedWidth
@@ -628,38 +643,12 @@ public class RepaintManager
width = Math.min(doubleBufferMaximumSize.width, width);
int height = Math.max(proposedHeight, root.getHeight());
height = Math.min(doubleBufferMaximumSize.height, height);
- buffer = component.createImage(width, height);
+ buffer = root.createImage(width, height);
offscreenBuffers.put(root, buffer);
}
return buffer;
}
-
- /**
- * Gets the root of the component given. If a parent of the
- * component is an instance of Applet, then the applet is
- * returned. The applet is considered the root for painting.
- * Otherwise, the root Window is returned if it exists.
- *
- * @param comp - The component to get the root for.
- * @return the parent root. An applet if it is a parent,
- * or the root window. If neither exist, null is returned.
- */
- private Component getRoot(Component comp)
- {
- Applet app = null;
-
- while (comp != null)
- {
- if (app == null && comp instanceof Window)
- return comp;
- else if (comp instanceof Applet)
- app = (Applet) comp;
- comp = comp.getParent();
- }
-
- return app;
- }
-
+
/**
* Blits the back buffer of the specified root component to the screen. If
* the RepaintManager is currently working on a paint request, the commit
@@ -667,67 +656,98 @@ public class RepaintManager
* done (by {@link #commitRemainingBuffers}). This is package private because
* it must get called by JComponent.
*
- * @param root the component, either a Window or an Applet instance
- * @param area the area to paint on screen
+ * @param comp the component to be painted
+ * @param area the area to paint on screen, in comp coordinates
*/
- void commitBuffer(Component root, Rectangle area)
+ void commitBuffer(Component comp, Rectangle area)
{
+ // Determine the component that we finally paint the buffer upon.
+ // We need to paint on the nearest heavyweight component, so that Swing
+ // hierarchies inside (non-window) heavyweights get painted correctly.
+ // Otherwise we would end up blitting the backbuffer behind the heavyweight
+ // which is wrong.
+ Component root = getHeavyweightParent(comp);
+ // FIXME: Optimize this.
+ Rectangle rootRect = SwingUtilities.convertRectangle(comp, area, root);
+
// We synchronize on dirtyComponents here because that is what
// paintDirtyRegions also synchronizes on while painting.
synchronized (dirtyComponents)
{
// If the RepaintManager is not currently painting, then directly
// blit the requested buffer on the screen.
- if (! repaintUnderway)
+ if (true || ! repaintUnderway)
{
- Graphics g = root.getGraphics();
- Image buffer = (Image) offscreenBuffers.get(root);
- Rectangle clip = g.getClipBounds();
- if (clip != null)
- area = SwingUtilities.computeIntersection(clip.x, clip.y,
- clip.width, clip.height,
- area);
- int dx1 = area.x;
- int dy1 = area.y;
- int dx2 = area.x + area.width;
- int dy2 = area.y + area.height;
- // Make sure we have a sane clip at this point.
- g.clipRect(area.x, area.y, area.width, area.height);
-
- // Make sure the coordinates are inside the buffer, everything else
- // might lead to problems.
- // TODO: This code should not really be necessary, however, in fact
- // we have two issues here:
- // 1. We shouldn't get repaint requests in areas outside the buffer
- // region in the first place. This still happens for example
- // when a component is inside a JViewport, and the component has
- // a size that would reach beyond the window size.
- // 2. Graphics.drawImage() should not behave strange when trying
- // to draw regions outside the image.
- int bufferWidth = buffer.getWidth(root);
- int bufferHeight = buffer.getHeight(root);
- dx1 = Math.min(bufferWidth, dx1);
- dy1 = Math.min(bufferHeight, dy1);
- dx2 = Math.min(bufferWidth, dx2);
- dy2 = Math.min(bufferHeight, dy2);
- g.drawImage(buffer, 0, 0, root);
- g.dispose();
+ blitBuffer(root, rootRect);
}
+
// Otherwise queue this request up, until all the RepaintManager work
// is done.
else
{
if (commitRequests.containsKey(root))
- SwingUtilities.computeUnion(area.x, area.y, area.width,
- area.height,
+ SwingUtilities.computeUnion(rootRect.x, rootRect.y,
+ rootRect.width, rootRect.height,
(Rectangle) commitRequests.get(root));
else
- commitRequests.put(root, area);
+ commitRequests.put(root, rootRect);
}
}
}
/**
+ * Copies the buffer to the screen. Note that the root component here is
+ * not necessarily the component with which the offscreen buffer is
+ * associated. The offscreen buffers are always allocated for the toplevel
+ * windows. However, painted is performed on lower-level heavyweight
+ * components too, if they contain Swing components.
+ *
+ * @param root the heavyweight component to blit upon
+ * @param rootRect the rectangle in the root component's coordinate space
+ */
+ private void blitBuffer(Component root, Rectangle rootRect)
+ {
+ if (! root.isShowing())
+ return;
+
+ // Find the Window from which we use the backbuffer.
+ Component bufferRoot = root;
+ Rectangle bufferRect = rootRect.getBounds();
+ if (!(bufferRoot instanceof Window))
+ {
+ bufferRoot = SwingUtilities.getWindowAncestor(bufferRoot);
+ SwingUtilities.convertRectangleToAncestor(root, rootRect, bufferRoot);
+ }
+
+ Graphics g = root.getGraphics();
+ Image buffer = (Image) offscreenBuffers.get(bufferRoot);
+
+ // Make sure we have a sane clip at this point.
+ g.clipRect(rootRect.x, rootRect.y, rootRect.width, rootRect.height);
+ g.drawImage(buffer, rootRect.x - bufferRect.x, rootRect.y - bufferRect.y,
+ root);
+ g.dispose();
+
+ }
+
+ /**
+ * Finds and returns the nearest heavyweight parent for the specified
+ * component. If the component isn't contained inside a heavyweight parent,
+ * this returns null.
+ *
+ * @param comp the component
+ *
+ * @return the nearest heavyweight parent for the specified component or
+ * null if the component has no heavyweight ancestor
+ */
+ private Component getHeavyweightParent(Component comp)
+ {
+ while (comp != null && comp.isLightweight())
+ comp = comp.getParent();
+ return comp;
+ }
+
+ /**
* Commits the queued up back buffers to screen all at once.
*/
private void commitRemainingBuffers()
@@ -743,7 +763,7 @@ public class RepaintManager
Map.Entry entry = (Map.Entry) i.next();
Component root = (Component) entry.getKey();
Rectangle area = (Rectangle) entry.getValue();
- commitBuffer(root, area);
+ blitBuffer(root, area);
i.remove();
}
}
@@ -767,7 +787,7 @@ public class RepaintManager
public Image getVolatileOffscreenBuffer(Component comp, int proposedWidth,
int proposedHeight)
{
- Component root = getRoot(comp);
+ Component root = SwingUtilities.getWindowAncestor(comp);
Image buffer = (Image) offscreenBuffers.get(root);
if (buffer == null
|| buffer.getWidth(null) < proposedWidth
diff --git a/libjava/classpath/javax/swing/ScrollPaneLayout.java b/libjava/classpath/javax/swing/ScrollPaneLayout.java
index 31846fa557d..8ce8fd86f7a 100644
--- a/libjava/classpath/javax/swing/ScrollPaneLayout.java
+++ b/libjava/classpath/javax/swing/ScrollPaneLayout.java
@@ -82,7 +82,8 @@ public class ScrollPaneLayout
// Nothing to do here.
}
- public void syncWithScrollPane(JScrollPane scrollPane) {
+ public void syncWithScrollPane(JScrollPane scrollPane)
+ {
viewport = scrollPane.getViewport();
rowHead = scrollPane.getRowHeader();
colHead = scrollPane.getColumnHeader();
@@ -145,7 +146,8 @@ public class ScrollPaneLayout
throw new IllegalArgumentException();
}
- public void removeLayoutComponent(Component component) {
+ public void removeLayoutComponent(Component component)
+ {
if (component == viewport)
viewport = null;
else if (component == vsb)
@@ -448,7 +450,8 @@ public class ScrollPaneLayout
* @deprecated As of Swing 1.1 replaced by
* {@link javax.swing.JScrollPane#getViewportBorderBounds}.
*/
- public Rectangle getViewportBorderBounds(JScrollPane scrollPane) {
+ public Rectangle getViewportBorderBounds(JScrollPane scrollPane)
+ {
return null;
}
diff --git a/libjava/classpath/javax/swing/SizeSequence.java b/libjava/classpath/javax/swing/SizeSequence.java
index 26099a15461..a5f34710c76 100644
--- a/libjava/classpath/javax/swing/SizeSequence.java
+++ b/libjava/classpath/javax/swing/SizeSequence.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
+import java.util.Arrays;
+
/**
* A sequence of values that represent the dimensions (widths or heights) of
* some collection of items (for example, the widths of the columns in a table).
@@ -80,8 +82,8 @@ public class SizeSequence
*/
public SizeSequence(int numEntries, int value)
{
- sizes = new int[0];
- insertEntries(0, numEntries, value);
+ sizes = new int[numEntries];
+ Arrays.fill(sizes, value);
}
/**
diff --git a/libjava/classpath/javax/swing/SpringLayout.java b/libjava/classpath/javax/swing/SpringLayout.java
index d87050639fe..2595b196703 100644
--- a/libjava/classpath/javax/swing/SpringLayout.java
+++ b/libjava/classpath/javax/swing/SpringLayout.java
@@ -505,7 +505,7 @@ public class SpringLayout implements LayoutManager2
}
}
- private static abstract class DeferredDimension extends Spring
+ private abstract static class DeferredDimension extends Spring
{
private int value;
diff --git a/libjava/classpath/javax/swing/SwingUtilities.java b/libjava/classpath/javax/swing/SwingUtilities.java
index 5d02d9bb396..ccd37d03a55 100644
--- a/libjava/classpath/javax/swing/SwingUtilities.java
+++ b/libjava/classpath/javax/swing/SwingUtilities.java
@@ -1045,8 +1045,7 @@ public class SwingUtilities
*/
public static boolean isLeftMouseButton(MouseEvent event)
{
- return ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK)
- == InputEvent.BUTTON1_DOWN_MASK);
+ return ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0);
}
/**
@@ -1599,4 +1598,27 @@ public class SwingUtilities
throw new IllegalArgumentException("Unrecognised code: " + code);
}
}
+
+ /**
+ * Converts a rectangle in the coordinate system of a child component into
+ * a rectangle of one of it's Ancestors. The result is stored in the input
+ * rectangle.
+ *
+ * @param comp the child component
+ * @param r the rectangle to convert
+ * @param ancestor the ancestor component
+ */
+ static void convertRectangleToAncestor(Component comp, Rectangle r,
+ Component ancestor)
+ {
+ if (comp == ancestor)
+ return;
+
+ r.x += comp.getX();
+ r.y += comp.getY();
+
+ Component parent = comp.getParent();
+ if (parent != null && parent != ancestor)
+ convertRectangleToAncestor(parent, r, ancestor);
+ }
}
diff --git a/libjava/classpath/javax/swing/Timer.java b/libjava/classpath/javax/swing/Timer.java
index 231b71d73bb..acd22624947 100644
--- a/libjava/classpath/javax/swing/Timer.java
+++ b/libjava/classpath/javax/swing/Timer.java
@@ -1,5 +1,5 @@
/* Timer.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -264,9 +264,13 @@ public class Timer
* firing the first event.
*
* @param d The time gap between the subsequent events, in milliseconds
+ *
+ * @throws IllegalArgumentException if <code>d</code> is less than zero.
*/
public void setDelay(int d)
{
+ if (d < 0)
+ throw new IllegalArgumentException("Invalid delay: " + d);
delay = d;
}
@@ -287,9 +291,13 @@ public class Timer
* subsequent events.
*
* @param i the initial delay, in milliseconds
+ *
+ * @throws IllegalArgumentException if <code>i</code> is less than zero.
*/
public void setInitialDelay(int i)
{
+ if (i < 0)
+ throw new IllegalArgumentException("Invalid initial delay: " + i);
initialDelay = i;
}
diff --git a/libjava/classpath/javax/swing/ToolTipManager.java b/libjava/classpath/javax/swing/ToolTipManager.java
index c7de4db8330..963ccf88117 100644
--- a/libjava/classpath/javax/swing/ToolTipManager.java
+++ b/libjava/classpath/javax/swing/ToolTipManager.java
@@ -1,5 +1,5 @@
/* ToolTipManager.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -267,10 +267,12 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
}
/**
- * This method sets the initial delay before the ToolTip is shown when the
+ * Sets the initial delay before the ToolTip is shown when the
* mouse enters a Component.
*
* @param delay The initial delay before the ToolTip is shown.
+ *
+ * @throws IllegalArgumentException if <code>delay</code> is less than zero.
*/
public void setInitialDelay(int delay)
{
@@ -289,9 +291,11 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
}
/**
- * This method sets the time the ToolTip will be shown before being hidden.
+ * Sets the time the ToolTip will be shown before being hidden.
*
- * @param delay The time the ToolTip will be shown before being hidden.
+ * @param delay the delay (in milliseconds) before tool tips are hidden.
+ *
+ * @throws IllegalArgumentException if <code>delay</code> is less than zero.
*/
public void setDismissDelay(int delay)
{
@@ -310,10 +314,12 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
}
/**
- * This method sets the amount of delay where if the mouse re-enters a
+ * Sets the amount of delay where if the mouse re-enters a
* Component, the tooltip will be shown immediately.
*
- * @param delay The reshow delay.
+ * @param delay The reshow delay (in milliseconds).
+ *
+ * @throws IllegalArgumentException if <code>delay</code> is less than zero.
*/
public void setReshowDelay(int delay)
{
diff --git a/libjava/classpath/javax/swing/UIManager.java b/libjava/classpath/javax/swing/UIManager.java
index e6f80116321..77be44afcbb 100644
--- a/libjava/classpath/javax/swing/UIManager.java
+++ b/libjava/classpath/javax/swing/UIManager.java
@@ -45,6 +45,7 @@ import java.awt.Insets;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
+import java.util.Enumeration;
import java.util.Locale;
import javax.swing.border.Border;
@@ -117,6 +118,87 @@ public class UIManager implements Serializable
}
}
+ /**
+ * A UIDefaults subclass that multiplexes between itself and a 'fallback'
+ * UIDefaults instance. This is used to protect the L&F UIDefaults from beeing
+ * overwritten by applications.
+ */
+ private static class MultiplexUIDefaults
+ extends UIDefaults
+ {
+ private class MultiplexEnumeration
+ implements Enumeration
+ {
+ Enumeration[] enums;
+ int i;
+ MultiplexEnumeration(Enumeration e1, Enumeration e2)
+ {
+ enums = new Enumeration[]{ e1, e2 };
+ i = 0;
+ }
+
+ public boolean hasMoreElements()
+ {
+ return enums[i].hasMoreElements() || i < enums.length - 1;
+ }
+
+ public Object nextElement()
+ {
+ Object val = enums[i].nextElement();
+ if (! enums[i].hasMoreElements() && i < enums.length - 1)
+ i++;
+ return val;
+ }
+
+ }
+
+ UIDefaults fallback;
+
+ MultiplexUIDefaults(UIDefaults d)
+ {
+ fallback = d;
+ }
+
+ public Object get(Object key)
+ {
+ Object val = super.get(key);
+ if (val == null)
+ val = fallback.get(key);
+ return val;
+ }
+
+ public Object get(Object key, Locale l)
+ {
+ Object val = super.get(key, l);
+ if (val == null)
+ val = fallback.get(key, l);
+ return val;
+ }
+
+ public Object remove(Object key)
+ {
+ Object val = super.remove(key);
+ if (val == null)
+ val = fallback.remove(key);
+ return val;
+ }
+
+ public int size()
+ {
+ return super.size() + fallback.size();
+ }
+
+ public Enumeration keys()
+ {
+ return new MultiplexEnumeration(super.keys(), fallback.keys());
+ }
+
+ public Enumeration elements()
+ {
+ return new MultiplexEnumeration(super.elements(), fallback.elements());
+ }
+ }
+
private static final long serialVersionUID = -5547433830339189365L;
/** The installed look and feel(s). */
@@ -131,12 +213,9 @@ public class UIManager implements Serializable
/** The current look and feel. */
static LookAndFeel currentLookAndFeel;
- static UIDefaults currentUIDefaults;
+ static MultiplexUIDefaults currentUIDefaults;
- /**
- * UIDefaults set by the user.
- */
- static UIDefaults userUIDefaults;
+ static UIDefaults lookAndFeelDefaults;
/** Property change listener mechanism. */
static PropertyChangeSupport listeners
@@ -149,9 +228,7 @@ public class UIManager implements Serializable
{
if (defaultlaf != null)
{
- Class lafClass = Class.forName(defaultlaf);
- LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
- setLookAndFeel(laf);
+ setLookAndFeel(defaultlaf);
}
else
{
@@ -162,6 +239,7 @@ public class UIManager implements Serializable
{
System.err.println("cannot initialize Look and Feel: " + defaultlaf);
System.err.println("error: " + ex.toString());
+ ex.printStackTrace();
System.err.println("falling back to Metal Look and Feel");
try
{
@@ -312,12 +390,7 @@ public class UIManager implements Serializable
*/
public static Object get(Object key)
{
- Object val = null;
- if (userUIDefaults != null)
- val = userUIDefaults.get(key);
- if (val == null)
- val = getLookAndFeelDefaults().get(key);
- return val;
+ return getDefaults().get(key);
}
/**
@@ -330,12 +403,7 @@ public class UIManager implements Serializable
*/
public static Object get(Object key, Locale locale)
{
- Object val = null;
- if (userUIDefaults != null)
- val = userUIDefaults.get(key, locale);
- if (val == null)
- val = getLookAndFeelDefaults().get(key, locale);
- return val;
+ return getDefaults().get(key, locale);
}
/**
@@ -414,6 +482,8 @@ public class UIManager implements Serializable
*/
public static UIDefaults getDefaults()
{
+ if (currentUIDefaults == null)
+ currentUIDefaults = new MultiplexUIDefaults(null);
return currentUIDefaults;
}
@@ -546,7 +616,7 @@ public class UIManager implements Serializable
*/
public static UIDefaults getLookAndFeelDefaults()
{
- return currentUIDefaults;
+ return lookAndFeelDefaults;
}
/**
@@ -587,13 +657,7 @@ public class UIManager implements Serializable
*/
public static ComponentUI getUI(JComponent target)
{
- ComponentUI ui = null;
- if (userUIDefaults != null
- && userUIDefaults.get(target.getUIClassID()) != null)
- ui = userUIDefaults.getUI(target);
- if (ui == null)
- ui = currentUIDefaults.getUI(target);
- return ui;
+ return getDefaults().getUI(target);
}
/**
@@ -625,11 +689,7 @@ public class UIManager implements Serializable
*/
public static Object put(Object key, Object value)
{
- Object old = get(key);
- if (userUIDefaults == null)
- userUIDefaults = new UIDefaults();
- userUIDefaults.put(key, value);
- return old;
+ return getDefaults().put(key, value);
}
/**
@@ -654,7 +714,8 @@ public class UIManager implements Serializable
throws UnsupportedLookAndFeelException
{
if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel())
- throw new UnsupportedLookAndFeelException(newLookAndFeel.getName());
+ throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()
+ + " not supported on this platform");
LookAndFeel oldLookAndFeel = currentLookAndFeel;
if (oldLookAndFeel != null)
oldLookAndFeel.uninitialize();
@@ -664,7 +725,12 @@ public class UIManager implements Serializable
if (newLookAndFeel != null)
{
newLookAndFeel.initialize();
- currentUIDefaults = newLookAndFeel.getDefaults();
+ lookAndFeelDefaults = newLookAndFeel.getDefaults();
+ if (currentUIDefaults == null)
+ currentUIDefaults =
+ new MultiplexUIDefaults(lookAndFeelDefaults);
+ else
+ currentUIDefaults.fallback = lookAndFeelDefaults;
}
else
{
@@ -689,7 +755,8 @@ public class UIManager implements Serializable
throws ClassNotFoundException, InstantiationException, IllegalAccessException,
UnsupportedLookAndFeelException
{
- Class c = Class.forName(className);
+ Class c = Class.forName(className, true,
+ Thread.currentThread().getContextClassLoader());
LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
setLookAndFeel(a);
}
diff --git a/libjava/classpath/javax/swing/border/TitledBorder.java b/libjava/classpath/javax/swing/border/TitledBorder.java
index 56146e01d1b..38ccd720f16 100644
--- a/libjava/classpath/javax/swing/border/TitledBorder.java
+++ b/libjava/classpath/javax/swing/border/TitledBorder.java
@@ -1,5 +1,5 @@
/* TitledBorder.java --
- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -961,7 +961,8 @@ public class TitledBorder extends AbstractBorder
public void setTitlePosition(int titlePosition)
{
if ((titlePosition < DEFAULT_POSITION) || (titlePosition > BELOW_BOTTOM))
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(titlePosition
+ + " is not a valid title position.");
// Swing borders are not JavaBeans, thus no need to fire an event.
this.titlePosition = titlePosition;
@@ -982,7 +983,8 @@ public class TitledBorder extends AbstractBorder
{
if ((titleJustification < DEFAULT_JUSTIFICATION)
|| (titleJustification > TRAILING))
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(titleJustification
+ + " is not a valid title justification.");
// Swing borders are not JavaBeans, thus no need to fire an event.
this.titleJustification = titleJustification;
diff --git a/libjava/classpath/javax/swing/event/EventListenerList.java b/libjava/classpath/javax/swing/event/EventListenerList.java
index 6a2f34ebb3d..bde8b3c7e4f 100644
--- a/libjava/classpath/javax/swing/event/EventListenerList.java
+++ b/libjava/classpath/javax/swing/event/EventListenerList.java
@@ -108,7 +108,7 @@ public class EventListenerList
* An array with all currently registered listeners. The array has
* twice as many elements as there are listeners. For an even
* integer <code>i</code>, <code>listenerList[i]</code> indicates
- * the registered class, and <code>listenerList[i+1]</code> is the
+ * the registered class, and <code>listenerList[i + 1]</code> is the
* listener.
*/
protected transient Object[] listenerList = NO_LISTENERS;
diff --git a/libjava/classpath/javax/swing/event/ListDataEvent.java b/libjava/classpath/javax/swing/event/ListDataEvent.java
index 2a6e6dbe9f0..897fc128f20 100644
--- a/libjava/classpath/javax/swing/event/ListDataEvent.java
+++ b/libjava/classpath/javax/swing/event/ListDataEvent.java
@@ -1,5 +1,5 @@
/* ListDataEvent.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,9 @@ package javax.swing.event;
import java.util.EventObject;
/**
+ * An event that contains information about a modification to the content of
+ * a list.
+ *
* @author Andrew Selkirk
* @author Ronald Veldema
*/
@@ -48,32 +51,46 @@ public class ListDataEvent extends EventObject
{
private static final long serialVersionUID = 2510353260071004774L;
+ /** An event type indicating that the list content has been modified. */
public static final int CONTENTS_CHANGED = 0;
+
+ /** An event type indicating that an interval has been added to the list. */
public static final int INTERVAL_ADDED = 1;
+
+ /**
+ * An event type indicating that an interval has been removed from the
+ * list.
+ */
public static final int INTERVAL_REMOVED = 2;
- private int type = 0;
- private int index0 = 0;
- private int index1 = 0;
+ private int type;
+ private int index0;
+ private int index1;
/**
* Creates a <code>ListDataEvent</code> object.
*
- * @param source The source of the event.
- * @param type The type of the event
- * @param index0 Bottom of range
- * @param index1 Top of range
+ * @param source the source of the event (<code>null</code> not permitted).
+ * @param type the type of the event (should be one of
+ * {@link #CONTENTS_CHANGED}, {@link #INTERVAL_ADDED} or
+ * {@link #INTERVAL_REMOVED}, although this is not enforced).
+ * @param index0 the index for one end of the modified range of list
+ * elements.
+ * @param index1 the index for the other end of the modified range of list
+ * elements.
*/
public ListDataEvent(Object source, int type, int index0, int index1)
{
super(source);
this.type = type;
- this.index0 = index0;
- this.index1 = index1;
+ this.index0 = Math.min(index0, index1);
+ this.index1 = Math.max(index0, index1);
}
/**
- * Returns the bottom index.
+ * Returns the index of the first item in the range of modified list items.
+ *
+ * @return The index of the first item in the range of modified list items.
*/
public int getIndex0()
{
@@ -81,7 +98,9 @@ public class ListDataEvent extends EventObject
}
/**
- * Returns the top index.
+ * Returns the index of the last item in the range of modified list items.
+ *
+ * @return The index of the last item in the range of modified list items.
*/
public int getIndex1()
{
@@ -89,10 +108,25 @@ public class ListDataEvent extends EventObject
}
/**
- * Returns the type of this event.
+ * Returns a code representing the type of this event, which is usually one
+ * of {@link #CONTENTS_CHANGED}, {@link #INTERVAL_ADDED} or
+ * {@link #INTERVAL_REMOVED}.
+ *
+ * @return The event type.
*/
public int getType()
{
return type;
}
+
+ /**
+ * Returns a string representing the state of this event.
+ *
+ * @return A string.
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[type=" + type + ",index0=" + index0
+ + ",index1=" + index1 + "]";
+ }
}
diff --git a/libjava/classpath/javax/swing/event/MenuEvent.java b/libjava/classpath/javax/swing/event/MenuEvent.java
index 35bb5b97b43..8ba32929e2d 100644
--- a/libjava/classpath/javax/swing/event/MenuEvent.java
+++ b/libjava/classpath/javax/swing/event/MenuEvent.java
@@ -1,5 +1,5 @@
/* MenuEvent.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package javax.swing.event;
-// Imports
import java.util.EventObject;
/**
@@ -45,15 +44,16 @@ import java.util.EventObject;
* @author Andrew Selkirk
* @author Ronald Veldema
*/
-public class MenuEvent extends EventObject {
-
- /**
- * Constructor MenuEvent
- * @param source Source object
- */
- public MenuEvent(Object source) {
- super(source);
- } // MenuEvent()
-
-
-} // MenuEvent
+public class MenuEvent extends EventObject
+{
+
+ /**
+ * Constructor MenuEvent
+ * @param source Source object
+ */
+ public MenuEvent(Object source)
+ {
+ super(source);
+ }
+
+}
diff --git a/libjava/classpath/javax/swing/event/TreeExpansionListener.java b/libjava/classpath/javax/swing/event/TreeExpansionListener.java
index 08507a0ffe9..45a5ef93c6d 100644
--- a/libjava/classpath/javax/swing/event/TreeExpansionListener.java
+++ b/libjava/classpath/javax/swing/event/TreeExpansionListener.java
@@ -37,26 +37,26 @@ exception statement from your version. */
package javax.swing.event;
-// Imports
import java.util.EventListener;
/**
* TreeExpansionListener public interface
* @author Andrew Selkirk
*/
-public interface TreeExpansionListener extends EventListener {
+public interface TreeExpansionListener extends EventListener
+{
- /**
- * Tree collapsed
- * @param event Tree Expansion Event
- */
- void treeCollapsed(TreeExpansionEvent event);
+ /**
+ * Tree collapsed
+ * @param event Tree Expansion Event
+ */
+ void treeCollapsed(TreeExpansionEvent event);
- /**
- * Tree expanded
- * @param event Tree Expansion Event
- */
- void treeExpanded(TreeExpansionEvent event);
+ /**
+ * Tree expanded
+ * @param event Tree Expansion Event
+ */
+ void treeExpanded(TreeExpansionEvent event);
-} // TreeExpansionListener
+}
diff --git a/libjava/classpath/javax/swing/filechooser/FileSystemView.java b/libjava/classpath/javax/swing/filechooser/FileSystemView.java
index f51b745c892..84b80dd402c 100644
--- a/libjava/classpath/javax/swing/filechooser/FileSystemView.java
+++ b/libjava/classpath/javax/swing/filechooser/FileSystemView.java
@@ -76,7 +76,10 @@ public abstract class FileSystemView
*/
public File createFileObject(String path)
{
- return new File(path);
+ File f = new File(path);
+ if (isFileSystemRoot(f))
+ f = this.createFileSystemRoot(f);
+ return f;
}
/**
@@ -223,16 +226,24 @@ public abstract class FileSystemView
/**
* Returns the name of a file as it would be displayed by the underlying
- * system. This implementation returns <code>null</code>, subclasses must
- * override.
+ * system.
*
* @param f the file.
*
- * @return <code>null</code>.
+ * @return the name of a file as it would be displayed by the underlying
+ * system
+ *
+ * @specnote The specification suggests that the information here is
+ * fetched from a ShellFolder class. This seems to be a non public
+ * private file handling class. We simply return File.getName()
+ * here and leave special handling to subclasses.
*/
public String getSystemDisplayName(File f)
{
- return null;
+ String name = null;
+ if (f != null)
+ name = f.getName();
+ return name;
}
/**
diff --git a/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java b/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java
index 96dfd2e1b1a..f8d71e1df33 100644
--- a/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java
+++ b/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java
@@ -106,17 +106,34 @@ class UnixFileSystemView extends FileSystemView
/**
* Returns the name of a file as it would be displayed by the underlying
- * system. This method is NOT YET IMPLEMENTED.
+ * system.
*
* @param f the file.
*
- * @return <code>null</code>.
+ * @return the name of a file as it would be displayed by the underlying
+ * system
*/
public String getSystemDisplayName(File f)
- throws NotImplementedException
{
- // FIXME: Implement;
- return null;
+ String name = null;
+ if (f != null)
+ {
+ if (isRoot(f))
+ name = f.getAbsolutePath();
+ else
+ {
+ try
+ {
+ String path = f.getCanonicalPath();
+ name = path.substring(path.lastIndexOf(File.separator) + 1);
+ }
+ catch (IOException e)
+ {
+ name = f.getName();
+ }
+ }
+ }
+ return name;
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/IconUIResource.java b/libjava/classpath/javax/swing/plaf/IconUIResource.java
index 659c8e7bab7..8ac9e0875ae 100644
--- a/libjava/classpath/javax/swing/plaf/IconUIResource.java
+++ b/libjava/classpath/javax/swing/plaf/IconUIResource.java
@@ -1,5 +1,5 @@
/* IconUIResource.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,7 +63,8 @@ public class IconUIResource implements Icon, UIResource, Serializable
/**
- * The icon that is wrapped by this <code>IconUIResource</code>.
+ * The icon that is wrapped by this <code>IconUIResource</code> (never
+ * <code>null</code>).
*/
private Icon delegate;
@@ -73,10 +74,12 @@ public class IconUIResource implements Icon, UIResource, Serializable
* icon. All messages are forwarded to the delegate icon.
*
* @param delegate the icon that is wrapped by this
- * <code>IconUIResource</code>.
+ * <code>IconUIResource</code> (<code>null</code> not permitted).
*/
public IconUIResource(Icon delegate)
{
+ if (delegate == null)
+ throw new IllegalArgumentException("Null 'delegate' argument.");
this.delegate = delegate;
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
index f796d9a730a..781269b2adf 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
@@ -1,5 +1,5 @@
/* BasicArrowButton.java --
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Polygon;
-import java.awt.Rectangle;
import javax.swing.ButtonModel;
import javax.swing.JButton;
@@ -86,7 +85,9 @@ public class BasicArrowButton extends JButton implements SwingConstants
transient Color highlight = Color.WHITE;
/**
- * Creates a new <code>BasicArrowButton</code> object.
+ * Creates a new <code>BasicArrowButton</code> object with an arrow pointing
+ * in the specified direction. If the <code>direction</code> is not one of
+ * the specified constants, no arrow is drawn.
*
* @param direction The direction the arrow points in (one of:
* {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
@@ -95,6 +96,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
{
super();
setDirection(direction);
+ setFocusable(false);
}
/**
@@ -116,8 +118,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
this.shadow = shadow;
this.darkShadow = darkShadow;
this.highlight = highlight;
- // Mark the button as not closing the popup, we handle this ourselves.
- putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP, Boolean.TRUE);
+ setFocusable(false);
}
/**
@@ -162,28 +163,22 @@ public class BasicArrowButton extends JButton implements SwingConstants
public void paint(Graphics g)
{
super.paint(g);
- Rectangle bounds = getBounds();
- int size = bounds.height / 4;
- int x = bounds.x + (bounds.width - size) / 2;
- int y = (bounds.height - size) / 4;
+
+ int height = getHeight();
+ int size = height / 4;
+
+ int x = (getWidth() - size) / 2;
+ int y = (height - size) / 2;
+
ButtonModel m = getModel();
if (m.isArmed())
{
x++;
y++;
}
+
paintTriangle(g, x, y, size, direction, isEnabled());
}
-
- /** The preferred size for the button. */
- private static final Dimension PREFERRED_SIZE = new Dimension(16, 16);
-
- /** The minimum size for the button. */
- private static final Dimension MINIMUM_SIZE = new Dimension(5, 5);
-
- /** The maximum size for the button. */
- private static final Dimension MAXIMUM_SIZE
- = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
/**
* Returns the preferred size of the arrow button.
@@ -192,7 +187,10 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public Dimension getPreferredSize()
{
- return PREFERRED_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(16, 16);
}
/**
@@ -202,17 +200,23 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public Dimension getMinimumSize()
{
- return MINIMUM_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(5, 5);
}
/**
* Returns the maximum size of the arrow button.
*
- * @return The maximum size.
+ * @return The maximum size (always Integer.MAX_VALUE x Integer.MAX_VALUE).
*/
public Dimension getMaximumSize()
{
- return MAXIMUM_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java b/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java
index 89e99a29a31..84895821518 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicButtonListener.java
@@ -38,13 +38,17 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import gnu.classpath.SystemProperties;
+
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -66,7 +70,23 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
public void propertyChange(PropertyChangeEvent e)
{
- // TODO: What should be done here, if anything?
+ // Store the TextLayout for this in a client property for speed-up
+ // painting of the label.
+ String property = e.getPropertyName();
+ if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+ || property.equals("font"))
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+ == null)
+ {
+ AbstractButton b = (AbstractButton) e.getSource();
+ String text = b.getText();
+ if (text == null)
+ text = "";
+ FontRenderContext frc = new FontRenderContext(new AffineTransform(),
+ false, false);
+ TextLayout layout = new TextLayout(text, b.getFont(), frc);
+ b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
+ }
}
protected void checkOpacity(AbstractButton b)
@@ -160,11 +180,14 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
- if (e.getButton() == MouseEvent.BUTTON1)
+ if (SwingUtilities.isLeftMouseButton(e))
{
// It is important that these transitions happen in this order.
model.setArmed(true);
model.setPressed(true);
+
+ if (! button.isFocusOwner() && button.isRequestFocusEnabled())
+ button.requestFocus();
}
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
index 0a537c4bdd8..d531133ba26 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
@@ -442,13 +442,17 @@ public class BasicButtonUI extends ButtonUI
if (b.isEnabled())
{
g.setColor(b.getForeground());
- g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ // FIXME: Underline mnemonic.
+ BasicGraphicsUtils.drawString(b, g, text, -1, textRect.x,
+ textRect.y + fm.getAscent());
}
else
{
String prefix = getPropertyPrefix();
g.setColor(UIManager.getColor(prefix + "disabledText"));
- g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ // FIXME: Underline mnemonic.
+ BasicGraphicsUtils.drawString(b, g, text, -1, textRect.x,
+ textRect.y + fm.getAscent());
}
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
index 2cb1623cbc2..d98fd2afe38 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -62,6 +60,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
import javax.swing.CellRendererPane;
import javax.swing.ComboBoxEditor;
import javax.swing.ComboBoxModel;
@@ -241,6 +240,8 @@ public class BasicComboBoxUI extends ComboBoxUI
comboBox.setLayout(createLayoutManager());
comboBox.setFocusable(true);
installKeyboardActions();
+ comboBox.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP,
+ Boolean.TRUE);
}
}
@@ -288,7 +289,7 @@ public class BasicComboBoxUI extends ComboBoxUI
comboBox.addPropertyChangeListener(propertyChangeListener);
focusListener = createFocusListener();
- editor.addFocusListener(focusListener);
+ comboBox.addFocusListener(focusListener);
itemListener = createItemListener();
comboBox.addItemListener(itemListener);
@@ -542,7 +543,9 @@ public class BasicComboBoxUI extends ComboBoxUI
{
editor.setFont(comboBox.getFont());
if (popupKeyListener != null)
- editor.addKeyListener(popupKeyListener);
+ editor.addKeyListener(popupKeyListener);
+ if (keyListener != null)
+ editor.addKeyListener(keyListener);
comboBox.configureEditor(comboBox.getEditor(),
comboBox.getSelectedItem());
}
@@ -554,6 +557,8 @@ public class BasicComboBoxUI extends ComboBoxUI
{
if (popupKeyListener != null)
editor.removeKeyListener(popupKeyListener);
+ if (keyListener != null)
+ editor.removeKeyListener(keyListener);
}
/**
@@ -571,6 +576,10 @@ public class BasicComboBoxUI extends ComboBoxUI
arrowButton.addMouseListener(popupMouseListener);
if (popupMouseMotionListener != null)
arrowButton.addMouseMotionListener(popupMouseMotionListener);
+
+ // Mark the button as not closing the popup, we handle this ourselves.
+ arrowButton.putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP,
+ Boolean.TRUE);
}
}
@@ -712,18 +721,51 @@ public class BasicComboBoxUI extends ComboBoxUI
return new Dimension(32767, 32767);
}
+ /**
+ * Returns the number of accessible children of the combobox.
+ *
+ * @param c the component (combobox) to check, ignored
+ *
+ * @return the number of accessible children of the combobox
+ */
public int getAccessibleChildrenCount(JComponent c)
- throws NotImplementedException
{
- // FIXME: Need to implement
- return 0;
+ int count = 1;
+ if (comboBox.isEditable())
+ count = 2;
+ return count;
}
+ /**
+ * Returns the accessible child with the specified index.
+ *
+ * @param c the component, this is ignored
+ * @param i the index of the accessible child to return
+ */
public Accessible getAccessibleChild(JComponent c, int i)
- throws NotImplementedException
{
- // FIXME: Need to implement
- return null;
+ Accessible child = null;
+ switch (i)
+ {
+ case 0: // The popup.
+ if (popup instanceof Accessible)
+ {
+ AccessibleContext ctx = ((Accessible) popup).getAccessibleContext();
+ ctx.setAccessibleParent(comboBox);
+ child = (Accessible) popup;
+ }
+ break;
+ case 1: // The editor, if any.
+ if (comboBox.isEditable() && editor instanceof Accessible)
+ {
+ AccessibleContext ctx =
+ ((Accessible) editor).getAccessibleContext();
+ ctx.setAccessibleParent(comboBox);
+ child = (Accessible) editor;
+ }
+ break;
+ }
+ return child;
}
/**
@@ -735,10 +777,11 @@ public class BasicComboBoxUI extends ComboBoxUI
* @return true if the specified key is a navigation key and false otherwis
*/
protected boolean isNavigationKey(int keyCode)
- throws NotImplementedException
{
- // FIXME: Need to implement
- return false;
+ return keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN
+ || keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT
+ || keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_ESCAPE
+ || keyCode == KeyEvent.VK_TAB;
}
/**
@@ -759,7 +802,7 @@ public class BasicComboBoxUI extends ComboBoxUI
protected void selectPreviousPossibleValue()
{
int index = comboBox.getSelectedIndex();
- if (index != 0)
+ if (index > 0)
comboBox.setSelectedIndex(index - 1);
}
@@ -1163,10 +1206,31 @@ public class BasicComboBoxUI extends ComboBoxUI
* Invoked whenever key is pressed while JComboBox is in focus.
*/
public void keyPressed(KeyEvent e)
- throws NotImplementedException
{
- // FIXME: This method calls JComboBox.selectWithKeyChar if the key that
- // was pressed is not a navigation key.
+ if (comboBox.getModel().getSize() != 0 && comboBox.isEnabled())
+ {
+ if (! isNavigationKey(e.getKeyCode()))
+ {
+ if (! comboBox.isEditable())
+ if (comboBox.selectWithKeyChar(e.getKeyChar()))
+ e.consume();
+ }
+ else
+ {
+ if (e.getKeyCode() == KeyEvent.VK_UP && comboBox.isPopupVisible())
+ selectPreviousPossibleValue();
+ else if (e.getKeyCode() == KeyEvent.VK_DOWN)
+ {
+ if (comboBox.isPopupVisible())
+ selectNextPossibleValue();
+ else
+ comboBox.showPopup();
+ }
+ else if (e.getKeyCode() == KeyEvent.VK_ENTER
+ || e.getKeyCode() == KeyEvent.VK_ESCAPE)
+ popup.hide();
+ }
+ }
}
}
@@ -1330,5 +1394,4 @@ public class BasicComboBoxUI extends ComboBoxUI
// FIXME: Need to handle changes in other bound properties.
}
}
-
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java b/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
index ef7a880c2ac..ed916cb5f1a 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
+++ b/libjava/classpath/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.
@@ -40,35 +40,296 @@ package javax.swing.plaf.basic;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
import java.util.Vector;
import javax.swing.AbstractListModel;
import javax.swing.JFileChooser;
+import javax.swing.SwingUtilities;
import javax.swing.event.ListDataEvent;
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! */
- private int directories;
+ /**
+ * The directories in the list.
+ */
+ private Vector directories;
+
+ /**
+ * The files in the list.
+ */
+ private Vector files;
- /** 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! */
+ /**
+ * The thread that loads the file view.
+ */
+ private DirectoryLoadThread loadThread;
+
+ /**
+ * This thread is responsible for loading file lists from the
+ * current directory and updating the model.
+ */
+ private class DirectoryLoadThread extends Thread
+ {
+
+ /**
+ * Updates the Swing list model.
+ */
+ private class UpdateSwingRequest
+ implements Runnable
+ {
+
+ private List added;
+ private int addIndex;
+ private List removed;
+ private int removeIndex;
+ private boolean cancel;
+
+ UpdateSwingRequest(List add, int ai, List rem, int ri)
+ {
+ added = add;
+ addIndex = ai;
+ removed = rem;
+ removeIndex = ri;
+ cancel = false;
+ }
+
+ public void run()
+ {
+ if (! cancel)
+ {
+ int numRemoved = removed == null ? 0 : removed.size();
+ int numAdded = added == null ? 0 : added.size();
+ synchronized (contents)
+ {
+ if (numRemoved > 0)
+ contents.removeAll(removed);
+ if (numAdded > 0)
+ contents.addAll(added);
+
+ files = null;
+ directories = null;
+ }
+ if (numRemoved > 0 && numAdded == 0)
+ fireIntervalRemoved(BasicDirectoryModel.this, removeIndex,
+ removeIndex + numRemoved - 1);
+ else if (numRemoved == 0 && numAdded > 0)
+ fireIntervalAdded(BasicDirectoryModel.this, addIndex,
+ addIndex + numAdded - 1);
+ else
+ fireContentsChanged();
+ }
+ }
+
+ void cancel()
+ {
+ cancel = true;
+ }
+ }
+
+ /**
+ * The directory beeing loaded.
+ */
+ File directory;
+
+ /**
+ * Stores all UpdateSwingRequests that are sent to the event queue.
+ */
+ private UpdateSwingRequest pending;
+
+ /**
+ * Creates a new DirectoryLoadThread that loads the specified
+ * directory.
+ *
+ * @param dir the directory to load
+ */
+ DirectoryLoadThread(File dir)
+ {
+ super("Basic L&F directory loader");
+ directory = dir;
+ }
+
+ public void run()
+ {
+ FileSystemView fsv = filechooser.getFileSystemView();
+ File[] files = fsv.getFiles(directory,
+ filechooser.isFileHidingEnabled());
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ // Check list for accepted files.
+ Vector accepted = new Vector();
+ for (int i = 0; i < files.length; i++)
+ {
+ if (filechooser.accept(files[i]))
+ accepted.add(files[i]);
+ }
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ // Sort list.
+ sort(accepted);
+
+ // Now split up directories from files so that we get the directories
+ // listed before the files.
+ Vector newFiles = new Vector();
+ Vector newDirectories = new Vector();
+ for (Iterator i = accepted.iterator(); i.hasNext();)
+ {
+ File f = (File) i.next();
+ boolean traversable = filechooser.isTraversable(f);
+ if (traversable)
+ newDirectories.add(f);
+ else if (! traversable && filechooser.isFileSelectionEnabled())
+ newFiles.add(f);
+
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ }
+
+ // Build up new file cache. Try to update only the changed elements.
+ // This will be important for actions like adding new files or
+ // directories inside a large file list.
+ Vector newCache = new Vector(newDirectories);
+ newCache.addAll(newFiles);
+
+ int newSize = newCache.size();
+ int oldSize = contents.size();
+ if (newSize < oldSize)
+ {
+ // Check for removed interval.
+ int start = -1;
+ int end = -1;
+ boolean found = false;
+ for (int i = 0; i < newSize && !found; i++)
+ {
+ if (! newCache.get(i).equals(contents.get(i)))
+ {
+ start = i;
+ end = i + oldSize - newSize;
+ found = true;
+ }
+ }
+ if (start >= 0 && end > start
+ && contents.subList(end, oldSize)
+ .equals(newCache.subList(start, newSize)))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ Vector removed = new Vector(contents.subList(start, end));
+ UpdateSwingRequest r = new UpdateSwingRequest(null, 0,
+ removed, start);
+ invokeLater(r);
+ newCache = null;
+ }
+ }
+ else if (newSize > oldSize)
+ {
+ // Check for inserted interval.
+ int start = oldSize;
+ int end = newSize;
+ boolean found = false;
+ for (int i = 0; i < oldSize && ! found; i++)
+ {
+ if (! newCache.get(i).equals(contents.get(i)))
+ {
+ start = i;
+ boolean foundEnd = false;
+ for (int j = i; j < newSize && ! foundEnd; j++)
+ {
+ if (newCache.get(j).equals(contents.get(i)))
+ {
+ end = j;
+ foundEnd = true;
+ }
+ }
+ end = i + oldSize - newSize;
+ }
+ }
+ if (start >= 0 && end > start
+ && newCache.subList(end, newSize)
+ .equals(contents.subList(start, oldSize)))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+
+ List added = newCache.subList(start, end);
+ UpdateSwingRequest r = new UpdateSwingRequest(added, start,
+ null, 0);
+ invokeLater(r);
+ newCache = null;
+ }
+ }
+
+ // Handle complete list changes (newCache != null).
+ if (newCache != null && ! contents.equals(newCache))
+ {
+ // Occasional check if we have been interrupted.
+ if (isInterrupted())
+ return;
+ UpdateSwingRequest r = new UpdateSwingRequest(newCache, 0,
+ contents, 0);
+ invokeLater(r);
+ }
+ }
+
+ /**
+ * Wraps SwingUtilities.invokeLater() and stores the request in
+ * a Vector so that we can still cancel it later.
+ *
+ * @param update the request to invoke
+ */
+ private void invokeLater(UpdateSwingRequest update)
+ {
+ pending = update;
+ SwingUtilities.invokeLater(update);
+ }
+
+ /**
+ * Cancels all pending update requests that might be in the AWT
+ * event queue.
+ */
+ void cancelPending()
+ {
+ if (pending != null)
+ pending.cancel();
+ }
+ }
+
+ /** A Comparator class/object for sorting the file list. */
private Comparator comparator = new Comparator()
{
public int compare(Object o1, Object o2)
@@ -91,14 +352,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 +368,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Fires a content change event.
*/
public void fireContentsChanged()
{
@@ -114,80 +376,99 @@ 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 getDirectories()
{
- Vector tmp = new Vector();
- for (int i = 0; i < directories; i++)
- tmp.add(contents.get(i));
- return tmp;
+ // Synchronize this with the UpdateSwingRequest for the case when
+ // contents is modified.
+ synchronized (contents)
+ {
+ Vector dirs = directories;
+ if (dirs == null)
+ {
+ // Initializes this in getFiles().
+ getFiles();
+ dirs = directories;
+ }
+ return dirs;
+ }
}
/**
- * 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 getFiles()
{
- Vector tmp = new Vector();
- for (int i = directories; i < getSize(); i++)
- tmp.add(contents.get(i));
- return tmp;
+ synchronized (contents)
+ {
+ Vector f = files;
+ if (f == null)
+ {
+ f = new Vector();
+ Vector d = new Vector(); // Directories;
+ for (Iterator i = contents.iterator(); i.hasNext();)
+ {
+ File file = (File) i.next();
+ if (filechooser.isTraversable(file))
+ d.add(file);
+ else
+ f.add(file);
+ }
+ files = f;
+ directories = d;
+ }
+ return f;
+ }
}
/**
- * 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 +476,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ * Obsoleted method which does nothing.
*/
public void intervalRemoved(ListDataEvent e)
{
@@ -205,7 +484,7 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Obsoleted method which does nothing.
*/
public void invalidateFileCache()
{
@@ -213,12 +492,16 @@ public class BasicDirectoryModel extends AbstractListModel
}
/**
- * DOCUMENT ME!
+ * Less than, determine the relative order in the list of two files
+ * for sorting purposes.
+ *
+ * The order is: directories < files, and thereafter alphabetically,
+ * using the default locale collation.
*
- * @param a DOCUMENT ME!
- * @param b DOCUMENT ME!
+ * @param a the first file
+ * @param b the second file
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if a > b, <code>false</code> if a < b.
*/
protected boolean lt(File a, File b)
{
@@ -241,73 +524,66 @@ 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();
+ String property = e.getPropertyName();
+ if (property.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_HIDING_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)
+ || property.equals(JFileChooser.FILE_VIEW_CHANGED_PROPERTY)
+ )
+ {
+ 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 v)
{
Collections.sort(v, comparator);
- Enumeration e = Collections.enumeration(v);
- Vector tmp = new Vector();
- for (; e.hasMoreElements();)
- tmp.add(e.nextElement());
-
- contents = tmp;
}
/**
- * DOCUMENT ME!
+ * Re-loads the list of files
*/
public void validateFileCache()
{
- contents.clear();
- directories = 0;
- FileSystemView fsv = filechooser.getFileSystemView();
- File[] list = fsv.getFiles(filechooser.getCurrentDirectory(),
- filechooser.isFileHidingEnabled());
-
- if (list == null)
- return;
-
- for (int i = 0; i < list.length; i++)
+ File dir = filechooser.getCurrentDirectory();
+ if (dir != null)
{
- if (list[i] == null)
- continue;
- if (filechooser.accept(list[i]))
- {
- contents.add(list[i]);
- if (filechooser.isTraversable(list[i]))
- directories++;
- }
+ // Cancel all pending requests.
+ if (loadThread != null)
+ {
+ loadThread.interrupt();
+ loadThread.cancelPending();
+ }
+ loadThread = new DirectoryLoadThread(dir);
+ loadThread.start();
}
- sort(contents);
- filechooser.revalidate();
- filechooser.repaint();
}
}
+
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
index 1356db4aeec..dc1c051225c 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/libjava/classpath/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);
@@ -266,7 +268,14 @@ public class BasicFileChooserUI extends FileChooserUI
*/
public String getName(File f)
{
- return f.getName();
+ String name = null;
+ if (f != null)
+ {
+ JFileChooser c = getFileChooser();
+ FileSystemView v = c.getFileSystemView();
+ name = v.getSystemDisplayName(f);
+ }
+ return name;
}
/**
@@ -409,7 +418,7 @@ public class BasicFileChooserUI extends FileChooserUI
closeDialog();
}
}
- else
+ else // single click
{
String path = p.toString();
File f = fsv.createFileObject(path);
@@ -436,10 +445,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 +548,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the JFileChooser to the selected file on an update
*
* @param e DOCUMENT ME!
*/
@@ -550,9 +560,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 +768,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 --
@@ -874,7 +897,9 @@ public class BasicFileChooserUI extends FileChooserUI
protected void installListeners(JFileChooser fc)
{
propertyChangeListener = createPropertyChangeListener(filechooser);
- filechooser.addPropertyChangeListener(propertyChangeListener);
+ if (propertyChangeListener != null)
+ filechooser.addPropertyChangeListener(propertyChangeListener);
+ fc.addPropertyChangeListener(getModel());
}
/**
@@ -884,8 +909,12 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected void uninstallListeners(JFileChooser fc)
{
- filechooser.removePropertyChangeListener(propertyChangeListener);
- propertyChangeListener = null;
+ if (propertyChangeListener != null)
+ {
+ filechooser.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+ fc.removePropertyChangeListener(getModel());
}
/**
@@ -1046,12 +1075,8 @@ public class BasicFileChooserUI extends FileChooserUI
*/
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
{
- return new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent e)
- {
- }
- };
+ // The RI returns null here, so do we.
+ return null;
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java b/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java
index 068de345bec..1e84be93282 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import gnu.classpath.SystemProperties;
+
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
@@ -65,6 +67,14 @@ import javax.swing.SwingUtilities;
public class BasicGraphicsUtils
{
/**
+ * Used as a key for a client property to store cached TextLayouts in. This
+ * is used for speed-up drawing of text in
+ * {@link #drawString(Graphics, String, int, int, int)}.
+ */
+ static final String CACHED_TEXT_LAYOUT =
+ "BasicGraphicsUtils.cachedTextLayout";
+
+ /**
* Constructor. It is utterly unclear why this class should
* be constructable, but this is what the API specification
* says.
@@ -536,6 +546,170 @@ public class BasicGraphicsUtils
g2.fill(underline);
}
+ /**
+ * Draws a string on the specified component.
+ *
+ * @param c the component
+ * @param g the Graphics context
+ * @param text the string
+ * @param underlinedChar the character to be underlined
+ * @param x the X location
+ * @param y the Y location
+ */
+ static void drawString(JComponent c, Graphics g, String text,
+ int underlinedChar, int x, int y)
+ {
+ int index = -1;
+
+ /* It is intentional that lower case is used. In some languages,
+ * the set of lowercase characters is larger than the set of
+ * uppercase ones. Therefore, it is good practice to use lowercase
+ * for such comparisons (which really means that the author of this
+ * code can vaguely remember having read some Unicode techreport
+ * with this recommendation, but is too lazy to look for the URL).
+ */
+ if ((underlinedChar >= 0) || (underlinedChar <= 0xffff))
+ index = text.toLowerCase().indexOf(
+ Character.toLowerCase((char) underlinedChar));
+
+ drawStringUnderlineCharAt(c, g, text, index, x, y);
+ }
+
+
+ /**
+ * Draws a String at the given location, underlining the character
+ * at the specified index. Drawing is performed in the current color
+ * and font of <code>g</code>.
+ *
+ * <p><img src="doc-files/BasicGraphicsUtils-5.png" width="500"
+ * height="100" alt="[An illustration showing how to use the
+ * method]" />
+ *
+ * This is an accelerated version of the method with the same name. It
+ * uses a pre-laid out TextLayout stored in a client property.
+ *
+ * @param c the component that is drawn
+ * @param g the graphics into which the String is drawn.
+ *
+ * @param text the String to draw.
+ *
+ * @param underlinedIndex the index of the underlined character in
+ * <code>text</code>. If <code>underlinedIndex</code> falls
+ * outside the range <code>[0, text.length() - 1]</code>, the
+ * text will be drawn without underlining anything.
+ *
+ * @param x the x coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ *
+ * @param y the y coordinate of the text, as it would be passed to
+ * {@link java.awt.Graphics#drawString(java.lang.String,
+ * int, int)}.
+ */
+ static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text,
+ int underlinedIndex,
+ int x, int y)
+ {
+ Graphics2D g2;
+ Rectangle2D.Double underline;
+ FontRenderContext frc;
+ FontMetrics fmet;
+ LineMetrics lineMetrics;
+ Font font;
+ TextLayout layout;
+ double underlineX1, underlineX2;
+ boolean drawUnderline;
+ int textLength;
+
+ textLength = text.length();
+ if (textLength == 0)
+ return;
+
+ drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength);
+
+ // FIXME: unfortunately pango and cairo can't agree on metrics
+ // so for the time being we continue to *not* use TextLayouts.
+ if (!(g instanceof Graphics2D)
+ || SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") != null)
+ {
+ /* Fall-back. This is likely to produce garbage for any text
+ * containing right-to-left (Hebrew or Arabic) characters, even
+ * if the underlined character is left-to-right.
+ */
+ g.drawString(text, x, y);
+ if (drawUnderline)
+ {
+ fmet = g.getFontMetrics();
+ g.fillRect(
+ /* x */ x + fmet.stringWidth(text.substring(0, underlinedIndex)),
+ /* y */ y + fmet.getDescent() - 1,
+ /* width */ fmet.charWidth(text.charAt(underlinedIndex)),
+ /* height */ 1);
+ }
+
+ return;
+ }
+
+ g2 = (Graphics2D) g;
+ font = g2.getFont();
+ frc = g2.getFontRenderContext();
+ lineMetrics = font.getLineMetrics(text, frc);
+ layout = (TextLayout) c.getClientProperty(CACHED_TEXT_LAYOUT);
+ if (layout == null)
+ {
+ layout = new TextLayout(text, font, frc);
+ System.err.println("Unable to use cached TextLayout for: " + text);
+ }
+
+ /* Draw the text. */
+ layout.draw(g2, x, y);
+ if (!drawUnderline)
+ return;
+
+ underlineX1 = x + layout.getLogicalHighlightShape(
+ underlinedIndex, underlinedIndex).getBounds2D().getX();
+ underlineX2 = x + layout.getLogicalHighlightShape(
+ underlinedIndex + 1, underlinedIndex + 1).getBounds2D().getX();
+
+ underline = new Rectangle2D.Double();
+ if (underlineX1 < underlineX2)
+ {
+ underline.x = underlineX1;
+ underline.width = underlineX2 - underlineX1;
+ }
+ else
+ {
+ underline.x = underlineX2;
+ underline.width = underlineX1 - underlineX2;
+ }
+
+
+ underline.height = lineMetrics.getUnderlineThickness();
+ underline.y = lineMetrics.getUnderlineOffset();
+ if (underline.y == 0)
+ {
+ /* Some fonts do not specify an underline offset, although they
+ * actually should do so. In that case, the result of calling
+ * lineMetrics.getUnderlineOffset() will be zero. Since it would
+ * look very ugly if the underline was be positioned immediately
+ * below the baseline, we check for this and move the underline
+ * below the descent, as shown in the following ASCII picture:
+ *
+ * ##### ##### #
+ * # # # #
+ * # # # #
+ * # # # #
+ * ##### ###### ---- baseline (0)
+ * #
+ * #
+ * ------------------###----------- lineMetrics.getDescent()
+ */
+ underline.y = lineMetrics.getDescent();
+ }
+
+ underline.y += y;
+ g2.fill(underline);
+ }
/**
* Draws a rectangle, simulating a dotted stroke by painting only
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 23bcdc315ee..8f2181336cb 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -692,17 +691,12 @@ public class BasicInternalFrameUI extends InternalFrameUI
/** The MouseEvent target. */
private transient Component mouseEventTarget;
- /** The component pressed. */
- private transient Component pressedComponent;
+ private Component dragTarget;
- /** The last component entered. */
- private transient Component lastComponentEntered;
-
- /** Used to store/reset lastComponentEntered. */
- private transient Component tempComponent;
-
- /** The number of presses. */
- private transient int pressCount;
+ /**
+ * Indicates if we are currently in a dragging operation or not.
+ */
+ private boolean isDragging;
/**
* This method is called when the mouse enters the glass pane.
@@ -767,7 +761,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mousePressed(MouseEvent e)
{
- activateFrame(frame);
+ // Experiments show that this seems to call the
+ // borderListener.mousePressed() method to activate the frame.
+ if (borderListener != null)
+ borderListener.mousePressed(e);
handleEvent(e);
}
@@ -783,149 +780,104 @@ public class BasicInternalFrameUI extends InternalFrameUI
}
/**
- * This method acquires a candidate component to dispatch the MouseEvent to.
+ * This is a helper method that dispatches the GlassPane MouseEvents to the
+ * proper component.
*
- * @param me
- * The MouseEvent to acquire a component for.
+ * @param e the mouse event to be dispatched
*/
- private void acquireComponentForMouseEvent(MouseEvent me)
+ private void handleEvent(MouseEvent e)
{
- int x = me.getX();
- int y = me.getY();
-
- // Find the candidate which should receive this event.
- Component parent = frame.getLayeredPane();
- if (parent == null)
- return;
- Component candidate = null;
- Point p = me.getPoint();
- while (candidate == null && parent != null)
- {
- candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
- if (candidate == null)
- {
- p = SwingUtilities.convertPoint(parent, p.x, p.y,
- parent.getParent());
- parent = parent.getParent();
- }
- }
-
- // If the only candidate we found was the native container itself,
- // don't dispatch any event at all. We only care about the lightweight
- // children here.
- if (candidate == frame.getContentPane())
- candidate = null;
-
- // If our candidate is new, inform the old target we're leaving.
- if (lastComponentEntered != null && lastComponentEntered.isShowing()
- && lastComponentEntered != candidate)
+ // Find candidate component inside the JInternalFrame.
+ Component target = frame.getLayeredPane().findComponentAt(e.getX(),
+ e.getY());
+
+ // Now search upwards to find a component that actually has
+ // a MouseListener attached.
+ while (target != null
+ && target.getMouseListeners().length == 0
+ && target.getMouseMotionListeners().length == 0
+ && target.getMouseWheelListeners().length == 0)
{
- Point tp = SwingUtilities.convertPoint(frame.getContentPane(), x, y,
- lastComponentEntered);
- MouseEvent exited = new MouseEvent(lastComponentEntered,
- MouseEvent.MOUSE_EXITED,
- me.getWhen(), me.getModifiersEx(),
- tp.x, tp.y, me.getClickCount(),
- me.isPopupTrigger(),
- me.getButton());
- tempComponent = lastComponentEntered;
- lastComponentEntered = null;
- tempComponent.dispatchEvent(exited);
+ target = target.getParent();
}
- // If we have a candidate, maybe enter it.
- if (candidate != null)
+ if (target != null)
{
- mouseEventTarget = candidate;
- if (candidate.isLightweight() && candidate.isShowing()
- && candidate != frame.getContentPane()
- && candidate != lastComponentEntered)
- {
- lastComponentEntered = mouseEventTarget;
- Point cp = SwingUtilities.convertPoint(frame.getContentPane(), x,
- y, lastComponentEntered);
- MouseEvent entered = new MouseEvent(lastComponentEntered,
- MouseEvent.MOUSE_ENTERED,
- me.getWhen(),
- me.getModifiersEx(), cp.x,
- cp.y, me.getClickCount(),
- me.isPopupTrigger(),
- me.getButton());
- lastComponentEntered.dispatchEvent(entered);
- }
- }
-
- if (me.getID() == MouseEvent.MOUSE_RELEASED
- || me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
- || me.getID() == MouseEvent.MOUSE_DRAGGED)
- // If any of the following events occur while a button is held down,
- // they should be dispatched to the same component to which the
- // original MOUSE_PRESSED event was dispatched:
- // - MOUSE_RELEASED
- // - MOUSE_PRESSED: another button pressed while the first is held down
- // - MOUSE_DRAGGED
- mouseEventTarget = pressedComponent;
- else if (me.getID() == MouseEvent.MOUSE_CLICKED)
- {
- // Don't dispatch CLICKED events whose target is not the same as the
- // target for the original PRESSED event.
- if (candidate != pressedComponent)
- mouseEventTarget = null;
- else if (pressCount == 0)
- pressedComponent = null;
+ int id = e.getID();
+ switch (id)
+ {
+ case MouseEvent.MOUSE_ENTERED:
+ // Now redispatch the thing.
+ if (! isDragging || frame.isSelected())
+ {
+ mouseEventTarget = target;
+ redispatch(id, e, mouseEventTarget);
+ }
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ if (! isDragging || frame.isSelected())
+ {
+ redispatch(id, e, mouseEventTarget);
+ }
+ break;
+ case MouseEvent.MOUSE_PRESSED:
+ mouseEventTarget = target;
+ redispatch(id, e, mouseEventTarget);
+ // Start dragging.
+ dragTarget = target;
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ if (isDragging)
+ {
+ redispatch(id, e, dragTarget);
+ isDragging = false;
+ }
+ else
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_MOVED:
+ if (target != mouseEventTarget)
+ {
+ // Create additional MOUSE_EXITED/MOUSE_ENTERED pairs.
+ redispatch(MouseEvent.MOUSE_EXITED, e, mouseEventTarget);
+ mouseEventTarget = target;
+ redispatch(MouseEvent.MOUSE_ENTERED, e, mouseEventTarget);
+ }
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_DRAGGED:
+ if (! isDragging)
+ isDragging = true;
+ redispatch(id, e, mouseEventTarget);
+ break;
+ case MouseEvent.MOUSE_WHEEL:
+ redispatch(id, e, mouseEventTarget);
+ break;
+ default:
+ assert false : "Must not reach here";
+ }
}
}
/**
- * This is a helper method that dispatches the GlassPane MouseEvents to the
- * proper component.
- *
- * @param e
- * The AWTEvent to be dispatched. Usually an instance of
- * MouseEvent.
+ * Redispatches the event to the real target with the specified id.
+ *
+ * @param id the new event ID
+ * @param e the original event
+ * @param target the real event target
*/
- private void handleEvent(AWTEvent e)
+ private void redispatch(int id, MouseEvent e, Component target)
{
- if (e instanceof MouseEvent)
- {
- MouseEvent me = (MouseEvent) e;
- acquireComponentForMouseEvent(me);
-
- //If there is no target, return
- if (mouseEventTarget == null)
- return;
-
- //Avoid re-dispatching to ourselves and causing an infinite loop
- if (mouseEventTarget.equals(frame.getGlassPane()))
- return;
-
- // Avoid dispatching ENTERED and EXITED events twice.
- if (mouseEventTarget.isShowing()
- && e.getID() != MouseEvent.MOUSE_ENTERED
- && e.getID() != MouseEvent.MOUSE_EXITED)
- {
- MouseEvent newEvt = SwingUtilities.convertMouseEvent(
- frame.getGlassPane(),
- me,
- mouseEventTarget);
- mouseEventTarget.dispatchEvent(newEvt);
-
- switch (e.getID())
- {
- case MouseEvent.MOUSE_PRESSED:
- if (pressCount++ == 0)
- pressedComponent = mouseEventTarget;
- break;
- case MouseEvent.MOUSE_RELEASED:
- // Clear our memory of the original PRESSED event, only if
- // we're not expecting a CLICKED event after this. If
- // there is a CLICKED event after this, it will do clean up.
- if (--pressCount == 0 && mouseEventTarget != pressedComponent)
- pressedComponent = null;
- break;
- }
- }
- }
+ Point p = SwingUtilities.convertPoint(frame.getLayeredPane(), e.getX(),
+ e.getY(), target);
+ MouseEvent ev = new MouseEvent(target, id, e.getWhen(),
+ e.getModifiers() | e.getModifiersEx(),
+ p.x, p.y, e.getClickCount(),
+ e.isPopupTrigger());
+ target.dispatchEvent(ev);
}
}
@@ -945,41 +897,61 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void propertyChange(PropertyChangeEvent evt)
{
- if (evt.getPropertyName().equals(JInternalFrame.IS_MAXIMUM_PROPERTY))
+ String property = evt.getPropertyName();
+ if (property.equals(JInternalFrame.IS_MAXIMUM_PROPERTY))
{
if (frame.isMaximum())
maximizeFrame(frame);
else
minimizeFrame(frame);
}
- else if (evt.getPropertyName().equals(JInternalFrame.IS_ICON_PROPERTY))
+ else if (property.equals(JInternalFrame.IS_ICON_PROPERTY))
{
if (frame.isIcon())
iconifyFrame(frame);
else
deiconifyFrame(frame);
}
- else if (evt.getPropertyName().equals(JInternalFrame.IS_SELECTED_PROPERTY))
+ else if (property.equals(JInternalFrame.IS_SELECTED_PROPERTY))
{
+ Component glassPane = frame.getGlassPane();
if (frame.isSelected())
- activateFrame(frame);
+ {
+ activateFrame(frame);
+ glassPane.setVisible(false);
+ }
else
- deactivateFrame(frame);
+ {
+ deactivateFrame(frame);
+ glassPane.setVisible(true);
+ }
}
- else if (evt.getPropertyName().equals(JInternalFrame.ROOT_PANE_PROPERTY)
- || evt.getPropertyName().equals(
- JInternalFrame.GLASS_PANE_PROPERTY))
+ else if (property.equals(JInternalFrame.ROOT_PANE_PROPERTY)
+ || property.equals(JInternalFrame.GLASS_PANE_PROPERTY))
{
Component old = (Component) evt.getOldValue();
- old.removeMouseListener(glassPaneDispatcher);
- old.removeMouseMotionListener(glassPaneDispatcher);
+ if (old != null)
+ {
+ old.removeMouseListener(glassPaneDispatcher);
+ old.removeMouseMotionListener(glassPaneDispatcher);
+ }
Component newPane = (Component) evt.getNewValue();
- newPane.addMouseListener(glassPaneDispatcher);
- newPane.addMouseMotionListener(glassPaneDispatcher);
+ if (newPane != null)
+ {
+ newPane.addMouseListener(glassPaneDispatcher);
+ newPane.addMouseMotionListener(glassPaneDispatcher);
+ }
frame.revalidate();
}
+ else if (property.equals(JInternalFrame.IS_CLOSED_PROPERTY))
+ {
+ if (evt.getNewValue() == Boolean.TRUE)
+ {
+ closeFrame(frame);
+ }
+ }
/*
* FIXME: need to add ancestor properties to JComponents. else if
* (evt.getPropertyName().equals(JComponent.ANCESTOR_PROPERTY)) { if
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java
index 60e3a98684f..304e13ad735 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicLabelUI.java
@@ -1,5 +1,5 @@
/* BasicLabelUI.java
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,20 +37,25 @@
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Color;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
import javax.swing.Icon;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLabel;
+import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
@@ -369,14 +374,39 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
}
/**
- * This method installs the keyboard actions for the given {@link JLabel}.
+ * Installs the keyboard actions for the given {@link JLabel}.
*
* @param l The {@link JLabel} to install keyboard actions for.
*/
protected void installKeyboardActions(JLabel l)
- throws NotImplementedException
{
- //FIXME: implement.
+ Component c = l.getLabelFor();
+ if (c != null)
+ {
+ int mnemonic = l.getDisplayedMnemonic();
+ if (mnemonic > 0)
+ {
+ // add a keystroke for the given mnemonic mapping to 'press';
+ InputMap keyMap = new InputMap();
+ keyMap.put(KeyStroke.getKeyStroke(mnemonic, KeyEvent.VK_ALT),
+ "press");
+ SwingUtilities.replaceUIInputMap(l,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
+
+ // add an action to focus the component when 'press' happens
+ ActionMap map = new ActionMap();
+ map.put("press", new AbstractAction() {
+ public void actionPerformed(ActionEvent event)
+ {
+ JLabel label = (JLabel) event.getSource();
+ Component c = label.getLabelFor();
+ if (c != null)
+ c.requestFocus();
+ }
+ });
+ SwingUtilities.replaceUIActionMap(l, map);
+ }
+ }
}
/**
@@ -385,9 +415,10 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* @param l The {@link JLabel} to uninstall keyboard actions for.
*/
protected void uninstallKeyboardActions(JLabel l)
- throws NotImplementedException
{
- //FIXME: implement.
+ SwingUtilities.replaceUIActionMap(l, null);
+ SwingUtilities.replaceUIInputMap(l, JComponent.WHEN_IN_FOCUSED_WINDOW,
+ null);
}
/**
@@ -426,5 +457,30 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
JLabel l = (JLabel) e.getSource();
BasicHTML.updateRenderer(l, text);
}
+ else if (e.getPropertyName().equals("displayedMnemonic"))
+ {
+ // update the key to action mapping
+ JLabel label = (JLabel) e.getSource();
+ if (label.getLabelFor() != null)
+ {
+ int oldMnemonic = ((Integer) e.getOldValue()).intValue();
+ int newMnemonic = ((Integer) e.getNewValue()).intValue();
+ InputMap keyMap = label.getInputMap(
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ keyMap.put(KeyStroke.getKeyStroke(oldMnemonic,
+ KeyEvent.ALT_DOWN_MASK), null);
+ keyMap.put(KeyStroke.getKeyStroke(newMnemonic,
+ KeyEvent.ALT_DOWN_MASK), "press");
+ }
+ }
+ else if (e.getPropertyName().equals("labelFor"))
+ {
+ JLabel label = (JLabel) e.getSource();
+ InputMap keyMap = label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
+ int mnemonic = label.getDisplayedMnemonic();
+ if (mnemonic > 0)
+ keyMap.put(KeyStroke.getKeyStroke(mnemonic, KeyEvent.ALT_DOWN_MASK),
+ "press");
+ }
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
index 44f6a408984..493fc0578e3 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -61,12 +59,12 @@ import javax.swing.DefaultListSelectionModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JList;
-import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
+import javax.swing.TransferHandler;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ListDataEvent;
@@ -76,8 +74,8 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.ListUI;
+import javax.swing.plaf.UIResource;
/**
* The Basic Look and Feel UI delegate for the
@@ -215,9 +213,26 @@ public class BasicListUI extends ListUI
target.actionPerformed(derivedEvent);
}
}
-
- class ListAction extends AbstractAction
+
+ /**
+ * Implements the action for the JList's keyboard commands.
+ */
+ private class ListAction
+ extends AbstractAction
{
+ // TODO: Maybe make a couple of classes out of this bulk Action.
+ // Form logical groups of Actions when doing this.
+
+ /**
+ * Creates a new ListAction for the specified command.
+ *
+ * @param cmd the actionCommand to set
+ */
+ ListAction(String cmd)
+ {
+ putValue(ACTION_COMMAND_KEY, cmd);
+ }
+
public void actionPerformed(ActionEvent e)
{
int lead = list.getLeadSelectionIndex();
@@ -398,7 +413,7 @@ public class BasicListUI extends ListUI
list.ensureIndexIsVisible(list.getLeadSelectionIndex());
}
}
-
+
/**
* A helper class which listens for {@link MouseEvent}s
* from the {@link JList}.
@@ -464,7 +479,8 @@ public class BasicListUI extends ListUI
*/
public void mousePressed(MouseEvent event)
{
- // TODO: What should be done here, if anything?
+ // We need to explicitly request focus.
+ list.requestFocusInWindow();
}
/**
@@ -992,39 +1008,83 @@ public class BasicListUI extends ListUI
*/
protected void installKeyboardActions()
{
+ // Install UI InputMap.
InputMap focusInputMap = (InputMap) UIManager.get("List.focusInputMap");
- InputMapUIResource parentInputMap = new InputMapUIResource();
- // FIXME: The JDK uses a LazyActionMap for parentActionMap
- ActionMap parentActionMap = new ActionMapUIResource();
- action = new ListAction();
- Object keys[] = focusInputMap.allKeys();
- // Register key bindings in the UI InputMap-ActionMap pair
- for (int i = 0; i < keys.length; i++)
+ SwingUtilities.replaceUIInputMap(list, JComponent.WHEN_FOCUSED,
+ focusInputMap);
+
+ // Install UI ActionMap.
+ ActionMap am = (ActionMap) UIManager.get("List.actionMap");
+ if (am == null)
{
- KeyStroke stroke = (KeyStroke) keys[i];
- String actionString = (String) focusInputMap.get(stroke);
- parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
- stroke.getModifiers()),
- actionString);
-
- parentActionMap.put(actionString,
- new ActionListenerProxy(action, actionString));
+ // Create the actionMap once and store it in the current UIDefaults
+ // for use in other components.
+ am = new ActionMapUIResource();
+ ListAction action;
+ action = new ListAction("selectPreviousRow");
+ am.put("selectPreviousRow", action);
+ action = new ListAction("selectNextRow");
+ am.put("selectNextRow", action);
+ action = new ListAction("selectPreviousRowExtendSelection");
+ am.put("selectPreviousRowExtendSelection", action);
+ action = new ListAction("selectNextRowExtendSelection");
+ am.put("selectNextRowExtendSelection", action);
+
+ action = new ListAction("selectPreviousColumn");
+ am.put("selectPreviousColumn", action);
+ action = new ListAction("selectNextColumn");
+ am.put("selectNextColumn", action);
+ action = new ListAction("selectPreviousColumnExtendSelection");
+ am.put("selectPreviousColumnExtendSelection", action);
+ action = new ListAction("selectNextColumnExtendSelection");
+ am.put("selectNextColumnExtendSelection", action);
+
+ action = new ListAction("selectFirstRow");
+ am.put("selectFirstRow", action);
+ action = new ListAction("selectLastRow");
+ am.put("selectLastRow", action);
+ action = new ListAction("selectFirstRowExtendSelection");
+ am.put("selectFirstRowExtendSelection", action);
+ action = new ListAction("selectLastRowExtendSelection");
+ am.put("selectLastRowExtendSelection", action);
+
+ action = new ListAction("scrollUp");
+ am.put("scrollUp", action);
+ action = new ListAction("scrollUpExtendSelection");
+ am.put("scrollUpExtendSelection", action);
+ action = new ListAction("scrollDown");
+ am.put("scrollDown", action);
+ action = new ListAction("scrollDownExtendSelection");
+ am.put("scrollDownExtendSelection", action);
+
+ action = new ListAction("selectAll");
+ am.put("selectAll", action);
+ action = new ListAction("clearSelection");
+ am.put("clearSelection", action);
+
+ am.put("copy", TransferHandler.getCopyAction());
+ am.put("cut", TransferHandler.getCutAction());
+ am.put("paste", TransferHandler.getPasteAction());
+
+ UIManager.put("List.actionMap", am);
}
- // Register the new InputMap-ActionMap as the parents of the list's
- // InputMap and ActionMap
- parentInputMap.setParent(list.getInputMap().getParent());
- parentActionMap.setParent(list.getActionMap().getParent());
- list.getInputMap().setParent(parentInputMap);
- list.getActionMap().setParent(parentActionMap);
+
+ SwingUtilities.replaceUIActionMap(list, am);
}
/**
* Uninstalls keyboard actions for this UI in the {@link JList}.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // TODO: Implement this properly.
+ // Uninstall the InputMap.
+ InputMap im = SwingUtilities.getUIInputMap(list, JComponent.WHEN_FOCUSED);
+ if (im instanceof UIResource)
+ SwingUtilities.replaceUIInputMap(list, JComponent.WHEN_FOCUSED, null);
+
+ // Uninstall the ActionMap.
+ if (SwingUtilities.getUIActionMap(list) instanceof UIResource)
+ SwingUtilities.replaceUIActionMap(list, null);
}
/**
@@ -1151,7 +1211,7 @@ public class BasicListUI extends ListUI
boolean hasFocus = (list.getLeadSelectionIndex() == row) && BasicListUI.this.list.hasFocus();
Component comp = rend.getListCellRendererComponent(list,
data.getElementAt(row),
- 0, isSel, hasFocus);
+ row, isSel, hasFocus);
rendererPane.paintComponent(g, comp, list, bounds);
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
index 0f6e0243fcf..c056a2403f9 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -64,6 +64,7 @@ import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
+import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
import javax.swing.MenuSelectionManager;
@@ -129,7 +130,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel
if (target instanceof Container)
target = ((Container) target).findComponentAt(ev.getPoint());
if (m.getSelectedPath().length > 0
- && ! m.isComponentPartOfCurrentMenu(target))
+ && ! m.isComponentPartOfCurrentMenu(target)
+ && (((JComponent)target).getClientProperty(DONT_CANCEL_POPUP) == null
+ || !((JComponent)target).getClientProperty(DONT_CANCEL_POPUP).equals(Boolean.TRUE)))
{
m.clearSelectedPath();
}
@@ -1028,6 +1031,25 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"PopupMenu.border", new BorderUIResource.BevelBorderUIResource(0),
"PopupMenu.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"PopupMenu.foreground", new ColorUIResource(darkShadow),
+ "PopupMenu.selectedWindowInputMapBindings",
+ new Object[] {"ESCAPE", "cancel",
+ "DOWN", "selectNext",
+ "KP_DOWN", "selectNext",
+ "UP", "selectPrevious",
+ "KP_UP", "selectPrevious",
+ "LEFT", "selectParent",
+ "KP_LEFT", "selectParent",
+ "RIGHT", "selectChild",
+ "KP_RIGHT", "selectChild",
+ "ENTER", "return",
+ "SPACE", "return"
+ },
+ "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
+ new Object[] {"LEFT", "selectChild",
+ "KP_LEFT", "selectChild",
+ "RIGHT", "selectParent",
+ "KP_RIGHT", "selectParent",
+ },
"ProgressBar.background", new ColorUIResource(Color.LIGHT_GRAY),
"ProgressBar.border",
new BorderUIResource.LineBorderUIResource(Color.GREEN, 2),
@@ -1607,7 +1629,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"Tree.foreground", new ColorUIResource(Color.black),
- "Tree.hash", new ColorUIResource(new Color(128, 128, 128)),
+ "Tree.hash", new ColorUIResource(new Color(184, 207, 228)),
"Tree.leftChildIndent", new Integer(7),
"Tree.rightChildIndent", new Integer(13),
"Tree.rowHeight", new Integer(16),
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java
index f258ebe3069..cd25a3baf77 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java
@@ -38,24 +38,31 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Dimension;
+import java.awt.event.ActionEvent;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.BoxLayout;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.LookAndFeel;
import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
@@ -64,6 +71,47 @@ import javax.swing.plaf.MenuBarUI;
*/
public class BasicMenuBarUI extends MenuBarUI
{
+
+ /**
+ * This action is performed for the action command 'takeFocus'.
+ */
+ private static class FocusAction
+ extends AbstractAction
+ {
+
+ /**
+ * Creates a new FocusAction.
+ */
+ FocusAction()
+ {
+ super("takeFocus");
+ }
+
+ /**
+ * Performs the action.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ // In the JDK this action seems to pop up the first menu of the
+ // menu bar.
+ JMenuBar menuBar = (JMenuBar) event.getSource();
+ MenuSelectionManager defaultManager =
+ MenuSelectionManager.defaultManager();
+ MenuElement me[];
+ MenuElement subElements[];
+ JMenu menu = menuBar.getMenu(0);
+ if (menu != null)
+ {
+ me = new MenuElement[3];
+ me[0] = (MenuElement) menuBar;
+ me[1] = (MenuElement) menu;
+ me[2] = (MenuElement) menu.getPopupMenu();
+ defaultManager.setSelectedPath(me);
+ }
+ }
+
+ }
+
protected ChangeListener changeListener;
/*ContainerListener that listens to the ContainerEvents fired from menu bar*/
@@ -178,9 +226,46 @@ public class BasicMenuBarUI extends MenuBarUI
* This method installs the keyboard actions for the JMenuBar.
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement
+ // Install InputMap.
+ Object[] bindings =
+ (Object[]) SharedUIDefaults.get("MenuBar.windowBindings");
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(menuBar, bindings);
+ SwingUtilities.replaceUIInputMap(menuBar,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // Install ActionMap.
+ SwingUtilities.replaceUIActionMap(menuBar, getActionMap());
+ }
+
+ /**
+ * Creates and returns the shared action map for JTrees.
+ *
+ * @return the shared action map for JTrees
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("MenuBar.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("MenuBar.actionMap", am);
+ }
+ return am;
+ }
+
+ /**
+ * Creates the default actions when there are none specified by the L&F.
+ *
+ * @return the default actions
+ */
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new FocusAction();
+ am.put(action.getValue(Action.NAME), action);
+ return am;
}
/**
@@ -226,9 +311,10 @@ public class BasicMenuBarUI extends MenuBarUI
* This method reverses the work done in installKeyboardActions.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement.
+ SwingUtilities.replaceUIInputMap(menuBar,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, null);
+ SwingUtilities.replaceUIActionMap(menuBar, null);
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
index 63a09bff6a2..bbc08535cdc 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import gnu.classpath.SystemProperties;
+
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -52,11 +54,15 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
import javax.swing.ActionMap;
import javax.swing.ButtonModel;
import javax.swing.Icon;
@@ -237,7 +243,8 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void propertyChange(PropertyChangeEvent e)
{
- if (e.getPropertyName() == "accelerator")
+ String property = e.getPropertyName();
+ if (property.equals("accelerator"))
{
InputMap map = SwingUtilities.getUIInputMap(menuItem,
JComponent.WHEN_IN_FOCUSED_WINDOW);
@@ -250,6 +257,22 @@ public class BasicMenuItemUI extends MenuItemUI
if (accelerator != null)
map.put(accelerator, "doClick");
}
+ // TextLayout caching for speed-up drawing of text.
+ else if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+ || property.equals("font"))
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+ == null)
+
+ {
+ AbstractButton b = (AbstractButton) e.getSource();
+ String text = b.getText();
+ if (text == null)
+ text = "";
+ FontRenderContext frc = new FontRenderContext(new AffineTransform(),
+ false, false);
+ TextLayout layout = new TextLayout(text, b.getFont(), frc);
+ b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
+ }
}
}
@@ -833,12 +856,13 @@ public class BasicMenuItemUI extends MenuItemUI
int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
if (mnemonicIndex != -1)
- BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex,
+ BasicGraphicsUtils.drawStringUnderlineCharAt(menuItem, g, text,
+ mnemonicIndex,
textRect.x,
textRect.y
+ fm.getAscent());
else
- BasicGraphicsUtils.drawString(g, text, 0, textRect.x,
+ BasicGraphicsUtils.drawString(menuItem, g, text, 0, textRect.x,
textRect.y + fm.getAscent());
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
index f8936be5b66..7d8784fd15a 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
@@ -220,9 +220,8 @@ public class BasicMenuUI extends BasicMenuItemUI
*
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Need to implement
+ super.installKeyboardActions();
}
/**
@@ -230,13 +229,12 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
protected void installListeners()
{
- ((JMenu) menuItem).addMouseListener(mouseInputListener);
- ((JMenu) menuItem).addMouseMotionListener(mouseInputListener);
+ super.installListeners();
((JMenu) menuItem).addMenuListener(menuListener);
- ((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener);
}
protected void setupPostTimer(JMenu menu)
+ throws NotImplementedException
{
// TODO: Implement this properly.
}
@@ -265,9 +263,8 @@ public class BasicMenuUI extends BasicMenuItemUI
* Basic look and feel's defaults.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Need to implement
+ super.installKeyboardActions();
}
/**
@@ -276,9 +273,8 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
protected void uninstallListeners()
{
- ((JMenu) menuItem).removeMouseListener(mouseInputListener);
+ super.uninstallListeners();
((JMenu) menuItem).removeMenuListener(menuListener);
- ((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener);
}
/**
@@ -351,7 +347,7 @@ public class BasicMenuUI extends BasicMenuItemUI
public void mouseMoved(MouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
public void mousePressed(MouseEvent e)
@@ -472,7 +468,8 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public ChangeHandler(JMenu m, BasicMenuUI ui)
{
- // Not used.
+ menu = m;
+ this.ui = ui;
}
/**
@@ -520,7 +517,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
/**
@@ -531,7 +528,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
}
@@ -548,7 +545,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuKeyPressed(MenuKeyEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
/**
@@ -558,7 +555,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuKeyReleased(MenuKeyEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
/**
@@ -568,6 +565,7 @@ public class BasicMenuUI extends BasicMenuItemUI
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyTyped(MenuKeyEvent e)
+ throws NotImplementedException
{
// TODO: What should be done here, if anything?
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
index 9acf8210d9e..e2380858098 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -38,13 +38,12 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -58,10 +57,14 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
+import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
@@ -76,6 +79,7 @@ import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.OptionPaneUI;
@@ -85,6 +89,21 @@ import javax.swing.plaf.OptionPaneUI;
public class BasicOptionPaneUI extends OptionPaneUI
{
/**
+ * Implements the "close" keyboard action.
+ */
+ static class OptionPaneCloseAction
+ extends AbstractAction
+ {
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JOptionPane op = (JOptionPane) event.getSource();
+ op.setValue(new Integer(JOptionPane.CLOSED_OPTION));
+ }
+
+ }
+
+ /**
* This is a helper class that listens to the buttons located at the bottom
* of the JOptionPane.
*
@@ -389,36 +408,20 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
public void propertyChange(PropertyChangeEvent e)
{
- if (e.getPropertyName().equals(JOptionPane.ICON_PROPERTY)
- || e.getPropertyName().equals(JOptionPane.MESSAGE_TYPE_PROPERTY))
- addIcon(messageAreaContainer);
- else if (e.getPropertyName().equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY))
- resetSelectedValue();
- else if (e.getPropertyName().equals(JOptionPane.INITIAL_VALUE_PROPERTY)
- || e.getPropertyName().equals(JOptionPane.OPTIONS_PROPERTY)
- || e.getPropertyName().equals(JOptionPane.OPTION_TYPE_PROPERTY))
+ String property = e.getPropertyName();
+ if (property.equals(JOptionPane.ICON_PROPERTY)
+ || property.equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY)
+ || property.equals(JOptionPane.INITIAL_VALUE_PROPERTY)
+ || property.equals(JOptionPane.MESSAGE_PROPERTY)
+ || property.equals(JOptionPane.MESSAGE_TYPE_PROPERTY)
+ || property.equals(JOptionPane.OPTION_TYPE_PROPERTY)
+ || property.equals(JOptionPane.OPTIONS_PROPERTY)
+ || property.equals(JOptionPane.WANTS_INPUT_PROPERTY))
{
- Container newButtons = createButtonArea();
- optionPane.remove(buttonContainer);
- optionPane.add(newButtons);
- buttonContainer = newButtons;
+ uninstallComponents();
+ installComponents();
+ optionPane.validate();
}
-
- else if (e.getPropertyName().equals(JOptionPane.MESSAGE_PROPERTY)
- || e.getPropertyName().equals(JOptionPane.WANTS_INPUT_PROPERTY)
- || e.getPropertyName().equals(JOptionPane.SELECTION_VALUES_PROPERTY))
- {
- optionPane.remove(messageAreaContainer);
- messageAreaContainer = createMessageArea();
- optionPane.add(messageAreaContainer);
- Container newButtons = createButtonArea();
- optionPane.remove(buttonContainer);
- optionPane.add(newButtons);
- buttonContainer = newButtons;
- optionPane.add(buttonContainer);
- }
- optionPane.invalidate();
- optionPane.repaint();
}
}
@@ -460,17 +463,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
protected JOptionPane optionPane;
/** The size of the icons. */
- // FIXME: wrong name for a constant.
- private static final int iconSize = 36;
-
- /** The foreground color for the message area. */
- private transient Color messageForeground;
-
- /** The border around the message area. */
- private transient Border messageBorder;
-
- /** The border around the button area. */
- private transient Border buttonBorder;
+ private static final int ICON_SIZE = 36;
/** The string used to describe OK buttons. */
private static final String OK_STRING = "OK";
@@ -505,7 +498,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
public int getIconWidth()
{
- return iconSize;
+ return ICON_SIZE;
}
/**
@@ -515,7 +508,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
public int getIconHeight()
{
- return iconSize;
+ return ICON_SIZE;
}
/**
@@ -566,7 +559,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
// Should be purple.
g.setColor(Color.RED);
- g.fillOval(0, 0, iconSize, iconSize);
+ g.fillOval(0, 0, ICON_SIZE, ICON_SIZE);
g.setColor(Color.BLACK);
g.drawOval(16, 6, 4, 4);
@@ -615,7 +608,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
Color saved = g.getColor();
g.setColor(Color.GREEN);
- g.fillRect(0, 0, iconSize, iconSize);
+ g.fillRect(0, 0, ICON_SIZE, ICON_SIZE);
g.setColor(Color.BLACK);
@@ -623,7 +616,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
g.drawOval(14, 5, 10, 10);
g.setColor(Color.GREEN);
- g.fillRect(0, 10, iconSize, iconSize - 10);
+ g.fillRect(0, 10, ICON_SIZE, ICON_SIZE - 10);
g.setColor(Color.BLACK);
@@ -640,10 +633,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
}
};
- // FIXME: Uncomment when the ImageIcons are fixed.
-
- /* IconUIResource warningIcon, questionIcon, infoIcon, errorIcon;*/
-
/**
* Creates a new BasicOptionPaneUI object.
*/
@@ -705,6 +694,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
if (icon != null)
{
iconLabel = new JLabel(icon);
+ configureLabel(iconLabel);
top.add(iconLabel, BorderLayout.WEST);
}
}
@@ -766,7 +756,9 @@ public class BasicOptionPaneUI extends OptionPaneUI
}
else if (msg instanceof Icon)
{
- container.add(new JLabel((Icon) msg), cons);
+ JLabel label = new JLabel((Icon) msg);
+ configureLabel(label);
+ container.add(label, cons);
cons.gridy++;
}
else
@@ -783,8 +775,11 @@ public class BasicOptionPaneUI extends OptionPaneUI
addMessageComponents(container, cons, tmp, maxll, true);
}
else
- addMessageComponents(container, cons, new JLabel(msg.toString()),
- maxll, true);
+ {
+ JLabel label = new JLabel(msg.toString());
+ configureLabel(label);
+ addMessageComponents(container, cons, label, maxll, true);
+ }
}
}
@@ -815,6 +810,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
remainder = d.substring(maxll);
}
JLabel label = new JLabel(line);
+ configureLabel(label);
c.add(label);
// If there is nothing left to burst, then we can stop.
@@ -825,8 +821,12 @@ public class BasicOptionPaneUI extends OptionPaneUI
if (remainder.length() > maxll || remainder.contains("\n"))
burstStringInto(c, remainder, maxll);
else
- // Add the remainder to the container and be done.
- c.add(new JLabel(remainder));
+ {
+ // Add the remainder to the container and be done.
+ JLabel l = new JLabel(remainder);
+ configureLabel(l);
+ c.add(l);
+ }
}
/**
@@ -862,6 +862,9 @@ public class BasicOptionPaneUI extends OptionPaneUI
protected Container createButtonArea()
{
JPanel buttonPanel = new JPanel();
+ Border b = UIManager.getBorder("OptionPane.buttonAreaBorder");
+ if (b != null)
+ buttonPanel.setBorder(b);
buttonPanel.setLayout(createLayoutManager());
addButtonComponents(buttonPanel, getButtons(), getInitialValueIndex());
@@ -887,6 +890,10 @@ public class BasicOptionPaneUI extends OptionPaneUI
protected Container createMessageArea()
{
JPanel messageArea = new JPanel();
+ Border messageBorder = UIManager.getBorder("OptionPane.messageAreaBorder");
+ if (messageBorder != null)
+ messageArea.setBorder(messageBorder);
+
messageArea.setLayout(new BorderLayout());
addIcon(messageArea);
@@ -941,8 +948,9 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
protected Container createSeparator()
{
- // FIXME: Figure out what this method is supposed to return and where
- // this should be added to the OptionPane.
+ // The reference implementation returns null here. When overriding
+ // to return something non-null, the component gets added between
+ // the message area and the button area. See installComponents().
return null;
}
@@ -1143,35 +1151,17 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
protected void installComponents()
{
- // reset it.
- hasCustomComponents = false;
- Container msg = createMessageArea();
- if (msg != null)
- {
- ((JComponent) msg).setBorder(messageBorder);
- msg.setForeground(messageForeground);
- messageAreaContainer = msg;
- optionPane.add(msg);
- }
+ // First thing is the message area.
+ optionPane.add(createMessageArea());
- // FIXME: Figure out if the separator should be inserted here or what
- // this thing is supposed to do. Note: The JDK does NOT insert another
- // component at this place. The JOptionPane only has two panels in it
- // and there actually are applications that depend on this beeing so.
+ // Add separator when createSeparator() is overridden to return
+ // something other than null.
Container sep = createSeparator();
if (sep != null)
optionPane.add(sep);
- Container button = createButtonArea();
- if (button != null)
- {
- ((JComponent) button).setBorder(buttonBorder);
- buttonContainer = button;
- optionPane.add(button);
- }
-
- optionPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
- optionPane.invalidate();
+ // Last thing is the button area.
+ optionPane.add(createButtonArea());
}
/**
@@ -1185,10 +1175,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
LookAndFeel.installBorder(optionPane, "OptionPane.border");
optionPane.setOpaque(true);
- messageBorder = UIManager.getBorder("OptionPane.messageAreaBorder");
- messageForeground = UIManager.getColor("OptionPane.messageForeground");
- buttonBorder = UIManager.getBorder("OptionPane.buttonAreaBorder");
-
minimumSize = UIManager.getDimension("OptionPane.minimumSize");
// FIXME: Image icons don't seem to work properly right now.
@@ -1206,9 +1192,44 @@ public class BasicOptionPaneUI extends OptionPaneUI
* This method installs keyboard actions for the JOptionpane.
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement.
+ // Install the input map.
+ Object[] bindings =
+ (Object[]) SharedUIDefaults.get("OptionPane.windowBindings");
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(optionPane,
+ bindings);
+ SwingUtilities.replaceUIInputMap(optionPane,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ SwingUtilities.replaceUIActionMap(optionPane, getActionMap());
+ }
+
+ /**
+ * Fetches the action map from the UI defaults, or create a new one
+ * if the action map hasn't been initialized.
+ *
+ * @return the action map
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("OptionPane.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("OptionPane.actionMap", am);
+ }
+ return am;
+ }
+
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new OptionPaneCloseAction();
+
+ am.put("close", action);
+ return am;
}
/**
@@ -1321,10 +1342,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
minimumSize = null;
- messageBorder = null;
- buttonBorder = null;
- messageForeground = null;
-
// FIXME: ImageIcons don't seem to work properly
/*
@@ -1339,9 +1356,10 @@ public class BasicOptionPaneUI extends OptionPaneUI
* This method uninstalls keyboard actions for the JOptionPane.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement.
+ SwingUtilities.replaceUIInputMap(optionPane, JComponent.
+ WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ SwingUtilities.replaceUIActionMap(optionPane, null);
}
/**
@@ -1367,4 +1385,20 @@ public class BasicOptionPaneUI extends OptionPaneUI
optionPane = null;
}
+
+ /**
+ * Applies the proper UI configuration to labels that are added to
+ * the OptionPane.
+ *
+ * @param l the label to configure
+ */
+ private void configureLabel(JLabel l)
+ {
+ Color c = UIManager.getColor("OptionPane.messageForeground");
+ if (c != null)
+ l.setForeground(c);
+ Font f = UIManager.getFont("OptionPane.messageFont");
+ if (f != null)
+ l.setFont(f);
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java
index a26a5c7c46b..8c0fe6757e3 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -37,33 +37,574 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.KeyboardFocusManager;
+import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
+import java.util.EventListener;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.BoxLayout;
+import javax.swing.InputMap;
+import javax.swing.JApplet;
import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.JRootPane;
import javax.swing.LookAndFeel;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PopupMenuUI;
-
/**
* UI Delegate for JPopupMenu
*/
public class BasicPopupMenuUI extends PopupMenuUI
{
+ /**
+ * Handles keyboard navigation through menus.
+ */
+ private static class NavigateAction
+ extends AbstractAction
+ {
+
+ /**
+ * Creates a new NavigateAction instance.
+ *
+ * @param name the name of the action
+ */
+ NavigateAction(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Actually performs the action.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ String name = (String) getValue(Action.NAME);
+ if (name.equals("selectNext"))
+ navigateNextPrevious(true);
+ else if (name.equals("selectPrevious"))
+ navigateNextPrevious(false);
+ else if (name.equals("selectChild"))
+ navigateParentChild(true);
+ else if (name.equals("selectParent"))
+ navigateParentChild(false);
+ else if (name.equals("cancel"))
+ cancel();
+ else if (name.equals("return"))
+ doReturn();
+ else
+ assert false : "Must not reach here";
+ }
+
+ /**
+ * Navigates to the next or previous menu item.
+ *
+ * @param dir <code>true</code>: navigate to next, <code>false</code>:
+ * navigate to previous
+ */
+ private void navigateNextPrevious(boolean dir)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ int len = path.length;
+ if (len >= 2)
+ {
+
+ if (path[0] instanceof JMenuBar &&
+ path[1] instanceof JMenu && len == 2)
+ {
+
+ // A toplevel menu is selected, but its popup not yet shown.
+ // Show the popup and select the first item
+ JPopupMenu popup = ((JMenu)path[1]).getPopupMenu();
+ MenuElement next =
+ findEnabledChild(popup.getSubElements(), -1, true);
+ MenuElement[] newPath;
+
+ if (next != null)
+ {
+ newPath = new MenuElement[4];
+ newPath[3] = next;
+ }
+ else
+ {
+ // Menu has no enabled items, show the popup anyway.
+ newPath = new MenuElement[3];
+ }
+ System.arraycopy(path, 0, newPath, 0, 2);
+ newPath[2] = popup;
+ msm.setSelectedPath(newPath);
+ }
+ else if (path[len - 1] instanceof JPopupMenu &&
+ path[len - 2] instanceof JMenu)
+ {
+ // Select next item in already shown popup menu.
+ JMenu menu = (JMenu) path[len - 2];
+ JPopupMenu popup = menu.getPopupMenu();
+ MenuElement next =
+ findEnabledChild(popup.getSubElements(), -1, dir);
+
+ if (next != null)
+ {
+ MenuElement[] newPath = new MenuElement[len + 1];
+ System.arraycopy(path, 0, newPath, 0, len);
+ newPath[len] = next;
+ msm.setSelectedPath(newPath);
+ }
+ else
+ {
+ // All items in the popup are disabled.
+ // Find the parent popup menu and select
+ // its next item. If there's no parent popup menu , do nothing.
+ if (len > 2 && path[len - 3] instanceof JPopupMenu)
+ {
+ popup = ((JPopupMenu) path[len - 3]);
+ next = findEnabledChild(popup.getSubElements(),
+ menu, dir);
+ if (next != null && next != menu)
+ {
+ MenuElement[] newPath = new MenuElement[len - 1];
+ System.arraycopy(path, 0, newPath, 0, len - 2);
+ newPath[len - 2] = next;
+ msm.setSelectedPath(newPath);
+ }
+ }
+ }
+ }
+ else
+ {
+ // Only select the next item.
+ MenuElement subs[] = path[len - 2].getSubElements();
+ MenuElement nextChild =
+ findEnabledChild(subs, path[len - 1], dir);
+ if (nextChild == null)
+ {
+ nextChild = findEnabledChild(subs, -1, dir);
+ }
+ if (nextChild != null)
+ {
+ path[len-1] = nextChild;
+ msm.setSelectedPath(path);
+ }
+ }
+ }
+ }
+
+ private MenuElement findEnabledChild(MenuElement[] children,
+ MenuElement start, boolean dir)
+ {
+ MenuElement found = null;
+ for (int i = 0; i < children.length && found == null; i++)
+ {
+ if (children[i] == start)
+ {
+ found = findEnabledChild(children, i, dir);
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Searches the next or previous enabled child menu element.
+ *
+ * @param children the children to search through
+ * @param start the index at which to start
+ * @param dir the direction (true == forward, false == backward)
+ *
+ * @return the found element or null
+ */
+ private MenuElement findEnabledChild(MenuElement[] children,
+ int start, boolean dir)
+ {
+ MenuElement result = null;
+ if (dir)
+ {
+ result = findNextEnabledChild(children, start + 1, children.length-1);
+ if (result == null)
+ result = findNextEnabledChild(children, 0, start - 1);
+ }
+ else
+ {
+ result = findPreviousEnabledChild(children, start - 1, 0);
+ if (result == null)
+ result = findPreviousEnabledChild(children, children.length-1,
+ start + 1);
+ }
+ return result;
+ }
+
+ /**
+ * Finds the next child element that is enabled and visible.
+ *
+ * @param children the children to search through
+ * @param start the start index
+ * @param end the end index
+ *
+ * @return the found child, or null
+ */
+ private MenuElement findNextEnabledChild(MenuElement[] children, int start,
+ int end)
+ {
+ MenuElement found = null;
+ for (int i = start; i <= end && found == null; i++)
+ {
+ if (children[i] != null)
+ {
+ Component comp = children[i].getComponent();
+ if (comp != null && comp.isEnabled() && comp.isVisible())
+ {
+ found = children[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Finds the previous child element that is enabled and visible.
+ *
+ * @param children the children to search through
+ * @param start the start index
+ * @param end the end index
+ *
+ * @return the found child, or null
+ */
+ private MenuElement findPreviousEnabledChild(MenuElement[] children,
+ int start, int end)
+ {
+ MenuElement found = null;
+ for (int i = start; i >= end && found == null; i--)
+ {
+ if (children[i] != null)
+ {
+ Component comp = children[i].getComponent();
+ if (comp != null && comp.isEnabled() && comp.isVisible())
+ {
+ found = children[i];
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Navigates to the parent or child menu item.
+ *
+ * @param selectChild <code>true</code>: navigate to child,
+ * <code>false</code>: navigate to parent
+ */
+ private void navigateParentChild(boolean selectChild)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ int len = path.length;
+
+ if (selectChild)
+ {
+ if (len > 0 && path[len - 1] instanceof JMenu
+ && ! ((JMenu) path[len-1]).isTopLevelMenu())
+ {
+ // We have a submenu, open it.
+ JMenu menu = (JMenu) path[len - 1];
+ JPopupMenu popup = menu.getPopupMenu();
+ MenuElement[] subs = popup.getSubElements();
+ MenuElement item = findEnabledChild(subs, -1, true);
+ MenuElement[] newPath;
+
+ if (item == null)
+ {
+ newPath = new MenuElement[len + 1];
+ }
+ else
+ {
+ newPath = new MenuElement[len + 2];
+ newPath[len + 1] = item;
+ }
+ System.arraycopy(path, 0, newPath, 0, len);
+ newPath[len] = popup;
+ msm.setSelectedPath(newPath);
+ return;
+ }
+ }
+ else
+ {
+ int popupIndex = len-1;
+ if (len > 2
+ && (path[popupIndex] instanceof JPopupMenu
+ || path[--popupIndex] instanceof JPopupMenu)
+ && ! ((JMenu) path[popupIndex - 1]).isTopLevelMenu())
+ {
+ // We have a submenu, close it.
+ MenuElement newPath[] = new MenuElement[popupIndex];
+ System.arraycopy(path, 0, newPath, 0, popupIndex);
+ msm.setSelectedPath(newPath);
+ return;
+ }
+ }
+
+ // If we got here, we have not selected a child or parent.
+ // Check if we have a toplevel menu selected. If so, then select
+ // another one.
+ if (len > 1 && path[0] instanceof JMenuBar)
+ {
+ MenuElement currentMenu = path[1];
+ MenuElement nextMenu = findEnabledChild(path[0].getSubElements(),
+ currentMenu, selectChild);
+
+ if (nextMenu != null && nextMenu != currentMenu)
+ {
+ MenuElement newSelection[];
+ if (len == 2)
+ {
+ // Menu is selected but its popup not shown.
+ newSelection = new MenuElement[2];
+ newSelection[0] = path[0];
+ newSelection[1] = nextMenu;
+ }
+ else
+ {
+ // Menu is selected and its popup is shown.
+ newSelection = new MenuElement[3];
+ newSelection[0] = path[0];
+ newSelection[1] = nextMenu;
+ newSelection[2] = ((JMenu) nextMenu).getPopupMenu();
+ }
+ msm.setSelectedPath(newSelection);
+ }
+ }
+ }
+
+ /**
+ * Handles cancel requests (ESC key).
+ */
+ private void cancel()
+ {
+ // Fire popup menu cancelled event. Unfortunately the
+ // firePopupMenuCancelled() is protected in JPopupMenu so we work
+ // around this limitation by fetching the listeners and notifying them
+ // directly.
+ JPopupMenu lastPopup = (JPopupMenu) getLastPopup();
+ EventListener[] ll = lastPopup.getListeners(PopupMenuListener.class);
+ for (int i = 0; i < ll.length; i++)
+ {
+ PopupMenuEvent ev = new PopupMenuEvent(lastPopup);
+ ((PopupMenuListener) ll[i]).popupMenuCanceled(ev);
+ }
+
+ // Close the last popup or the whole selection if there's only one
+ // popup left.
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ if(path.length > 4)
+ {
+ MenuElement newPath[] = new MenuElement[path.length - 2];
+ System.arraycopy(path,0,newPath,0,path.length-2);
+ MenuSelectionManager.defaultManager().setSelectedPath(newPath);
+ }
+ else
+ msm.clearSelectedPath();
+ }
+
+ /**
+ * Returns the last popup menu in the current selection or null.
+ *
+ * @return the last popup menu in the current selection or null
+ */
+ private JPopupMenu getLastPopup()
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement[] p = msm.getSelectedPath();
+ JPopupMenu popup = null;
+ for(int i = p.length - 1; popup == null && i >= 0; i--)
+ {
+ if (p[i] instanceof JPopupMenu)
+ popup = (JPopupMenu) p[i];
+ }
+ return popup;
+ }
+
+ /**
+ * Handles ENTER key requests. This normally opens submenus on JMenu
+ * items, or activates the menu item as if it's been clicked on it.
+ */
+ private void doReturn()
+ {
+ KeyboardFocusManager fmgr =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ Component focusOwner = fmgr.getFocusOwner();
+ if((focusOwner == null || (focusOwner instanceof JRootPane)))
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement path[] = msm.getSelectedPath();
+ MenuElement lastElement;
+ if(path.length > 0)
+ {
+ lastElement = path[path.length - 1];
+ if(lastElement instanceof JMenu)
+ {
+ MenuElement newPath[] = new MenuElement[path.length + 1];
+ System.arraycopy(path,0,newPath,0,path.length);
+ newPath[path.length] = ((JMenu) lastElement).getPopupMenu();
+ msm.setSelectedPath(newPath);
+ }
+ else if(lastElement instanceof JMenuItem)
+ {
+ JMenuItem mi = (JMenuItem)lastElement;
+ if (mi.getUI() instanceof BasicMenuItemUI)
+ {
+ ((BasicMenuItemUI)mi.getUI()).doClick(msm);
+ }
+ else
+ {
+ msm.clearSelectedPath();
+ mi.doClick(0);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Installs keyboard actions when a popup is opened, and uninstalls the
+ * keyboard actions when closed. This listens on the default
+ * MenuSelectionManager.
+ */
+ private class KeyboardHelper
+ implements ChangeListener
+ {
+ private MenuElement[] lastSelectedPath = new MenuElement[0];
+ private Component lastFocused;
+ private JRootPane invokerRootPane;
+
+ public void stateChanged(ChangeEvent event)
+ {
+ MenuSelectionManager msm = (MenuSelectionManager) event.getSource();
+ MenuElement[] p = msm.getSelectedPath();
+ JPopupMenu popup = getActivePopup(p);
+ if (popup == null || popup.isFocusable())
+ {
+ if (lastSelectedPath.length != 0 && p.length != 0 )
+ {
+ if (! invokerEquals(p[0], lastSelectedPath[0]))
+ {
+ uninstallKeyboardActionsImpl();
+ lastSelectedPath = new MenuElement[0];
+ }
+ }
+
+ if (lastSelectedPath.length == 0 && p.length > 0)
+ {
+ JComponent invoker;
+ if (popup == null)
+ {
+ if (p.length == 2 && p[0] instanceof JMenuBar
+ && p[1] instanceof JMenu)
+ {
+ // A menu has been selected but not opened.
+ invoker = (JComponent)p[1];
+ popup = ((JMenu)invoker).getPopupMenu();
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ Component c = popup.getInvoker();
+ if(c instanceof JFrame)
+ {
+ invoker = ((JFrame) c).getRootPane();
+ }
+ else if(c instanceof JApplet)
+ {
+ invoker = ((JApplet) c).getRootPane();
+ }
+ else
+ {
+ while (!(c instanceof JComponent))
+ {
+ if (c == null)
+ {
+ return;
+ }
+ c = c.getParent();
+ }
+ invoker = (JComponent)c;
+ }
+ }
+
+ // Remember current focus owner.
+ lastFocused = KeyboardFocusManager.
+ getCurrentKeyboardFocusManager().getFocusOwner();
+
+ // Install keybindings used for menu navigation.
+ invokerRootPane = SwingUtilities.getRootPane(invoker);
+ if (invokerRootPane != null)
+ {
+ invokerRootPane.requestFocus(true);
+ installKeyboardActionsImpl();
+ }
+ }
+ else if (lastSelectedPath.length != 0 && p.length == 0)
+ {
+ // menu hidden -- return focus to where it had been before
+ // and uninstall menu keybindings
+ uninstallKeyboardActionsImpl();
+ }
+ }
+
+ // Remember the last path selected
+ lastSelectedPath = p;
+ }
+
+ private JPopupMenu getActivePopup(MenuElement[] path)
+ {
+ JPopupMenu active = null;
+ for (int i = path.length - 1; i >= 0 && active == null; i--)
+ {
+ MenuElement elem = path[i];
+ if (elem instanceof JPopupMenu)
+ {
+ active = (JPopupMenu) elem;
+ }
+ }
+ return active;
+ }
+
+ private boolean invokerEquals(MenuElement el1, MenuElement el2)
+ {
+ Component invoker1 = el1.getComponent();
+ Component invoker2 = el2.getComponent();
+ if (invoker1 instanceof JPopupMenu)
+ invoker1 = ((JPopupMenu) invoker1).getInvoker();
+ if (invoker2 instanceof JPopupMenu)
+ invoker2 = ((JPopupMenu) invoker2).getInvoker();
+ return invoker1 == invoker2;
+ }
+ }
+
/* popupMenu for which this UI delegate is for*/
protected JPopupMenu popupMenu;
@@ -75,6 +616,19 @@ public class BasicPopupMenuUI extends PopupMenuUI
TopWindowListener topWindowListener;
/**
+ * Counts how many popup menus are handled by this UI or a subclass.
+ * This is used to install a KeyboardHelper on the MenuSelectionManager
+ * for the first popup, and uninstall this same KeyboardHelper when the
+ * last popup is uninstalled.
+ */
+ private static int numPopups;
+
+ /**
+ * This is the KeyboardHelper that listens on the MenuSelectionManager.
+ */
+ private static KeyboardHelper keyboardHelper;
+
+ /**
* Creates a new BasicPopupMenuUI object.
*/
public BasicPopupMenuUI()
@@ -106,6 +660,16 @@ public class BasicPopupMenuUI extends PopupMenuUI
public void installUI(JComponent c)
{
super.installUI(c);
+
+ // Install KeyboardHelper when the first popup is initialized.
+ if (numPopups == 0)
+ {
+ keyboardHelper = new KeyboardHelper();
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ msm.addChangeListener(keyboardHelper);
+ }
+ numPopups++;
+
popupMenu = (JPopupMenu) c;
popupMenu.setLayout(new DefaultMenuLayout(popupMenu, BoxLayout.Y_AXIS));
popupMenu.setBorderPainted(true);
@@ -113,6 +677,7 @@ public class BasicPopupMenuUI extends PopupMenuUI
installDefaults();
installListeners();
+ installKeyboardActions();
}
/**
@@ -139,9 +704,77 @@ public class BasicPopupMenuUI extends PopupMenuUI
* This method installs the keyboard actions for this {@link JPopupMenu}.
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Need to implement
+ // We can't install the keyboard actions here, because then all
+ // popup menus would have their actions registered in the KeyboardManager.
+ // So we install it when the popup menu is opened, and uninstall it
+ // when it's closed. This is done in the KeyboardHelper class.
+ // Install InputMap.
+ }
+
+ /**
+ * Called by the KeyboardHandler when a popup is made visible.
+ */
+ void installKeyboardActionsImpl()
+ {
+ Object[] bindings;
+ if (popupMenu.getComponentOrientation().isLeftToRight())
+ {
+ bindings = (Object[])
+ SharedUIDefaults.get("PopupMenu.selectedWindowInputMapBindings");
+ }
+ else
+ {
+ bindings = (Object[]) SharedUIDefaults.get
+ ("PopupMenu.selectedWindowInputMapBindings.RightToLeft");
+ }
+ InputMap inputMap = LookAndFeel.makeComponentInputMap(popupMenu, bindings);
+ SwingUtilities.replaceUIInputMap(popupMenu,
+ JComponent.WHEN_IN_FOCUSED_WINDOW,
+ inputMap);
+
+ // Install ActionMap.
+ SwingUtilities.replaceUIActionMap(popupMenu, getActionMap());
+ }
+
+ /**
+ * Creates and returns the shared action map for JTrees.
+ *
+ * @return the shared action map for JTrees
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("PopupMenu.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("PopupMenu.actionMap", am);
+ }
+ return am;
+ }
+
+ /**
+ * Creates the default actions when there are none specified by the L&F.
+ *
+ * @return the default actions
+ */
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new NavigateAction("selectNext");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectPrevious");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectParent");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("selectChild");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("return");
+ am.put(action.getValue(Action.NAME), action);
+ action = new NavigateAction("cancel");
+ am.put(action.getValue(Action.NAME), action);
+
+ return am;
}
/**
@@ -155,7 +788,17 @@ public class BasicPopupMenuUI extends PopupMenuUI
{
uninstallListeners();
uninstallDefaults();
+ uninstallKeyboardActions();
popupMenu = null;
+
+ // Install KeyboardHelper when the first popup is initialized.
+ numPopups--;
+ if (numPopups == 0)
+ {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ msm.removeChangeListener(keyboardHelper);
+ }
+
}
/**
@@ -182,9 +825,22 @@ public class BasicPopupMenuUI extends PopupMenuUI
* Uninstalls any keyboard actions.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Need to implement
+ // We can't install the keyboard actions here, because then all
+ // popup menus would have their actions registered in the KeyboardManager.
+ // So we install it when the popup menu is opened, and uninstall it
+ // when it's closed. This is done in the KeyboardHelper class.
+ // Install InputMap.
+ }
+
+ /**
+ * Called by the KeyboardHandler when a popup is made invisible.
+ */
+ void uninstallKeyboardActionsImpl()
+ {
+ SwingUtilities.replaceUIInputMap(popupMenu,
+ JComponent.WHEN_IN_FOCUSED_WINDOW, null);
+ SwingUtilities.replaceUIActionMap(popupMenu, null);
}
/**
@@ -278,9 +934,10 @@ public class BasicPopupMenuUI extends PopupMenuUI
// Adds topWindowListener to top-level window to listener to
// ComponentEvents fired by it. We need to cancel this popup menu
// if topWindow to which this popup belongs was resized or moved.
- Component invoker = popupMenu.getInvoker();
+ Component invoker = popupMenu.getInvoker();
Component rootContainer = SwingUtilities.getRoot(invoker);
- rootContainer.addComponentListener(topWindowListener);
+ if (rootContainer != null)
+ rootContainer.addComponentListener(topWindowListener);
// if this popup menu is a free floating popup menu,
// then by default its first element should be always selected when
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
index a7da21c4f6e..aed4d69d6d5 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -42,6 +42,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
@@ -92,14 +93,6 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
protected void installDefaults(AbstractButton b)
{
super.installDefaults(b);
- if (b.getIcon() == null)
- b.setIcon(icon);
- if (b.getSelectedIcon() == null)
- b.setSelectedIcon(icon);
- if (b.getDisabledIcon() == null)
- b.setDisabledIcon(icon);
- if (b.getDisabledSelectedIcon() == null)
- b.setDisabledSelectedIcon(icon);
}
/**
@@ -145,16 +138,17 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
g.setFont(f);
ButtonModel m = b.getModel();
- Icon currentIcon = null;
- if (m.isSelected() && m.isEnabled())
- currentIcon = b.getSelectedIcon();
- else if (! m.isSelected() && m.isEnabled())
- currentIcon = b.getIcon();
- else if (m.isSelected() && ! m.isEnabled())
- currentIcon = b.getDisabledSelectedIcon();
- else // (!m.isSelected() && ! m.isEnabled())
- currentIcon = b.getDisabledIcon();
+ // FIXME: Do a filtering on any customized icon if the following property
+ // is set.
+ boolean enabled = b.isEnabled();
+
+ Icon currentIcon = b.getIcon();
+ if (currentIcon == null)
+ {
+ currentIcon = getDefaultIcon();
+ }
+
SwingUtilities.calculateInnerArea(b, vr);
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
b.getText(), currentIcon,
@@ -162,15 +156,57 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
- if (currentIcon != null)
- {
- currentIcon.paintIcon(c, g, ir.x, ir.y);
- }
+ currentIcon.paintIcon(c, g, ir.x, ir.y);
+
if (text != null)
paintText(g, b, tr, text);
if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
paintFocus(g, tr, c.getSize());
}
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ // This is basically the same code as in
+ // BasicGraphicsUtils.getPreferredButtonSize() but takes the default icon
+ // property into account. JRadioButton and subclasses always have an icon:
+ // the check box. If the user explicitly changes it with setIcon() that
+ // one will be used for layout calculations and painting instead.
+ // The other icon properties are ignored.
+ AbstractButton b = (AbstractButton) c;
+
+ Rectangle contentRect;
+ Rectangle viewRect;
+ Rectangle iconRect = new Rectangle();
+ Rectangle textRect = new Rectangle();
+ Insets insets = b.getInsets();
+
+ Icon i = b.getIcon();
+ if (i == null)
+ i = getDefaultIcon();
+
+ viewRect = new Rectangle();
+
+ SwingUtilities.layoutCompoundLabel(
+ b, // for the component orientation
+ b.getFontMetrics(b.getFont()),
+ b.getText(),
+ i,
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ viewRect, iconRect, textRect,
+ defaultTextIconGap + defaultTextShiftOffset);
+
+ contentRect = textRect.union(iconRect);
+
+ return new Dimension(insets.left
+ + contentRect.width
+ + insets.right + b.getHorizontalAlignment(),
+ insets.top
+ + contentRect.height
+ + insets.bottom);
+ }
/**
* Paints the focus indicator for JRadioButtons.
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
index b29026342e0..78e5168fc80 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -302,8 +302,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void mouseMoved(MouseEvent e)
{
- // Not interested in where the mouse
- // is unless it is being dragged.
+ if (thumbRect.contains(e.getPoint()))
+ thumbRollover = true;
+ else
+ thumbRollover = false;
}
/**
@@ -486,6 +488,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
/** The scrollbar this UI is acting for. */
protected JScrollBar scrollbar;
+
+ /** True if the mouse is over the thumb. */
+ boolean thumbRollover;
/**
* This method adds a component to the layout.
@@ -1401,4 +1406,45 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
value = min;
return value;
}
+
+ /**
+ * Returns true if the mouse is over the thumb.
+ *
+ * @return true if the mouse is over the thumb.
+ *
+ * @since 1.5
+ */
+ public boolean isThumbRollover()
+ {
+ return thumbRollover;
+ }
+
+ /**
+ * Set thumbRollover to active. This indicates
+ * whether or not the mouse is over the thumb.
+ *
+ * @param active - true if the mouse is over the thumb.
+ *
+ * @since 1.5
+ */
+ protected void setThumbRollover(boolean active)
+ {
+ thumbRollover = active;
+ }
+
+ /**
+ * Indicates whether the user can position the thumb with
+ * a mouse click (i.e. middle button).
+ *
+ * @return true if the user can position the thumb with a mouse
+ * click.
+ *
+ * @since 1.5
+ */
+ public boolean getSupportsAbsolutePositioning()
+ {
+ // The positioning feature has not been implemented.
+ // So, false is always returned.
+ return false;
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
index 2fb16f12e63..3811eebdfd6 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
@@ -371,6 +371,7 @@ public class BasicSliderUI extends SliderUI
*/
public void mouseDragged(MouseEvent e)
{
+ dragging = true;
if (slider.isEnabled())
{
currentMouseX = e.getX();
@@ -450,6 +451,7 @@ public class BasicSliderUI extends SliderUI
*/
public void mouseReleased(MouseEvent e)
{
+ dragging = false;
if (slider.isEnabled())
{
currentMouseX = e.getX();
@@ -593,6 +595,9 @@ public class BasicSliderUI extends SliderUI
/** True if the slider has focus. */
private transient boolean hasFocus;
+
+ /** True if the user is dragging the slider. */
+ boolean dragging;
/**
* Creates a new Basic look and feel Slider UI.
@@ -605,6 +610,18 @@ public class BasicSliderUI extends SliderUI
}
/**
+ * Returns true if the user is dragging the slider.
+ *
+ * @return true if the slider is being dragged.
+ *
+ * @since 1.5
+ */
+ protected boolean isDragging()
+ {
+ return dragging;
+ }
+
+ /**
* Gets the shadow color to be used for this slider. The shadow color is the
* color used for drawing the top and left edges of the track.
*
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 1b2552837c6..11f25167d21 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -1,5 +1,5 @@
/* BasicTabbedPaneUI.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -51,6 +49,7 @@ import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
@@ -60,7 +59,10 @@ import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
import javax.swing.Icon;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
@@ -72,6 +74,7 @@ import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
import javax.swing.plaf.TabbedPaneUI;
@@ -80,11 +83,127 @@ import javax.swing.text.View;
/**
* This is the Basic Look and Feel's UI delegate for JTabbedPane.
+ *
+ * @author Lillian Angel (langel@redhat.com)
+ * @author Kim Ho (kho@redhat.com)
+ * @author Roman Kennke (kennke@aicas.com)
+ * @author Robert Schuster (robertschuster@fsfe.org)
*/
public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
+
+ static class NavigateAction extends AbstractAction
+ {
+ int direction;
+
+ NavigateAction(String name, int dir)
+ {
+ super(name);
+ direction = dir;
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JTabbedPane tp = (JTabbedPane) event.getSource();
+ BasicTabbedPaneUI ui = (BasicTabbedPaneUI) tp.getUI();
+
+ ui.navigateSelectedTab(direction);
+ }
+
+ }
+
+ static class NavigatePageDownAction extends AbstractAction
+ {
+
+ public NavigatePageDownAction()
+ {
+ super("navigatePageDown");
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JTabbedPane tp = (JTabbedPane) event.getSource();
+ BasicTabbedPaneUI ui = (BasicTabbedPaneUI) tp.getUI();
+
+ int i = tp.getSelectedIndex();
+
+ if (i < 0)
+ i = 0;
+
+ ui.selectNextTabInRun(i);
+ }
+
+ }
+
+ static class NavigatePageUpAction extends AbstractAction
+ {
+
+ public NavigatePageUpAction()
+ {
+ super("navigatePageUp");
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JTabbedPane tp = (JTabbedPane) event.getSource();
+ BasicTabbedPaneUI ui = (BasicTabbedPaneUI) tp.getUI();
+
+ int i = tp.getSelectedIndex();
+
+ if (i < 0)
+ i = 0;
+
+ ui.selectPreviousTabInRun(i);
+
+ }
+ }
+
+ static class RequestFocusAction extends AbstractAction
+ {
+
+ public RequestFocusAction()
+ {
+ super("requestFocus");
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ ((JTabbedPane) event.getSource()).requestFocus();
+ }
+
+ }
+
+ static class RequestFocusForVisibleComponentAction extends AbstractAction
+ {
+
+ public RequestFocusForVisibleComponentAction()
+ {
+ super("requestFocusForVisibleComponent");
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ JTabbedPane tp = (JTabbedPane) event.getSource();
+
+ // FIXME: This should select a suitable component within
+ // the tab content. However I dont know whether we have
+ // to search for this component or wether the called is
+ // supposed to do that.
+ tp.getSelectedComponent().requestFocus();
+ }
+
+ }
+
/**
- * A helper class that handles focus.
+ * A helper class that handles focus.
+ * <p>The purpose of this class is to implement a more flexible focus
+ * handling for the tabbed pane, which is used to determine whether the
+ * focus indicator should be painted or not. When in scrolling layout
+ * mode the area containing the tabs is a scrollpane, so simply testing
+ * whether the tabbed pane has the focus does not work.</p>
+ * <p>The <code>FocusHandler</code> is installed on the scrollpane and
+ * the tabbed pane and sets the variable <code>hasFocus</code> to
+ * <code>false</code> only when both components do not hold the focus.</p>
*
* @specnote Apparently this class was intended to be protected,
* but was made public by a compiler bug and is now
@@ -99,7 +218,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public void focusGained(FocusEvent e)
{
- // FIXME: Implement.
+ Object source = e.getSource();
+ if (source == panel )
+ tabPane.requestFocus();
+ else if (source == tabPane)
+ tabPane.repaint();
}
/**
@@ -109,7 +232,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public void focusLost(FocusEvent e)
{
- // FIXME: Implement.
+ if (e.getOppositeComponent() == tabPane.getSelectedComponent())
+ tabPane.requestFocus();
+ else if (e.getSource() == tabPane)
+ tabPane.repaint();
}
}
@@ -124,6 +250,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public class MouseHandler extends MouseAdapter
{
+ public void mouseReleased(MouseEvent e)
+ {
+ // Nothing to do here.
+ }
+
/**
* This method is called when the mouse is pressed. The index cannot
* change to a tab that is not enabled.
@@ -132,14 +263,84 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public void mousePressed(MouseEvent e)
{
- if (tabPane.isEnabled())
+ Object s = e.getSource();
+ int placement = tabPane.getTabPlacement();
+
+ if (s == incrButton)
{
- int index = tabForCoordinate(tabPane, e.getX(), e.getY());
- if (index >= 0 && tabPane.isEnabledAt(index))
+ if(!incrButton.isEnabled())
+ return;
+
+ currentScrollLocation++;
+
+ switch (placement)
{
- tabPane.setSelectedIndex(index);
+ case JTabbedPane.TOP:
+ case JTabbedPane.BOTTOM:
+ currentScrollOffset = getTabAreaInsets(placement).left;
+ for (int i = 0; i < currentScrollLocation; i++)
+ currentScrollOffset += rects[i].width;
+ break;
+ default:
+ currentScrollOffset = getTabAreaInsets(placement).top;
+ for (int i = 0; i < currentScrollLocation; i++)
+ currentScrollOffset += rects[i].height;
+ break;
}
+
+ updateViewPosition();
+ updateButtons();
+
+ tabPane.repaint();
+ }
+ else if (s == decrButton)
+ {
+ if(!decrButton.isEnabled())
+ return;
+
+ // The scroll location may be zero but the offset
+ // greater than zero because of an adjustement to
+ // make a partially visible tab completely visible.
+ if (currentScrollLocation > 0)
+ currentScrollLocation--;
+
+ // Set the offset back to 0 and recompute it.
+ currentScrollOffset = 0;
+
+ switch (placement)
+ {
+ case JTabbedPane.TOP:
+ case JTabbedPane.BOTTOM:
+ // Take the tab area inset into account.
+ if (currentScrollLocation > 0)
+ currentScrollOffset = getTabAreaInsets(placement).left;
+ // Recompute scroll offset.
+ for (int i = 0; i < currentScrollLocation; i++)
+ currentScrollOffset += rects[i].width;
+ break;
+ default:
+ // Take the tab area inset into account.
+ if (currentScrollLocation > 0)
+ currentScrollOffset = getTabAreaInsets(placement).top;
+
+ for (int i = 0; i < currentScrollLocation; i++)
+ currentScrollOffset += rects[i].height;
+ }
+
+ updateViewPosition();
+ updateButtons();
+
+ tabPane.repaint();
+ } else if (tabPane.isEnabled())
+ {
+ int index = tabForCoordinate(tabPane, e.getX(), e.getY());
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT
+ && s == panel)
+ scrollTab(index, placement);
+
+ tabPane.setSelectedIndex(index);
}
+
}
/**
@@ -197,6 +398,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
if (e.getPropertyName().equals("tabLayoutPolicy"))
{
+ currentScrollLocation = currentScrollOffset = 0;
+
layoutManager = createLayoutManager();
tabPane.setLayout(layoutManager);
@@ -265,7 +468,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// Find out the minimum/preferred size to display the largest child
// of the tabbed pane.
- for (int i = 0; i < tabPane.getTabCount(); i++)
+ int count = tabPane.getTabCount();
+ for (int i = 0; i < count; i++)
{
c = tabPane.getComponentAt(i);
if (c == null)
@@ -282,21 +486,19 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
- int min = calculateMaxTabWidth(tabPlacement);
- width = Math.max(min, width);
- int tabAreaHeight = preferredTabAreaHeight(tabPlacement,
- width - tabAreaInsets.left
- - tabAreaInsets.right);
- height += tabAreaHeight;
+ width = Math.max(calculateMaxTabWidth(tabPlacement), width);
+
+ height += preferredTabAreaHeight(tabPlacement,
+ width - tabAreaInsets.left
+ - tabAreaInsets.right);
}
else
{
- int min = calculateMaxTabHeight(tabPlacement);
- height = Math.max(min, height);
- int tabAreaWidth = preferredTabAreaWidth(tabPlacement,
- height - tabAreaInsets.top
- - tabAreaInsets.bottom);
- width += tabAreaWidth;
+ height = Math.max(calculateMaxTabHeight(tabPlacement), height);
+
+ width += preferredTabAreaWidth(tabPlacement,
+ height - tabAreaInsets.top
+ - tabAreaInsets.bottom);
}
Insets tabPaneInsets = tabPane.getInsets();
@@ -306,7 +508,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// if tab placement is LEFT OR RIGHT, they share width.
// if tab placement is TOP OR BOTTOM, they share height
- // PRE STEP: finds the default sizes for the labels as well as their locations.
+ // PRE STEP: finds the default sizes for the labels as well as their
+ // locations.
// AND where they will be placed within the run system.
// 1. calls normalizeTab Runs.
// 2. calls rotate tab runs.
@@ -345,7 +548,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
break;
case RIGHT:
maxTabWidth = calculateMaxTabWidth(tabPlacement);
- x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth;
+ x = size.width - (insets.right + tabAreaInsets.right)
+ - maxTabWidth - 1;
y = insets.top + tabAreaInsets.top;
breakAt = size.height - (insets.bottom + tabAreaInsets.bottom);
break;
@@ -353,7 +557,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
maxTabHeight = calculateMaxTabHeight(tabPlacement);
x = insets.left + tabAreaInsets.left;
y = size.height - (insets.bottom + tabAreaInsets.bottom)
- - maxTabHeight;
+ - maxTabHeight - 1;
breakAt = size.width - (insets.right + tabAreaInsets.right);
break;
case TOP:
@@ -372,6 +576,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
runCount = 0;
selectedRun = -1;
int selectedIndex = tabPane.getSelectedIndex();
+ if (selectedIndex < 0)
+ selectedIndex = 0;
Rectangle rect;
@@ -409,7 +615,6 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
rect.height = maxTabHeight;
if (i == selectedIndex)
selectedRun = runCount - 1;
-
}
}
else
@@ -454,9 +659,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int start;
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
- start = y;
- else
start = x;
+ else
+ start = y;
normalizeTabRuns(tabPlacement, tabCount, start, breakAt);
selectedRun = getRunForTab(tabCount, selectedIndex);
if (shouldRotateTabRuns(tabPlacement))
@@ -464,7 +669,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
rotateTabRuns(tabPlacement, selectedRun);
}
}
-
+
+ // Suppress padding if we have only one tab run.
+ if (runCount == 1)
+ return;
+
// Pad the runs.
int tabRunOverlay = getTabRunOverlay(tabPlacement);
for (int i = runCount - 1; i >= 0; --i)
@@ -604,16 +813,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public Dimension minimumLayoutSize(Container parent)
{
- return calculateSize(false);
+ return calculateSize(true);
}
- // If there is more free space in an adjacent run AND the tab in the run can fit in the
- // adjacent run, move it. This method is not perfect, it is merely an approximation.
+ // If there is more free space in an adjacent run AND the tab
+ // in the run can fit in the adjacent run, move it. This method
+ // is not perfect, it is merely an approximation.
// If you play around with Sun's JTabbedPane, you'll see that
// it does do some pretty strange things with regards to not moving tabs
// that should be moved.
// start = the x position where the tabs will begin
- // max = the maximum position of where the tabs can go to (tabAreaInsets.left + the width of the tab area)
+ // max = the maximum position of where the tabs can go to
+ // (tabAreaInsets.left + the width of the tab area)
/**
* This method tries to "even out" the number of tabs in each run based on
@@ -631,18 +842,20 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
if (tabPlacement == SwingUtilities.TOP
|| tabPlacement == SwingUtilities.BOTTOM)
{
- // We should only do this for runCount - 1, cause we can only shift that many times between
- // runs.
+ // We should only do this for runCount - 1, cause we can
+ // only shift that many times between runs.
for (int i = 1; i < runCount; i++)
{
Rectangle currRun = rects[lastTabInRun(tabCount, i)];
- Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
+ Rectangle nextRun = rects[lastTabInRun(tabCount,
+ getNextTabRun(i))];
int spaceInCurr = currRun.x + currRun.width;
int spaceInNext = nextRun.x + nextRun.width;
int diffNow = spaceInCurr - spaceInNext;
int diffLater = (spaceInCurr - currRun.width)
- (spaceInNext + currRun.width);
+
while (Math.abs(diffLater) < Math.abs(diffNow)
&& spaceInNext + currRun.width < max)
{
@@ -654,11 +867,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
diffLater = (spaceInCurr - currRun.width)
- (spaceInNext + currRun.width);
}
-
- // Fix the bounds.
- int first = lastTabInRun(tabCount, i) + 1;
- int last = lastTabInRun(tabCount, getNextTabRun(i));
- int currX = tabAreaInsets.left;
+
+ // Fixes the bounds of all tabs in the current
+ // run.
+ int first = tabRuns[i];
+ int last = lastTabInRun(tabCount, i);
+ int currX = start;
for (int j = first; j <= last; j++)
{
rects[j].x = currX;
@@ -671,7 +885,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
for (int i = 1; i < runCount; i++)
{
Rectangle currRun = rects[lastTabInRun(tabCount, i)];
- Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
+ Rectangle nextRun = rects[lastTabInRun(tabCount,
+ getNextTabRun(i))];
int spaceInCurr = currRun.y + currRun.height;
int spaceInNext = nextRun.y + nextRun.height;
@@ -690,9 +905,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
- (spaceInNext + currRun.height);
}
- int first = lastTabInRun(tabCount, i) + 1;
- int last = lastTabInRun(tabCount, getNextTabRun(i));
- int currY = tabAreaInsets.top;
+ // Fixes the bounds of tabs in the current run.
+ int first = tabRuns[i];
+ int last = lastTabInRun(tabCount, i);
+ int currY = start;
for (int j = first; j <= last; j++)
{
rects[j].y = currY;
@@ -718,7 +934,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
rects[selectedIndex].height += insets.top + insets.bottom;
}
- // If the tabs on the run don't fill the width of the window, make it fit now.
+ // If the tabs on the run don't fill the width of the window, make it
+ // fit now.
// start = starting index of the run
// end = last index of the run
// max = tabAreaInsets.left + width (or equivalent)
@@ -742,7 +959,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int runWidth = rects[end].x + rects[end].width;
int spaceRemaining = max - runWidth;
int numTabs = end - start + 1;
-
+
// now divvy up the space.
int spaceAllocated = spaceRemaining / numTabs;
int currX = rects[start].x;
@@ -750,11 +967,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
rects[i].x = currX;
rects[i].width += spaceAllocated;
+
currX += rects[i].width;
// This is used because since the spaceAllocated
// variable is an int, it rounds down. Sometimes,
// we don't fill an entire row, so we make it do
// so now.
+
if (i == end && rects[i].x + rects[i].width != max)
rects[i].width = max - rects[i].x;
}
@@ -819,7 +1038,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// The reason why we can't use runCount:
// This method is only called to calculate the size request
- // for the tabbedPane. However, this size request is dependent on
+ // for the tabbedPane. However, this size request is dependent on
// our desired width. We need to find out what the height would
// be IF we got our desired width.
for (int i = 0; i < tabPane.getTabCount(); i++)
@@ -882,7 +1101,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
runs++;
int maxTabWidth = calculateMaxTabWidth(tabPlacement);
- int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs, maxTabWidth);
+ int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs,
+ maxTabWidth);
return tabAreaWidth;
}
@@ -896,11 +1116,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void rotateTabRuns(int tabPlacement, int selectedRun)
{
- if (runCount == 1 || selectedRun == 1 || selectedRun == -1)
+ if (runCount == 1 || selectedRun == 0 || selectedRun == -1)
return;
int[] newTabRuns = new int[tabRuns.length];
int currentRun = selectedRun;
- int i = 1;
+ int i = 0;
do
{
newTabRuns[i] = tabRuns[currentRun];
@@ -908,8 +1128,6 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
i++;
}
while (i < runCount);
- if (runCount > 1)
- newTabRuns[0] = tabRuns[currentRun];
tabRuns = newTabRuns;
BasicTabbedPaneUI.this.selectedRun = 1;
@@ -942,7 +1160,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public Dimension preferredLayoutSize(Container parent)
{
- return super.calculateSize(true);
+ return super.calculateSize(false);
}
/**
@@ -1016,29 +1234,27 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
SwingUtilities.calculateInnerArea(tabPane, calcRect);
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
Insets insets = tabPane.getInsets();
- int runs = 1;
- int start = 0;
- int top = 0;
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
int maxHeight = calculateMaxTabHeight(tabPlacement);
calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
- start = tabAreaInsets.left + insets.left;
int width = 0;
- int runWidth = start;
- top = insets.top + tabAreaInsets.top;
+ int runWidth = tabAreaInsets.left + insets.left;
+ int top = insets.top + tabAreaInsets.top;
for (int i = 0; i < tabCount; i++)
{
width = calculateTabWidth(tabPlacement, i, fm);
-
- rects[i] = new Rectangle(runWidth, top, width, maxHeight);
+
+ // The proper instances should exists because
+ // assureRectsCreated() was being run already.
+ rects[i].setBounds(runWidth, top, width, maxHeight);
+
runWidth += width;
}
tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
- tabAreaRect.height = runs * maxTabHeight
- - (runs - 1) * tabRunOverlay
- + tabAreaInsets.top + tabAreaInsets.bottom;
+ tabAreaRect.height = maxTabHeight + tabAreaInsets.top
+ + tabAreaInsets.bottom;
contentRect.width = tabAreaRect.width;
contentRect.height = tabPane.getHeight() - insets.top
- insets.bottom - tabAreaRect.height;
@@ -1061,23 +1277,25 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
int height = 0;
- start = tabAreaInsets.top + insets.top;
- int runHeight = start;
+ int runHeight = tabAreaInsets.top + insets.top;;
int fontHeight = fm.getHeight();
- top = insets.left + tabAreaInsets.left;
+ int left = insets.left + tabAreaInsets.left;
for (int i = 0; i < tabCount; i++)
{
height = calculateTabHeight(tabPlacement, i, fontHeight);
- rects[i] = new Rectangle(top, runHeight, maxWidth, height);
+
+ // The proper instances should exists because
+ // assureRectsCreated() was being run already.
+ rects[i].setBounds(left, runHeight, maxWidth, height);
runHeight += height;
}
- tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
- + tabAreaInsets.left + tabAreaInsets.right;
+ tabAreaRect.width = maxTabWidth + tabAreaInsets.left
+ + tabAreaInsets.right;
tabAreaRect.height = tabPane.getHeight() - insets.top
- - insets.bottom;
+ - insets.bottom;
tabAreaRect.y = insets.top;
contentRect.width = tabPane.getWidth() - insets.left - insets.right
- - tabAreaRect.width;
+ - tabAreaRect.width;
contentRect.height = tabAreaRect.height;
contentRect.y = insets.top;
if (tabPlacement == SwingConstants.LEFT)
@@ -1091,11 +1309,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabAreaRect.x = contentRect.x + contentRect.width;
}
}
- runCount = runs;
- if (runCount > tabRuns.length)
- expandTabRunsArray();
-
- padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
+
+ // Unlike the behavior in the WRAP_TAB_LAYOUT the selected
+ // tab is not padded specially.
}
/**
@@ -1113,8 +1329,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
if (tabCount == 0)
return;
int tabPlacement = tabPane.getTabPlacement();
- incrButton.setVisible(false);
- decrButton.setVisible(false);
+
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
@@ -1124,18 +1339,49 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Dimension incrDims = incrButton.getPreferredSize();
Dimension decrDims = decrButton.getPreferredSize();
- decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
- - incrDims.width - decrDims.width,
- tabAreaRect.y, decrDims.width,
- tabAreaRect.height);
- incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
- - incrDims.width, tabAreaRect.y,
- decrDims.width, tabAreaRect.height);
-
+ if (tabPlacement == SwingConstants.BOTTOM)
+ {
+ // Align scroll buttons with the bottom border of the tabbed
+ // pane's content area.
+ decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - incrDims.width - decrDims.width,
+ tabAreaRect.y, decrDims.width,
+ decrDims.height);
+ incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - incrDims.width, tabAreaRect.y,
+ incrDims.width, incrDims.height);
+ }
+ else
+ {
+ // Align scroll buttons with the top border of the tabbed
+ // pane's content area.
+ decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - incrDims.width - decrDims.width,
+ tabAreaRect.y + tabAreaRect.height
+ - decrDims.height, decrDims.width,
+ decrDims.height);
+ incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - incrDims.width,
+ tabAreaRect.y + tabAreaRect.height
+ - incrDims.height,
+ incrDims.width, incrDims.height);
+ }
+
tabAreaRect.width -= decrDims.width + incrDims.width;
+
+ updateButtons();
+
incrButton.setVisible(true);
decrButton.setVisible(true);
}
+ else
+ {
+ incrButton.setVisible(false);
+ decrButton.setVisible(false);
+
+ currentScrollOffset = 0;
+ currentScrollLocation = 0;
+ }
}
if (tabPlacement == SwingConstants.LEFT
@@ -1147,34 +1393,54 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Dimension incrDims = incrButton.getPreferredSize();
Dimension decrDims = decrButton.getPreferredSize();
- decrButton.setBounds(tabAreaRect.x,
- tabAreaRect.y + tabAreaRect.height
- - incrDims.height - decrDims.height,
- tabAreaRect.width, decrDims.height);
- incrButton.setBounds(tabAreaRect.x,
- tabAreaRect.y + tabAreaRect.height
- - incrDims.height, tabAreaRect.width,
- incrDims.height);
+ if (tabPlacement == SwingConstants.RIGHT)
+ {
+ // Align scroll buttons with the right border of the tabbed
+ // pane's content area.
+ decrButton.setBounds(tabAreaRect.x,
+ tabAreaRect.y + tabAreaRect.height
+ - incrDims.height - decrDims.height,
+ decrDims.width, decrDims.height);
+ incrButton.setBounds(tabAreaRect.x,
+ tabAreaRect.y + tabAreaRect.height
+ - incrDims.height, incrDims.width,
+ incrDims.height);
+ }
+ else
+ {
+ // Align scroll buttons with the left border of the tabbed
+ // pane's content area.
+ decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - decrDims.width,
+ tabAreaRect.y + tabAreaRect.height
+ - incrDims.height - decrDims.height,
+ decrDims.width, decrDims.height);
+ incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+ - incrDims.width,
+ tabAreaRect.y + tabAreaRect.height
+ - incrDims.height, incrDims.width,
+ incrDims.height);
+ }
tabAreaRect.height -= decrDims.height + incrDims.height;
+
incrButton.setVisible(true);
decrButton.setVisible(true);
}
+ else
+ {
+ incrButton.setVisible(false);
+ decrButton.setVisible(false);
+
+ currentScrollOffset = 0;
+ currentScrollLocation = 0;
+ }
}
viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,
tabAreaRect.height);
- int tabC = tabPane.getTabCount() - 1;
- if (tabCount > 0)
- {
- int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
- int h = Math.max(rects[tabC].height, tabAreaRect.height);
- p = findPointForIndex(currentScrollLocation);
-
- // we want to cover that entire space so that borders that run under
- // the tab area don't show up when we move the viewport around.
- panel.setSize(w + p.x, h + p.y);
- }
- viewport.setViewPosition(p);
+
+ updateViewPosition();
+
viewport.repaint();
}
}
@@ -1198,7 +1464,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
selectedRun = getRunForTab(tabPane.getTabCount(),
tabPane.getSelectedIndex());
- tabPane.revalidate();
+
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
+ tabPane.revalidate();
tabPane.repaint();
}
}
@@ -1224,7 +1492,17 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public void paint(Graphics g, JComponent c)
{
- paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
+ int placement = tabPane.getTabPlacement();
+ g.setColor(highlight);
+ if (placement == SwingUtilities.TOP
+ || placement == SwingUtilities.BOTTOM)
+ g.fillRect(currentScrollOffset, 0,
+ tabAreaRect.width, tabAreaRect.height);
+ else
+ g.fillRect(0, currentScrollOffset,
+ tabAreaRect.width, tabAreaRect.height);
+
+ paintTabArea(g, placement, tabPane.getSelectedIndex());
}
}
@@ -1285,6 +1563,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/** The starting visible tab in the run in SCROLL_TAB_MODE.
* This is package-private to avoid an accessor method. */
transient int currentScrollLocation;
+
+ transient int currentScrollOffset;
/** A reusable rectangle. */
protected Rectangle calcRect;
@@ -1340,16 +1620,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/** The gap between text and label */
protected int textIconGap;
- // Keeps track of tab runs.
- // The organization of this array is as follows (lots of experimentation to
- // figure this out)
- // index 0 = furthest away from the component area (aka outer run)
- // index 1 = closest to component area (aka selected run)
- // index > 1 = listed in order leading from selected run to outer run.
- // each int in the array is the tab index + 1 (counting starts at 1)
- // for the last tab in the run. (same as the rects array)
-
- /** This array keeps track of which tabs are in which run. See above. */
+ /** This array keeps track of which tabs are in which run.
+ * <p>The value at index i denotes the index of the first tab in run i.</p>
+ * <p>If the value for any index (i > 0) is 0 then (i - 1) is the last
+ * run.</p>
+ */
protected int[] tabRuns;
/**
@@ -1428,7 +1703,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
* The currently visible component.
*/
private Component visibleComponent;
-
+
+ private Color selectedColor;
+
+ private Rectangle tempTextRect = new Rectangle();
+
+ private Rectangle tempIconRect = new Rectangle();
+
/**
* Creates a new BasicTabbedPaneUI object.
*/
@@ -1517,8 +1798,115 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Point p = new Point(w, h);
return p;
}
+
+ /** TabbedPanes in scrolling mode should use this method to
+ * scroll properly to the tab given by the index argument.
+ *
+ * @param index The tab to scroll to.
+ * @param placement The tab's placement.
+ */
+ final void scrollTab(int index, int placement)
+ {
+ int diff;
+ if (index >= 0 && tabPane.isEnabledAt(index))
+ {
+ // If the user clicked on the last tab and that one was
+ // only partially visible shift the scroll offset to make
+ // it completely visible.
+ switch (placement)
+ {
+ case JTabbedPane.TOP:
+ case JTabbedPane.BOTTOM:
+ if ((diff = rects[index].x
+ + rects[index].width
+ - decrButton.getX() - currentScrollOffset) > 0)
+ currentScrollOffset += diff;
+ else if ((diff = rects[index].x - currentScrollOffset) < 0)
+ {
+ if (index == 0)
+ currentScrollOffset = 0;
+ else
+ currentScrollOffset += diff;
+ }
+
+ currentScrollLocation = tabForCoordinate(tabPane,
+ currentScrollOffset,
+ rects[index].y);
+ break;
+ default:
+ if ((diff = rects[index].y + rects[index].height
+ - decrButton.getY() - currentScrollOffset) > 0)
+ currentScrollOffset += diff;
+ else if ((diff = rects[index].y - currentScrollOffset) < 0)
+ {
+ if (index == 0)
+ currentScrollOffset = 0;
+ else
+ currentScrollOffset += diff;
+ }
+
+ currentScrollLocation = tabForCoordinate(tabPane,
+ rects[index].x,
+ currentScrollOffset);
+ }
+
+ updateViewPosition();
+ updateButtons();
+ }
+ }
+
+ /** Sets the enabled state of the increase and decrease button
+ * according to the current scrolling offset and tab pane width
+ * (or height in TOP/BOTTOM placement).
+ */
+ final void updateButtons()
+ {
+ int tc = tabPane.getTabCount();
+
+ // The increase button should be enabled as long as the
+ // right/bottom border of the last tab is under the left/top
+ // border of the decrease button.
+ switch (tabPane.getTabPlacement())
+ {
+ case JTabbedPane.BOTTOM:
+ case JTabbedPane.TOP:
+ incrButton.setEnabled(currentScrollLocation + 1 < tc
+ && rects[tc-1].x + rects[tc-1].width
+ - currentScrollOffset > decrButton.getX());
+ break;
+ default:
+ incrButton.setEnabled(currentScrollLocation + 1 < tc
+ && rects[tc-1].y + rects[tc-1].height
+ - currentScrollOffset > decrButton.getY());
+ }
+
+ // The decrease button is enabled when the tab pane is scrolled in any way.
+ decrButton.setEnabled(currentScrollOffset > 0);
+
+ }
/**
+ * Updates the position of the scrolling viewport's view
+ * according to the current scroll offset.
+ */
+ final void updateViewPosition()
+ {
+ Point p = viewport.getViewPosition();
+
+ switch (tabPane.getTabPlacement())
+ {
+ case JTabbedPane.LEFT:
+ case JTabbedPane.RIGHT:
+ p.y = currentScrollOffset;
+ break;
+ default:
+ p.x = currentScrollOffset;
+ }
+
+ viewport.setViewPosition(p);
+ }
+
+ /**
* This method creates a new BasicTabbedPaneUI.
*
* @param c The JComponent to create a UI for.
@@ -1583,22 +1971,30 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
return new TabbedPaneLayout();
else
{
+ runCount = 1;
+ tabRuns[0] = 0;
+
incrButton = createIncreaseButton();
+ incrButton.addMouseListener(mouseListener);
+
decrButton = createDecreaseButton();
- viewport = new ScrollingViewport();
- viewport.setLayout(null);
+ decrButton.addMouseListener(mouseListener);
+ decrButton.setEnabled(false);
+
panel = new ScrollingPanel();
+ panel.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ panel.addMouseListener(mouseListener);
+ panel.addFocusListener(focusListener);
+
+ viewport = new ScrollingViewport();
+ viewport.setBackground(Color.LIGHT_GRAY);
viewport.setView(panel);
+ viewport.setLayout(null);
+
tabPane.add(incrButton);
tabPane.add(decrButton);
tabPane.add(viewport);
- currentScrollLocation = 0;
- decrButton.setEnabled(false);
- panel.addMouseListener(mouseListener);
- incrButton.addMouseListener(mouseListener);
- decrButton.addMouseListener(mouseListener);
- viewport.setBackground(Color.LIGHT_GRAY);
-
+
return new TabbedPaneScrollLayout();
}
}
@@ -1616,7 +2012,14 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void uninstallComponents()
{
- // Nothing to be done.
+ if (incrButton != null)
+ tabPane.remove(incrButton);
+
+ if (decrButton != null)
+ tabPane.remove(decrButton);
+
+ if (viewport != null)
+ tabPane.remove(viewport);
}
/**
@@ -1629,8 +2032,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
"TabbedPane.font");
tabPane.setOpaque(false);
- highlight = UIManager.getColor("TabbedPane.highlight");
- lightHighlight = UIManager.getColor("TabbedPane.lightHighlight");
+ lightHighlight = UIManager.getColor("TabbedPane.highlight");
+ highlight = UIManager.getColor("TabbedPane.light");
shadow = UIManager.getColor("TabbedPane.shadow");
darkShadow = UIManager.getColor("TabbedPane.darkShadow");
@@ -1641,10 +2044,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
- selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets");
+ selectedTabPadInsets
+ = UIManager.getInsets("TabbedPane.selectedTabPadInsets");
tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
- contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
+ contentBorderInsets
+ = UIManager.getInsets("TabbedPane.contentBorderInsets");
tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
+
+ // Although 'TabbedPane.contentAreaColor' is not defined in the defaults
+ // of BasicLookAndFeel it is used by this class.
+ selectedColor = UIManager.getColor("TabbedPane.contentAreaColor");
+ if (selectedColor == null)
+ selectedColor = UIManager.getColor("control");
calcRect = new Rectangle();
tabRuns = new int[10];
@@ -1661,6 +2072,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabAreaRect = null;
contentRect = null;
tabRuns = null;
+
+ tempIconRect = null;
+ tempTextRect = null;
contentBorderInsets = null;
tabAreaInsets = null;
@@ -1672,11 +2086,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
shadow = null;
lightHighlight = null;
highlight = null;
-
- // Install UI colors and fonts.
- LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",
- "TabbedPane.foreground",
- "TabbedPane.font");
+
+ selectedColor = null;
}
/**
@@ -1704,6 +2115,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabPane.removePropertyChangeListener(propertyChangeListener);
tabPane.removeChangeListener(tabChangeListener);
tabPane.removeMouseListener(mouseListener);
+
+ if (incrButton != null)
+ incrButton.removeMouseListener(mouseListener);
+
+ if (decrButton != null)
+ decrButton.removeMouseListener(mouseListener);
+
+ if (panel != null)
+ {
+ panel.removeMouseListener(mouseListener);
+ panel.removeFocusListener(focusListener);
+ }
focusListener = null;
propertyChangeListener = null;
@@ -1755,18 +2178,31 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
* This method installs keyboard actions for the JTabbedPane.
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Implement.
+ InputMap keyMap = (InputMap) UIManager.get("TabbedPane.focusInputMap");
+ SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, keyMap);
+
+ keyMap = (InputMap) UIManager.get("TabbedPane.ancestorInputMap");
+ SwingUtilities
+ .replaceUIInputMap(tabPane,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ keyMap);
+
+ ActionMap map = getActionMap();
+ SwingUtilities.replaceUIActionMap(tabPane, map);
}
/**
* This method uninstalls keyboard actions for the JTabbedPane.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: Implement.
+ SwingUtilities.replaceUIActionMap(tabPane, null);
+ SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null);
+ SwingUtilities
+ .replaceUIInputMap(tabPane,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ null);
}
/**
@@ -1806,9 +2242,25 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
if (tabPane.getTabCount() == 0)
return;
+
+ int index = tabPane.getSelectedIndex();
+ if (index < 0)
+ index = 0;
+
+ int tabPlacement = tabPane.getTabPlacement();
+
+ // Paint the tab area only in WRAP_TAB_LAYOUT Mode from this method
+ // because it is done through the ScrollingViewport.paint() method
+ // for the SCROLL_TAB_LAYOUT mode.
if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
- paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
- paintContentBorder(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
+ {
+ g.setColor(highlight);
+ g.fillRect(tabAreaRect.x, tabAreaRect.y,
+ tabAreaRect.width, tabAreaRect.height);
+ paintTabArea(g, tabPlacement, index);
+ }
+
+ paintContentBorder(g, tabPlacement, index);
}
/**
@@ -1821,14 +2273,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
{
- Rectangle ir = new Rectangle();
- Rectangle tr = new Rectangle();
-
- boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
-
// Please note: the ordering of the painting is important.
// we WANT to paint the outermost run first and then work our way in.
+
+ // The following drawing code works for both tab layouts.
int tabCount = tabPane.getTabCount();
+
for (int i = runCount - 1; i >= 0; --i)
{
int start = tabRuns[i];
@@ -1842,14 +2292,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
if (j != selectedIndex)
{
- paintTab(g, tabPlacement, rects, j, ir, tr);
+ paintTab(g, tabPlacement, rects, j,
+ tempIconRect, tempTextRect);
}
}
}
-
+
// Paint selected tab in front of every other tab.
if (selectedIndex >= 0)
- paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
+ paintTab(g, tabPlacement, rects, selectedIndex,
+ tempIconRect, tempTextRect);
}
/**
@@ -1889,8 +2341,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// Paint the text.
paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
textRect, isSelected);
+
// Paint icon if necessary.
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
+
// Paint focus indicator.
paintFocusIndicator(g, tabPlacement, rects, tabIndex, iconRect, textRect,
isSelected);
@@ -2030,8 +2484,17 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
protected int getTabLabelShiftX(int tabPlacement, int tabIndex,
boolean isSelected)
{
- // No reason to shift.
- return 0;
+ switch (tabPlacement)
+ {
+ default:
+ case SwingUtilities.TOP:
+ case SwingUtilities.BOTTOM:
+ return 1;
+ case SwingUtilities.LEFT:
+ return (isSelected) ? -1 : 1;
+ case SwingUtilities.RIGHT:
+ return (isSelected) ? 1 : -1;
+ }
}
/**
@@ -2047,8 +2510,17 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
boolean isSelected)
{
- // No reason to shift.
- return 0;
+ switch (tabPlacement)
+ {
+ default:
+ case SwingUtilities.TOP:
+ return (isSelected) ? -1 : 1;
+ case SwingUtilities.BOTTOM:
+ return (isSelected) ? 1 : -1;
+ case SwingUtilities.LEFT:
+ case SwingUtilities.RIGHT:
+ return 0;
+ }
}
/**
@@ -2078,32 +2550,33 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
g.setColor(focus);
switch (tabPlacement)
- {
- case LEFT:
- x = rect.x + 3;
- y = rect.y + 3;
- w = rect.width - 5;
- h = rect.height - 6;
- break;
- case RIGHT:
- x = rect.x + 2;
- y = rect.y + 3;
- w = rect.width - 6;
- h = rect.height - 5;
- break;
- case BOTTOM:
- x = rect.x + 3;
- y = rect.y + 2;
- w = rect.width - 6;
- h = rect.height - 5;
- break;
- case TOP:
- default:
- x = rect.x + 3;
- y = rect.y + 3;
- w = rect.width - 6;
- h = rect.height - 5;
- }
+ {
+ case LEFT:
+ x = rect.x + 3;
+ y = rect.y + 3;
+ w = rect.width - 5;
+ h = rect.height - 6;
+ break;
+ case RIGHT:
+ x = rect.x + 2;
+ y = rect.y + 3;
+ w = rect.width - 6;
+ h = rect.height - 5;
+ break;
+ case BOTTOM:
+ x = rect.x + 3;
+ y = rect.y + 2;
+ w = rect.width - 6;
+ h = rect.height - 5;
+ break;
+ case TOP:
+ default:
+ x = rect.x + 3;
+ y = rect.y + 3;
+ w = rect.width - 6;
+ h = rect.height - 5;
+ }
+
BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
}
}
@@ -2125,34 +2598,109 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
Color saved = g.getColor();
- if (! isSelected || tabPlacement != SwingConstants.TOP)
- {
+ switch (tabPlacement)
+ {
+ case SwingConstants.TOP:
g.setColor(shadow);
- g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
- g.setColor(darkShadow);
- g.drawLine(x, y + h, x + w, y + h);
- }
+ // Inner right line.
+ g.drawLine(x + w - 2, y + 2, x + w - 2, y + h);
- if (! isSelected || tabPlacement != SwingConstants.LEFT)
- {
g.setColor(darkShadow);
- g.drawLine(x + w, y, x + w, y + h);
+ // Outer right line.
+ g.drawLine(x + w - 1, y + 2, x + w - 1, y + h);
+
+ // Upper right corner.
+ g.drawLine(x + w - 2, y + 1, x + w - 1, y + 2);
+
+ g.setColor(lightHighlight);
+
+ // Left line.
+ g.drawLine(x, y + 3, x, y + h);
+
+ // Upper line.
+ g.drawLine(x + 3, y, x + w - 3, y);
+
+ // Upper left corner.
+ g.drawLine(x, y + 2, x + 2, y);
+
+ break;
+ case SwingConstants.LEFT:
+ g.setColor(lightHighlight);
+ // Top line.
+ g.drawLine(x + 3, y, x + w - 1, y);
+
+ // Top left border.
+ g.drawLine(x + 2, y, x, y + 2);
+
+ // Left line.
+ g.drawLine(x, y + 3, x, y + h - 4);
+
+ // Bottom left corner.
+ g.drawLine(x, y + h - 3, x + 1, y + h - 2);
+
+ g.setColor(darkShadow);
+ // Outer bottom line.
+ g.drawLine(x + 2, y + h - 1, x + w - 1, y + h - 1);
+
g.setColor(shadow);
- g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
- }
+ // Inner bottom line.
+ g.drawLine(x + 2, y + h - 2, x + w - 1, y + h - 2);
+
+ break;
+ case SwingConstants.BOTTOM:
+ g.setColor(shadow);
+ // Inner right line.
+ g.drawLine(x + w - 2, y, x + w - 2, y + h - 2);
- if (! isSelected || tabPlacement != SwingConstants.RIGHT)
- {
- g.setColor(lightHighlight);
- g.drawLine(x, y, x, y + h);
- }
+ // Inner bottom line.
+ g.drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1);
- if (! isSelected || tabPlacement != SwingConstants.BOTTOM)
- {
+ g.setColor(darkShadow);
+ // Outer right line.
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 3);
+
+ // Bottom right corner.
+ g.drawLine(x + w - 1, y + h - 2, x + w - 3, y + h);
+
+ // Bottom line.
+ g.drawLine(x + 2, y + h, x + w - 4, y + h);
+
g.setColor(lightHighlight);
- g.drawLine(x, y, x + w, y);
- }
-
+ // Left line.
+ g.drawLine(x, y, x, y + h - 3);
+
+ // Bottom left corner.
+ g.drawLine(x, y + h - 2, x + 1, y + h - 1);
+ break;
+ case SwingConstants.RIGHT:
+ g.setColor(lightHighlight);
+ // Top line.
+ g.drawLine(x, y, x + w - 3, y);
+
+ g.setColor(darkShadow);
+ // Top right corner.
+ g.drawLine(x + w - 2, y + 1, x + w - 1, y + 2);
+
+ // Outer right line.
+ g.drawLine(x + w - 1, y + 3, x + w - 1, y + h - 3);
+
+ // Bottom right corner.
+ g.drawLine(x + w - 2, y + h - 2, x + w - 3, y + h - 1);
+
+ // Bottom line.
+ g.drawLine(x, y + h - 1, x + w - 4, y + h - 1);
+
+ g.setColor(shadow);
+
+ // Inner right line.
+ g.drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3);
+
+ // Inner bottom line.
+ g.drawLine(x, y + h - 2, x + w - 3, y + h - 2);
+
+ break;
+ }
+
g.setColor(saved);
}
@@ -2173,17 +2721,32 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
boolean isSelected)
{
Color saved = g.getColor();
+
if (isSelected)
- g.setColor(Color.LIGHT_GRAY);
+ g.setColor(selectedColor);
else
{
Color bg = tabPane.getBackgroundAt(tabIndex);
if (bg == null)
- bg = Color.GRAY;
+ bg = Color.LIGHT_GRAY;
g.setColor(bg);
}
- g.fillRect(x, y, w, h);
+ switch (tabPlacement)
+ {
+ case SwingConstants.TOP:
+ g.fillRect(x + 1, y + 1, w - 1, h - 1);
+ break;
+ case SwingConstants.BOTTOM:
+ g.fillRect(x, y, w - 1, h - 1);
+ break;
+ case SwingConstants.LEFT:
+ g.fillRect(x + 1, y + 1, w - 1, h - 2);
+ break;
+ case SwingConstants.RIGHT:
+ g.fillRect(x, y + 1, w - 1, h - 2);
+ break;
+ }
g.setColor(saved);
}
@@ -2260,25 +2823,27 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Color saved = g.getColor();
g.setColor(lightHighlight);
- int startgap = rects[selectedIndex].x;
- int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
-
- int diff = 0;
+ int startgap = rects[selectedIndex].x - currentScrollOffset;
+ int endgap = rects[selectedIndex].x + rects[selectedIndex].width
+ - currentScrollOffset;
- if (tabPlacement == SwingConstants.TOP)
+ // Paint the highlight line with a gap if the tabs are at the top
+ // and the selected tab is inside the visible area.
+ if (tabPlacement == SwingConstants.TOP && startgap >= 0)
{
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.x;
- }
-
- g.drawLine(x, y, startgap - diff, y);
- g.drawLine(endgap - diff, y, x + w, y);
+ g.drawLine(x, y, startgap, y);
+ g.drawLine(endgap, y, x + w - 1, y);
+
+ g.setColor(selectedColor);
+ g.drawLine(startgap, y, endgap - 1, y);
}
else
g.drawLine(x, y, x + w, y);
-
+
+ g.setColor(selectedColor);
+ g.drawLine(x, y + 1, x + w - 1, y + 1);
+ g.drawLine(x, y + 2, x + w - 1, y + 2);
+
g.setColor(saved);
}
@@ -2300,24 +2865,25 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Color saved = g.getColor();
g.setColor(lightHighlight);
- int startgap = rects[selectedIndex].y;
- int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
+ int startgap = rects[selectedIndex].y - currentScrollOffset;
+ int endgap = rects[selectedIndex].y + rects[selectedIndex].height
+ - currentScrollOffset;
int diff = 0;
- if (tabPlacement == SwingConstants.LEFT)
+ if (tabPlacement == SwingConstants.LEFT && startgap >= 0)
{
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.y;
- }
-
- g.drawLine(x, y, x, startgap - diff);
- g.drawLine(x, endgap - diff, x, y + h);
+ g.drawLine(x, y, x, startgap);
+ g.drawLine(x, endgap, x, y + h - 1);
+
+ g.setColor(selectedColor);
+ g.drawLine(x, startgap, x, endgap - 1);
}
else
- g.drawLine(x, y, x, y + h);
+ g.drawLine(x, y, x, y + h - 1);
+
+ g.setColor(selectedColor);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 4);
g.setColor(saved);
}
@@ -2339,34 +2905,34 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
Color saved = g.getColor();
- int startgap = rects[selectedIndex].x;
- int endgap = rects[selectedIndex].x + rects[selectedIndex].width;
-
- int diff = 0;
+ int startgap = rects[selectedIndex].x - currentScrollOffset;
+ int endgap = rects[selectedIndex].x + rects[selectedIndex].width
+ - currentScrollOffset;
- if (tabPlacement == SwingConstants.BOTTOM)
+ if (tabPlacement == SwingConstants.BOTTOM && startgap >= 0)
{
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.x;
- }
-
g.setColor(shadow);
- g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1);
- g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);
+ g.drawLine(x + 1, y + h - 2, startgap, y + h - 2);
+ g.drawLine(endgap, y + h - 2, x + w - 2, y + h - 2);
g.setColor(darkShadow);
- g.drawLine(x, y + h, startgap - diff, y + h);
- g.drawLine(endgap - diff, y + h, x + w, y + h);
+ g.drawLine(x, y + h - 1, startgap , y + h - 1);
+ g.drawLine(endgap, y + h - 1, x + w - 1, y + h - 1);
+
+ g.setColor(selectedColor);
+ g.drawLine(startgap, y + h - 1, endgap - 1, y + h - 1);
+ g.drawLine(startgap, y + h - 2, endgap - 1, y + h - 2);
}
else
{
g.setColor(shadow);
- g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
+ g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2);
g.setColor(darkShadow);
- g.drawLine(x, y + h, x + w, y + h);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
}
+
+ g.setColor(selectedColor);
+ g.drawLine(x + 1, y + h - 3, x + w - 2, y + h - 3);
g.setColor(saved);
}
@@ -2387,34 +2953,36 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int w, int h)
{
Color saved = g.getColor();
- int startgap = rects[selectedIndex].y;
- int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
+ int startgap = rects[selectedIndex].y - currentScrollOffset;
+ int endgap = rects[selectedIndex].y + rects[selectedIndex].height
+ - currentScrollOffset;
int diff = 0;
- if (tabPlacement == SwingConstants.RIGHT)
+ if (tabPlacement == SwingConstants.RIGHT && startgap >= 0)
{
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.y;
- }
-
g.setColor(shadow);
- g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff);
- g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, startgap);
+ g.drawLine(x + w - 2, endgap, x + w - 2, y + h - 2);
g.setColor(darkShadow);
- g.drawLine(x + w, y, x + w, startgap - diff);
- g.drawLine(x + w, endgap - diff, x + w, y + h);
+ g.drawLine(x + w - 1, y, x + w - 1, startgap);
+ g.drawLine(x + w - 1, endgap, x + w - 1, y + h - 2);
+
+ g.setColor(selectedColor);
+ g.drawLine(x + w - 2, startgap, x + w - 2, endgap - 1);
+ g.drawLine(x + w - 1, startgap, x + w - 1, endgap - 1);
}
else
{
g.setColor(shadow);
- g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
g.setColor(darkShadow);
- g.drawLine(x + w, y, x + w, y + h);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 2);
}
+
+ g.setColor(selectedColor);
+ g.drawLine(x + w - 3, y + 1, x + w - 3, y + h - 4);
g.setColor(saved);
}
@@ -2458,11 +3026,15 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
public int tabForCoordinate(JTabbedPane pane, int x, int y)
{
+ // Note: This code is tab layout mode agnostic.
if (! tabPane.isValid())
tabPane.validate();
-
+
int tabCount = tabPane.getTabCount();
- int index = -1;
+
+ // If the user clicked outside of any tab rect the
+ // selection should not change.
+ int index = tabPane.getSelectedIndex();
for (int i = 0; i < tabCount; ++i)
{
if (rects[i].contains(x, y))
@@ -2472,8 +3044,6 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
}
}
- // FIXME: Handle scrollable tab layout.
-
return index;
}
@@ -2569,7 +3139,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
protected int getRunForTab(int tabCount, int tabIndex)
{
if (runCount == 1 && tabIndex < tabCount && tabIndex >= 0)
- return 1;
+ return 0;
for (int i = 0; i < runCount; i++)
{
int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;
@@ -2688,6 +3258,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected View getTextViewForTab(int tabIndex)
{
+ // FIXME: When the label contains HTML this should return something
+ // non-null.
return null;
}
@@ -2704,7 +3276,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
protected int calculateTabHeight(int tabPlacement, int tabIndex,
int fontHeight)
{
- // FIXME: Handle HTML somehow.
+ // FIXME: Handle HTML by using the view (see getTextViewForTab).
int height = fontHeight;
Icon icon = getIconForTab(tabIndex);
@@ -2921,8 +3493,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
tabPane.getSelectedIndex(),
- (tabPlacement == SwingConstants.RIGHT)
- ? true : false);
+ (tabPlacement == SwingConstants.TOP)
+ ? direction == SwingConstants.NORTH
+ : direction == SwingConstants.SOUTH);
selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
offset);
}
@@ -2938,8 +3511,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
tabPane.getSelectedIndex(),
- (tabPlacement == SwingConstants.RIGHT)
- ? true : false);
+ (tabPlacement == SwingConstants.LEFT)
+ ? direction == SwingConstants.WEST
+ : direction == SwingConstants.EAST);
selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
offset);
}
@@ -2953,8 +3527,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void selectNextTabInRun(int current)
{
- tabPane.setSelectedIndex(getNextTabIndexInRun(tabPane.getTabCount(),
- current));
+ current = getNextTabIndexInRun(tabPane.getTabCount(),
+ current);
+
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ scrollTab(current, tabPane.getTabPlacement());
+
+ tabPane.setSelectedIndex(current);
}
/**
@@ -2964,8 +3543,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void selectPreviousTabInRun(int current)
{
- tabPane.setSelectedIndex(getPreviousTabIndexInRun(tabPane.getTabCount(),
- current));
+ current = getPreviousTabIndexInRun(tabPane.getTabCount(),
+ current);
+
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ scrollTab(current, tabPane.getTabPlacement());
+
+ tabPane.setSelectedIndex(current);
}
/**
@@ -2975,7 +3559,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void selectNextTab(int current)
{
- tabPane.setSelectedIndex(getNextTabIndex(current));
+ current = getNextTabIndex(current);
+
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ scrollTab(current, tabPane.getTabPlacement());
+
+ tabPane.setSelectedIndex(current);
}
/**
@@ -2985,7 +3574,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void selectPreviousTab(int current)
{
- tabPane.setSelectedIndex(getPreviousTabIndex(current));
+ current = getPreviousTabIndex(current);
+
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ scrollTab(current, tabPane.getTabPlacement());
+
+ tabPane.setSelectedIndex(current);
}
/**
@@ -3019,7 +3613,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int index = tabForCoordinate(tabPane, x, y);
if (index != -1)
- tabPane.setSelectedIndex(index);
+ {
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ scrollTab(index, tabPlacement);
+ tabPane.setSelectedIndex(index);
+ }
}
// This method is called when you press up/down to cycle through tab runs.
@@ -3056,6 +3654,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
else
offset = rects[lastTabInRun(tabCount, nextRun)].x
- rects[lastTabInRun(tabCount, currRun)].x;
+
return offset;
}
@@ -3102,9 +3701,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
int index = getNextTabIndex(base);
int run = getRunForTab(tabCount, base);
- if (index == lastTabInRun(tabCount, run) + 1)
- index = lastTabInRun(tabCount, getPreviousTabRun(run)) + 1;
- return getNextTabIndex(base);
+ if (base == lastTabInRun(tabCount, run))
+ index = (run > 0)
+ ? lastTabInRun(tabCount, getPreviousTabRun(run)) + 1
+ : 0;
+
+ return index;
}
/**
@@ -3122,7 +3724,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int run = getRunForTab(tabCount, base);
if (index == lastTabInRun(tabCount, getPreviousTabRun(run)))
index = lastTabInRun(tabCount, run);
- return getPreviousTabIndex(base);
+
+ return index;
}
/**
@@ -3180,6 +3783,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// so I won't check it either.
switch (targetPlacement)
{
+ default:
case SwingConstants.TOP:
targetInsets.top = topInsets.top;
targetInsets.left = topInsets.left;
@@ -3206,6 +3810,44 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
break;
}
}
+
+ ActionMap getActionMap()
+ {
+ ActionMap map = (ActionMap) UIManager.get("TabbedPane.actionMap");
+
+ if (map == null) // first time here
+ {
+ map = createActionMap();
+ if (map != null)
+ UIManager.put("TabbedPane.actionMap", map);
+ }
+ return map;
+ }
+
+ ActionMap createActionMap()
+ {
+ ActionMap map = new ActionMapUIResource();
+
+ map.put("navigatePageDown", new NavigatePageDownAction());
+ map.put("navigatePageUp", new NavigatePageUpAction());
+ map.put("navigateDown",
+ new NavigateAction("navigateDown", SwingConstants.SOUTH));
+
+ map.put("navigateUp",
+ new NavigateAction("navigateUp", SwingConstants.NORTH));
+
+ map.put("navigateLeft",
+ new NavigateAction("navigateLeft", SwingConstants.WEST));
+
+ map.put("navigateRight",
+ new NavigateAction("navigateRight", SwingConstants.EAST));
+
+ map.put("requestFocusForVisibleComponent",
+ new RequestFocusForVisibleComponentAction());
+ map.put("requestFocus", new RequestFocusAction());
+
+ return map;
+ }
/**
* Sets the tab which should be highlighted when in rollover mode. And
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
index cdd44a711e7..15be4d57e62 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
@@ -48,7 +46,6 @@ import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
@@ -58,6 +55,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
+import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.CellRendererPane;
import javax.swing.DefaultCellEditor;
@@ -65,16 +63,16 @@ import javax.swing.DefaultListSelectionModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTable;
-import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.TransferHandler;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.TableUI;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
@@ -164,14 +162,37 @@ public class BasicTableUI extends TableUI
public class FocusHandler implements FocusListener
{
- public void focusGained(FocusEvent e)
+ public void focusGained(FocusEvent e)
{
- // TODO: Implement this properly.
+ // The only thing that is affected by a focus change seems to be
+ // how the lead cell is painted. So we repaint this cell.
+ repaintLeadCell();
}
- public void focusLost(FocusEvent e)
+ public void focusLost(FocusEvent e)
+ {
+ // The only thing that is affected by a focus change seems to be
+ // how the lead cell is painted. So we repaint this cell.
+ repaintLeadCell();
+ }
+
+ /**
+ * Repaints the lead cell in response to a focus change, to refresh
+ * the display of the focus indicator.
+ */
+ private void repaintLeadCell()
{
- // TODO: Implement this properly.
+ int rowCount = table.getRowCount();
+ int columnCount = table.getColumnCount();
+ int rowLead = table.getSelectionModel().getLeadSelectionIndex();
+ int columnLead = table.getColumnModel().getSelectionModel().
+ getLeadSelectionIndex();
+ if (rowLead >= 0 && rowLead < rowCount && columnLead >= 0
+ && columnLead < columnCount)
+ {
+ Rectangle dirtyRect = table.getCellRect(rowLead, columnLead, false);
+ table.repaint(dirtyRect);
+ }
}
}
@@ -242,19 +263,19 @@ public class BasicTableUI extends TableUI
}
}
- public void mouseEntered(MouseEvent e)
+ public void mouseEntered(MouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
- public void mouseExited(MouseEvent e)
+ public void mouseExited(MouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
- public void mouseMoved(MouseEvent e)
+ public void mouseMoved(MouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
public void mousePressed(MouseEvent e)
@@ -287,6 +308,9 @@ public class BasicTableUI extends TableUI
colLead != colModel.getLeadSelectionIndex())
if (table.isEditing())
table.editingStopped(new ChangeEvent(e));
+
+ // Must request focus explicitly.
+ table.requestFocusInWindow();
}
}
@@ -456,66 +480,100 @@ public class BasicTableUI extends TableUI
table.setOpaque(true);
}
+ /**
+ * Installs keyboard actions on the table.
+ */
protected void installKeyboardActions()
{
- InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap");
- InputMapUIResource parentInputMap = new InputMapUIResource();
- // FIXME: The JDK uses a LazyActionMap for parentActionMap
- ActionMap parentActionMap = new ActionMapUIResource();
- action = new TableAction();
- Object keys[] = ancestorMap.allKeys();
- // Register key bindings in the UI InputMap-ActionMap pair
- for (int i = 0; i < keys.length; i++)
- {
- KeyStroke stroke = (KeyStroke) keys[i];
- String actionString = (String) ancestorMap.get(stroke);
+ // Install the input map.
+ InputMap inputMap =
+ (InputMap) SharedUIDefaults.get("Table.ancestorInputMap");
+ SwingUtilities.replaceUIInputMap(table,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ inputMap);
- parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
- stroke.getModifiers()),
- actionString);
-
- parentActionMap.put(actionString,
- new ActionListenerProxy(action, actionString));
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ SwingUtilities.replaceUIActionMap(table, getActionMap());
- }
- // Set the UI InputMap-ActionMap pair to be the parents of the
- // JTable's InputMap-ActionMap pair
- parentInputMap.setParent(table.getInputMap(
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent());
- parentActionMap.setParent(table.getActionMap().getParent());
- table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
- setParent(parentInputMap);
- table.getActionMap().setParent(parentActionMap);
}
/**
- * This class is used to mimmic the behaviour of the JDK when registering
- * keyboard actions. It is the same as the private class used in JComponent
- * for the same reason. This class receives an action event and dispatches
- * it to the true receiver after altering the actionCommand property of the
- * event.
+ * Fetches the action map from the UI defaults, or create a new one
+ * if the action map hasn't been initialized.
+ *
+ * @return the action map
*/
- private static class ActionListenerProxy
- extends AbstractAction
+ private ActionMap getActionMap()
{
- ActionListener target;
- String bindingCommandName;
-
- public ActionListenerProxy(ActionListener li,
- String cmd)
- {
- target = li;
- bindingCommandName = cmd;
- }
+ ActionMap am = (ActionMap) UIManager.get("Table.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("Table.actionMap", am);
+ }
+ return am;
+ }
- public void actionPerformed(ActionEvent e)
- {
- ActionEvent derivedEvent = new ActionEvent(e.getSource(),
- e.getID(),
- bindingCommandName,
- e.getModifiers());
- target.actionPerformed(derivedEvent);
- }
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new TableAction();
+
+ am.put("cut", TransferHandler.getCutAction());
+ am.put("copy", TransferHandler.getCopyAction());
+ am.put("paste", TransferHandler.getPasteAction());
+
+ am.put("cancel", action);
+ am.put("selectAll", action);
+ am.put("clearSelection", action);
+ am.put("startEditing", action);
+
+ am.put("selectNextRow", action);
+ am.put("selectNextRowCell", action);
+ am.put("selectNextRowExtendSelection", action);
+ am.put("selectNextRowChangeLead", action);
+
+ am.put("selectPreviousRow", action);
+ am.put("selectPreviousRowCell", action);
+ am.put("selectPreviousRowExtendSelection", action);
+ am.put("selectPreviousRowChangeLead", action);
+
+ am.put("selectNextColumn", action);
+ am.put("selectNextColumnCell", action);
+ am.put("selectNextColumnExtendSelection", action);
+ am.put("selectNextColumnChangeLead", action);
+
+ am.put("selectPreviousColumn", action);
+ am.put("selectPreviousColumnCell", action);
+ am.put("selectPreviousColumnExtendSelection", action);
+ am.put("selectPreviousColumnChangeLead", action);
+
+ am.put("scrollLeftChangeSelection", action);
+ am.put("scrollLeftExtendSelection", action);
+ am.put("scrollRightChangeSelection", action);
+ am.put("scrollRightExtendSelection", action);
+
+ am.put("scrollUpChangeSelection", action);
+ am.put("scrollUpExtendSelection", action);
+ am.put("scrollDownChangeSelection", action);
+ am.put("scrolldownExtendSelection", action);
+
+ am.put("selectFirstColumn", action);
+ am.put("selectFirstColumnExtendSelection", action);
+ am.put("selectLastColumn", action);
+ am.put("selectLastColumnExtendSelection", action);
+
+ am.put("selectFirstRow", action);
+ am.put("selectFirstRowExtendSelection", action);
+ am.put("selectLastRow", action);
+ am.put("selectLastRowExtendSelection", action);
+
+ am.put("addToSelection", action);
+ am.put("toggleAndAnchor", action);
+ am.put("extendTo", action);
+ am.put("moveSelectionTo", action);
+
+ return am;
}
/**
@@ -524,7 +582,8 @@ public class BasicTableUI extends TableUI
* method is called when a key that has been registered for the JTable
* is received.
*/
- class TableAction extends AbstractAction
+ private static class TableAction
+ extends AbstractAction
{
/**
* What to do when this action is called.
@@ -533,6 +592,8 @@ public class BasicTableUI extends TableUI
*/
public void actionPerformed(ActionEvent e)
{
+ JTable table = (JTable) e.getSource();
+
DefaultListSelectionModel rowModel
= (DefaultListSelectionModel) table.getSelectionModel();
DefaultListSelectionModel colModel
@@ -543,9 +604,11 @@ public class BasicTableUI extends TableUI
int colLead = colModel.getLeadSelectionIndex();
int colMax = table.getModel().getColumnCount() - 1;
-
- String command = e.getActionCommand();
-
+
+ // The command with which the action has been called is stored
+ // in this undocumented action value. This allows us to have only
+ // one Action instance to serve all keyboard input for JTable.
+ String command = (String) getValue("__command__");
if (command.equals("selectPreviousRowExtendSelection"))
{
rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0));
@@ -603,11 +666,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollUpExtendSelection"))
{
int target;
- if (rowLead == getFirstVisibleRowIndex())
- target = Math.max(0, rowLead - (getLastVisibleRowIndex()
- - getFirstVisibleRowIndex() + 1));
+ if (rowLead == getFirstVisibleRowIndex(table))
+ target = Math.max(0, rowLead - (getLastVisibleRowIndex(table)
+ - getFirstVisibleRowIndex(table) + 1));
else
- target = getFirstVisibleRowIndex();
+ target = getFirstVisibleRowIndex(table);
rowModel.setLeadSelectionIndex(target);
colModel.setLeadSelectionIndex(colLead);
@@ -620,11 +683,12 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollRightChangeSelection"))
{
int target;
- if (colLead == getLastVisibleColumnIndex())
- target = Math.min(colMax, colLead + (getLastVisibleColumnIndex()
- - getFirstVisibleColumnIndex() + 1));
+ if (colLead == getLastVisibleColumnIndex(table))
+ target = Math.min(colMax, colLead
+ + (getLastVisibleColumnIndex(table)
+ - getFirstVisibleColumnIndex(table) + 1));
else
- target = getLastVisibleColumnIndex();
+ target = getLastVisibleColumnIndex(table);
colModel.setSelectionInterval(target, target);
rowModel.setSelectionInterval(rowLead, rowLead);
@@ -637,11 +701,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollLeftChangeSelection"))
{
int target;
- if (colLead == getFirstVisibleColumnIndex())
- target = Math.max(0, colLead - (getLastVisibleColumnIndex()
- - getFirstVisibleColumnIndex() + 1));
+ if (colLead == getFirstVisibleColumnIndex(table))
+ target = Math.max(0, colLead - (getLastVisibleColumnIndex(table)
+ - getFirstVisibleColumnIndex(table) + 1));
else
- target = getFirstVisibleColumnIndex();
+ target = getFirstVisibleColumnIndex(table);
colModel.setSelectionInterval(target, target);
rowModel.setSelectionInterval(rowLead, rowLead);
@@ -723,14 +787,18 @@ public class BasicTableUI extends TableUI
// If there are multiple rows and columns selected, select the next
// cell and wrap at the edges of the selection.
if (command.indexOf("Column") != -1)
- advanceMultipleSelection(colModel, colMinSelected, colMaxSelected,
- rowModel, rowMinSelected, rowMaxSelected,
- command.equals("selectPreviousColumnCell"), true);
+ advanceMultipleSelection(table, colModel, colMinSelected,
+ colMaxSelected, rowModel, rowMinSelected,
+ rowMaxSelected,
+ command.equals("selectPreviousColumnCell"),
+ true);
else
- advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected,
- colModel, colMinSelected, colMaxSelected,
- command.equals("selectPreviousRowCell"), false);
+ advanceMultipleSelection(table, rowModel, rowMinSelected,
+ rowMaxSelected, colModel, colMinSelected,
+ colMaxSelected,
+ command.equals("selectPreviousRowCell"),
+ false);
}
else if (command.equals("selectNextColumn"))
{
@@ -740,11 +808,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollLeftExtendSelection"))
{
int target;
- if (colLead == getFirstVisibleColumnIndex())
- target = Math.max(0, colLead - (getLastVisibleColumnIndex()
- - getFirstVisibleColumnIndex() + 1));
+ if (colLead == getFirstVisibleColumnIndex(table))
+ target = Math.max(0, colLead - (getLastVisibleColumnIndex(table)
+ - getFirstVisibleColumnIndex(table) + 1));
else
- target = getFirstVisibleColumnIndex();
+ target = getFirstVisibleColumnIndex(table);
colModel.setLeadSelectionIndex(target);
rowModel.setLeadSelectionIndex(rowLead);
@@ -752,11 +820,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollDownChangeSelection"))
{
int target;
- if (rowLead == getLastVisibleRowIndex())
- target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex()
- - getFirstVisibleRowIndex() + 1));
+ if (rowLead == getLastVisibleRowIndex(table))
+ target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex(table)
+ - getFirstVisibleRowIndex(table) + 1));
else
- target = getLastVisibleRowIndex();
+ target = getLastVisibleRowIndex(table);
rowModel.setSelectionInterval(target, target);
colModel.setSelectionInterval(colLead, colLead);
@@ -764,11 +832,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollRightExtendSelection"))
{
int target;
- if (colLead == getLastVisibleColumnIndex())
- target = Math.min(colMax, colLead + (getLastVisibleColumnIndex()
- - getFirstVisibleColumnIndex() + 1));
+ if (colLead == getLastVisibleColumnIndex(table))
+ target = Math.min(colMax, colLead + (getLastVisibleColumnIndex(table)
+ - getFirstVisibleColumnIndex(table) + 1));
else
- target = getLastVisibleColumnIndex();
+ target = getLastVisibleColumnIndex(table);
colModel.setLeadSelectionIndex(target);
rowModel.setLeadSelectionIndex(rowLead);
@@ -785,11 +853,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollDownExtendSelection"))
{
int target;
- if (rowLead == getLastVisibleRowIndex())
- target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex()
- - getFirstVisibleRowIndex() + 1));
+ if (rowLead == getLastVisibleRowIndex(table))
+ target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex(table)
+ - getFirstVisibleRowIndex(table) + 1));
else
- target = getLastVisibleRowIndex();
+ target = getLastVisibleRowIndex(table);
rowModel.setLeadSelectionIndex(target);
colModel.setLeadSelectionIndex(colLead);
@@ -797,11 +865,11 @@ public class BasicTableUI extends TableUI
else if (command.equals("scrollUpChangeSelection"))
{
int target;
- if (rowLead == getFirstVisibleRowIndex())
- target = Math.max(0, rowLead - (getLastVisibleRowIndex()
- - getFirstVisibleRowIndex() + 1));
+ if (rowLead == getFirstVisibleRowIndex(table))
+ target = Math.max(0, rowLead - (getLastVisibleRowIndex(table)
+ - getFirstVisibleRowIndex(table) + 1));
else
- target = getFirstVisibleRowIndex();
+ target = getFirstVisibleRowIndex(table);
rowModel.setSelectionInterval(target, target);
colModel.setSelectionInterval(colLead, colLead);
@@ -926,7 +994,7 @@ public class BasicTableUI extends TableUI
* Returns the column index of the first visible column.
* @return the column index of the first visible column.
*/
- int getFirstVisibleColumnIndex()
+ int getFirstVisibleColumnIndex(JTable table)
{
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
@@ -939,7 +1007,7 @@ public class BasicTableUI extends TableUI
* Returns the column index of the last visible column.
*
*/
- int getLastVisibleColumnIndex()
+ int getLastVisibleColumnIndex(JTable table)
{
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
@@ -952,7 +1020,7 @@ public class BasicTableUI extends TableUI
* Returns the row index of the first visible row.
*
*/
- int getFirstVisibleRowIndex()
+ int getFirstVisibleRowIndex(JTable table)
{
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
@@ -965,7 +1033,7 @@ public class BasicTableUI extends TableUI
* Returns the row index of the last visible row.
*
*/
- int getLastVisibleRowIndex()
+ int getLastVisibleRowIndex(JTable table)
{
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
@@ -977,7 +1045,7 @@ public class BasicTableUI extends TableUI
// area is larger than the table)
if (table.rowAtPoint(r.getLocation()) == -1)
{
- if (getFirstVisibleRowIndex() == -1)
+ if (getFirstVisibleRowIndex(table) == -1)
return -1;
else
return table.getModel().getRowCount() - 1;
@@ -1003,7 +1071,8 @@ public class BasicTableUI extends TableUI
* @param reverse true if shift was held for the event
* @param eventIsTab true if TAB was pressed, false if ENTER pressed
*/
- void advanceMultipleSelection(ListSelectionModel firstModel, int firstMin,
+ void advanceMultipleSelection(JTable table, ListSelectionModel firstModel,
+ int firstMin,
int firstMax, ListSelectionModel secondModel,
int secondMin, int secondMax, boolean reverse,
boolean eventIsTab)
@@ -1167,30 +1236,24 @@ public class BasicTableUI extends TableUI
table.addPropertyChangeListener(propertyChangeListener);
}
- protected void uninstallDefaults()
+ /**
+ * Uninstalls UI defaults that have been installed by
+ * {@link #installDefaults()}.
+ */
+ protected void uninstallDefaults()
{
- // TODO: this method used to do the following which is not
- // quite right (at least it breaks apps that run fine with the
- // JDK):
- //
- // table.setFont(null);
- // table.setGridColor(null);
- // table.setForeground(null);
- // table.setBackground(null);
- // table.setSelectionForeground(null);
- // table.setSelectionBackground(null);
- //
- // This would leave the component in a corrupt state, which is
- // not acceptable. A possible solution would be to have component
- // level defaults installed, that get overridden by the UI defaults
- // and get restored in this method. I am not quite sure about this
- // though. / Roman Kennke
+ // Nothing to do here for now.
}
- protected void uninstallKeyboardActions()
- throws NotImplementedException
+ /**
+ * Uninstalls the keyboard actions that have been installed by
+ * {@link #installKeyboardActions()}.
+ */
+ protected void uninstallKeyboardActions()
{
- // TODO: Implement this properly.
+ SwingUtilities.replaceUIInputMap(table, JComponent.
+ WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ SwingUtilities.replaceUIActionMap(table, null);
}
protected void uninstallListeners()
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextFieldUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextFieldUI.java
index 89c4e5a7562..6792aa065da 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextFieldUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextFieldUI.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
import java.beans.PropertyChangeEvent;
import javax.swing.JComponent;
@@ -94,12 +95,24 @@ public class BasicTextFieldUI extends BasicTextUI
{
if (event.getPropertyName().equals("editable"))
{
- boolean editable = ((Boolean) event.getNewValue()).booleanValue();
-
// Changing the color only if the current background is an instance of
// ColorUIResource is the behavior of the RI.
if (textComponent.getBackground() instanceof ColorUIResource)
- textComponent.setBackground(editable ? background : inactiveBackground);
+ {
+ Color c = null;
+ Color old = textComponent.getBackground();
+ String prefix = getPropertyPrefix();
+ if (! textComponent.isEnabled())
+ c = SharedUIDefaults.getColor(prefix + ".disabledBackground");
+ if (c == null && ! textComponent.isEditable())
+ c = SharedUIDefaults.getColor(prefix + ".inactiveBackground");
+ if (c == null)
+ c = SharedUIDefaults.getColor(prefix + ".background");
+ if (c != null && c != old)
+ {
+ textComponent.setBackground(c);
+ }
+ }
}
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
index 34261cfe644..8e9c8c949f3 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
@@ -83,7 +83,6 @@ import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
import javax.swing.text.Position;
-import javax.swing.text.Utilities;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
@@ -418,7 +417,19 @@ public abstract class BasicTextUI extends TextUI
if (event.getPropertyName().equals("document"))
{
// Document changed.
- modelChanged();
+ Object oldValue = event.getOldValue();
+ if (oldValue != null)
+ {
+ Document oldDoc = (Document) oldValue;
+ oldDoc.removeDocumentListener(documentHandler);
+ }
+ Object newValue = event.getNewValue();
+ if (newValue != null)
+ {
+ Document newDoc = (Document) newValue;
+ newDoc.addDocumentListener(documentHandler);
+ }
+ modelChanged();
}
BasicTextUI.this.propertyChange(event);
@@ -501,18 +512,6 @@ public abstract class BasicTextUI extends TextUI
DocumentHandler documentHandler = new DocumentHandler();
/**
- * The standard background color. This is the color which is used to paint
- * text in enabled text components.
- */
- Color background;
-
- /**
- * The inactive background color. This is the color which is used to paint
- * text in disabled text components.
- */
- Color inactiveBackground;
-
- /**
* Creates a new <code>BasicTextUI</code> instance.
*/
public BasicTextUI()
@@ -558,22 +557,23 @@ public abstract class BasicTextUI extends TextUI
*/
public void installUI(final JComponent c)
{
- super.installUI(c);
-
textComponent = (JTextComponent) c;
+ installDefaults();
+ textComponent.addPropertyChangeListener(updateHandler);
Document doc = textComponent.getDocument();
if (doc == null)
{
doc = getEditorKit(textComponent).createDefaultDocument();
textComponent.setDocument(doc);
}
- installDefaults();
+ else
+ {
+ doc.addDocumentListener(documentHandler);
+ modelChanged();
+ }
+
installListeners();
installKeyboardActions();
-
- // We need to trigger this so that the view hierarchy gets initialized.
- modelChanged();
-
}
/**
@@ -581,34 +581,60 @@ public abstract class BasicTextUI extends TextUI
*/
protected void installDefaults()
{
+ String prefix = getPropertyPrefix();
+ // Install the standard properties.
+ LookAndFeel.installColorsAndFont(textComponent, prefix + ".background",
+ prefix + ".foreground", prefix + ".font");
+ LookAndFeel.installBorder(textComponent, prefix + ".border");
+ textComponent.setMargin(UIManager.getInsets(prefix + ".margin"));
+
+ // Some additional text component only properties.
+ Color color = textComponent.getCaretColor();
+ if (color == null || color instanceof UIResource)
+ {
+ color = UIManager.getColor(prefix + ".caretForeground");
+ textComponent.setCaretColor(color);
+ }
+
+ // Fetch the colors for enabled/disabled text components.
+ color = textComponent.getDisabledTextColor();
+ if (color == null || color instanceof UIResource)
+ {
+ color = UIManager.getColor(prefix + ".inactiveBackground");
+ textComponent.setDisabledTextColor(color);
+ }
+ color = textComponent.getSelectedTextColor();
+ if (color == null || color instanceof UIResource)
+ {
+ color = UIManager.getColor(prefix + ".selectionForeground");
+ textComponent.setSelectedTextColor(color);
+ }
+ color = textComponent.getSelectionColor();
+ if (color == null || color instanceof UIResource)
+ {
+ color = UIManager.getColor(prefix + ".selectionBackground");
+ textComponent.setSelectionColor(color);
+ }
+
+ Insets margin = textComponent.getMargin();
+ if (margin == null || margin instanceof UIResource)
+ {
+ margin = UIManager.getInsets(prefix + ".margin");
+ textComponent.setMargin(margin);
+ }
+
Caret caret = textComponent.getCaret();
- if (caret == null)
+ if (caret == null || caret instanceof UIResource)
{
caret = createCaret();
textComponent.setCaret(caret);
+ caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate"));
}
Highlighter highlighter = textComponent.getHighlighter();
- if (highlighter == null)
+ if (highlighter == null || highlighter instanceof UIResource)
textComponent.setHighlighter(createHighlighter());
- String prefix = getPropertyPrefix();
- LookAndFeel.installColorsAndFont(textComponent, prefix + ".background",
- prefix + ".foreground", prefix + ".font");
- LookAndFeel.installBorder(textComponent, prefix + ".border");
- textComponent.setMargin(UIManager.getInsets(prefix + ".margin"));
-
- caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate"));
-
- // Fetch the colors for enabled/disabled text components.
- background = UIManager.getColor(prefix + ".background");
- inactiveBackground = UIManager.getColor(prefix + ".inactiveBackground");
- textComponent.setDisabledTextColor(UIManager.getColor(prefix
- + ".inactiveForeground"));
- textComponent.setSelectedTextColor(UIManager.getColor(prefix
- + ".selectionForeground"));
- textComponent.setSelectionColor(UIManager.getColor(prefix
- + ".selectionBackground"));
}
/**
@@ -670,18 +696,6 @@ public abstract class BasicTextUI extends TextUI
protected void installListeners()
{
textComponent.addFocusListener(focuslistener);
- textComponent.addPropertyChangeListener(updateHandler);
- installDocumentListeners();
- }
-
- /**
- * Installs the document listeners on the textComponent's model.
- */
- private void installDocumentListeners()
- {
- Document doc = textComponent.getDocument();
- if (doc != null)
- doc.addDocumentListener(documentHandler);
}
/**
@@ -845,9 +859,7 @@ public abstract class BasicTextUI extends TextUI
*/
protected void uninstallListeners()
{
- textComponent.removePropertyChangeListener(updateHandler);
textComponent.removeFocusListener(focuslistener);
- textComponent.getDocument().removeDocumentListener(documentHandler);
}
/**
@@ -1029,7 +1041,7 @@ public abstract class BasicTextUI extends TextUI
*/
public void damageRange(JTextComponent t, int p0, int p1)
{
- damageRange(t, p0, p1, null, null);
+ damageRange(t, p0, p1, Position.Bias.Forward, Position.Bias.Backward);
}
/**
@@ -1049,106 +1061,36 @@ public abstract class BasicTextUI extends TextUI
public void damageRange(JTextComponent t, int p0, int p1,
Position.Bias firstBias, Position.Bias secondBias)
{
- // Do nothing if the component cannot be properly displayed.
- if (t.getWidth() == 0 || t.getHeight() == 0)
- return;
-
- try
+ Rectangle alloc = getVisibleEditorRect();
+ if (alloc != null)
{
- // Limit p0 and p1 to sane values to prevent unfriendly
- // BadLocationExceptions. This makes it possible for the highlighter
- // to send us illegal values which can happen when a large number
- // of selected characters are removed (eg. by pressing delete
- // or backspace).
- // The reference implementation does not throw an exception, too.
- p0 = Math.min(p0, t.getDocument().getLength());
- p1 = Math.min(p1, t.getDocument().getLength());
-
- Rectangle l1 = modelToView(t, p0, firstBias);
- Rectangle l2 = modelToView(t, p1, secondBias);
- if (l1 == null || l2 == null)
+ Document doc = t.getDocument();
+
+ // Acquire lock here to avoid structural changes in between.
+ if (doc instanceof AbstractDocument)
+ ((AbstractDocument) doc).readLock();
+ try
{
- // Unable to determine the start or end of the selection.
- t.repaint();
+ rootView.setSize(alloc.width, alloc.height);
+ Shape damage = rootView.modelToView(p0, firstBias, p1, secondBias,
+ alloc);
+ Rectangle r = damage instanceof Rectangle ? (Rectangle) damage
+ : damage.getBounds();
+ textComponent.repaint(r.x, r.y, r.width, r.height);
}
- else if (l1.y == l2.y)
+ catch (BadLocationException ex)
{
- SwingUtilities.computeUnion(l2.x, l2.y, l2.width, l2.height, l1);
- t.repaint(l1);
+ // Lets ignore this as it causes no serious problems.
+ // For debugging, comment this out.
+ // ex.printStackTrace();
}
- else
+ finally
{
- // The two rectangles lie on different lines and we need a
- // different algorithm to calculate the damaged area:
- // 1. The line of p0 is damaged from the position of p0
- // to the right border.
- // 2. All lines between the ones where p0 and p1 lie on
- // are completely damaged. Use the allocation area to find
- // out the bounds.
- // 3. The final line is damaged from the left bound to the
- // position of p1.
- Insets insets = t.getInsets();
-
- // Damage first line until the end.
- l1.width = insets.right + t.getWidth() - l1.x;
- t.repaint(l1);
-
- // Note: Utilities.getPositionBelow() may return the offset
- // that was put in. In that case there is no next line and
- // we should stop searching for one.
-
- int posBelow = Utilities.getPositionBelow(t, p0, l1.x);
- int p1RowStart = Utilities.getRowStart(t, p1);
-
- if (posBelow != -1
- && posBelow != p0
- && Utilities.getRowStart(t, posBelow) != p1RowStart)
- {
- // Take the rectangle of the offset we just found and grow it
- // to the maximum width. Retain y because this is our start
- // height.
- Rectangle grow = modelToView(t, posBelow);
- grow.x = insets.left;
- grow.width = t.getWidth() + insets.right;
-
- // Find further lines which have to be damaged completely.
- int nextPosBelow = posBelow;
- while (nextPosBelow != -1
- && posBelow != nextPosBelow
- && Utilities.getRowStart(t, nextPosBelow) != p1RowStart)
- {
- posBelow = nextPosBelow;
- nextPosBelow = Utilities.getPositionBelow(t, posBelow,
- l1.x);
-
- if (posBelow == nextPosBelow)
- break;
- }
- // Now posBelow is an offset on the last line which has to be
- // damaged completely. (newPosBelow is on the same line as p1)
-
- // Retrieve the rectangle of posBelow and use its y and height
- // value to calculate the final height of the multiple line
- // spanning rectangle.
- Rectangle end = modelToView(t, posBelow);
- grow.height = end.y + end.height - grow.y;
-
- // Mark that area as damage.
- t.repaint(grow);
- }
-
- // Damage last line from its beginning to the position of p1.
- l2.width += l2.x;
- l2.x = insets.left;
- t.repaint(l2);
+ // Release lock.
+ if (doc instanceof AbstractDocument)
+ ((AbstractDocument) doc).readUnlock();
}
}
- catch (BadLocationException ex)
- {
- AssertionError err = new AssertionError("Unexpected bad location");
- err.initCause(ex);
- throw err;
- }
}
/**
@@ -1245,10 +1187,29 @@ public abstract class BasicTextUI extends TextUI
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)
throws BadLocationException
{
- Rectangle r = getVisibleEditorRect();
-
- return (r != null) ? rootView.modelToView(pos, r, bias).getBounds()
- : null;
+ // We need to read-lock here because we depend on the document
+ // structure not beeing changed in between.
+ Document doc = textComponent.getDocument();
+ if (doc instanceof AbstractDocument)
+ ((AbstractDocument) doc).readLock();
+ Rectangle rect = null;
+ try
+ {
+ Rectangle r = getVisibleEditorRect();
+ if (r != null)
+ {
+ rootView.setSize(r.width, r.height);
+ Shape s = rootView.modelToView(pos, r, bias);
+ if (s != null)
+ rect = s.getBounds();
+ }
+ }
+ finally
+ {
+ if (doc instanceof AbstractDocument)
+ ((AbstractDocument) doc).readUnlock();
+ }
+ return rect;
}
/**
@@ -1361,7 +1322,6 @@ public abstract class BasicTextUI extends TextUI
Document doc = textComponent.getDocument();
if (doc == null)
return;
- installDocumentListeners();
Element elem = doc.getDefaultRootElement();
if (elem == null)
return;
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
index 8fce2f08a66..1c36b408d5a 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import gnu.classpath.NotImplementedException;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -50,6 +48,7 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
+import java.awt.event.ActionEvent;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.FocusEvent;
@@ -62,7 +61,11 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Hashtable;
+import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
@@ -77,6 +80,7 @@ import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ToolBarUI;
import javax.swing.plaf.UIResource;
@@ -87,6 +91,35 @@ import javax.swing.plaf.basic.BasicBorders.ButtonBorder;
*/
public class BasicToolBarUI extends ToolBarUI implements SwingConstants
{
+
+ /**
+ * Implements the keyboard actions for JToolBar.
+ */
+ static class ToolBarAction
+ extends AbstractAction
+ {
+ /**
+ * Performs the action.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ Object cmd = getValue("__command__");
+ JToolBar toolBar = (JToolBar) event.getSource();
+ BasicToolBarUI ui = (BasicToolBarUI) toolBar.getUI();
+
+ if (cmd.equals("navigateRight"))
+ ui.navigateFocusedComp(EAST);
+ else if (cmd.equals("navigateLeft"))
+ ui.navigateFocusedComp(WEST);
+ else if (cmd.equals("navigateUp"))
+ ui.navigateFocusedComp(NORTH);
+ else if (cmd.equals("navigateDown"))
+ ui.navigateFocusedComp(SOUTH);
+ else
+ assert false : "Shouldn't reach here";
+ }
+ }
+
/** Static owner of all DragWindows.
* This is package-private to avoid an accessor method. */
static JFrame owner = new JFrame();
@@ -619,9 +652,46 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
* by the look and feel.
*/
protected void installKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement.
+ // Install the input map.
+ InputMap inputMap =
+ (InputMap) SharedUIDefaults.get("ToolBar.ancestorInputMap");
+ SwingUtilities.replaceUIInputMap(toolBar,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ inputMap);
+
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ SwingUtilities.replaceUIActionMap(toolBar, getActionMap());
+ }
+
+ /**
+ * Fetches the action map from the UI defaults, or create a new one
+ * if the action map hasn't been initialized.
+ *
+ * @return the action map
+ */
+ private ActionMap getActionMap()
+ {
+ ActionMap am = (ActionMap) UIManager.get("ToolBar.actionMap");
+ if (am == null)
+ {
+ am = createDefaultActions();
+ UIManager.getLookAndFeelDefaults().put("ToolBar.actionMap", am);
+ }
+ return am;
+ }
+
+ private ActionMap createDefaultActions()
+ {
+ ActionMapUIResource am = new ActionMapUIResource();
+ Action action = new ToolBarAction();
+
+ am.put("navigateLeft", action);
+ am.put("navigateRight", action);
+ am.put("navigateUp", action);
+ am.put("navigateDown", action);
+
+ return am;
}
/**
@@ -643,7 +713,12 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
floatFrame.addWindowListener(windowListener);
toolBarFocusListener = createToolBarFocusListener();
- toolBar.addFocusListener(toolBarFocusListener);
+ if (toolBarFocusListener != null)
+ {
+ int count = toolBar.getComponentCount();
+ for (int i = 0; i < count; i++)
+ toolBar.getComponent(i).addFocusListener(toolBarFocusListener);
+ }
}
/**
@@ -758,9 +833,55 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
* @param direction The direction to give focus to.
*/
protected void navigateFocusedComp(int direction)
- throws NotImplementedException
{
- // FIXME: Implement.
+ int count = toolBar.getComponentCount();
+ switch (direction)
+ {
+ case EAST:
+ case SOUTH:
+ if (focusedCompIndex >= 0 && focusedCompIndex < count)
+ {
+ int i = focusedCompIndex + 1;
+ boolean focusRequested = false;
+ // Find component to focus and request focus on it.
+ while (i != focusedCompIndex && ! focusRequested)
+ {
+ if (i >= count)
+ i = 0;
+ Component comp = toolBar.getComponentAtIndex(i++);
+ if (comp != null && comp.isFocusable()
+ && comp.isEnabled())
+ {
+ comp.requestFocus();
+ focusRequested = true;
+ }
+ }
+ }
+ break;
+ case WEST:
+ case NORTH:
+ if (focusedCompIndex >= 0 && focusedCompIndex < count)
+ {
+ int i = focusedCompIndex - 1;
+ boolean focusRequested = false;
+ // Find component to focus and request focus on it.
+ while (i != focusedCompIndex && ! focusRequested)
+ {
+ if (i < 0)
+ i = count - 1;
+ Component comp = toolBar.getComponentAtIndex(i--);
+ if (comp != null && comp.isFocusable()
+ && comp.isEnabled())
+ {
+ comp.requestFocus();
+ focusRequested = true;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
/**
@@ -925,9 +1046,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
* This method uninstalls keyboard actions installed by the UI.
*/
protected void uninstallKeyboardActions()
- throws NotImplementedException
{
- // FIXME: implement.
+ SwingUtilities.replaceUIInputMap(toolBar, JComponent.
+ WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ SwingUtilities.replaceUIActionMap(toolBar, null);
}
/**
@@ -935,8 +1057,13 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
protected void uninstallListeners()
{
- toolBar.removeFocusListener(toolBarFocusListener);
- toolBarFocusListener = null;
+ if (toolBarFocusListener != null)
+ {
+ int count = toolBar.getComponentCount();
+ for (int i = 0; i < count; i++)
+ toolBar.getComponent(i).removeFocusListener(toolBarFocusListener);
+ toolBarFocusListener = null;
+ }
floatFrame.removeWindowListener(windowListener);
windowListener = null;
@@ -998,7 +1125,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
public void mouseClicked(MouseEvent e)
{
- // Don't care.
+ // Nothing to do here.
}
/**
@@ -1020,7 +1147,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
public void mouseEntered(MouseEvent e)
{
- // Don't care (yet).
+ // Nothing to do here.
}
/**
@@ -1030,7 +1157,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
public void mouseExited(MouseEvent e)
{
- // Don't care (yet).
+ // Nothing to do here.
}
/**
@@ -1040,7 +1167,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
public void mouseMoved(MouseEvent e)
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
/**
@@ -1203,13 +1330,17 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
}
/**
- * FIXME: Do something.
+ * Sets the orientation of the toolbar and the
+ * drag window.
*
- * @param o DOCUMENT ME!
+ * @param o - the new orientation of the toolbar and drag
+ * window.
*/
public void setOrientation(int o)
{
- // FIXME: implement.
+ toolBar.setOrientation(o);
+ if (dragWindow != null)
+ dragWindow.setOrientation(o);
}
}
@@ -1290,6 +1421,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
cachedBounds = toolBar.getPreferredSize();
cachedOrientation = toolBar.getOrientation();
+
+ Component c = e.getChild();
+ if (toolBarFocusListener != null)
+ c.addFocusListener(toolBarFocusListener);
}
/**
@@ -1303,6 +1438,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
setBorderToNormal(e.getChild());
cachedBounds = toolBar.getPreferredSize();
cachedOrientation = toolBar.getOrientation();
+
+ Component c = e.getChild();
+ if (toolBarFocusListener != null)
+ c.removeFocusListener(toolBarFocusListener);
}
}
@@ -1332,27 +1471,30 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
protected ToolBarFocusListener()
{
- // FIXME: implement.
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ * Receives notification when the toolbar or one of it's component
+ * receives the keyboard input focus.
+ *
+ * @param e the focus event
*/
public void focusGained(FocusEvent e)
{
- // FIXME: implement.
+ Component c = e.getComponent();
+ focusedCompIndex = toolBar.getComponentIndex(c);
}
/**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ * Receives notification when the toolbar or one of it's component
+ * looses the keyboard input focus.
+ *
+ * @param e the focus event
*/
public void focusLost(FocusEvent e)
{
- // FIXME: implement.
+ // Do nothing here.
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
index 4c139fe465b..9a193986ac5 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
@@ -174,6 +174,9 @@ public class BasicTreeUI
/**
* Set to false when editing and shouldSelectCall() returns true meaning the
* node should be selected before editing, used in completeEditing.
+ * GNU Classpath editing is implemented differently, so this value is not
+ * actually read anywhere. However it is always set correctly to maintain
+ * interoperability with the derived classes that read this field.
*/
protected boolean stopEditingInCompleteEditing;
@@ -235,9 +238,6 @@ public class BasicTreeUI
/** Set to true if the editor has a different size than the renderer. */
protected boolean editorHasDifferentSize;
- /** The action bound to KeyStrokes. */
- TreeAction action;
-
/** Boolean to keep track of editing. */
boolean isEditing;
@@ -474,8 +474,18 @@ public class BasicTreeUI
*/
protected void setCellRenderer(TreeCellRenderer tcr)
{
- currentCellRenderer = tcr;
+ // Finish editing before changing the renderer.
+ completeEditing();
+
+ // The renderer is set in updateRenderer.
updateRenderer();
+
+ // Refresh the layout if necessary.
+ if (treeState != null)
+ {
+ treeState.invalidateSizes();
+ updateSize();
+ }
}
/**
@@ -845,9 +855,9 @@ public class BasicTreeUI
updateRenderer();
updateDepthOffset();
setSelectionModel(tree.getSelectionModel());
- treeState = createLayoutCache();
- treeSelectionModel.setRowMapper(treeState);
configureLayoutCache();
+ treeState.setRootVisible(tree.isRootVisible());
+ treeSelectionModel.setRowMapper(treeState);
updateSize();
}
@@ -1068,7 +1078,6 @@ public class BasicTreeUI
*/
protected void uninstallKeyboardActions()
{
- action = null;
tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(
null);
tree.getActionMap().setParent(null);
@@ -1169,10 +1178,26 @@ public class BasicTreeUI
protected void updateRenderer()
{
if (tree != null)
- currentCellRenderer = tree.getCellRenderer();
-
- if (currentCellRenderer == null)
- currentCellRenderer = createDefaultCellRenderer();
+ {
+ TreeCellRenderer rend = tree.getCellRenderer();
+ if (rend != null)
+ {
+ createdRenderer = false;
+ currentCellRenderer = rend;
+ if (createdCellEditor)
+ tree.setCellEditor(null);
+ }
+ else
+ {
+ tree.setCellRenderer(createDefaultCellRenderer());
+ createdRenderer = true;
+ }
+ }
+ else
+ {
+ currentCellRenderer = null;
+ createdRenderer = false;
+ }
updateCellEditor();
}
@@ -1237,6 +1262,11 @@ public class BasicTreeUI
{
LookAndFeel.installColorsAndFont(tree, "Tree.background",
"Tree.foreground", "Tree.font");
+
+ hashColor = UIManager.getColor("Tree.hash");
+ if (hashColor == null)
+ hashColor = Color.black;
+
tree.setOpaque(true);
rightChildIndent = UIManager.getInt("Tree.rightChildIndent");
@@ -1264,8 +1294,6 @@ public class BasicTreeUI
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
ancestorInputMap);
- action = new TreeAction();
-
SwingUtilities.replaceUIActionMap(tree, getActionMap());
}
@@ -1295,9 +1323,6 @@ public class BasicTreeUI
ActionMapUIResource am = new ActionMapUIResource();
Action action;
- action = new TreeAction();
- am.put(action.getValue(Action.NAME), action);
-
// TreeHomeAction.
action = new TreeHomeAction(-1, "selectFirst");
am.put(action.getValue(Action.NAME), action);
@@ -1349,6 +1374,13 @@ public class BasicTreeUI
am.put(action.getValue(Action.NAME), action);
action = new TreePageAction(1, "scrollDownChangeLead");
am.put(action.getValue(Action.NAME), action);
+
+ // Tree editing actions
+ action = new TreeStartEditingAction("startEditing");
+ am.put(action.getValue(Action.NAME), action);
+ action = new TreeCancelEditingAction("cancel");
+ am.put(action.getValue(Action.NAME), action);
+
return am;
}
@@ -1703,9 +1735,10 @@ public class BasicTreeUI
protected void completeEditing(boolean messageStop, boolean messageCancel,
boolean messageTree)
{
- if (! stopEditingInCompleteEditing || editingComponent == null)
+ // Make no attempt to complete the non existing editing session.
+ if (!isEditing(tree))
return;
-
+
if (messageStop)
{
getCellEditor().stopCellEditing();
@@ -1812,14 +1845,25 @@ public class BasicTreeUI
boolean cntlClick = false;
if (! treeModel.isLeaf(path.getLastPathComponent()))
{
- int width = 8; // Only guessing.
+ int width;
Icon expandedIcon = getExpandedIcon();
if (expandedIcon != null)
width = expandedIcon.getIconWidth();
+ else
+ // Only guessing. This is the width of
+ // the tree control icon in Metal L&F.
+ width = 18;
Insets i = tree.getInsets();
- int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1)
- - getRightChildIndent() - width / 2 + i.left;
+
+ int depth;
+ if (isRootVisible())
+ depth = path.getPathCount()-1;
+ else
+ depth = path.getPathCount()-2;
+
+ int left = getRowX(tree.getRowForPath(path), depth)
+ - width + i.left;
cntlClick = mouseX >= left && mouseX <= left + width;
}
return cntlClick;
@@ -1848,7 +1892,8 @@ public class BasicTreeUI
*/
protected void toggleExpandState(TreePath path)
{
- if (tree.isExpanded(path))
+ // tree.isExpanded(path) would do the same, but treeState knows faster.
+ if (treeState.isExpanded(path))
tree.collapsePath(path);
else
tree.expandPath(path);
@@ -1975,94 +2020,35 @@ public class BasicTreeUI
Object node = pathForRow.getLastPathComponent();
return treeModel.isLeaf(node);
}
-
+
/**
- * This class implements the actions that we want to happen when specific keys
- * are pressed for the JTree. The actionPerformed method is called when a key
- * that has been registered for the JTree is received.
+ * The action to start editing at the current lead selection path.
*/
- class TreeAction
+ class TreeStartEditingAction
extends AbstractAction
{
-
/**
- * What to do when this action is called.
+ * Creates the new tree cancel editing action.
+ *
+ * @param name the name of the action (used in toString).
+ */
+ public TreeStartEditingAction(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Start editing at the current lead selection path.
*
* @param e the ActionEvent that caused this action.
*/
public void actionPerformed(ActionEvent e)
{
- String command = e.getActionCommand();
TreePath lead = tree.getLeadSelectionPath();
-
- if (command.equals("selectPreviousChangeLead")
- || command.equals("selectPreviousExtendSelection")
- || command.equals("selectPrevious") || command.equals("selectNext")
- || command.equals("selectNextExtendSelection")
- || command.equals("selectNextChangeLead"))
- (new TreeIncrementAction(0, "")).actionPerformed(e);
- else if (command.equals("selectParent") || command.equals("selectChild"))
- (new TreeTraverseAction(0, "")).actionPerformed(e);
- else if (command.equals("selectAll"))
- {
- TreePath[] paths = new TreePath[treeState.getRowCount()];
- for (int i = 0; i < paths.length; i++)
- paths[i] = treeState.getPathForRow(i);
- tree.addSelectionPaths(paths);
- }
- else if (command.equals("startEditing"))
+ if (!tree.isEditing())
tree.startEditingAtPath(lead);
- else if (command.equals("toggle"))
- {
- if (tree.isEditing())
- tree.stopEditing();
- else
- {
- Object last = lead.getLastPathComponent();
- TreePath path = new TreePath(getPathToRoot(last, 0));
- if (! treeModel.isLeaf(last))
- toggleExpandState(path);
- }
- }
- else if (command.equals("clearSelection"))
- tree.clearSelection();
-
- if (tree.isEditing() && ! command.equals("startEditing"))
- tree.stopEditing();
-
- tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
- }
-
- /**
- * This class is used to mimic the behaviour of the JDK when registering
- * keyboard actions. It is the same as the private class used in JComponent
- * for the same reason. This class receives an action event and dispatches it
- * to the true receiver after altering the actionCommand property of the
- * event.
- */
- private static class ActionListenerProxy
- extends AbstractAction
- {
- ActionListener target;
-
- String bindingCommandName;
-
- public ActionListenerProxy(ActionListener li, String cmd)
- {
- target = li;
- bindingCommandName = cmd;
- }
-
- public void actionPerformed(ActionEvent e)
- {
- ActionEvent derivedEvent = new ActionEvent(e.getSource(), e.getID(),
- bindingCommandName,
- e.getModifiers());
-
- target.actionPerformed(derivedEvent);
- }
- }
+ }
/**
* Updates the preferred size when scrolling, if necessary.
@@ -2290,9 +2276,49 @@ public class BasicTreeUI
* @param e the key typed
*/
public void keyTyped(KeyEvent e)
- throws NotImplementedException
{
- // TODO: What should be done here, if anything?
+ char typed = Character.toLowerCase(e.getKeyChar());
+ for (int row = tree.getLeadSelectionRow() + 1;
+ row < tree.getRowCount(); row++)
+ {
+ if (checkMatch(row, typed))
+ {
+ tree.setSelectionRow(row);
+ tree.scrollRowToVisible(row);
+ return;
+ }
+ }
+
+ // Not found below, search above:
+ for (int row = 0; row < tree.getLeadSelectionRow(); row++)
+ {
+ if (checkMatch(row, typed))
+ {
+ tree.setSelectionRow(row);
+ tree.scrollRowToVisible(row);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Check if the given tree row starts with this character
+ *
+ * @param row the tree row
+ * @param typed the typed char, must be converted to lowercase
+ * @return true if the given tree row starts with this character
+ */
+ boolean checkMatch(int row, char typed)
+ {
+ TreePath path = treeState.getPathForRow(row);
+ String node = path.getLastPathComponent().toString();
+ if (node.length() > 0)
+ {
+ char x = node.charAt(0);
+ if (typed == Character.toLowerCase(x))
+ return true;
+ }
+ return false;
}
/**
@@ -2301,9 +2327,8 @@ public class BasicTreeUI
* @param e the key pressed
*/
public void keyPressed(KeyEvent e)
- throws NotImplementedException
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
/**
@@ -2312,9 +2337,8 @@ public class BasicTreeUI
* @param e the key released
*/
public void keyReleased(KeyEvent e)
- throws NotImplementedException
{
- // TODO: What should be done here, if anything?
+ // Nothing to do here.
}
}
@@ -2341,14 +2365,23 @@ public class BasicTreeUI
*/
public void mousePressed(MouseEvent e)
{
+ // Any mouse click cancels the previous waiting edit action, initiated
+ // by the single click on the selected node.
+ if (startEditTimer != null)
+ {
+ startEditTimer.stop();
+ startEditTimer = null;
+ }
if (tree != null && tree.isEnabled())
{
- // Maybe stop editing and return.
- if (isEditing(tree) && tree.getInvokesStopCellEditing()
- && !stopEditing(tree))
- return;
-
+ // Always end the current editing session if clicked on the
+ // tree and outside the bounds of the editing component.
+ if (isEditing(tree))
+ if (!stopEditing(tree))
+ // Return if we have failed to cancel the editing session.
+ return;
+
int x = e.getX();
int y = e.getY();
TreePath path = getClosestPathForLocation(tree, x, y);
@@ -2361,11 +2394,47 @@ public class BasicTreeUI
if (x > bounds.x && x <= (bounds.x + bounds.width))
{
- if (! startEditing(path, e))
- selectPathForEvent(path, e);
+ TreePath currentLead = tree.getLeadSelectionPath();
+ if (currentLead != null && currentLead.equals(path)
+ && e.getClickCount() == 1 && tree.isEditable())
+ {
+ // Schedule the editing session.
+ final TreePath editPath = path;
+
+ // The code below handles the required click-pause-click
+ // functionality which must be present in the tree UI.
+ // If the next click comes after the
+ // time longer than the double click interval AND
+ // the same node stays focused for the WAIT_TILL_EDITING
+ // duration, the timer starts the editing session.
+ if (startEditTimer != null)
+ startEditTimer.stop();
+
+ startEditTimer = new Timer(WAIT_TILL_EDITING,
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ startEditing(editPath, EDIT);
+ }
+ });
+
+ startEditTimer.setRepeats(false);
+ startEditTimer.start();
+ }
+ else
+ {
+ if (e.getClickCount() == 2)
+ toggleExpandState(path);
+ else
+ selectPathForEvent(path, e);
+ }
}
}
}
+
+ // We need to request the focus.
+ tree.requestFocusInWindow();
}
/**
@@ -2830,6 +2899,9 @@ public class BasicTreeUI
}
}
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**
@@ -2945,6 +3017,9 @@ public class BasicTreeUI
tree.setAnchorSelectionPath(newPath);
tree.setLeadSelectionPath(newPath);
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**
@@ -3249,6 +3324,9 @@ public class BasicTreeUI
// and anchor.
tree.setLeadSelectionPath(leadPath);
tree.setAnchorSelectionPath(anchorPath);
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
}
@@ -3336,6 +3414,9 @@ public class BasicTreeUI
tree.expandPath(current);
}
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**
@@ -3644,7 +3725,13 @@ public class BasicTreeUI
{
Rectangle bounds = getPathBounds(tree, path);
TreePath parent = path.getParentPath();
- if (parent != null)
+
+ boolean paintLine;
+ if (isRootVisible())
+ paintLine = parent != null;
+ else
+ paintLine = parent != null && parent.getPathCount() > 1;
+ if (paintLine)
{
Rectangle parentBounds = getPathBounds(tree, parent);
paintVerticalLine(g, tree, parentBounds.x + 2 * gap,
diff --git a/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java b/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
index 47876491160..34278052bc1 100644
--- a/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
+++ b/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
import java.util.HashMap;
import javax.swing.UIManager;
@@ -75,4 +76,16 @@ public class SharedUIDefaults
}
return o;
}
+
+ /**
+ * Returns a shared UI color.
+ *
+ * @param key the key
+ *
+ * @return the shared color instance
+ */
+ static Color getColor(String key)
+ {
+ return (Color) get(key);
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
index 6a528de2b6b..265ea7ef6ae 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
@@ -259,7 +259,9 @@ public class MetalComboBoxButton
Component comp = renderer.getListCellRendererComponent(listBox,
comboBox.getSelectedItem(), -1, false, false);
comp.setFont(rendererPane.getFont());
- if (model.isArmed() && model.isPressed())
+
+ if ((model.isArmed() && model.isPressed())
+ || (comboBox.isFocusOwner() && !comboBox.isPopupVisible()))
{
if (isOpaque())
{
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
index 1219ad9fd11..824f1d8021b 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
@@ -42,6 +42,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
@@ -303,8 +304,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)
@@ -567,10 +569,17 @@ public class MetalFileChooserUI
extends DefaultListCellRenderer
{
/**
+ * This is the icon that is displayed in the combobox. This wraps
+ * the standard icon and adds indendation.
+ */
+ private IndentIcon indentIcon;
+
+ /**
* Creates a new renderer.
*/
public DirectoryComboBoxRenderer(JFileChooser fc)
- {
+ {
+ indentIcon = new IndentIcon();
}
/**
@@ -586,31 +595,86 @@ public class MetalFileChooserUI
* @return The list cell renderer.
*/
public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected, boolean cellHasFocus)
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
{
- FileView fileView = getFileView(getFileChooser());
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
File file = (File) value;
- setIcon(fileView.getIcon(file));
- setText(fileView.getName(file));
-
- if (isSelected)
- {
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
- }
- else
- {
- setBackground(list.getBackground());
- setForeground(list.getForeground());
- }
+ setText(getFileChooser().getName(file));
+
+ // Install indented icon.
+ Icon icon = getFileChooser().getIcon(file);
+ indentIcon.setIcon(icon);
+ int depth = directoryModel.getDepth(index);
+ indentIcon.setDepth(depth);
+ setIcon(indentIcon);
- setEnabled(list.isEnabled());
- setFont(list.getFont());
return this;
}
}
/**
+ * An icon that wraps another icon and adds indentation.
+ */
+ class IndentIcon
+ implements Icon
+ {
+
+ /**
+ * The indentation level.
+ */
+ private static final int INDENT = 10;
+
+ /**
+ * The wrapped icon.
+ */
+ private Icon icon;
+
+ /**
+ * The current depth.
+ */
+ private int depth;
+
+ /**
+ * Sets the icon to be wrapped.
+ *
+ * @param i the icon
+ */
+ void setIcon(Icon i)
+ {
+ icon = i;
+ }
+
+ /**
+ * Sets the indentation depth.
+ *
+ * @param d the depth to set
+ */
+ void setDepth(int d)
+ {
+ depth = d;
+ }
+
+ public int getIconHeight()
+ {
+ return icon.getIconHeight();
+ }
+
+ public int getIconWidth()
+ {
+ return icon.getIconWidth() + depth * INDENT;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ icon.paintIcon(c, g, x + depth * INDENT, y);
+ }
+
+ }
+
+ /**
* A renderer for the files and directories in the file chooser.
*/
protected class FileRenderer
@@ -956,9 +1020,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 +1049,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 +1159,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 +1229,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/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
index a317e3fc00d..30ec7e72b28 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
@@ -1,5 +1,5 @@
/* MetalIconFactory.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,6 +54,7 @@ import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
+import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.UIResource;
@@ -78,7 +79,8 @@ public class MetalIconFactory implements Serializable
/**
* An icon displayed for {@link JCheckBoxMenuItem} components.
*/
- private static class CheckBoxMenuItemIcon implements Icon, Serializable
+ private static class CheckBoxMenuItemIcon
+ implements Icon, UIResource, Serializable
{
/**
* Creates a new icon instance.
@@ -153,7 +155,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserDetailViewIcon()
*/
- private static class FileChooserDetailViewIcon implements Icon, Serializable
+ private static class FileChooserDetailViewIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -233,7 +236,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserHomeFolderIcon()
*/
- private static class FileChooserHomeFolderIcon implements Icon, Serializable
+ private static class FileChooserHomeFolderIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -322,7 +326,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserListViewIcon()
*/
- private static class FileChooserListViewIcon implements Icon, Serializable
+ private static class FileChooserListViewIcon
+ implements Icon, UIResource, Serializable
{
/**
* Creates a new icon.
@@ -418,7 +423,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserNewFolderIcon()
*/
- private static class FileChooserNewFolderIcon implements Icon, Serializable
+ private static class FileChooserNewFolderIcon
+ implements Icon, UIResource, Serializable
{
/**
* Creates a new icon.
@@ -490,8 +496,7 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserNewFolderIcon()
*/
- private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
- implements Icon, Serializable
+ private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
{
/**
* Creates a new icon.
@@ -883,7 +888,8 @@ public class MetalIconFactory implements Serializable
/**
* An icon displayed for {@link JRadioButtonMenuItem} components.
*/
- private static class RadioButtonMenuItemIcon implements Icon, Serializable
+ private static class RadioButtonMenuItemIcon
+ implements Icon, UIResource, Serializable
{
/**
* Creates a new icon instance.
@@ -960,7 +966,8 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class HorizontalSliderThumbIcon implements Icon, Serializable
+ private static class HorizontalSliderThumbIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -1102,7 +1109,8 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'close' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameCloseIcon implements Icon, Serializable
+ private static class InternalFrameCloseIcon
+ implements Icon, UIResource, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -1219,7 +1227,7 @@ public class MetalIconFactory implements Serializable
* The icon displayed at the top-left corner of a {@link JInternalFrame}.
*/
private static class InternalFrameDefaultMenuIcon
- implements Icon, Serializable
+ implements Icon, UIResource, Serializable
{
/**
@@ -1291,7 +1299,7 @@ public class MetalIconFactory implements Serializable
* provide a 'restore' option.
*/
private static class InternalFrameAltMaximizeIcon
- implements Icon, Serializable
+ implements Icon, UIResource, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -1401,7 +1409,8 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'maximize' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameMaximizeIcon implements Icon, Serializable
+ private static class InternalFrameMaximizeIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -1513,7 +1522,8 @@ public class MetalIconFactory implements Serializable
/**
* An icon used in the title frame of a {@link JInternalFrame}.
*/
- private static class InternalFrameMinimizeIcon implements Icon, Serializable
+ private static class InternalFrameMinimizeIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -1617,7 +1627,8 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class VerticalSliderThumbIcon implements Icon, Serializable
+ private static class VerticalSliderThumbIcon
+ implements Icon, UIResource, Serializable
{
/**
* This mask is used to paint the gradient in the shape of the thumb.
@@ -1801,78 +1812,36 @@ public class MetalIconFactory implements Serializable
/**
* Paints the icon at the location (x, y).
*
- * @param c the component.
- * @param g the graphics device.
- * @param x the x coordinate.
- * @param y the y coordinate.
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
*/
- public void paintIcon(Component c, Graphics g, int x, int y)
+ public void paintIcon(Component c, Graphics g, int x, int y)
{
- x = x + 5;
- y = y + 5;
- if (collapsed)
- {
- // TODO: pick up appropriate UI colors
- g.setColor(Color.black);
- g.drawLine(x + 2, y, x + 5, y);
- g.drawLine(x + 6, y + 1, x + 7, y + 2);
- g.fillRect(x + 7, y + 3, 5, 2);
- g.drawLine(x + 7, y + 5, x + 6, y + 6);
- g.drawLine(x + 1, y + 1, x + 1, y + 1);
- g.drawLine(x, y + 2, x, y + 5);
- g.drawLine(x + 1, y + 6, x + 1, y + 6);
- g.drawLine(x + 2, y + 7, x + 5, y + 7);
- g.fillRect(x + 3, y + 3, 2, 2);
-
- g.setColor(new Color(204, 204, 255));
- g.drawLine(x + 3, y + 2, x + 4, y + 2);
- g.drawLine(x + 2, y + 3, x + 2, y + 4);
- g.drawLine(x + 3, y + 5, x + 3, y + 5);
- g.drawLine(x + 5, y + 3, x + 5, y + 3);
-
- g.setColor(new Color(153, 153, 204));
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 2, y + 5, x + 2, y + 5);
- g.drawLine(x + 2, y + 6, x + 5, y + 6);
- g.drawLine(x + 5, y + 2, x + 5, y + 2);
- g.drawLine(x + 6, y + 2, x + 6, y + 5);
-
- g.setColor(new Color(102, 102, 153));
- g.drawLine(x + 2, y + 1, x + 5, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 5);
- }
+ // TODO: pick up appropriate UI colors
+ Color dark = new Color(99, 130, 191);
+ Color light = new Color(163, 184, 204);
+ Color white = Color.white;
+
+ x += 8;
+ y += 6;
+
+ final int w = 6;
+ final int wHalf = (w >> 2);
+ g.setColor(light);
+ g.drawOval(x, y, w, w);
+ g.setColor(dark);
+ g.fillOval(x + 1, y + 1, w - 1, w - 1);
+
+ if (collapsed)
+ g.fillRect(x + w, y + wHalf + 1, w, 2);
else
- {
- // TODO: pick up appropriate UI colors
- g.setColor(Color.black);
- g.drawLine(x + 2, y, x + 5, y);
- g.drawLine(x + 6, y + 1, x + 7, y + 2);
- g.drawLine(x + 7, y + 2, x + 7, y + 5);
- g.fillRect(x + 3, y + 7, 2, 5);
- g.drawLine(x + 7, y + 5, x + 6, y + 6);
- g.drawLine(x + 1, y + 1, x + 1, y + 1);
- g.drawLine(x, y + 2, x, y + 5);
- g.drawLine(x + 1, y + 6, x + 1, y + 6);
- g.drawLine(x + 2, y + 7, x + 5, y + 7);
- g.fillRect(x + 3, y + 3, 2, 2);
-
- g.setColor(new Color(204, 204, 255));
- g.drawLine(x + 3, y + 2, x + 4, y + 2);
- g.drawLine(x + 2, y + 3, x + 2, y + 4);
- g.drawLine(x + 3, y + 5, x + 3, y + 5);
- g.drawLine(x + 5, y + 3, x + 5, y + 3);
-
- g.setColor(new Color(153, 153, 204));
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 2, y + 5, x + 2, y + 5);
- g.drawLine(x + 2, y + 6, x + 5, y + 6);
- g.drawLine(x + 5, y + 2, x + 5, y + 2);
- g.drawLine(x + 6, y + 2, x + 6, y + 5);
-
- g.setColor(new Color(102, 102, 153));
- g.drawLine(x + 2, y + 1, x + 5, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 5);
- }
+ g.fillRect(x + wHalf + 1, y + w, 2, w);
+
+ g.setColor(white);
+ g.fillRect(x + wHalf + 1, y + wHalf + 1, 2, 2);
+
}
/**
@@ -1964,7 +1933,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getTreeHardDriveIcon()
*/
- private static class TreeHardDriveIcon implements Icon, Serializable
+ private static class TreeHardDriveIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -2074,7 +2044,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getTreeFloppyDriveIcon()
*/
- private static class TreeFloppyDriveIcon implements Icon, Serializable
+ private static class TreeFloppyDriveIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -2150,7 +2121,8 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getTreeComputerIcon()
*/
- private static class TreeComputerIcon implements Icon, Serializable
+ private static class TreeComputerIcon
+ implements Icon, UIResource, Serializable
{
/**
@@ -2255,6 +2227,12 @@ public class MetalIconFactory implements Serializable
/** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
private static Icon treeHardDriveIcon;
+ /** The icon instance returned by {@link #getHorizontalSliderThumbIcon()}. */
+ private static Icon horizontalSliderThumbIcon;
+
+ /** The icon instance returned by {@link #getVerticalSliderThumbIcon()}. */
+ private static Icon verticalSliderThumbIcon;
+
/**
* Creates a new instance. All the methods are static, so creating an
* instance isn't necessary.
@@ -2383,7 +2361,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getHorizontalSliderThumbIcon()
{
- return new HorizontalSliderThumbIcon();
+ if (horizontalSliderThumbIcon == null)
+ horizontalSliderThumbIcon = new HorizontalSliderThumbIcon();
+ return horizontalSliderThumbIcon;
}
/**
@@ -2462,7 +2442,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getVerticalSliderThumbIcon()
{
- return new VerticalSliderThumbIcon();
+ if (verticalSliderThumbIcon == null)
+ verticalSliderThumbIcon = new VerticalSliderThumbIcon();
+ return verticalSliderThumbIcon;
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
index 09eafd40fe9..8a5a61107c1 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -85,7 +85,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
}
/**
- * Sets the current theme to a new instance of {@link DefaultMetalTheme}.
+ * Sets the current theme to a new instance of {@link OceanTheme}.
*/
protected void createDefaultTheme()
{
@@ -709,6 +709,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
* @param theme the theme (<code>null</code> not permitted).
*
* @throws NullPointerException if <code>theme</code> is <code>null</code>.
+ *
+ * @see #getCurrentTheme()
*/
public static void setCurrentTheme(MetalTheme theme)
{
@@ -1183,20 +1185,26 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"SplitPaneDivider.draggingColor", Color.DARK_GRAY,
"TabbedPane.background", getControlShadow(),
+ "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
+ "TabbedPane.contentOpaque", Boolean.TRUE,
"TabbedPane.darkShadow", getControlDarkShadow(),
"TabbedPane.focus", getPrimaryControlDarkShadow(),
"TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
"TabbedPane.foreground", getControlTextColor(),
"TabbedPane.highlight", getControlHighlight(),
"TabbedPane.light", getControl(),
- "TabbedPane.selected", getControl(),
+ "TabbedPane.selected", getControl(), // overridden in OceanTheme
"TabbedPane.selectHighlight", getControlHighlight(),
"TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
"TabbedPane.shadow", getControlShadow(),
- "TabbedPane.tabAreaBackground", getControl(),
- "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6),
+ "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme
+ "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito
"TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
+ // new properties in OceanTheme:
+ // TabbedPane.contentAreaColor
+ // TabbedPane.unselectedBackground
+
"Table.background", getWindowBackground(),
"Table.focusCellBackground", getWindowBackground(),
"Table.focusCellForeground", getControlTextColor(),
@@ -1243,6 +1251,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"TextPane.selectionBackground", getTextHighlightColor(),
"TextPane.selectionForeground", getHighlightedTextColor(),
+ "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
"TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12),
"TitledBorder.titleColor", getSystemTextColor(),
@@ -1335,12 +1344,17 @@ public class MetalLookAndFeel extends BasicLookAndFeel
}
/**
- * Returns the current theme setting for the Metal L&amp;F.
+ * Returns the current theme for the Metal look and feel. The default is
+ * an instance of {@link OceanTheme}.
*
- * @return the current theme setting for the Metal L&amp;F
+ * @return The current theme (never <code>null</code>).
+ *
+ * @see #setCurrentTheme(MetalTheme)
*/
public static MetalTheme getCurrentTheme()
{
+ if (theme == null)
+ theme = new OceanTheme();
return theme;
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
index 31d8d671fa1..ff763ea9da9 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
@@ -44,6 +44,7 @@ import javax.swing.JComponent;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicMenuBarUI;
/**
@@ -75,7 +76,9 @@ public class MetalMenuBarUI extends BasicMenuBarUI
*/
public void update(Graphics g, JComponent c)
{
- if (c.isOpaque() && UIManager.get("MenuBar.gradient") != null)
+ if (c.isOpaque()
+ && UIManager.get("MenuBar.gradient") != null
+ && c.getBackground() instanceof UIResource)
{
MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
SwingConstants.VERTICAL, "MenuBar.gradient");
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java b/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java
index 84f9cfe494e..a55dc091665 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java
@@ -84,6 +84,7 @@ public class MetalScrollButton extends BasicArrowButton
super(direction);
buttonWidth = width;
this.freeStanding = freeStanding;
+ setFocusable(false);
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index c49abe832e4..20135fc857e 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
@@ -1,5 +1,5 @@
/* MetalTabbedPaneUI.java
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -170,7 +170,9 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
*/
protected LayoutManager createLayoutManager()
{
- return new TabbedPaneLayout();
+ return (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
+ ? new MetalTabbedPaneUI.TabbedPaneLayout()
+ : super.createLayoutManager();
}
/**
@@ -326,7 +328,6 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
int bottom = h - 1;
int right = w - 1;
-
int tabCount = tabPane.getTabCount();
int currentRun = getRunForTab(tabCount, tabIndex);
int firstIndex = tabRuns[currentRun];
@@ -396,14 +397,17 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
{
if (tabPane.getSelectedIndex() == tabIndex - 1)
{
- g.drawLine(0, 5, 0, bottom);
- g.setColor(oceanSelectedBorder);
- g.drawLine(0, 0, 0, 5);
+ g.drawLine(0, 6, 0, bottom);
+ if (tabIndex != firstIndex)
+ {
+ g.setColor(oceanSelectedBorder);
+ g.drawLine(0, 0, 0, 5);
+ }
}
else if (isSelected)
{
g.drawLine(0, 5, 0, bottom);
- if (tabIndex != 0)
+ if (tabIndex != firstIndex)
{
g.setColor(darkShadow);
g.drawLine(0, 0, 0, 5);
@@ -463,9 +467,10 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
{
Color c;
if (tabPane.getSelectedIndex() == tabIndex - 1)
- c = UIManager.getColor("TabbedPane.tabAreaBackground");
+ c = selectColor;
else
c = getUnselectedBackground(tabIndex - 1);
+ g.setColor(c);
g.fillRect(right - 5, 0, 5, 3);
g.fillRect(right - 2, 3, 2, 2);
}
@@ -522,10 +527,13 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
}
else if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1)
{
- g.setColor(oceanSelectedBorder);
- g.drawLine(right, 0, right, 6);
+ if (tabIndex != firstIndex)
+ {
+ g.setColor(oceanSelectedBorder);
+ g.drawLine(right, 0, right, 6);
+ }
g.setColor(darkShadow);
- g.drawLine(right, 6, right, bottom);
+ g.drawLine(right, 7, right, bottom);
}
else if (tabIndex != firstIndex)
{
@@ -598,8 +606,10 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
if (isOcean && isSelected)
{
g.drawLine(0, 0, 0, bottom - 5);
- if ((currentRun == 0 && tabIndex != 0)
- || (currentRun > 0 && tabIndex != tabRuns[currentRun - 1]))
+
+ // Paint a connecting line to the tab below for all
+ // but the first tab in the last run.
+ if (tabIndex != tabRuns[runCount-1])
{
g.setColor(darkShadow);
g.drawLine(0, bottom - 5, 0, bottom);
@@ -688,6 +698,103 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
}
/**
+ * This method paints the focus rectangle around the selected tab.
+ *
+ * @param g The Graphics object to paint with.
+ * @param tabPlacement The JTabbedPane's tab placement.
+ * @param rects The array of rectangles keeping track of size and position.
+ * @param tabIndex The tab index.
+ * @param iconRect The icon bounds.
+ * @param textRect The text bounds.
+ * @param isSelected Whether this tab is selected.
+ */
+ protected void paintFocusIndicator(Graphics g, int tabPlacement,
+ Rectangle[] rects, int tabIndex,
+ Rectangle iconRect, Rectangle textRect,
+ boolean isSelected)
+ {
+ if (tabPane.hasFocus() && isSelected)
+ {
+ Rectangle rect = rects[tabIndex];
+
+ g.setColor(focus);
+ g.translate(rect.x, rect.y);
+
+ switch (tabPlacement)
+ {
+ case LEFT:
+ // Top line
+ g.drawLine(7, 2, rect.width-2, 2);
+
+ // Right line
+ g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
+
+ // Bottom line
+ g.drawLine(rect.width-2, rect.height-2, 3, rect.height-2);
+
+ // Left line
+ g.drawLine(2, rect.height-3, 2, 7);
+
+ // Slant
+ g.drawLine(2, 6, 6, 2);
+ break;
+ case RIGHT:
+ // Top line
+ g.drawLine(1, 2, rect.width-8, 2);
+
+ // Slant
+ g.drawLine(rect.width-7, 2, rect.width-3, 6);
+
+ // Right line
+ g.drawLine(rect.width-3, 7, rect.width-3, rect.height-3);
+
+ // Bottom line
+ g.drawLine(rect.width-3, rect.height-2, 2, rect.height-2);
+
+ // Left line
+ g.drawLine(1, rect.height-2, 1, 2);
+ break;
+ case BOTTOM:
+ // Top line
+ g.drawLine(2, 1, rect.width-2, 1);
+
+ // Right line
+ g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
+
+ // Bottom line
+ g.drawLine(7, rect.height-3, rect.width-2, rect.height-3);
+
+ // Slant
+ g.drawLine(6, rect.height-3, 2, rect.height-7);
+
+ // Left line
+ g.drawLine(2, rect.height-8, 2, 2);
+
+ break;
+ case TOP:
+ default:
+ // Top line
+ g.drawLine(6, 2, rect.width-2, 2);
+
+ // Right line
+ g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
+
+ // Bottom line
+ g.drawLine(3, rect.height-3, rect.width-2, rect.height-3);
+
+ // Left line
+ g.drawLine(2, rect.height-3, 2, 7);
+
+ // Slant
+ g.drawLine(2, 6, 6, 2);
+
+ }
+
+ g.translate(-rect.x, -rect.y);
+ }
+ }
+
+ /**
* Returns <code>true</code> if the tabs in the specified run should be
* padded to make the run fill the width/height of the {@link JTabbedPane}.
*
@@ -1144,4 +1251,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
bg = unselectedBackground;
return bg;
}
+
+ protected int getTabLabelShiftX(int tabPlacement,
+ int index,
+ boolean isSelected)
+ {
+ return 0;
+ }
+
+ protected int getTabLabelShiftY(int tabPlacement,
+ int index,
+ boolean isSelected)
+ {
+ return 0;
+ }
+
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
index 72cbb34a6dc..0c3a38d5cc3 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
@@ -41,6 +41,7 @@ import gnu.classpath.SystemProperties;
import java.awt.Color;
import java.awt.Component;
+import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.TexturePaint;
@@ -106,7 +107,7 @@ class MetalUtils
for (int mX = x + xOff; mX < (x + w); mX += 4)
{
- g.drawLine(mX, mY, mX, mY);
+ g.fillRect(mX, mY, 1, 1);
}
// increase x offset
@@ -305,6 +306,15 @@ class MetalUtils
float g1, float g2, Color c1, Color c2,
Color c3, int[][] mask)
{
+
+ if (g instanceof Graphics2D
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null)
+ {
+ paintHorizontalGradient2D((Graphics2D) g, x, y, w, h, g1, g2, c1, c2,
+ c3, mask);
+ return;
+ }
+
// Calculate the coordinates.
int y0 = y;
int y1 = y + h;
@@ -339,7 +349,7 @@ class MetalUtils
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
}
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
// Paint solid c2 area.
g.setColor(c2);
@@ -353,7 +363,7 @@ class MetalUtils
{
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
}
@@ -377,7 +387,7 @@ class MetalUtils
y0 = mask[xc - x0][0] + y;
y1 = mask[xc - x0][1] + y;
}
- g.drawLine(xc, y0, xc, y1);
+ g.fillRect(xc, y0, 1, y1 - y0);
}
// Paint third gradient area (c1->c3).
@@ -421,9 +431,17 @@ class MetalUtils
* described above
*/
static void paintVerticalGradient(Graphics g, int x, int y, int w, int h,
- double g1, double g2, Color c1, Color c2,
+ float g1, float g2, Color c1, Color c2,
Color c3, int[][] mask)
{
+ if (g instanceof Graphics2D
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null)
+ {
+ paintVerticalGradient2D((Graphics2D) g, x, y, w, h, g1, g2, c1, c2,
+ c3, mask);
+ return;
+ }
+
// Calculate the coordinates.
int x0 = x;
int x1 = x + w;
@@ -458,7 +476,7 @@ class MetalUtils
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
// Paint solid c2 area.
g.setColor(c2);
@@ -472,7 +490,7 @@ class MetalUtils
{
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
}
@@ -496,7 +514,7 @@ class MetalUtils
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
// Paint third gradient area (c1->c3).
@@ -519,7 +537,61 @@ class MetalUtils
x0 = mask[yc - y0][0] + x;
x1 = mask[yc - y0][1] + x;
}
- g.drawLine(x0, yc, x1, yc);
+ g.fillRect(x0, yc, x1 - x0, 1);
}
}
+
+ /**
+ * Paints a horizontal gradient using Graphics2D functionality.
+ *
+ * @param g the Graphics2D instance
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param g1 the relative width of the c1->c2 gradients
+ * @param g2 the relative width of the c2 solid area
+ * @param c1 the color 1
+ * @param c2 the color 2
+ * @param c3 the color 3
+ * @param mask the mask that should be used when painting the gradient as
+ * described above
+ */
+ private static void paintHorizontalGradient2D(Graphics2D g, int x, int y,
+ int w, int h, float g1,
+ float g2, Color c1,
+ Color c2, Color c3,
+ int[][] mask)
+ {
+ // FIXME: Handle the mask somehow, or do Graphics2D clipping instead.
+ GradientPaint p1 = new GradientPaint(x, y, c1, x + w * g1, y, c2);
+ g.setPaint(p1);
+ // This fills the first gradient and the solid area in one go.
+ g.fillRect(x, y, (int) (w * (g1 + g2)), h);
+
+ GradientPaint p2 = new GradientPaint(x + (w * (g1 + g2)), y, c2, x + w, y,
+ c3);
+ g.setPaint(p2);
+ g.fillRect((int) (x + (w * (g1 + g2))), y,
+ (int) (w * (1. - (g1 + g2))), h);
+ }
+
+ private static void paintVerticalGradient2D(Graphics2D g, int x, int y,
+ int w, int h, float g1,
+ float g2, Color c1,
+ Color c2, Color c3,
+ int[][] mask)
+ {
+ // FIXME: Handle the mask somehow, or do Graphics2D clipping instead.
+ GradientPaint p1 = new GradientPaint(x, y, c1, x, y + h * g1, c2);
+ g.setPaint(p1);
+ // This fills the first gradient and the solid area in one go.
+ g.fillRect(x, y, w, (int) (h * (g1 + g2)));
+
+ GradientPaint p2 = new GradientPaint(x, y + (h * (g1 + g2)), c2, x, y + h,
+ c3);
+ g.setPaint(p2);
+ g.fillRect(x, (int) (y + (h * (g1 + g2))), w,
+ (int) (h * (1. - (g1 + g2))));
+ }
}
diff --git a/libjava/classpath/javax/swing/table/DefaultTableColumnModel.java b/libjava/classpath/javax/swing/table/DefaultTableColumnModel.java
index 24ac8fc9c39..33e68ea9fcd 100644
--- a/libjava/classpath/javax/swing/table/DefaultTableColumnModel.java
+++ b/libjava/classpath/javax/swing/table/DefaultTableColumnModel.java
@@ -91,10 +91,10 @@ public class DefaultTableColumnModel
/**
* A change event used when notifying listeners of a change to the
* <code>columnMargin</code> field. This single event is reused for all
- * notifications.
+ * notifications (it is lazily instantiated within the
+ * {@link #fireColumnMarginChanged()} method).
*/
- // FIXME: use lazy instantiation
- protected transient ChangeEvent changeEvent = new ChangeEvent(this);
+ protected transient ChangeEvent changeEvent;
/**
* A flag that indicates whether or not columns can be selected.
@@ -580,7 +580,9 @@ public class DefaultTableColumnModel
*/
protected void fireColumnMarginChanged()
{
- EventListener [] listeners = getListeners(TableColumnModelListener.class);
+ EventListener[] listeners = getListeners(TableColumnModelListener.class);
+ if (changeEvent == null && listeners.length > 0)
+ changeEvent = new ChangeEvent(this);
for (int i = 0; i < listeners.length; ++i)
((TableColumnModelListener) listeners[i]).columnMarginChanged(changeEvent);
}
diff --git a/libjava/classpath/javax/swing/text/AbstractDocument.java b/libjava/classpath/javax/swing/text/AbstractDocument.java
index 1ef81732fed..eb46a8c42f6 100644
--- a/libjava/classpath/javax/swing/text/AbstractDocument.java
+++ b/libjava/classpath/javax/swing/text/AbstractDocument.java
@@ -147,14 +147,19 @@ public abstract class AbstractDocument implements Document, Serializable
/**
* A condition variable that readers and writers wait on.
*/
- Object documentCV = new Object();
+ private Object documentCV = new Object();
/** An instance of a DocumentFilter.FilterBypass which allows calling
* the insert, remove and replace method without checking for an installed
* document filter.
*/
- DocumentFilter.FilterBypass bypass;
-
+ private DocumentFilter.FilterBypass bypass;
+
+ /**
+ * The bidi root element.
+ */
+ private Element bidiRoot;
+
/**
* Creates a new <code>AbstractDocument</code> with the specified
* {@link Content} model.
@@ -185,6 +190,13 @@ public abstract class AbstractDocument implements Document, Serializable
{
content = doc;
context = ctx;
+
+ // FIXME: This is determined using a Mauve test. Make the document
+ // actually use this.
+ putProperty("i18n", Boolean.FALSE);
+
+ // FIXME: Fully implement bidi.
+ bidiRoot = new BranchElement(null, null);
}
/** Returns the DocumentFilter.FilterBypass instance for this
@@ -360,7 +372,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public Element getBidiRootElement()
{
- return null;
+ return bidiRoot;
}
/**
@@ -477,8 +489,9 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public Element[] getRootElements()
{
- Element[] elements = new Element[1];
+ Element[] elements = new Element[2];
elements[0] = getDefaultRootElement();
+ elements[1] = getBidiRootElement();
return elements;
}
@@ -739,29 +752,36 @@ public abstract class AbstractDocument implements Document, Serializable
void removeImpl(int offset, int length) throws BadLocationException
{
- // Prevent some unneccessary method invocation (observed in the RI).
- if (length <= 0)
- return;
-
- DefaultDocumentEvent event =
- new DefaultDocumentEvent(offset, length,
- DocumentEvent.EventType.REMOVE);
-
- try
+ // The RI silently ignores all requests that have a negative length.
+ // Don't ask my why, but that's how it is.
+ if (length > 0)
{
- writeLock();
+ if (offset < 0 || offset > getLength())
+ throw new BadLocationException("Invalid remove position", offset);
+
+ if (offset + length > getLength())
+ throw new BadLocationException("Invalid remove length", offset);
+
+ DefaultDocumentEvent event =
+ new DefaultDocumentEvent(offset, length,
+ DocumentEvent.EventType.REMOVE);
+
+ try
+ {
+ writeLock();
- // The order of the operations below is critical!
- removeUpdate(event);
- UndoableEdit temp = content.remove(offset, length);
+ // The order of the operations below is critical!
+ removeUpdate(event);
+ UndoableEdit temp = content.remove(offset, length);
- postRemoveUpdate(event);
- fireRemoveUpdate(event);
+ postRemoveUpdate(event);
+ fireRemoveUpdate(event);
+ }
+ finally
+ {
+ writeUnlock();
+ }
}
- finally
- {
- writeUnlock();
- }
}
/**
@@ -1674,20 +1694,15 @@ public abstract class AbstractDocument implements Document, Serializable
/** The serialization UID (compatible with JDK1.5). */
private static final long serialVersionUID = -6037216547466333183L;
- /** The child elements of this BranchElement. */
- private Element[] children = new Element[0];
-
/**
- * The cached startOffset value. This is used in the case when a
- * BranchElement (temporarily) has no child elements.
+ * The child elements of this BranchElement.
*/
- private int startOffset;
+ private Element[] children;;
/**
- * The cached endOffset value. This is used in the case when a
- * BranchElement (temporarily) has no child elements.
+ * The number of children in the branch element.
*/
- private int endOffset;
+ private int numChildren;
/**
* Creates a new <code>BranchElement</code> with the specified
@@ -1700,8 +1715,8 @@ public abstract class AbstractDocument implements Document, Serializable
public BranchElement(Element parent, AttributeSet attributes)
{
super(parent, attributes);
- startOffset = -1;
- endOffset = -1;
+ children = new Element[1];
+ numChildren = 0;
}
/**
@@ -1716,8 +1731,8 @@ public abstract class AbstractDocument implements Document, Serializable
Vector tmp = new Vector();
- for (int index = 0; index < children.length; ++index)
- tmp.add(children[index]);
+ for (int index = 0; index < numChildren; ++index)
+ tmp.add(children[index]);
return tmp.elements();
}
@@ -1743,8 +1758,8 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public Element getElement(int index)
{
- if (index < 0 || index >= children.length)
- return null;
+ if (index < 0 || index >= numChildren)
+ return null;
return children[index];
}
@@ -1756,7 +1771,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getElementCount()
{
- return children.length;
+ return numChildren;
}
/**
@@ -1777,7 +1792,7 @@ public abstract class AbstractDocument implements Document, Serializable
// XXX: There is surely a better algorithm
// as beginning from first element each time.
- for (int index = 0; index < children.length - 1; ++index)
+ for (int index = 0; index < numChildren - 1; ++index)
{
Element elem = children[index];
@@ -1814,15 +1829,11 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getEndOffset()
{
- if (children.length == 0)
- {
- if (endOffset == -1)
- throw new NullPointerException("BranchElement has no children.");
- }
- else
- endOffset = children[children.length - 1].getEndOffset();
-
- return endOffset;
+ // This might accss one cached element or trigger an NPE for
+ // numChildren == 0. This is checked by a Mauve test.
+ Element child = numChildren > 0 ? children[numChildren - 1]
+ : children[0];
+ return child.getEndOffset();
}
/**
@@ -1848,15 +1859,13 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getStartOffset()
{
- if (children.length == 0)
- {
- if (startOffset == -1)
- throw new NullPointerException("BranchElement has no children.");
- }
- else
- startOffset = children[0].getStartOffset();
-
- return startOffset;
+ // Do not explicitly throw an NPE here. If the first element is null
+ // then the NPE gets thrown anyway. If it isn't, then it either
+ // holds a real value (for numChildren > 0) or a cached value
+ // (for numChildren == 0) as we don't fully remove elements in replace()
+ // when removing single elements.
+ // This is checked by a Mauve test.
+ return children[0].getStartOffset();
}
/**
@@ -1884,7 +1893,7 @@ public abstract class AbstractDocument implements Document, Serializable
{
// XXX: There is surely a better algorithm
// as beginning from first element each time.
- for (int index = 0; index < children.length; ++index)
+ for (int index = 0; index < numChildren; ++index)
{
Element elem = children[index];
@@ -1905,14 +1914,26 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public void replace(int offset, int length, Element[] elements)
{
- Element[] target = new Element[children.length - length
- + elements.length];
- System.arraycopy(children, 0, target, 0, offset);
- System.arraycopy(elements, 0, target, offset, elements.length);
- System.arraycopy(children, offset + length, target,
- offset + elements.length,
- children.length - offset - length);
- children = target;
+ int delta = elements.length - length;
+ int copyFrom = offset + length; // From where to copy.
+ int copyTo = copyFrom + delta; // Where to copy to.
+ int numMove = numChildren - copyFrom; // How many elements are moved.
+ if (numChildren + delta > children.length)
+ {
+ // Gotta grow the array.
+ int newSize = Math.max(2 * children.length, numChildren + delta);
+ Element[] target = new Element[newSize];
+ System.arraycopy(children, 0, target, 0, offset);
+ System.arraycopy(elements, 0, target, offset, elements.length);
+ System.arraycopy(children, copyFrom, target, copyTo, numMove);
+ children = target;
+ }
+ else
+ {
+ System.arraycopy(children, copyFrom, children, copyTo, numMove);
+ System.arraycopy(elements, 0, children, offset, elements.length);
+ }
+ numChildren += delta;
}
/**
@@ -2165,18 +2186,6 @@ public abstract class AbstractDocument implements Document, Serializable
private Position endPos;
/**
- * This gets possible added to the startOffset when a startOffset
- * outside the document range is requested.
- */
- private int startDelta;
-
- /**
- * This gets possible added to the endOffset when a endOffset
- * outside the document range is requested.
- */
- private int endDelta;
-
- /**
* Creates a new <code>LeafElement</code>.
*
* @param parent the parent of this <code>LeafElement</code>
@@ -2188,28 +2197,21 @@ public abstract class AbstractDocument implements Document, Serializable
int end)
{
super(parent, attributes);
- int len = content.length();
- startDelta = 0;
- if (start > len)
- startDelta = start - len;
- endDelta = 0;
- if (end > len)
- endDelta = end - len;
try
- {
- startPos = createPosition(start - startDelta);
- endPos = createPosition(end - endDelta);
- }
- catch (BadLocationException ex)
- {
- AssertionError as;
- as = new AssertionError("BadLocationException thrown "
- + "here. start=" + start
- + ", end=" + end
- + ", length=" + getLength());
- as.initCause(ex);
- throw as;
- }
+ {
+ startPos = createPosition(start);
+ endPos = createPosition(end);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError as;
+ as = new AssertionError("BadLocationException thrown "
+ + "here. start=" + start
+ + ", end=" + end
+ + ", length=" + getLength());
+ as.initCause(ex);
+ throw as;
+ }
}
/**
@@ -2281,7 +2283,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getEndOffset()
{
- return endPos.getOffset() + endDelta;
+ return endPos.getOffset();
}
/**
@@ -2307,7 +2309,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getStartOffset()
{
- return startPos.getOffset() + startDelta;
+ return startPos.getOffset();
}
/**
diff --git a/libjava/classpath/javax/swing/text/BoxView.java b/libjava/classpath/javax/swing/text/BoxView.java
index a184a813152..27e3c0f9a1b 100644
--- a/libjava/classpath/javax/swing/text/BoxView.java
+++ b/libjava/classpath/javax/swing/text/BoxView.java
@@ -67,6 +67,11 @@ public class BoxView
private boolean[] layoutValid = new boolean[2];
/**
+ * Indicates if the requirements for an axis are valid.
+ */
+ private boolean[] requirementsValid = new boolean[2];
+
+ /**
* The spans along the X_AXIS and Y_AXIS.
*/
private int[][] spans = new int[2][];
@@ -265,8 +270,10 @@ public class BoxView
super.replace(offset, length, views);
// Invalidate layout information.
- layoutChanged(X_AXIS);
- layoutChanged(Y_AXIS);
+ layoutValid[X_AXIS] = false;
+ requirementsValid[X_AXIS] = false;
+ layoutValid[Y_AXIS] = false;
+ requirementsValid[Y_AXIS] = false;
}
/**
@@ -278,19 +285,26 @@ public class BoxView
*/
public void paint(Graphics g, Shape a)
{
- Rectangle inside = getInsideAllocation(a);
- // TODO: Used for debugging.
- //g.drawRect(inside.x, inside.y, inside.width, inside.height);
+ Rectangle alloc;
+ if (a instanceof Rectangle)
+ alloc = (Rectangle) a;
+ else
+ alloc = a.getBounds();
+
+ int x = alloc.x + getLeftInset();
+ int y = alloc.y + getTopInset();
- Rectangle copy = new Rectangle(inside);
+ Rectangle clip = g.getClipBounds();
+ Rectangle tmp = new Rectangle();
int count = getViewCount();
for (int i = 0; i < count; ++i)
{
- copy.setBounds(inside);
- childAllocation(i, copy);
- if (!copy.isEmpty()
- && g.hitClip(copy.x, copy.y, copy.width, copy.height))
- paintChild(g, copy, i);
+ tmp.x = x + getOffset(X_AXIS, i);
+ tmp.y = y + getOffset(Y_AXIS, i);
+ tmp.width = getSpan(X_AXIS, i);
+ tmp.height = getSpan(Y_AXIS, i);
+ if (tmp.intersects(clip))
+ paintChild(g, tmp, i);
}
}
@@ -305,7 +319,13 @@ public class BoxView
public float getPreferredSpan(int axis)
{
updateRequirements(axis);
- return requirements[axis].preferred;
+ // Add margin.
+ float margin;
+ if (axis == X_AXIS)
+ margin = getLeftInset() + getRightInset();
+ else
+ margin = getTopInset() + getBottomInset();
+ return requirements[axis].preferred + margin;
}
/**
@@ -319,12 +339,14 @@ public class BoxView
*/
public float getMaximumSpan(int axis)
{
- float max;
- if (axis == myAxis)
- max = getPreferredSpan(axis);
+ updateRequirements(axis);
+ // Add margin.
+ float margin;
+ if (axis == X_AXIS)
+ margin = getLeftInset() + getRightInset();
else
- max = Integer.MAX_VALUE;
- return max;
+ margin = getTopInset() + getBottomInset();
+ return requirements[axis].maximum + margin;
}
/**
@@ -341,7 +363,13 @@ public class BoxView
public float getMinimumSpan(int axis)
{
updateRequirements(axis);
- return requirements[axis].minimum;
+ // Add margin.
+ float margin;
+ if (axis == X_AXIS)
+ margin = getLeftInset() + getRightInset();
+ else
+ margin = getTopInset() + getBottomInset();
+ return requirements[axis].minimum + margin;
}
/**
@@ -435,34 +463,29 @@ public class BoxView
protected SizeRequirements calculateMajorAxisRequirements(int axis,
SizeRequirements sr)
{
- updateChildRequirements(axis);
+ SizeRequirements res = sr;
+ if (res == null)
+ res = new SizeRequirements();
- SizeRequirements result = sr;
- if (result == null)
- result = new SizeRequirements();
+ float min = 0;
+ float pref = 0;
+ float max = 0;
- long minimum = 0;
- long preferred = 0;
- long maximum = 0;
- for (int i = 0; i < children.length; i++)
+ int n = getViewCount();
+ for (int i = 0; i < n; i++)
{
- minimum += childReqs[axis][i].minimum;
- preferred += childReqs[axis][i].preferred;
- maximum += childReqs[axis][i].maximum;
+ View child = getView(i);
+ min += child.getMinimumSpan(axis);
+ pref = child.getPreferredSpan(axis);
+ max = child.getMaximumSpan(axis);
}
- // Overflow check.
- if (minimum > Integer.MAX_VALUE)
- minimum = Integer.MAX_VALUE;
- if (preferred > Integer.MAX_VALUE)
- preferred = Integer.MAX_VALUE;
- if (maximum > Integer.MAX_VALUE)
- maximum = Integer.MAX_VALUE;
-
- result.minimum = (int) minimum;
- result.preferred = (int) preferred;
- result.maximum = (int) maximum;
- result.alignment = 0.5F;
- return result;
+
+ res.minimum = (int) min;
+ res.preferred = (int) pref;
+ res.maximum = (int) max;
+ res.alignment = 0.5F;
+
+ return res;
}
/**
@@ -480,44 +503,24 @@ public class BoxView
protected SizeRequirements calculateMinorAxisRequirements(int axis,
SizeRequirements sr)
{
- updateChildRequirements(axis);
-
SizeRequirements res = sr;
if (res == null)
res = new SizeRequirements();
- float minLeft = 0;
- float minRight = 0;
- float prefLeft = 0;
- float prefRight = 0;
- float maxLeft = 0;
- float maxRight = 0;
- for (int i = 0; i < childReqs[axis].length; i++)
+ res.minimum = 0;
+ res.preferred = 0;
+ res.maximum = 0;
+ res.alignment = 0.5F;
+ int n = getViewCount();
+ for (int i = 0; i < n; i++)
{
- float myMinLeft = childReqs[axis][i].minimum * childReqs[axis][i].alignment;
- float myMinRight = childReqs[axis][i].minimum - myMinLeft;
- minLeft = Math.max(myMinLeft, minLeft);
- minRight = Math.max(myMinRight, minRight);
- float myPrefLeft = childReqs[axis][i].preferred * childReqs[axis][i].alignment;
- float myPrefRight = childReqs[axis][i].preferred - myPrefLeft;
- prefLeft = Math.max(myPrefLeft, prefLeft);
- prefRight = Math.max(myPrefRight, prefRight);
- float myMaxLeft = childReqs[axis][i].maximum * childReqs[axis][i].alignment;
- float myMaxRight = childReqs[axis][i].maximum - myMaxLeft;
- maxLeft = Math.max(myMaxLeft, maxLeft);
- maxRight = Math.max(myMaxRight, maxRight);
+ View child = getView(i);
+ res.minimum = Math.max((int) child.getMinimumSpan(axis), res.minimum);
+ res.preferred = Math.max((int) child.getPreferredSpan(axis),
+ res.preferred);
+ res.maximum = Math.max((int) child.getMaximumSpan(axis), res.maximum);
}
- int minSize = (int) (minLeft + minRight);
- int prefSize = (int) (prefLeft + prefRight);
- int maxSize = (int) (maxLeft + maxRight);
- float align = prefLeft / (prefRight + prefLeft);
- if (Float.isNaN(align))
- align = 0;
- res.alignment = align;
- res.maximum = maxSize;
- res.preferred = prefSize;
- res.minimum = minSize;
return res;
}
@@ -697,15 +700,62 @@ public class BoxView
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
int[] spans)
{
- updateChildRequirements(axis);
- updateRequirements(axis);
+ // Set the spans to the preferred sizes. Determine the space
+ // that we have to adjust the sizes afterwards.
+ long sumPref = 0;
+ int n = getViewCount();
+ for (int i = 0; i < n; i++)
+ {
+ View child = getView(i);
+ spans[i] = (int) child.getPreferredSpan(axis);
+ sumPref = spans[i];
+ }
- // Calculate the spans and offsets using the SizeRequirements uility
- // methods.
- SizeRequirements.calculateTiledPositions(targetSpan, requirements[axis],
- childReqs[axis],
- offsets, spans);
+ // Try to adjust the spans so that we fill the targetSpan.
+ long diff = targetSpan - sumPref;
+ float factor = 0.0F;
+ int[] diffs = null;
+ if (diff != 0)
+ {
+ long total = 0;
+ diffs = new int[n];
+ for (int i = 0; i < n; i++)
+ {
+ View child = getView(i);
+ int span;
+ if (diff < 0)
+ {
+ span = (int) child.getMinimumSpan(axis);
+ diffs[i] = spans[i] - span;
+ }
+ else
+ {
+ span = (int) child.getMaximumSpan(axis);
+ diffs[i] = span - spans[i];
+ }
+ total += span;
+ }
+ float maxAdjust = Math.abs(total - sumPref);
+ factor = diff / maxAdjust;
+ factor = Math.min(factor, 1.0F);
+ factor = Math.max(factor, -1.0F);
+ }
+
+ // Actually perform adjustments.
+ int totalOffs = 0;
+ for (int i = 0; i < n; i++)
+ {
+ offsets[i] = totalOffs;
+ if (diff != 0)
+ {
+ float adjust = factor * diffs[i];
+ spans[i] += Math.round(adjust);
+ }
+ // Avoid overflow here.
+ totalOffs = (int) Math.min((long) totalOffs + (long) spans[i],
+ Integer.MAX_VALUE);
+ }
}
/**
@@ -720,14 +770,26 @@ public class BoxView
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets,
int[] spans)
{
- updateChildRequirements(axis);
- updateRequirements(axis);
-
- // Calculate the spans and offsets using the SizeRequirements uility
- // methods.
- SizeRequirements.calculateAlignedPositions(targetSpan, requirements[axis],
- childReqs[axis], offsets,
- spans);
+ int count = getViewCount();
+ for (int i = 0; i < count; i++)
+ {
+ View child = getView(i);
+ int max = (int) child.getMaximumSpan(axis);
+ if (max < targetSpan)
+ {System.err.println("align: " + child);
+ // Align child when it can't be made as wide as the target span.
+ float align = child.getAlignment(axis);
+ offsets[i] = (int) ((targetSpan - max) * align);
+ spans[i] = max;
+ }
+ else
+ {
+ // Expand child to target width if possible.
+ int min = (int) child.getMinimumSpan(axis);
+ offsets[i] = 0;
+ spans[i] = Math.max(min, targetSpan);
+ }
+ }
}
/**
@@ -822,15 +884,8 @@ public class BoxView
*/
public float getAlignment(int axis)
{
- float align;
- if (axis == myAxis)
- align = 0.5F;
- else
- {
- updateRequirements(axis);
- align = requirements[axis].alignment;
- }
- return align;
+ updateRequirements(axis);
+ return requirements[axis].alignment;
}
/**
@@ -843,9 +898,15 @@ public class BoxView
public void preferenceChanged(View child, boolean width, boolean height)
{
if (width)
- layoutValid[X_AXIS] = false;
+ {
+ layoutValid[X_AXIS] = false;
+ requirementsValid[X_AXIS] = false;
+ }
if (height)
- layoutValid[Y_AXIS] = false;
+ {
+ layoutValid[Y_AXIS] = false;
+ requirementsValid[Y_AXIS] = false;
+ }
super.preferenceChanged(child, width, height);
}
@@ -862,7 +923,7 @@ public class BoxView
if (! isAllocationValid())
{
Rectangle bounds = a.getBounds();
- layout(bounds.width, bounds.height);
+ setSize(bounds.width, bounds.height);
}
return super.modelToView(pos, a, bias);
}
@@ -963,7 +1024,7 @@ public class BoxView
*/
private void updateRequirements(int axis)
{
- if (! layoutValid[axis])
+ if (! requirementsValid[axis])
{
if (axis == myAxis)
requirements[axis] = calculateMajorAxisRequirements(axis,
@@ -971,6 +1032,7 @@ public class BoxView
else
requirements[axis] = calculateMinorAxisRequirements(axis,
requirements[axis]);
+ requirementsValid[axis] = true;
}
}
}
diff --git a/libjava/classpath/javax/swing/text/CompositeView.java b/libjava/classpath/javax/swing/text/CompositeView.java
index 17f13dbedd6..6f487b8981e 100644
--- a/libjava/classpath/javax/swing/text/CompositeView.java
+++ b/libjava/classpath/javax/swing/text/CompositeView.java
@@ -217,25 +217,43 @@ public abstract class CompositeView
public Shape modelToView(int pos, Shape a, Position.Bias bias)
throws BadLocationException
{
- int childIndex = getViewIndex(pos, bias);
- if (childIndex == -1)
- throw new BadLocationException("Position " + pos + " is not represented by view.", pos);
-
- Shape ret = null;
-
- View child = getView(childIndex);
- Shape childAlloc = getChildAllocation(childIndex, a);
-
- if (childAlloc == null)
- ret = createDefaultLocation(a, bias);
-
- Shape result = child.modelToView(pos, childAlloc, bias);
-
- if (result != null)
- ret = result;
- else
- ret = createDefaultLocation(a, bias);
+ boolean backward = bias == Position.Bias.Backward;
+ int testpos = backward ? Math.max(0, pos - 1) : pos;
+ Shape ret = null;
+ if (! backward || testpos >= getStartOffset())
+ {
+ int childIndex = getViewIndexAtPosition(testpos);
+ if (childIndex != -1 && childIndex < getViewCount())
+ {
+ View child = getView(childIndex);
+ if (child != null && testpos >= child.getStartOffset()
+ && testpos < child.getEndOffset())
+ {
+ Shape childAlloc = getChildAllocation(childIndex, a);
+ if (childAlloc != null)
+ {
+ ret = child.modelToView(pos, childAlloc, bias);
+ // Handle corner case.
+ if (ret == null && child.getEndOffset() == pos)
+ {
+ childIndex++;
+ if (childIndex < getViewCount())
+ {
+ child = getView(childIndex);
+ childAlloc = getChildAllocation(childIndex, a);
+ ret = child.modelToView(pos, childAlloc, bias);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ throw new BadLocationException("Position " + pos
+ + " is not represented by view.", pos);
+ }
+ }
return ret;
}
@@ -378,7 +396,10 @@ public abstract class CompositeView
{
if (b == Position.Bias.Backward && pos != 0)
pos -= 1;
- return getViewIndexAtPosition(pos);
+ int i = -1;
+ if (pos >= getStartOffset() && pos < getEndOffset())
+ i = getViewIndexAtPosition(pos);
+ return i;
}
/**
@@ -446,9 +467,13 @@ public abstract class CompositeView
*/
protected View getViewAtPosition(int pos, Rectangle a)
{
+ View view = null;
int i = getViewIndexAtPosition(pos);
- View view = children[i];
- childAllocation(i, a);
+ if (i >= 0 && i < getViewCount() && a != null)
+ {
+ view = getView(i);
+ childAllocation(i, a);
+ }
return view;
}
@@ -464,17 +489,10 @@ public abstract class CompositeView
*/
protected int getViewIndexAtPosition(int pos)
{
- int index = -1;
- for (int i = 0; i < children.length; i++)
- {
- if (children[i].getStartOffset() <= pos
- && children[i].getEndOffset() > pos)
- {
- index = i;
- break;
- }
- }
- return index;
+ // We have a 1:1 mapping of elements to views here, so we forward
+ // this to the element.
+ Element el = getElement();
+ return el.getElementIndex(pos);
}
/**
diff --git a/libjava/classpath/javax/swing/text/DefaultCaret.java b/libjava/classpath/javax/swing/text/DefaultCaret.java
index 4ad204c00c9..84f47f120de 100644
--- a/libjava/classpath/javax/swing/text/DefaultCaret.java
+++ b/libjava/classpath/javax/swing/text/DefaultCaret.java
@@ -221,9 +221,12 @@ public class DefaultCaret extends Rectangle
if (name.equals("document"))
{
Document oldDoc = (Document) e.getOldValue();
- oldDoc.removeDocumentListener(documentListener);
+ if (oldDoc != null)
+ oldDoc.removeDocumentListener(documentListener);
+
Document newDoc = (Document) e.getNewValue();
- newDoc.addDocumentListener(documentListener);
+ if (newDoc != null)
+ newDoc.addDocumentListener(documentListener);
}
else if (name.equals("editable"))
{
@@ -549,7 +552,6 @@ public class DefaultCaret extends Rectangle
*/
public void mousePressed(MouseEvent event)
{
- int button = event.getButton();
// The implementation assumes that consuming the event makes the AWT event
// mechanism forget about this event instance and not transfer focus.
@@ -562,23 +564,37 @@ public class DefaultCaret extends Rectangle
// - a middle-click positions the caret and pastes the clipboard
// contents.
// - a middle-click when shift is held down is ignored
-
- if (button == MouseEvent.BUTTON1)
- if (event.isShiftDown())
- moveCaret(event);
- else
- positionCaret(event);
- else if(button == MouseEvent.BUTTON2)
- if (event.isShiftDown())
- event.consume();
+
+ if (SwingUtilities.isLeftMouseButton(event))
+ {
+ // Handle the caret.
+ if (event.isShiftDown() && getDot() != -1)
+ {
+ moveCaret(event);
+ }
else
{
positionCaret(event);
-
+ }
+
+ // Handle the focus.
+ if (textComponent != null && textComponent.isEnabled()
+ && textComponent.isRequestFocusEnabled())
+ {
+ textComponent.requestFocus();
+ }
+
+ // TODO: Handle double click for selecting words.
+ }
+ else if(event.getButton() == MouseEvent.BUTTON2)
+ {
+ // Special handling for X11-style pasting.
+ if (! event.isShiftDown())
+ {
+ positionCaret(event);
textComponent.paste();
}
- else
- event.consume();
+ }
}
/**
@@ -708,7 +724,11 @@ public class DefaultCaret extends Rectangle
propertyChangeListener = new PropertyChangeHandler();
textComponent.addPropertyChangeListener(propertyChangeListener);
documentListener = new DocumentHandler();
- textComponent.getDocument().addDocumentListener(documentListener);
+
+ Document doc = textComponent.getDocument();
+ if (doc != null)
+ doc.addDocumentListener(documentListener);
+
active = textComponent.isEditable() && textComponent.isEnabled();
repaint();
@@ -891,10 +911,10 @@ public class DefaultCaret extends Rectangle
}
catch (BadLocationException e)
{
- AssertionError ae;
- ae = new AssertionError("Unexpected bad caret location: " + dot);
- ae.initCause(e);
- throw ae;
+ // Let's ignore that. This shouldn't really occur. But if it
+ // does (it seems that this happens when the model is mutating),
+ // it causes no real damage. Uncomment this for debugging.
+ // e.printStackTrace();
}
if (rect == null)
@@ -1128,10 +1148,10 @@ public class DefaultCaret extends Rectangle
}
catch (BadLocationException e)
{
- AssertionError ae;
- ae = new AssertionError("Unexpected bad caret location: " + dot);
- ae.initCause(e);
- throw ae;
+ // Let's ignore that. This shouldn't really occur. But if it
+ // does (it seems that this happens when the model is mutating),
+ // it causes no real damage. Uncomment this for debugging.
+ // e.printStackTrace();
}
if (area != null)
damage(area);
@@ -1140,6 +1160,24 @@ public class DefaultCaret extends Rectangle
}
/**
+ * Returns <code>true</code> if this <code>Caret</code> is blinking,
+ * and <code>false</code> if not. The returned value is independent of
+ * the visiblity of this <code>Caret</code> as returned by {@link #isVisible()}.
+ *
+ * @return <code>true</code> if this <code>Caret</code> is blinking,
+ * and <code>false</code> if not.
+ * @see #isVisible()
+ * @since 1.5
+ */
+ public boolean isActive()
+ {
+ if (blinkTimer != null)
+ return blinkTimer.isRunning();
+
+ return false;
+ }
+
+ /**
* Returns <code>true</code> if this <code>Caret</code> is currently visible,
* and <code>false</code> if it is not.
*
diff --git a/libjava/classpath/javax/swing/text/EmptyAttributeSet.java b/libjava/classpath/javax/swing/text/EmptyAttributeSet.java
new file mode 100644
index 00000000000..98fb8828c89
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/EmptyAttributeSet.java
@@ -0,0 +1,153 @@
+/* EmptyAttributeSet.java -- An empty attribute set
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+ * An immutable, empty attribute set.
+ *
+ * @see SimpleAttributeSet#EMPTY
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+final class EmptyAttributeSet
+ implements AttributeSet
+{
+
+ /**
+ * Always return false as this AttributeSet doesn't contain any attributes.
+ */
+ public boolean containsAttribute(Object name, Object value)
+ {
+ return false;
+ }
+
+ /**
+ * Return true only if the attributes argument also contains no attributes.
+ */
+ public boolean containsAttributes(AttributeSet attributes)
+ {
+ return attributes.getAttributeCount() == 0;
+ }
+
+ /**
+ * Return this, as this is immutable.
+ */
+ public AttributeSet copyAttributes()
+ {
+ return this;
+ }
+
+ /**
+ * Always return null as this AttributeSet doesn't contain any attributes.
+ */
+ public Object getAttribute(Object key)
+ {
+ return null;
+ }
+
+ /**
+ * Always return 0.
+ */
+ public int getAttributeCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns an empty Enumeration.
+ */
+ public Enumeration getAttributeNames()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ throw new NoSuchElementException("No more elements");
+ }
+
+ };
+ }
+
+ /**
+ * Always return null as this has no resolve parent.
+ */
+ public AttributeSet getResolveParent()
+ {
+ return null;
+ }
+
+ /**
+ * Always return false as this AttributeSet doesn't contain any attributes.
+ */
+ public boolean isDefined(Object attrName)
+ {
+ return false;
+ }
+
+ /**
+ * Other attribute sets are equal if they are empty too.
+ */
+ public boolean isEqual(AttributeSet attr)
+ {
+ return attr.getAttributeCount() == 0;
+ }
+
+ /**
+ * Other objects are equal if it's the same instance as this, or if
+ * it's another attribute set without attributes.
+ */
+ public boolean equals(Object o)
+ {
+ boolean eq = o == this;
+ if (! eq)
+ {
+ eq = (o instanceof AttributeSet)
+ && ((AttributeSet) o).getAttributeCount() == 0;
+ }
+ return eq;
+ }
+}
diff --git a/libjava/classpath/javax/swing/text/FlowView.java b/libjava/classpath/javax/swing/text/FlowView.java
index 8ca55d8347a..3de95ed7f8d 100644
--- a/libjava/classpath/javax/swing/text/FlowView.java
+++ b/libjava/classpath/javax/swing/text/FlowView.java
@@ -159,20 +159,18 @@ public abstract class FlowView extends BoxView
}
/**
- * Lays out one row of the flow view. This is called by {@link #layout}
- * to fill one row with child views until the available span is exhausted.
- *
- * The default implementation fills the row by calling
- * {@link #createView(FlowView, int, int, int)} until the available space
- * is exhausted, a forced break is encountered or there are no more views
- * in the logical view. If the available space is exhausted,
- * {@link #adjustRow(FlowView, int, int, int)} is called to fit the row
- * into the available span.
- *
+ * Lays out one row of the flow view. This is called by {@link #layout} to
+ * fill one row with child views until the available span is exhausted. The
+ * default implementation fills the row by calling
+ * {@link #createView(FlowView, int, int, int)} until the available space is
+ * exhausted, a forced break is encountered or there are no more views in
+ * the logical view. If the available space is exhausted,
+ * {@link #adjustRow(FlowView, int, int, int)} is called to fit the row into
+ * the available span.
+ *
* @param fv the flow view for which we perform the layout
* @param rowIndex the index of the row
* @param pos the model position for the beginning of the row
- *
* @return the start position of the next row
*/
protected int layoutRow(FlowView fv, int rowIndex, int pos)
@@ -188,34 +186,39 @@ public abstract class FlowView extends BoxView
if (span == 0)
span = Integer.MAX_VALUE;
- while (span > 0)
+ Row: while (span > 0)
{
- if (logicalView.getViewIndex(offset, Position.Bias.Forward) == -1)
+ if (logicalView.getViewIndex(offset, Position.Bias.Forward) == - 1)
break;
View view = createView(fv, offset, span, rowIndex);
if (view == null)
break;
+
int viewSpan = (int) view.getPreferredSpan(axis);
- row.append(view);
int breakWeight = view.getBreakWeight(axis, x, span);
- if (breakWeight >= View.ForcedBreakWeight)
- break;
+
+ row.append(view);
+ offset += (view.getEndOffset() - view.getStartOffset());
x += viewSpan;
span -= viewSpan;
- offset += (view.getEndOffset() - view.getStartOffset());
- }
- if (span < 0)
- {
- int flowStart = fv.getFlowStart(axis);
- int flowSpan = fv.getFlowSpan(axis);
- adjustRow(fv, rowIndex, flowSpan, flowStart);
- int rowViewCount = row.getViewCount();
- if (rowViewCount > 0)
- offset = row.getView(rowViewCount - 1).getEndOffset();
- else
- offset = -1;
+
+ // Break if the line if the view does not fit in this row or the
+ // line just must be broken.
+ if (span < 0 || breakWeight >= View.ForcedBreakWeight)
+ {
+ int flowStart = fv.getFlowStart(axis);
+ int flowSpan = fv.getFlowSpan(axis);
+ adjustRow(fv, rowIndex, flowSpan, flowStart);
+ int rowViewCount = row.getViewCount();
+ if (rowViewCount > 0)
+ offset = row.getView(rowViewCount - 1).getEndOffset();
+ else
+ offset = - 1;
+ break Row;
+ }
}
- return offset != pos ? offset : -1;
+
+ return offset != pos ? offset : - 1;
}
/**
@@ -521,6 +524,7 @@ public abstract class FlowView extends BoxView
*/
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
{
+ layoutPool.removeUpdate(changes, a, vf);
strategy.removeUpdate(this, changes, getInsideAllocation(a));
layoutDirty = true;
}
@@ -536,6 +540,7 @@ public abstract class FlowView extends BoxView
*/
public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
{
+ layoutPool.changedUpdate(changes, a, vf);
strategy.changedUpdate(this, changes, getInsideAllocation(a));
layoutDirty = true;
}
@@ -594,12 +599,14 @@ public abstract class FlowView extends BoxView
protected SizeRequirements calculateMinorAxisRequirements(int axis,
SizeRequirements r)
{
- // We need to call super here so that the alignment is properly
- // calculated.
- SizeRequirements res = super.calculateMinorAxisRequirements(axis, r);
+ SizeRequirements res = r;
+ if (res == null)
+ res = new SizeRequirements();
res.minimum = (int) layoutPool.getMinimumSpan(axis);
- res.preferred = (int) layoutPool.getPreferredSpan(axis);
- res.maximum = (int) layoutPool.getMaximumSpan(axis);
+ res.preferred = Math.max(res.minimum,
+ (int) layoutPool.getMinimumSpan(axis));
+ res.maximum = Integer.MAX_VALUE;
+ res.alignment = 0.5F;
return res;
}
}
diff --git a/libjava/classpath/javax/swing/text/GapContent.java b/libjava/classpath/javax/swing/text/GapContent.java
index 4f06003b458..760e396a223 100644
--- a/libjava/classpath/javax/swing/text/GapContent.java
+++ b/libjava/classpath/javax/swing/text/GapContent.java
@@ -39,7 +39,13 @@ exception statement from your version. */
package javax.swing.text;
import java.io.Serializable;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.Vector;
import java.util.WeakHashMap;
@@ -73,30 +79,39 @@ public class GapContent
* The index to the positionMarks array entry, which in turn holds the
* mark into the buffer array.
*/
- int index;
+ Mark mark;
/**
* Creates a new GapContentPosition object.
*
- * @param mark the mark of this Position
+ * @param offset the offset of this Position
*/
- GapContentPosition(int mark)
+ GapContentPosition(int offset)
{
// Try to find the mark in the positionMarks array, and store the index
// to it.
synchronized (GapContent.this)
{
- int i = binarySearch(positionMarks, mark, numMarks);
+ // Try to make space.
+ garbageCollect();
+ Mark m = new Mark(offset);
+ int i = search(marks, m);
if (i >= 0) // mark found
{
- index = i;
+ m = (Mark) marks.get(i);
}
else
{
- index = -i - 1;
- insertMark(index, mark);
+ i = -i - 1;
+ marks.add(i, m);
}
+ m.refCount++;
+ mark = m;
}
+
+ // Register this position in the death queue, so we can cleanup the marks
+ // when this position object gets GC'ed.
+ new WeakReference(this, queueOfDeath);
}
/**
@@ -106,19 +121,77 @@ public class GapContent
*/
public int getOffset()
{
- synchronized (GapContent.this)
- {
- // Fetch the actual mark.
- int mark = positionMarks[index];
- // Check precondition.
- assert mark <= gapStart || mark >= gapEnd : "mark: " + mark
- + ", gapStart: " + gapStart
- + ", gapEnd: " + gapEnd;
- int res = mark;
- if (mark > gapStart)
- res -= (gapEnd - gapStart);
- return res;
- }
+ return mark.getOffset();
+ }
+ }
+
+ /**
+ * Holds a mark into the buffer that is used by GapContentPosition to find
+ * the actual offset of the position. This is pulled out of the
+ * GapContentPosition object so that the mark and position can be handled
+ * independently, and most important, so that the GapContentPosition can
+ * be garbage collected while we still hold a reference to the Mark object.
+ */
+ private class Mark
+ implements Comparable
+ {
+ /**
+ * The actual mark into the buffer.
+ */
+ int mark;
+
+ /**
+ * The number of GapContentPosition object that reference this mark. If
+ * it reaches zero, it get's deleted by {@link GapContent#garbageCollect()}.
+ */
+ int refCount;
+
+ /**
+ * Creates a new Mark object for the specified offset.
+ *
+ * @param offset the offset
+ */
+ Mark(int offset)
+ {
+ mark = offset;
+ if (mark >= gapStart && mark != 0)
+ mark += (gapEnd - gapStart);
+ }
+
+ /**
+ * Returns the offset of the mark.
+ *
+ * @return the offset of the mark
+ */
+ int getOffset()
+ {
+ assert mark == 0 || mark < gapStart || mark >= gapEnd :
+ "Invalid mark: " + mark + ", gapStart: " + gapStart
+ + ", gapEnd: " + gapEnd;
+
+ int res = mark;
+ if (mark >= gapEnd)
+ res -= (gapEnd - gapStart);
+ return res;
+ }
+
+ /**
+ * Implementation of Comparable.
+ */
+ public int compareTo(Object o)
+ {
+ Mark other = (Mark) o;
+ return mark - other.mark;
+ }
+ /**
+ * Adjustment for equals().
+ */
+ public boolean equals(Object o)
+ {
+ if (o == null || !(o instanceof Mark))
+ return false;
+ else
+ return ((Mark) o).mark == mark;
}
}
@@ -230,19 +303,21 @@ public class GapContent
/**
* Holds the marks for positions. These marks are referenced by the
* GapContentPosition instances by an index into this array.
+ *
+ * This is package private to avoid accessor synthetic methods.
*/
- int[] positionMarks;
+ ArrayList marks;
- /**
- * The number of elements in the positionMarks array. The positionMarks array
- * might be bigger than the actual number of elements.
- */
- int numMarks;
+ WeakHashMap positions;
/**
- * (Weakly) Stores the GapContentPosition instances.
+ * Queues all references to GapContentPositions that are about to be
+ * GC'ed. This is used to remove the corresponding marks from the
+ * positionMarks array if the number of references to that mark reaches zero.
+ *
+ * This is package private to avoid accessor synthetic methods.
*/
- WeakHashMap positions;
+ ReferenceQueue queueOfDeath;
/**
* Creates a new GapContent object.
@@ -265,8 +340,8 @@ public class GapContent
gapEnd = size;
buffer[0] = '\n';
positions = new WeakHashMap();
- positionMarks = new int[10];
- numMarks = 0;
+ marks = new ArrayList();
+ queueOfDeath = new ReferenceQueue();
}
/**
@@ -417,6 +492,8 @@ public class GapContent
if ((where + len) > length)
throw new BadLocationException("len plus where cannot be greater"
+ " than the content length", len + where);
+ if (len < 0)
+ throw new BadLocationException("negative length not allowed: ", len);
// check if requested segment is contiguous
if ((where < gapStart) && ((gapStart - where) < len))
@@ -455,6 +532,11 @@ public class GapContent
*/
public Position createPosition(final int offset) throws BadLocationException
{
+ // Implementation note: We used to perform explicit check on the offset
+ // here. However, this makes some Mauve and Intel/Harmony tests fail
+ // and luckily enough the GapContent can very well deal with offsets
+ // outside the buffer bounds. So I removed that check.
+
// We try to find a GapContentPosition at the specified offset and return
// that. Otherwise we must create a new one.
GapContentPosition pos = null;
@@ -472,10 +554,7 @@ public class GapContent
// If none was found, then create and return a new one.
if (pos == null)
{
- int mark = offset;
- if (mark >= gapStart)
- mark += (gapEnd - gapStart);
- pos = new GapContentPosition(mark);
+ pos = new GapContentPosition(offset);
positions.put(pos, null);
}
@@ -497,7 +576,7 @@ public class GapContent
int delta = newSize - gapEnd + gapStart;
// Update the marks after the gapEnd.
- adjustPositionsInRange(gapEnd, buffer.length - gapEnd, delta);
+ adjustPositionsInRange(gapEnd, -1, delta);
// Copy the data around.
char[] newBuf = (char[]) allocateArray(length() + newSize);
@@ -523,7 +602,7 @@ public class GapContent
{
// Update the positions between newGapStart and (old) gapStart. The marks
// must be shifted by (gapEnd - gapStart).
- adjustPositionsInRange(newGapStart, gapStart - newGapStart, gapEnd - gapStart);
+ adjustPositionsInRange(newGapStart, gapStart, gapEnd - gapStart);
System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart
- newGapStart);
gapStart = newGapStart;
@@ -533,14 +612,13 @@ public class GapContent
{
// Update the positions between newGapEnd and (old) gapEnd. The marks
// must be shifted by (gapEnd - gapStart).
- adjustPositionsInRange(gapEnd, newGapEnd - gapEnd, -(gapEnd - gapStart));
+ adjustPositionsInRange(gapEnd, newGapEnd, -(gapEnd - gapStart));
System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart
- gapStart);
gapStart = newGapStart;
gapEnd = newGapEnd;
}
- if (gapStart == 0)
- resetMarksAtZero();
+ resetMarksAtZero();
}
/**
@@ -560,6 +638,7 @@ public class GapContent
+ "old gap start.";
setPositionsInRange(newGapStart, gapStart, false);
gapStart = newGapStart;
+ resetMarksAtZero();
}
/**
@@ -579,6 +658,7 @@ public class GapContent
+ "old gap end.";
setPositionsInRange(gapEnd, newGapEnd, false);
gapEnd = newGapEnd;
+ resetMarksAtZero();
}
/**
@@ -617,10 +697,6 @@ public class GapContent
if (addItems != null)
{
System.arraycopy(addItems, 0, buffer, gapStart, addSize);
-
-
- resetMarksAtZero();
-
gapStart += addSize;
}
}
@@ -689,102 +765,61 @@ public class GapContent
*/
private void setPositionsInRange(int start, int end, boolean toStart)
{
- // We slump together all the GapContentPositions to point to
- // one mark. So this is implemented as follows:
- // 1. Remove all the marks in the specified range.
- // 2. Insert one new mark at the correct location.
- // 3. Adjust all affected GapContentPosition instances to point to
- // this new mark.
-
synchronized (this)
{
- int startIndex = binarySearch(positionMarks, start, numMarks);
+ // Find the start and end indices in the positionMarks array.
+ Mark m = new Mark(0); // For comparison / search only.
+ m.mark = start;
+ int startIndex = search(marks, m);
if (startIndex < 0) // Translate to insertion index, if not found.
startIndex = - startIndex - 1;
- int endIndex = binarySearch(positionMarks, end, numMarks);
+ m.mark = end;
+ int endIndex = search(marks, m);
if (endIndex < 0) // Translate to insertion index - 1, if not found.
endIndex = - endIndex - 2;
- // Update the marks.
- // We have inclusive interval bounds, but let one element over for
- // filling in the new value.
- int removed = endIndex - startIndex;
- if (removed <= 0)
- return;
- System.arraycopy(positionMarks, endIndex + 1, positionMarks,
- startIndex + 1, positionMarks.length - endIndex - 1);
- numMarks -= removed;
- if (toStart)
- {
- positionMarks[startIndex] = start;
- }
- else
- {
- positionMarks[startIndex] = end;
- }
+ // Actually adjust the marks.
+ for (int i = startIndex; i <= endIndex; i++)
+ ((Mark) marks.get(i)).mark = toStart ? start : end;
+ }
- // Update all affected GapContentPositions to point to the new index
- // and all GapContentPositions that come after the interval to
- // have their index moved by -removed.
- Set positionSet = positions.keySet();
- for (Iterator i = positionSet.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- if (p.index > startIndex || p.index <= endIndex)
- p.index = startIndex;
- else if (p.index > endIndex)
- p.index -= removed;
- }
- }
}
-
+
/**
* Adjusts the mark of all <code>Position</code>s that are in the range
* specified by <code>offset</code> and </code>length</code> within
* the buffer array by <code>increment</code>
*
- * @param offset the start offset of the range to search
- * @param length the length of the range to search
+ * @param startOffs the start offset of the range to search
+ * @param endOffs the length of the range to search, -1 means all to the end
* @param incr the increment
*/
- private void adjustPositionsInRange(int offset, int length, int incr)
+ private void adjustPositionsInRange(int startOffs, int endOffs, int incr)
{
- int endMark = offset + length;
-
synchronized (this)
{
// Find the start and end indices in the positionMarks array.
- int startIndex = binarySearch(positionMarks, offset, numMarks);
+ Mark m = new Mark(0); // For comparison / search only.
+
+ m.mark = startOffs;
+ int startIndex = search(marks, m);
if (startIndex < 0) // Translate to insertion index, if not found.
startIndex = - startIndex - 1;
- int endIndex = binarySearch(positionMarks, endMark, numMarks);
- if (endIndex < 0) // Translate to insertion index - 1, if not found.
- endIndex = - endIndex - 2;
-
- // We must not change the order of the marks, this would have
- // unpredictable results while binary-searching the marks.
- assert (startIndex <= 0
- || positionMarks[startIndex - 1]
- <= positionMarks [startIndex] + incr)
- && (endIndex >= numMarks - 1
- || positionMarks[endIndex + 1]
- >= positionMarks[endIndex] + incr)
- : "Adjusting the marks must not change their order";
-
- // Some debug helper output to determine if the start or end of the
- // should ever be coalesced together with adjecent marks.
- if (startIndex > 0 && positionMarks[startIndex - 1]
- == positionMarks[startIndex] + incr)
- System.err.println("DEBUG: We could coalesce the start of the region"
- + " in GapContent.adjustPositionsInRange()");
- if (endIndex < numMarks - 1 && positionMarks[endIndex + 1]
- == positionMarks[endIndex] + incr)
- System.err.println("DEBUG: We could coalesce the end of the region"
- + " in GapContent.adjustPositionsInRange()");
+ m.mark = endOffs;
+ int endIndex;
+ if (endOffs == -1)
+ endIndex = marks.size() - 1;
+ else
+ {
+ endIndex = search(marks, m);
+ if (endIndex < 0) // Translate to insertion index - 1, if not found.
+ endIndex = - endIndex - 2;
+ }
// Actually adjust the marks.
- for (int i = startIndex; i <= endIndex; i++)
- positionMarks[i] += incr;
+ for (int i = startIndex; i <= endIndex; i++) {
+ ((Mark) marks.get(i)).mark += incr;
+ }
}
}
@@ -800,7 +835,12 @@ public class GapContent
if (gapStart != 0)
return;
- positionMarks[0] = 0;
+ for (int i = 0; i < marks.size(); i++)
+ {
+ Mark m = (Mark) marks.get(i);
+ if (m.mark <= gapEnd)
+ m.mark = 0;
+ }
}
/**
@@ -845,89 +885,60 @@ public class GapContent
*/
private void dumpMarks()
{
- System.err.print("positionMarks: ");
- for (int i = 0; i < numMarks; i++)
- System.err.print(positionMarks[i] + ", ");
- System.err.println();
+ System.out.print("positionMarks: ");
+ for (int i = 0; i < marks.size(); i++)
+ System.out.print(((Mark) marks.get(i)).mark + ", ");
+ System.out.println();
}
/**
- * Inserts a mark into the positionMarks array. This must update all the
- * GapContentPosition instances in positions that come after insertionPoint.
+ * Polls the queue of death for GapContentPositions, updates the
+ * corresponding reference count and removes the corresponding mark
+ * if the refcount reaches zero.
*
- * This is package private to avoid synthetic accessor methods.
- *
- * @param insertionPoint the index at which to insert the mark
- * @param mark the mark to insert
+ * This is package private to avoid accessor synthetic methods.
*/
- void insertMark(int insertionPoint, int mark)
+ void garbageCollect()
{
- synchronized (this)
+ Reference ref = queueOfDeath.poll();
+ while (ref != null)
{
- // Update the positions.
- Set positionSet = positions.keySet();
- for (Iterator i = positionSet.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- if (p.index >= insertionPoint)
- p.index++;
- }
-
- // Update the position marks.
- if (positionMarks.length <= numMarks)
+ if (ref != null)
{
- int[] newMarks = new int[positionMarks.length + 10];
- System.arraycopy(positionMarks, 0, newMarks, 0, insertionPoint);
- newMarks[insertionPoint] = mark;
- System.arraycopy(positionMarks, insertionPoint, newMarks,
- insertionPoint + 1,
- numMarks - insertionPoint);
- positionMarks = newMarks;
+ GapContentPosition pos = (GapContentPosition) ref.get();
+ Mark m = pos.mark;
+ m.refCount--;
+ if (m.refCount == 0)
+ marks.remove(m);
}
- else
- {
- System.arraycopy(positionMarks, insertionPoint, positionMarks,
- insertionPoint + 1,
- numMarks - insertionPoint);
- positionMarks[insertionPoint] = mark;
- }
- numMarks++;
+ ref = queueOfDeath.poll();
}
}
/**
- * An adaption of {@link java.util.Arrays#binarySearch(int[], int)} to
- * specify a maximum index up to which the array is searched. This allows
- * us to have some trailing entries that we ignore.
- *
- * This is package private to avoid synthetic accessor methods.
- *
- * @param a the array
- * @param key the key to search for
- * @param maxIndex the maximum index up to which the search is performed
+ * Searches the first occurance of object <code>o</code> in list
+ * <code>l</code>. This performs a binary search by calling
+ * {@link Collections#binarySearch(List, Object)} and when an object has been
+ * found, it searches backwards to the first occurance of that object in the
+ * list. The meaning of the return value is the same as in
+ * <code>Collections.binarySearch()</code>.
*
- * @return the index of the found entry, or (-(index)-1) for the
- * insertion point when not found
+ * @param l the list to search through
+ * @param o the object to be searched
*
- * @see java.util.Arrays#binarySearch(int[], int)
+ * @return the index of the first occurance of o in l, or -i + 1 if not found
*/
- int binarySearch(int[] a, int key, int maxIndex)
+ private int search(List l, Object o)
{
- int low = 0;
- int hi = maxIndex - 1;
- int mid = 0;
- while (low <= hi)
+ int i = Collections.binarySearch(l, o);
+ while (i > 0)
{
- mid = (low + hi) >>> 1;
- final int d = a[mid];
- if (d == key)
- return mid;
- else if (d > key)
- hi = mid - 1;
+ Object o2 = l.get(i - 1);
+ if (o2.equals(o))
+ i--;
else
- // This gets the insertion point right on the last loop.
- low = ++mid;
+ break;
}
- return -mid - 1;
+ return i;
}
}
diff --git a/libjava/classpath/javax/swing/text/IconView.java b/libjava/classpath/javax/swing/text/IconView.java
index 699cda90eba..7bb7635b4e7 100644
--- a/libjava/classpath/javax/swing/text/IconView.java
+++ b/libjava/classpath/javax/swing/text/IconView.java
@@ -44,7 +44,6 @@ import java.awt.Shape;
import javax.swing.Icon;
import javax.swing.JTextPane;
-import javax.swing.SwingConstants;
/**
* A View that can render an icon. This view is created by the
@@ -156,4 +155,21 @@ public class IconView
return el.getStartOffset();
}
+ /**
+ * Returns the alignment for this view. This will be 1.0 for the Y_AXIS,
+ * and the super behaviour for the X_AXIS.
+ *
+ * @param axis the axis for which to calculate the alignment
+ *
+ * @return the alignment
+ */
+ public float getAlignment(int axis)
+ {
+ float align;
+ if (axis == Y_AXIS)
+ align = 1.0F;
+ else
+ align = super.getAlignment(axis);
+ return align;
+ }
}
diff --git a/libjava/classpath/javax/swing/text/JTextComponent.java b/libjava/classpath/javax/swing/text/JTextComponent.java
index 9de151dfbac..6da84bfe7d8 100644
--- a/libjava/classpath/javax/swing/text/JTextComponent.java
+++ b/libjava/classpath/javax/swing/text/JTextComponent.java
@@ -42,6 +42,7 @@ import gnu.classpath.NotImplementedException;
import java.awt.AWTEvent;
import java.awt.Color;
+import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
@@ -90,9 +91,10 @@ public abstract class JTextComponent extends JComponent
implements Scrollable, Accessible
{
/**
- * This class implements accessibility support for the JTextComponent class.
- * It provides an implementation of the Java Accessibility API appropriate
- * to menu user-interface elements.
+ * AccessibleJTextComponent implements accessibility hooks for
+ * JTextComponent. It allows an accessibility driver to read and
+ * manipulate the text component's contents as well as update UI
+ * elements such as the caret.
*/
public class AccessibleJTextComponent extends AccessibleJComponent implements
AccessibleText, CaretListener, DocumentListener, AccessibleAction,
@@ -100,15 +102,18 @@ public abstract class JTextComponent extends JComponent
{
private static final long serialVersionUID = 7664188944091413696L;
- /** The caret's offset. */
+ /**
+ * The caret's offset.
+ */
int dot = 0;
-
- /** The current JTextComponent. */
+
+ /**
+ * The current JTextComponent.
+ */
JTextComponent textComp = JTextComponent.this;
-
+
/**
- * Constructs an AccessibleJTextComponent.
- * Adds a listener to track caret change.
+ * Construct an AccessibleJTextComponent.
*/
public AccessibleJTextComponent()
{
@@ -117,11 +122,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the zero-based offset of the caret. Note: The character
- * to the right of the caret will have the same index value as the
- * offset (the caret is between two characters).
- *
- * @return offset of caret
+ * Retrieve the current caret position. The index of the first
+ * caret position is 0.
+ *
+ * @return caret position
*/
public int getCaretPosition()
{
@@ -130,9 +134,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the portion of the text that is selected.
- *
- * @return null if no text is selected.
+ * Retrieve the current text selection. If no text is selected
+ * this method returns null.
+ *
+ * @return the currently selected text or null
*/
public String getSelectedText()
{
@@ -140,11 +145,14 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the start offset within the selected text. If there is no
- * selection, but there is a caret, the start and end offsets will be
- * the same. Return 0 if the text is empty, or the caret position if no selection.
- *
- * @return index of the start of the text >= 0.
+ * Retrieve the index of the first character in the current text
+ * selection. If there is no text in the text component, this
+ * method returns 0. If there is text in the text component, but
+ * there is no selection, this method returns the current caret
+ * position.
+ *
+ * @return the index of the first character in the selection, the
+ * current caret position or 0
*/
public int getSelectionStart()
{
@@ -154,12 +162,14 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the end offset within the selected text. If there is no
- * selection, but there is a caret, the start and end offsets will
- * be the same. Return 0 if the text is empty, or the caret position
- * if no selection.
- *
- * @return index of the end of the text >= 0.
+ * Retrieve the index of the last character in the current text
+ * selection. If there is no text in the text component, this
+ * method returns 0. If there is text in the text component, but
+ * there is no selection, this method returns the current caret
+ * position.
+ *
+ * @return the index of the last character in the selection, the
+ * current caret position or 0
*/
public int getSelectionEnd()
{
@@ -169,13 +179,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Handles caret updates (fire appropriate property change event, which are
- * AccessibleContext.ACCESSIBLE_CARET_PROPERTY and
- * AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY). This keeps track of
- * the dot position internally. When the caret moves, the internal position
- * is updated after firing the event.
- *
- * @param e - caret event
+ * Handle a change in the caret position and fire any applicable
+ * property change events.
+ *
+ * @param e - the caret update event
*/
public void caretUpdate(CaretEvent e)
throws NotImplementedException
@@ -185,7 +192,7 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the accessible state set of this component.
+ * Retreive the accessible state set of this component.
*
* @return the accessible state set of this component
*/
@@ -198,7 +205,7 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the accessible role of this component.
+ * Retrieve the accessible role of this component.
*
* @return the accessible role of this component
*
@@ -210,20 +217,19 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the AccessibleEditableText interface for this text component.
- *
+ * Retrieve an AccessibleEditableText object that controls this
+ * text component.
+ *
* @return this
*/
public AccessibleEditableText getAccessibleEditableText()
{
return this;
}
-
+
/**
- * Get the AccessibleText associated with this object. In the implementation
- * of the Java Accessibility API for this class, return this object,
- * which is responsible for implementing the AccessibleText interface on
- * behalf of itself.
+ * Retrieve an AccessibleText object that controls this text
+ * component.
*
* @return this
*
@@ -235,10 +241,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Insert update. Fire appropriate property change event which
- * is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY.
- *
- * @param e - document event
+ * Handle a text insertion event and fire an
+ * AccessibleContext.ACCESSIBLE_TEXT_PROPERTY property change
+ * event.
+ *
+ * @param e - the insertion event
*/
public void insertUpdate(DocumentEvent e)
throws NotImplementedException
@@ -247,10 +254,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Remove update. Fire appropriate property change event which
- * is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY.
- *
- * @param e - document event
+ * Handle a text removal event and fire an
+ * AccessibleContext.ACCESSIBLE_TEXT_PROPERTY property change
+ * event.
+ *
+ * @param e - the removal event
*/
public void removeUpdate(DocumentEvent e)
throws NotImplementedException
@@ -259,10 +267,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Changed update. Fire appropriate property change event which
- * is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY.
- *
- * @param e - document event
+ * Handle a text change event and fire an
+ * AccessibleContext.ACCESSIBLE_TEXT_PROPERTY property change
+ * event.
+ *
+ * @param e - text change event
*/
public void changedUpdate(DocumentEvent e)
throws NotImplementedException
@@ -271,11 +280,13 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Given a point in the coordinate system of this object, return the
- * 0-based index of the character at that point, or -1 if there is none.
+ * Get the index of the character at the given point, in component
+ * pixel co-ordinates. If the point argument is invalid this
+ * method returns -1.
*
- * @param p the point to look at
- * @return the character index, or -1
+ * @param p - a point in component pixel co-ordinates
+ *
+ * @return a character index, or -1
*/
public int getIndexAtPoint(Point p)
throws NotImplementedException
@@ -284,17 +295,14 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Determines the bounding box of the indexed character. Returns an empty
- * rectangle if the index is out of bounds. The bounds are returned in local coordinates.
- * If the index is invalid a null rectangle is returned. The screen coordinates returned are
- * "unscrolled coordinates" if the JTextComponent is contained in a JScrollPane in which
- * case the resulting rectangle should be composed with the parent coordinates.
- * Note: the JTextComponent must have a valid size (e.g. have been added to a parent
- * container whose ancestor container is a valid top-level window) for this method to
- * be able to return a meaningful (non-null) value.
+ * Calculate the bounding box of the character at the given index.
+ * The returned x and y co-ordinates are relative to this text
+ * component's top-left corner. If the index is invalid this
+ * method returns null.
+ *
+ * @param index - the character index
*
- * @param index the 0-based character index
- * @return the bounding box, may be empty or null.
+ * @return a character's bounding box, or null
*/
public Rectangle getCharacterBounds(int index)
throws NotImplementedException
@@ -303,9 +311,9 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Return the number of characters.
+ * Return the length of the text in this text component.
*
- * @return the character count
+ * @return a character length
*/
public int getCharCount()
{
@@ -313,10 +321,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the attributes of a character at an index, or null if the index
- * is out of bounds.
+ * Gets the character attributes of the character at index. If
+ * the index is out of bounds, null is returned.
*
- * @param index the 0-based character index
+ * @param index - index of the character
+ *
* @return the character's attributes
*/
public AttributeSet getCharacterAttribute(int index)
@@ -326,26 +335,28 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the section of text at the index, or null if the index or part
- * is invalid.
- *
- * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
- * @param index the 0-based character index
- * @return the selection of text at that index, or null
+ * Gets the text located at index. null is returned if the index
+ * or part is invalid.
+ *
+ * @param part - {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+ * @param index - index of the part
+ *
+ * @return the part of text at that index, or null
*/
public String getAtIndex(int part, int index)
throws NotImplementedException
{
return null; // TODO
}
-
+
/**
- * Returns the section of text after the index, or null if the index or part
- * is invalid.
- *
- * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
- * @param index the 0-based character index
- * @return the selection of text after that index, or null
+ * Gets the text located after index. null is returned if the index
+ * or part is invalid.
+ *
+ * @param part - {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+ * @param index - index after the part
+ *
+ * @return the part of text after that index, or null
*/
public String getAfterIndex(int part, int index)
throws NotImplementedException
@@ -354,12 +365,13 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Returns the section of text before the index, or null if the index or part
- * is invalid.
- *
- * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
- * @param index the 0-based character index
- * @return the selection of text before that index, or null
+ * Gets the text located before index. null is returned if the index
+ * or part is invalid.
+ *
+ * @param part - {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+ * @param index - index before the part
+ *
+ * @return the part of text before that index, or null
*/
public String getBeforeIndex(int part, int index)
throws NotImplementedException
@@ -368,10 +380,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Get the number possible actions for this object, with the zeroth
- * representing the default action.
+ * Returns the number of actions for this object. The zero-th
+ * object represents the default action.
*
- * @return the 0-based number of actions
+ * @return the number of actions (0-based).
*/
public int getAccessibleActionCount()
throws NotImplementedException
@@ -380,11 +392,12 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Get a description for the specified action. Returns null if out of
- * bounds.
+ * Returns the description of the i-th action. Null is returned if
+ * i is out of bounds.
*
- * @param i the action to describe, 0-based
- * @return description of the action
+ * @param i - the action to get the description for
+ *
+ * @return description of the i-th action
*/
public String getAccessibleActionDescription(int i)
throws NotImplementedException
@@ -394,10 +407,12 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Perform the specified action. Does nothing if out of bounds.
+ * Performs the i-th action. Nothing happens if i is
+ * out of bounds.
*
- * @param i the action to perform, 0-based
- * @return true if the action was performed
+ * @param i - the action to perform
+ *
+ * @return true if the action was performed successfully
*/
public boolean doAccessibleAction(int i)
throws NotImplementedException
@@ -406,9 +421,9 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Set the text contents to the given string.
+ * Sets the text contents.
*
- * @param s the new text
+ * @param s - the new text contents.
*/
public void setTextContents(String s)
throws NotImplementedException
@@ -417,10 +432,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Inserts the given string at the specified location.
+ * Inserts the text at the given index.
*
- * @param index the index for insertion
- * @param s the new text
+ * @param index - the index to insert the new text at.
+ * @param s - the new text
*/
public void insertTextAtIndex(int index, String s)
throws NotImplementedException
@@ -429,10 +444,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Return the text between two points.
+ * Gets the text between two indexes.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
*/
public String getTextRange(int start, int end)
{
@@ -447,10 +462,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Delete the text between two points.
+ * Deletes the text between two indexes.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
*/
public void delete(int start, int end)
{
@@ -458,10 +473,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Cut the text between two points to the system clipboard.
+ * Cuts the text between two indexes. The text is put
+ * into the system clipboard.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
*/
public void cut(int start, int end)
{
@@ -470,9 +486,9 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Paste the text from the system clipboard at the given index.
+ * Pastes the text from the system clipboard to the given index.
*
- * @param start the start position
+ * @param start - the starting index
*/
public void paste(int start)
{
@@ -481,11 +497,12 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Replace the text between two points with the given string.
+ * Replaces the text between two indexes with the given text.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
- * @param s the string to paste
+ *
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
+ * @param s - the text to paste
*/
public void replaceText(int start, int end, String s)
{
@@ -494,10 +511,10 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Select the text between two points.
+ * Selects the text between two indexes.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
*/
public void selectText(int start, int end)
{
@@ -505,11 +522,11 @@ public abstract class JTextComponent extends JComponent
}
/**
- * Set the attributes of text between two points.
+ * Sets the attributes of all the text between two indexes.
*
- * @param start the start position, inclusive
- * @param end the end position, exclusive
- * @param s the new attribute set for the range
+ * @param start - the starting index (inclusive)
+ * @param end - the ending index (exclusive)
+ * @param s - the new attribute set for the text in the range
*/
public void setAttributes(int start, int end, AttributeSet s)
throws NotImplementedException
@@ -1163,8 +1180,19 @@ public abstract class JTextComponent extends JComponent
public void setDocument(Document newDoc)
{
Document oldDoc = doc;
- doc = newDoc;
- firePropertyChange("document", oldDoc, newDoc);
+ try
+ {
+ if (oldDoc instanceof AbstractDocument)
+ ((AbstractDocument) oldDoc).readLock();
+
+ doc = newDoc;
+ firePropertyChange("document", oldDoc, newDoc);
+ }
+ finally
+ {
+ if (oldDoc instanceof AbstractDocument)
+ ((AbstractDocument) oldDoc).readUnlock();
+ }
revalidate();
repaint();
}
@@ -1641,10 +1669,12 @@ public abstract class JTextComponent extends JComponent
public boolean getScrollableTracksViewportWidth()
{
- if (getParent() instanceof JViewport)
- return getParent().getWidth() > getPreferredSize().width;
+ boolean res = false;;
+ Container c = getParent();
+ if (c instanceof JViewport)
+ res = ((JViewport) c).getExtentSize().width > getPreferredSize().width;
- return false;
+ return res;
}
/**
diff --git a/libjava/classpath/javax/swing/text/ParagraphView.java b/libjava/classpath/javax/swing/text/ParagraphView.java
index 15bed781825..c4857863d35 100644
--- a/libjava/classpath/javax/swing/text/ParagraphView.java
+++ b/libjava/classpath/javax/swing/text/ParagraphView.java
@@ -74,6 +74,39 @@ public class ParagraphView extends FlowView implements TabExpander
return align;
}
+ /**
+ * Allows rows to span the whole parent view.
+ */
+ public float getMaximumSpan(int axis)
+ {
+ float max;
+ if (axis == X_AXIS)
+ max = Float.MAX_VALUE;
+ else
+ max = super.getMaximumSpan(axis);
+ return max;
+ }
+
+ /**
+ * Overridden because child views are not necessarily laid out in model
+ * order.
+ */
+ protected int getViewIndexAtPosition(int pos)
+ {
+ int index = -1;
+ if (pos >= getStartOffset() && pos < getEndOffset())
+ {
+ int nviews = getViewCount();
+ for (int i = 0; i < nviews && index == -1; i++)
+ {
+ View child = getView(i);
+ if (pos >= child.getStartOffset() && pos < child.getEndOffset())
+ index = i;
+ }
+ }
+ return index;
+ }
+
protected void loadChildren(ViewFactory vf)
{
// Do nothing here. The children are added while layouting.
@@ -140,7 +173,7 @@ public class ParagraphView extends FlowView implements TabExpander
{
float align;
if (axis == X_AXIS)
- align = super.getAlignment(axis);
+ align = 0.5F;
else if (getViewCount() > 0)
{
float prefHeight = getPreferredSpan(Y_AXIS);
@@ -148,7 +181,7 @@ public class ParagraphView extends FlowView implements TabExpander
align = (firstRowHeight / 2.F) / prefHeight;
}
else
- align = 0.0F;
+ align = 0.5F;
return align;
}
diff --git a/libjava/classpath/javax/swing/text/PlainDocument.java b/libjava/classpath/javax/swing/text/PlainDocument.java
index c699dcad2aa..730a619da9f 100644
--- a/libjava/classpath/javax/swing/text/PlainDocument.java
+++ b/libjava/classpath/javax/swing/text/PlainDocument.java
@@ -56,8 +56,12 @@ public class PlainDocument extends AbstractDocument
public static final String lineLimitAttribute = "lineLimit";
public static final String tabSizeAttribute = "tabSize";
- private BranchElement rootElement;
- private int tabSize;
+ /**
+ * The default root element of this document. This is made type Element
+ * because the RI seems to accept other types of elements as well from
+ * createDefaultRoot() (when overridden by a subclass).
+ */
+ private Element rootElement;
public PlainDocument()
{
@@ -67,8 +71,10 @@ public class PlainDocument extends AbstractDocument
public PlainDocument(AbstractDocument.Content content)
{
super(content);
- tabSize = 8;
- rootElement = (BranchElement) createDefaultRoot();
+ rootElement = createDefaultRoot();
+
+ // This property has been determined using a Mauve test.
+ putProperty("tabSize", new Integer(8));
}
private void reindex()
@@ -105,10 +111,10 @@ public class PlainDocument extends AbstractDocument
protected AbstractDocument.AbstractElement createDefaultRoot()
{
BranchElement root =
- (BranchElement) createBranchElement(null, SimpleAttributeSet.EMPTY);
+ (BranchElement) createBranchElement(null, null);
Element[] array = new Element[1];
- array[0] = createLeafElement(root, SimpleAttributeSet.EMPTY, 0, 1);
+ array[0] = createLeafElement(root, null, 0, 1);
root.replace(0, 0, array);
return root;
@@ -117,116 +123,97 @@ public class PlainDocument extends AbstractDocument
protected void insertUpdate(DefaultDocumentEvent event,
AttributeSet attributes)
{
+
+ String text = null;
int offset = event.getOffset();
- int eventLength = event.getLength();
- int end = offset + event.getLength();
- int oldElementIndex, elementIndex = rootElement.getElementIndex(offset);
- Element firstElement = rootElement.getElement(elementIndex);
- oldElementIndex = elementIndex;
-
- // If we're inserting immediately after a newline we have to fix the
- // Element structure (but only if we are dealing with a line which
- // has not existed as Element before).
- if (offset > 0 && firstElement.getStartOffset() != offset)
+ int length = event.getLength();
+ try
{
- try
- {
- String s = getText(offset - 1, 1);
- if (s.equals("\n") )
- {
- int newEl2EndOffset = end;
- boolean replaceNext = false;
- if (rootElement.getElementCount() > elementIndex + 1)
- {
- replaceNext = true;
- newEl2EndOffset =
- rootElement.getElement(elementIndex + 1).getEndOffset();
- }
- Element newEl1 =
- createLeafElement(rootElement, firstElement.getAttributes(),
- firstElement.getStartOffset(), offset);
- Element newEl2 =
- createLeafElement (rootElement, firstElement.getAttributes(),
- offset, newEl2EndOffset);
- if (replaceNext)
- rootElement.replace(elementIndex, 2, new Element[] { newEl1, newEl2 });
- else
- rootElement.replace(elementIndex, 1, new Element[] { newEl1, newEl2 });
- firstElement = newEl2;
- elementIndex ++;
- }
- }
- catch (BadLocationException ble)
- {
- // This shouldn't happen.
- AssertionError ae = new AssertionError();
- ae.initCause(ble);
- throw ae;
- }
+ text = getText(offset, length);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError err = new AssertionError();
+ err.initCause(ex);
+ throw err;
}
- // added and removed are Element arrays used to add an ElementEdit
- // to the DocumentEvent if there were entire lines added or removed.
- Element[] removed = new Element[1];
- Element[] added;
- try
+ boolean hasLineBreak = text.indexOf('\n') != -1;
+ boolean prevCharIsLineBreak = false;
+ try
{
- String str = content.getString(offset, eventLength);
- ArrayList elts = new ArrayList();
+ prevCharIsLineBreak =
+ offset > 0 && getText(offset - 1, 1).charAt(0) == '\n';
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError err = new AssertionError();
+ err.initCause(ex);
+ throw err;
+ }
+ boolean lastCharIsLineBreak = text.charAt(text.length() - 1) == '\n';
+ int lineIndex = -1;
+ int lineStart = -1;
+ int lineEnd = -1;
+ Element[] removed = null;
+ BranchElement root = (BranchElement) rootElement;
+ boolean updateStructure = true;
- // Determine how many NEW lines were added by finding the newline
- // characters within the newly inserted text
- int j = firstElement.getStartOffset();
- int i = str.indexOf('\n', 0);
- int contentLength = content.length();
-
- while (i != -1 && i <= eventLength)
- {
- // For each new line, create a new element
- elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY,
- j, offset + i + 1));
-
- j = offset + i + 1;
- if (j >= contentLength)
- break;
- i = str.indexOf('\n', i + 1);
- }
+ if (prevCharIsLineBreak && ! lastCharIsLineBreak)
+ {
+ // We must fix the structure a little if the previous char
+ // is a linebreak and the last char isn't.
+ lineIndex = root.getElementIndex(offset - 1);
+ Element prevLine = root.getElement(lineIndex);
+ Element nextLine = root.getElement(lineIndex + 1);
+ lineStart = prevLine.getStartOffset();
+ lineEnd = nextLine.getEndOffset();
+ removed = new Element[]{ prevLine, nextLine };
+ }
+ else if (hasLineBreak)
+ {
+ lineIndex = root.getElementIndex(offset);
+ Element line = root.getElement(lineIndex);
+ lineStart = line.getStartOffset();
+ lineEnd = line.getEndOffset();
+ removed = new Element[]{ line };
+ }
+ else
+ {
+ updateStructure = false;
+ }
- // If there were new lines added we have to add an ElementEdit to
- // the DocumentEvent and we have to call rootElement.replace to
- // insert the new lines
- if (elts.size() != 0)
+ if (updateStructure)
+ {
+ // Break the lines between lineStart and lineEnd.
+ ArrayList lines = new ArrayList();
+ int len = lineEnd - lineStart;
+ try
{
- // If we have created new lines test whether there are remaining
- // characters in firstElement after the inserted text and if so
- // create a new element for them.
- if (j < firstElement.getEndOffset())
- elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY, j, firstElement.getEndOffset()));
-
- // Set up the ElementEdit by filling the added and removed
- // arrays with the proper Elements
- added = new Element[elts.size()];
- elts.toArray(added);
-
- removed[0] = firstElement;
-
- // Now create and add the ElementEdit
- ElementEdit e = new ElementEdit(rootElement, elementIndex, removed,
- added);
- event.addEdit(e);
-
- // And call replace to actually make the changes
- ((BranchElement) rootElement).replace(elementIndex, 1, added);
+ text = getText(lineStart, len);
}
+ catch (BadLocationException ex)
+ {
+ AssertionError err = new AssertionError();
+ err.initCause(ex);
+ throw err;
+ }
+ int prevLineBreak = 0;
+ int lineBreak = text.indexOf('\n');
+ do
+ {
+ lineBreak++;
+ lines.add(createLeafElement(root, null, lineStart + prevLineBreak,
+ lineStart + lineBreak));
+ prevLineBreak = lineBreak;
+ lineBreak = text.indexOf('\n', prevLineBreak);
+ } while (prevLineBreak < len);
+
+ // Update the element structure and prepare document event.
+ Element[] added = (Element[]) lines.toArray(new Element[lines.size()]);
+ event.addEdit(new ElementEdit(root, lineIndex, removed, added));
+ root.replace(lineIndex, removed.length, added);
}
- catch (BadLocationException e)
- {
- // This shouldn't happen so we throw an AssertionError
- AssertionError ae = new AssertionError();
- ae.initCause(e);
- throw ae;
- }
-
super.insertUpdate(event, attributes);
}
@@ -264,7 +251,7 @@ public class PlainDocument extends AbstractDocument
event.addEdit(e);
// collapse elements if the removal spans more than 1 line
- rootElement.replace(i1, i2 - i1 + 1, added);
+ ((BranchElement) rootElement).replace(i1, i2 - i1 + 1, added);
}
}
diff --git a/libjava/classpath/javax/swing/text/Segment.java b/libjava/classpath/javax/swing/text/Segment.java
index d2364e05a10..63c5fa09dbc 100644
--- a/libjava/classpath/javax/swing/text/Segment.java
+++ b/libjava/classpath/javax/swing/text/Segment.java
@@ -165,8 +165,9 @@ public class Segment implements Cloneable, CharacterIterator
/**
* Sets the current index to point to the last character in the segment and
- * returns that character. If the segment contains zero characters, this
- * method returns {@link #DONE}.
+ * returns that character. If the segment contains zero characters, the
+ * current index is set to {@link #getEndIndex()} and this method returns
+ * {@link #DONE}.
*
* @return The last character in the segment, or {@link #DONE} if the
* segment contains zero characters.
@@ -174,7 +175,10 @@ public class Segment implements Cloneable, CharacterIterator
public char last()
{
if (count == 0)
- return DONE;
+ {
+ current = getEndIndex();
+ return DONE;
+ }
current = getEndIndex() - 1;
return array[current];
diff --git a/libjava/classpath/javax/swing/text/SimpleAttributeSet.java b/libjava/classpath/javax/swing/text/SimpleAttributeSet.java
index 8dbcb0c6a14..8684ef87d34 100644
--- a/libjava/classpath/javax/swing/text/SimpleAttributeSet.java
+++ b/libjava/classpath/javax/swing/text/SimpleAttributeSet.java
@@ -51,8 +51,10 @@ public class SimpleAttributeSet
/** The serialization UID (compatible with JDK1.5). */
private static final long serialVersionUID = 8267656273837665219L;
- /** An empty attribute set. */
- public static final AttributeSet EMPTY = new SimpleAttributeSet();
+ /**
+ * An empty attribute set.
+ */
+ public static final AttributeSet EMPTY = new EmptyAttributeSet();
/** Storage for the attributes. */
Hashtable tab;
diff --git a/libjava/classpath/javax/swing/text/StringContent.java b/libjava/classpath/javax/swing/text/StringContent.java
index 0a31505f3a6..8014dc3bce6 100644
--- a/libjava/classpath/javax/swing/text/StringContent.java
+++ b/libjava/classpath/javax/swing/text/StringContent.java
@@ -178,11 +178,13 @@ public final class StringContent
}
/**
- * Creates a new instance containing the string "\n".
+ * Creates a new instance containing the string "\n". This is equivalent
+ * to calling {@link #StringContent(int)} with an <code>initialLength</code>
+ * of 10.
*/
public StringContent()
{
- this(1);
+ this(10);
}
/**
diff --git a/libjava/classpath/javax/swing/text/TabSet.java b/libjava/classpath/javax/swing/text/TabSet.java
index ecad9444ea5..0f2c8c7c1ee 100644
--- a/libjava/classpath/javax/swing/text/TabSet.java
+++ b/libjava/classpath/javax/swing/text/TabSet.java
@@ -1,5 +1,5 @@
/* TabSet.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,23 +39,54 @@ package javax.swing.text;
import java.io.Serializable;
+/**
+ * A set of tab stops. Instances of this class are immutable.
+ */
public class TabSet implements Serializable
{
/** The serialization UID (compatible with JDK1.5). */
private static final long serialVersionUID = 2367703481999080593L;
+ /** Storage for the tab stops. */
TabStop[] tabs;
+ /**
+ * Creates a new <code>TabSet</code> containing the specified tab stops.
+ *
+ * @param t the tab stops (<code>null</code> permitted).
+ */
public TabSet(TabStop[] t)
{
- tabs = t;
+ if (t != null)
+ tabs = (TabStop[]) t.clone();
+ else
+ tabs = new TabStop[0];
}
+ /**
+ * Returns the tab stop with the specified index.
+ *
+ * @param i the index.
+ *
+ * @return The tab stop.
+ *
+ * @throws IllegalArgumentException if <code>i</code> is not in the range
+ * <code>0</code> to <code>getTabCount() - 1</code>.
+ */
public TabStop getTab(int i)
{
+ if (i < 0 || i >= tabs.length)
+ throw new IllegalArgumentException("Index out of bounds.");
return tabs[i];
}
+ /**
+ * Returns the tab following the specified location.
+ *
+ * @param location the location.
+ *
+ * @return The tab following the specified location (or <code>null</code>).
+ */
public TabStop getTabAfter(float location)
{
int idx = getTabIndexAfter(location);
@@ -65,11 +96,23 @@ public class TabSet implements Serializable
return tabs[idx];
}
+ /**
+ * Returns the number of tab stops in this tab set.
+ *
+ * @return The number of tab stops in this tab set.
+ */
public int getTabCount()
{
return tabs.length;
}
+ /**
+ * Returns the index of the specified tab, or -1 if the tab is not found.
+ *
+ * @param tab the tab (<code>null</code> permitted).
+ *
+ * @return The index of the specified tab, or -1.
+ */
public int getTabIndex(TabStop tab)
{
for (int i = 0; i < tabs.length; ++i)
@@ -78,28 +121,88 @@ public class TabSet implements Serializable
return -1;
}
+ /**
+ * Returns the index of the tab at or after the specified location.
+ *
+ * @param location the tab location.
+ *
+ * @return The index of the tab stop, or -1.
+ */
public int getTabIndexAfter(float location)
{
- int idx = -1;
- for (int i = 0; i < tabs.length; ++i)
+ for (int i = 0; i < tabs.length; i++)
+ {
+ if (location <= tabs[i].getPosition())
+ return i;
+ }
+ return -1;
+ }
+
+ /**
+ * Tests this <code>TabSet</code> for equality with an arbitrary object.
+ *
+ * @param obj the object (<code>null</code> permitted).
+ *
+ * @return <code>true</code> if this <code>TabSet</code> is equal to
+ * <code>obj</code>, and <code>false</code> otherwise.
+ *
+ * @since 1.5
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (!(obj instanceof TabSet))
+ return false;
+ TabSet that = (TabSet) obj;
+ int tabCount = getTabCount();
+ if (tabCount != that.getTabCount())
+ return false;
+ for (int i = 0; i < tabCount; i++)
+ {
+ if (!this.getTab(i).equals(that.getTab(i)))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns a hash code for this <code>TabSet</code>.
+ *
+ * @return A hash code.
+ *
+ * @since 1.5
+ */
+ public int hashCode()
+ {
+ // this hash code won't match Sun's, but that shouldn't matter...
+ int result = 193;
+ int tabs = getTabCount();
+ for (int i = 0; i < tabs; i++)
{
- if (location < tabs[i].getPosition())
- idx = i;
+ TabStop t = getTab(i);
+ if (t != null)
+ result = 37 * result + t.hashCode();
}
- return idx;
+ return result;
}
+ /**
+ * Returns a string representation of this <code>TabSet</code>.
+ *
+ * @return A string representation of this <code>TabSet</code>.
+ */
public String toString()
{
StringBuffer sb = new StringBuffer();
- sb.append("[");
+ sb.append("[ ");
for (int i = 0; i < tabs.length; ++i)
{
if (i != 0)
sb.append(" - ");
sb.append(tabs[i].toString());
}
- sb.append("]");
+ sb.append(" ]");
return sb.toString();
}
}
diff --git a/libjava/classpath/javax/swing/text/TabStop.java b/libjava/classpath/javax/swing/text/TabStop.java
index 56f862fdae4..f4c3f851406 100644
--- a/libjava/classpath/javax/swing/text/TabStop.java
+++ b/libjava/classpath/javax/swing/text/TabStop.java
@@ -1,5 +1,5 @@
-/* TabSet.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+/* TabStop.java --
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,9 @@ package javax.swing.text;
import java.io.Serializable;
+/**
+ * Represents a tab position in some text.
+ */
public class TabStop implements Serializable
{
/** The serialization UID (compatible with JDK1.5). */
@@ -61,18 +64,42 @@ public class TabStop implements Serializable
int align;
int leader;
+ /**
+ * Creates a new <code>TabStop</code> for the specified tab position.
+ *
+ * @param pos the tab position.
+ */
public TabStop(float pos)
{
this(pos, ALIGN_LEFT, LEAD_NONE);
}
+ /**
+ * Creates a new <code>TabStop</code> with the specified attributes.
+ *
+ * @param pos the tab position.
+ * @param align the alignment (one of {@link #ALIGN_LEFT},
+ * {@link #ALIGN_CENTER}, {@link #ALIGN_RIGHT}, {@link #ALIGN_DECIMAL}
+ * or {@link #ALIGN_BAR}).
+ * @param leader the leader (one of {@link #LEAD_NONE}, {@link #LEAD_DOTS},
+ * {@link #LEAD_EQUALS}, {@link #LEAD_HYPHENS}, {@link #LEAD_THICKLINE}
+ * or {@link #LEAD_UNDERLINE}).
+ */
public TabStop(float pos, int align, int leader)
{
this.pos = pos;
this.align = align;
this.leader = leader;
}
-
+
+ /**
+ * Tests this <code>TabStop</code> for equality with an arbitrary object.
+ *
+ * @param other the other object (<code>null</code> permitted).
+ *
+ * @return <code>true</code> if this <code>TabStop</code> is equal to
+ * the specified object, and <code>false</code> otherwise.
+ */
public boolean equals(Object other)
{
return (other != null)
@@ -82,34 +109,60 @@ public class TabStop implements Serializable
&& (((TabStop)other).getAlignment() == this.getAlignment());
}
+ /**
+ * Returns the tab alignment. This should be one of {@link #ALIGN_LEFT},
+ * {@link #ALIGN_CENTER}, {@link #ALIGN_RIGHT}, {@link #ALIGN_DECIMAL} or
+ * {@link #ALIGN_BAR}.
+ *
+ * @return The tab alignment.
+ */
public int getAlignment()
{
return align;
}
+ /**
+ * Returns the leader type. This should be one of {@link #LEAD_NONE},
+ * {@link #LEAD_DOTS}, {@link #LEAD_EQUALS}, {@link #LEAD_HYPHENS},
+ * {@link #LEAD_THICKLINE} or {@link #LEAD_UNDERLINE}.
+ *
+ * @return The leader type.
+ */
public int getLeader()
{
return leader;
}
+ /**
+ * Returns the tab position.
+ *
+ * @return The tab position.
+ */
public float getPosition()
{
return pos;
}
+ /**
+ * Returns a hash code for this <code>TabStop</code>.
+ *
+ * @return A hash code.
+ */
public int hashCode()
{
return (int) pos + (int) leader + (int) align;
}
+ /**
+ * Returns a string describing this <code>TabStop</code>.
+ *
+ * @return A string describing this <code>TabStop</code>.
+ */
public String toString()
{
String prefix = "";
switch (align)
{
- case ALIGN_LEFT:
- prefix = "left ";
- break;
case ALIGN_RIGHT:
prefix = "right ";
break;
@@ -130,7 +183,8 @@ public class TabStop implements Serializable
break;
}
- return (prefix + "tab @" + pos + ((leader == LEAD_NONE) ? "" : "(w/leaders)"));
+ return prefix + "tab @" + pos
+ + ((leader == LEAD_NONE) ? "" : " (w/leaders)");
}
}
diff --git a/libjava/classpath/javax/swing/text/View.java b/libjava/classpath/javax/swing/text/View.java
index d8ad5f5858e..55a63f6b668 100644
--- a/libjava/classpath/javax/swing/text/View.java
+++ b/libjava/classpath/javax/swing/text/View.java
@@ -401,7 +401,10 @@ public abstract class View implements SwingConstants
Element el = getElement();
DocumentEvent.ElementChange ec = ev.getChange(el);
if (ec != null)
- updateChildren(ec, ev, vf);
+ {
+ if (! updateChildren(ec, ev, vf))
+ ec = null;
+ }
forwardUpdate(ec, ev, shape, vf);
updateLayout(ec, ev, shape);
}
@@ -493,27 +496,66 @@ public abstract class View implements SwingConstants
int count = getViewCount();
if (count > 0)
{
+ // Determine start index.
int startOffset = ev.getOffset();
- int endOffset = startOffset + ev.getLength();
int startIndex = getViewIndex(startOffset, Position.Bias.Backward);
- int endIndex = getViewIndex(endOffset, Position.Bias.Forward);
- int index = -1;
- int addLength = -1;
- if (ec != null)
+
+ // For REMOVE events we have to forward the event to the last element,
+ // for the case that an Element has been removed that represente
+ // the offset.
+ if (startIndex == -1 && ev.getType() == DocumentEvent.EventType.REMOVE
+ && startOffset >= getEndOffset())
{
- index = ec.getIndex();
- addLength = ec.getChildrenAdded().length;
+ startIndex = getViewCount() - 1;
}
- if (startIndex >= 0 && endIndex >= 0)
+ // When startIndex is on a view boundary, forward event to the
+ // previous view too.
+ if (startIndex >= 0)
{
- for (int i = startIndex; i <= endIndex; i++)
+ View v = getView(startIndex);
+ if (v != null)
+ {
+ if (v.getStartOffset() == startOffset && startOffset > 0)
+ startIndex = Math.max(0, startIndex - 1);
+ }
+ }
+ startIndex = Math.max(0, startIndex);
+
+ // Determine end index.
+ int endIndex = startIndex;
+ if (ev.getType() != DocumentEvent.EventType.REMOVE)
+ {
+ endIndex = getViewIndex(startOffset + ev.getLength(),
+ Position.Bias.Forward);
+ if (endIndex < 0)
+ endIndex = getViewCount() - 1;
+ }
+
+ // Determine hole that comes from added elements (we don't forward
+ // the event to newly added views.
+ int startAdded = endIndex + 1;
+ int endAdded = startAdded;
+ Element[] added = (ec != null) ? ec.getChildrenAdded() : null;
+ if (added != null && added.length > 0)
+ {
+ startAdded = ec.getIndex();
+ endAdded = startAdded + added.length - 1;
+ }
+
+ // Forward event to all views between startIndex and endIndex,
+ // and leave out all views in the hole.
+ for (int i = startIndex; i <= endIndex; i++)
+ {
+ // Skip newly added child views.
+ if (! (i >= startAdded && i <= endAdded))
{
- // Skip newly added child views.
- if (index >= 0 && i >= index && i < (index+addLength))
- continue;
View child = getView(i);
- forwardUpdateToView(child, ev, shape, vf);
+ if (child != null)
+ {
+ Shape childAlloc = getChildAllocation(i, shape);
+ forwardUpdateToView(child, ev, childAlloc, vf);
+ }
}
}
}
@@ -611,9 +653,46 @@ public abstract class View implements SwingConstants
if (b2 != Position.Bias.Forward && b2 != Position.Bias.Backward)
throw new IllegalArgumentException
("b2 must be either Position.Bias.Forward or Position.Bias.Backward");
- Rectangle s1 = (Rectangle) modelToView(p1, a, b1);
- Rectangle s2 = (Rectangle) modelToView(p2, a, b2);
- return SwingUtilities.computeUnion(s1.x, s1.y, s1.width, s1.height, s2);
+
+ Shape s1 = modelToView(p1, a, b1);
+ // Special case for p2 == end index.
+ Shape s2;
+ if (p2 != getEndOffset())
+ {
+ s2 = modelToView(p2, a, b2);
+ }
+ else
+ {
+ try
+ {
+ s2 = modelToView(p2, a, b2);
+ }
+ catch (BadLocationException ex)
+ {
+ // Assume the end rectangle to be at the right edge of the
+ // view.
+ Rectangle aRect = a instanceof Rectangle ? (Rectangle) a
+ : a.getBounds();
+ s2 = new Rectangle(aRect.x + aRect.width - 1, aRect.y, 1,
+ aRect.height);
+ }
+ }
+
+ // Need to modify the rectangle, so we create a copy in all cases.
+ Rectangle r1 = s1.getBounds();
+ Rectangle r2 = s2 instanceof Rectangle ? (Rectangle) s2
+ : s2.getBounds();
+
+ // For multiline view, let the resulting rectangle span the whole view.
+ if (r1.y != r2.y)
+ {
+ Rectangle aRect = a instanceof Rectangle ? (Rectangle) a
+ : a.getBounds();
+ r1.x = aRect.x;
+ r1.width = aRect.width;
+ }
+
+ return SwingUtilities.computeUnion(r2.x, r2.y, r2.width, r2.height, r1);
}
/**
diff --git a/libjava/classpath/javax/swing/text/html/BRView.java b/libjava/classpath/javax/swing/text/html/BRView.java
new file mode 100644
index 00000000000..5521fed8edf
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/html/BRView.java
@@ -0,0 +1,71 @@
+/* BRView.java -- HTML BR tag view
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.html;
+
+import javax.swing.text.Element;
+
+/**
+ * Handled the HTML BR tag.
+ */
+class BRView
+ extends NullView
+
+{
+ /**
+ * Creates the new BR view.
+ *
+ * @param elem the HTML element, representing the view.
+ */
+ public BRView(Element elem)
+ {
+ super(elem);
+ }
+
+ /**
+ * Always return ForcedBreakWeight for the X_AXIS, BadBreakWeight for the
+ * Y_AXIS.
+ */
+ public int getBreakWeight(int axis, float pos, float len)
+ {
+ if (axis == X_AXIS)
+ return ForcedBreakWeight;
+ else
+ return BadBreakWeight;
+ }
+}
diff --git a/libjava/classpath/javax/swing/text/html/HRuleView.java b/libjava/classpath/javax/swing/text/html/HRuleView.java
new file mode 100644
index 00000000000..3bae5eb8e83
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/html/HRuleView.java
@@ -0,0 +1,189 @@
+/* HRuleView.java -- Horizontal dash in HTML documents.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.html;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import javax.swing.text.Element;
+import javax.swing.text.View;
+
+/**
+ * Represents the long horizontal separating dash that can be inserted into the
+ * HTML documents with HR tag.
+ */
+class HRuleView extends InlineView
+{
+ /**
+ * The null view, indicating, that nothing should be painted ahead the
+ * breaking point.
+ */
+ View nullView;
+
+ /**
+ * The height of the horizontal dash area.
+ */
+ static int HEIGHT = 4;
+
+ /**
+ * The imaginary invisible view that stays after end of line after the
+ * breaking procedure. It occupies on character.
+ */
+ class Beginning extends NullView
+ {
+ /**
+ * The break offset that becomes the views start offset.
+ */
+ int breakOffset;
+
+ /**
+ * Return the end offset that is always one char after the break offset.
+ */
+ public int getEndOffset()
+ {
+ return breakOffset + 1;
+ }
+
+ /**
+ * Return the start offset that has been passed in a constructor.
+ */
+ public int getStartOffset()
+ {
+ return breakOffset;
+ }
+
+ /**
+ * Create the new instance of this view.
+ *
+ * @param element the element (inherited from the HR view)
+ * @param offset the position where the HR view has been broken
+ */
+ public Beginning(Element element, int offset)
+ {
+ super(element);
+ breakOffset = offset;
+ }
+ }
+
+ /**
+ * Creates the new HR view.
+ */
+ public HRuleView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Returns the ForcedBreakWeight for the vertical axis, indicating, the the
+ * view must be broken to be displayed correctly. The horizontal dash is
+ * not breakeable along the Y axis.
+ */
+ public int getBreakWeight(int axis, float pos, float len)
+ {
+ if (axis == X_AXIS && ((getEndOffset() - getStartOffset()) > 1))
+ return ForcedBreakWeight;
+ else
+ return BadBreakWeight;
+ }
+
+ /**
+ * Draws the double line, upped black and the lower light gray.
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ Rectangle bounds = a.getBounds();
+
+ int x = bounds.x;
+ int y = bounds.y;
+
+ int w = bounds.x + bounds.width;
+
+ // We move "half pixel up" from the actual horizontal position -
+ // this will be rounded to the closest actual int co-ordinate.
+ int h = bounds.y + (int) Math.round(bounds.height * 0.5 - 0.5);
+
+ g.setColor(Color.black);
+ g.drawLine(x, y++, w, h++);
+ g.setColor(Color.lightGray);
+ g.drawLine(x, y, w, h);
+ }
+
+ /**
+ * Break the view into this view and the invisible imaginary view that
+ * stays on the end of line that is broken by HR dash. The view is broken
+ * only if its length is longer than one (the two characters are expected
+ * in the initial length).
+ */
+ public View breakView(int axis, int offset, float pos, float len)
+ {
+ if (getEndOffset() - getStartOffset() > 1)
+ return new Beginning(getElement(), offset);
+ else
+ return this;
+ }
+
+ /**
+ * Returns the width of the container for the horizontal axis and the
+ * thickness of the dash area for the vertical axis.
+ */
+ public float getMaximumSpan(int axis)
+ {
+ if (axis == X_AXIS)
+ {
+ Component container = getContainer();
+ if (container != null)
+ return getContainer().getWidth();
+ else
+ return 640;
+ }
+ else
+ return HEIGHT;
+ }
+
+ /**
+ * Returns the same values as {@link #getMaximumSpan(int)}
+ */
+ public float getPreferredSpan(int axis)
+ {
+ return getMaximumSpan(axis);
+ }
+}
diff --git a/libjava/classpath/javax/swing/text/html/HTMLDocument.java b/libjava/classpath/javax/swing/text/html/HTMLDocument.java
index e714a857b61..0bfc338df45 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLDocument.java
+++ b/libjava/classpath/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 parseBuffer = new Vector();
- /** 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)
@@ -1433,14 +1436,14 @@ public class HTMLDocument extends DefaultStyledDocument
// Migrate from the rather htmlAttributeSet to the faster, lighter and
// unchangeable alternative implementation.
AttributeSet copy = a.copyAttributes();
-
- // TODO: Figure out why we must always insert this single character
- // (otherwise the element does not appear). Either fix or add explaining
- // comment or at least report a normal bug.
- DefaultStyledDocument.ElementSpec spec;
- spec = new DefaultStyledDocument.ElementSpec(copy,
- DefaultStyledDocument.ElementSpec.ContentType,
- new char[] {' '}, 0, 1 );
+
+ // The two spaces are required because some special elements like HR
+ // must be broken. At least two characters are needed to break into the
+ // two parts.
+ DefaultStyledDocument.ElementSpec spec =
+ new DefaultStyledDocument.ElementSpec(copy,
+ DefaultStyledDocument.ElementSpec.ContentType,
+ new char[] {' ', ' '}, 0, 2 );
parseBuffer.add(spec);
}
@@ -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/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
index adda4922d57..5d77be8fdd4 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
+++ b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
@@ -71,6 +71,11 @@ import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import javax.swing.text.html.parser.ParserDelegator;
+/* Move these imports here after javax.swing.text.html to make it compile
+ with jikes. */
+import gnu.javax.swing.text.html.parser.GnuParserDelegator;
+import gnu.javax.swing.text.html.parser.HTML_401Swing;
+
/**
* @author Lillian Angel (langel at redhat dot com)
*/
@@ -557,19 +562,18 @@ public class HTMLEditorKit
else if (tag == HTML.Tag.HEAD)
view = new NullView(element);
else if (tag.equals(HTML.Tag.TABLE))
- view = new HTMLTableView(element);
+ view = new javax.swing.text.html.TableView(element);
else if (tag.equals(HTML.Tag.TD))
view = new ParagraphView(element);
-
+ else if (tag.equals(HTML.Tag.HR))
+ view = new HRuleView(element);
+ else if (tag.equals(HTML.Tag.BR))
+ view = new BRView(element);
/*
else if (tag.equals(HTML.Tag.MENU) || tag.equals(HTML.Tag.DIR)
|| tag.equals(HTML.Tag.UL) || tag.equals(HTML.Tag.OL))
view = new ListView(element);
- else if (tag.equals(HTML.Tag.HR))
- view = new HRuleView(element);
- else if (tag.equals(HTML.Tag.BR))
- view = new BRView(element);
else if (tag.equals(HTML.Tag.INPUT) || tag.equals(HTML.Tag.SELECT)
|| tag.equals(HTML.Tag.TEXTAREA))
view = new FormView(element);
@@ -887,7 +891,9 @@ public class HTMLEditorKit
protected Parser getParser()
{
if (parser == null)
- parser = new ParserDelegator();
+ {
+ parser = new GnuParserDelegator(HTML_401Swing.getInstance());
+ }
return parser;
}
diff --git a/libjava/classpath/javax/swing/text/html/StyleSheet.java b/libjava/classpath/javax/swing/text/html/StyleSheet.java
index 2466a2808fe..d92abde7825 100644
--- a/libjava/classpath/javax/swing/text/html/StyleSheet.java
+++ b/libjava/classpath/javax/swing/text/html/StyleSheet.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.text.html;
+import gnu.javax.swing.text.html.CharacterAttributeTranslator;
+
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
@@ -585,47 +587,15 @@ public class StyleSheet extends StyleContext
}
/**
- * Converst a color string to a color. If it is not found, null is returned.
- *
- * @param color - the color string such as "RED" or "#NNNNNN"
- * @return the Color, or null if not found.
- */
- public Color stringToColor(String color)
- {
- color = color.toLowerCase();
- if (color.equals("black") || color.equals("#000000"))
- return Color.BLACK;
- else if (color.equals("aqua") || color.equals("#00FFFF"))
- return new Color(127, 255, 212);
- else if (color.equals("gray") || color.equals("#808080"))
- return Color.GRAY;
- else if (color.equals("navy") || color.equals("#000080"))
- return new Color(0, 0, 128);
- else if (color.equals("silver") || color.equals("#C0C0C0"))
- return Color.LIGHT_GRAY;
- else if (color.equals("green") || color.equals("#008000"))
- return Color.GREEN;
- else if (color.equals("olive") || color.equals("#808000"))
- return new Color(128, 128, 0);
- else if (color.equals("teal") || color.equals("#008080"))
- return new Color(0, 128, 128);
- else if (color.equals("blue") || color.equals("#0000FF"))
- return Color.BLUE;
- else if (color.equals("lime") || color.equals("#00FF00"))
- return new Color(0, 255, 0);
- else if (color.equals("purple") || color.equals("#800080"))
- return new Color(128, 0, 128);
- else if (color.equals("white") || color.equals("#FFFFFF"))
- return Color.WHITE;
- else if (color.equals("fuchsia") || color.equals("#FF00FF"))
- return Color.MAGENTA;
- else if (color.equals("maroon") || color.equals("#800000"))
- return new Color(128, 0, 0);
- else if (color.equals("Red") || color.equals("#FF0000"))
- return Color.RED;
- else if (color.equals("Yellow") || color.equals("#FFFF00"))
- return Color.YELLOW;
- return null;
+ * Convert the color string represenation into java.awt.Color. The valid
+ * values are like "aqua" , "#00FFFF" or "rgb(1,6,44)".
+ *
+ * @param colorName the color to convert.
+ * @return the matching java.awt.color
+ */
+ public Color stringToColor(String colorName)
+ {
+ return CharacterAttributeTranslator.getColor(colorName);
}
/**
diff --git a/libjava/classpath/javax/swing/text/html/TableView.java b/libjava/classpath/javax/swing/text/html/TableView.java
new file mode 100644
index 00000000000..c2edc8cdd64
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/html/TableView.java
@@ -0,0 +1,137 @@
+/* TableView.java -- A table view for HTML tables
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.html;
+
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+
+/**
+ * A conrete implementation of TableView that renders HTML tables.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+class TableView
+ extends javax.swing.text.TableView
+{
+ /**
+ * Represents a single table row.
+ */
+ public class RowView extends TableRow
+ {
+ /**
+ * Creates a new instance of the <code>RowView</code>.
+ *
+ * @param el the element for which to create a row view
+ */
+ public RowView(Element el)
+ {
+ super(el);
+ }
+
+ /**
+ * Get the associated style sheet from the document.
+ *
+ * @return the associated style sheet.
+ */
+ protected StyleSheet getStyleSheet()
+ {
+ Document d = getElement().getDocument();
+ if (d instanceof HTMLDocument)
+ return ((HTMLDocument) d).getStyleSheet();
+ else
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new HTML table view for the specified element.
+ *
+ * @param el the element for the table view
+ */
+ public TableView(Element el)
+ {
+ super(el);
+ }
+
+ /**
+ * Get the associated style sheet from the document.
+ *
+ * @return the associated style sheet.
+ */
+ protected StyleSheet getStyleSheet()
+ {
+ Document d = getElement().getDocument();
+ if (d instanceof HTMLDocument)
+ return ((HTMLDocument) d).getStyleSheet();
+ else
+ return null;
+ }
+
+ /**
+ * Creates a view for a table row.
+ *
+ * @param el the element that represents the table row
+ * @return a view for rendering the table row
+ * (and instance of {@link RowView}).
+ */
+ protected TableRow createTableRow(Element el)
+ {
+ return new RowView(el);
+ }
+
+ /**
+ * Loads the children of the Table. This completely bypasses the ViewFactory
+ * and creates instances of TableRow instead.
+ *
+ * @param vf ignored
+ */
+ protected void loadChildren(ViewFactory vf)
+ {
+ Element el = getElement();
+ int numChildren = el.getElementCount();
+ View[] rows = new View[numChildren];
+ for (int i = 0; i < numChildren; ++i)
+ {
+ rows[i] = createTableRow(el.getElement(i));
+ }
+ replace(0, getViewCount(), rows);
+ }
+}
diff --git a/libjava/classpath/javax/swing/text/html/parser/ParserDelegator.java b/libjava/classpath/javax/swing/text/html/parser/ParserDelegator.java
index e5d2db4df7c..70636d92923 100644
--- a/libjava/classpath/javax/swing/text/html/parser/ParserDelegator.java
+++ b/libjava/classpath/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/libjava/classpath/javax/swing/text/rtf/RTFParser.java b/libjava/classpath/javax/swing/text/rtf/RTFParser.java
index 4f0f967c117..de1b1c6ff15 100644
--- a/libjava/classpath/javax/swing/text/rtf/RTFParser.java
+++ b/libjava/classpath/javax/swing/text/rtf/RTFParser.java
@@ -140,9 +140,17 @@ class RTFParser
parseHeader();
parseDocument();
- Token t2 = scanner.readToken();
- if (t2.type != Token.RCURLY)
- throw new RTFParseException("expected right curly braces");
+ Token t2 = scanner.peekToken();
+ if (t2.type == Token.RCURLY)
+ {
+ // Eat the token.
+ scanner.readToken();
+ }
+ else
+ {
+ // Ignore this for maximum robustness when file is broken.
+ System.err.println("RTF warning: expected right curly braces");
+ }
}
diff --git a/libjava/classpath/javax/swing/text/rtf/RTFScanner.java b/libjava/classpath/javax/swing/text/rtf/RTFScanner.java
index 3cdd6e8e0b9..060e087eb67 100644
--- a/libjava/classpath/javax/swing/text/rtf/RTFScanner.java
+++ b/libjava/classpath/javax/swing/text/rtf/RTFScanner.java
@@ -71,6 +71,11 @@ class RTFScanner
private StringBuffer buffer;
/**
+ * Lookahead token.
+ */
+ private Token lastToken;
+
+ /**
* Constructs a new RTFScanner without initializing the {@link Reader}.
*/
private RTFScanner()
@@ -120,7 +125,7 @@ class RTFScanner
*
* @throws IOException if the underlying stream has problems
*/
- public Token readToken()
+ private Token readTokenImpl()
throws IOException
{
Token token = null;
@@ -156,6 +161,27 @@ class RTFScanner
return token;
}
+ Token peekToken()
+ throws IOException
+ {
+ lastToken = readTokenImpl();
+ return lastToken;
+ }
+
+ Token readToken()
+ throws IOException
+ {
+ Token token;
+ if (lastToken != null)
+ {
+ token = lastToken;
+ lastToken = null;
+ }
+ else
+ token = readTokenImpl();
+ return token;
+ }
+
/**
* Reads in a control word and optional parameter.
*
diff --git a/libjava/classpath/javax/swing/tree/TreePath.java b/libjava/classpath/javax/swing/tree/TreePath.java
index 93b59b07edf..1c4d78787f4 100644
--- a/libjava/classpath/javax/swing/tree/TreePath.java
+++ b/libjava/classpath/javax/swing/tree/TreePath.java
@@ -174,7 +174,7 @@ public class TreePath implements Serializable
return false;
for (index = 0; index < path.length; index++)
{
- if (!treepath[index].equals(path[index]))
+ if (!path[index].equals(treepath[index]))
return false;
}
diff --git a/libjava/classpath/lib/Makefile.am b/libjava/classpath/lib/Makefile.am
index 004a766ddcd..e7e2bd83c79 100644
--- a/libjava/classpath/lib/Makefile.am
+++ b/libjava/classpath/lib/Makefile.am
@@ -8,11 +8,11 @@ sinclude $(JAVA_DEPEND)
## GCJ LOCAL: prune .svn directories
propertydirs := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java javax org META-INF -type d ! -name CVS -print | fgrep -v .svn)
propertyfiles := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java javax org -name \*\.properties -print)
-metafiles := $(shell cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -type f -print | fgrep -v .svn)
+metafiles := $(shell cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -name \*\.in -prune -o -type f -print | fgrep -v .svn)
## END GCJ LOCAL
iconfiles := $(shell cd $(top_srcdir) && $(FIND) gnu/javax/swing/plaf/gtk/icons -name *.png -type f -print)
-compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:$(top_srcdir)/external/relaxngDatatype:.:$(USER_CLASSLIB)
+compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:$(top_srcdir)/external/relaxngDatatype:.:$(USER_CLASSLIB):$(PATH_TO_ESCHER)
# handling source to bytecode compiler programs like gcj, jikes and kjc
if FOUND_GCJ
@@ -46,9 +46,9 @@ COLLECTIONS = collections.jar
collections.jar: mkcollections.pl
./mkcollections.pl $(top_srcdir)
if FOUND_GCJ
- $(GCJ) -C `$(FIND) $(COLLECTIONS_PREFIX) -name '*' -type f -print`
+ $(GCJ) -C `$(FIND) $(COLLECTIONS_PREFIX) -name '*.java' -type f -print`
else
- $(JAVAC) `$(FIND) $(COLLECTIONS_PREFIX) -name '*' -type f -print`
+ $(JAVAC) `$(FIND) $(COLLECTIONS_PREFIX) -name '*.java' -type f -print`
endif
if test "$(FASTJAR)" != ""; then \
$(FASTJAR) cf $@ $(COLLECTIONS_PREFIX); \
@@ -77,6 +77,7 @@ install-data-local: genclasses compile-classes
cp -R java $(DESTDIR)$(pkgdatadir)
cp -R javax $(DESTDIR)$(pkgdatadir)
cp -R org $(DESTDIR)$(pkgdatadir)
+ cp -R sun $(DESTDIR)$(pkgdatadir)
cp -R META-INF $(DESTDIR)$(pkgdatadir)
# FIXME - should mimic doc/api/Makefile.am instead...
@@ -85,6 +86,7 @@ uninstall-local:
rm -rf $(DESTDIR)$(pkgdatadir)/java
rm -rf $(DESTDIR)$(pkgdatadir)/javax
rm -rf $(DESTDIR)$(pkgdatadir)/org
+ rm -rf $(DESTDIR)$(pkgdatadir)/sun
rm -rf $(DESTDIR)$(pkgdatadir)/META-INF
endif # INSTALL_CLASS_FILES
@@ -99,8 +101,8 @@ glibj.zip:
else
glibj.zip: classes compile-classes resources
- if test "$(ZIP)" != ""; then $(ZIP) -r -D glibj.zip gnu java javax org META-INF > /dev/null; fi
- if test "$(FASTJAR)" != ""; then $(FASTJAR) cf glibj.zip gnu java javax org META-INF; fi
+ if test "$(ZIP)" != ""; then $(ZIP) -r -D glibj.zip gnu java javax org sun META-INF > /dev/null; fi
+ if test "$(FASTJAR)" != ""; then $(FASTJAR) cf glibj.zip gnu java javax org sun META-INF; fi
endif # USE_PREBUILT_GLIBJ_ZIP
@@ -167,11 +169,12 @@ compile-classes: classes $(JAVA_SRCS) Makefile
touch compile-classes
endif
-EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
+EXTRA_DIST = standard.omit.in mkcollections.pl.in Makefile.gcj split-for-gcj.sh
CLEANFILES = compile-classes resources classes \
- glibj.zip classes.1 classes.2 \
+ glibj.zip classes.1 classes.2 Makefile.deps \
$(top_builddir)/gnu/java/locale/LocaleData.java \
$(JAVA_DEPEND)
+DISTCLEANFILES = standard.omit
clean-local:
-rm -rf gnu
@@ -179,16 +182,17 @@ clean-local:
-rm -rf javax
-rm -rf org
-rm -rf com
+ -rm -rf sun
-rm -rf META-INF
-rm -rf lists
- -rm -f Makefile.deps
dist-hook:
mkdir -p $(distdir)
- cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org $(top_srcdir)/vm $(top_srcdir)/resource $(distdir)/..
+ cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org $(top_srcdir)/sun $(top_srcdir)/vm $(top_srcdir)/resource $(distdir)/..
# Delete not wanted files.
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm $(distdir)/../resource -name CVS -print | xargs rm -fr
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm $(distdir)/../resource -name .cvsignore -print | xargs rm -f
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm -name class-dependencies.conf -print | xargs rm -f
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm $(distdir)/../resource -name CVS -print | xargs rm -fr
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm $(distdir)/../resource -name .cvsignore -print | xargs rm -f
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm -name class-dependencies.conf -print | xargs rm -f
rm -f $(distdir)/../gnu/classpath/Configuration.java
+ rm -f $(distdir)/../gnu/java/security/Configuration.java
rm -f $(distdir)/../gnu/java/locale/LocaleData.java
diff --git a/libjava/classpath/lib/Makefile.in b/libjava/classpath/lib/Makefile.in
index 00594b55607..90372967612 100644
--- a/libjava/classpath/lib/Makefile.in
+++ b/libjava/classpath/lib/Makefile.in
@@ -89,6 +89,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -109,6 +111,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -139,6 +142,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -189,6 +196,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -209,6 +217,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -276,9 +286,9 @@ vm_classes = @vm_classes@
JAVA_DEPEND = java.dep
propertydirs := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java javax org META-INF -type d ! -name CVS -print | fgrep -v .svn)
propertyfiles := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java javax org -name \*\.properties -print)
-metafiles := $(shell cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -type f -print | fgrep -v .svn)
+metafiles := $(shell cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -name \*\.in -prune -o -type f -print | fgrep -v .svn)
iconfiles := $(shell cd $(top_srcdir) && $(FIND) gnu/javax/swing/plaf/gtk/icons -name *.png -type f -print)
-compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:$(top_srcdir)/external/relaxngDatatype:.:$(USER_CLASSLIB)
+compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:$(top_srcdir)/external/relaxngDatatype:.:$(USER_CLASSLIB):$(PATH_TO_ESCHER)
@FOUND_ECJ_TRUE@@FOUND_GCJX_FALSE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE@@FOUND_KJC_FALSE@JAVAC = $(ECJ) -source 1.4 -encoding UTF-8 -warn:-deprecation,serial,unused -proceedOnError -bootclasspath '' -classpath $(compile_classpath) -d . @classes
@FOUND_GCJX_TRUE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE@@FOUND_KJC_FALSE@JAVAC = $(GCJX) -g -encoding UTF-8 -classpath .:$(USER_CLASSLIB) -d . @classes
@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE@@FOUND_KJC_TRUE@JAVAC = $(KJC) -classpath .:$(USER_CLASSLIB) -d . @classes
@@ -289,12 +299,13 @@ compile_classpath = $(vm_classes):$(top_srcdir):$(top_srcdir)/external/w3c_dom:$
JAVAH = $(USER_JAVAH) -jni -classpath .:$(USER_CLASSLIB)
@CREATE_COLLECTIONS_TRUE@COLLECTIONS = collections.jar
@BUILD_CLASS_FILES_TRUE@noinst_DATA = genclasses compile-classes resources
-EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
+EXTRA_DIST = standard.omit.in mkcollections.pl.in Makefile.gcj split-for-gcj.sh
CLEANFILES = compile-classes resources classes \
- glibj.zip classes.1 classes.2 \
+ glibj.zip classes.1 classes.2 Makefile.deps \
$(top_builddir)/gnu/java/locale/LocaleData.java \
$(JAVA_DEPEND)
+DISTCLEANFILES = standard.omit
all: all-am
.SUFFIXES:
@@ -405,6 +416,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -473,8 +485,8 @@ sinclude $(JAVA_DEPEND)
@CREATE_COLLECTIONS_TRUE@collections.jar: mkcollections.pl
@CREATE_COLLECTIONS_TRUE@ ./mkcollections.pl $(top_srcdir)
-@CREATE_COLLECTIONS_TRUE@@FOUND_GCJ_TRUE@ $(GCJ) -C `$(FIND) $(COLLECTIONS_PREFIX) -name '*' -type f -print`
-@CREATE_COLLECTIONS_TRUE@@FOUND_GCJ_FALSE@ $(JAVAC) `$(FIND) $(COLLECTIONS_PREFIX) -name '*' -type f -print`
+@CREATE_COLLECTIONS_TRUE@@FOUND_GCJ_TRUE@ $(GCJ) -C `$(FIND) $(COLLECTIONS_PREFIX) -name '*.java' -type f -print`
+@CREATE_COLLECTIONS_TRUE@@FOUND_GCJ_FALSE@ $(JAVAC) `$(FIND) $(COLLECTIONS_PREFIX) -name '*.java' -type f -print`
@CREATE_COLLECTIONS_TRUE@ if test "$(FASTJAR)" != ""; then \
@CREATE_COLLECTIONS_TRUE@ $(FASTJAR) cf $@ $(COLLECTIONS_PREFIX); \
@CREATE_COLLECTIONS_TRUE@ else \
@@ -487,6 +499,7 @@ sinclude $(JAVA_DEPEND)
@INSTALL_CLASS_FILES_TRUE@ cp -R java $(DESTDIR)$(pkgdatadir)
@INSTALL_CLASS_FILES_TRUE@ cp -R javax $(DESTDIR)$(pkgdatadir)
@INSTALL_CLASS_FILES_TRUE@ cp -R org $(DESTDIR)$(pkgdatadir)
+@INSTALL_CLASS_FILES_TRUE@ cp -R sun $(DESTDIR)$(pkgdatadir)
@INSTALL_CLASS_FILES_TRUE@ cp -R META-INF $(DESTDIR)$(pkgdatadir)
# FIXME - should mimic doc/api/Makefile.am instead...
@@ -495,6 +508,7 @@ sinclude $(JAVA_DEPEND)
@INSTALL_CLASS_FILES_TRUE@ rm -rf $(DESTDIR)$(pkgdatadir)/java
@INSTALL_CLASS_FILES_TRUE@ rm -rf $(DESTDIR)$(pkgdatadir)/javax
@INSTALL_CLASS_FILES_TRUE@ rm -rf $(DESTDIR)$(pkgdatadir)/org
+@INSTALL_CLASS_FILES_TRUE@ rm -rf $(DESTDIR)$(pkgdatadir)/sun
@INSTALL_CLASS_FILES_TRUE@ rm -rf $(DESTDIR)$(pkgdatadir)/META-INF
.PHONY: genclasses
@@ -503,8 +517,8 @@ sinclude $(JAVA_DEPEND)
@USE_PREBUILT_GLIBJ_ZIP_TRUE@ cp $(PATH_TO_GLIBJ_ZIP) .
@USE_PREBUILT_GLIBJ_ZIP_FALSE@glibj.zip: classes compile-classes resources
-@USE_PREBUILT_GLIBJ_ZIP_FALSE@ if test "$(ZIP)" != ""; then $(ZIP) -r -D glibj.zip gnu java javax org META-INF > /dev/null; fi
-@USE_PREBUILT_GLIBJ_ZIP_FALSE@ if test "$(FASTJAR)" != ""; then $(FASTJAR) cf glibj.zip gnu java javax org META-INF; fi
+@USE_PREBUILT_GLIBJ_ZIP_FALSE@ if test "$(ZIP)" != ""; then $(ZIP) -r -D glibj.zip gnu java javax org sun META-INF > /dev/null; fi
+@USE_PREBUILT_GLIBJ_ZIP_FALSE@ if test "$(FASTJAR)" != ""; then $(FASTJAR) cf glibj.zip gnu java javax org sun META-INF; fi
resources: copy-vmresources.sh
if ! [ -e gnu ]; then mkdir gnu; fi
@@ -564,18 +578,19 @@ clean-local:
-rm -rf javax
-rm -rf org
-rm -rf com
+ -rm -rf sun
-rm -rf META-INF
-rm -rf lists
- -rm -f Makefile.deps
dist-hook:
mkdir -p $(distdir)
- cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org $(top_srcdir)/vm $(top_srcdir)/resource $(distdir)/..
+ cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org $(top_srcdir)/sun $(top_srcdir)/vm $(top_srcdir)/resource $(distdir)/..
# Delete not wanted files.
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm $(distdir)/../resource -name CVS -print | xargs rm -fr
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm $(distdir)/../resource -name .cvsignore -print | xargs rm -f
- $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm -name class-dependencies.conf -print | xargs rm -f
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm $(distdir)/../resource -name CVS -print | xargs rm -fr
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm $(distdir)/../resource -name .cvsignore -print | xargs rm -f
+ $(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../sun $(distdir)/../vm -name class-dependencies.conf -print | xargs rm -f
rm -f $(distdir)/../gnu/classpath/Configuration.java
+ rm -f $(distdir)/../gnu/java/security/Configuration.java
rm -f $(distdir)/../gnu/java/locale/LocaleData.java
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/libjava/classpath/lib/copy-vmresources.sh.in b/libjava/classpath/lib/copy-vmresources.sh.in
index 39b3292e740..dbda9de202e 100644
--- a/libjava/classpath/lib/copy-vmresources.sh.in
+++ b/libjava/classpath/lib/copy-vmresources.sh.in
@@ -13,7 +13,7 @@ for p in ${vmdirs}; do
for u in ${dirs}; do
mkdir -p ${destMetaDir}/${u};
done;
- files=`find . -name "CVS" -prune -o -type f -print`;
+ files=`find . -name "CVS" -prune -o -name "*.in" -prune -o -type f -print`;
for u in ${files}; do
cp ${u} ${destMetaDir}/${u};
done
diff --git a/libjava/classpath/lib/gen-classlist.sh.in b/libjava/classpath/lib/gen-classlist.sh.in
index aeba9bfad37..1d38956ddcb 100755
--- a/libjava/classpath/lib/gen-classlist.sh.in
+++ b/libjava/classpath/lib/gen-classlist.sh.in
@@ -18,7 +18,7 @@ echo "Adding java source files from srcdir '@top_srcdir@'."
# We do this because it makes splitting for the gcj build much
# cheaper.
(cd @top_srcdir@
- @FIND@ java javax gnu org -follow -name '*.java' -print |
+ @FIND@ java javax gnu org sun -follow -name '*.java' -print |
sort -r | sed -e 's,/\([^/]*\)$, \1,' |
while read pkg file; do
echo $pkg @top_srcdir@ $pkg/$file
@@ -43,7 +43,7 @@ vm_dirlist=`echo "@vm_classes@" | sed -e 's/:/ /g'`
for dir in $vm_dirlist; do
echo "Adding java source files from VM directory $dir"
(cd $dir
- for subdir in java javax gnu org com; do
+ for subdir in java javax gnu org com sun; do
if test -d $subdir; then
@FIND@ $subdir -name '*.java' -print
fi
@@ -66,7 +66,7 @@ if test ! "${top_builddir}" -ef "@top_srcdir@"; then
fi
-cat @top_srcdir@/lib/$1.omit vm.omit > tmp.omit
+cat $1.omit vm.omit > tmp.omit
for dir in $vm_dirlist; do
if test -f $dir/$1.omit; then
cat $dir/$1.omit >> tmp.omit
diff --git a/libjava/classpath/lib/mkcollections.pl.in b/libjava/classpath/lib/mkcollections.pl.in
index bd00f01f29e..3d2d3c78a14 100755
--- a/libjava/classpath/lib/mkcollections.pl.in
+++ b/libjava/classpath/lib/mkcollections.pl.in
@@ -25,7 +25,8 @@
my $destpath=@COLLECTIONS_PREFIX@;
my $classpath=pop;
my @javalangclasses=qw(UnsupportedOperationException
- Comparable);
+ Comparable
+ Iterable);
my @javautilclasses=qw(AbstractCollection
AbstractList
AbstractMap
diff --git a/libjava/classpath/lib/standard.omit b/libjava/classpath/lib/standard.omit
index a518f7df828..11d05c78161 100644
--- a/libjava/classpath/lib/standard.omit
+++ b/libjava/classpath/lib/standard.omit
@@ -1 +1,2 @@
-../gnu/test/.*$
+gnu/test/.*java$
+gnu/java/awt/peer/x/.*java$
diff --git a/libjava/classpath/lib/standard.omit.in b/libjava/classpath/lib/standard.omit.in
new file mode 100644
index 00000000000..d5437d3bd69
--- /dev/null
+++ b/libjava/classpath/lib/standard.omit.in
@@ -0,0 +1 @@
+gnu/test/.*java$
diff --git a/libjava/classpath/native/Makefile.in b/libjava/classpath/native/Makefile.in
index 386b99b7984..d16a973b192 100644
--- a/libjava/classpath/native/Makefile.in
+++ b/libjava/classpath/native/Makefile.in
@@ -92,6 +92,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -112,6 +114,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -142,6 +145,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -192,6 +199,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -212,6 +220,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/fdlibm/Makefile.in b/libjava/classpath/native/fdlibm/Makefile.in
index d5c2e0608fa..43d7b9c54c1 100644
--- a/libjava/classpath/native/fdlibm/Makefile.in
+++ b/libjava/classpath/native/fdlibm/Makefile.in
@@ -111,6 +111,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -131,6 +133,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -161,6 +164,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -211,6 +218,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -231,6 +239,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jawt/Makefile.in b/libjava/classpath/native/jawt/Makefile.in
index 4a15a208b9e..03aefa77b6c 100644
--- a/libjava/classpath/native/jawt/Makefile.in
+++ b/libjava/classpath/native/jawt/Makefile.in
@@ -111,6 +111,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -131,6 +133,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -161,6 +164,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -211,6 +218,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -231,6 +239,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/Makefile.am b/libjava/classpath/native/jni/Makefile.am
index 64cd35a5156..2b205826c1b 100644
--- a/libjava/classpath/native/jni/Makefile.am
+++ b/libjava/classpath/native/jni/Makefile.am
@@ -20,14 +20,19 @@ if CREATE_QT_PEER_LIBRARIES
CLASSPATH_QT_PEER_DIR = qt-peer
endif
+if CREATE_GCONF_PEER_LIBRARIES
+ CLASSPATH_GCONF_PEER_DIR = gconf-peer
+endif
+
if CREATE_XMLJ_LIBRARY
XMLJDIR = xmlj
endif
SUBDIRS = classpath $(JNIDIRS) \
- $(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR)
+ $(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR) \
+ $(CLASSPATH_GCONF_PEER_DIR)
DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \
- gtk-peer qt-peer xmlj midi-alsa midi-dssi
+ gtk-peer gconf-peer qt-peer xmlj midi-alsa midi-dssi
all-local:
cd $(top_srcdir) && $(SHELL) ./scripts/check_jni_methods.sh
diff --git a/libjava/classpath/native/jni/Makefile.in b/libjava/classpath/native/jni/Makefile.in
index 30e9f37fca6..56d2bf7b472 100644
--- a/libjava/classpath/native/jni/Makefile.in
+++ b/libjava/classpath/native/jni/Makefile.in
@@ -92,6 +92,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -112,6 +114,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -142,6 +145,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -192,6 +199,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -212,6 +220,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -281,12 +291,14 @@ vm_classes = @vm_classes@
@CREATE_DSSI_LIBRARIES_TRUE@DSSIDIR = midi-dssi
@CREATE_GTK_PEER_LIBRARIES_TRUE@GTKDIR = gtk-peer
@CREATE_QT_PEER_LIBRARIES_TRUE@CLASSPATH_QT_PEER_DIR = qt-peer
+@CREATE_GCONF_PEER_LIBRARIES_TRUE@CLASSPATH_GCONF_PEER_DIR = gconf-peer
@CREATE_XMLJ_LIBRARY_TRUE@XMLJDIR = xmlj
SUBDIRS = classpath $(JNIDIRS) \
- $(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR)
+ $(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR) \
+ $(CLASSPATH_GCONF_PEER_DIR)
DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \
- gtk-peer qt-peer xmlj midi-alsa midi-dssi
+ gtk-peer gconf-peer qt-peer xmlj midi-alsa midi-dssi
all: all-recursive
diff --git a/libjava/classpath/native/jni/classpath/Makefile.in b/libjava/classpath/native/jni/classpath/Makefile.in
index 967dd6e8140..b8f83ff2c76 100644
--- a/libjava/classpath/native/jni/classpath/Makefile.in
+++ b/libjava/classpath/native/jni/classpath/Makefile.in
@@ -102,6 +102,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -122,6 +124,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -152,6 +155,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -202,6 +209,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -222,6 +230,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/gconf-peer/GConfNativePeer.c b/libjava/classpath/native/jni/gconf-peer/GConfNativePeer.c
new file mode 100644
index 00000000000..a442226cae6
--- /dev/null
+++ b/libjava/classpath/native/jni/gconf-peer/GConfNativePeer.c
@@ -0,0 +1,598 @@
+/* GConfNativePeer.c -- Implements native methods for class GConfNativePeer
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <jni.h>
+
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gconf/gconf-client.h>
+
+#include "jcl.h"
+
+#include "gnu_java_util_prefs_gconf_GConfNativePeer.h"
+
+/*
+ * Cached id, methods and objects
+ */
+
+/** Reference count */
+static int reference_count = 0;
+
+/** GConfClient backend */
+static GConfClient *client = NULL;
+
+/** java.util.ArrayList class */
+static jclass jlist_class = NULL;
+
+/** java.util.ArrayList constructor id */
+static jmethodID jlist_init_id = NULL;
+
+/** ava.util.ArrayList add id */
+static jmethodID jlist_add_id = NULL;
+
+/* ***** PRIVATE FUNCTIONS DELCARATION ***** */
+
+/**
+ * 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);
+
+/**
+ * Throws a new runtime exception after a failure, with the given message.
+ */
+static void throw_exception (JNIEnv * env, const char *msg);
+
+/**
+ * Throws the given exception after a failure, with the given message.
+ */
+static void
+throw_exception_by_name (JNIEnv * env, const char *name, const char *msg);
+
+/**
+ * Return a reference to a java.util.ArrayList class.
+ */
+static gboolean set_jlist_class (JNIEnv * env);
+
+/**
+ * Builds a new reference to a new java.util.ArrayList instace.
+ * The instance should be freed by the caller after use.
+ */
+static jclass get_jlist_reference (JNIEnv * env, jclass jlist_class);
+
+/* ***** END: PRIVATE FUNCTIONS DELCARATION ***** */
+
+/* ***** NATIVE FUNCTIONS ***** */
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: init_class
+ * Signature: ()V
+ */
+JNIEXPORT void
+JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
+ (JNIEnv *env, jclass clazz)
+{
+ if (reference_count == 0)
+ {
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+ (env, clazz);
+ return;
+ }
+
+ reference_count++;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: init_id_chache
+ * Signature: ()V
+ */
+JNIEXPORT void
+JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)))
+{
+ 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)
+ {
+ /* release the string and throw a runtime exception */
+ throw_exception (env,
+ "Unable to initialize GConfClient in native code\n");
+ return;
+ }
+
+ /* ***** java.util.ArrayList ***** */
+ if (set_jlist_class (env) == FALSE)
+ {
+ throw_exception (env,
+ "Unable to get valid reference to java.util.List in native code\n");
+ return;
+ }
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_gconf_client_all_keys
+ * Signature: (Ljava/lang/String;)Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys
+ (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;
+ GSList *tmp;
+
+ /* java.util.ArrayList */
+ jobject jlist = NULL;
+
+ dir = JCL_jstring_to_cstring (env, node);
+ if (dir == NULL)
+ {
+ 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",
+ err->message);
+ g_error_free (err);
+ err = NULL;
+
+ JCL_free_cstring (env, node, dir);
+ return NULL;
+ }
+
+ jlist = get_jlist_reference (env, jlist_class);
+ if (jlist == NULL)
+ {
+ throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
+ "Unable to get java.util.List reference in native code\n");
+ JCL_free_cstring (env, node, dir);
+ g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
+ g_slist_free (entries);
+ return NULL;
+ }
+
+ tmp = entries;
+ while (tmp != NULL)
+ {
+ const char *_val = gconf_entry_get_key (tmp->data);
+ _val = strrchr (_val, '/');
+ ++_val;
+ (*env)->CallBooleanMethod (env, jlist, jlist_add_id,
+ (*env)->NewStringUTF (env, _val));
+ tmp = g_slist_next (tmp);
+ }
+
+ /* clean up things */
+ JCL_free_cstring (env, node, dir);
+ g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
+ g_slist_free (entries);
+
+ return jlist;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_gconf_client_all_nodes
+ * Signature: (Ljava/lang/String;)Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+ const char *dir = NULL;
+ GError *err = NULL;
+ GSList *entries = NULL;
+ GSList *tmp;
+
+ /* java.util.ArrayList */
+ jobject jlist = NULL;
+
+ dir = JCL_jstring_to_cstring (env, node);
+ if (dir == NULL)
+ {
+ 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",
+ err->message);
+ g_error_free (err);
+ err = NULL;
+ JCL_free_cstring (env, node, dir);
+ return NULL;
+ }
+
+ jlist = get_jlist_reference (env, jlist_class);
+ if (jlist == NULL)
+ {
+ throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
+ "Unable to get java.util.List reference in native code\n");
+ JCL_free_cstring (env, node, dir);
+ g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
+ g_slist_free (entries);
+ return NULL;
+ }
+
+ tmp = entries;
+ while (tmp != NULL)
+ {
+ const char *_val = tmp->data;
+ _val = strrchr (_val, '/');
+ ++_val;
+ (*env)->CallBooleanMethod (env, jlist, jlist_add_id,
+ (*env)->NewStringUTF (env, _val));
+ tmp = g_slist_next (tmp);
+ }
+
+ /* clean up things */
+ JCL_free_cstring (env, node, dir);
+ g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
+ g_slist_free (entries);
+
+ return jlist;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_suggest_sync
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)))
+{
+ 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",
+ err->message);
+ g_error_free (err);
+ err = NULL;
+ }
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_unset
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
+{
+ const char *_key = NULL;
+ gboolean result = JNI_FALSE;
+ GError *err = NULL;
+
+ _key = JCL_jstring_to_cstring (env, key);
+ if (_key == NULL)
+ {
+ return JNI_FALSE;
+ }
+
+ gdk_threads_enter ();
+ result = gconf_client_unset (client, _key, &err);
+ gdk_threads_leave ();
+ if (err != NULL)
+ {
+ result = JNI_FALSE;
+ g_error_free (err);
+ err = NULL;
+ }
+
+ JCL_free_cstring (env, key, _key);
+
+ return result;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_get_string
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key)
+{
+ const char *_key = NULL;
+ const char *_value = NULL;
+ GError *err = NULL;
+ jstring result = NULL;
+
+ _key = JCL_jstring_to_cstring (env, key);
+ if (_key == NULL)
+ {
+ 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)
+ {
+ /* just in case */
+ if (_value != NULL) g_free ((gpointer) _value);
+ g_error_free (err);
+ err = NULL;
+
+ return NULL;
+ }
+
+ /* 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;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_set_string
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)),
+ jstring key, jstring value)
+{
+ const char *_key = NULL;
+ const char *_value = NULL;
+ GError *err = NULL;
+
+ gboolean result = JNI_FALSE;
+
+ /* 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)
+ {
+ 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);
+ err = NULL;
+ result = JNI_FALSE;
+ }
+
+ JCL_free_cstring (env, key, _key);
+ JCL_free_cstring (env, value, _value);
+
+ return (jboolean) result;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_remove_dir
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+ const char *dir = NULL;
+
+ dir = JCL_jstring_to_cstring (env, node);
+ if (dir == NULL)
+ return;
+
+ gdk_threads_enter ();
+ gconf_client_remove_dir (client, dir, NULL);
+ gdk_threads_leave ();
+
+ JCL_free_cstring (env, node, dir);
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_add_dir
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+ const char *dir = NULL;
+
+ dir = JCL_jstring_to_cstring (env, node);
+ if (dir == NULL)
+ 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);
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: gconf_client_dir_exists
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
+{
+ const char *dir = NULL;
+ GError *err = NULL;
+ jboolean value = JNI_FALSE;
+
+ dir = JCL_jstring_to_cstring (env, node);
+ if (dir == NULL)
+ 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;
+
+ JCL_free_cstring (env, node, dir);
+
+ return value;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: finalize_class
+ * Signature: ()V
+ */
+JNIEXPORT void
+JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)))
+{
+ 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);
+
+ jlist_class = NULL;
+ jlist_init_id = NULL;
+ jlist_add_id = NULL;
+
+ return;
+ }
+
+ reference_count--;
+}
+
+/* ***** END: NATIVE FUNCTIONS ***** */
+
+/* ***** PRIVATE FUNCTIONS IMPLEMENTATION ***** */
+
+static void throw_exception (JNIEnv *env, const char *msg)
+{
+ throw_exception_by_name (env, "java/lang/RuntimeException", msg);
+}
+
+static void
+throw_exception_by_name (JNIEnv *env, const char *name, const char *msg)
+{
+ JCL_ThrowException (env, name, msg);
+}
+
+static void init_gconf_client (void)
+{
+ g_type_init ();
+ client = gconf_client_get_default ();
+}
+
+static gboolean set_jlist_class (JNIEnv *env)
+{
+ jclass local_jlist_class = NULL;
+
+ /* gets a reference to the ArrayList class */
+ local_jlist_class = JCL_FindClass (env, "java/util/ArrayList");
+ if (local_jlist_class == NULL)
+ {
+ return FALSE;
+ }
+
+ jlist_class = (*env)->NewGlobalRef (env, local_jlist_class);
+ (*env)->DeleteLocalRef (env, local_jlist_class);
+ if (jlist_class == NULL)
+ {
+ return FALSE;
+ }
+
+ /* and initialize it */
+ jlist_init_id = (*env)->GetMethodID (env, jlist_class, "<init>", "()V");
+ if (jlist_init_id == NULL)
+ {
+ return FALSE;
+ }
+
+ jlist_add_id = (*env)->GetMethodID (env, jlist_class, "add",
+ "(Ljava/lang/Object;)Z");
+ if (jlist_add_id == NULL)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static jobject get_jlist_reference (JNIEnv *env, jclass jlist_class)
+{
+ return (*env)->NewObject (env, jlist_class, jlist_init_id);
+}
+
+/* ***** END: PRIVATE FUNCTIONS IMPLEMENTATION ***** */
diff --git a/libjava/classpath/native/jni/gconf-peer/Makefile.am b/libjava/classpath/native/jni/gconf-peer/Makefile.am
new file mode 100644
index 00000000000..d8821832639
--- /dev/null
+++ b/libjava/classpath/native/jni/gconf-peer/Makefile.am
@@ -0,0 +1,12 @@
+nativeexeclib_LTLIBRARIES = libgconfpeer.la
+
+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@ @GDK_LIBS@
+
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GCONF_CFLAGS@ @GDK_CFLAGS@
diff --git a/libjava/classpath/native/jni/gconf-peer/Makefile.in b/libjava/classpath/native/jni/gconf-peer/Makefile.in
new file mode 100644
index 00000000000..8d53b06dab3
--- /dev/null
+++ b/libjava/classpath/native/jni/gconf-peer/Makefile.in
@@ -0,0 +1,591 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = native/jni/gconf-peer
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+ $(top_srcdir)/m4/acinclude.m4 \
+ $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(nativeexeclibdir)"
+nativeexeclibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
+libgconfpeer_la_DEPENDENCIES = \
+ $(top_builddir)/native/jni/classpath/native_state.lo \
+ $(top_builddir)/native/jni/classpath/jcl.lo
+am_libgconfpeer_la_OBJECTS = GConfNativePeer.lo
+libgconfpeer_la_OBJECTS = $(am_libgconfpeer_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libgconfpeer_la_SOURCES)
+DIST_SOURCES = $(libgconfpeer_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
+BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
+CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
+CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
+CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
+CREATE_COLLECTIONS_FALSE = @CREATE_COLLECTIONS_FALSE@
+CREATE_COLLECTIONS_TRUE = @CREATE_COLLECTIONS_TRUE@
+CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
+CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
+CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
+CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
+CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
+CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
+CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
+CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
+CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
+CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
+CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
+CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
+CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
+CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ = @ECJ@
+EGREP = @EGREP@
+ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@
+ENABLE_LOCAL_SOCKETS_TRUE = @ENABLE_LOCAL_SOCKETS_TRUE@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+FASTJAR = @FASTJAR@
+FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
+FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
+FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
+FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
+FOUND_GCJX_TRUE = @FOUND_GCJX_TRUE@
+FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@
+FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@
+FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@
+FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@
+FOUND_KJC_FALSE = @FOUND_KJC_FALSE@
+FOUND_KJC_TRUE = @FOUND_KJC_TRUE@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCJ = @GCJ@
+GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL_CLASS_FILES_FALSE = @INSTALL_CLASS_FILES_FALSE@
+INSTALL_CLASS_FILES_TRUE = @INSTALL_CLASS_FILES_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_GLIBJ_ZIP_FALSE = @INSTALL_GLIBJ_ZIP_FALSE@
+INSTALL_GLIBJ_ZIP_TRUE = @INSTALL_GLIBJ_ZIP_TRUE@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+JIKES = @JIKES@
+JIKESENCODING = @JIKESENCODING@
+JIKESWARNINGS = @JIKESWARNINGS@
+KJC = @KJC@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@
+REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@
+REMOVE = @REMOVE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+USER_CLASSLIB = @USER_CLASSLIB@
+USER_JAVAH = @USER_JAVAH@
+USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
+USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
+USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
+USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
+USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
+USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
+VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+default_toolkit = @default_toolkit@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+vm_classes = @vm_classes@
+nativeexeclib_LTLIBRARIES = libgconfpeer.la
+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@ @GDK_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GCONF_CFLAGS@ @GDK_CFLAGS@
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu native/jni/gconf-peer/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu native/jni/gconf-peer/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-nativeexeclibLTLIBRARIES: $(nativeexeclib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(nativeexeclibdir)" || $(mkdir_p) "$(DESTDIR)$(nativeexeclibdir)"
+ @list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(nativeexeclibdir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(nativeexeclibdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-nativeexeclibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @set -x; list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(nativeexeclibdir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(nativeexeclibdir)/$$p"; \
+ done
+
+clean-nativeexeclibLTLIBRARIES:
+ -test -z "$(nativeexeclib_LTLIBRARIES)" || rm -f $(nativeexeclib_LTLIBRARIES)
+ @list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgconfpeer.la: $(libgconfpeer_la_OBJECTS) $(libgconfpeer_la_DEPENDENCIES)
+ $(LINK) -rpath $(nativeexeclibdir) $(libgconfpeer_la_LDFLAGS) $(libgconfpeer_la_OBJECTS) $(libgconfpeer_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GConfNativePeer.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(nativeexeclibdir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-nativeexeclibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-nativeexeclibLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-nativeexeclibLTLIBRARIES
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-nativeexeclibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-nativeexeclibLTLIBRARIES install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-info-am \
+ uninstall-nativeexeclibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c b/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c
new file mode 100644
index 00000000000..6dfbfcce4a9
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/GtkDragSourceContextPeer.c
@@ -0,0 +1,256 @@
+/* gtkdragsourcecontextpeer.c -- Native implementation of GtkDragSourceContextPeer
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include "gtkpeer.h"
+#include "GtkDragSourceContextPeer.h"
+
+#include <jni.h>
+#include <gtk/gtk.h>
+
+static GtkWidget * get_widget (GtkWidget *widget);
+
+#define ACTION_COPY 1
+#define ACTION_MOVE 2
+#define ACTION_COPY_OR_MOVE 3
+#define ACTION_LINK 1073741824
+
+#define AWT_DEFAULT_CURSOR 0
+#define AWT_CROSSHAIR_CURSOR 1
+#define AWT_TEXT_CURSOR 2
+#define AWT_WAIT_CURSOR 3
+#define AWT_SW_RESIZE_CURSOR 4
+#define AWT_SE_RESIZE_CURSOR 5
+#define AWT_NW_RESIZE_CURSOR 6
+#define AWT_NE_RESIZE_CURSOR 7
+#define AWT_N_RESIZE_CURSOR 8
+#define AWT_S_RESIZE_CURSOR 9
+#define AWT_W_RESIZE_CURSOR 10
+#define AWT_E_RESIZE_CURSOR 11
+#define AWT_HAND_CURSOR 12
+#define AWT_MOVE_CURSOR 13
+
+GtkWidget *widget;
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_create
+ (JNIEnv *env, jobject obj, jobject comp)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ NSA_SET_GLOBAL_REF (env, obj);
+ NSA_SET_GLOBAL_REF (env, comp);
+
+ ptr = NSA_GET_PTR (env, comp);
+ widget = get_widget (GTK_WIDGET (ptr));
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeSetCursor
+ (JNIEnv *env, jobject obj, jint type)
+{
+ void *ptr;
+ GdkWindow *win;
+ GdkCursorType gdk_cursor_type;
+ GdkCursor *gdk_cursor;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_GLOBAL_REF (env, obj);
+
+ switch (type)
+ {
+ case AWT_CROSSHAIR_CURSOR:
+ gdk_cursor_type = GDK_CROSSHAIR;
+ break;
+ case AWT_TEXT_CURSOR:
+ gdk_cursor_type = GDK_XTERM;
+ break;
+ case AWT_WAIT_CURSOR:
+ gdk_cursor_type = GDK_WATCH;
+ break;
+ case AWT_SW_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_BOTTOM_LEFT_CORNER;
+ break;
+ case AWT_SE_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_BOTTOM_RIGHT_CORNER;
+ break;
+ case AWT_NW_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_TOP_LEFT_CORNER;
+ break;
+ case AWT_NE_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_TOP_RIGHT_CORNER;
+ break;
+ case AWT_N_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_TOP_SIDE;
+ break;
+ case AWT_S_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_BOTTOM_SIDE;
+ break;
+ case AWT_W_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_LEFT_SIDE;
+ break;
+ case AWT_E_RESIZE_CURSOR:
+ gdk_cursor_type = GDK_RIGHT_SIDE;
+ break;
+ case AWT_HAND_CURSOR:
+ gdk_cursor_type = GDK_HAND2;
+ break;
+ case AWT_MOVE_CURSOR:
+ gdk_cursor_type = GDK_FLEUR;
+ break;
+ default:
+ gdk_cursor_type = GDK_LEFT_PTR;
+ }
+
+ win = widget->window;
+ if ((widget->window) == NULL)
+ win = widget->window;
+
+ gdk_cursor = gdk_cursor_new (gdk_cursor_type);
+
+ gdk_window_set_cursor (win, gdk_cursor);
+ gdk_cursor_unref (gdk_cursor);
+
+ gdk_flush();
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_connectSignals
+ (JNIEnv *env, jobject obj, jobject comp)
+{
+ jobject *gref;
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_GLOBAL_REF (env, obj);
+ gref = NSA_GET_GLOBAL_REF (env, comp);
+
+ /* Uncomment when needed:
+ g_signal_connect (G_OBJECT (widget), "drag_motion",
+ G_CALLBACK (drag_motion_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_begin",
+ G_CALLBACK (drag_begin_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_end",
+ G_CALLBACK (drag_end_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_data_get",
+ G_CALLBACK (drag_data_get_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_drop",
+ G_CALLBACK (drag_drop_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_data_delete",
+ G_CALLBACK (drag_data_delete_cb), *gref);
+ g_signal_connect (G_OBJECT (widget), "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), *gref);
+ */
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeStartDrag
+ (JNIEnv *env, jobject obj, jobject img, jint x, jint y, jint act,
+ jstring target)
+{
+ void *ptr;
+ const gchar *data;
+ GtkTargetEntry tar[1];
+ GdkEvent *event;
+ GdkPixbuf *image = NULL;
+ GdkDragContext *context = NULL;
+ GdkDragAction action = GDK_ACTION_DEFAULT;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_GLOBAL_REF (env, obj);
+
+ data = (*env)->GetStringUTFChars (env, target, NULL);
+ tar[0].target = (gchar *) data;
+ event = gdk_event_new (GDK_ALL_EVENTS_MASK);
+
+ switch (act)
+ {
+ case ACTION_COPY:
+ action = GDK_ACTION_COPY;
+ break;
+ case ACTION_MOVE:
+ action = GDK_ACTION_MOVE;
+ break;
+ case ACTION_COPY_OR_MOVE:
+ action = GDK_ACTION_COPY | GDK_ACTION_MOVE;
+ break;
+ case ACTION_LINK:
+ action = GDK_ACTION_LINK;
+ break;
+ default:
+ action = GDK_ACTION_DEFAULT;
+ }
+
+ gtk_drag_highlight (widget);
+ context = gtk_drag_begin (widget,
+ gtk_target_list_new (tar, sizeof (tar) / sizeof (GtkTargetEntry)),
+ action, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, event);
+
+ if (img != NULL)
+ {
+ image = cp_gtk_image_get_pixbuf (env, img);
+ gtk_drag_set_icon_pixbuf (context, image, x, y);
+ }
+
+ gdk_event_free (event);
+ (*env)->ReleaseStringUTFChars (env, target, data);
+
+ gdk_threads_leave ();
+}
+
+static GtkWidget *
+get_widget (GtkWidget *widget)
+{
+ GtkWidget *w;
+
+ if (GTK_IS_EVENT_BOX (widget) || GTK_IS_CONTAINER (widget))
+ w = gtk_bin_get_child (GTK_BIN(widget));
+ else
+ w = widget;
+
+ return w;
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.am b/libjava/classpath/native/jni/gtk-peer/Makefile.am
index eecd1536901..b7e84144e7d 100644
--- a/libjava/classpath/native/jni/gtk-peer/Makefile.am
+++ b/libjava/classpath/native/jni/gtk-peer/Makefile.am
@@ -12,10 +12,8 @@ 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_GtkCheckboxGroupPeer.c \
gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c \
gnu_java_awt_peer_gtk_GtkCheckboxPeer.c \
gnu_java_awt_peer_gtk_GtkChoicePeer.c \
@@ -42,6 +40,7 @@ libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_CairoSurface.c \
gnu_java_awt_peer_gtk_GtkToolkit.c \
gnu_java_awt_peer_gtk_GtkWindowPeer.c \
gnu_java_awt_peer_gtk_GtkVolatileImage.c \
+ GtkDragSourceContextPeer.c \
cairographics2d.h \
gthread-jni.c \
gdkdisplay.h \
diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.in b/libjava/classpath/native/jni/gtk-peer/Makefile.in
index cd004a7df0e..11e9fc0ba0c 100644
--- a/libjava/classpath/native/jni/gtk-peer/Makefile.in
+++ b/libjava/classpath/native/jni/gtk-peer/Makefile.in
@@ -75,10 +75,8 @@ am_libgtkpeer_la_OBJECTS = gnu_java_awt_peer_gtk_CairoSurface.lo \
gnu_java_awt_peer_gtk_GdkPixbufDecoder.lo \
gnu_java_awt_peer_gtk_GdkRobotPeer.lo \
gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.lo \
- gnu_java_awt_peer_gtk_GdkTextLayout.lo \
gnu_java_awt_peer_gtk_GtkButtonPeer.lo \
gnu_java_awt_peer_gtk_GtkCanvasPeer.lo \
- gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.lo \
gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.lo \
gnu_java_awt_peer_gtk_GtkCheckboxPeer.lo \
gnu_java_awt_peer_gtk_GtkChoicePeer.lo \
@@ -104,8 +102,8 @@ am_libgtkpeer_la_OBJECTS = gnu_java_awt_peer_gtk_CairoSurface.lo \
gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \
gnu_java_awt_peer_gtk_GtkToolkit.lo \
gnu_java_awt_peer_gtk_GtkWindowPeer.lo \
- gnu_java_awt_peer_gtk_GtkVolatileImage.lo gthread-jni.lo \
- gtk_jawt.lo
+ gnu_java_awt_peer_gtk_GtkVolatileImage.lo \
+ GtkDragSourceContextPeer.lo gthread-jni.lo gtk_jawt.lo
libgtkpeer_la_OBJECTS = $(am_libgtkpeer_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -153,6 +151,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -173,6 +173,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -203,6 +204,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -253,6 +258,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -273,6 +279,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -351,10 +359,8 @@ 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_GtkCheckboxGroupPeer.c \
gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c \
gnu_java_awt_peer_gtk_GtkCheckboxPeer.c \
gnu_java_awt_peer_gtk_GtkChoicePeer.c \
@@ -381,6 +387,7 @@ libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_CairoSurface.c \
gnu_java_awt_peer_gtk_GtkToolkit.c \
gnu_java_awt_peer_gtk_GtkWindowPeer.c \
gnu_java_awt_peer_gtk_GtkVolatileImage.c \
+ GtkDragSourceContextPeer.c \
cairographics2d.h \
gthread-jni.c \
gdkdisplay.h \
@@ -473,6 +480,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GtkDragSourceContextPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_CairoGraphics2D.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_CairoSurface.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_ComponentGraphics.Plo@am__quote@
@@ -484,10 +492,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkPixbufDecoder.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkRobotPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkTextLayout.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkButtonPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkCanvasPeer.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkCheckboxPeer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkChoicePeer.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
index 5aa1ada4b61..45cf4fbdaca 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
@@ -239,7 +239,6 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix
{
jdouble *native_matrix = NULL;
struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
- g_assert (obj != NULL);
g_assert (gr != NULL);
native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
@@ -263,8 +262,19 @@ 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,
+(JNIEnv *env, jobject obj __attribute__((unused)), jlong pointer,
jobject font,
jfloat x, jfloat y, jint n,
jintArray java_codes,
@@ -278,7 +288,6 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
float *native_positions;
jint i = 0;
- g_assert (obj != NULL);
g_assert (java_codes != NULL);
g_assert (java_positions != NULL);
@@ -306,7 +315,9 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
(*env)->ReleaseFloatArrayElements (env, java_positions, native_positions, 0);
(*env)->ReleaseIntArrayElements (env, java_codes, native_codes, 0);
+ pango_fc_font_lock_face( (PangoFcFont *)pfont->font );
cairo_show_glyphs (gr->cr, glyphs, n);
+ pango_fc_font_unlock_face( (PangoFcFont *)pfont->font );
g_free(glyphs);
}
@@ -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)
@@ -665,6 +709,46 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter
}
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawLine
+(JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
+ jlong pointer, jdouble x1, jdouble y1, jdouble x2, jdouble y2)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_new_path(gr->cr);
+ cairo_move_to(gr->cr, x1, y1);
+ cairo_line_to(gr->cr, x2, y2);
+ cairo_stroke(gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawRect
+(JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
+ jlong pointer, jdouble x, jdouble y, jdouble w, jdouble h)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_new_path(gr->cr);
+ cairo_rectangle(gr->cr, x, y, w, h);
+ cairo_stroke(gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFillRect
+(JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
+ jlong pointer, jdouble x, jdouble y, jdouble w, jdouble h)
+{
+ struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
+ g_assert (gr != NULL);
+
+ cairo_new_path(gr->cr);
+ cairo_rectangle(gr->cr, x, y, w, h);
+ cairo_fill(gr->cr);
+}
+
/************************** FONT STUFF ****************************/
static void
@@ -679,18 +763,19 @@ install_font_peer(cairo_t *cr,
if (pfont->graphics_resource == NULL)
{
- face = pango_ft2_font_get_face (pfont->font);
+ face = pango_fc_font_lock_face( (PangoFcFont *)pfont->font );
g_assert (face != NULL);
ft = cairo_ft_font_face_create_for_ft_face (face, 0);
g_assert (ft != NULL);
cairo_set_font_face (cr, ft);
- cairo_font_face_destroy (ft);
+ /* cairo_font_face_destroy (ft);*/
cairo_set_font_size (cr,
(pango_font_description_get_size (pfont->desc) /
(double)PANGO_SCALE));
ft = cairo_get_font_face (cr);
+ pango_fc_font_unlock_face( (PangoFcFont *)pfont->font );
pfont->graphics_resource = ft;
}
else
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
index d85ba326f00..25163cd9f3e 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
@@ -276,15 +276,52 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative
gdk_threads_leave();
}
+JNIEXPORT jobject JNICALL
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_nativeGrab
+(JNIEnv *env, jclass cls __attribute__((unused)), jobject peer )
+{
+ GdkPixbuf *pixbuf;
+ GdkDrawable *drawable;
+ GdkWindow *win;
+ gint w,h;
+ GtkWidget *widget = NULL;
+ void *ptr = NULL;
+
+ gdk_threads_enter();
+
+ ptr = NSA_GET_PTR (env, peer);
+ g_assert (ptr != NULL);
+
+ widget = GTK_WIDGET (ptr);
+ g_assert (widget != NULL);
+
+ cp_gtk_grab_current_drawable (widget, &drawable, &win);
+ g_assert (drawable != NULL);
+
+ gdk_drawable_get_size ( drawable, &w, &h );
+
+ pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, w, h );
+ gdk_pixbuf_get_from_drawable( pixbuf, drawable, NULL, 0, 0, 0, 0, w, h );
+ g_object_ref( pixbuf );
+ gdk_draw_pixbuf (drawable, NULL, pixbuf,
+ 0, 0, 0, 0,
+ w, h,
+ GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_threads_leave();
+
+ return JCL_NewRawDataObject (env, pixbuf);
+}
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
(JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer,
- jlong img, jint x, jint y, jint w, jint h)
+ jlong img, jint x, jint y, jint w, jint h, jint cx, jint cy, jint cw, jint ch)
{
GdkPixmap *pixmap;
GtkWidget *widget = NULL;
void *ptr = NULL;
GdkGC *gc;
+ GdkRectangle clip;
gdk_threads_enter();
ptr = NSA_GET_PTR (env, peer);
@@ -296,6 +333,13 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
pixmap = JLONG_TO_PTR(GdkPixmap, img);
gc = gdk_gc_new(widget->window);
+
+ clip.x = cx;
+ clip.y = cy;
+ clip.width = cw;
+ clip.height = ch;
+ gdk_gc_set_clip_rectangle(gc, &clip);
+
gdk_draw_drawable(widget->window,
gc,
pixmap,
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
index 89adcd1e525..6528ad43a2e 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
@@ -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/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
deleted file mode 100644
index 84999879147..00000000000
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/* gnu_java_awt_GdkTextLayout.c
- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
-
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
-
-
-#include <jni.h>
-#include <gtk/gtk.h>
-#include <string.h>
-#include <pango/pango.h>
-#include <pango/pangoft2.h>
-#include <pango/pangofc-font.h>
-#include <freetype/ftglyph.h>
-#include <freetype/ftoutln.h>
-#include "jcl.h"
-#include "native_state.h"
-#include "gdkfont.h"
-#include "gnu_java_awt_peer_gtk_GdkTextLayout.h"
-#include "cairographics2d.h"
-
-struct state_table *cp_gtk_native_text_layout_state_table;
-
-typedef struct gp
-{
- JNIEnv *env;
- jobject obj;
- double px;
- double py;
- double sx;
- double sy;
-} generalpath ;
-
-static void paint_glyph_run(cairo_t *cr, cairo_glyph_t **glyphs,
- gint *n_glyphs, PangoLayoutRun *run);
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState
- (JNIEnv *env, jclass clazz)
-{
- NSA_TEXT_LAYOUT_INIT (env, clazz);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState
- (JNIEnv *env, jobject self)
-{
- struct textlayout *tl;
-
- gdk_threads_enter ();
-
- g_assert(self != NULL);
- tl = g_malloc0 (sizeof (struct textlayout));
- g_assert(tl != NULL);
- tl->pango_layout = pango_layout_new(gdk_pango_context_get());
- g_assert(tl->pango_layout != NULL);
- NSA_SET_TEXT_LAYOUT_PTR (env, self, tl);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText
- (JNIEnv *env, jobject self, jstring text)
-{
- struct textlayout *tl;
- gchar *str = NULL;
- gint len = 0;
-
- g_assert(self != NULL);
- g_assert(text != NULL);
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, self);
- g_assert(tl != NULL);
- g_assert(tl->pango_layout != NULL);
-
- len = (*env)->GetStringUTFLength (env, text);
- str = (gchar *)(*env)->GetStringUTFChars (env, text, NULL);
- g_assert (str != NULL);
-
- gdk_threads_enter ();
-
- pango_layout_set_text (tl->pango_layout, str, len);
-
- (*env)->ReleaseStringUTFChars (env, text, str);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_setFont (JNIEnv *env, jobject obj, jobject font)
-{
- struct textlayout *tl;
- struct peerfont *pf;
-
- g_assert(obj != NULL);
- g_assert(font != NULL);
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
- g_assert(tl != NULL);
- g_assert(tl->pango_layout != NULL);
- pf = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
- g_assert(pf != NULL);
-
- gdk_threads_enter ();
-
- pango_layout_set_font_description(tl->pango_layout, pf->desc);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos
- (JNIEnv *env, jobject self, jint idx, jdoubleArray javaPos)
-{
- struct textlayout *tl;
- PangoRectangle pangoPos;
- jdouble *nativePos;
-
- gdk_threads_enter ();
-
- g_assert(self != NULL);
- g_assert(javaPos != NULL);
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, self);
- g_assert(tl != NULL);
- g_assert(tl->pango_layout != NULL);
-
- g_assert((*env)->GetArrayLength (env, javaPos) == 4);
-
- nativePos = (*env)->GetDoubleArrayElements (env, javaPos, NULL);
-
- pango_layout_index_to_pos (tl->pango_layout, idx, &pangoPos);
-
- nativePos[0] = (jdouble) pangoPos.x;
- nativePos[1] = (jdouble) pangoPos.y;
- nativePos[2] = (jdouble) pangoPos.width;
- nativePos[3] = (jdouble) pangoPos.height;
-
- (*env)->ReleaseDoubleArrayElements (env, javaPos, nativePos, 0);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_getExtents
- (JNIEnv *env, jobject self, jdoubleArray javaInkExtents, jdoubleArray javaLogExtents)
-{
- struct textlayout *tl;
- PangoRectangle pangoInkExtents, pangoLogExtents;
- jdouble *nativeInkExtents, *nativeLogExtents;
-
- gdk_threads_enter ();
-
- g_assert(self != NULL);
- g_assert(javaInkExtents != NULL);
- g_assert(javaLogExtents != NULL);
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, self);
- g_assert(tl != NULL);
- g_assert(tl->pango_layout != NULL);
-
- g_assert((*env)->GetArrayLength (env, javaInkExtents) == 4);
- g_assert((*env)->GetArrayLength (env, javaLogExtents) == 4);
-
- nativeInkExtents = (*env)->GetDoubleArrayElements (env, javaInkExtents, NULL);
- nativeLogExtents = (*env)->GetDoubleArrayElements (env, javaLogExtents, NULL);
-
- pango_layout_get_extents (tl->pango_layout,
- &pangoInkExtents, &pangoLogExtents);
-
- nativeInkExtents[0] = (jdouble) pangoInkExtents.x;
- nativeInkExtents[1] = (jdouble) pangoInkExtents.y;
- nativeInkExtents[2] = (jdouble) pangoInkExtents.width;
- nativeInkExtents[3] = (jdouble) pangoInkExtents.height;
-
- nativeLogExtents[0] = (jdouble) pangoLogExtents.x;
- nativeLogExtents[1] = (jdouble) pangoLogExtents.y;
- nativeLogExtents[2] = (jdouble) pangoLogExtents.width;
- nativeLogExtents[3] = (jdouble) pangoLogExtents.height;
-
- (*env)->ReleaseDoubleArrayElements (env, javaInkExtents, nativeInkExtents, 0);
- (*env)->ReleaseDoubleArrayElements (env, javaLogExtents, nativeLogExtents, 0);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose
- (JNIEnv *env, jobject self)
-{
- struct textlayout *tl;
-
- gdk_threads_enter ();
-
- g_assert(self != NULL);
- tl = (struct textlayout *) NSA_DEL_TEXT_LAYOUT_PTR (env, self);
- g_assert(tl != NULL);
- if (tl->pango_layout != NULL)
- g_object_unref (tl->pango_layout);
- g_free(tl);
-
- gdk_threads_leave ();
-}
-
-/**
- * Draw this textlayout on a cairo surface
- * FIXME: Seems completely broken.
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout
- (JNIEnv *env, jobject obj, jlong cg2d, jfloat x, jfloat y)
-{
- /*
- * FIXME: Some day we expect either cairo or pango will know how to make
- * a pango layout paint to a cairo surface. that day is not yet here.
- */
-
- struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, cg2d);
- cairo_t *cr = gr->cr;
- struct textlayout *tl = NULL;
- PangoLayoutIter *i = NULL;
- PangoLayoutRun *run = NULL;
- cairo_glyph_t *glyphs = NULL;
- gint n_glyphs = 0;
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
-
- g_assert (cr != NULL);
- g_assert (tl != NULL);
- g_assert (tl->pango_layout != NULL);
-
- gdk_threads_enter ();
-
- i = pango_layout_get_iter (tl->pango_layout);
- g_assert (i != NULL);
-
- cairo_translate (cr, x, y);
-
- do
- {
- run = pango_layout_iter_get_run (i);
- if (run != NULL)
- paint_glyph_run (cr, &glyphs, &n_glyphs, run);
- }
- while (pango_layout_iter_next_run (i));
-
- if (glyphs != NULL)
- g_free (glyphs);
-
- cairo_translate (cr, -x, -y);
-
- pango_layout_iter_free (i);
-
- gdk_threads_leave ();
-}
-
-static void
-paint_glyph_run(cairo_t *cr,
- cairo_glyph_t **glyphs,
- gint *n_glyphs,
- PangoLayoutRun *run)
-{
- gint i = 0;
- gint x = 0, y = 0;
-
- g_assert (cr != NULL);
- g_assert (glyphs != NULL);
- g_assert (n_glyphs != NULL);
- g_assert (run != NULL);
-
- if (run->glyphs != NULL && run->glyphs->num_glyphs > 0)
- {
- if (*n_glyphs < run->glyphs->num_glyphs)
- {
- *glyphs = g_realloc(*glyphs,
- (sizeof(cairo_glyph_t)
- * run->glyphs->num_glyphs));
- *n_glyphs = run->glyphs->num_glyphs;
- }
-
- g_assert (*glyphs != NULL);
-
- for (i = 0; i < run->glyphs->num_glyphs; ++i)
- {
- (*glyphs)[i].index = run->glyphs->glyphs[i].glyph;
-
- (*glyphs)[i].x =
- ((double) (x + run->glyphs->glyphs[i].geometry.x_offset))
- / ((double) PANGO_SCALE);
-
- (*glyphs)[i].y =
- ((double) (y + run->glyphs->glyphs[i].geometry.y_offset))
- / ((double) PANGO_SCALE);
-
- x += run->glyphs->glyphs[i].geometry.width;
- }
- cairo_show_glyphs (cr, *glyphs, run->glyphs->num_glyphs);
- }
-}
-
-/* GetOutline code follows ****************************/
-/********* Freetype callback functions *****************************/
-
-static int _moveTo( const FT_Vector* to,
- void *p)
-{
- JNIEnv *env;
- jobject obj;
- jclass cls;
- jmethodID method;
- jvalue values[2];
- generalpath *path = (generalpath *) p;
-
- env = path->env;
- obj = path->obj;
-
- values[0].f = (jfloat)(to->x * path->sx + path->px);
- values[1].f = (jfloat)(to->y * path->sy + path->py);
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "moveTo", "(FF)V");
- (*env)->CallVoidMethodA(env, obj, method, values );
-
- return 0;
-}
-
-static int _lineTo( const FT_Vector* to,
- void *p)
-{
- JNIEnv *env;
- jobject obj;
- jclass cls;
- jmethodID method;
- jvalue values[2];
- generalpath *path = (generalpath *) p;
-
- env = path->env;
- obj = path->obj;
- values[0].f = (jfloat)(to->x * path->sx + path->px);
- values[1].f = (jfloat)(to->y * path->sy + path->py);
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "lineTo", "(FF)V");
- (*env)->CallVoidMethodA(env, obj, method, values );
-
- return 0;
-}
-
-static int _quadTo( const FT_Vector* cp,
- const FT_Vector* to,
- void *p)
-{
- JNIEnv *env;
- jobject obj;
- jclass cls;
- jmethodID method;
- jvalue values[4];
- generalpath *path = (generalpath *) p;
-
- env = path->env;
- obj = path->obj;
- values[0].f = (jfloat)(cp->x * path->sx + path->px);
- values[1].f = (jfloat)(cp->y * path->sy + path->py);
- values[2].f = (jfloat)(to->x * path->sx + path->px);
- values[3].f = (jfloat)(to->y * path->sy + path->py);
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "quadTo", "(FFFF)V");
- (*env)->CallVoidMethodA(env, obj, method, values );
-
- return 0;
-}
-
-static int _curveTo( const FT_Vector* cp1,
- const FT_Vector* cp2,
- const FT_Vector* to,
- void *p)
-{
- JNIEnv *env;
- jobject obj;
- jclass cls;
- jmethodID method;
- jvalue values[6];
- generalpath *path = (generalpath *) p;
-
- env = path->env;
- obj = path->obj;
- values[0].f = (jfloat)(cp1->x * path->sx + path->px);
- values[1].f = (jfloat)(cp1->y * path->sy + path->py);
- values[2].f = (jfloat)(cp2->x * path->sx + path->px);
- values[3].f = (jfloat)(cp2->y * path->sy + path->py);
- values[4].f = (jfloat)(to->x * path->sx + path->px);
- values[5].f = (jfloat)(to->y * path->sy + path->py);
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "curveTo", "(FFFFFF)V");
- (*env)->CallVoidMethodA(env, obj, method, values );
-
- return 0;
-}
-
-
-JNIEXPORT jobject JNICALL
-Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline
- (JNIEnv *env, jobject obj, jobject transform)
-{
- struct textlayout *tl;
- generalpath *path;
- jobject gp;
- GSList *current_run;
- PangoLayoutLine *current_line;
- FT_Outline_Funcs ftCallbacks =
- {
- (FT_Outline_MoveToFunc) _moveTo,
- (FT_Outline_LineToFunc) _lineTo,
- (FT_Outline_ConicToFunc) _quadTo,
- (FT_Outline_CubicToFunc) _curveTo,
- 0,
- 0
- };
- PangoLayoutIter* layoutIterator;
-
- gdk_threads_enter ();
-
- tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
- g_assert(tl != NULL);
- g_assert(tl->pango_layout != NULL);
-
- path = g_malloc0 (sizeof (generalpath));
- g_assert(path != NULL);
- path->env = env;
-
- /* Scaling factors */
- path->sx = PANGO_SCALE/65536.0;
- path->sy = -PANGO_SCALE/65536.0;
-
- { /* create a GeneralPath instance */
- jclass cls;
- jmethodID method;
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "<init>", "()V");
- gp = path->obj = (*env)->NewObject (env, cls, method);
- }
-
- layoutIterator = pango_layout_get_iter (tl->pango_layout);
- g_assert (layoutIterator != NULL);
-
- if (pango_layout_iter_get_line (layoutIterator))
- do
- {
- PangoRectangle line_logical_rect;
- current_line = pango_layout_iter_get_line (layoutIterator);
- pango_layout_iter_get_line_extents (layoutIterator,
- NULL,
- &line_logical_rect);
-
- path->px = line_logical_rect.x/(double)PANGO_SCALE;
- path->py = line_logical_rect.y/(double)PANGO_SCALE;
-
- current_run = current_line->runs;
- while (current_run)
- {
- FT_Face ft_face;
- int index;
- PangoGlyphItem *run = current_run->data;
- PangoGlyphString *glyphs = run->glyphs;
-
- PangoAnalysis *analysis = &run->item->analysis;
- g_assert (analysis != NULL);
- g_assert (analysis->font != NULL);
-
- ft_face = pango_fc_font_lock_face ((PangoFcFont *)analysis->font);
- g_assert (ft_face != NULL);
-
- for (index = 0; index < glyphs->num_glyphs; index++)
- {
- FT_Glyph glyph;
- FT_Error fterror;
- PangoGlyphGeometry pgg = glyphs->glyphs[index].geometry;
-
- fterror = FT_Load_Glyph(ft_face,
- (FT_UInt)(glyphs->glyphs[index].glyph),
- FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP);
- g_assert(fterror == 0);
-
- FT_Get_Glyph (ft_face->glyph, &glyph);
- FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
- &ftCallbacks, path);
- FT_Done_Glyph (glyph);
-
- path->px += pgg.width/(double)PANGO_SCALE;
- }
-
- pango_fc_font_unlock_face ((PangoFcFont *)analysis->font);
- current_run = current_run->next;
- }
- } while (pango_layout_iter_next_line (layoutIterator));
-
- g_free(path);
- gdk_threads_leave ();
-
- if (transform != NULL)
- {
- jclass cls;
- jmethodID method;
-
- cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
- method = (*env)->GetMethodID (env, cls, "transform",
- "(Ljava/awt/geom/AffineTransform;)V");
- (*env)->CallVoidMethod(env, gp, method, transform );
- }
-
- return gp;
-}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
index 191cdda8fcc..9a6f713ba8a 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
@@ -40,9 +40,12 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkCheckboxPeer.h"
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
+#include "jcl.h"
static jmethodID postItemEventID;
-static GtkWidget *combobox_get_widget (GtkWidget *widget);
+static jmethodID addToGroupMapID;
+static GtkWidget *checkbox_get_widget (GtkWidget *widget);
+static void item_toggled_cb (GtkToggleButton *item, jobject peer);
void
cp_gtk_checkbox_init_jni (void)
@@ -55,61 +58,25 @@ cp_gtk_checkbox_init_jni (void)
postItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcheckboxpeer,
"postItemEvent",
"(Ljava/lang/Object;Z)V");
-}
-
-static void item_toggled_cb (GtkToggleButton *item, jobject peer);
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create
- (JNIEnv *env, jobject obj, jobject group)
-{
- GtkWidget *button;
- GtkWidget *eventbox;
-
- gdk_threads_enter ();
-
- NSA_SET_GLOBAL_REF (env, obj);
- eventbox = gtk_event_box_new ();
- if (group == NULL)
- {
- button = gtk_check_button_new_with_label ("");
- gtk_container_add (GTK_CONTAINER (eventbox), button);
- gtk_widget_show (button);
- }
- else
- {
- void *native_group = NSA_GET_PTR (env, group);
- button = gtk_radio_button_new_with_label_from_widget (native_group, "");
- gtk_container_add (GTK_CONTAINER (eventbox), button);
- gtk_widget_show (button);
-
- if (native_group == NULL)
- {
- /* Set the native group so we can use the correct value the
- next time around. FIXME: this doesn't work! */
- NSA_SET_PTR (env, group, button);
- }
- }
-
- NSA_SET_PTR (env, obj, eventbox);
-
- gdk_threads_leave ();
+ addToGroupMapID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcheckboxpeer,
+ "addToGroupMap",
+ "(J)V");
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals
(JNIEnv *env, jobject obj)
{
- void *ptr = NULL;
- jobject *gref = NULL;
+ void *ptr;
+ jobject *gref;
GtkWidget *bin;
gdk_threads_enter ();
ptr = NSA_GET_PTR (env, obj);
gref = NSA_GET_GLOBAL_REF (env, obj);
- bin = combobox_get_widget (GTK_WIDGET (ptr));
+ bin = checkbox_get_widget (GTK_WIDGET (ptr));
/* Checkbox signals */
g_signal_connect (G_OBJECT (bin), "toggled",
@@ -121,46 +88,6 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals
gdk_threads_leave ();
}
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
- (JNIEnv *env, jobject obj, jobject group)
-{
- GtkRadioButton *button;
- void *native_group, *ptr;
- GtkWidget *bin;
-
- gdk_threads_enter ();
-
- ptr = NSA_GET_PTR (env, obj);
- bin = combobox_get_widget (GTK_WIDGET (ptr));
-
- /* FIXME: we can't yet switch between a checkbutton and a
- radiobutton. However, AWT requires this. For now we just
- crash. */
-
- button = GTK_RADIO_BUTTON (bin);
-
- native_group = NSA_GET_PTR (env, group);
- if (native_group == NULL)
- gtk_radio_button_set_group (button, NULL);
- else
- gtk_radio_button_set_group (button,
- gtk_radio_button_get_group
- (GTK_RADIO_BUTTON (native_group)));
-
- /* If the native group wasn't set on the new CheckboxGroup, then set
- it now so that the right thing will happen with the next
- radiobutton. The native state for a CheckboxGroup is a pointer
- to one of the widgets in the group. We are careful to keep this
- always pointing at a live widget; whenever a widget is destroyed
- (or otherwise removed from the group), the CheckboxGroup peer is
- notified. */
- if (native_group == NULL)
- NSA_SET_PTR (env, group, native_group);
-
- gdk_threads_leave ();
-}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkToggleButtonSetActive
(JNIEnv *env, jobject obj, jboolean is_active)
@@ -171,7 +98,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkToggleButtonSetActive
gdk_threads_enter ();
ptr = NSA_GET_PTR (env, obj);
- bin = combobox_get_widget (GTK_WIDGET (ptr));
+ bin = checkbox_get_widget (GTK_WIDGET (ptr));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bin), is_active);
@@ -192,7 +119,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
ptr = NSA_GET_PTR (env, obj);
- button = combobox_get_widget (GTK_WIDGET (ptr));
+ button = checkbox_get_widget (GTK_WIDGET (ptr));
label = gtk_bin_get_child (GTK_BIN(button));
if (!label)
@@ -233,7 +160,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel
c_label = (*env)->GetStringUTFChars (env, label, NULL);
- label_widget = gtk_bin_get_child (GTK_BIN (combobox_get_widget (GTK_WIDGET (ptr))));
+ label_widget = gtk_bin_get_child (GTK_BIN (checkbox_get_widget (GTK_WIDGET (ptr))));
gtk_label_set_text (GTK_LABEL (label_widget), c_label);
(*env)->ReleaseStringUTFChars (env, label, c_label);
@@ -241,6 +168,223 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel
gdk_threads_leave ();
}
+/* A check button is created if we are not part of
+ a group.
+ This function is called when initially creating the
+ button, so an eventbox is created.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createCheckButton
+ (JNIEnv *env, jobject obj)
+{
+ GtkWidget *button;
+ GtkWidget *eventbox;
+
+ gdk_threads_enter ();
+
+ NSA_SET_GLOBAL_REF (env, obj);
+ eventbox = gtk_event_box_new ();
+
+ button = gtk_check_button_new_with_label ("");
+ gtk_container_add (GTK_CONTAINER (eventbox), button);
+ gtk_widget_show (button);
+
+ NSA_SET_PTR (env, obj, eventbox);
+
+ gdk_threads_leave ();
+}
+
+/* A radio button is created if we are part of a group.
+ groupPointer points to the corresponding group. If 0,
+ a new group is created.
+ This function is called when initially creating the
+ button, so an eventbox is created.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_createRadioButton
+ (JNIEnv *env, jobject obj, jlong groupPointer)
+{
+ GtkWidget *button;
+ GtkWidget *eventbox;
+ GSList *native_group = NULL;
+
+ gdk_threads_enter ();
+
+ NSA_SET_GLOBAL_REF (env, obj);
+ eventbox = gtk_event_box_new ();
+
+ if (groupPointer != 0)
+ {
+ native_group = JLONG_TO_PTR (GSList, groupPointer);
+ g_assert (GTK_IS_RADIO_BUTTON (native_group->data));
+ }
+ button = gtk_radio_button_new_with_label (native_group, "");
+
+ if (native_group == NULL)
+ native_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
+ if (g_slist_index (native_group, GTK_RADIO_BUTTON (button)) == -1)
+ {
+ native_group = g_slist_prepend (native_group, GTK_RADIO_BUTTON (button));
+ GTK_RADIO_BUTTON(button)->group = native_group;
+ }
+
+ gtk_container_add (GTK_CONTAINER (eventbox), button);
+ gtk_widget_show (button);
+
+ NSA_SET_PTR (env, obj, eventbox);
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj,
+ addToGroupMapID,
+ PTR_TO_JLONG (native_group));
+
+ gdk_threads_leave ();
+}
+
+/* Add the object to the group pointed to by groupPointer.
+ If groupPointer is 0, create a new group and create
+ a radio button. Otherwise, creating a radio button in an
+ existing group.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_addToGroup
+ (JNIEnv *env, jobject obj, jlong groupPointer)
+{
+ void *ptr;
+ GtkWidget *container;
+ GtkWidget *check_button;
+ GtkWidget *radio_button;
+ const gchar *label;
+ GSList *native_group = NULL;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ container = GTK_WIDGET (ptr);
+ check_button = checkbox_get_widget (container);
+ label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
+ (GTK_BIN (check_button))));
+
+ /* Need to remove the check_button, and replace it with
+ a radio button in a group.
+ */
+ if (groupPointer != 0)
+ {
+ native_group = JLONG_TO_PTR (GSList, groupPointer);
+ g_assert (GTK_IS_RADIO_BUTTON (native_group->data));
+ }
+
+ radio_button = gtk_radio_button_new_with_label (native_group, label);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button)));
+
+ if (native_group == NULL)
+ native_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
+ if (g_slist_index (native_group, GTK_RADIO_BUTTON (radio_button)) == -1)
+ {
+ native_group = g_slist_prepend (native_group, GTK_RADIO_BUTTON (radio_button));
+ GTK_RADIO_BUTTON(radio_button)->group = native_group;
+ }
+
+ gtk_container_remove (GTK_CONTAINER (container), check_button);
+ gtk_container_add (GTK_CONTAINER (container), radio_button);
+ gtk_widget_show (radio_button);
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj,
+ addToGroupMapID,
+ PTR_TO_JLONG (native_group));
+
+ gdk_threads_leave ();
+}
+
+/* Remove the object from the group pointed to by groupPointer.
+ We are removing the radio button and creating a check button.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_removeFromGroup
+ (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ GtkWidget *container;
+ GtkWidget *check_button;
+ GtkWidget *radio_button;
+ GSList *native_group;
+ const gchar *label;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ container = GTK_WIDGET (ptr);
+ radio_button = checkbox_get_widget (container);
+ label = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child
+ (GTK_BIN (radio_button))));
+
+ /* Need to remove the radio_button, and replace it with
+ a check button.
+ */
+ check_button = gtk_check_button_new_with_label (label);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_button)));
+
+ native_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
+ native_group = g_slist_remove (native_group, GTK_RADIO_BUTTON (radio_button));
+
+ if (native_group && ! GTK_IS_RADIO_BUTTON (native_group->data))
+ native_group = NULL;
+
+ GTK_RADIO_BUTTON(radio_button)->group = NULL;
+
+ gtk_container_remove (GTK_CONTAINER (container), radio_button);
+ gtk_container_add (GTK_CONTAINER (container), check_button);
+ gtk_widget_show (check_button);
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj,
+ addToGroupMapID,
+ PTR_TO_JLONG (native_group));
+
+ gdk_threads_leave ();
+}
+
+/* Move the radio button to a new group. If groupPointer is
+ 0, create a new group.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_switchToGroup
+ (JNIEnv *env, jobject obj, jlong groupPointer)
+{
+ void *ptr;
+ GtkWidget *radio_button;
+ GSList *native_group = NULL;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+ radio_button = checkbox_get_widget (GTK_WIDGET (ptr));
+
+ native_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
+ native_group = g_slist_remove (native_group, GTK_RADIO_BUTTON (radio_button));
+ GTK_RADIO_BUTTON(radio_button)->group = NULL;
+
+ if (groupPointer != 0)
+ {
+ native_group = JLONG_TO_PTR (GSList, groupPointer);
+ g_assert (GTK_IS_RADIO_BUTTON (native_group->data));
+ }
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_button), native_group);
+
+ native_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
+ if (g_slist_index (native_group, GTK_RADIO_BUTTON (radio_button)) == -1)
+ {
+ native_group = g_slist_prepend (native_group, GTK_RADIO_BUTTON (radio_button));
+ GTK_RADIO_BUTTON(radio_button)->group = native_group;
+ }
+
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), obj,
+ addToGroupMapID,
+ PTR_TO_JLONG (native_group));
+
+ gdk_threads_leave ();
+}
+
static void
item_toggled_cb (GtkToggleButton *item, jobject peer)
{
@@ -251,7 +395,7 @@ item_toggled_cb (GtkToggleButton *item, jobject peer)
}
static GtkWidget *
-combobox_get_widget (GtkWidget *widget)
+checkbox_get_widget (GtkWidget *widget)
{
GtkWidget *wid;
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index 4cd80a73f1b..39524eea02c 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -339,6 +339,42 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetSensitive
gdk_threads_leave ();
}
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetHasFocus
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ jboolean retval;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ retval = GTK_WIDGET_HAS_FOCUS((GTK_WIDGET (ptr)));
+
+ gdk_threads_leave ();
+
+ return retval;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetCanFocus
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ jboolean retval;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ retval = GTK_WIDGET_CAN_FOCUS((GTK_WIDGET (ptr)));
+
+ gdk_threads_leave ();
+
+ return retval;
+}
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus
(JNIEnv *env, jobject obj)
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index ff3fbe896b9..8805ae7b35b 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -166,6 +166,11 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
result_array = (*env)->NewIntArray (env, (width * height));
+ if (result_array == NULL)
+ {
+ gdk_threads_leave ();
+ return NULL;
+ }
dst = result_array_iter =
(*env)->GetIntArrayElements (env, result_array, NULL);
@@ -184,13 +189,27 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
pixeldata += rowstride;
}
} else {
+
+ /* Add a default alpha value of 0xFF to the pixeldata without alpha
+ information and keep it in the same format as the pixeldata with alpha
+ information. On Little Endian systems: AABBGGRR and on Big Endian
+ systems: RRGGBBAA. */
+
for(i = 0; i < height; i++)
{
for(j = 0; j < width; j++)
- dst[j] = 0xFF000000 |
- (pixeldata[j*3 + 2] & 0xFF) << 16 |
- (pixeldata[j*3 + 1] & 0xFF) << 8 |
- (pixeldata[j*3] & 0xFF);
+
+#ifndef WORDS_BIGENDIAN
+ dst[j] = 0xFF000000
+ | (pixeldata[j*3 + 2] & 0xFF) << 16
+ | (pixeldata[j*3 + 1] & 0xFF) << 8
+ | (pixeldata[j*3] & 0xFF);
+#else
+ dst[j] = (pixeldata[j*3] & 0xFF) << 24
+ | (pixeldata[j*3 + 1] & 0xFF) << 16
+ | (pixeldata[j*3 + 2] & 0xFF) << 8
+ | 0xFF;
+#endif
dst += width;
pixeldata += rowstride;
}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
index 74180a78447..77021ceec0a 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
@@ -147,7 +147,7 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkWidgetModifyFont
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText
+Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setNativeText
(JNIEnv *env, jobject obj, jstring text)
{
const char *str;
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index c966f6331a4..8949fa92762 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -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/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
index d7ef474e002..e391d64ecdd 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
@@ -73,7 +73,8 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init (JNIEnv *env,
pixmap = gdk_pixmap_new( widget->window, width, height, -1 );
}
else
- pixmap = gdk_pixmap_new( NULL, width, height, 16 );
+ pixmap = gdk_pixmap_new( NULL, width, height,
+ gdk_rgb_get_visual()->depth );
gdk_threads_leave();
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index 1c858faf540..3f288af5ce1 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -246,7 +246,11 @@ exception statement from your version. */
#define VK_COMPOSE 65312
#define VK_ALT_GRAPH 65406
#define VK_UNDEFINED 0
+#define VK_BEGIN 65368
+#define VK_CONTEXT_MENU 525
+#define VK_WINDOWS 524
+
#define AWT_KEY_CHAR_UNDEFINED 0
#define AWT_FRAME_STATE_NORMAL 0
@@ -721,14 +725,28 @@ keysym_to_awt_keycode (GdkEventKey *event)
return VK_CUT;
return VK_COPY;
return VK_PASTE;
+ */
+ case GDK_Undo:
return VK_UNDO;
+ case GDK_Redo:
return VK_AGAIN;
+ /*
return VK_FIND;
return VK_PROPS;
return VK_STOP;
return VK_COMPOSE;
+ */
+ case GDK_ISO_Level3_Shift:
return VK_ALT_GRAPH;
+ /*
+ case VK_BEGIN:
*/
+ case GDK_Menu:
+ return VK_CONTEXT_MENU;
+ case GDK_Super_L:
+ case GDK_Super_R:
+ return VK_WINDOWS;
+
default:
return VK_UNDEFINED;
}
@@ -1227,6 +1245,38 @@ 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 jboolean JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowHasFocus
+(JNIEnv *env, jobject obj)
+{
+ void *ptr;
+ jboolean retval;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ retval = gtk_window_has_toplevel_focus (GTK_WINDOW (ptr));
+
+ gdk_threads_leave ();
+ return retval;
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisibleNative
(JNIEnv *env, jobject obj, jboolean visible)
{
@@ -2115,14 +2165,27 @@ cp_gtk_awt_keycode_to_keysym (jint keyCode, jint keyLocation)
case VK_CUT:
case VK_COPY:
case VK_PASTE:
+ */
case VK_UNDO:
+ return GDK_Undo;
case VK_AGAIN:
+ return GDK_Redo;
+ /*
case VK_FIND:
case VK_PROPS:
case VK_STOP:
case VK_COMPOSE:
+ */
case VK_ALT_GRAPH:
+ return GDK_ISO_Level3_Shift;
+ /*
+ case VK_BEGIN:
*/
+ case VK_CONTEXT_MENU:
+ return GDK_Menu;
+ case VK_WINDOWS:
+ return GDK_Super_R;
+
default:
return GDK_VoidSymbol;
}
diff --git a/libjava/classpath/native/jni/java-io/Makefile.in b/libjava/classpath/native/jni/java-io/Makefile.in
index ca4b8a4728f..e997fd26039 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.in
+++ b/libjava/classpath/native/jni/java-io/Makefile.in
@@ -112,6 +112,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -132,6 +134,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -162,6 +165,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -212,6 +219,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -232,6 +240,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/java-io/java_io_VMFile.c b/libjava/classpath/native/jni/java-io/java_io_VMFile.c
index 354df04ed35..7a3fdaf43a8 100644
--- a/libjava/classpath/native/jni/java-io/java_io_VMFile.c
+++ b/libjava/classpath/native/jni/java-io/java_io_VMFile.c
@@ -1,5 +1,5 @@
/* java_io_VMFile.c - Native methods for java.io.File class
- Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -730,3 +730,237 @@ Java_java_io_VMFile_list (JNIEnv * env, jobject obj
return (0);
#endif /* not WITHOUT_FILESYSTEM */
}
+
+/*************************************************************************/
+
+/*
+ * These two methods are used to maintain dynamically allocated
+ * buffers for getCanonicalPath without the overhead of calling
+ * realloc every time a buffer is modified. Buffers are sized
+ * at the smallest multiple of CHUNKSIZ that is greater than or
+ * equal to the desired length. The default CHUNKSIZ is 256,
+ * longer than most paths, so in most cases a getCanonicalPath
+ * will require only one malloc per buffer.
+ */
+
+#define CHUNKLOG 8
+#define CHUNKSIZ (1 << CHUNKLOG)
+
+static int
+nextChunkSize (int size)
+{
+ return ((size >> CHUNKLOG) + ((size & (CHUNKSIZ - 1)) ? 1 : 0)) << CHUNKLOG;
+}
+
+static char *
+maybeGrowBuf (JNIEnv *env, char *buf, int *size, int required)
+{
+ if (required > *size)
+ {
+ *size = nextChunkSize (required);
+ buf = JCL_realloc (env, buf, *size);
+ }
+ return buf;
+}
+
+/*************************************************************************/
+
+/*
+ * This method converts a path to canonical form on GNU/Posix systems.
+ * This involves the removal of redundant separators, references to
+ * "." and "..", and symbolic links.
+ *
+ * The conversion proceeds on a component-by-component basis: symbolic
+ * links and references to ".." are resolved as and when they occur.
+ * This means that if "/foo/bar" is a symbolic link to "/baz" then the
+ * canonical form of "/foo/bar/.." is "/" and not "/foo".
+ *
+ * In order to mimic the behaviour of proprietary JVMs, non-existant
+ * path components are allowed (a departure from the normal GNU system
+ * convention). This means that if "/foo/bar" is a symbolic link to
+ * "/baz", the canonical form of "/non-existant-directory/../foo/bar"
+ * is "/baz".
+ *
+ * Class: java_io_VMFile
+ * Method: toCanonicalForm
+ * Signature: (Ljava/lang/String)Ljava/lang/String
+ */
+
+JNIEXPORT jstring JNICALL
+Java_java_io_VMFile_toCanonicalForm (JNIEnv *env,
+ jclass class __attribute__ ((__unused__)),
+ jstring jpath)
+{
+#ifndef WITHOUT_FILESYSTEM
+ const char *path;
+ char *src, *dst;
+ int srci, dsti;
+ int srcl, dstl;
+ int len;
+ int fschecks;
+#if defined (HAVE_LSTAT) && defined (HAVE_READLINK)
+ struct stat sb;
+#endif /* HAVE_LSTAT && HAVE_READLINK */
+
+ path = JCL_jstring_to_cstring (env, jpath);
+ if (path == NULL)
+ return NULL;
+
+ /* It is the caller's responsibility to ensure the path is absolute. */
+ if (path[0] == 0 || path[0] != '/')
+ {
+ JCL_free_cstring (env, jpath, path);
+ JCL_ThrowException (env, "java/lang/RuntimeException", "Not absolute");
+ return NULL;
+ }
+
+ len = strlen (path);
+ srcl = nextChunkSize (len + 1);
+ src = JCL_malloc (env, srcl);
+ if (src == NULL)
+ {
+ JCL_free_cstring (env, jpath, path);
+ return NULL;
+ }
+ strcpy (src, path);
+ JCL_free_cstring (env, jpath, path);
+ srci = 1;
+
+ dstl = nextChunkSize (2);
+ dst = JCL_malloc (env, dstl);
+ if (dst == NULL)
+ {
+ JCL_free (env, src);
+ return NULL;
+ }
+ dst[0] = '/';
+ dsti = 1;
+
+ fschecks = JNI_TRUE;
+
+ while (src[srci] != '\0')
+ {
+ int tmpi, dsti_save;
+
+ /* Skip slashes. */
+ while (src[srci] == '/')
+ srci++;
+ tmpi = srci;
+ /* Find next slash. */
+ while (src[srci] != '/' && src[srci] != '\0')
+ srci++;
+ if (srci == tmpi)
+ /* We hit the end. */
+ break;
+ len = srci - tmpi;
+
+ /* Handle "." and "..". */
+ if (len == 1 && src[tmpi] == '.')
+ continue;
+ if (len == 2 && src[tmpi] == '.' && src[tmpi + 1] == '.')
+ {
+ while (dsti > 1 && dst[dsti - 1] != '/')
+ dsti--;
+ if (dsti != 1)
+ dsti--;
+ /* Reenable filesystem checking if disabled, as we might
+ * have reversed over whatever caused the problem before.
+ * At least one proprietary JVM has inconsistencies because
+ * it does not do this.
+ */
+ fschecks = JNI_TRUE;
+ continue;
+ }
+
+ /* Handle real path components. */
+ dst = maybeGrowBuf (env,
+ dst, &dstl, dsti + (dsti > 1 ? 1 : 0) + len + 1);
+ if (dst == NULL)
+ {
+ JCL_free (env, src);
+ return NULL;
+ }
+ dsti_save = dsti;
+ if (dsti > 1)
+ dst[dsti++] = '/';
+ strncpy (&dst[dsti], &src[tmpi], len);
+ dsti += len;
+ if (fschecks == JNI_FALSE)
+ continue;
+
+#if defined (HAVE_LSTAT) && defined (HAVE_READLINK)
+ dst[dsti] = '\0';
+ if (lstat (dst, &sb) == 0)
+ {
+ if (S_ISLNK (sb.st_mode))
+ {
+ int tmpl = CHUNKSIZ;
+ char *tmp = JCL_malloc (env, tmpl);
+ if (tmp == NULL)
+ {
+ JCL_free (env, src);
+ JCL_free (env, dst);
+ return NULL;
+ }
+
+ while (1)
+ {
+ tmpi = readlink (dst, tmp, tmpl);
+ if (tmpi < 1)
+ {
+ JCL_free (env, src);
+ JCL_free (env, dst);
+ JCL_free (env, tmp);
+ JCL_ThrowException (env, "java/io/IOException",
+ "readlink failed");
+ return NULL;
+ }
+ if (tmpi < tmpl)
+ break;
+ tmpl += CHUNKSIZ;
+ tmp = JCL_realloc (env, tmp, tmpl);
+ }
+
+ /* Prepend the link's path to src. */
+ tmp = maybeGrowBuf (env,
+ tmp, &tmpl, tmpi + strlen (&src[srci]) + 1);
+ if (tmp == NULL)
+ {
+ JCL_free (env, src);
+ JCL_free (env, dst);
+ return NULL;
+ }
+
+ strcpy (&tmp[tmpi], &src[srci]);
+ JCL_free (env, src);
+ src = tmp;
+ srcl = tmpl;
+ srci = 0;
+
+ /* Either replace or append dst depending on whether the
+ * link is relative or absolute.
+ */
+ dsti = src[0] == '/' ? 1 : dsti_save;
+ }
+ }
+ else
+ {
+ /* Something doesn't exist, or we don't have permission to
+ * read it, or a previous path component is a directory, or
+ * a symlink is looped. Whatever, we can't check the
+ * filesystem any more.
+ */
+ fschecks = JNI_FALSE;
+ }
+#endif /* HAVE_LSTAT && HAVE_READLINK */
+ }
+ dst[dsti] = '\0';
+
+ jpath = (*env)->NewStringUTF (env, dst);
+ JCL_free (env, src);
+ JCL_free (env, dst);
+ return jpath;
+#else /* not WITHOUT_FILESYSTEM */
+ return NULL;
+#endif /* not WITHOUT_FILESYSTEM */
+}
diff --git a/libjava/classpath/native/jni/java-lang/Makefile.in b/libjava/classpath/native/jni/java-lang/Makefile.in
index 70e673b3b31..b75e76815d8 100644
--- a/libjava/classpath/native/jni/java-lang/Makefile.in
+++ b/libjava/classpath/native/jni/java-lang/Makefile.in
@@ -118,6 +118,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -138,6 +140,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -168,6 +171,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -218,6 +225,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -238,6 +246,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c b/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
index 05b0d960e03..d2032279145 100644
--- a/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
+++ b/libjava/classpath/native/jni/java-lang/java_lang_VMSystem.c
@@ -113,11 +113,11 @@ Java_java_lang_VMSystem_setErr (JNIEnv * env,
/*
* Class: java_lang_VMSystem
- * Method: currentTimeMillis
+ * Method: nanoTime
* Signature: ()J
*/
JNIEXPORT jlong JNICALL
-Java_java_lang_VMSystem_currentTimeMillis
+Java_java_lang_VMSystem_nanoTime
(JNIEnv * env __attribute__ ((__unused__)),
jclass thisClass __attribute__ ((__unused__)))
{
@@ -129,8 +129,9 @@ Java_java_lang_VMSystem_currentTimeMillis
(*env)->FatalError (env, "gettimeofday call failed.");
result = (jlong) tp.tv_sec;
- result *= 1000;
- result += (tp.tv_usec / 1000);
+ result *= (jlong)1000000L;
+ result += (jlong)tp.tv_usec;
+ result *= (jlong)1000;
return result;
}
diff --git a/libjava/classpath/native/jni/java-net/Makefile.am b/libjava/classpath/native/jni/java-net/Makefile.am
index e48173a169d..26bb64f73bf 100644
--- a/libjava/classpath/native/jni/java-net/Makefile.am
+++ b/libjava/classpath/native/jni/java-net/Makefile.am
@@ -12,11 +12,12 @@ libjavanet_la_SOURCES = javanet.c \
javanet.h \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
+ java_net_VMURLConnection.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
-libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo $(LIBMAGIC)
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/libjava/classpath/native/jni/java-net/Makefile.in b/libjava/classpath/native/jni/java-net/Makefile.in
index cc47eb3fb73..4e19911a29f 100644
--- a/libjava/classpath/native/jni/java-net/Makefile.in
+++ b/libjava/classpath/native/jni/java-net/Makefile.in
@@ -61,10 +61,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(nativeexeclibdir)"
nativeexeclibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
libjavanet_la_DEPENDENCIES = \
- $(top_builddir)/native/jni/classpath/jcl.lo
+ $(top_builddir)/native/jni/classpath/jcl.lo \
+ $(am__DEPENDENCIES_1)
am__libjavanet_la_SOURCES_DIST = javanet.c javanet.h \
java_net_VMInetAddress.c java_net_VMNetworkInterface.c \
+ java_net_VMURLConnection.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
gnu_java_net_local_LocalSocketImpl.c local.c local.h
@@ -72,7 +75,7 @@ am__libjavanet_la_SOURCES_DIST = javanet.c javanet.h \
@ENABLE_LOCAL_SOCKETS_TRUE@am__objects_1 = gnu_java_net_local_LocalSocketImpl.lo \
@ENABLE_LOCAL_SOCKETS_TRUE@ local.lo
am_libjavanet_la_OBJECTS = javanet.lo java_net_VMInetAddress.lo \
- java_net_VMNetworkInterface.lo \
+ java_net_VMNetworkInterface.lo java_net_VMURLConnection.lo \
gnu_java_net_VMPlainDatagramSocketImpl.lo \
gnu_java_net_VMPlainSocketImpl.lo $(am__objects_1)
libjavanet_la_OBJECTS = $(am_libjavanet_la_OBJECTS)
@@ -122,6 +125,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -142,6 +147,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -172,6 +178,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -222,6 +232,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -242,6 +253,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -316,11 +329,12 @@ libjavanet_la_SOURCES = javanet.c \
javanet.h \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
+ java_net_VMURLConnection.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
-libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo $(LIBMAGIC)
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
AM_CFLAGS = @WARNING_CFLAGS@ @STRICT_WARNING_CFLAGS@ @ERROR_CFLAGS@
@@ -398,6 +412,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_net_local_LocalSocketImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_net_VMInetAddress.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_net_VMNetworkInterface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_net_VMURLConnection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/javanet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c b/libjava/classpath/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
index 3b29001a748..35fb6bcdcc7 100644
--- a/libjava/classpath/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
+++ b/libjava/classpath/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/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c b/libjava/classpath/native/jni/java-net/java_net_VMURLConnection.c
index 16ef43c40ff..52fae0ccb20 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
+++ b/libjava/classpath/native/jni/java-net/java_net_VMURLConnection.c
@@ -1,5 +1,5 @@
-/* gtkcheckboxgrouppeer.c -- Native implementation of GtkCheckboxGroupPeer
- Copyright (C) 2004 Free Software Foundation, Inc.
+/* VMURLConnection.c - native bits for URLConnection
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,53 +35,68 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <config.h>
-#include "gtkpeer.h"
-#include "gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.h"
+#include <java_net_VMURLConnection.h>
-static GtkWidget *comboboxgroup_get_widget (GtkWidget *widget);
+#ifdef HAVE_MAGIC_H
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_dispose
- (JNIEnv *env, jobject obj)
-{
- /* The actual underlying widget is owned by a different class. So
- we just clean up the hash table here. */
- NSA_DEL_PTR (env, obj);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove
- (JNIEnv *env, jobject obj, jobject checkbox)
-{
- GtkRadioButton *button;
- void *ptr;
- GSList *list;
+#include <magic.h>
- gdk_threads_enter ();
+static magic_t cookie;
- ptr = NSA_GET_PTR (env, checkbox);
- button = GTK_RADIO_BUTTON (comboboxgroup_get_widget (GTK_WIDGET (ptr)));
+#endif /* HAVE_MAGIC_H */
- /* Update the group to point to some other widget in the group. We
- have to do this because Gtk doesn't have a separate object to
- represent a radio button's group. */
- for (list = gtk_radio_button_get_group (button); list != NULL;
- list = list->next)
+void
+Java_java_net_VMURLConnection_init (JNIEnv *env __attribute__ ((__unused__)),
+ jclass klass __attribute__ ((__unused__)))
+{
+#ifdef HAVE_MAGIC_H
+ cookie = magic_open (MAGIC_MIME);
+ if (cookie == (magic_t) NULL)
+ return;
+ if (magic_load (cookie, NULL) == -1)
{
- if (list->data != button)
- break;
+ magic_close (cookie);
+ cookie = (magic_t) NULL;
}
-
- NSA_SET_PTR (env, obj, list ? list->data : NULL);
-
- gdk_threads_leave ();
+#endif /* HAVE_MAGIC_H */
}
-static GtkWidget *
-comboboxgroup_get_widget (GtkWidget *widget)
+#ifdef HAVE_MAGIC_H
+jstring
+Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env,
+ jclass klass
+ __attribute__ ((__unused__)),
+ jbyteArray bytes,
+ jint valid)
+{
+ jbyte *elements;
+ const char *result;
+
+ if (cookie == (magic_t) NULL)
+ return NULL;
+
+ elements = (*env)->GetByteArrayElements (env, bytes, NULL);
+ result = magic_buffer (cookie, elements, valid);
+
+ /* The mode we use doesn't matter, since we don't change the array. */
+ (*env)->ReleaseByteArrayElements (env, bytes, elements, JNI_ABORT);
+
+ if (result == NULL)
+ return NULL;
+ return (*env)->NewStringUTF (env, result);
+#else
+jstring
+Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env
+ __attribute__ ((__unused__)),
+ jclass klass
+ __attribute__ ((__unused__)),
+ jbyteArray bytes
+ __attribute__ ((__unused__)),
+ jint valid
+ __attribute__ ((__unused__)))
{
- if (GTK_IS_EVENT_BOX (widget))
- return gtk_bin_get_child (GTK_BIN(widget));
- return widget;
+ return NULL;
+#endif /* HAVE_MAGIC_H */
}
diff --git a/libjava/classpath/native/jni/java-nio/Makefile.am b/libjava/classpath/native/jni/java-nio/Makefile.am
index af564373b43..c3f6caf6209 100644
--- a/libjava/classpath/native/jni/java-nio/Makefile.am
+++ b/libjava/classpath/native/jni/java-nio/Makefile.am
@@ -1,6 +1,7 @@
nativeexeclib_LTLIBRARIES = libjavanio.la
libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \
+ gnu_java_nio_VMChannel.c \
gnu_java_nio_VMSelector.c \
gnu_java_nio_channels_FileChannelImpl.c \
gnu_java_nio_charset_iconv_IconvDecoder.c \
diff --git a/libjava/classpath/native/jni/java-nio/Makefile.in b/libjava/classpath/native/jni/java-nio/Makefile.in
index 5634c92cea5..48becf92728 100644
--- a/libjava/classpath/native/jni/java-nio/Makefile.in
+++ b/libjava/classpath/native/jni/java-nio/Makefile.in
@@ -66,7 +66,7 @@ libjavanio_la_DEPENDENCIES = \
$(top_builddir)/native/jni/classpath/jcl.lo \
$(am__DEPENDENCIES_1)
am_libjavanio_la_OBJECTS = gnu_java_nio_VMPipe.lo \
- gnu_java_nio_VMSelector.lo \
+ gnu_java_nio_VMChannel.lo gnu_java_nio_VMSelector.lo \
gnu_java_nio_channels_FileChannelImpl.lo \
gnu_java_nio_charset_iconv_IconvDecoder.lo \
gnu_java_nio_charset_iconv_IconvEncoder.lo \
@@ -119,6 +119,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -139,6 +141,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -169,6 +172,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -219,6 +226,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -239,6 +247,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -305,6 +315,7 @@ target_vendor = @target_vendor@
vm_classes = @vm_classes@
nativeexeclib_LTLIBRARIES = libjavanio.la
libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \
+ gnu_java_nio_VMChannel.c \
gnu_java_nio_VMSelector.c \
gnu_java_nio_channels_FileChannelImpl.c \
gnu_java_nio_charset_iconv_IconvDecoder.c \
@@ -387,6 +398,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_nio_VMChannel.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_nio_VMPipe.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_nio_VMSelector.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_nio_channels_FileChannelImpl.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c b/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
new file mode 100644
index 00000000000..5571bed27a5
--- /dev/null
+++ b/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
@@ -0,0 +1,525 @@
+/* gnu_java_nio_VMChannel.c -
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#include <config.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <string.h>
+
+#include <jni.h>
+#include <jcl.h>
+
+#include "gnu_java_nio_VMChannel.h"
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+
+#define IO_EXCEPTION "java/io/IOException"
+#define NON_READABLE_CHANNEL_EXCEPTION "java/nio/channels/NonReadableChannelException"
+#define NON_WRITABLE_CHANNEL_EXCEPTION "java/nio/channels/NonWritableChannelException"
+
+/*
+ * Limit to maximum of 16 buffers
+ */
+#define JCL_IOV_MAX 16
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum JCL_buffer_type { DIRECT, ARRAY, UNKNOWN };
+
+struct JCL_buffer
+{
+ enum JCL_buffer_type type;
+ jbyte *ptr;
+ jint offset;
+ jint position;
+ jint limit;
+ jint count;
+};
+
+jmethodID get_method_id(JNIEnv *, jclass, const char *, const char *);
+void JCL_print_buffer(JNIEnv *, struct JCL_buffer *);
+int JCL_init_buffer(JNIEnv *, struct JCL_buffer *, jobject);
+void JCL_release_buffer(JNIEnv *, struct JCL_buffer *, jobject, jint);
+void JCL_cleanup_buffers(JNIEnv *, struct JCL_buffer *, jint, jobjectArray, jint, jlong);
+
+static jfieldID address_fid;
+static jmethodID get_position_mid;
+static jmethodID set_position_mid;
+static jmethodID get_limit_mid;
+static jmethodID set_limit_mid;
+static jmethodID has_array_mid;
+static jmethodID array_mid;
+static jmethodID array_offset_mid;
+
+jmethodID
+get_method_id(JNIEnv *env, jclass clazz, const char *name,
+ const char *sig)
+{
+ jmethodID mid = (*env)->GetMethodID(env, clazz, name, sig);
+ if (mid == NULL)
+ {
+ JCL_ThrowException(env, "java/lang/InternalError", name);
+ return NULL;
+ }
+
+ return mid;
+}
+
+void
+JCL_print_buffer(JNIEnv *env __attribute__((__unused__)), struct JCL_buffer *buf)
+{
+ fprintf(stdout, "Buffer - type: %d, ptr: %p\n", buf->type, buf->ptr);
+ fflush(stdout);
+}
+
+
+int
+JCL_init_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf)
+{
+ jobject address = (*env)->GetObjectField(env, bbuf, address_fid);
+
+ buf->position = (*env)->CallIntMethod(env, bbuf, get_position_mid);
+ buf->limit = (*env)->CallIntMethod(env, bbuf, get_limit_mid);
+ buf->offset = 0;
+ buf->count = 0;
+ buf->type = UNKNOWN;
+
+ if (address != NULL)
+ {
+ buf->ptr = (jbyte *) JCL_GetRawData(env, address);
+ buf->type = DIRECT;
+ (*env)->DeleteLocalRef(env, address);
+ }
+ else
+ {
+ jboolean has_array;
+ has_array = (*env)->CallBooleanMethod(env, bbuf, has_array_mid);
+
+ if (has_array == JNI_TRUE)
+ {
+ jbyteArray arr;
+ buf->offset = (*env)->CallIntMethod(env, bbuf, array_offset_mid);
+ arr = (*env)->CallObjectMethod(env, bbuf, array_mid);
+ buf->ptr = (*env)->GetByteArrayElements(env, arr, 0);
+ buf->type = ARRAY;
+ (*env)->DeleteLocalRef(env, arr);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void
+JCL_release_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf,
+ jint action)
+{
+ jbyteArray arr;
+
+ /* Set the position to the appropriate value */
+ if (buf->count > 0)
+ {
+ jobject bbufTemp;
+ bbufTemp = (*env)->CallObjectMethod(env, bbuf, set_position_mid,
+ buf->position + buf->count);
+ (*env)->DeleteLocalRef(env, bbufTemp);
+ }
+
+ switch (buf->type)
+ {
+ case DIRECT:
+ break;
+ case ARRAY:
+ arr = (*env)->CallObjectMethod(env, bbuf, array_mid);
+ (*env)->ReleaseByteArrayElements(env, arr, buf->ptr, action);
+ (*env)->DeleteLocalRef(env, arr);
+ break;
+ case UNKNOWN:
+ /* TODO: Handle buffers that are not direct or array backed */
+ break;
+ }
+}
+
+void
+JCL_cleanup_buffers(JNIEnv *env,
+ struct JCL_buffer *bi_list,
+ jint vec_len,
+ jobjectArray bbufs,
+ jint offset,
+ jlong num_bytes)
+{
+ jint i;
+
+ /* Update all of the bbufs with the approriate information */
+ for (i = 0; i < vec_len; i++)
+ {
+ struct JCL_buffer* buf;
+ jobject bbuf;
+
+ buf = &bi_list[i];
+ bbuf = (*env)->GetObjectArrayElement(env, bbufs, offset + i);
+
+ if (num_bytes > (buf->limit - buf->position))
+ buf->count = (buf->limit - buf->position);
+ else
+ buf->count = num_bytes;
+
+ num_bytes -= buf->count;
+
+ JCL_release_buffer(env, buf, bbuf, JNI_ABORT);
+ (*env)->DeleteLocalRef(env, bbuf);
+ }
+}
+
+
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env,
+ jclass clazz __attribute__ ((__unused__)))
+{
+ jclass bufferClass = JCL_FindClass(env, "java/nio/Buffer");
+ jclass byteBufferClass = JCL_FindClass(env, "java/nio/ByteBuffer");
+
+ address_fid = (*env)->GetFieldID(env, bufferClass, "address",
+ "Lgnu/classpath/Pointer;");
+ if (address_fid == NULL)
+ {
+ JCL_ThrowException(env, "java/lang/InternalError",
+ "Unable to find internal field");
+ return;
+ }
+
+ get_position_mid = get_method_id(env, bufferClass, "position", "()I");
+ set_position_mid = get_method_id(env, bufferClass, "position",
+ "(I)Ljava/nio/Buffer;");
+ get_limit_mid = get_method_id(env, bufferClass, "limit", "()I");
+ set_limit_mid = get_method_id(env, bufferClass, "limit",
+ "(I)Ljava/nio/Buffer;");
+ has_array_mid = get_method_id(env, byteBufferClass, "hasArray", "()Z");
+ array_mid = get_method_id(env, byteBufferClass, "array", "()[B");
+ array_offset_mid = get_method_id(env, byteBufferClass, "arrayOffset", "()I");
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jboolean blocking)
+{
+ int opts;
+
+ opts = fcntl(fd, F_GETFL);
+ if (opts < 0)
+ {
+ JCL_ThrowException(env, IO_EXCEPTION,
+ "Failed to get flags for file desriptor");
+ return;
+ }
+
+ if (blocking)
+ opts |= O_NONBLOCK;
+ else
+ opts &= ~(O_NONBLOCK);
+
+ opts = fcntl(fd, F_SETFL, opts);
+
+ if (opts < 0)
+ {
+ JCL_ThrowException(env, IO_EXCEPTION,
+ "Failed to set flags for file desriptor");
+ return;
+ }
+}
+
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_read (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobject bbuf)
+{
+ jint len;
+ ssize_t result;
+ struct JCL_buffer buf;
+
+ if (JCL_init_buffer(env, &buf, bbuf) < 0)
+ {
+ /* TODO: Rethrown exception */
+ JCL_ThrowException (env, IO_EXCEPTION, "Buffer initialisation failed");
+ return -1;
+ }
+
+ len = buf.limit - buf.position;
+
+ result = read(fd, &(buf.ptr[buf.position + buf.offset]), len);
+ buf.count = result;
+
+ if (result == 0)
+ result = -1; /* End Of File */
+ else if (result == -1)
+ {
+ buf.count = 0;
+ if (errno == EAGAIN) /* Non-blocking */
+ result = 0;
+ else if (errno == EBADF) /* Bad fd */
+ {
+ JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
+ JCL_ThrowException (env, NON_READABLE_CHANNEL_EXCEPTION,
+ strerror(errno));
+ return -1;
+ }
+ else
+ {
+ JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
+ JCL_ThrowException (env, IO_EXCEPTION, strerror(errno));
+ return -1;
+ }
+ }
+ else
+
+ JCL_release_buffer(env, &buf, bbuf, JNI_COMMIT);
+
+ return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_write (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobject bbuf)
+{
+ jint len;
+ ssize_t result;
+ struct JCL_buffer buf;
+
+ if (JCL_init_buffer(env, &buf, bbuf) < 0)
+ {
+ /* TODO: Rethrown exception */
+ JCL_ThrowException (env, IO_EXCEPTION, "Buffer initialisation failed");
+ return -1;
+ }
+
+ len = buf.limit - buf.position;
+
+ result = write(fd, &(buf.ptr[buf.position + buf.offset]), len);
+ buf.count = result;
+
+ if (result == -1)
+ {
+ if (errno == EAGAIN) /* Non-blocking */
+ result = 0;
+ else
+ {
+ JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
+ JCL_ThrowException(env, IO_EXCEPTION, strerror(errno));
+ return -1;
+ }
+ }
+
+ JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
+
+ return result;
+}
+
+
+/*
+ * Implementation of a scattering read. Will use the appropriate
+ * vector based read call (currently readv on Linux).
+ *
+ * This has a limit to the number of buffers that will be read. It
+ * will not make muliple readv calls. This is to ensure that operations
+ * are atomic. Currently it is limited to 16 buffers. This is for
+ * compatibiliy with Sun.
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobjectArray bbufs,
+ jint offset,
+ jint length)
+{
+ jint i;
+/* jboolean is_error = JNI_FALSE; */
+/* char *error_msg; */
+ struct iovec buffers[JCL_IOV_MAX];
+ struct JCL_buffer bi_list[JCL_IOV_MAX];
+ ssize_t result;
+ jint vec_len = length < JCL_IOV_MAX ? length : JCL_IOV_MAX;
+ jlong bytes_read = 0;
+
+ /* Build the vector of buffers to read into */
+ for (i = 0; i < vec_len; i++)
+ {
+ struct JCL_buffer* buf;
+ jobject bbuf;
+
+ buf = &bi_list[i];
+ bbuf = (*env)->GetObjectArrayElement(env, bbufs, offset + i);
+
+ JCL_init_buffer(env, buf, bbuf);
+
+ buffers[i].iov_base = &(buf->ptr[buf->position + buf->offset]);
+ buffers[i].iov_len = buf->limit - buf->position;
+ (*env)->DeleteLocalRef(env, bbuf);
+ }
+
+ /* Work the scattering magic */
+ result = readv(fd, buffers, vec_len);
+ bytes_read = (jlong) result;
+
+ /* Handle the response */
+ if (result < 0)
+ {
+ if (errno == EAGAIN) /* Non blocking */
+ result = 0;
+ else if (errno == EBADF) /* Bad fd */
+ {
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset, bytes_read);
+ JCL_ThrowException (env, NON_READABLE_CHANNEL_EXCEPTION,
+ strerror(errno));
+ return -1;
+ }
+ else
+ {
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset, bytes_read);
+ JCL_ThrowException (env, IO_EXCEPTION, strerror(errno));
+ return -1;
+ }
+ bytes_read = 0;
+ }
+ else if (result == 0) /* EOF */
+ {
+ result = -1;
+ }
+
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset, bytes_read);
+
+ return (jlong) result;
+}
+
+/*
+ * Implementation of a gathering write. Will use the appropriate
+ * vector based read call (currently readv on Linux).
+ *
+ * This has a limit to the number of buffers that will be read. It
+ * will not make muliple readv calls. This is to ensure that operations
+ * are atomic. Currently it is limited to 16 buffers. This is for
+ * compatibiliy with Sun.
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobjectArray bbufs,
+ jint offset,
+ jint length)
+{
+ int i;
+/* jboolean is_error = JNI_FALSE; */
+/* char *error_msg; */
+ struct iovec buffers[JCL_IOV_MAX];
+ struct JCL_buffer bi_list[JCL_IOV_MAX];
+ ssize_t result;
+ jint vec_len = length < JCL_IOV_MAX ? length : JCL_IOV_MAX;
+ jlong bytes_written;
+
+
+ /* Build the vector of buffers to read into */
+ for (i = 0; i < vec_len; i++)
+ {
+ struct JCL_buffer* buf;
+ jobject bbuf;
+
+ buf = &bi_list[i];
+ bbuf = (*env)->GetObjectArrayElement(env, bbufs, offset + i);
+
+ JCL_init_buffer(env, buf, bbuf);
+
+ buffers[i].iov_base = &(buf->ptr[buf->position + buf->offset]);
+ buffers[i].iov_len = buf->limit - buf->position;
+ (*env)->DeleteLocalRef(env, bbuf);
+ }
+
+ /* Work the gathering magic */
+ result = writev(fd, buffers, vec_len);
+ bytes_written = (jlong) result;
+
+ if (result < 0)
+ {
+ bytes_written = 0;
+ if (errno == EAGAIN) /* Non blocking */
+ result = 0;
+ else if (errno == EBADF) /* Bad fd */
+ {
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset,
+ bytes_written);
+ JCL_ThrowException (env, NON_WRITABLE_CHANNEL_EXCEPTION,
+ strerror(errno));
+ return -1;
+ }
+ else
+ {
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset,
+ bytes_written);
+ JCL_ThrowException (env, IO_EXCEPTION, strerror(errno));
+ return -1;
+ }
+ }
+ else if (result == 0) /* EOF?? Does this happen on a write */
+ result = -1;
+
+ JCL_cleanup_buffers(env, bi_list, vec_len, bbufs, offset, bytes_written);
+ return (jlong) result;
+}
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
index f725cf2a4a7..bfee7e9dc08 100644
--- a/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+++ b/libjava/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c
@@ -60,6 +60,8 @@ Java_java_nio_VMDirectByteBuffer_allocate
return 0;
}
+ memset (buffer, 0, capacity);
+
return JCL_NewRawDataObject (env, buffer);
}
diff --git a/libjava/classpath/native/jni/java-util/Makefile.in b/libjava/classpath/native/jni/java-util/Makefile.in
index 7adf1a4ddaa..a1f3ce3ddc2 100644
--- a/libjava/classpath/native/jni/java-util/Makefile.in
+++ b/libjava/classpath/native/jni/java-util/Makefile.in
@@ -110,6 +110,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -130,6 +132,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -160,6 +163,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -210,6 +217,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -230,6 +238,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/midi-alsa/Makefile.in b/libjava/classpath/native/jni/midi-alsa/Makefile.in
index 90c403db6ab..ce7f2a9eef2 100644
--- a/libjava/classpath/native/jni/midi-alsa/Makefile.in
+++ b/libjava/classpath/native/jni/midi-alsa/Makefile.in
@@ -113,6 +113,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -133,6 +135,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -163,6 +166,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -213,6 +220,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -233,6 +241,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/midi-dssi/Makefile.in b/libjava/classpath/native/jni/midi-dssi/Makefile.in
index af01ba583ad..2fdd7d3cb75 100644
--- a/libjava/classpath/native/jni/midi-dssi/Makefile.in
+++ b/libjava/classpath/native/jni/midi-dssi/Makefile.in
@@ -113,6 +113,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -133,6 +135,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -163,6 +166,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -213,6 +220,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -233,6 +241,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/midi-dssi/dssi_data.h b/libjava/classpath/native/jni/midi-dssi/dssi_data.h
index 8278f7b9e18..27a4e283119 100644
--- a/libjava/classpath/native/jni/midi-dssi/dssi_data.h
+++ b/libjava/classpath/native/jni/midi-dssi/dssi_data.h
@@ -1,5 +1,5 @@
/* dssi_data.h - DSSI data
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,11 +55,6 @@ exception statement from your version. */
1/40th of a second). */
#define EVENT_BUFFER_SIZE 1024
-/* Helper macros for going between pointers and jlongs. */
-#define JLONG_TO_PTR(T,P) ((T *)(long)P)
-#define PTR_TO_JLONG(P) ((jlong)(long)P)
-
-
/* Every DSSI Synthesizer has one of these associated with it. The
Java class sees it as a "long" handle. */
diff --git a/libjava/classpath/native/jni/qt-peer/Makefile.am b/libjava/classpath/native/jni/qt-peer/Makefile.am
index 64ce20fb75d..b123ed36e6c 100644
--- a/libjava/classpath/native/jni/qt-peer/Makefile.am
+++ b/libjava/classpath/native/jni/qt-peer/Makefile.am
@@ -72,7 +72,6 @@ libqtpeer_la_SOURCES = \
qtwindowpeer.cpp \
slotcallbacks.cpp \
slotcallbacks.h
-
libqtpeer_la_LDFLAGS = -avoid-version
BUILT_SOURCES = $(libqtpeer_la_MOC)
diff --git a/libjava/classpath/native/jni/qt-peer/Makefile.in b/libjava/classpath/native/jni/qt-peer/Makefile.in
index 1b253b57226..55a3f7b106c 100644
--- a/libjava/classpath/native/jni/qt-peer/Makefile.in
+++ b/libjava/classpath/native/jni/qt-peer/Makefile.in
@@ -136,6 +136,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -156,6 +158,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -186,6 +189,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -236,6 +243,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -256,6 +264,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/jni/xmlj/Makefile.in b/libjava/classpath/native/jni/xmlj/Makefile.in
index 01f27548860..d0b2f9deb83 100644
--- a/libjava/classpath/native/jni/xmlj/Makefile.in
+++ b/libjava/classpath/native/jni/xmlj/Makefile.in
@@ -112,6 +112,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -132,6 +134,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -162,6 +165,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -212,6 +219,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -232,6 +240,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/plugin/Makefile.in b/libjava/classpath/native/plugin/Makefile.in
index 0560daca20b..ac5da0d0db3 100644
--- a/libjava/classpath/native/plugin/Makefile.in
+++ b/libjava/classpath/native/plugin/Makefile.in
@@ -110,6 +110,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -130,6 +132,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -160,6 +163,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -210,6 +217,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -230,6 +238,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/target/Linux/Makefile.in b/libjava/classpath/native/target/Linux/Makefile.in
index 4b36aa7fabd..819e6b56fb2 100644
--- a/libjava/classpath/native/target/Linux/Makefile.in
+++ b/libjava/classpath/native/target/Linux/Makefile.in
@@ -84,6 +84,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -104,6 +106,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -134,6 +137,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -184,6 +191,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -204,6 +212,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/target/Makefile.in b/libjava/classpath/native/target/Makefile.in
index 5e35e28c22f..59914d9338c 100644
--- a/libjava/classpath/native/target/Makefile.in
+++ b/libjava/classpath/native/target/Makefile.in
@@ -93,6 +93,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -113,6 +115,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -143,6 +146,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -193,6 +200,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -213,6 +221,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/target/generic/Makefile.in b/libjava/classpath/native/target/generic/Makefile.in
index 7b046f6c9f4..76e3d99ec10 100644
--- a/libjava/classpath/native/target/generic/Makefile.in
+++ b/libjava/classpath/native/target/generic/Makefile.in
@@ -84,6 +84,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -104,6 +106,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -134,6 +137,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -184,6 +191,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -204,6 +212,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/native/target/generic/target_generic_network.h b/libjava/classpath/native/target/generic/target_generic_network.h
index 4488ea87635..99bb5d76525 100644
--- a/libjava/classpath/native/target/generic/target_generic_network.h
+++ b/libjava/classpath/native/target/generic/target_generic_network.h
@@ -682,7 +682,8 @@ Systems : all
\
__value.tv_sec = flag / 1000; \
__value.tv_usec = (flag % 1000) * 1000; \
- result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ result = ( (setsockopt(socketDescriptor, SOL_SOCKET, SO_SNDTIMEO, &__value, sizeof(__value)) | \
+ setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVTIMEO, &__value, sizeof(__value))) == 0) ? TARGET_NATIVE_OK : TARGET_NATIVE_ERROR; \
} while (0)
#endif
diff --git a/libjava/classpath/org/omg/CORBA/CompletionStatusHelper.java b/libjava/classpath/org/omg/CORBA/CompletionStatusHelper.java
index 43b6b8c1099..bf1c375324d 100644
--- a/libjava/classpath/org/omg/CORBA/CompletionStatusHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/CurrentHelper.java b/libjava/classpath/org/omg/CORBA/CurrentHelper.java
index 51bd65fc143..f292449ecd1 100644
--- a/libjava/classpath/org/omg/CORBA/CurrentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/DefinitionKindHelper.java b/libjava/classpath/org/omg/CORBA/DefinitionKindHelper.java
index fddbb585a2e..ef7e26725b3 100644
--- a/libjava/classpath/org/omg/CORBA/DefinitionKindHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/IDLTypeHelper.java b/libjava/classpath/org/omg/CORBA/IDLTypeHelper.java
index 635168eb82d..ff874947f5e 100644
--- a/libjava/classpath/org/omg/CORBA/IDLTypeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/NameValuePairHelper.java b/libjava/classpath/org/omg/CORBA/NameValuePairHelper.java
index 5d2430b23bb..f6d93393038 100644
--- a/libjava/classpath/org/omg/CORBA/NameValuePairHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/ObjectHelper.java b/libjava/classpath/org/omg/CORBA/ObjectHelper.java
index 220f2daced2..f662a78880c 100644
--- a/libjava/classpath/org/omg/CORBA/ObjectHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/ParameterModeHelper.java b/libjava/classpath/org/omg/CORBA/ParameterModeHelper.java
index ac17a9235ba..c96ce94ac21 100644
--- a/libjava/classpath/org/omg/CORBA/ParameterModeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/PolicyErrorCodeHelper.java b/libjava/classpath/org/omg/CORBA/PolicyErrorCodeHelper.java
index ab7ac95479a..6feabdcfdb9 100644
--- a/libjava/classpath/org/omg/CORBA/PolicyErrorCodeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/PolicyErrorHelper.java b/libjava/classpath/org/omg/CORBA/PolicyErrorHelper.java
index 49db768cd3b..27b5b465e53 100644
--- a/libjava/classpath/org/omg/CORBA/PolicyErrorHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/PolicyHelper.java b/libjava/classpath/org/omg/CORBA/PolicyHelper.java
index 66fb0aa0868..53b56244eb2 100644
--- a/libjava/classpath/org/omg/CORBA/PolicyHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/PolicyListHelper.java b/libjava/classpath/org/omg/CORBA/PolicyListHelper.java
index 6e4d329b837..da0135c0222 100644
--- a/libjava/classpath/org/omg/CORBA/PolicyListHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/PolicyTypeHelper.java b/libjava/classpath/org/omg/CORBA/PolicyTypeHelper.java
index dadd3a9e6ef..7d5f9bf7656 100644
--- a/libjava/classpath/org/omg/CORBA/PolicyTypeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/ServiceDetailHelper.java b/libjava/classpath/org/omg/CORBA/ServiceDetailHelper.java
index 58000f2c5c7..76fbda610e6 100644
--- a/libjava/classpath/org/omg/CORBA/ServiceDetailHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/ServiceInformationHelper.java b/libjava/classpath/org/omg/CORBA/ServiceInformationHelper.java
index 78a21d1826f..f77378fd79c 100644
--- a/libjava/classpath/org/omg/CORBA/ServiceInformationHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/SetOverrideTypeHelper.java b/libjava/classpath/org/omg/CORBA/SetOverrideTypeHelper.java
index 1fa1ef868d1..fb2c8235a91 100644
--- a/libjava/classpath/org/omg/CORBA/SetOverrideTypeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/StringValueHelper.java b/libjava/classpath/org/omg/CORBA/StringValueHelper.java
index 24e79ce571b..5273f5cfb9d 100644
--- a/libjava/classpath/org/omg/CORBA/StringValueHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/UnionMemberHelper.java b/libjava/classpath/org/omg/CORBA/UnionMemberHelper.java
index c599542fb96..ef69329b7ab 100644
--- a/libjava/classpath/org/omg/CORBA/UnionMemberHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/UnknownUserExceptionHelper.java b/libjava/classpath/org/omg/CORBA/UnknownUserExceptionHelper.java
index e93dc740399..0ca50cb88c2 100644
--- a/libjava/classpath/org/omg/CORBA/UnknownUserExceptionHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/VisibilityHelper.java b/libjava/classpath/org/omg/CORBA/VisibilityHelper.java
index a09e5b6867d..a00f96e140e 100644
--- a/libjava/classpath/org/omg/CORBA/VisibilityHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/WStringValueHelper.java b/libjava/classpath/org/omg/CORBA/WStringValueHelper.java
index 1c63a408e3d..17f23214cf6 100644
--- a/libjava/classpath/org/omg/CORBA/WStringValueHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CORBA/WrongTransactionHelper.java b/libjava/classpath/org/omg/CORBA/WrongTransactionHelper.java
index 5bb5baff2eb..27368a4c03a 100644
--- a/libjava/classpath/org/omg/CORBA/WrongTransactionHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/BindingHelper.java b/libjava/classpath/org/omg/CosNaming/BindingHelper.java
index b5b42077218..86b0770162a 100644
--- a/libjava/classpath/org/omg/CosNaming/BindingHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/BindingIteratorHelper.java b/libjava/classpath/org/omg/CosNaming/BindingIteratorHelper.java
index 64f7b4dfa51..cb17d5748b3 100644
--- a/libjava/classpath/org/omg/CosNaming/BindingIteratorHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/BindingListHelper.java b/libjava/classpath/org/omg/CosNaming/BindingListHelper.java
index 44fe39dcad2..de04989e0b4 100644
--- a/libjava/classpath/org/omg/CosNaming/BindingListHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/BindingTypeHelper.java b/libjava/classpath/org/omg/CosNaming/BindingTypeHelper.java
index 2f0dc71c4ef..8f456ee70da 100644
--- a/libjava/classpath/org/omg/CosNaming/BindingTypeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NameComponentHelper.java b/libjava/classpath/org/omg/CosNaming/NameComponentHelper.java
index 8499edfe66e..8127aa01d9c 100644
--- a/libjava/classpath/org/omg/CosNaming/NameComponentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NameHelper.java b/libjava/classpath/org/omg/CosNaming/NameHelper.java
index 18faf31823b..f66fa4f099d 100644
--- a/libjava/classpath/org/omg/CosNaming/NameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextExtHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextExtHelper.java
index 86bf8c55dfd..aca0e9dfd23 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextExtHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
index cf4029ccfc8..81046074416 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
index 02f8fccb607..c7f3849a0c1 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
index 24c69fcb9b2..06faa2ff940 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
index 503fe22d69a..173bb989eb7 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java
index fb9b091a6a0..48b90c25ab0 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
index 6bf7bd7a6b3..f43111cb20b 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
index 1d0b6049b66..85e391cf8c3 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
index 8f1133602d7..5893332b804 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
index 6333dfcbcd3..a9b802f9549 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
index 442b7db9e63..0be9b75bc0b 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
index 45a42a0ba70..9d44dcbf383 100644
--- a/libjava/classpath/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/AnySeqHelper.java b/libjava/classpath/org/omg/DynamicAny/AnySeqHelper.java
index 60e4e6ea77e..ddf1422ff17 100644
--- a/libjava/classpath/org/omg/DynamicAny/AnySeqHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryHelper.java
index b8e3aafef5b..97b54873fbd 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
index a9f45c4b73c..96dbb5fb63d 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnyHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnyHelper.java
index 73e2d9856a1..a238bf48baa 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnyHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
index 1b5004f072b..0258d358919 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
index b09ab4db863..244a98aa0b8 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynAnySeqHelper.java b/libjava/classpath/org/omg/DynamicAny/DynAnySeqHelper.java
index ec3f0c4815f..66208ea19ee 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynAnySeqHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynArrayHelper.java b/libjava/classpath/org/omg/DynamicAny/DynArrayHelper.java
index f2892c85692..26824d747ae 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynArrayHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynEnumHelper.java b/libjava/classpath/org/omg/DynamicAny/DynEnumHelper.java
index 8db1a20065e..9af2e11948e 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynEnumHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynFixedHelper.java b/libjava/classpath/org/omg/DynamicAny/DynFixedHelper.java
index 84bb59d9f3c..4471bb26b03 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynFixedHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynSequenceHelper.java b/libjava/classpath/org/omg/DynamicAny/DynSequenceHelper.java
index ad30133712e..0aa7cdd2ab9 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynSequenceHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynStructHelper.java b/libjava/classpath/org/omg/DynamicAny/DynStructHelper.java
index 021c5d031a5..c683260f67d 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynStructHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynUnionHelper.java b/libjava/classpath/org/omg/DynamicAny/DynUnionHelper.java
index 8f924c0864e..e868ea41260 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynUnionHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/DynValueHelper.java b/libjava/classpath/org/omg/DynamicAny/DynValueHelper.java
index 026ca499077..ad75bc31fe3 100644
--- a/libjava/classpath/org/omg/DynamicAny/DynValueHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairHelper.java b/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairHelper.java
index a0e5c6b85f9..a9d9edba71a 100644
--- a/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
index ec4f728228f..56e6104eca3 100644
--- a/libjava/classpath/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/NameValuePairHelper.java b/libjava/classpath/org/omg/DynamicAny/NameValuePairHelper.java
index 1e0f52b5946..75bbf9a7433 100644
--- a/libjava/classpath/org/omg/DynamicAny/NameValuePairHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/DynamicAny/NameValuePairSeqHelper.java b/libjava/classpath/org/omg/DynamicAny/NameValuePairSeqHelper.java
index 62481534e1a..018ee7d2d9c 100644
--- a/libjava/classpath/org/omg/DynamicAny/NameValuePairSeqHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/CodecFactoryHelper.java b/libjava/classpath/org/omg/IOP/CodecFactoryHelper.java
index fea0b887bd9..89404f7d584 100644
--- a/libjava/classpath/org/omg/IOP/CodecFactoryHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java b/libjava/classpath/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
index e036dbf1f42..8861e43da5f 100644
--- a/libjava/classpath/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/CodecPackage/FormatMismatchHelper.java b/libjava/classpath/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
index e353be8f9ed..2a9295ae877 100644
--- a/libjava/classpath/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java b/libjava/classpath/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
index 8a93c5895a0..e2a8c905793 100644
--- a/libjava/classpath/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/CodecPackage/TypeMismatchHelper.java b/libjava/classpath/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
index 33951de701f..432e84d24cb 100644
--- a/libjava/classpath/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/ComponentIdHelper.java b/libjava/classpath/org/omg/IOP/ComponentIdHelper.java
index 64fbdfd74f5..35ffd9a69e4 100644
--- a/libjava/classpath/org/omg/IOP/ComponentIdHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/IORHelper.java b/libjava/classpath/org/omg/IOP/IORHelper.java
index 77f18d9b9cd..197e15a1203 100644
--- a/libjava/classpath/org/omg/IOP/IORHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/MultipleComponentProfileHelper.java b/libjava/classpath/org/omg/IOP/MultipleComponentProfileHelper.java
index 6f5156fe223..1c04ec54f9c 100644
--- a/libjava/classpath/org/omg/IOP/MultipleComponentProfileHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/ProfileIdHelper.java b/libjava/classpath/org/omg/IOP/ProfileIdHelper.java
index 2e3c8f08dbf..340fa27d550 100644
--- a/libjava/classpath/org/omg/IOP/ProfileIdHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/ServiceContextHelper.java b/libjava/classpath/org/omg/IOP/ServiceContextHelper.java
index 5693a32357a..d6549fa5405 100644
--- a/libjava/classpath/org/omg/IOP/ServiceContextHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/ServiceContextListHelper.java b/libjava/classpath/org/omg/IOP/ServiceContextListHelper.java
index fa436cbb885..7875db29e1d 100644
--- a/libjava/classpath/org/omg/IOP/ServiceContextListHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/ServiceIdHelper.java b/libjava/classpath/org/omg/IOP/ServiceIdHelper.java
index fac0746a82a..084dbd06d97 100644
--- a/libjava/classpath/org/omg/IOP/ServiceIdHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java b/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java
index eaee120f081..633891b9b57 100644
--- a/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/IOP/TaggedProfileHelper.java b/libjava/classpath/org/omg/IOP/TaggedProfileHelper.java
index 2943657c01f..9dbbfdaff1d 100644
--- a/libjava/classpath/org/omg/IOP/TaggedProfileHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/AdapterManagerIdHelper.java b/libjava/classpath/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
index f3f7e64416a..936e6bc1b81 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/AdapterNameHelper.java b/libjava/classpath/org/omg/PortableInterceptor/AdapterNameHelper.java
index 1cda311b23d..05844560a9a 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/AdapterNameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/AdapterStateHelper.java b/libjava/classpath/org/omg/PortableInterceptor/AdapterStateHelper.java
index ceb7ac8d52a..f0522caac0f 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/AdapterStateHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/CurrentHelper.java b/libjava/classpath/org/omg/PortableInterceptor/CurrentHelper.java
index df3bcaef72b..e453f601021 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/CurrentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ForwardRequestHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ForwardRequestHelper.java
index 5db56d74560..8aa19a991a1 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ForwardRequestHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java b/libjava/classpath/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
index 565242477d9..926974f1ab8 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/InvalidSlotHelper.java b/libjava/classpath/org/omg/PortableInterceptor/InvalidSlotHelper.java
index 98b2596771f..28558a000db 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/InvalidSlotHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
index 648e9679b42..2d9740a855e 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
index f89f9d4c6db..a87a3b747fd 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
index 55ee0be18fc..72c864811f7 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
index 258a73ae8a1..014c11308c2 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java b/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java
index c4f09896f97..e84f3e6be5d 100644
--- a/libjava/classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateSeqHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/CurrentHelper.java b/libjava/classpath/org/omg/PortableServer/CurrentHelper.java
index 281cefa6d9e..3afbf669b4b 100644
--- a/libjava/classpath/org/omg/PortableServer/CurrentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/CurrentPackage/NoContextHelper.java b/libjava/classpath/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
index 848a3c3d3f6..02c74c535c5 100644
--- a/libjava/classpath/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/ForwardRequestHelper.java b/libjava/classpath/org/omg/PortableServer/ForwardRequestHelper.java
index f4b0619b017..b30a2abebbb 100644
--- a/libjava/classpath/org/omg/PortableServer/ForwardRequestHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAHelper.java b/libjava/classpath/org/omg/PortableServer/POAHelper.java
index 3712da00d69..d6a951be52b 100644
--- a/libjava/classpath/org/omg/PortableServer/POAHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java b/libjava/classpath/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
index 2a587a4126b..e23d11997b4 100644
--- a/libjava/classpath/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
index 61a41089191..f616637ae26 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
index dd318bf09cb..bad920a5a4e 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
index 5e9e627c73f..32ddae8586f 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/NoServantHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/NoServantHelper.java
index fd2c189fc14..b9afb8ed79e 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/NoServantHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
index 011867473ee..bf5e9cd9ef2 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
index 0d8ff473cf3..2f5867cbdb5 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
index a74e674012a..33ca0667482 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
index 5fb52cf35b1..e86f4e948f7 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
index cd862b0814b..7650014c1f5 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java b/libjava/classpath/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
index a1f27cbb0eb..a9e7fc594d5 100644
--- a/libjava/classpath/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/ServantActivatorHelper.java b/libjava/classpath/org/omg/PortableServer/ServantActivatorHelper.java
index 8aa58b2f627..e1c4f09c869 100644
--- a/libjava/classpath/org/omg/PortableServer/ServantActivatorHelper.java
+++ b/libjava/classpath/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/libjava/classpath/org/omg/PortableServer/ServantLocatorHelper.java b/libjava/classpath/org/omg/PortableServer/ServantLocatorHelper.java
index 082c4c586ee..7bb933f7b9f 100644
--- a/libjava/classpath/org/omg/PortableServer/ServantLocatorHelper.java
+++ b/libjava/classpath/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/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory b/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory
new file mode 100644
index 00000000000..8d05bb13ae6
--- /dev/null
+++ b/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory
@@ -0,0 +1 @@
+gnu.java.util.prefs.GConfBasedFactory
diff --git a/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in b/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in
new file mode 100644
index 00000000000..b9465ce546e
--- /dev/null
+++ b/libjava/classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in
@@ -0,0 +1 @@
+@DEFAULT_PREFS_PEER@
diff --git a/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader b/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader
new file mode 100644
index 00000000000..6775a521fd9
--- /dev/null
+++ b/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader
@@ -0,0 +1 @@
+gnu.javax.sound.midi.file.MidiFileReader
diff --git a/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter b/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter
new file mode 100644
index 00000000000..85512e4ddfc
--- /dev/null
+++ b/libjava/classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter
@@ -0,0 +1 @@
+gnu.javax.sound.midi.file.MidiFileWriter
diff --git a/libjava/classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader b/libjava/classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader
new file mode 100644
index 00000000000..4fd59badb78
--- /dev/null
+++ b/libjava/classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader
@@ -0,0 +1,2 @@
+gnu.javax.sound.sampled.WAV.WAVReader
+gnu.javax.sound.sampled.AU.AUReader
diff --git a/libjava/classpath/resource/Makefile.in b/libjava/classpath/resource/Makefile.in
index 67a9d6c5e23..2ade725f961 100644
--- a/libjava/classpath/resource/Makefile.in
+++ b/libjava/classpath/resource/Makefile.in
@@ -95,6 +95,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -115,6 +117,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -145,6 +148,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -195,6 +202,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -215,6 +223,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
diff --git a/libjava/classpath/resource/gnu/classpath/tools/jarsigner/messages.properties b/libjava/classpath/resource/gnu/classpath/tools/jarsigner/messages.properties
index 4383256debb..d4088177c3a 100644
--- a/libjava/classpath/resource/gnu/classpath/tools/jarsigner/messages.properties
+++ b/libjava/classpath/resource/gnu/classpath/tools/jarsigner/messages.properties
@@ -119,4 +119,8 @@ SFHelper.1=Helper is NOT finished
SFHelper.4=.SF file has NOT been generated
SFHelper.6=Unknown or unsupported private key algorithm
SFHelper.9=Helper is NOT ready
+SFHelper.0=Warning: The certificate issued by {0}, for {1}, has expired as of {3,date,full} - {3,time,full}.
SFHelper.10=Helper is NOT started
+SFHelper.11=Warning: The certificate issued by {0}, for {1}, is only valid after {3,date,full} - {3,time,full}.
+SFHelper.14=[unknown]
+SFHelper.17=[unnamed]
diff --git a/libjava/classpath/resource/gnu/classpath/tools/keytool/messages.properties b/libjava/classpath/resource/gnu/classpath/tools/keytool/messages.properties
index 71b70a76694..98f4e684251 100644
--- a/libjava/classpath/resource/gnu/classpath/tools/keytool/messages.properties
+++ b/libjava/classpath/resource/gnu/classpath/tools/keytool/messages.properties
@@ -40,6 +40,9 @@
Main.6=keytool: {0}
Main.8=keytool error: {0}
+Main.5=Import a CA's Trusted Certificate.\n\
+[-file FILE] [-storetype STORE_TYPE] [-keystore URL]\n\
+[-storepass PASSWORD] [-provider PROVIDER_CLASS_NAME] [-v].
Main.18=Unrecognized command: {0}
Main.19=Usage: keytool [COMMAND] [-- COMMAND]...\n\
Manage private keys and public certificates.
@@ -540,3 +543,28 @@ SelfCertCmd.33=Fully qualified class name of a Security Provider to add to the \
JVM in-use.
SelfCertCmd.34=PROVIDER_CLASS_NAME
SelfCertCmd.35=Emit more verbose messages.
+
+CACertCmd.0=Alias [{0}] is already present in key store
+CACertCmd.1=Certificate in file "{0}" was added to the key store under the alias "{1}"
+CACertCmd.2=Usage: keytool -cacert [OPTION]...\n\
+Import a trusted CA certificate.
+CACertCmd.3=Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+CACertCmd.4=Command options
+CACertCmd.5=Location of the trusted CA certificate to import.
+CACertCmd.6=FILE
+CACertCmd.7=Type of the key store to use. If omitted, the default value is \
+that of the property "keystore.type" in the security properties file.
+CACertCmd.8=STORE_TYPE
+CACertCmd.9=Location of the key store to use. The default value is a \
+file-based scheme whose path is the file named ".keystore" in your home \
+directory.\n\
+If URL is malformed, the tool will use URL as a file-name of a key store; \
+i.e. as if the protocol was "file:".
+CACertCmd.10=URL
+CACertCmd.11=Password to unlock the key store. If omitted, you will be \
+prompted for one.
+CACertCmd.12=PASSWORD
+CACertCmd.13=Fully qualified class name of a Security Provider to add to the \
+JVM in-use.
+CACertCmd.14=PROVIDER_CLASS_NAME
+CACertCmd.15=Emit more verbose messages.
diff --git a/libjava/classpath/resource/gnu/java/awt/peer/x/fonts.properties b/libjava/classpath/resource/gnu/java/awt/peer/x/fonts.properties
new file mode 100644
index 00000000000..71a95c1935c
--- /dev/null
+++ b/libjava/classpath/resource/gnu/java/awt/peer/x/fonts.properties
@@ -0,0 +1,61 @@
+# fonts.properties
+# 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.
+
+serif.plain=-adobe-times-medium-r-normal--*-%d-75-*-p-*-iso8859-1
+serif.bold=-adobe-times-bold-r-normal--*-%d-75-*-p-*-iso8859-1
+serif.italic=-adobe-times-medium-o-normal--*-%d-75-*-p-*-iso8859-1
+serif.bolditalic=-adobe-times-bold-o-normal--*-%d-75-*-p-*-iso8859-1
+
+sansserif.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1
+sansserif.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1
+sansserif.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1
+sansserif.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1
+
+monospaced.plain=-adobe-courier-medium-r-normal--*-%d-75-*-p-*-iso8859-1
+monospaced.bold=-adobe-courier-bold-r-normal--*-%d-75-*-p-*-iso8859-1
+monospaced.italic=-adobe-courier-medium-o-normal--*-%d-75-*-p-*-iso8859-1
+monospaced.bolditalic=-adobe-courier-bold-o-normal--*-%d-75-*-p-*-iso8859-1
+
+dialog.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1
+dialog.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1
+dialog.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1
+dialog.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1
+
+dialoginput.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1
+dialoginput.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1
+dialoginput.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1
+dialoginput.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1
diff --git a/libjava/classpath/resource/gnu/regexp/MessagesBundle.properties b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties
index fb2f27c3991..fb2f27c3991 100644
--- a/libjava/classpath/resource/gnu/regexp/MessagesBundle.properties
+++ b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties
diff --git a/libjava/classpath/resource/gnu/regexp/MessagesBundle_fr.properties b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties
index 99da4e22da6..99da4e22da6 100644
--- a/libjava/classpath/resource/gnu/regexp/MessagesBundle_fr.properties
+++ b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties
diff --git a/libjava/classpath/resource/gnu/regexp/MessagesBundle_it.properties b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties
index 71be9207aec..ae8e141321b 100644
--- a/libjava/classpath/resource/gnu/regexp/MessagesBundle_it.properties
+++ b/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties
@@ -1,5 +1,5 @@
# Localized error messages for gnu.regexp, in Italian.
-# $Id: MessagesBundle_it.properties,v 1.1 2004/06/04 21:13:58 saugart Exp $
+# $Id: MessagesBundle_it.properties,v 1.1 2006/07/19 19:47:07 rabbit78 Exp $
# Messaggi italiani per gnu.regexp.
#
# Attenzione: Questa traduzione fu scritto da un italo-americano.
diff --git a/libjava/classpath/resource/java/security/classpath.security b/libjava/classpath/resource/java/security/classpath.security
index 13d691bfea2..166ac2ee2b0 100644
--- a/libjava/classpath/resource/java/security/classpath.security
+++ b/libjava/classpath/resource/java/security/classpath.security
@@ -1,5 +1,5 @@
# classpath.security
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Classpath.
#
@@ -41,3 +41,11 @@ security.provider.2=gnu.javax.crypto.jce.GnuCrypto
security.provider.3=gnu.javax.crypto.jce.GnuSasl
security.provider.4=gnu.javax.net.ssl.provider.Jessie
security.provider.5=gnu.javax.security.auth.callback.GnuCallbacks
+
+# The VM-wide default callback handler class name. MUST be a subclass of
+# javax.security.auth.callback.CallbackHandler
+auth.login.defaultCallbackHandler=gnu.javax.security.auth.callback.DefaultCallbackHandler
+
+# If this file isn't found we fall back to generating entropy through
+# "battling threads".
+securerandom.source=file:///dev/urandom
diff --git a/libjava/classpath/scripts/Makefile.am b/libjava/classpath/scripts/Makefile.am
index a0861661830..43378401812 100644
--- a/libjava/classpath/scripts/Makefile.am
+++ b/libjava/classpath/scripts/Makefile.am
@@ -1,2 +1,2 @@
-EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh
+EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh import-cacerts.sh
diff --git a/libjava/classpath/scripts/Makefile.in b/libjava/classpath/scripts/Makefile.in
index 71c01165c23..0ca40f439a5 100644
--- a/libjava/classpath/scripts/Makefile.in
+++ b/libjava/classpath/scripts/Makefile.in
@@ -85,6 +85,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -105,6 +107,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -135,6 +138,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -185,6 +192,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -205,6 +213,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -269,7 +279,7 @@ target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
vm_classes = @vm_classes@
-EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh
+EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh import-cacerts.sh
all: all-am
.SUFFIXES:
diff --git a/libjava/classpath/scripts/check_jni_methods.sh b/libjava/classpath/scripts/check_jni_methods.sh
index 243bb7e4a14..ffdc7b57106 100755
--- a/libjava/classpath/scripts/check_jni_methods.sh
+++ b/libjava/classpath/scripts/check_jni_methods.sh
@@ -29,7 +29,7 @@ find native/jni -name \*.cpp | \
cut -f4 -d\ | \
LC_ALL=C sed -e 's,^\JNIEXPORT .* JNICALL \(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
mv $TMPFILE2 $TMPFILE3
-sort $TMPFILE3 > $TMPFILE2
+sort $TMPFILE3 | uniq > $TMPFILE2
rm $TMPFILE3
# Write temporary ignore file.
@@ -37,6 +37,9 @@ cat > $TMPFILE3 << EOF
-Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
-Java_java_lang_VMSystem_arraycopy
-Java_java_lang_VMSystem_identityHashCode
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
EOF
# Compare again silently.
diff --git a/libjava/classpath/scripts/import-cacerts.sh b/libjava/classpath/scripts/import-cacerts.sh
new file mode 100755
index 00000000000..993d5847466
--- /dev/null
+++ b/libjava/classpath/scripts/import-cacerts.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+function visitFile() {
+ install/bin/gkeytool \
+ -cacert \
+ -v \
+ -storepass changeit \
+ -keystore resource/java/security/cacerts.gkr \
+ -file "$1"
+}
+
+function visitDir() {
+ local d
+ d=$1
+ for f in "$d/"*
+ do
+ if [ -d "$f" ] ; then
+ visitDir "$f"
+ else
+ visitFile "$f"
+ fi
+ done
+}
+
+if [ "$#" -lt "1" ] ; then
+ echo "Usage: import-cacerts DIR"
+ echo "Import CA trusted certificates into a 'cacerts.gkr' key store"
+ echo "under resource/java/security using 'changeit' as its password,"
+ echo "and constructing the Alias from the certificate's file name."
+ echo
+ echo " DIR the 'ca-certificates' deb package installation directory"
+ echo " containing trusted CA certificates."
+ echo
+else
+ caDir=$1
+ if [ ! -d $caDir ] ; then
+ echo "Argument MUST be a directory."
+ echo "Type command with no arguments for usage string."
+ exit 1
+ fi
+ visitDir $caDir
+fi
+exit 0 \ No newline at end of file
diff --git a/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java b/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
new file mode 100644
index 00000000000..ab9ad13d853
--- /dev/null
+++ b/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -0,0 +1,340 @@
+/* sun.reflect.annotation.AnnotationInvocationHandler
+ 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 sun.reflect.annotation;
+
+import java.io.Serializable;
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.annotation.IncompleteAnnotationException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class exists for serialization compatibility with the JDK.
+ * VMs can choose to implement annotations by constructing proxies
+ * with this invocation handler, but that is not required.
+ * If a different strategy for proxy objects is chosen, they can
+ * have a writeReplace method to substitute a Proxy based on this
+ * invocation handler is used for serialization.
+ */
+public final class AnnotationInvocationHandler
+ implements InvocationHandler, Serializable
+{
+ private static final long serialVersionUID = 6182022883658399397L;
+ private final Class type;
+ private final Map memberValues;
+
+ /**
+ * Construct a new invocation handler for an annotation proxy.
+ * Note that the VM is responsible for filling the memberValues map
+ * with the default values of all the annotation members.
+ */
+ public AnnotationInvocationHandler(Class type, Map memberValues)
+ {
+ this.type = type;
+ this.memberValues = memberValues;
+ }
+
+ /**
+ * Compare an instance of AnnotationInvocationHandler with another object.
+ * Note that the other object does not have to be an
+ * AnnotationInvocationHandler, any implementation of the annotation
+ * interface is allowed to be compared for equality.
+ * Note that this makes the equals method asymmetric, but this behavior
+ * is specified by Annotation.equals and identical to the JDK.
+ *
+ * This method is public for use by other parts of the VM. Some VMs
+ * (can) use different representations of annotations that reuse this
+ * method.
+ */
+ public static boolean equals(Class type, Map memberValues, Object other)
+ {
+ if (type.isInstance(other))
+ {
+ try
+ {
+ Method[] methods = type.getDeclaredMethods();
+ if (methods.length == memberValues.size())
+ {
+ for (int i = 0; i < methods.length; i++)
+ {
+ String key = methods[i].getName();
+ Object val = methods[i].invoke(other, new Object[0]);
+ if (! deepEquals(memberValues.get(key), val))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ catch (IllegalAccessException _)
+ {
+ // Ignore exception, like the JDK
+ }
+ catch (InvocationTargetException _)
+ {
+ // Ignore exception, like the JDK
+ }
+ }
+ return false;
+ }
+
+ private static boolean deepEquals(Object o1, Object o2)
+ {
+ if (o1 == o2)
+ return true;
+
+ if (o1 == null || o2 == null)
+ return false;
+
+ if (o1 instanceof boolean[] && o2 instanceof boolean[])
+ return Arrays.equals((boolean[]) o1, (boolean[]) o2);
+
+ if (o1 instanceof byte[] && o2 instanceof byte[])
+ return Arrays.equals((byte[]) o1, (byte[]) o2);
+
+ if (o1 instanceof char[] && o2 instanceof char[])
+ return Arrays.equals((char[]) o1, (char[]) o2);
+
+ if (o1 instanceof short[] && o2 instanceof short[])
+ return Arrays.equals((short[]) o1, (short[]) o2);
+
+ if (o1 instanceof int[] && o2 instanceof int[])
+ return Arrays.equals((int[]) o1, (int[]) o2);
+
+ if (o1 instanceof float[] && o2 instanceof float[])
+ return Arrays.equals((float[]) o1, (float[]) o2);
+
+ if (o1 instanceof long[] && o2 instanceof long[])
+ return Arrays.equals((long[]) o1, (long[]) o2);
+
+ if (o1 instanceof double[] && o2 instanceof double[])
+ return Arrays.equals((double[]) o1, (double[]) o2);
+
+ if (o1 instanceof Object[] && o2 instanceof Object[])
+ return Arrays.equals((Object[]) o1, (Object[]) o2);
+
+ return o1.equals(o2);
+ }
+
+ private static int deepHashCode(Object obj)
+ {
+ if (obj instanceof boolean[])
+ return Arrays.hashCode((boolean[]) obj);
+
+ if (obj instanceof byte[])
+ return Arrays.hashCode((byte[]) obj);
+
+ if (obj instanceof char[])
+ return Arrays.hashCode((char[]) obj);
+
+ if (obj instanceof short[])
+ return Arrays.hashCode((short[]) obj);
+
+ if (obj instanceof int[])
+ return Arrays.hashCode((int[]) obj);
+
+ if (obj instanceof float[])
+ return Arrays.hashCode((float[]) obj);
+
+ if (obj instanceof long[])
+ return Arrays.hashCode((long[]) obj);
+
+ if (obj instanceof double[])
+ return Arrays.hashCode((double[]) obj);
+
+ if (obj instanceof Object[])
+ return Arrays.hashCode((Object[]) obj);
+
+ return obj.hashCode();
+ }
+
+ /**
+ * Compute the hashCode for an annotation. Note that the algorithm is
+ * specified by Annotation.hashCode.
+ *
+ * This method is public for use by other parts of the VM. Some VMs
+ * (can) use different representations of annotations that reuse this
+ * method.
+ */
+ public static int hashCode(Class type, Map memberValues)
+ {
+ int h = 0;
+ Iterator iter = memberValues.keySet().iterator();
+ while (iter.hasNext())
+ {
+ Object key = iter.next();
+ Object val = memberValues.get(key);
+ h += deepHashCode(val) ^ 127 * key.hashCode();
+ }
+ return h;
+ }
+
+ private static String deepToString(Object obj)
+ {
+ if (obj instanceof boolean[])
+ return Arrays.toString((boolean[]) obj);
+
+ if (obj instanceof byte[])
+ return Arrays.toString((byte[]) obj);
+
+ if (obj instanceof char[])
+ return Arrays.toString((char[]) obj);
+
+ if (obj instanceof short[])
+ return Arrays.toString((short[]) obj);
+
+ if (obj instanceof int[])
+ return Arrays.toString((int[]) obj);
+
+ if (obj instanceof float[])
+ return Arrays.toString((float[]) obj);
+
+ if (obj instanceof long[])
+ return Arrays.toString((long[]) obj);
+
+ if (obj instanceof double[])
+ return Arrays.toString((double[]) obj);
+
+ if (obj instanceof Object[])
+ return Arrays.toString((Object[]) obj);
+
+ return obj.toString();
+ }
+
+ /**
+ * This method is public for use by other parts of the VM. Some VMs
+ * (can) use different representations of annotations that reuse this
+ * method.
+ */
+ public static String toString(Class type, Map memberValues)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append('@').append(type.getName()).append('(');
+ String sep = "";
+ Iterator iter = memberValues.keySet().iterator();
+ while (iter.hasNext())
+ {
+ Object key = iter.next();
+ Object val = memberValues.get(key);
+ sb.append(sep).append(key).append('=').append(deepToString(val));
+ sep = ", ";
+ }
+ sb.append(')');
+ return sb.toString();
+ }
+
+ private static Class getBoxedReturnType(Method method)
+ {
+ Class returnType = method.getReturnType();
+
+ if (returnType == boolean.class)
+ return Boolean.class;
+
+ if (returnType == byte.class)
+ return Byte.class;
+
+ if (returnType == char.class)
+ return Character.class;
+
+ if (returnType == short.class)
+ return Short.class;
+
+ if (returnType == int.class)
+ return Integer.class;
+
+ if (returnType == float.class)
+ return Float.class;
+
+ if (returnType == long.class)
+ return Long.class;
+
+ if (returnType == double.class)
+ return Double.class;
+
+ return returnType;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ String methodName = method.getName().intern();
+ if (args == null || args.length == 0)
+ {
+ if (methodName == "toString")
+ {
+ return toString(type, memberValues);
+ }
+ else if (methodName == "hashCode")
+ {
+ return Integer.valueOf(hashCode(type, memberValues));
+ }
+ else if (methodName == "annotationType")
+ {
+ return type;
+ }
+ else
+ {
+ Object val = memberValues.get(methodName);
+ if (val == null)
+ {
+ throw new IncompleteAnnotationException(type, methodName);
+ }
+ if (! getBoxedReturnType(method).isInstance(val))
+ {
+ throw new AnnotationTypeMismatchException(method,
+ val.getClass().getName());
+ }
+ return val;
+ }
+ }
+ else if (args.length == 1)
+ {
+ if (methodName == "equals")
+ {
+ return Boolean.valueOf(equals(type, memberValues, args[0]));
+ }
+ }
+ throw new InternalError("Invalid annotation proxy");
+ }
+}
diff --git a/libjava/classpath/tools/Makefile.am b/libjava/classpath/tools/Makefile.am
index cabe77d2274..01364f2411d 100755
--- a/libjava/classpath/tools/Makefile.am
+++ b/libjava/classpath/tools/Makefile.am
@@ -26,8 +26,9 @@ endif
## gcc/libjava/Makefile.am.
# if CREATE_WRAPPERS
# bin_SCRIPTS =
-# bin_PROGRAMS = gappletviewer gjarsigner gkeytool
-
+# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
+# gjar gnative2ascii gserialver
+#
# if FOUND_GCJ
# LIBJVM = -lgcj
# else
@@ -37,34 +38,55 @@ endif
# LIBJVM =
# endif
# endif
-
+#
# AM_CPPFLAGS = -Wall \
# -I$(top_srcdir)/include \
# -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
-
+#
# gappletviewer_SOURCES = toolwrapper.c
# gappletviewer_CFLAGS = \
# -DTOOLPACKAGE="\"appletviewer\"" \
# -DTOOLNAME="\"gappletviewer\""
# gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
# gjarsigner_SOURCES = toolwrapper.c
# gjarsigner_CFLAGS = \
# -DTOOLPACKAGE="\"jarsigner\"" \
# -DTOOLNAME="\"gjarsigner\""
# gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
# gkeytool_SOURCES = toolwrapper.c
# gkeytool_CFLAGS = \
# -DTOOLPACKAGE="\"keytool\"" \
# -DTOOLNAME="\"gkeytool\""
# gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
+# gjar_SOURCES = toolwrapper.c
+# gjar_CFLAGS = \
+# -DTOOLPACKAGE="\"jar\"" \
+# -DTOOLNAME="\"gjar\""
+# gjar_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
+# gnative2ascii_SOURCES = toolwrapper.c
+# gnative2ascii_CFLAGS = \
+# -DTOOLPACKAGE="\"native2ascii\"" \
+# -DTOOLNAME="\"gnative2ascii\""
+# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
+# gserialver_SOURCES = toolwrapper.c
+# gserialver_CFLAGS = \
+# -DTOOLPACKAGE="\"serialver\"" \
+# -DTOOLNAME="\"gserialver\""
+# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
# else
-# bin_SCRIPTS = gappletviewer gjarsigner gkeytool
+# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
+# gjar gnative2ascii gserialver
# bin_PROGRAMS =
# endif
-EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in
+## END GCJ LOCAL
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+ gjar.in gnative2ascii.in gserialver.in
# All our example java source files
TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java
diff --git a/libjava/classpath/tools/Makefile.in b/libjava/classpath/tools/Makefile.in
index 16001338dd6..a0a3471b9b7 100644
--- a/libjava/classpath/tools/Makefile.in
+++ b/libjava/classpath/tools/Makefile.in
@@ -39,7 +39,10 @@ host_triplet = @host@
target_triplet = @target@
subdir = tools
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/appletviewer.in $(srcdir)/jarsigner.in \
+ $(srcdir)/appletviewer.in $(srcdir)/gappletviewer.in \
+ $(srcdir)/gjar.in $(srcdir)/gjarsigner.in \
+ $(srcdir)/gkeytool.in $(srcdir)/gnative2ascii.in \
+ $(srcdir)/gserialver.in $(srcdir)/jarsigner.in \
$(srcdir)/keytool.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
@@ -53,7 +56,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
-CONFIG_CLEAN_FILES = appletviewer jarsigner keytool
+CONFIG_CLEAN_FILES = gappletviewer gjarsigner gkeytool gjar \
+ gnative2ascii gserialver appletviewer jarsigner keytool
SOURCES =
DIST_SOURCES =
DATA = $(noinst_DATA)
@@ -88,6 +92,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
@@ -108,6 +114,7 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
@@ -138,6 +145,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
GJDOC = @GJDOC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
@@ -188,6 +199,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
@@ -208,6 +220,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
VERSION = @VERSION@
@@ -282,8 +296,9 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
# if CREATE_WRAPPERS
# bin_SCRIPTS =
-# bin_PROGRAMS = gappletviewer gjarsigner gkeytool
-
+# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
+# gjar gnative2ascii gserialver
+#
# if FOUND_GCJ
# LIBJVM = -lgcj
# else
@@ -293,34 +308,55 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
# LIBJVM =
# endif
# endif
-
+#
# AM_CPPFLAGS = -Wall \
# -I$(top_srcdir)/include \
# -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
-
+#
# gappletviewer_SOURCES = toolwrapper.c
# gappletviewer_CFLAGS = \
# -DTOOLPACKAGE="\"appletviewer\"" \
# -DTOOLNAME="\"gappletviewer\""
# gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
# gjarsigner_SOURCES = toolwrapper.c
# gjarsigner_CFLAGS = \
# -DTOOLPACKAGE="\"jarsigner\"" \
# -DTOOLNAME="\"gjarsigner\""
# gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
# gkeytool_SOURCES = toolwrapper.c
# gkeytool_CFLAGS = \
# -DTOOLPACKAGE="\"keytool\"" \
# -DTOOLNAME="\"gkeytool\""
# gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM)
-
+#
+# gjar_SOURCES = toolwrapper.c
+# gjar_CFLAGS = \
+# -DTOOLPACKAGE="\"jar\"" \
+# -DTOOLNAME="\"gjar\""
+# gjar_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
+# gnative2ascii_SOURCES = toolwrapper.c
+# gnative2ascii_CFLAGS = \
+# -DTOOLPACKAGE="\"native2ascii\"" \
+# -DTOOLNAME="\"gnative2ascii\""
+# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
+# gserialver_SOURCES = toolwrapper.c
+# gserialver_CFLAGS = \
+# -DTOOLPACKAGE="\"serialver\"" \
+# -DTOOLNAME="\"gserialver\""
+# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM)
+#
# else
-# bin_SCRIPTS = gappletviewer gjarsigner gkeytool
+# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
+# gjar gnative2ascii gserialver
# bin_PROGRAMS =
# endif
-EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+ gjar.in gnative2ascii.in gserialver.in
+
# All our example java source files
TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java
@@ -383,6 +419,18 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+gappletviewer: $(top_builddir)/config.status $(srcdir)/gappletviewer.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gjarsigner: $(top_builddir)/config.status $(srcdir)/gjarsigner.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gkeytool: $(top_builddir)/config.status $(srcdir)/gkeytool.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gjar: $(top_builddir)/config.status $(srcdir)/gjar.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gnative2ascii: $(top_builddir)/config.status $(srcdir)/gnative2ascii.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gserialver: $(top_builddir)/config.status $(srcdir)/gserialver.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
appletviewer: $(top_builddir)/config.status $(srcdir)/appletviewer.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
jarsigner: $(top_builddir)/config.status $(srcdir)/jarsigner.in
diff --git a/libjava/classpath/tools/gappletviewer.in b/libjava/classpath/tools/gappletviewer.in
new file mode 100644
index 00000000000..1057aba9733
--- /dev/null
+++ b/libjava/classpath/tools/gappletviewer.in
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+## A simple shell script to launch the GNU Classpath appletviewer tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.appletviewer.Main "$@"
diff --git a/libjava/classpath/tools/gjar.in b/libjava/classpath/tools/gjar.in
new file mode 100644
index 00000000000..df2da926c0c
--- /dev/null
+++ b/libjava/classpath/tools/gjar.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath jar tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jar.Main "$@"
diff --git a/libjava/classpath/tools/jarsigner.sh.in b/libjava/classpath/tools/gjarsigner.in
index cea95a28814..071b8a6477d 100644
--- a/libjava/classpath/tools/jarsigner.sh.in
+++ b/libjava/classpath/tools/gjarsigner.in
@@ -44,20 +44,4 @@ prefix=@prefix@
tools_dir=@datadir@/@PACKAGE@
tools_cp=${tools_dir}/tools.zip
-# find the java executable...
-if [ -z "${JAVA}" ] ; then
- if [ -n "${JAVA_HOME}" ] ; then
- if [ -x "${JAVA_HOME}/jre/sh/java" ] ; then
- JAVA="${JAVA_HOME}/jre/sh/java"
- else
- JAVA="${JAVA_HOME}/bin/java"
- fi
- else
- JAVA=`which java 2> /dev/null `
- if [ -z "${JAVA}" ] ; then
- JAVA=java
- fi
- fi
-fi
-
-exec "${JAVA}" -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main $@
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main "$@"
diff --git a/libjava/classpath/tools/keytool.sh.in b/libjava/classpath/tools/gkeytool.in
index 6c11dc407df..d35f08df7df 100644
--- a/libjava/classpath/tools/keytool.sh.in
+++ b/libjava/classpath/tools/gkeytool.in
@@ -44,20 +44,4 @@ prefix=@prefix@
tools_dir=@datadir@/@PACKAGE@
tools_cp=${tools_dir}/tools.zip
-# find the java executable...
-if [ -z "${JAVA}" ] ; then
- if [ -n "${JAVA_HOME}" ] ; then
- if [ -x "${JAVA_HOME}/jre/sh/java" ] ; then
- JAVA="${JAVA_HOME}/jre/sh/java"
- else
- JAVA="${JAVA_HOME}/bin/java"
- fi
- else
- JAVA=`which java 2> /dev/null `
- if [ -z "${JAVA}" ] ; then
- JAVA=java
- fi
- fi
-fi
-
-exec "${JAVA}" -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main $@
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main "$@"
diff --git a/libjava/classpath/tools/gnative2ascii.in b/libjava/classpath/tools/gnative2ascii.in
new file mode 100644
index 00000000000..ade13f057a2
--- /dev/null
+++ b/libjava/classpath/tools/gnative2ascii.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath native2ascii tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.native2ascii.Main "$@"
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
index 3b337bf803c..fd2a7c0d832 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
@@ -199,7 +199,7 @@ class StandaloneAppletWindow
menuApplet.add(closeItem);
menuApplet.add(quitItem);
setMenuBar(menuBar);
- setTitle("GCJ Applet Viewer: " + tag.code);
+ setTitle("GNU Classpath Applet Viewer: " + tag.code);
AppletContext context = (AppletContext) contexts.get(tag.codebase);
((StandaloneAppletContext) context).addApplet(applet);
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
index 082cf89450b..3c6cf6f46ac 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
@@ -316,6 +316,9 @@ public class Parser
int eq = option.indexOf('=');
if (eq != - 1)
justName = option.substring(0, eq);
+ char shortName = 0;
+ if (justName.length() == 1)
+ shortName = justName.charAt(0);
Option found = null;
for (int i = options.size() - 1; i >= 0; --i)
{
@@ -325,6 +328,11 @@ public class Parser
found = opt;
break;
}
+ if (shortName != 0 && opt.getShortName() == shortName)
+ {
+ found = opt;
+ break;
+ }
}
if (found == null)
{
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
index 2286063f153..a085ca0c943 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
import gnu.java.security.hash.Sha160;
import gnu.java.security.util.Base64;
import gnu.java.util.jar.JarUtils;
@@ -76,9 +77,9 @@ class HashUtils
sha.update(buffer, 0, n);
count += n;
}
-
byte[] hash = sha.digest();
- log.finest("Hashed " + count + " byte(s)");
+ if (Configuration.DEBUG)
+ log.finest("Hashed " + count + " byte(s)");
String result = Base64.encode(hash);
return result;
}
@@ -92,7 +93,8 @@ class HashUtils
{
sha.update(ba);
byte[] hash = sha.digest();
- log.finest("Hashed " + ba.length + " byte(s)");
+ if (Configuration.DEBUG)
+ log.finest("Hashed " + ba.length + " byte(s)");
String result = Base64.encode(hash);
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
index 8d3bc31af0a..87db8b95278 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.java.util.jar.JarUtils;
@@ -69,8 +70,8 @@ public class JarSigner
void start() throws Exception
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
JarFile jarFile = new JarFile(main.getJarFileName());
SFHelper sfHelper = new SFHelper(jarFile);
@@ -119,19 +120,22 @@ public class JarSigner
String signaturesFileName = main.getSigFileName();
String sfFileName = JarUtils.META_INF + signaturesFileName
+ JarUtils.SF_SUFFIX;
- log.finest("Processing " + sfFileName); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Processing " + sfFileName); //$NON-NLS-1$
JarEntry sfEntry = new JarEntry(sfFileName);
sfEntry.setTime(System.currentTimeMillis());
outSignedJarFile.putNextEntry(sfEntry);
sfHelper.writeSF(outSignedJarFile);
- log.finer("Created .SF file"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Created .SF file"); //$NON-NLS-1$
if (main.isVerbose())
System.out.println(Messages.getString("JarSigner.8") + sfFileName); //$NON-NLS-1$
// 4. create the .DSA file
String dsaFileName = JarUtils.META_INF + signaturesFileName
+ JarUtils.DSA_SUFFIX;
- log.finest("Processing " + dsaFileName); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Processing " + dsaFileName); //$NON-NLS-1$
JarEntry dsaEntry = new JarEntry(dsaFileName);
dsaEntry.setTime(System.currentTimeMillis());
outSignedJarFile.putNextEntry(dsaEntry);
@@ -139,7 +143,8 @@ public class JarSigner
main.getSignerPrivateKey(),
main.getSignerCertificateChain(),
main.isInternalSF());
- log.finer("Created .DSA file"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Created .DSA file"); //$NON-NLS-1$
if (main.isVerbose())
System.out.println(Messages.getString("JarSigner.8") + dsaFileName); //$NON-NLS-1$
@@ -147,12 +152,13 @@ public class JarSigner
outSignedJarFile.close();
fos.close();
signedJarFile.renameTo(new File(main.getSignedJarFileName()));
- log.finer("Renamed signed JAR file"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Renamed signed JAR file"); //$NON-NLS-1$
if (main.isVerbose())
System.out.println(SystemProperties.getProperty("line.separator") //$NON-NLS-1$
+ Messages.getString("JarSigner.14")); //$NON-NLS-1$
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
private void copyFromTo(InputStream in, JarOutputStream out)
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
index f80147dfa5e..663f6906a9b 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.pkcs.PKCS7SignedData;
@@ -94,8 +95,8 @@ public class JarVerifier
void start() throws Exception
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
String jarFileName = main.getJarFileName();
jarFile = new JarFile(jarFileName);
@@ -144,8 +145,8 @@ public class JarVerifier
System.out.println(Messages.getFormattedString("JarVerifier.7", //$NON-NLS-1$
Integer.valueOf(limit)));
}
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
/**
@@ -162,9 +163,11 @@ public class JarVerifier
private boolean verifySF(String sigFileName) throws CRLException,
CertificateException, ZipException, IOException
{
- log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$
- log.finest("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$
+ log.fine("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
// 1. find the corresponding .DSA file for this .SF file
JarEntry dsaEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName
+ JarUtils.DSA_SUFFIX);
@@ -186,12 +189,14 @@ public class JarVerifier
if (encryptedDigest == null)
throw new SecurityException(Messages.getString("JarVerifier.16")); //$NON-NLS-1$
- log.finest("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
// 5. get the signer public key
Certificate cert = pkcs7SignedData.getCertificates()[0];
PublicKey verifierKey = cert.getPublicKey();
- log.finest("--- verifier public key = " + verifierKey); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("--- verifier public key = " + verifierKey); //$NON-NLS-1$
// 6. verify the signature file signature
OID digestEncryptionAlgorithmOID = signerInfo.getDigestEncryptionAlgorithmId();
@@ -225,10 +230,12 @@ public class JarVerifier
signatureAlgorithm.update(buffer, 0, n);
boolean result = signatureAlgorithm.verify(herSignature);
- log.finer("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$
- + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$
+ + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$
+ }
return result;
}
@@ -250,8 +257,8 @@ public class JarVerifier
*/
private boolean verifySFEntries(String alias) throws IOException
{
- log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$
// 1. read the signature file
JarEntry jarEntry = jarFile.getJarEntry(JarUtils.META_INF + alias
+ JarUtils.SF_SUFFIX);
@@ -291,8 +298,9 @@ public class JarVerifier
break;
}
- log.exiting(this.getClass().getName(), "verifySFEntries",
- Boolean.valueOf(result)); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "verifySFEntries", //$NON-NLS-1$
+ Boolean.valueOf(result));
return result;
}
@@ -319,7 +327,8 @@ public class JarVerifier
{
String expectedValue = getEntryHash(JarFile.MANIFEST_NAME);
boolean result = expectedValue.equalsIgnoreCase(hash);
- log.finest("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
index 6928bce5945..b6b50e7417a 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.common.CallbackUtil;
import gnu.classpath.tools.common.ProviderUtil;
@@ -131,8 +132,8 @@ public class Main
public static final void main(String[] args)
{
- log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
Main tool = new Main();
int result = 1;
try
@@ -143,20 +144,22 @@ public class Main
}
catch (SecurityException x)
{
- log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
System.err.println(Messages.getString("Main.7") + x.getMessage()); //$NON-NLS-1$
}
catch (Exception x)
{
- log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
System.err.println(Messages.getString("Main.9") + x); //$NON-NLS-1$
}
finally
{
tool.teardown();
}
-
- log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
System.exit(result);
}
@@ -171,8 +174,8 @@ public class Main
*/
private void processArgs(String[] args) throws Exception
{
- log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
cmdLineParser = new ToolParser();
cmdLineParser.initializeParser();
cmdLineParser.parse(args, new ToolParserCallback());
@@ -180,36 +183,41 @@ public class Main
setupCommonParams();
if (verify)
{
- log.finer("Will verify with the following parameters:"); //$NON-NLS-1$
- log.finer(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer("Options:"); //$NON-NLS-1$
- log.finer(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" verbose ? " + verbose); //$NON-NLS-1$
- log.finer(" certs ? " + certs); //$NON-NLS-1$
- log.finer(" internalsf ? " + internalSF); //$NON-NLS-1$
- log.finer(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("Will verify with the following parameters:"); //$NON-NLS-1$
+ log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine("Options:"); //$NON-NLS-1$
+ log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" verbose ? " + verbose); //$NON-NLS-1$
+ log.fine(" certs ? " + certs); //$NON-NLS-1$
+ log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$
+ log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ }
}
else // sign
{
setupSigningParams();
-
- log.finer("Will sign with the following parameters:"); //$NON-NLS-1$
- log.finer(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer("Options:"); //$NON-NLS-1$
- log.finer(" keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- log.finer(" verbose ? " + verbose); //$NON-NLS-1$
- log.finer(" internalsf ? " + internalSF); //$NON-NLS-1$
- log.finer(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("Will sign with the following parameters:"); //$NON-NLS-1$
+ log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine("Options:"); //$NON-NLS-1$
+ log.fine(" keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ log.fine(" verbose ? " + verbose); //$NON-NLS-1$
+ log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$
+ log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+ }
}
-
- log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$
}
/**
@@ -222,8 +230,8 @@ public class Main
*/
private void start() throws Exception
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
if (verify)
{
JarVerifier jv = new JarVerifier(this);
@@ -234,8 +242,8 @@ public class Main
JarSigner js = new JarSigner(this);
js.start();
}
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
/**
@@ -249,12 +257,13 @@ public class Main
*/
private void teardown()
{
- log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
if (providerInstalled)
ProviderUtil.removeProvider(provider.getName());
- log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
}
/**
@@ -279,8 +288,8 @@ public class Main
private void setupCommonParams() throws InstantiationException,
IllegalAccessException, ClassNotFoundException, IOException
{
- log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
File jar = new File(jarFileName);
if (! jar.exists())
throw new FileNotFoundException(jarFileName);
@@ -298,18 +307,23 @@ public class Main
String providerName = provider.getName();
Provider installedProvider = Security.getProvider(providerName);
if (installedProvider != null)
- log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ if (Configuration.DEBUG)
+ log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
else // install it
installNewProvider();
}
if (! verbose && certs)
{
- log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$
certs = false;
}
- log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
}
/**
@@ -319,11 +333,11 @@ public class Main
*/
private void installNewProvider()
{
- log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
providerInstalled = ProviderUtil.addProvider(provider) != -1;
-
- log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
}
/**
@@ -349,8 +363,8 @@ public class Main
NoSuchAlgorithmException, CertificateException,
UnsupportedCallbackException, UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
if (ksURL == null || ksURL.trim().length() == 0)
{
String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
@@ -424,7 +438,8 @@ public class Main
signerPrivateKey = (PrivateKey) key;
signerCertificateChain = store.getCertificateChain(alias);
- log.finest(String.valueOf(signerCertificateChain));
+ if (Configuration.DEBUG)
+ log.fine(String.valueOf(signerCertificateChain));
if (sigFileName == null)
sigFileName = alias;
@@ -449,7 +464,8 @@ public class Main
if (signedJarFileName == null)
signedJarFileName = jarFileName;
- log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
}
boolean isVerbose()
@@ -547,7 +563,8 @@ public class Main
if (! verify) // must have an ALIAS. use "mykey" if undefined
if (fileAndAlias.size() < 2)
{
- log.finer("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$
alias = "mykey"; //$NON-NLS-1$
}
else
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
index 35f461669de..d5b8760ee9d 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
@@ -38,6 +38,8 @@
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
+
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@@ -99,8 +101,9 @@ class Messages
}
catch (IllegalArgumentException x)
{
- log.fine("Exception while rendering a message format keyed by ["
- + key + "]: " + mf.toPattern());
+ if (Configuration.DEBUG)
+ log.fine("Exception while rendering a message format keyed by ["
+ + key + "]: " + mf.toPattern());
return constructMessage(mf.toPattern(), args);
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
index b4e5cc19368..83e87b84385 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.jarsigner;
+import gnu.classpath.Configuration;
import gnu.java.security.OID;
import gnu.java.security.Registry;
import gnu.java.security.der.DER;
@@ -62,10 +63,13 @@ import java.security.PrivateKey;
import java.security.cert.CRLException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509CRL;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -142,7 +146,8 @@ public class SFHelper
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JarUtils.writeSFManifest(sfMainAttributes, sfEntries, baos);
sfBytes = baos.toByteArray();
- log.finest("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
jar.write(sfBytes);
jar.flush();
@@ -216,7 +221,8 @@ public class SFHelper
if (this.state != SF_GENERATED)
throw new IllegalStateException(Messages.getString("SFHelper.4")); //$NON-NLS-1$
- log.finest("+++ signer private key = " + signerKey); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("+++ signer private key = " + signerKey); //$NON-NLS-1$
ISignature signatureAlgorithm;
ISignatureCodec signatureCodec;
OID digestEncryptionAlgorithmOID;
@@ -241,7 +247,8 @@ public class SFHelper
signatureAlgorithm.update(sfBytes, 0, sfBytes.length);
Object signature = signatureAlgorithm.sign();
byte[] signedSFBytes = signatureCodec.encodeSignature(signature);
- log.finest("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
Set digestAlgorithms = new HashSet();
List digestAlgorithm = new ArrayList(2);
@@ -261,6 +268,30 @@ public class SFHelper
Set signerInfos = new HashSet();
X509Certificate cert = (X509Certificate) certificates[0];
+ try
+ {
+ cert.checkValidity();
+ }
+ catch (CertificateExpiredException x)
+ {
+ String issuerName = getIssuerName(cert);
+ String subjectName = getSubjectName(cert);
+ Date notAfterDate = getNotAfterDate(cert);
+ System.out.println(Messages.getFormattedString("SFHelper.0", //$NON-NLS-1$
+ new Object[] { issuerName,
+ subjectName,
+ notAfterDate }));
+ }
+ catch (CertificateNotYetValidException x)
+ {
+ String issuerName = getIssuerName(cert);
+ String subjectName = getSubjectName(cert);
+ Date notBeforeDate = getNotBeforeDate(cert);
+ System.out.println(Messages.getFormattedString("SFHelper.11", //$NON-NLS-1$
+ new Object[] { issuerName,
+ subjectName,
+ notBeforeDate }));
+ }
X500Principal issuer = cert.getIssuerX500Principal();
BigInteger serialNumber = cert.getSerialNumber();
byte[] authenticatedAttributes = null;
@@ -322,7 +353,8 @@ public class SFHelper
String name = entry.getName();
InputStream jeis = jar.getInputStream(entry);
String hash = util.hashStream(jeis);
- log.finer("Hash of " + name + " = " + hash); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("Hash of " + name + " = " + hash); //$NON-NLS-1$ //$NON-NLS-2$
Attributes mainfestAttributes = manifest.getAttributes(name);
if (mainfestAttributes == null)
@@ -344,9 +376,12 @@ public class SFHelper
}
sfAttributes.putValue(Main.DIGEST, sfHash);
- log.finest("Name: " + name); //$NON-NLS-1$
- log.finest(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$
- log.finest(""); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("Name: " + name); //$NON-NLS-1$
+ log.fine(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$
+ log.fine(""); //$NON-NLS-1$
+ }
}
/**
@@ -365,9 +400,106 @@ public class SFHelper
manifest.write(baos);
baos.flush();
String manifestHash = util.hashByteArray(baos.toByteArray());
- log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$
sfMainAttributes.putValue(Main.DIGEST_MANIFEST, manifestHash);
this.state = FINISHED;
}
+
+ /**
+ * Given an X.509 certificate this method returns the string representation of
+ * the Issuer Distinguished Name.
+ *
+ * @param cert an X.509 certificate.
+ * @return the string representation of the Issuer's DN.
+ */
+ private String getIssuerName(X509Certificate cert)
+ {
+ X500Principal xp = cert.getIssuerX500Principal();
+ if (xp == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null Issuer. Return [unknown]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+ }
+ String result = xp.getName();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has an Issuer with null DN. Return [unnamed]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the string representation of
+ * the Subject Distinguished Name.
+ *
+ * @param cert an X.509 certificate.
+ * @return the string representation of the Subject's DN.
+ */
+ private String getSubjectName(X509Certificate cert)
+ {
+ X500Principal xp = cert.getSubjectX500Principal();
+ if (xp == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null Subject. Return [unknown]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+ }
+ String result = xp.getName();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has a Subject with null DN. Return [unnamed]"); //$NON-NLS-1$
+ return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the end validity date of
+ * this certificate.
+ *
+ * @param cert an X.509 certificate.
+ * @return the date when this certificate stops being valid.
+ */
+ private Date getNotAfterDate(X509Certificate cert)
+ {
+ Date result = cert.getNotAfter();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null start-validity date. Return epoch"); //$NON-NLS-1$
+ return new Date(0);
+ }
+ return result;
+ }
+
+ /**
+ * Given an X.509 certificate this method returns the start validity date of
+ * this certificate.
+ *
+ * @param cert an X.509 certificate.
+ * @return the date when this certificate starts being valid.
+ */
+ private Date getNotBeforeDate(X509Certificate cert)
+ {
+ Date result = cert.getNotBefore();
+ if (result == null)
+ {
+ if (Configuration.DEBUG)
+ log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+ + ", has null end-validity date. Return epoch"); //$NON-NLS-1$
+ return new Date(0);
+ }
+ return result;
+ }
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java
new file mode 100644
index 00000000000..2bf832beee0
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java
@@ -0,0 +1,313 @@
+/* CACertCmd.java -- GNU specific cacert handler
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+/**
+ * The <code>-cacert</code> keytol command handler is used to import a CA
+ * trusted X.509 certificate into a key store.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ * <dt>-file FILE_NAME</dt>
+ * <dd>The fully qualified path of the file containing the trusted CA
+ * certificate to import. If omitted, the tool will process STDIN.
+ * <p></dd>
+ *
+ * <dt>-storetype STORE_TYPE</dt>
+ * <dd>Use this option to specify the type of the key store to use. The
+ * default value, if this option is omitted, is that of the property
+ * <code>keystore.type</code> in the security properties file, which is
+ * obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ * static method.
+ * <p></dd>
+ *
+ * <dt>-keystore URL</dt>
+ * <dd>Use this option to specify the location of the key store to use.
+ * The default value is a file {@link java.net.URL} referencing the file
+ * named <code>.keystore</code> located in the path returned by the call to
+ * {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ * as argument.
+ * <p>
+ * If a URL was specified, but was found to be malformed --e.g. missing
+ * protocol element-- the tool will attempt to use the URL value as a file-
+ * name (with absolute or relative path-name) of a key store --as if the
+ * protocol was <code>file:</code>.
+ * <p></dd>
+ *
+ * <dt>-storepass PASSWORD</dt>
+ * <dd>Use this option to specify the password protecting the key store. If
+ * this option is omitted from the command line, you will be prompted to
+ * provide a password.
+ * <p></dd>
+ *
+ * <dt>-provider PROVIDER_CLASS_NAME</dt>
+ * <dd>A fully qualified class name of a Security Provider to add to the
+ * current list of Security Providers already installed in the JVM in-use.
+ * If a provider class is specified with this option, and was successfully
+ * added to the runtime --i.e. it was not already installed-- then the tool
+ * will attempt to removed this Security Provider before exiting.
+ * <p></dd>
+ *
+ * <dt>-v</dt>
+ * <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+public class CACertCmd
+ extends Command
+{
+ private static final Logger log = Logger.getLogger(CACertCmd.class.getName());
+ /** Pathname of the file containing the CA certificate to import. */
+ protected String _certFileName;
+ /** Type of the key store to use. */
+ protected String _ksType;
+ /** The URL to the keystore where the trusted certificates will be added. */
+ protected String _ksURL;
+ /** The password protecting the keystore. */
+ protected String _ksPassword;
+ /** Class name of a security provider to use. */
+ protected String _providerClassName;
+ /** Reference to the X.509 factory. */
+ private CertificateFactory x509Factory;
+
+ // default 0-arguments constructor
+
+ // public setters -----------------------------------------------------------
+
+ /** @param pathName the fully qualified path name of the file to process. */
+ public void setFile(String pathName)
+ {
+ this._certFileName = pathName;
+ }
+
+ /** @param type the key-store type to use. */
+ public void setStoretype(String type)
+ {
+ this._ksType = type;
+ }
+
+ /** @param url the key-store URL to use. */
+ public void setKeystore(String url)
+ {
+ this._ksURL = url;
+ }
+
+ /** @param password the key-store password to use. */
+ public void setStorepass(String password)
+ {
+ this._ksPassword = password;
+ }
+
+ /** @param className a security provider fully qualified class name to use. */
+ public void setProvider(String className)
+ {
+ this._providerClassName = className;
+ }
+
+ // life-cycle methods -------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see gnu.classpath.tools.keytool.Command#setup()
+ */
+ void setup() throws Exception
+ {
+ setInputStreamParam(_certFileName);
+ setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-cacert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
+ }
+
+ void start() throws CertificateException, KeyStoreException,
+ NoSuchAlgorithmException, IOException
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ alias = getAliasFromFileName(_certFileName);
+ if (store.containsAlias(alias))
+ throw new IllegalArgumentException(Messages.getFormattedString("CACertCmd.0", //$NON-NLS-1$
+ alias));
+ x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+ Certificate certificate = x509Factory.generateCertificate(inStream);
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
+ store.setCertificateEntry(alias, certificate);
+ saveKeyStore();
+ if (verbose)
+ System.out.println(Messages.getFormattedString("CACertCmd.1", //$NON-NLS-1$
+ new Object[] { _certFileName,
+ alias }));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ }
+
+ // own methods --------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see gnu.classpath.tools.keytool.Command#getParser()
+ */
+ Parser getParser()
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+ Parser result = new ClasspathToolParser(Main.CACERT_CMD, true);
+ result.setHeader(Messages.getString("CACertCmd.2")); //$NON-NLS-1$
+ result.setFooter(Messages.getString("CACertCmd.3")); //$NON-NLS-1$
+ OptionGroup options = new OptionGroup(Messages.getString("CACertCmd.4")); //$NON-NLS-1$
+ options.add(new Option(Main.FILE_OPT,
+ Messages.getString("CACertCmd.5"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.6")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _certFileName = argument;
+ }
+ });
+ options.add(new Option(Main.STORETYPE_OPT,
+ Messages.getString("CACertCmd.7"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.8")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksType = argument;
+ }
+ });
+ options.add(new Option(Main.KEYSTORE_OPT,
+ Messages.getString("CACertCmd.9"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.10")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksURL = argument;
+ }
+ });
+ options.add(new Option(Main.STOREPASS_OPT,
+ Messages.getString("CACertCmd.11"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _ksPassword = argument;
+ }
+ });
+ options.add(new Option(Main.PROVIDER_OPT,
+ Messages.getString("CACertCmd.13"), //$NON-NLS-1$
+ Messages.getString("CACertCmd.14")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ _providerClassName = argument;
+ }
+ });
+ options.add(new Option(Main.VERBOSE_OPT,
+ Messages.getString("CACertCmd.15")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ result.add(options);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ return result;
+ }
+
+ /**
+ * Construct an Alias string from the name of the file containing the
+ * certificate to import. This method first removes the last dot (".")
+ * character and any subsequent characters from the input name, and then
+ * replaces any space and dot characters with underscores. For example the
+ * input string <code>brasil.gov.br.cert</code> will result in
+ * <code>brasil_gov_br</code> as its alias.
+ *
+ * @param fileName the name of the file containing the CA certificate
+ * @return a string which can, and will, be used as the Alias of this CA
+ * certificate.
+ */
+ private String getAliasFromFileName(String fileName)
+ {
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getAliasFromFileName", fileName); //$NON-NLS-1$
+ // get the basename
+ fileName = new File(fileName).getName();
+ // remove '.' if at start
+ if (fileName.startsWith(".")) //$NON-NLS-1$
+ fileName = fileName.substring(1);
+
+ // remove last \..+
+ int ndx = fileName.lastIndexOf('.');
+ if (ndx > 0)
+ fileName = fileName.substring(0, ndx);
+ // replace spaces and dots with underscores
+ char[] chars = fileName.toCharArray();
+ for (int i = 0; i < chars.length; i++)
+ {
+ char c = chars[i];
+ if (c == ' ' || c == '.')
+ chars[i] = '_';
+ }
+ String result = new String(chars);
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$
+ return result;
+ }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
index fc85e6abd15..692b1f69015 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -258,24 +259,26 @@ class CertReqCmd extends Command
setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
setAliasParam(_alias);
setKeyPasswordNoPrompt(_password);
-
- log.finer("-certreq handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
- log.finer(" -file=" + _certReqFileName); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
- log.finer(" -attributes=" + nullAttributes); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-certreq handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+ log.fine(" -file=" + _certReqFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ log.fine(" -attributes=" + nullAttributes); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
UnsupportedCallbackException, UnrecoverableKeyException,
InvalidKeyException, SignatureException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
// 1. get the key entry and certificate chain associated to alias
Key privateKey = getAliasPrivateKey();
Certificate[] chain = store.getCertificateChain(alias);
@@ -305,16 +308,16 @@ class CertReqCmd extends Command
}
writer.close();
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.CERTREQ_CMD, true);
result.setHeader(Messages.getString("CertReqCmd.25")); //$NON-NLS-1$
result.setFooter(Messages.getString("CertReqCmd.24")); //$NON-NLS-1$
@@ -408,8 +411,8 @@ class CertReqCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
index 0811074b8c1..bc5cff2aaba 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.common.CallbackUtil;
import gnu.classpath.tools.common.ProviderUtil;
@@ -242,12 +243,12 @@ abstract class Command
*/
String[] processArgs(String[] args)
{
- log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
Parser cmdOptionsParser = getParser();
String[] result = cmdOptionsParser.parse(args);
-
- log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$
return result;
}
@@ -312,8 +313,8 @@ abstract class Command
*/
void teardown()
{
- log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
if (storeStream != null)
try
{
@@ -321,8 +322,9 @@ abstract class Command
}
catch (IOException ignored)
{
- log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$
- + ignored);
+ if (Configuration.DEBUG)
+ log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$
+ + ignored);
}
if (outStream != null)
@@ -357,7 +359,8 @@ abstract class Command
if (providerNdx > 0)
ProviderUtil.removeProvider(provider.getName());
- log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
}
// parameter setup and validation methods -----------------------------------
@@ -371,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
@@ -385,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);
}
/**
@@ -399,17 +428,20 @@ 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)
{
- log.finest("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
if (className != null && className.trim().length() > 0)
{
className = className.trim();
SecurityProviderInfo spi = ProviderUtil.addProvider(className);
provider = spi.getProvider();
if (provider == null)
- log.fine("Was unable to add provider from class " + className);
-
+ {
+ if (Configuration.DEBUG)
+ log.fine("Was unable to add provider from class " + className);
+ }
providerNdx = spi.getPosition();
}
}
@@ -424,9 +456,10 @@ 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)
{
- log.finest("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
if (type == null || type.trim().length() == 0)
storeType = KeyStore.getDefaultType();
else
@@ -484,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$
@@ -496,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)
@@ -514,18 +547,25 @@ 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
{
- log.finest("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$
if (url == null || url.trim().length() == 0)
{
String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
@@ -533,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$
}
@@ -551,7 +594,8 @@ abstract class Command
storeStream = storeURL.openStream();
if (storeStream.available() == 0)
{
- log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$
newKeyStore = true;
}
@@ -564,8 +608,9 @@ abstract class Command
if (provider != null)
throw x;
- log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$
- + " Will prompt user for another provider and continue"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$
+ + " Will prompt user for another provider and continue"); //$NON-NLS-1$
String prompt = Messages.getString("Command.40"); //$NON-NLS-1$
NameCallback ncb = new NameCallback(prompt);
getCallbackHandler().handle(new Callback[] { ncb });
@@ -580,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.
@@ -596,8 +643,9 @@ abstract class Command
}
catch (IOException x)
{
- log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$
- + ". Ignore"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$
+ + ". Ignore"); //$NON-NLS-1$
}
}
@@ -818,9 +866,9 @@ abstract class Command
PrivateKey privateKey)
throws IOException, SignatureException, InvalidKeyException
{
- log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$
- new Object[] { distinguishedName, publicKey, privateKey });
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$
+ new Object[] { distinguishedName, publicKey, privateKey });
byte[] versionBytes = new DERValue(DER.INTEGER, BigInteger.ZERO).getEncoded();
DERValue derVersion = new DERValue(DER.CONSTRUCTED | DER.CONTEXT | 0,
versionBytes.length, versionBytes, null);
@@ -901,8 +949,8 @@ abstract class Command
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DERWriter.write(baos, derCertificate);
byte[] result = baos.toByteArray();
-
- log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$
return result;
}
@@ -992,8 +1040,8 @@ abstract class Command
protected void saveKeyStore(char[] password) throws IOException,
KeyStoreException, NoSuchAlgorithmException, CertificateException
{
- log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
URLConnection con = storeURL.openConnection();
con.setDoOutput(true);
con.setUseCaches(false);
@@ -1004,8 +1052,8 @@ abstract class Command
store.store(out, password);
out.flush();
out.close();
-
- log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
}
/**
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
index 4c32ee1e697..8107055d02b 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -158,33 +159,35 @@ class DeleteCmd extends Command
{
setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
setTheAlias(_alias);
-
- log.finer("-delete handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-delete handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException,
CertificateException, IOException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
ensureStoreContainsAlias();
store.deleteEntry(alias);
saveKeyStore();
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.DELETE_CMD, true);
result.setHeader(Messages.getString("DeleteCmd.18")); //$NON-NLS-1$
result.setFooter(Messages.getString("DeleteCmd.17")); //$NON-NLS-1$
@@ -243,8 +246,8 @@ class DeleteCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
index 46f7acdf013..75f71801c9a 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -188,32 +189,36 @@ class ExportCmd extends Command
setOutputStreamParam(_certFileName);
setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
setAliasParam(_alias);
-
- log.finer("-export handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -file=" + _certFileName); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -rfc=" + rfc); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-export handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -rfc=" + rfc); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, CertificateEncodingException,
IOException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
ensureStoreContainsAlias();
Certificate certificate;
if (store.isCertificateEntry(alias))
{
- log.finer("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$
certificate = store.getCertificate(alias);
}
else
{
- log.finer("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$
Certificate[] chain = store.getCertificateChain(alias);
certificate = chain[0];
}
@@ -231,15 +236,16 @@ class ExportCmd extends Command
outStream.write(derBytes);
// stream is closed in Command.teardown()
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.EXPORT_CMD, true);
result.setHeader(Messages.getString("ExportCmd.17")); //$NON-NLS-1$
result.setFooter(Messages.getString("ExportCmd.18")); //$NON-NLS-1$
@@ -315,8 +321,8 @@ class ExportCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
index 6da0f58b6fa..03a1555a8c6 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -302,68 +303,76 @@ 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);
setKeySize(_keySizeStr);
setDName(_dName);
setValidityParam(_validityStr);
-
- log.finer("-genkey handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -keyalg=" + keyPairGenerator.getAlgorithm()); //$NON-NLS-1$
- log.finer(" -keysize=" + keySize); //$NON-NLS-1$
- log.finer(" -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$
- log.finer(" -dname=" + distinguishedName); //$NON-NLS-1$
- log.finer(" -validity=" + validityInDays); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-genkey handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -keyalg=" + keyPairGenerator.getAlgorithm()); //$NON-NLS-1$
+ log.fine(" -keysize=" + keySize); //$NON-NLS-1$
+ log.fine(" -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$
+ log.fine(" -dname=" + distinguishedName); //$NON-NLS-1$
+ log.fine(" -validity=" + validityInDays); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws CertificateException, KeyStoreException,
InvalidKeyException, SignatureException, IOException,
NoSuchAlgorithmException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ {
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+ log.fine("About to generate key-pair..."); //$NON-NLS-1$
+ }
// 1. generate a new key-pair
- log.finer("About to generate key-pair..."); //$NON-NLS-1$
keyPairGenerator.initialize(keySize);
KeyPair kp = keyPairGenerator.generateKeyPair();
PublicKey publicKey = kp.getPublic();
PrivateKey privateKey = kp.getPrivate();
// 2. generate a self-signed certificate
- log.finer("About to generate a self-signed certificate..."); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("About to generate a self-signed certificate..."); //$NON-NLS-1$
byte[] derBytes = getSelfSignedCertificate(distinguishedName,
publicKey,
privateKey);
- log.finest(Util.dumpString(derBytes, "derBytes ")); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine(Util.dumpString(derBytes, "derBytes ")); //$NON-NLS-1$
CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
ByteArrayInputStream bais = new ByteArrayInputStream(derBytes);
Certificate certificate = x509Factory.generateCertificate(bais);
- log.finest("certificate = " + certificate); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
// 3. store it, w/ its private key, associating them to alias
Certificate[] chain = new Certificate[] { certificate };
- log.finest("About to store newly generated material in key store..."); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("About to store newly generated material in key store..."); //$NON-NLS-1$
store.setKeyEntry(alias, privateKey, keyPasswordChars, chain);
// 4. persist the key store
saveKeyStore();
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.GENKEY_CMD, true);
result.setHeader(Messages.getString("GenKeyCmd.57")); //$NON-NLS-1$
result.setFooter(Messages.getString("GenKeyCmd.58")); //$NON-NLS-1$
@@ -476,8 +485,8 @@ class GenKeyCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
@@ -574,8 +583,8 @@ class GenKeyCmd extends Command
name = sb.toString().trim();
}
-
- log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Configuration.DEBUG)
+ log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$
distinguishedName = new X500DistinguishedName(name);
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
index 46c5b97692b..d0de589d933 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -148,22 +149,24 @@ class IdentityDBCmd extends Command
void setup() throws Exception
{
setInputStreamParam(_idbFileName);
- setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
-
- log.finer("-identitydb handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -file=" + _idbFileName); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+ if (Configuration.DEBUG)
+ {
+ log.fine("-identitydb handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _idbFileName); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true);
result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$
result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$
@@ -222,8 +225,8 @@ class IdentityDBCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
index 2e01bc0e4f9..3a6ed872bfb 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
@@ -291,27 +292,29 @@ 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);
-
- log.finer("-import handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -file=" + _certFileName); //$NON-NLS-1$
- log.finer(" -noprompt=" + noPrompt); //$NON-NLS-1$
- log.finer(" -trustcacerts=" + trustCACerts); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-import handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -noprompt=" + noPrompt); //$NON-NLS-1$
+ log.fine(" -trustcacerts=" + trustCACerts); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws CertificateException, KeyStoreException, IOException,
UnsupportedCallbackException, NoSuchAlgorithmException,
CertPathValidatorException, UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
if (trustCACerts)
{
String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$
@@ -336,16 +339,16 @@ class ImportCmd extends Command
ensureAliasIsKeyEntry();
importCertificateReply();
}
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.IMPORT_CMD, true);
result.setHeader(Messages.getString("ImportCmd.27")); //$NON-NLS-1$
result.setFooter(Messages.getString("ImportCmd.26")); //$NON-NLS-1$
@@ -438,8 +441,8 @@ class ImportCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
@@ -480,10 +483,11 @@ class ImportCmd extends Command
UnsupportedCallbackException, CertPathValidatorException,
UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
Certificate certificate = x509Factory.generateCertificate(inStream);
- log.finest("certificate = " + certificate); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
LinkedList orderedReply = new LinkedList();
orderedReply.addLast(certificate);
@@ -495,8 +499,8 @@ class ImportCmd extends Command
}
else
System.out.println(Messages.getString("ImportCmd.28")); //$NON-NLS-1$
-
- log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
}
/**
@@ -525,8 +529,8 @@ class ImportCmd extends Command
NoSuchAlgorithmException, CertPathValidatorException,
UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
Collection certificates = x509Factory.generateCertificates(inStream);
ensureReplyIsOurs(certificates);
// we now have established that the public keys are the same.
@@ -535,8 +539,8 @@ class ImportCmd extends Command
importCertificate((Certificate) certificates.iterator().next());
else
importChain(certificates);
-
- log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
}
/**
@@ -564,8 +568,8 @@ class ImportCmd extends Command
KeyStoreException, UnrecoverableKeyException, IOException,
UnsupportedCallbackException, CertificateException
{
- log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$
LinkedList reply = new LinkedList();
reply.addLast(certificate);
@@ -576,8 +580,8 @@ class ImportCmd extends Command
Key privateKey = getAliasPrivateKey();
store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
saveKeyStore();
-
- log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$
}
/**
@@ -608,8 +612,8 @@ class ImportCmd extends Command
CertPathValidatorException, KeyStoreException, UnrecoverableKeyException,
IOException, UnsupportedCallbackException, CertificateException
{
- log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$
LinkedList reply = orderChain(chain);
if (findTrustAndUpdate(reply, ! noPrompt))
{
@@ -618,8 +622,8 @@ class ImportCmd extends Command
store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
saveKeyStore();
}
-
- log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$
}
/**
@@ -638,10 +642,11 @@ class ImportCmd extends Command
private void ensureReplyIsOurs(Collection certificates) throws IOException,
UnsupportedCallbackException, KeyStoreException
{
- log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
Certificate certificate = (Certificate) certificates.iterator().next();
- log.finest("certificate = " + certificate); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("certificate = " + certificate); //$NON-NLS-1$
Certificate[] chain = store.getCertificateChain(alias);
if (chain == null)
throw new IllegalArgumentException(Messages.getFormattedString("ImportCmd.37", //$NON-NLS-1$
@@ -673,8 +678,8 @@ class ImportCmd extends Command
anchorPublicKey.getClass().getName() }));
if (! sameKey)
throw new IllegalArgumentException(Messages.getString("ImportCmd.41")); //$NON-NLS-1$
-
- log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
}
private boolean areEqual(DSAPublicKey pk1, DSAPublicKey pk2)
@@ -726,7 +731,8 @@ class ImportCmd extends Command
*/
private LinkedList orderChain(Collection chain)
{
- log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$
LinkedList in = new LinkedList(chain);
int initialCount = in.size();
LinkedList result = new LinkedList();
@@ -750,7 +756,8 @@ class ImportCmd extends Command
new Object[] { Integer.valueOf(result.size()),
Integer.valueOf(initialCount) }));
}
- log.entering(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$
return result;
}
@@ -786,7 +793,8 @@ class ImportCmd extends Command
KeyStoreException, UnrecoverableKeyException, UnsupportedCallbackException,
CertificateEncodingException
{
- log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$
CertPathValidator validator = CertPathValidator.getInstance("PKIX"); //$NON-NLS-1$
X509CertPath certPath = new X509CertPath(reply);
PKIXCertPathValidatorResult cpvr = findTrustInStore(certPath, validator);
@@ -824,16 +832,17 @@ class ImportCmd extends Command
reply.addLast(trustedCert);
result = true;
}
- log.entering(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$
- Boolean.valueOf(result));
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$
+ Boolean.valueOf(result));
return result;
}
private PKIXCertPathValidatorResult findTrustInStore(X509CertPath certPath,
CertPathValidator validator)
{
- log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$
PKIXCertPathValidatorResult result;
try
{
@@ -847,8 +856,8 @@ class ImportCmd extends Command
x);
result = null;
}
-
- log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$
return result;
}
@@ -864,8 +873,9 @@ class ImportCmd extends Command
*/
private PKIXParameters getCertPathParameters(String type, String pathName)
{
- log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$
- new Object[] { type, pathName });
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$
+ new Object[] { type, pathName });
FileInputStream stream = null;
PKIXParameters result = null;
try
@@ -877,7 +887,8 @@ class ImportCmd extends Command
}
catch (Exception x)
{
- log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$
}
finally
{
@@ -890,7 +901,8 @@ class ImportCmd extends Command
{
}
}
- log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$
return result;
}
@@ -898,7 +910,8 @@ class ImportCmd extends Command
X509CertPath certPath,
PKIXParameters params)
{
- log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$
PKIXCertPathValidatorResult result = null;
if (params != null)
try
@@ -908,9 +921,11 @@ class ImportCmd extends Command
}
catch (Exception x)
{
- log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$
}
- log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$
return result;
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
index 61a8eb880f3..81549864b9e 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -209,22 +210,24 @@ class KeyCloneCmd extends Command
setAliasParam(_alias);
setKeyPasswordNoPrompt(_password);
setDestinationAlias(_destAlias);
-
- log.finer("-keyclone handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -dest=" + destinationAlias); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-keyclone handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -dest=" + destinationAlias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
UnsupportedCallbackException, UnrecoverableKeyException,
CertificateException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
if (store.containsAlias(destinationAlias))
throw new SecurityException(Messages.getString("KeyCloneCmd.23")); //$NON-NLS-1$
@@ -236,16 +239,16 @@ class KeyCloneCmd extends Command
store.setKeyEntry(destinationAlias, privateKey, newKeyPasswordChars, chain);
saveKeyStore();
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.KEYCLONE_CMD, true);
result.setHeader(Messages.getString("KeyCloneCmd.22")); //$NON-NLS-1$
result.setFooter(Messages.getString("KeyCloneCmd.21")); //$NON-NLS-1$
@@ -331,8 +334,8 @@ class KeyCloneCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
index 83beb161b06..89e6daa0249 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
@@ -195,22 +196,24 @@ class KeyPasswdCmd extends Command
setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
setAliasParam(_alias);
setKeyPasswordNoPrompt(_password);
-
- log.finer("-keypasswd handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -new=" + _newPassword); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-keypasswd handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -new=" + _newPassword); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
UnsupportedCallbackException, UnrecoverableKeyException,
CertificateException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
// 1. get the key entry and certificate chain associated to alias
Key privateKey = getAliasPrivateKey();
Certificate[] chain = store.getCertificateChain(alias);
@@ -221,16 +224,16 @@ class KeyPasswdCmd extends Command
// 3. persist the key store
saveKeyStore();
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.KEYPASSWD_CMD, true);
result.setHeader(Messages.getString("KeyPasswdCmd.23")); //$NON-NLS-1$
result.setFooter(Messages.getString("KeyPasswdCmd.22")); //$NON-NLS-1$
@@ -307,8 +310,8 @@ class KeyPasswdCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
index 99fcfa2cf9a..61cec01a4dc 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -181,32 +182,36 @@ class ListCmd extends Command
if (verbose & rfc)
{
- log.warning("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$
- + "Only the former will be considered"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$
+ + "Only the former will be considered"); //$NON-NLS-1$
rfc = false;
}
-
- log.finer("-list handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
- log.finer(" -rfc=" + rfc); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-list handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ log.fine(" -rfc=" + rfc); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, CertificateEncodingException,
IOException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
PrintWriter writer = new PrintWriter(outStream, true);
writer.println(Messages.getFormattedString("ListCmd.21", store.getType())); //$NON-NLS-1$
writer.println(Messages.getFormattedString("ListCmd.22", //$NON-NLS-1$
store.getProvider().getName()));
if (all)
{
- log.finest("About to list all aliases in key store..."); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.fine("About to list all aliases in key store..."); //$NON-NLS-1$
writer.println();
writer.println(Messages.getFormattedString("ListCmd.24", //$NON-NLS-1$
Integer.valueOf(store.size())));
@@ -219,16 +224,16 @@ class ListCmd extends Command
}
else
list1Alias(alias, writer);
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.LIST_CMD, true);
result.setHeader(Messages.getString("ListCmd.20")); //$NON-NLS-1$
result.setFooter(Messages.getString("ListCmd.19")); //$NON-NLS-1$
@@ -295,8 +300,8 @@ class ListCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
@@ -314,12 +319,12 @@ class ListCmd extends Command
private void list1Alias(String anAlias, PrintWriter writer)
throws KeyStoreException, CertificateEncodingException, IOException
{
- log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$
writer.println();
writer.println(Messages.getFormattedString("ListCmd.30", anAlias)); //$NON-NLS-1$
- writer.println(Messages.getFormattedString("ListCmd.31", store.getCreationDate(anAlias))); //$NON-NLS-1$
-
+ writer.println(Messages.getFormattedString("ListCmd.31", //$NON-NLS-1$
+ store.getCreationDate(anAlias)));
if (store.isCertificateEntry(anAlias))
{
writer.println(Messages.getString("ListCmd.32")); //$NON-NLS-1$
@@ -335,7 +340,8 @@ class ListCmd extends Command
else
throw new IllegalArgumentException(Messages.getFormattedString("ListCmd.34", //$NON-NLS-1$
anAlias));
- log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$
}
/**
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
index 582aba08228..08d55556efd 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.common.ProviderUtil;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
@@ -74,6 +75,7 @@ public class Main
static final String STOREPASSWD_CMD = "storepasswd"; //$NON-NLS-1$
static final String KEYPASSWD_CMD = "keypasswd"; //$NON-NLS-1$
static final String DELETE_CMD = "delete"; //$NON-NLS-1$
+ static final String CACERT_CMD = "cacert"; //$NON-NLS-1$
static final String _GENKEY = "-" + GENKEY_CMD; //$NON-NLS-1$
static final String _IMPORT = "-" + IMPORT_CMD; //$NON-NLS-1$
@@ -88,6 +90,7 @@ public class Main
static final String _KEYPASSWD = "-" + KEYPASSWD_CMD; //$NON-NLS-1$
static final String _DELETE = "-" + DELETE_CMD; //$NON-NLS-1$
static final String _HELP = "-help"; //$NON-NLS-1$
+ static final String _CACERT = "-" + CACERT_CMD; //$NON-NLS-1$
static final String ALIAS_OPT = "alias"; //$NON-NLS-1$
static final String SIGALG_OPT = "sigalg"; //$NON-NLS-1$
@@ -119,16 +122,20 @@ public class Main
private int gnuCallbacksNdx = -2;
/** The command line parser. */
private Parser cmdLineParser;
+ /** The shutdown hook. */
+ private ShutdownHook shutdownThread;
private Main()
{
super();
+ shutdownThread = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
}
public static final void main(String[] args)
{
- log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
Main tool = new Main();
int result = 1;
try
@@ -145,21 +152,25 @@ public class Main
}
catch (SecurityException x)
{
- log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
System.err.println(Messages.getFormattedString("Main.6", //$NON-NLS-1$
x.getMessage()));
}
catch (Exception x)
{
- log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
System.err.println(Messages.getFormattedString("Main.8", x)); //$NON-NLS-1$
}
finally
{
tool.teardown();
+ if (tool.shutdownThread != null)
+ Runtime.getRuntime().removeShutdownHook(tool.shutdownThread);
}
-
- log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
System.exit(result);
}
@@ -167,19 +178,19 @@ public class Main
private void setup()
{
- log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
cmdLineParser = getParser();
gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto());
gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks());
-
- log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
}
private void start(String[] args) throws Exception
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
if (args == null || args.length == 0)
throw new OptionException(""); //$NON-NLS-1$
@@ -213,6 +224,8 @@ public class Main
cmd = new KeyPasswdCmd();
else if (_DELETE.equals(opt))
cmd = new DeleteCmd();
+ else if (_CACERT.equals(opt))
+ cmd = new CACertCmd();
else if (_HELP.equals(opt))
throw new OptionException(""); //$NON-NLS-1$
else
@@ -224,14 +237,14 @@ public class Main
args = cmd.processArgs(cmdArgs);
cmd.doCommand();
}
-
- log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
}
private Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(KEYTOOL_TOOL, true);
result.setHeader(Messages.getString("Main.19")); //$NON-NLS-1$
result.setFooter(Messages.getString("Main.20")); //$NON-NLS-1$
@@ -260,16 +273,18 @@ public class Main
Messages.getString("Main.32"))); //$NON-NLS-1$
cmdGroup.add(new NoParseOption(DELETE_CMD,
Messages.getString("Main.33"))); //$NON-NLS-1$
+ cmdGroup.add(new NoParseOption(CACERT_CMD,
+ Messages.getString("Main.5"))); //$NON-NLS-1$
result.add(cmdGroup);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
- private void teardown()
+ void teardown()
{
- log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
// if we added our own providers remove them
if (gnuCryptoProviderNdx > 0)
ProviderUtil.removeProvider(Registry.GNU_CRYPTO);
@@ -277,7 +292,8 @@ public class Main
if (gnuCallbacksNdx > 0)
ProviderUtil.removeProvider("GNU-CALLBACKS"); //$NON-NLS-1$
- log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
}
private void printHelp()
@@ -309,4 +325,13 @@ public class Main
// do nothing
}
}
+
+ private class ShutdownHook
+ extends Thread
+ {
+ public void run()
+ {
+ teardown();
+ }
+ }
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
index 7ecaa1c37ab..ea2825f105d 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
@@ -38,6 +38,8 @@
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
+
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@@ -99,8 +101,9 @@ class Messages
}
catch (IllegalArgumentException x)
{
- log.fine("Exception while rendering a message format keyed by ["
- + key + "]: " + mf.toPattern());
+ if (Configuration.DEBUG)
+ log.fine("Exception while rendering a message format keyed by ["
+ + key + "]: " + mf.toPattern());
return constructMessage(mf.toPattern(), args);
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
index d259258e723..2c5461b3619 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -86,31 +87,33 @@ class PrintCertCmd extends Command
void setup() throws Exception
{
setInputStreamParam(_certFileName);
-
- log.finer("-printcert handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -file=" + _certFileName); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-printcert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -file=" + _certFileName); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws CertificateException
{
- log.entering(getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(getClass().getName(), "start"); //$NON-NLS-1$
CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
Certificate certificate = x509Factory.generateCertificate(inStream);
PrintWriter writer = new PrintWriter(System.out, true);
writer.println();
printVerbose(certificate, writer);
-
- log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.PRINTCERT_CMD, true);
result.setHeader(Messages.getString("PrintCertCmd.5")); //$NON-NLS-1$
result.setFooter(Messages.getString("PrintCertCmd.6")); //$NON-NLS-1$
@@ -133,8 +136,8 @@ class PrintCertCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
index db700a164e0..75f1e8299ed 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
@@ -264,24 +265,26 @@ class SelfCertCmd extends Command
setAliasParam(_alias);
setKeyPasswordNoPrompt(_password);
setValidityParam(_validityStr);
-
- log.finer("-selfcert handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -alias=" + alias); //$NON-NLS-1$
- log.finer(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
- log.finer(" -dname=" + _dName); //$NON-NLS-1$
- log.finer(" -validity=" + validityInDays); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-selfcert handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -alias=" + alias); //$NON-NLS-1$
+ log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+ log.fine(" -dname=" + _dName); //$NON-NLS-1$
+ log.fine(" -validity=" + validityInDays); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException, IOException, UnsupportedCallbackException,
InvalidKeyException, SignatureException, CertificateException
{
- log.entering(getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(getClass().getName(), "start"); //$NON-NLS-1$
// 1. get the key entry and certificate chain associated to alias
Key privateKey = getAliasPrivateKey();
Certificate[] chain = store.getCertificateChain(alias);
@@ -310,16 +313,16 @@ class SelfCertCmd extends Command
// 7. persist the key store
saveKeyStore();
-
- log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.SELFCERT_CMD, true);
result.setHeader(Messages.getString("SelfCertCmd.14")); //$NON-NLS-1$
result.setFooter(Messages.getString("SelfCertCmd.15")); //$NON-NLS-1$
@@ -414,8 +417,8 @@ class SelfCertCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
index 6c4dfddb92a..1313ec6abe7 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
+import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
@@ -159,30 +160,32 @@ class StorePasswdCmd extends Command
{
setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
setNewKeystorePassword(_newPassword);
-
- log.finer("-storepasswd handler will use the following options:"); //$NON-NLS-1$
- log.finer(" -storetype=" + storeType); //$NON-NLS-1$
- log.finer(" -keystore=" + storeURL); //$NON-NLS-1$
- log.finer(" -provider=" + provider); //$NON-NLS-1$
- log.finer(" -v=" + verbose); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ {
+ log.fine("-storepasswd handler will use the following options:"); //$NON-NLS-1$
+ log.fine(" -storetype=" + storeType); //$NON-NLS-1$
+ log.fine(" -keystore=" + storeURL); //$NON-NLS-1$
+ log.fine(" -provider=" + provider); //$NON-NLS-1$
+ log.fine(" -v=" + verbose); //$NON-NLS-1$
+ }
}
void start() throws KeyStoreException, NoSuchAlgorithmException,
CertificateException, IOException
{
- log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
saveKeyStore(newStorePasswordChars);
-
- log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
}
// own methods --------------------------------------------------------------
Parser getParser()
{
- log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
-
+ if (Configuration.DEBUG)
+ log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
Parser result = new ClasspathToolParser(Main.STOREPASSWD_CMD, true);
result.setHeader(Messages.getString("StorePasswdCmd.18")); //$NON-NLS-1$
result.setFooter(Messages.getString("StorePasswdCmd.17")); //$NON-NLS-1$
@@ -241,8 +244,8 @@ class StorePasswdCmd extends Command
}
});
result.add(options);
-
- log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+ if (Configuration.DEBUG)
+ log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
return result;
}
diff --git a/libjava/classpath/tools/gserialver.in b/libjava/classpath/tools/gserialver.in
new file mode 100644
index 00000000000..15ed3f996c5
--- /dev/null
+++ b/libjava/classpath/tools/gserialver.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath serialver tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.serialver.Main "$@"
diff --git a/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java b/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
index d8616063d19..d4985bf2f2e 100644
--- a/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
+++ b/libjava/classpath/vm/reference/gnu/classpath/jdwp/VMVirtualMachine.java
@@ -199,7 +199,7 @@ public class VMVirtualMachine
* @return an array of virtual machine methods
*/
public static native VMMethod[] getAllClassMethods (Class klass)
- { return null; }
+ throws JdwpException;
/**
* A factory method for getting valid virtual machine methods
@@ -213,7 +213,7 @@ public class VMVirtualMachine
* @throws JdwpException for any other error
*/
public static native VMMethod getClassMethod(Class klass, long id)
- { return null; }
+ throws JdwpException;
/**
* Returns the thread's call stack
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
new file mode 100644
index 00000000000..c1c7d13dd44
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
@@ -0,0 +1,89 @@
+/* VMClassLoadingMXBeanImpl.java - VM impl. of a class loading bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMClassLoadingMXBeanImpl
+{
+
+ /**
+ * Returns the number of classes currently loaded by
+ * the virtual machine.
+ *
+ * @return the number of loaded classes.
+ */
+ static native int getLoadedClassCount();
+
+ /**
+ * Returns the number of classes that have been unloaded
+ * by the virtual machine since it was started.
+ *
+ * @return the number of unloaded classes.
+ */
+ static native long getUnloadedClassCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when classes are loaded and unloaded. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ static native boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when classes are loaded and unloaded. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ */
+ static native void setVerbose(boolean verbose);
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java
new file mode 100644
index 00000000000..b9b5bbcefc7
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMCompilationMXBeanImpl.java
@@ -0,0 +1,66 @@
+/* VMCompilationMXBeanImpl.java - VM implementation of a compilation bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the JIT
+ * compiler of the virtual machine, if one exists.
+ * Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getCompilationMXBean()},
+ * if this is the case.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMCompilationMXBeanImpl
+{
+
+ /**
+ * Returns the number of milliseconds the JIT
+ * compiler has spent compiling Java bytecode
+ * to native machine code. This is only called
+ * if a JIT compiler exists and the
+ * gnu.java.lang.management.CompilationTimeSupport
+ * property has been set.
+ *
+ * @return the number of milliseconds spent
+ * compiling.
+ */
+ static native long getTotalCompilationTime();
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java
new file mode 100644
index 00000000000..2a202849a8f
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java
@@ -0,0 +1,80 @@
+/* VMGarbageCollectorMXBeanImpl.java - VM interface for a GC bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the garbage collectors
+ * of the virtual machine. Garbage collectors are responsible
+ * for removing unreferenced objects from memory. A garbage
+ * collector is a type of memory manager, so this interface
+ * is combined with that of generic memory managers. An instance
+ * of this bean for each garbage collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMGarbageCollectorMXBeanImpl
+{
+
+ /**
+ * Returns the number of collections the garbage collector
+ * represented by this bean has made. -1 is returned if the
+ * collection count is undefined.
+ *
+ * @param name the name of the garbage collector.
+ * @return the number of collections made, or -1 if this is
+ * undefined.
+ */
+ static native long getCollectionCount(String name);
+
+ /**
+ * Returns the accumulated number of milliseconds this garbage
+ * collector has spent freeing the memory used by unreferenced
+ * objects. -1 is returned if the collection time is undefined.
+ * Note that the accumulated time may not change, even when the
+ * collection count increases, if the time taken is sufficiently
+ * short; this depends on the resolution of the timer used.
+ *
+ * @param name the name of the garbage collector.
+ * @return the accumulated number of milliseconds spent collecting,
+ * or -1 if this is undefined.
+ */
+ static native long getCollectionTime(String name);
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
new file mode 100644
index 00000000000..193e3353517
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
@@ -0,0 +1,109 @@
+/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryMXBeanImpl
+{
+
+ /**
+ * Returns an instance of {@link java.lang.management.MemoryUsage}
+ * with appropriate initial, used, committed and maximum values
+ * for the heap. By default, this uses the methods of
+ * {@link java.lang.Runtime} to provide some of the values.
+ *
+ * @return an {@link java.lang.management.MemoryUsage} instance
+ * for the heap.
+ */
+ static MemoryUsage getHeapMemoryUsage()
+ {
+ Runtime runtime = Runtime.getRuntime();
+ long totalMem = runtime.totalMemory();
+ return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
+ totalMem, runtime.maxMemory());
+ }
+
+ /**
+ * Returns an instance of {@link java.lang.management.MemoryUsage}
+ * with appropriate initial, used, committed and maximum values
+ * for non-heap memory.
+ *
+ * @return an {@link java.lang.management.MemoryUsage} instance
+ * for non-heap memory.
+ */
+ static native MemoryUsage getNonHeapMemoryUsage();
+
+ /**
+ * Returns the number of objects ready to be garbage collected.
+ *
+ * @return the number of finalizable objects.
+ */
+ static native int getObjectPendingFinalizationCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when memory is allocated and deallocated. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ static native boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when memory is allocated and deallocated. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ */
+ static native void setVerbose(boolean verbose);
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java
new file mode 100644
index 00000000000..0a4204a6d57
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java
@@ -0,0 +1,95 @@
+/* VMMemoryManagerMXBeanImpl.java - VM interface for a memory manager bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Provides access to information about the memory managers
+ * of the virtual machine. An instance of this bean for each
+ * memory manager is obtained by calling
+ * {@link ManagementFactory#getMemoryManagerMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryManagerMXBeanImpl
+{
+
+ /**
+ * Returns an array containing the names of the memory pools
+ * this memory manager manages.
+ *
+ * @param name the name of the memory manager.
+ * @return an array containing the name of each memory pool
+ * this manager is responsible for.
+ */
+ static String[] getMemoryPoolNames(String name)
+ {
+ List managedPools = new ArrayList();
+ Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+ String[] managers = bean.getMemoryManagerNames();
+ for (int a = 0; a < managers.length; ++a)
+ if (managers[a].equals(name))
+ {
+ managedPools.add(bean.getName());
+ break;
+ }
+ }
+ return (String[]) managedPools.toArray(new String[managedPools.size()]);
+ }
+
+ /**
+ * Returns true if this memory manager is still valid. A memory
+ * manager becomes invalid when it is removed by the virtual machine
+ * and no longer used.
+ *
+ * @param name the name of the memory manager.
+ * @return true if this memory manager is valid.
+ */
+ static native boolean isValid(String name);
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
new file mode 100644
index 00000000000..723d4e89713
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
@@ -0,0 +1,195 @@
+/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information on the memory resources or
+ * pools used by the current invocation of the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryPoolMXBeanImpl
+{
+
+ /**
+ * Returns memory usage statistics for the specified pool
+ * just after a best-effort attempt to free memory. This
+ * is valid only for certain garbage collectors.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics or <code>null</code>
+ * if this pool does not support such statistics.
+ */
+ static native MemoryUsage getCollectionUsage(String name);
+
+ /**
+ * Returns the collection usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined). The value is initially zero.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold.
+ */
+ static native long getCollectionUsageThreshold(String name);
+
+ /**
+ * Returns the number of times the collection usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold count.
+ */
+ static native long getCollectionUsageThresholdCount(String name);
+
+ /**
+ * Returns an array of names of memory managers which manage
+ * the specified pool.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a list of memory managers for the pool.
+ */
+ static native String[] getMemoryManagerNames(String name);
+
+ /**
+ * Returns the peak usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static native MemoryUsage getPeakUsage(String name);
+
+ /**
+ * Returns the type of memory used by the specified pool.
+ * The value must be either "HEAP" or "NON_HEAP".
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the type of the given pool.
+ */
+ static native String getType(String name);
+
+ /**
+ * Returns the current usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static native MemoryUsage getUsage(String name);
+
+ /**
+ * Returns the usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined). The value is initially defined by the
+ * virtual machine.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold.
+ */
+ static native long getUsageThreshold(String name);
+
+ /**
+ * Returns the number of times the usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold count.
+ */
+ static native long getUsageThresholdCount(String name);
+
+ /**
+ * Returns true if the specified pool is still valid i.e.
+ * it is still in use by the virtual machine.
+ *
+ * @param name the name of the pool to check the validity of.
+ * @return true if the pool is valid.
+ */
+ static native boolean isValid(String name);
+
+ /**
+ * Resets the peak usage level to the current usage level for
+ * the specified pool.
+ *
+ * @param name the name of the pool to reset the peak usage of.
+ */
+ static native void resetPeakUsage(String name);
+
+ /**
+ * Sets the collection usage threshold for the specified
+ * pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static native void setCollectionUsageThreshold(String name, long threshold);
+
+ /**
+ * Sets the usage threshold for the specified pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static native void setUsageThreshold(String name, long threshold);
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
new file mode 100644
index 00000000000..32a86604614
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
@@ -0,0 +1,89 @@
+/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMRuntimeMXBeanImpl
+{
+
+ /**
+ * Returns the command-line arguments supplied
+ * to the virtual machine, excluding those supplied
+ * to <code>main()</code>.
+ *
+ * @return the command-line arguments.
+ */
+ static native String[] getInputArguments();
+
+ /**
+ * Returns a developer-chosen name for the virtual
+ * machine, which may differ over different running
+ * instances of the same virtual machine binary.
+ * For example, this may include the particular
+ * process identifier used by this instance or
+ * the host name of the machine on which it is
+ * running. The intention is that this name refers
+ * to the precise entity that the other data supplied
+ * by the bean refers to, rather than the VM in general.
+ *
+ * @return the custom name of the VM.
+ */
+ static String getName()
+ {
+ return SystemProperties.getProperty("java.vm.name") + " " +
+ SystemProperties.getProperty("java.vm.version");
+ }
+
+ /**
+ * The time in milliseconds at which the virtual
+ * machine was started. This method is only executed
+ * once (for efficency), as the value is not expected
+ * to change.
+ *
+ * @return the VM start time.
+ */
+ static native long getStartTime();
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java b/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java
new file mode 100644
index 00000000000..c5bcb631055
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/lang/management/VMThreadMXBeanImpl.java
@@ -0,0 +1,207 @@
+/* VMThreadMXBeanImpl.java - VM impl. of a thread bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ThreadInfo;
+
+/**
+ * Provides access to information about the threads
+ * of the virtual machine. An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * See {@link java.lang.management.ThreadMXBean} for
+ * full documentation.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMThreadMXBeanImpl
+{
+
+ /**
+ * Cache of how many threads were found.
+ */
+ private static int filled;
+
+ /**
+ * Returns the ids of cycles of deadlocked threads, occurring
+ * due to monitor ownership.
+ *
+ * @return the ids of the deadlocked threads.
+ */
+ static native long[] findMonitorDeadlockedThreads();
+
+ /* This is the same as in Thread.getAllStackTraces() */
+ static Thread[] getAllThreads()
+ {
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ while (group.getParent() != null)
+ group = group.getParent();
+ int arraySize = group.activeCount();
+ Thread[] threadList = new Thread[arraySize];
+ filled = group.enumerate(threadList);
+ while (filled == arraySize)
+ {
+ arraySize *= 2;
+ threadList = new Thread[arraySize];
+ filled = group.enumerate(threadList);
+ }
+ return threadList;
+ }
+
+ /**
+ * Returns the id of all live threads at the time of execution.
+ *
+ * @return the live thread ids.
+ */
+ static long[] getAllThreadIds()
+ {
+ Thread[] threadList = getAllThreads();
+ long[] ids = new long[filled];
+ for (int a = 0; a < filled; ++a)
+ ids[a] = threadList[a].getId();
+ return ids;
+ }
+
+ /**
+ * Returns the number of nanoseconds of CPU time
+ * the current thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @return the nanoseconds of CPU time used by
+ * the current thread.
+ */
+ static native long getCurrentThreadCpuTime();
+
+ /**
+ * Returns the number of nanoseconds of user time
+ * the current thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @return the nanoseconds of user time used by
+ * the current thread.
+ */
+ static native long getCurrentThreadUserTime();
+
+ /**
+ * Returns the number of live daemon threads.
+ *
+ * @return the number of live daemon threads.
+ */
+ static int getDaemonThreadCount()
+ {
+ Thread[] threadList = getAllThreads();
+ int daemonCount = 0;
+ for (int a = 0; a < filled; ++a)
+ {
+ if (threadList[a].isDaemon())
+ ++daemonCount;
+ }
+ return daemonCount;
+ }
+
+ /**
+ * Returns the current peak number of live threads.
+ *
+ * @return the peak number of live threads.
+ */
+ static native int getPeakThreadCount();
+
+ /**
+ * Returns the number of live threads.
+ *
+ * @return the number of live threads.
+ */
+ static int getThreadCount()
+ {
+ getAllThreads();
+ return filled;
+ }
+
+ /**
+ * Returns the number of nanoseconds of CPU time
+ * the specified thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @param id the thread to obtain statistics on.
+ * @return the nanoseconds of CPU time used by
+ * the thread.
+ */
+ static native long getThreadCpuTime(long id);
+
+ /**
+ * Returns the {@link java.lang.management.ThreadInfo}
+ * which corresponds to the specified id.
+ *
+ * @param id the id of the thread.
+ * @param maxDepth the depth of the stack trace.
+ * @return the corresponding <code>ThreadInfo</code>.
+ */
+ static native ThreadInfo getThreadInfoForId(long id, int maxDepth);
+
+ /**
+ * Returns the number of nanoseconds of user time
+ * the specified thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @param id the thread to obtain statistics on.
+ * @return the nanoseconds of user time used by
+ * the thread.
+ */
+ static native long getThreadUserTime(long id);
+
+ /**
+ * Returns the total number of threads that have
+ * been started over the lifetime of the virtual
+ * machine.
+ *
+ * @return the total number of threads started.
+ */
+ static native long getTotalStartedThreadCount();
+
+ /**
+ * Resets the peak thread count to the current
+ * number of live threads.
+ */
+ static native void resetPeakThreadCount();
+
+}
diff --git a/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
new file mode 100644
index 00000000000..fdea8ff6213
--- /dev/null
+++ b/libjava/classpath/vm/reference/gnu/java/nio/VMChannel.java
@@ -0,0 +1,197 @@
+/* VMChannel.java -- Native interface suppling channel operations.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import gnu.classpath.Configuration;
+import gnu.java.net.PlainSocketImpl;
+import gnu.java.nio.PipeImpl.SinkChannelImpl;
+import gnu.java.nio.PipeImpl.SourceChannelImpl;
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Native interface to support configuring of channel to run in a non-blocking
+ * manner and support scatter/gather io operations.
+ *
+ * @author Michael Barker <mike@middlesoft.co.uk>
+ *
+ */
+public class VMChannel
+{
+ private final int fd;
+
+ private VMChannel(int fd)
+ {
+ this.fd = fd;
+ }
+
+ public static VMChannel getVMChannel(PlainSocketImpl socket)
+ {
+ return new VMChannel(socket.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(SourceChannelImpl source)
+ {
+ return new VMChannel(source.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(SinkChannelImpl sink)
+ {
+ return new VMChannel(sink.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(FileChannelImpl file)
+ {
+ return new VMChannel(file.getNativeFD());
+ }
+
+ static
+ {
+ // load the shared library needed for native methods.
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary ("javanio");
+ }
+ initIDs();
+ }
+
+ /**
+ * Set the file descriptor to have the required blocking
+ * setting.
+ *
+ * @param fd
+ * @param blocking
+ */
+ public native void setBlocking(int fd, boolean blocking);
+
+ public void setBlocking(boolean blocking)
+ {
+ setBlocking(fd, blocking);
+ }
+
+
+ /**
+ * Reads a byte buffer directly using the supplied file descriptor.
+ * Assumes that the buffer is a DirectBuffer.
+ *
+ * @param fd Native file descriptor to read from.
+ * @param dst Direct Byte Buffer to read to.
+ * @return Number of bytes read.
+ * @throws IOException If an error occurs or dst is not a direct buffers.
+ */
+ native int read(int fd, ByteBuffer dst)
+ throws IOException;
+
+ public int read(ByteBuffer dst)
+ throws IOException
+ {
+ return read(fd, dst);
+ }
+
+ /**
+ * Reads into byte buffers directly using the supplied file descriptor.
+ * Assumes that the buffer list contains DirectBuffers. Will perform a
+ * scattering read.
+ *
+ * @param fd Native file descriptor to read from.
+ * @param dsts An array direct byte buffers.
+ * @param offset Index of the first buffer to read to.
+ * @param length The number of buffers to read to.
+ * @return Number of bytes read.
+ * @throws IOException If an error occurs or the dsts are not direct buffers.
+ */
+ native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
+ throws IOException;
+
+ public long readScattering(ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if (offset + length > dsts.length)
+ throw new IndexOutOfBoundsException("offset + length > dsts.length");
+
+ return readScattering(fd, dsts, offset, length);
+ }
+
+ /**
+ * Writes from a direct byte bufer using the supplied file descriptor.
+ * Assumes the buffer is a DirectBuffer.
+ *
+ * @param fd
+ * @param src
+ * @return Number of bytes written.
+ * @throws IOException
+ */
+ native int write(int fd, ByteBuffer src)
+ throws IOException;
+
+ public int write(ByteBuffer src)
+ throws IOException
+ {
+ return write(fd, src);
+ }
+
+ /**
+ * Writes from byte buffers directly using the supplied file descriptor.
+ * Assumes the that buffer list constains DirectBuffers. Will perform
+ * as gathering write.
+ *
+ * @param fd
+ * @param srcs
+ * @param offset
+ * @param length
+ * @return Number of bytes written.
+ * @throws IOException
+ */
+ native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ public long writeGathering(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if (offset + length > srcs.length)
+ throw new IndexOutOfBoundsException("offset + length > srcs.length");
+
+ return writeGathering(fd, srcs, offset, length);
+ }
+
+ private native static void initIDs();
+
+}
diff --git a/libjava/classpath/vm/reference/java/io/VMFile.java b/libjava/classpath/vm/reference/java/io/VMFile.java
index 2931044c853..2f48aad71f8 100644
--- a/libjava/classpath/vm/reference/java/io/VMFile.java
+++ b/libjava/classpath/vm/reference/java/io/VMFile.java
@@ -1,5 +1,5 @@
/* VMFile.java -- Class for methods natively accessing files
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -210,10 +210,10 @@ final class VMFile
/**
* This method returns a canonical representation of the pathname of
- * the given path. The actual form of the canonical representation is
- * different. On the GNU system, the canonical form differs from the
- * absolute form in that all relative file references to "." and ".."
- * are resolved and removed.
+ * this file. The actual form of the canonical representation is
+ * system-dependent. On the GNU system, conversion to canonical
+ * form involves the removal of redundant separators, references to
+ * "." and "..", and symbolic links.
* <p>
* Note that this method, unlike the other methods which return path
* names, can throw an IOException. This is because native method
@@ -221,9 +221,5 @@ final class VMFile
*
* @exception IOException If an error occurs
*/
- public static String toCanonicalForm(String path) throws IOException
- {
- // FIXME: this only works on UNIX
- return PlatformHelper.toCanonicalForm(path);
- }
+ public static native String toCanonicalForm(String path) throws IOException;
}
diff --git a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java
index 4caa58c2ae6..897df5186b3 100644
--- a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java
+++ b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java
@@ -75,6 +75,10 @@ final class VMClassLoader
/** packages loaded by the bootstrap class loader */
static final HashMap definedPackages = new HashMap();
+ /** jars from property java.boot.class.path */
+ static final HashMap bootjars = new HashMap();
+
+
/**
* Converts the array string of native package names to
* Packages. The packages are then put into the
@@ -168,10 +172,6 @@ final class VMClassLoader
return (URL)e.nextElement();
return null;
}
-
- /** jars from property java.boot.class.path */
- static final HashMap bootjars = new HashMap();
-
/**
* Helper to get a list of resources from the bootstrap class loader.
*
diff --git a/libjava/classpath/vm/reference/java/lang/VMSystem.java b/libjava/classpath/vm/reference/java/lang/VMSystem.java
index f96986df373..bf46b27aa92 100644
--- a/libjava/classpath/vm/reference/java/lang/VMSystem.java
+++ b/libjava/classpath/vm/reference/java/lang/VMSystem.java
@@ -135,7 +135,10 @@ final class VMSystem
* @return the current time
* @see java.util.Date
*/
- public static native long currentTimeMillis();
+ public static long currentTimeMillis()
+ {
+ return nanoTime() / 1000000L;
+ }
/**
* <p>
@@ -162,10 +165,7 @@ final class VMSystem
* @return the time of a system timer in nanoseconds.
* @since 1.5
*/
- public static long nanoTime()
- {
- return currentTimeMillis() * 1000;
- }
+ public static native long nanoTime();
/**
* Returns a list of 'name=value' pairs representing the current environment
diff --git a/libjava/classpath/vm/reference/java/lang/VMThread.java b/libjava/classpath/vm/reference/java/lang/VMThread.java
index 302de6c35a8..ff0ec687863 100644
--- a/libjava/classpath/vm/reference/java/lang/VMThread.java
+++ b/libjava/classpath/vm/reference/java/lang/VMThread.java
@@ -446,4 +446,16 @@ final class VMThread
return false;
}
}
+
+ /**
+ * Returns the current state of the thread.
+ * The value must be one of "BLOCKED", "NEW",
+ * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
+ * "WAITING".
+ *
+ * @return a string corresponding to one of the
+ * thread enumeration states specified above.
+ */
+ native String getState();
+
}
diff --git a/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java b/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java
new file mode 100644
index 00000000000..f10497014b4
--- /dev/null
+++ b/libjava/classpath/vm/reference/java/lang/management/VMManagementFactory.java
@@ -0,0 +1,75 @@
+/* VMManagementFactory.java - VM interface for obtaining system beans.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides lists of resources required by the
+ * {@link java.lang.management.ManagementFactory} for
+ * creating beans.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMManagementFactory
+{
+
+ /**
+ * Return a list of the names of the currently available
+ * memory pools within the virtual machine.
+ *
+ * @return a list of memory pool names.
+ */
+ static native String[] getMemoryPoolNames();
+
+ /**
+ * Return a list of the names of the currently available
+ * memory managers within the virtual machine. This should
+ * not include the garbage collectors listed below.
+ *
+ * @return a list of memory manager names.
+ */
+ static native String[] getMemoryManagerNames();
+
+ /**
+ * Return a list of the names of the currently available
+ * garbage collectors within the virtual machine.
+ *
+ * @return a list of garbage collector names.
+ */
+ static native String[] getGarbageCollectorNames();
+}
diff --git a/libjava/classpath/vm/reference/java/net/VMURLConnection.java b/libjava/classpath/vm/reference/java/net/VMURLConnection.java
new file mode 100644
index 00000000000..19bf5814e67
--- /dev/null
+++ b/libjava/classpath/vm/reference/java/net/VMURLConnection.java
@@ -0,0 +1,79 @@
+/* VMURLConnection - VM code for URLConnection
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+final class VMURLConnection
+{
+ public static final int LENGTH = 1024;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanet");
+ init();
+ }
+
+ private static native void init();
+
+ private static native String guessContentTypeFromBuffer(byte[] b, int valid);
+
+ /**
+ * This is called from URLConnection to guess the mime type of a
+ * stream. This method may return null to indicate that it could
+ * not guess a type.
+ */
+ static String guessContentTypeFromStream(InputStream is)
+ throws IOException
+ {
+ if (! is.markSupported())
+ return null;
+ is.mark(LENGTH);
+ byte[] bytes = new byte[LENGTH];
+ int r = is.read(bytes);
+ if (r < 0)
+ return null;
+ is.reset();
+ return guessContentTypeFromBuffer(bytes, r);
+ }
+}
diff --git a/libjava/classpath/vm/reference/gnu/classpath/Unsafe.java b/libjava/classpath/vm/reference/sun/misc/Unsafe.java
index 6e4ec98027f..fa199f83e0a 100644
--- a/libjava/classpath/vm/reference/gnu/classpath/Unsafe.java
+++ b/libjava/classpath/vm/reference/sun/misc/Unsafe.java
@@ -35,7 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath;
+package sun.misc;
import java.lang.reflect.Field;
@@ -48,7 +48,7 @@ import java.lang.reflect.Field;
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
*/
-public final class Unsafe
+public class Unsafe
{
// Singleton class.
private static Unsafe unsafe = new Unsafe();
@@ -279,7 +279,7 @@ public final class Unsafe
* @param arrayClass the class for which the first element's address should
* be obtained.
* @return the offset of the first element of the array class.
- * @see #arrayIndexScale(Class)
+ * @see arrayIndexScale(Class)
*/
public native int arrayBaseOffset(Class arrayClass);
diff --git a/libjava/classpath/vm/reference/sun/reflect/Reflection.java b/libjava/classpath/vm/reference/sun/reflect/Reflection.java
new file mode 100644
index 00000000000..ef25ce71f1c
--- /dev/null
+++ b/libjava/classpath/vm/reference/sun/reflect/Reflection.java
@@ -0,0 +1,51 @@
+/* Reflection.java - JSR 166 reflection hooks
+ 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 sun.reflect;
+
+import gnu.classpath.VMStackWalker;
+
+public class Reflection
+{
+ /**
+ * A stack-walking wrapper method used by the JSR 166 RI.
+ */
+ public static Class getCallerClass(int depth)
+ {
+ return VMStackWalker.getClassContext()[depth];
+ }
+}
diff --git a/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java b/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java
new file mode 100644
index 00000000000..aa89c50ac9b
--- /dev/null
+++ b/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java
@@ -0,0 +1,92 @@
+/* ReflectUtil.java - JSR 166 reflection hooks
+ 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 sun.reflect.misc;
+
+import java.lang.reflect.Modifier;
+
+public class ReflectUtil
+{
+ // We use this inaccessible inner class as an argument type
+ // in verifyMemberAccess. All current users of this method
+ // in the JSR 166 RI pass 'null' for this argument, and
+ // consequently we don't know what it means. Using a funny
+ // type like this for the argument means that if the RI changes,
+ // we will see a compilation error.
+ private static class MustBeNull
+ {
+ }
+
+ public static void checkPackageAccess(Class declaringClass)
+ {
+ // FIXME: not sure what to check here.
+ }
+
+ /**
+ * Perform access checks on a member of a class. This API is
+ * derived from the public domain code in the JSR 166 reference
+ * implementation.
+ * @param caller the class requesting access to the member
+ * @param declarer the declaring class of the member
+ * @param ignored unknown parameter; always null
+ * @param modifiers the modifiers on the member
+ */
+ public static void ensureMemberAccess(Class caller,
+ Class declarer,
+ MustBeNull ignored,
+ int modifiers)
+ {
+ // Same class, always ok.
+ if (caller == declarer)
+ return;
+ // Public access is ok.
+ if ((modifiers & Modifier.PUBLIC) != 0)
+ return;
+ // Protected access and request comes from
+ // a subclass of the declarer -- ok.
+ if ((modifiers & Modifier.PROTECTED) != 0
+ && declarer.isAssignableFrom(caller))
+ return;
+ // Package-private access, or protected access,
+ // and the packages are the same --ok.
+ if ((modifiers & Modifier.PRIVATE) == 0
+ && caller.getPackage() == declarer.getPackage())
+ return;
+ // Otherwise, no.
+ throw new IllegalAccessError();
+ }
+}
diff --git a/libjava/configure b/libjava/configure
index 43b9920619c..e305b1f3658 100755
--- a/libjava/configure
+++ b/libjava/configure
@@ -854,6 +854,7 @@ Optional Features:
in a compiler-specific directory
--enable-multilib build many library versions (default)
--enable-plugin build gcjwebplugin web browser plugin
+ --enable-gconf-peer compile GConf native peers for util.preferences
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-maintainer-mode enable make rules and dependencies not useful
@@ -1642,6 +1643,21 @@ else
fi;
+# Check whether --enable-gconf-peer or --disable-gconf-peer was given.
+if test "${enable_gconf_peer+set}" = set; then
+ enableval="$enable_gconf_peer"
+ case "$enableval" in
+ yes) gconf_enabled=yes ;;
+ no) gconf_enabled=no ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable gconf-peer" >&5
+echo "$as_me: error: Unknown argument to enable/disable gconf-peer" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+else
+ gconf_enabled=no
+
+fi;
+
# It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX.
@@ -5034,6 +5050,10 @@ ac_configure_args="$ac_configure_args --with-glibj=build"
if test "$plugin_enabled" != yes; then
ac_configure_args="$ac_configure_args --disable-plugin"
fi
+if test "$gconf_enabled" != yes; then
+ ac_configure_args="$ac_configure_args --disable-gconf-peer"
+ ac_configure_args="$ac_configure_args --enable-default-preferences-peer=gnu.java.util.prefs.FileBasedFactory"
+fi
if test "$use_gtk_awt" != yes; then
ac_configure_args="$ac_configure_args --disable-gtk-peer"
fi
@@ -5856,7 +5876,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5859 "configure"' > conftest.$ac_ext
+ echo '#line 5879 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -6859,7 +6879,7 @@ if test "${enable_sjlj_exceptions+set}" = set; then
:
else
cat > conftest.$ac_ext << EOF
-#line 6862 "configure"
+#line 6882 "configure"
struct S { ~S(); };
void bar();
void foo()
diff --git a/libjava/configure.ac b/libjava/configure.ac
index e529593d1e6..cc53350cd79 100644
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -95,6 +95,17 @@ AC_ARG_ENABLE(plugin,
[plugin_enabled=no]
)
+AC_ARG_ENABLE(gconf-peer,
+ AS_HELP_STRING([--enable-gconf-peer],
+ [compile GConf native peers for util.preferences]),
+ [case "$enableval" in
+ yes) gconf_enabled=yes ;;
+ no) gconf_enabled=no ;;
+ *) AC_MSG_ERROR([Unknown argument to enable/disable gconf-peer]);;
+ esac],
+ [gconf_enabled=no]
+)
+
# It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX.
GCC_NO_EXECUTABLES
@@ -346,6 +357,10 @@ ac_configure_args="$ac_configure_args --with-glibj=build"
if test "$plugin_enabled" != yes; then
ac_configure_args="$ac_configure_args --disable-plugin"
fi
+if test "$gconf_enabled" != yes; then
+ ac_configure_args="$ac_configure_args --disable-gconf-peer"
+ ac_configure_args="$ac_configure_args --enable-default-preferences-peer=gnu.java.util.prefs.FileBasedFactory"
+fi
if test "$use_gtk_awt" != yes; then
ac_configure_args="$ac_configure_args --disable-gtk-peer"
fi
diff --git a/libjava/gcj/Makefile.in b/libjava/gcj/Makefile.in
index 91db9b0518c..44db450cbd2 100644
--- a/libjava/gcj/Makefile.in
+++ b/libjava/gcj/Makefile.in
@@ -251,6 +251,7 @@ bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
+build_libsubdir = @build_libsubdir@
build_os = @build_os@
build_subdir = @build_subdir@
build_vendor = @build_vendor@
diff --git a/libjava/gnu/awt/xlib/XToolkit.java b/libjava/gnu/awt/xlib/XToolkit.java
index 6651ae789a2..98ef7c162b3 100644
--- a/libjava/gnu/awt/xlib/XToolkit.java
+++ b/libjava/gnu/awt/xlib/XToolkit.java
@@ -28,7 +28,6 @@ import gnu.gcj.xlib.Visual;
import gnu.java.awt.ClasspathToolkit;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.peer.ClasspathFontPeer;
-import gnu.java.awt.peer.ClasspathTextLayoutPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
public class XToolkit extends ClasspathToolkit
@@ -405,12 +404,6 @@ public class XToolkit extends ClasspathToolkit
return new XFontPeer (name,style,size);
}
- public ClasspathTextLayoutPeer
- getClasspathTextLayoutPeer (AttributedString str, FontRenderContext frc)
- {
- throw new Error("not implemented");
- }
-
/** Creates a font, reading the glyph definitions from a stream.
*
* <p>This method provides the platform-specific implementation for
diff --git a/libjava/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java b/libjava/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
new file mode 100644
index 00000000000..77ddbf5eb51
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
@@ -0,0 +1,100 @@
+/* VMClassLoadingMXBeanImpl.java - VM impl. of a class loading bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMClassLoadingMXBeanImpl
+{
+
+ /**
+ * Returns the number of classes currently loaded by
+ * the virtual machine.
+ *
+ * @return the number of loaded classes.
+ */
+ static int getLoadedClassCount()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of classes that have been unloaded
+ * by the virtual machine since it was started.
+ *
+ * @return the number of unloaded classes.
+ */
+ static long getUnloadedClassCount()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when classes are loaded and unloaded. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ static boolean isVerbose()
+ {
+ return false;
+ }
+
+ /**
+ * Turns on or off the emission of additional information
+ * when classes are loaded and unloaded. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ */
+ static void setVerbose(boolean verbose)
+ {
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMCompilationMXBeanImpl.java b/libjava/gnu/java/lang/management/VMCompilationMXBeanImpl.java
new file mode 100644
index 00000000000..d529cdc8c44
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMCompilationMXBeanImpl.java
@@ -0,0 +1,69 @@
+/* VMCompilationMXBeanImpl.java - VM implementation of a compilation bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the JIT
+ * compiler of the virtual machine, if one exists.
+ * Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getCompilationMXBean()},
+ * if this is the case.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMCompilationMXBeanImpl
+{
+
+ /**
+ * Returns the number of milliseconds the JIT
+ * compiler has spent compiling Java bytecode
+ * to native machine code. This is only called
+ * if a JIT compiler exists and the
+ * gnu.java.lang.management.CompilationTimeSupport
+ * property has been set.
+ *
+ * @return the number of milliseconds spent
+ * compiling.
+ */
+ static long getTotalCompilationTime()
+ {
+ return -1;
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java b/libjava/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java
new file mode 100644
index 00000000000..b56efa954c1
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java
@@ -0,0 +1,86 @@
+/* VMGarbageCollectorMXBeanImpl.java - VM interface for a GC bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+/**
+ * Provides access to information about the garbage collectors
+ * of the virtual machine. Garbage collectors are responsible
+ * for removing unreferenced objects from memory. A garbage
+ * collector is a type of memory manager, so this interface
+ * is combined with that of generic memory managers. An instance
+ * of this bean for each garbage collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMGarbageCollectorMXBeanImpl
+{
+
+ /**
+ * Returns the number of collections the garbage collector
+ * represented by this bean has made. -1 is returned if the
+ * collection count is undefined.
+ *
+ * @param name the name of the garbage collector.
+ * @return the number of collections made, or -1 if this is
+ * undefined.
+ */
+ static long getCollectionCount(String name)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the accumulated number of milliseconds this garbage
+ * collector has spent freeing the memory used by unreferenced
+ * objects. -1 is returned if the collection time is undefined.
+ * Note that the accumulated time may not change, even when the
+ * collection count increases, if the time taken is sufficiently
+ * short; this depends on the resolution of the timer used.
+ *
+ * @param name the name of the garbage collector.
+ * @return the accumulated number of milliseconds spent collecting,
+ * or -1 if this is undefined.
+ */
+ static long getCollectionTime(String name)
+ {
+ return -1;
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/libjava/gnu/java/lang/management/VMMemoryMXBeanImpl.java
new file mode 100644
index 00000000000..660de5eb707
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMMemoryMXBeanImpl.java
@@ -0,0 +1,120 @@
+/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryMXBeanImpl
+{
+
+ /**
+ * Returns an instance of {@link java.lang.management.MemoryUsage}
+ * with appropriate initial, used, committed and maximum values
+ * for the heap. By default, this uses the methods of
+ * {@link java.lang.Runtime} to provide some of the values.
+ *
+ * @return an {@link java.lang.management.MemoryUsage} instance
+ * for the heap.
+ */
+ static MemoryUsage getHeapMemoryUsage()
+ {
+ Runtime runtime = Runtime.getRuntime();
+ long totalMem = runtime.totalMemory();
+ return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
+ totalMem, runtime.maxMemory());
+ }
+
+ /**
+ * Returns an instance of {@link java.lang.management.MemoryUsage}
+ * with appropriate initial, used, committed and maximum values
+ * for non-heap memory.
+ *
+ * @return an {@link java.lang.management.MemoryUsage} instance
+ * for non-heap memory.
+ */
+ static MemoryUsage getNonHeapMemoryUsage()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the number of objects ready to be garbage collected.
+ *
+ * @return the number of finalizable objects.
+ */
+ static int getObjectPendingFinalizationCount()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when memory is allocated and deallocated. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ static boolean isVerbose()
+ {
+ return false;
+ }
+
+ /**
+ * Turns on or off the emission of additional information
+ * when memory is allocated and deallocated. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ */
+ static void setVerbose(boolean verbose)
+ {
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java b/libjava/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java
new file mode 100644
index 00000000000..2db4cf4c14b
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java
@@ -0,0 +1,98 @@
+/* VMMemoryManagerMXBeanImpl.java - VM interface for a memory manager bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Provides access to information about the memory managers
+ * of the virtual machine. An instance of this bean for each
+ * memory manager is obtained by calling
+ * {@link ManagementFactory#getMemoryManagerMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryManagerMXBeanImpl
+{
+
+ /**
+ * Returns an array containing the names of the memory pools
+ * this memory manager manages.
+ *
+ * @param name the name of the memory manager.
+ * @return an array containing the name of each memory pool
+ * this manager is responsible for.
+ */
+ static String[] getMemoryPoolNames(String name)
+ {
+ List managedPools = new ArrayList();
+ Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+ String[] managers = bean.getMemoryManagerNames();
+ for (int a = 0; a < managers.length; ++a)
+ if (managers[a].equals(name))
+ {
+ managedPools.add(bean.getName());
+ break;
+ }
+ }
+ return (String[]) managedPools.toArray(new String[managedPools.size()]);
+ }
+
+ /**
+ * Returns true if this memory manager is still valid. A memory
+ * manager becomes invalid when it is removed by the virtual machine
+ * and no longer used.
+ *
+ * @param name the name of the memory manager.
+ * @return true if this memory manager is valid.
+ */
+ static boolean isValid(String name)
+ {
+ return false;
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java b/libjava/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
new file mode 100644
index 00000000000..d0f85b68425
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
@@ -0,0 +1,231 @@
+/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information on the memory resources or
+ * pools used by the current invocation of the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryPoolMXBeanImpl
+{
+
+ /**
+ * Returns memory usage statistics for the specified pool
+ * just after a best-effort attempt to free memory. This
+ * is valid only for certain garbage collectors.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics or <code>null</code>
+ * if this pool does not support such statistics.
+ */
+ static MemoryUsage getCollectionUsage(String name)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the collection usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined). The value is initially zero.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold.
+ */
+ static long getCollectionUsageThreshold(String name)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of times the collection usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold count.
+ */
+ static long getCollectionUsageThresholdCount(String name)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns an array of names of memory managers which manage
+ * the specified pool.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a list of memory managers for the pool.
+ */
+ static String[] getMemoryManagerNames(String name)
+ {
+ return new String[0];
+ }
+
+ /**
+ * Returns the peak usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static MemoryUsage getPeakUsage(String name)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the type of memory used by the specified pool.
+ * The value must be either "HEAP" or "NON_HEAP".
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the type of the given pool.
+ */
+ static String getType(String name)
+ {
+ return "HEAP";
+ }
+
+ /**
+ * Returns the current usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a {@link java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static MemoryUsage getUsage(String name)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined). The value is initially defined by the
+ * virtual machine.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold.
+ */
+ static long getUsageThreshold(String name)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of times the usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold count.
+ */
+ static long getUsageThresholdCount(String name)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns true if the specified pool is still valid i.e.
+ * it is still in use by the virtual machine.
+ *
+ * @param name the name of the pool to check the validity of.
+ * @return true if the pool is valid.
+ */
+ static boolean isValid(String name)
+ {
+ return false;
+ }
+
+ /**
+ * Resets the peak usage level to the current usage level for
+ * the specified pool.
+ *
+ * @param name the name of the pool to reset the peak usage of.
+ */
+ static void resetPeakUsage(String name)
+ {
+ }
+
+ /**
+ * Sets the collection usage threshold for the specified
+ * pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static void setCollectionUsageThreshold(String name, long threshold)
+ {
+ }
+
+ /**
+ * Sets the usage threshold for the specified pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static void setUsageThreshold(String name, long threshold)
+ {
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/libjava/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
new file mode 100644
index 00000000000..bbfceb6ffd7
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
@@ -0,0 +1,95 @@
+/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMRuntimeMXBeanImpl
+{
+
+ /**
+ * Returns the command-line arguments supplied
+ * to the virtual machine, excluding those supplied
+ * to <code>main()</code>.
+ *
+ * @return the command-line arguments.
+ */
+ static String[] getInputArguments()
+ {
+ return new String[0];
+ }
+
+ /**
+ * Returns a developer-chosen name for the virtual
+ * machine, which may differ over different running
+ * instances of the same virtual machine binary.
+ * For example, this may include the particular
+ * process identifier used by this instance or
+ * the host name of the machine on which it is
+ * running. The intention is that this name refers
+ * to the precise entity that the other data supplied
+ * by the bean refers to, rather than the VM in general.
+ *
+ * @return the custom name of the VM.
+ */
+ static String getName()
+ {
+ return SystemProperties.getProperty("java.vm.name") + " " +
+ SystemProperties.getProperty("java.vm.version");
+ }
+
+ /**
+ * The time in milliseconds at which the virtual
+ * machine was started. This method is only executed
+ * once (for efficency), as the value is not expected
+ * to change.
+ *
+ * @return the VM start time.
+ */
+ static long getStartTime()
+ {
+ return -1;
+ }
+
+}
diff --git a/libjava/gnu/java/lang/management/VMThreadMXBeanImpl.java b/libjava/gnu/java/lang/management/VMThreadMXBeanImpl.java
new file mode 100644
index 00000000000..3478372c6c5
--- /dev/null
+++ b/libjava/gnu/java/lang/management/VMThreadMXBeanImpl.java
@@ -0,0 +1,233 @@
+/* VMThreadMXBeanImpl.java - VM impl. of a thread bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.ThreadInfo;
+
+/**
+ * Provides access to information about the threads
+ * of the virtual machine. An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * See {@link java.lang.management.ThreadMXBean} for
+ * full documentation.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMThreadMXBeanImpl
+{
+
+ /**
+ * Cache of how many threads were found.
+ */
+ private static int filled;
+
+ /**
+ * Returns the ids of cycles of deadlocked threads, occurring
+ * due to monitor ownership.
+ *
+ * @return the ids of the deadlocked threads.
+ */
+ static long[] findMonitorDeadlockedThreads()
+ {
+ return new long[0];
+ }
+
+ /* This is the same as in Thread.getAllStackTraces() */
+ static Thread[] getAllThreads()
+ {
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ while (group.getParent() != null)
+ group = group.getParent();
+ int arraySize = group.activeCount();
+ Thread[] threadList = new Thread[arraySize];
+ filled = group.enumerate(threadList);
+ while (filled == arraySize)
+ {
+ arraySize *= 2;
+ threadList = new Thread[arraySize];
+ filled = group.enumerate(threadList);
+ }
+ return threadList;
+ }
+
+ /**
+ * Returns the id of all live threads at the time of execution.
+ *
+ * @return the live thread ids.
+ */
+ static long[] getAllThreadIds()
+ {
+ Thread[] threadList = getAllThreads();
+ long[] ids = new long[filled];
+ for (int a = 0; a < filled; ++a)
+ ids[a] = threadList[a].getId();
+ return ids;
+ }
+
+ /**
+ * Returns the number of nanoseconds of CPU time
+ * the current thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @return the nanoseconds of CPU time used by
+ * the current thread.
+ */
+ static long getCurrentThreadCpuTime()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of nanoseconds of user time
+ * the current thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @return the nanoseconds of user time used by
+ * the current thread.
+ */
+ static long getCurrentThreadUserTime()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of live daemon threads.
+ *
+ * @return the number of live daemon threads.
+ */
+ static int getDaemonThreadCount()
+ {
+ Thread[] threadList = getAllThreads();
+ int daemonCount = 0;
+ for (int a = 0; a < filled; ++a)
+ {
+ if (threadList[a].isDaemon())
+ ++daemonCount;
+ }
+ return daemonCount;
+ }
+
+ /**
+ * Returns the current peak number of live threads.
+ *
+ * @return the peak number of live threads.
+ */
+ static int getPeakThreadCount()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of live threads.
+ *
+ * @return the number of live threads.
+ */
+ static int getThreadCount()
+ {
+ getAllThreads();
+ return filled;
+ }
+
+ /**
+ * Returns the number of nanoseconds of CPU time
+ * the specified thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @param id the thread to obtain statistics on.
+ * @return the nanoseconds of CPU time used by
+ * the thread.
+ */
+ static long getThreadCpuTime(long id)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the {@link java.lang.management.ThreadInfo}
+ * which corresponds to the specified id.
+ *
+ * @param id the id of the thread.
+ * @param maxDepth the depth of the stack trace.
+ * @return the corresponding <code>ThreadInfo</code>.
+ */
+ static ThreadInfo getThreadInfoForId(long id, int maxDepth)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the number of nanoseconds of user time
+ * the specified thread has used in total. This is
+ * only called if this feature is enabled and
+ * supported.
+ *
+ * @param id the thread to obtain statistics on.
+ * @return the nanoseconds of user time used by
+ * the thread.
+ */
+ static long getThreadUserTime(long id)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the total number of threads that have
+ * been started over the lifetime of the virtual
+ * machine.
+ *
+ * @return the total number of threads started.
+ */
+ static long getTotalStartedThreadCount()
+ {
+ return -1;
+ }
+
+ /**
+ * Resets the peak thread count to the current
+ * number of live threads.
+ */
+ static void resetPeakThreadCount()
+ {
+ }
+
+}
diff --git a/libjava/gnu/java/nio/VMChannel.java b/libjava/gnu/java/nio/VMChannel.java
new file mode 100644
index 00000000000..23f44bbf964
--- /dev/null
+++ b/libjava/gnu/java/nio/VMChannel.java
@@ -0,0 +1,199 @@
+/* VMChannel.java -- Native interface suppling channel operations.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import gnu.classpath.Configuration;
+import gnu.java.net.PlainSocketImpl;
+import gnu.java.nio.PipeImpl.SinkChannelImpl;
+import gnu.java.nio.PipeImpl.SourceChannelImpl;
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Native interface to support configuring of channel to run in a non-blocking
+ * manner and support scatter/gather io operations.
+ *
+ * @author Michael Barker <mike@middlesoft.co.uk>
+ *
+ */
+public class VMChannel
+{
+ private final int fd;
+
+ private VMChannel(int fd)
+ {
+ this.fd = fd;
+ }
+
+ public static VMChannel getVMChannel(PlainSocketImpl socket)
+ {
+ return new VMChannel(socket.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(SourceChannelImpl source)
+ {
+ return new VMChannel(source.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(SinkChannelImpl sink)
+ {
+ return new VMChannel(sink.getNativeFD());
+ }
+
+ public static VMChannel getVMChannel(FileChannelImpl file)
+ {
+ return null; // XXX - return new VMChannel(file.getNativeFD());
+ }
+
+ /**
+ * Set the file descriptor to have the required blocking
+ * setting.
+ *
+ * @param fd
+ * @param blocking
+ */
+ public void setBlocking(int fd, boolean blocking)
+ {
+ throw new RuntimeException("XXX - Implement me!");
+ }
+
+ public void setBlocking(boolean blocking)
+ {
+ setBlocking(fd, blocking);
+ }
+
+
+ /**
+ * Reads a byte buffer directly using the supplied file descriptor.
+ * Assumes that the buffer is a DirectBuffer.
+ *
+ * @param fd Native file descriptor to read from.
+ * @param dst Direct Byte Buffer to read to.
+ * @return Number of bytes read.
+ * @throws IOException If an error occurs or dst is not a direct buffers.
+ */
+ int read(int fd, ByteBuffer dst)
+ throws IOException
+ {
+ throw new IOException("XXX - Implement me!");
+ }
+
+ public int read(ByteBuffer dst)
+ throws IOException
+ {
+ return read(fd, dst);
+ }
+
+ /**
+ * Reads into byte buffers directly using the supplied file descriptor.
+ * Assumes that the buffer list contains DirectBuffers. Will perform a
+ * scattering read.
+ *
+ * @param fd Native file descriptor to read from.
+ * @param dsts An array direct byte buffers.
+ * @param offset Index of the first buffer to read to.
+ * @param length The number of buffers to read to.
+ * @return Number of bytes read.
+ * @throws IOException If an error occurs or the dsts are not direct buffers.
+ */
+ long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ throw new IOException("XXX - Implement me!");
+ }
+
+ public long readScattering(ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if (offset + length > dsts.length)
+ throw new IndexOutOfBoundsException("offset + length > dsts.length");
+
+ return readScattering(fd, dsts, offset, length);
+ }
+
+ /**
+ * Writes from a direct byte bufer using the supplied file descriptor.
+ * Assumes the buffer is a DirectBuffer.
+ *
+ * @param fd
+ * @param src
+ * @return Number of bytes written.
+ * @throws IOException
+ */
+ int write(int fd, ByteBuffer src)
+ throws IOException
+ {
+ throw new IOException("XXX - Implement me!");
+ }
+
+ public int write(ByteBuffer src)
+ throws IOException
+ {
+ return write(fd, src);
+ }
+
+ /**
+ * Writes from byte buffers directly using the supplied file descriptor.
+ * Assumes the that buffer list constains DirectBuffers. Will perform
+ * as gathering write.
+ *
+ * @param fd
+ * @param srcs
+ * @param offset
+ * @param length
+ * @return Number of bytes written.
+ * @throws IOException
+ */
+ long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ throw new IOException("XXX - Implement me!");
+ }
+
+ public long writeGathering(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if (offset + length > srcs.length)
+ throw new IndexOutOfBoundsException("offset + length > srcs.length");
+
+ return writeGathering(fd, srcs, offset, length);
+ }
+}
diff --git a/libjava/include/Makefile.in b/libjava/include/Makefile.in
index 49c23875455..992ad3b1b91 100644
--- a/libjava/include/Makefile.in
+++ b/libjava/include/Makefile.in
@@ -250,6 +250,7 @@ bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
+build_libsubdir = @build_libsubdir@
build_os = @build_os@
build_subdir = @build_subdir@
build_vendor = @build_vendor@
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index aafd00c23f6..7da182c9675 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -400,6 +400,7 @@ public:
java::lang::Class *getEnclosingClass (void);
java::lang::reflect::Constructor *getEnclosingConstructor (void);
java::lang::reflect::Method *getEnclosingMethod (void);
+ jboolean isEnum (void);
// FIXME: this probably shouldn't be public.
jint size (void)
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index b462465c2ed..75819e868f9 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -1016,4 +1016,17 @@ public final class Class implements Type, GenericDeclaration, Serializable
// FIXME - provide real implementation.
return new TypeVariable[0];
}
+
+ /**
+ * Returns true if this class is an <code>Enum</code>.
+ *
+ * @return true if this is an enumeration class.
+ * @since 1.5
+ */
+ public boolean isEnum()
+ {
+ // FIXME - provide real implementation.
+ return false;
+ }
+
}
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java
index 0cc4afdea19..2b7fb2aec01 100644
--- a/libjava/java/lang/Thread.java
+++ b/libjava/java/lang/Thread.java
@@ -1112,4 +1112,17 @@ public class Thread implements Runnable
*/
void uncaughtException(Thread thr, Throwable exc);
}
+
+ /**
+ * Returns the current state of the thread. This
+ * is designed for monitoring thread behaviour, rather
+ * than for synchronization control.
+ *
+ * @return the current thread state.
+ */
+ public String getState()
+ {
+ // FIXME - Provide real implementation.
+ return "NEW";
+ }
}
diff --git a/libjava/java/lang/management/VMManagementFactory.java b/libjava/java/lang/management/VMManagementFactory.java
new file mode 100644
index 00000000000..6a906c730db
--- /dev/null
+++ b/libjava/java/lang/management/VMManagementFactory.java
@@ -0,0 +1,84 @@
+/* VMManagementFactory.java - VM interface for obtaining system beans.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides lists of resources required by the
+ * {@link java.lang.management.ManagementFactory} for
+ * creating beans.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMManagementFactory
+{
+
+ /**
+ * Return a list of the names of the currently available
+ * memory pools within the virtual machine.
+ *
+ * @return a list of memory pool names.
+ */
+ static String[] getMemoryPoolNames()
+ {
+ return new String[0];
+ }
+
+ /**
+ * Return a list of the names of the currently available
+ * memory managers within the virtual machine. This should
+ * not include the garbage collectors listed below.
+ *
+ * @return a list of memory manager names.
+ */
+ static String[] getMemoryManagerNames()
+ {
+ return new String[0];
+ }
+
+ /**
+ * Return a list of the names of the currently available
+ * garbage collectors within the virtual machine.
+ *
+ * @return a list of garbage collector names.
+ */
+ static String[] getGarbageCollectorNames()
+ {
+ return new String[0];
+ }
+}
diff --git a/libjava/java/net/VMURLConnection.java b/libjava/java/net/VMURLConnection.java
new file mode 100644
index 00000000000..6555e8cbafe
--- /dev/null
+++ b/libjava/java/net/VMURLConnection.java
@@ -0,0 +1,76 @@
+/* VMURLConnection - VM code for URLConnection
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+final class VMURLConnection
+{
+ public static final int LENGTH = 1024;
+
+ // private static native void init();
+
+ private static String guessContentTypeFromBuffer(byte[] b, int valid)
+ {
+ // FIXME - write real implementation
+ return null;
+ }
+
+ /**
+ * This is called from URLConnection to guess the mime type of a
+ * stream. This method may return null to indicate that it could
+ * not guess a type.
+ */
+ static String guessContentTypeFromStream(InputStream is)
+ throws IOException
+ {
+ if (! is.markSupported())
+ return null;
+ is.mark(LENGTH);
+ byte[] bytes = new byte[LENGTH];
+ int r = is.read(bytes);
+ if (r < 0)
+ return null;
+ is.reset();
+ return guessContentTypeFromBuffer(bytes, r);
+ }
+}
diff --git a/libjava/javax/naming/spi/NamingManager.java b/libjava/javax/naming/spi/NamingManager.java
new file mode 100644
index 00000000000..11e8130570b
--- /dev/null
+++ b/libjava/javax/naming/spi/NamingManager.java
@@ -0,0 +1,654 @@
+/* NamingManager.java -- Creates contexts and objects
+ Copyright (C) 2000, 2001, 2002, 2003, 2004,
+ 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+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.naming.spi;
+
+// import gnu.classpath.VMStackWalker;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+
+import javax.naming.CannotProceedException;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.NoInitialContextException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+
+/**
+ * Contains methods for creating contexts and objects referred to by
+ * location information. The location is specified in the scope of the
+ * certain naming or directory service. This class only contais static
+ * methods and cannot be instantiated.
+ */
+public class NamingManager
+{
+ /**
+ * The environment property into which getContinuationContext() stores the
+ * value of the CannotProceedException parameter. The value of this field
+ * is <i>java.naming.spi.CannotProceedException<i>.
+ */
+ public static final String CPE = "java.naming.spi.CannotProceedException";
+
+ private static InitialContextFactoryBuilder icfb;
+
+ // Package private so DirectoryManager can access it.
+ static ObjectFactoryBuilder ofb;
+
+ // This class cannot be instantiated.
+ NamingManager ()
+ {
+ }
+
+ /**
+ * Checks if the initial context factory builder has been set.
+ *
+ * @return true if the builder has been set
+ *
+ * @see #setInitialContextFactoryBuilder(InitialContextFactoryBuilder)
+ */
+ public static boolean hasInitialContextFactoryBuilder ()
+ {
+ return icfb != null;
+ }
+
+ /**
+ * Creates the initial context. If the initial object factory builder has
+ * been set with {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)},
+ * the work is delegated to this builder. Otherwise, the method searches
+ * for the property Context.INITIAL_CONTEXT_FACTORY first in the passed
+ * table and then in the system properties. The value of this property is
+ * uses as a class name to install the context factory. The corresponding
+ * class must exist, be public and have the public parameterless constructor.
+ *
+ * @param environment the properties, used to create the context.
+ *
+ * @return the created context
+ *
+ * @throws NoInitialContextException if the initial builder is not set,
+ * the property Context.INITIAL_CONTEXT_FACTORY is missing of the
+ * class, named by this property, cannot be instantiated.
+ * @throws NamingException if throws by the context factory
+ */
+ public static Context getInitialContext (Hashtable environment)
+ throws NamingException
+ {
+ InitialContextFactory icf = null;
+
+ if (icfb != null)
+ icf = icfb.createInitialContextFactory(environment);
+ else
+ {
+ String java_naming_factory_initial = null;
+ if (environment != null)
+ java_naming_factory_initial
+ = (String) environment.get (Context.INITIAL_CONTEXT_FACTORY);
+ if (java_naming_factory_initial == null)
+ java_naming_factory_initial =
+ System.getProperty (Context.INITIAL_CONTEXT_FACTORY);
+ if (java_naming_factory_initial == null)
+ throw new
+ NoInitialContextException ("Can't find property: "
+ + Context.INITIAL_CONTEXT_FACTORY);
+
+ try
+ {
+ icf = (InitialContextFactory)Class.forName
+ (java_naming_factory_initial, true,
+ Thread.currentThread().getContextClassLoader())
+ .newInstance ();
+ }
+ catch (Exception exception)
+ {
+ NoInitialContextException e
+ = new NoInitialContextException
+ ("Can't load InitialContextFactory class: "
+ + java_naming_factory_initial);
+ e.setRootCause(exception);
+ throw e;
+ }
+ }
+
+ return icf.getInitialContext (environment);
+ }
+
+ /**
+ * <p>
+ * Creates the URL context for the given URL scheme id.
+ * </p>
+ * <p>
+ * The class name of the factory that creates the context has the naming
+ * pattern scheme-idURLContextFactory. For instance, the factory for the "ftp"
+ * sheme should be named "ftpURLContextFactory".
+ * </p>
+ * <p>
+ * The Context.URL_PKG_PREFIXES environment property contains the
+ * colon-separated list of the possible package prefixes. The package name is
+ * constructed concatenating the package prefix with the scheme id. This
+ * property is searched in the passed <i>environment</i> parameter and later
+ * in the system properties.
+ * </p>
+ * <p>
+ * If the factory class cannot be found in the specified packages, system will
+ * try to use the default internal factory for the given scheme.
+ * </p>
+ * <p>
+ * After the factory is instantiated, its method
+ * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
+ * is called to create and return the object instance.
+ *
+ * @param refInfo passed to the factory
+ * @param name passed to the factory
+ * @param nameCtx passed to the factory
+ * @param scheme the url scheme that must be supported by the given context
+ * @param environment the properties for creating the factory and context (may
+ * be null)
+ * @return the created context
+ * @throws NamingException if thrown by the factory when creating the context.
+ */
+ static Context getURLContext(Object refInfo, Name name, Context nameCtx,
+ String scheme, Hashtable environment)
+ throws NamingException
+ {
+ // Specified as the default in the docs. Unclear if this is
+ // right for us.
+ String defaultPrefix = "com.sun.jndi.url";
+
+ StringBuffer allPrefixes = new StringBuffer();
+
+ String prefixes;
+ if (environment != null)
+ {
+ prefixes = (String) environment.get(Context.URL_PKG_PREFIXES);
+ if (prefixes != null)
+ allPrefixes.append(prefixes);
+ }
+
+ prefixes = System.getProperty(Context.URL_PKG_PREFIXES);
+ if (prefixes != null)
+ {
+ if (allPrefixes.length() > 0)
+ allPrefixes.append(':');
+ allPrefixes.append(prefixes);
+ }
+
+ if (allPrefixes.length() > 0)
+ allPrefixes.append(':');
+ allPrefixes.append(defaultPrefix);
+
+ scheme = scheme + "." + scheme + "URLContextFactory";
+
+ StringTokenizer tokens = new StringTokenizer(allPrefixes.toString(), ":");
+ while (tokens.hasMoreTokens())
+ {
+ String aTry = tokens.nextToken();
+ try
+ {
+ String tryClass = aTry + "." + scheme;
+ Class factoryClass = forName(tryClass);
+ if (factoryClass != null)
+ {
+ ObjectFactory factory = (ObjectFactory) factoryClass.newInstance();
+ Object obj = factory.getObjectInstance(refInfo, name, nameCtx,
+ environment);
+ Context ctx = (Context) obj;
+ if (ctx != null)
+ return ctx;
+ }
+ }
+ catch (ClassNotFoundException _1)
+ {
+ // Ignore it.
+ }
+ catch (ClassCastException _2)
+ {
+ // This means that the class we found was not an
+ // ObjectFactory or that the factory returned something
+ // which was not a Context.
+ }
+ catch (InstantiationException _3)
+ {
+ // If we couldn't instantiate the factory we might get
+ // this.
+ }
+ catch (IllegalAccessException _4)
+ {
+ // Another possibility when instantiating.
+ }
+ catch (NamingException _5)
+ {
+ throw _5;
+ }
+ catch (Exception _6)
+ {
+ // Anything from getObjectInstance.
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Load the class with the given name. This method tries to use the context
+ * class loader first. If this fails, it searches for the suitable class
+ * loader in the caller stack trace. This method is a central point where all
+ * requests to find a class by name are delegated.
+ */
+ static Class forName(String className)
+ {
+ try
+ {
+ return Class.forName(className, true,
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException nex)
+ {
+ /**
+ * Returns the first user defined class loader on the call stack, or
+ * null when no non-null class loader was found.
+ Class[] ctx = VMStackWalker.getClassContext();
+ for (int i = 0; i < ctx.length; i++)
+ {
+ // Since we live in a class loaded by the bootstrap
+ // class loader, getClassLoader is safe to call without
+ // needing to be wrapped in a privileged action.
+ ClassLoader cl = ctx[i].getClassLoader();
+ try
+ {
+ if (cl != null)
+ return Class.forName(className, true, cl);
+ }
+ catch (ClassNotFoundException nex2)
+ {
+ // Try next.
+ }
+ }
+ */
+ }
+ return null;
+ }
+
+
+ /**
+ * <p>
+ * Creates the URL context for the given URL scheme id.
+ * </p>
+ * <p>
+ * The class name of the factory that creates the context has the naming
+ * pattern scheme-idURLContextFactory. For instance, the factory for the "ftp"
+ * sheme should be named "ftpURLContextFactory". The Context.URL_PKG_PREFIXES
+ * environment property contains the colon-separated list of the possible
+ * package prefixes. The package name is constructed concatenating the package
+ * prefix with the scheme id.
+ * </p>
+ * <p>
+ * If the factory class cannot be found in the specified packages, system will
+ * try to use the default internal factory for the given scheme.
+ * </p>
+ * <p>
+ * After the factory is instantiated, its method
+ * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)}
+ * is called to create and return the object instance.
+ *
+ * @param scheme the url scheme that must be supported by the given context
+ * @param environment the properties for creating the factory and context (may
+ * be null)
+ * @return the created context
+ * @throws NamingException if thrown by the factory when creating the context.
+ */
+ public static Context getURLContext (String scheme,
+ Hashtable environment)
+ throws NamingException
+ {
+ return getURLContext (null, null, null, scheme, environment);
+ }
+
+ /**
+ * Sets the initial object factory builder.
+ *
+ * @param builder the builder to set
+ *
+ * @throws SecurityException if the builder cannot be installed due
+ * security restrictions.
+ * @throws NamingException if the builder cannot be installed due other
+ * reasons
+ * @throws IllegalStateException if setting the builder repeatedly
+ */
+ public static void setObjectFactoryBuilder (ObjectFactoryBuilder builder)
+ throws NamingException
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkSetFactory ();
+ // Once the builder is installed it cannot be replaced.
+ if (ofb != null)
+ throw new IllegalStateException ("object factory builder already installed");
+ if (builder != null)
+ ofb = builder;
+ }
+
+ static StringTokenizer getPlusPath (String property, Hashtable env,
+ Context nameCtx)
+ throws NamingException
+ {
+ String path = (String) env.get (property);
+ if (nameCtx == null)
+ nameCtx = getInitialContext (env);
+ String path2 = (String) nameCtx.getEnvironment ().get (property);
+ if (path == null)
+ path = path2;
+ else if (path2 != null)
+ path += ":" + path2;
+ return new StringTokenizer (path != null ? path : "", ":");
+ }
+
+ /**
+ * <p>Creates an object for the specified name context, environment and
+ * referencing context object.</p>
+ * <p>
+ * If the builder factory is set by
+ * {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)}, the call is
+ * delegated to that factory. Otherwise, the object is created using the
+ * following rules:
+ * <ul>
+ * <li>If the referencing object (refInfo) contains the factory class name,
+ * the object is created by this factory. If the creation fails,
+ * the parameter refInfo is returned as the method return value.</li>
+ * <li>If the referencing object has no factory class name, and the addresses
+ * are StringRefAddrs having the address type "URL", the object is
+ * created by the URL context factory. The used factory corresponds the
+ * the naming schema of the each URL. If the attempt to create
+ * the object this way is not successful, the subsequent rule is
+ * tried.</li>
+ * <li> If the refInfo is not an instance of Reference or Referencable
+ * (for example, null), the object is created by the factories,
+ * specified in the Context.OBJECT_FACTORIES property of the
+ * environment and the provider resource file, associated with the
+ * nameCtx. The value of this property is the colon separated list
+ * of the possible factories. If none of the factories can be
+ * loaded, the refInfo is returned.
+ * </ul>
+ * </p>
+ * <p>The object factory must be public and have the public parameterless
+ * constructor.</p>
+ *
+ * @param refInfo the referencing object, for which the new object must be
+ * created (can be null). If not null, it is usually an instance of
+ * the {@link Reference} or {@link Referenceable}.
+ * @param name the name of the object. The name is relative to
+ * the nameCtx naming context. The value of this parameter can be
+ * null if the name is not specified.
+ * @param nameCtx the naming context, in which scope the name of the new
+ * object is specified. If this parameter is null, the name is
+ * specified in the scope of the initial context.
+ * @param environment contains additional information for creating the object.
+ * This paramter can be null if there is no need to provide any
+ * additional information.
+ *
+ * @return the created object. If the creation fails, in some cases
+ * the parameter refInfo may be returned.
+ *
+ * @throws NamingException if the attempt to name the new object has failed
+ * @throws Exception if the object factory throws it. The object factory
+ * only throws an exception if it does not want other factories
+ * to be used to create the object.
+ */
+ public static Object getObjectInstance (Object refInfo,
+ Name name,
+ Context nameCtx,
+ Hashtable environment)
+ throws Exception
+ {
+ ObjectFactory factory = null;
+
+ if (ofb != null)
+ factory = ofb.createObjectFactory (refInfo, environment);
+ else
+ {
+ // First see if we have a Reference or a Referenceable. If so
+ // we do some special processing.
+ Object ref2 = refInfo;
+ if (refInfo instanceof Referenceable)
+ ref2 = ((Referenceable) refInfo).getReference ();
+ if (ref2 instanceof Reference)
+ {
+ Reference ref = (Reference) ref2;
+
+ // If we have a factory class name then we use that.
+ String fClass = ref.getFactoryClassName ();
+ if (fClass != null)
+ {
+ // Exceptions here are passed to the caller.
+ Class k = Class.forName (fClass,
+ true,
+ Thread.currentThread().getContextClassLoader());
+ factory = (ObjectFactory) k.newInstance ();
+ }
+ else
+ {
+ // There's no factory class name. If the address is a
+ // StringRefAddr with address type `URL', then we try
+ // the URL's context factory.
+ Enumeration e = ref.getAll ();
+ while (e.hasMoreElements ())
+ {
+ RefAddr ra = (RefAddr) e.nextElement ();
+ if (ra instanceof StringRefAddr
+ && "URL".equals (ra.getType ()))
+ {
+ factory
+ = (ObjectFactory) getURLContext (refInfo,
+ name,
+ nameCtx,
+ (String) ra.getContent (),
+ environment);
+ Object obj = factory.getObjectInstance (refInfo,
+ name,
+ nameCtx,
+ environment);
+ if (obj != null)
+ return obj;
+ }
+ }
+
+ // Have to try the next step.
+ factory = null;
+ }
+ }
+
+ // Now look at OBJECT_FACTORIES to find the factory.
+ if (factory == null)
+ {
+ StringTokenizer tokens = getPlusPath (Context.OBJECT_FACTORIES,
+ environment, nameCtx);
+
+ while (tokens.hasMoreTokens ())
+ {
+ String klassName = tokens.nextToken ();
+ Class k = Class.forName (klassName,
+ true,
+ Thread.currentThread().getContextClassLoader());
+ factory = (ObjectFactory) k.newInstance ();
+ Object obj = factory.getObjectInstance (refInfo, name,
+ nameCtx, environment);
+ if (obj != null)
+ return obj;
+ }
+
+ // Failure.
+ return refInfo;
+ }
+ }
+
+ if (factory == null)
+ return refInfo;
+ Object obj = factory.getObjectInstance (refInfo, name,
+ nameCtx, environment);
+ return obj == null ? refInfo : obj;
+ }
+
+ /**
+ * Sets the initial context factory builder.
+ *
+ * @param builder the builder to set
+ *
+ * @throws SecurityException if the builder cannot be installed due
+ * security restrictions.
+ * @throws NamingException if the builder cannot be installed due other
+ * reasons
+ * @throws IllegalStateException if setting the builder repeatedly
+ *
+ * @see #hasInitialContextFactoryBuilder()
+ */
+ public static void setInitialContextFactoryBuilder
+ (InitialContextFactoryBuilder builder)
+ throws NamingException
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkSetFactory ();
+ // Once the builder is installed it cannot be replaced.
+ if (icfb != null)
+ throw new IllegalStateException ("ctx factory builder already installed");
+ if (builder != null)
+ icfb = builder;
+ }
+
+ /**
+ * Creates a context in which the context operation must be continued.
+ * This method is used by operations on names that span multiple namespaces.
+ *
+ * @param cpe the exception that triggered this continuation. This method
+ * obtains the environment ({@link CannotProceedException#getEnvironment()}
+ * and sets the environment property {@link #CPE} = cpe.
+ *
+ * @return a non null context for continuing the operation
+ *
+ * @throws NamingException if the naming problems have occured
+ */
+ public static Context getContinuationContext (CannotProceedException cpe)
+ throws NamingException
+ {
+ Hashtable env = cpe.getEnvironment ();
+ if (env != null)
+ env.put (CPE, cpe);
+
+ // TODO: Check if this implementation matches the API specification
+ try
+ {
+ Object obj = getObjectInstance (cpe.getResolvedObj(),
+ cpe.getAltName (),
+ cpe.getAltNameCtx (),
+ env);
+ if (obj != null)
+ return (Context) obj;
+ }
+ catch (Exception _)
+ {
+ }
+
+ // fix stack trace for re-thrown exception (message confusing otherwise)
+ cpe.fillInStackTrace();
+
+ throw cpe;
+ }
+
+ /**
+ * Get the object state for binding.
+ *
+ * @param obj the object, for that the binding state must be retrieved. Cannot
+ * be null.
+ * @param name the name of this object, related to the nameCtx. Can be null if
+ * not specified.
+ * @param nameCtx the naming context, to that the object name is related. Can
+ * be null if the name is related to the initial default context.
+ * @param environment the properties for creating the object state. Can be
+ * null if no properties are provided.
+ * @return the object state for binding, may be null if no changes are
+ * returned by the factory
+ * @throws NamingException
+ */
+ public static Object getStateToBind (Object obj, Name name,
+ Context nameCtx, Hashtable environment)
+ throws NamingException
+ {
+ StringTokenizer tokens = getPlusPath (Context.STATE_FACTORIES,
+ environment, nameCtx);
+ while (tokens.hasMoreTokens ())
+ {
+ String klassName = tokens.nextToken ();
+ try
+ {
+ Class k = Class.forName (klassName,
+ true,
+ Thread.currentThread().getContextClassLoader());
+ StateFactory factory = (StateFactory) k.newInstance ();
+ Object o = factory.getStateToBind (obj, name, nameCtx,
+ environment);
+ if (o != null)
+ return o;
+ }
+ catch (ClassNotFoundException _1)
+ {
+ // Ignore it.
+ }
+ catch (ClassCastException _2)
+ {
+ // This means that the class we found was not an
+ // ObjectFactory or that the factory returned something
+ // which was not a Context.
+ }
+ catch (InstantiationException _3)
+ {
+ // If we couldn't instantiate the factory we might get
+ // this.
+ }
+ catch (IllegalAccessException _4)
+ {
+ // Another possibility when instantiating.
+ }
+ }
+
+ return obj;
+ }
+}
diff --git a/libjava/scripts/makemake.tcl b/libjava/scripts/makemake.tcl
index f857dd0669c..954d1847ec4 100755
--- a/libjava/scripts/makemake.tcl
+++ b/libjava/scripts/makemake.tcl
@@ -49,7 +49,9 @@ set package_map(gnu/xml) bc
set package_map(javax/imageio) bc
set package_map(javax/xml) bc
set package_map(gnu/java/beans) bc
+set package_map(gnu/java/util/prefs/gconf) bc
set package_map(gnu/java/awt/peer/gtk) bc
+set package_map(gnu/java/awt/dnd/peer/gtk) bc
set package_map(gnu/java/awt/peer/qt) bc
set package_map(gnu/javax/sound/midi) bc
set package_map(org/xml) bc
@@ -377,6 +379,7 @@ scan_packages .
classify_source_file . java/lang/ConcreteProcess.java
classify_source_file classpath gnu/java/locale/LocaleData.java
classify_source_file classpath gnu/classpath/Configuration.java
+classify_source_file classpath gnu/java/security/Configuration.java
puts "## This file was automatically generated by scripts/makemake.tcl"
puts "## Do not edit!"
diff --git a/libjava/sources.am b/libjava/sources.am
index a18ad9430e9..56502e29210 100644
--- a/libjava/sources.am
+++ b/libjava/sources.am
@@ -232,7 +232,6 @@ gnu/awt/xlib.list: $(gnu_awt_xlib_source_files)
gnu_classpath_source_files = \
-classpath/gnu/classpath/ByteArray.java \
classpath/gnu/classpath/Configuration.java \
classpath/gnu/classpath/NotImplementedException.java \
classpath/gnu/classpath/Pointer.java \
@@ -259,7 +258,11 @@ gnu_classpath_debug_source_files = \
classpath/gnu/classpath/debug/Component.java \
classpath/gnu/classpath/debug/PreciseFilter.java \
classpath/gnu/classpath/debug/Simple1LineFormatter.java \
-classpath/gnu/classpath/debug/SystemLogger.java
+classpath/gnu/classpath/debug/SystemLogger.java \
+classpath/gnu/classpath/debug/TeeInputStream.java \
+classpath/gnu/classpath/debug/TeeOutputStream.java \
+classpath/gnu/classpath/debug/TeeReader.java \
+classpath/gnu/classpath/debug/TeeWriter.java
gnu_classpath_debug_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_classpath_debug_source_files)))
@@ -298,9 +301,14 @@ gnu/classpath/jdwp.list: $(gnu_classpath_jdwp_source_files)
gnu_classpath_jdwp_event_source_files = \
classpath/gnu/classpath/jdwp/event/BreakpointEvent.java \
classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java \
+classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java \
classpath/gnu/classpath/jdwp/event/Event.java \
classpath/gnu/classpath/jdwp/event/EventManager.java \
classpath/gnu/classpath/jdwp/event/EventRequest.java \
+classpath/gnu/classpath/jdwp/event/ExceptionEvent.java \
+classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java \
+classpath/gnu/classpath/jdwp/event/MethodExitEvent.java \
+classpath/gnu/classpath/jdwp/event/SingleStepEvent.java \
classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java \
classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java \
classpath/gnu/classpath/jdwp/event/VmDeathEvent.java \
@@ -689,6 +697,32 @@ gnu/java/awt/color.list: $(gnu_java_awt_color_source_files)
-include gnu/java/awt/color.deps
+gnu_java_awt_dnd_source_files = \
+classpath/gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java
+
+gnu_java_awt_dnd_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_dnd_source_files)))
+
+gnu/java/awt/dnd.list: $(gnu_java_awt_dnd_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_awt_dnd_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/awt/dnd.list
+
+-include gnu/java/awt/dnd.deps
+
+
+gnu_java_awt_dnd_peer_gtk_source_files = \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java \
+classpath/gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java
+
+gnu-java-awt-dnd-peer-gtk.lo: $(gnu_java_awt_dnd_peer_gtk_source_files)
+ @find classpath/lib/gnu/java/awt/dnd/peer/gtk -name '*.class' > gnu-java-awt-dnd-peer-gtk.list
+ $(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-awt-dnd-peer-gtk.lo @gnu-java-awt-dnd-peer-gtk.list
+ @rm -f gnu-java-awt-dnd-peer-gtk.list
+
gnu_java_awt_font_source_files = \
classpath/gnu/java/awt/font/FontDelegate.java \
classpath/gnu/java/awt/font/FontFactory.java \
@@ -797,7 +831,6 @@ gnu/java/awt/java2d.list: $(gnu_java_awt_java2d_source_files)
gnu_java_awt_peer_source_files = \
classpath/gnu/java/awt/peer/ClasspathFontPeer.java \
-classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java \
classpath/gnu/java/awt/peer/EmbeddedWindowPeer.java \
classpath/gnu/java/awt/peer/GLightweightPeer.java
@@ -831,10 +864,8 @@ classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
classpath/gnu/java/awt/peer/gtk/GdkRobotPeer.java \
classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java \
-classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java \
classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java \
-classpath/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java \
@@ -856,6 +887,7 @@ classpath/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkMenuPeer.java \
+classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java \
classpath/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java \
@@ -1094,6 +1126,39 @@ gnu/java/lang.list: $(gnu_java_lang_source_files)
-include gnu/java/lang.deps
+gnu_java_lang_management_source_files = \
+classpath/gnu/java/lang/management/BeanImpl.java \
+classpath/gnu/java/lang/management/ClassLoadingMXBeanImpl.java \
+classpath/gnu/java/lang/management/CompilationMXBeanImpl.java \
+classpath/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryManagerMXBeanImpl.java \
+classpath/gnu/java/lang/management/MemoryPoolMXBeanImpl.java \
+classpath/gnu/java/lang/management/OperatingSystemMXBeanImpl.java \
+classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java \
+classpath/gnu/java/lang/management/ThreadMXBeanImpl.java \
+gnu/java/lang/management/VMClassLoadingMXBeanImpl.java \
+gnu/java/lang/management/VMCompilationMXBeanImpl.java \
+gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java \
+gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java \
+gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
+gnu/java/lang/management/VMThreadMXBeanImpl.java
+
+gnu_java_lang_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_lang_management_source_files)))
+
+gnu/java/lang/management.list: $(gnu_java_lang_management_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_lang_management_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/lang/management.list
+
+-include gnu/java/lang/management.deps
+
+
gnu_java_lang_reflect_source_files = \
classpath/gnu/java/lang/reflect/ClassSignatureParser.java \
classpath/gnu/java/lang/reflect/FieldSignatureParser.java \
@@ -1314,6 +1379,30 @@ gnu/java/net.list: $(gnu_java_net_source_files)
-include gnu/java/net.deps
+gnu_java_net_loader_source_files = \
+classpath/gnu/java/net/loader/FileResource.java \
+classpath/gnu/java/net/loader/FileURLLoader.java \
+classpath/gnu/java/net/loader/JarURLLoader.java \
+classpath/gnu/java/net/loader/JarURLResource.java \
+classpath/gnu/java/net/loader/RemoteResource.java \
+classpath/gnu/java/net/loader/RemoteURLLoader.java \
+classpath/gnu/java/net/loader/Resource.java \
+classpath/gnu/java/net/loader/URLLoader.java \
+classpath/gnu/java/net/loader/URLStreamHandlerCache.java
+
+gnu_java_net_loader_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_loader_source_files)))
+
+gnu/java/net/loader.list: $(gnu_java_net_loader_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_net_loader_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/net/loader.list
+
+-include gnu/java/net/loader.deps
+
+
gnu_java_net_local_source_files = \
classpath/gnu/java/net/local/LocalServerSocket.java \
classpath/gnu/java/net/local/LocalSocket.java \
@@ -1503,6 +1592,8 @@ gnu/java/nio/ServerSocketChannelImpl.java \
gnu/java/nio/ServerSocketChannelSelectionKey.java \
gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/SocketChannelSelectionKey.java \
+classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java \
+gnu/java/nio/VMChannel.java \
gnu/java/nio/VMPipe.java \
gnu/java/nio/VMSelector.java
@@ -1742,6 +1833,7 @@ gnu/java/rmi/server.list: $(gnu_java_rmi_server_source_files)
gnu_java_security_source_files = \
+classpath/gnu/java/security/Configuration.java \
classpath/gnu/java/security/Engine.java \
classpath/gnu/java/security/OID.java \
classpath/gnu/java/security/PolicyFile.java \
@@ -2128,12 +2220,13 @@ gnu/java/security/sig/rsa.list: $(gnu_java_security_sig_rsa_source_files)
gnu_java_security_util_source_files = \
classpath/gnu/java/security/util/Base64.java \
+classpath/gnu/java/security/util/ByteArray.java \
classpath/gnu/java/security/util/DerUtil.java \
classpath/gnu/java/security/util/ExpirableObject.java \
classpath/gnu/java/security/util/FormatUtil.java \
+classpath/gnu/java/security/util/IntegerUtil.java \
classpath/gnu/java/security/util/PRNG.java \
classpath/gnu/java/security/util/Prime.java \
-classpath/gnu/java/security/util/Prime2.java \
classpath/gnu/java/security/util/Sequence.java \
classpath/gnu/java/security/util/SimpleList.java \
classpath/gnu/java/security/util/Util.java
@@ -2268,6 +2361,8 @@ gnu_java_util_prefs_source_files = \
classpath/gnu/java/util/prefs/EventDispatcher.java \
classpath/gnu/java/util/prefs/FileBasedFactory.java \
classpath/gnu/java/util/prefs/FileBasedPreferences.java \
+classpath/gnu/java/util/prefs/GConfBasedFactory.java \
+classpath/gnu/java/util/prefs/GConfBasedPreferences.java \
classpath/gnu/java/util/prefs/MemoryBasedFactory.java \
classpath/gnu/java/util/prefs/MemoryBasedPreferences.java \
classpath/gnu/java/util/prefs/NodeReader.java \
@@ -2286,6 +2381,60 @@ gnu/java/util/prefs.list: $(gnu_java_util_prefs_source_files)
-include gnu/java/util/prefs.deps
+gnu_java_util_prefs_gconf_source_files = \
+classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
+
+gnu-java-util-prefs-gconf.lo: $(gnu_java_util_prefs_gconf_source_files)
+ @find classpath/lib/gnu/java/util/prefs/gconf -name '*.class' > gnu-java-util-prefs-gconf.list
+ $(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-util-prefs-gconf.lo @gnu-java-util-prefs-gconf.list
+ @rm -f gnu-java-util-prefs-gconf.list
+
+gnu_java_util_regex_source_files = \
+classpath/gnu/java/util/regex/BacktrackStack.java \
+classpath/gnu/java/util/regex/CharIndexed.java \
+classpath/gnu/java/util/regex/CharIndexedCharArray.java \
+classpath/gnu/java/util/regex/CharIndexedCharSequence.java \
+classpath/gnu/java/util/regex/CharIndexedInputStream.java \
+classpath/gnu/java/util/regex/CharIndexedString.java \
+classpath/gnu/java/util/regex/CharIndexedStringBuffer.java \
+classpath/gnu/java/util/regex/RE.java \
+classpath/gnu/java/util/regex/REException.java \
+classpath/gnu/java/util/regex/REFilterInputStream.java \
+classpath/gnu/java/util/regex/REMatch.java \
+classpath/gnu/java/util/regex/REMatchEnumeration.java \
+classpath/gnu/java/util/regex/RESyntax.java \
+classpath/gnu/java/util/regex/REToken.java \
+classpath/gnu/java/util/regex/RETokenAny.java \
+classpath/gnu/java/util/regex/RETokenBackRef.java \
+classpath/gnu/java/util/regex/RETokenChar.java \
+classpath/gnu/java/util/regex/RETokenEnd.java \
+classpath/gnu/java/util/regex/RETokenEndOfPreviousMatch.java \
+classpath/gnu/java/util/regex/RETokenEndSub.java \
+classpath/gnu/java/util/regex/RETokenIndependent.java \
+classpath/gnu/java/util/regex/RETokenLookAhead.java \
+classpath/gnu/java/util/regex/RETokenLookBehind.java \
+classpath/gnu/java/util/regex/RETokenNamedProperty.java \
+classpath/gnu/java/util/regex/RETokenOneOf.java \
+classpath/gnu/java/util/regex/RETokenPOSIX.java \
+classpath/gnu/java/util/regex/RETokenRange.java \
+classpath/gnu/java/util/regex/RETokenRepeated.java \
+classpath/gnu/java/util/regex/RETokenStart.java \
+classpath/gnu/java/util/regex/RETokenWordBoundary.java \
+classpath/gnu/java/util/regex/UncheckedRE.java
+
+gnu_java_util_regex_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_util_regex_source_files)))
+
+gnu/java/util/regex.list: $(gnu_java_util_regex_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_java_util_regex_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/java/util/regex.list
+
+-include gnu/java/util/regex.deps
+
+
gnu_javax_crypto_source_files = \
classpath/gnu/javax/crypto/RSACipherImpl.java
@@ -2381,6 +2530,10 @@ gnu/javax/crypto/jce.list: $(gnu_javax_crypto_jce_source_files)
gnu_javax_crypto_jce_cipher_source_files = \
+classpath/gnu/javax/crypto/jce/cipher/AES128KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AES192KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AES256KeyWrapSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/AESKeyWrapSpi.java \
classpath/gnu/javax/crypto/jce/cipher/AESSpi.java \
classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java \
classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java \
@@ -2388,12 +2541,14 @@ classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java \
classpath/gnu/javax/crypto/jce/cipher/Cast5Spi.java \
classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java \
classpath/gnu/javax/crypto/jce/cipher/DESSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/KeyWrappingAlgorithmAdapter.java \
classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java \
classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java \
classpath/gnu/javax/crypto/jce/cipher/PBES2.java \
classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java \
classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java \
classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java \
+classpath/gnu/javax/crypto/jce/cipher/TripleDESKeyWrapSpi.java \
classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java \
classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
@@ -2699,6 +2854,27 @@ gnu/javax/crypto/keyring.list: $(gnu_javax_crypto_keyring_source_files)
-include gnu/javax/crypto/keyring.deps
+gnu_javax_crypto_kwa_source_files = \
+classpath/gnu/javax/crypto/kwa/AESKeyWrap.java \
+classpath/gnu/javax/crypto/kwa/BaseKeyWrappingAlgorithm.java \
+classpath/gnu/javax/crypto/kwa/IKeyWrappingAlgorithm.java \
+classpath/gnu/javax/crypto/kwa/KeyUnwrappingException.java \
+classpath/gnu/javax/crypto/kwa/KeyWrappingAlgorithmFactory.java \
+classpath/gnu/javax/crypto/kwa/TripleDESKeyWrap.java
+
+gnu_javax_crypto_kwa_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_crypto_kwa_source_files)))
+
+gnu/javax/crypto/kwa.list: $(gnu_javax_crypto_kwa_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_crypto_kwa_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/crypto/kwa.list
+
+-include gnu/javax/crypto/kwa.deps
+
+
gnu_javax_crypto_mac_source_files = \
classpath/gnu/javax/crypto/mac/BaseMac.java \
classpath/gnu/javax/crypto/mac/HMac.java \
@@ -2754,6 +2930,7 @@ gnu/javax/crypto/mode.list: $(gnu_javax_crypto_mode_source_files)
gnu_javax_crypto_pad_source_files = \
classpath/gnu/javax/crypto/pad/BasePad.java \
classpath/gnu/javax/crypto/pad/IPad.java \
+classpath/gnu/javax/crypto/pad/ISO10126.java \
classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java \
classpath/gnu/javax/crypto/pad/PKCS7.java \
classpath/gnu/javax/crypto/pad/PadFactory.java \
@@ -2920,6 +3097,22 @@ gnu/javax/crypto/sasl/srp.list: $(gnu_javax_crypto_sasl_srp_source_files)
-include gnu/javax/crypto/sasl/srp.deps
+gnu_javax_imageio_source_files = \
+classpath/gnu/javax/imageio/IIOInputStream.java
+
+gnu_javax_imageio_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_source_files)))
+
+gnu/javax/imageio.list: $(gnu_javax_imageio_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio.list
+
+-include gnu/javax/imageio.deps
+
+
gnu_javax_imageio_bmp_source_files = \
classpath/gnu/javax/imageio/bmp/BMPDecoder.java \
classpath/gnu/javax/imageio/bmp/BMPEncoder.java \
@@ -2960,6 +3153,83 @@ gnu/javax/imageio/bmp.list: $(gnu_javax_imageio_bmp_source_files)
-include gnu/javax/imageio/bmp.deps
+gnu_javax_imageio_gif_source_files = \
+classpath/gnu/javax/imageio/gif/GIFFile.java \
+classpath/gnu/javax/imageio/gif/GIFImageReader.java \
+classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java
+
+gnu_javax_imageio_gif_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_gif_source_files)))
+
+gnu/javax/imageio/gif.list: $(gnu_javax_imageio_gif_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_gif_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/gif.list
+
+-include gnu/javax/imageio/gif.deps
+
+
+gnu_javax_imageio_jpeg_source_files = \
+classpath/gnu/javax/imageio/jpeg/DCT.java \
+classpath/gnu/javax/imageio/jpeg/HuffmanTable.java \
+classpath/gnu/javax/imageio/jpeg/JPEGComponent.java \
+classpath/gnu/javax/imageio/jpeg/JPEGDecoder.java \
+classpath/gnu/javax/imageio/jpeg/JPEGException.java \
+classpath/gnu/javax/imageio/jpeg/JPEGFrame.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageInputStream.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageReader.java \
+classpath/gnu/javax/imageio/jpeg/JPEGImageReaderSpi.java \
+classpath/gnu/javax/imageio/jpeg/JPEGMarker.java \
+classpath/gnu/javax/imageio/jpeg/JPEGMarkerFoundException.java \
+classpath/gnu/javax/imageio/jpeg/JPEGScan.java \
+classpath/gnu/javax/imageio/jpeg/YCbCr_ColorSpace.java \
+classpath/gnu/javax/imageio/jpeg/ZigZag.java
+
+gnu_javax_imageio_jpeg_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_jpeg_source_files)))
+
+gnu/javax/imageio/jpeg.list: $(gnu_javax_imageio_jpeg_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_jpeg_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/jpeg.list
+
+-include gnu/javax/imageio/jpeg.deps
+
+
+gnu_javax_imageio_png_source_files = \
+classpath/gnu/javax/imageio/png/PNGChunk.java \
+classpath/gnu/javax/imageio/png/PNGData.java \
+classpath/gnu/javax/imageio/png/PNGDecoder.java \
+classpath/gnu/javax/imageio/png/PNGEncoder.java \
+classpath/gnu/javax/imageio/png/PNGException.java \
+classpath/gnu/javax/imageio/png/PNGFile.java \
+classpath/gnu/javax/imageio/png/PNGFilter.java \
+classpath/gnu/javax/imageio/png/PNGGamma.java \
+classpath/gnu/javax/imageio/png/PNGHeader.java \
+classpath/gnu/javax/imageio/png/PNGICCProfile.java \
+classpath/gnu/javax/imageio/png/PNGImageReader.java \
+classpath/gnu/javax/imageio/png/PNGImageReaderSpi.java \
+classpath/gnu/javax/imageio/png/PNGPalette.java \
+classpath/gnu/javax/imageio/png/PNGPhys.java \
+classpath/gnu/javax/imageio/png/PNGTime.java
+
+gnu_javax_imageio_png_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_imageio_png_source_files)))
+
+gnu/javax/imageio/png.list: $(gnu_javax_imageio_png_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_imageio_png_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/imageio/png.list
+
+-include gnu/javax/imageio/png.deps
+
+
gnu_javax_net_ssl_source_files = \
classpath/gnu/javax/net/ssl/Base64.java \
classpath/gnu/javax/net/ssl/EntropySource.java \
@@ -3321,13 +3591,50 @@ classpath/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java \
classpath/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java \
classpath/gnu/javax/sound/midi/alsa/AlsaPortDevice.java \
classpath/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java \
-classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java
+classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java \
+classpath/gnu/javax/sound/midi/file/ExtendedMidiFileFormat.java \
+classpath/gnu/javax/sound/midi/file/MidiDataInputStream.java \
+classpath/gnu/javax/sound/midi/file/MidiDataOutputStream.java \
+classpath/gnu/javax/sound/midi/file/MidiFileReader.java \
+classpath/gnu/javax/sound/midi/file/MidiFileWriter.java
gnu-javax-sound-midi.lo: $(gnu_javax_sound_midi_source_files)
@find classpath/lib/gnu/javax/sound/midi -name '*.class' > gnu-javax-sound-midi.list
$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-javax-sound-midi.lo @gnu-javax-sound-midi.list
@rm -f gnu-javax-sound-midi.list
+gnu_javax_sound_sampled_AU_source_files = \
+classpath/gnu/javax/sound/sampled/AU/AUReader.java
+
+gnu_javax_sound_sampled_AU_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_sound_sampled_AU_source_files)))
+
+gnu/javax/sound/sampled/AU.list: $(gnu_javax_sound_sampled_AU_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_sound_sampled_AU_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/sound/sampled/AU.list
+
+-include gnu/javax/sound/sampled/AU.deps
+
+
+gnu_javax_sound_sampled_WAV_source_files = \
+classpath/gnu/javax/sound/sampled/WAV/WAVReader.java
+
+gnu_javax_sound_sampled_WAV_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_sound_sampled_WAV_source_files)))
+
+gnu/javax/sound/sampled/WAV.list: $(gnu_javax_sound_sampled_WAV_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(gnu_javax_sound_sampled_WAV_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > gnu/javax/sound/sampled/WAV.list
+
+-include gnu/javax/sound/sampled/WAV.deps
+
+
gnu_javax_swing_plaf_gnu_source_files = \
classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
@@ -3379,7 +3686,9 @@ gnu/javax/swing/text/html.list: $(gnu_javax_swing_text_html_source_files)
gnu_javax_swing_text_html_parser_source_files = \
+classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java \
classpath/gnu/javax/swing/text/html/parser/HTML_401F.java \
+classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java \
classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java \
classpath/gnu/javax/swing/text/html/parser/gnuDTD.java \
classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java \
@@ -3478,52 +3787,6 @@ gnu/javax/swing/tree.list: $(gnu_javax_swing_tree_source_files)
-include gnu/javax/swing/tree.deps
-gnu_regexp_source_files = \
-classpath/gnu/regexp/BacktrackStack.java \
-classpath/gnu/regexp/CharIndexed.java \
-classpath/gnu/regexp/CharIndexedCharArray.java \
-classpath/gnu/regexp/CharIndexedCharSequence.java \
-classpath/gnu/regexp/CharIndexedInputStream.java \
-classpath/gnu/regexp/CharIndexedString.java \
-classpath/gnu/regexp/CharIndexedStringBuffer.java \
-classpath/gnu/regexp/RE.java \
-classpath/gnu/regexp/REException.java \
-classpath/gnu/regexp/REFilterInputStream.java \
-classpath/gnu/regexp/REMatch.java \
-classpath/gnu/regexp/REMatchEnumeration.java \
-classpath/gnu/regexp/RESyntax.java \
-classpath/gnu/regexp/REToken.java \
-classpath/gnu/regexp/RETokenAny.java \
-classpath/gnu/regexp/RETokenBackRef.java \
-classpath/gnu/regexp/RETokenChar.java \
-classpath/gnu/regexp/RETokenEnd.java \
-classpath/gnu/regexp/RETokenEndOfPreviousMatch.java \
-classpath/gnu/regexp/RETokenEndSub.java \
-classpath/gnu/regexp/RETokenIndependent.java \
-classpath/gnu/regexp/RETokenLookAhead.java \
-classpath/gnu/regexp/RETokenLookBehind.java \
-classpath/gnu/regexp/RETokenNamedProperty.java \
-classpath/gnu/regexp/RETokenOneOf.java \
-classpath/gnu/regexp/RETokenPOSIX.java \
-classpath/gnu/regexp/RETokenRange.java \
-classpath/gnu/regexp/RETokenRepeated.java \
-classpath/gnu/regexp/RETokenStart.java \
-classpath/gnu/regexp/RETokenWordBoundary.java \
-classpath/gnu/regexp/UncheckedRE.java
-
-gnu_regexp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_regexp_source_files)))
-
-gnu/regexp.list: $(gnu_regexp_source_files)
- @$(mkinstalldirs) $(dir $@)
- @for file in $(gnu_regexp_source_files); do \
- if test -f $(srcdir)/$$file; then \
- echo $(srcdir)/$$file; \
- else echo $$file; fi; \
- done > gnu/regexp.list
-
--include gnu/regexp.deps
-
-
gnu_xml_source_files = \
classpath/gnu/xml/aelfred2/JAXPFactory.java \
classpath/gnu/xml/aelfred2/SAXDriver.java \
@@ -4042,11 +4305,13 @@ classpath/java/awt/MenuComponent.java \
classpath/java/awt/MenuContainer.java \
classpath/java/awt/MenuItem.java \
classpath/java/awt/MenuShortcut.java \
+classpath/java/awt/MouseInfo.java \
classpath/java/awt/PageAttributes.java \
classpath/java/awt/Paint.java \
classpath/java/awt/PaintContext.java \
classpath/java/awt/Panel.java \
classpath/java/awt/Point.java \
+classpath/java/awt/PointerInfo.java \
classpath/java/awt/Polygon.java \
classpath/java/awt/PopupMenu.java \
classpath/java/awt/PrintGraphics.java \
@@ -4453,6 +4718,7 @@ classpath/java/awt/peer/MenuBarPeer.java \
classpath/java/awt/peer/MenuComponentPeer.java \
classpath/java/awt/peer/MenuItemPeer.java \
classpath/java/awt/peer/MenuPeer.java \
+classpath/java/awt/peer/MouseInfoPeer.java \
classpath/java/awt/peer/PanelPeer.java \
classpath/java/awt/peer/PopupMenuPeer.java \
classpath/java/awt/peer/RobotPeer.java \
@@ -4790,7 +5056,8 @@ java/lang.list: $(java_lang_source_files)
java_lang_annotation_source_files = \
classpath/java/lang/annotation/Annotation.java \
classpath/java/lang/annotation/AnnotationFormatError.java \
-classpath/java/lang/annotation/AnnotationTypeMismatchException.java
+classpath/java/lang/annotation/AnnotationTypeMismatchException.java \
+classpath/java/lang/annotation/IncompleteAnnotationException.java
java_lang_annotation_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_annotation_source_files)))
@@ -4825,6 +5092,36 @@ java/lang/instrument.list: $(java_lang_instrument_source_files)
-include java/lang/instrument.deps
+java_lang_management_source_files = \
+classpath/java/lang/management/ClassLoadingMXBean.java \
+classpath/java/lang/management/CompilationMXBean.java \
+classpath/java/lang/management/GarbageCollectorMXBean.java \
+classpath/java/lang/management/ManagementFactory.java \
+classpath/java/lang/management/ManagementPermission.java \
+classpath/java/lang/management/MemoryMXBean.java \
+classpath/java/lang/management/MemoryManagerMXBean.java \
+classpath/java/lang/management/MemoryNotificationInfo.java \
+classpath/java/lang/management/MemoryPoolMXBean.java \
+classpath/java/lang/management/MemoryUsage.java \
+classpath/java/lang/management/OperatingSystemMXBean.java \
+classpath/java/lang/management/RuntimeMXBean.java \
+classpath/java/lang/management/ThreadInfo.java \
+classpath/java/lang/management/ThreadMXBean.java \
+java/lang/management/VMManagementFactory.java
+
+java_lang_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_lang_management_source_files)))
+
+java/lang/management.list: $(java_lang_management_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(java_lang_management_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > java/lang/management.list
+
+-include java/lang/management.deps
+
+
java_lang_ref_source_files = \
classpath/java/lang/ref/PhantomReference.java \
java/lang/ref/Reference.java \
@@ -4884,7 +5181,8 @@ java/lang/reflect.list: $(java_lang_reflect_source_files)
java_math_source_files = \
classpath/java/math/BigDecimal.java \
-classpath/java/math/BigInteger.java
+classpath/java/math/BigInteger.java \
+classpath/java/math/MathContext.java
java_math_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_math_source_files)))
@@ -4945,7 +5243,8 @@ classpath/java/net/URLStreamHandler.java \
classpath/java/net/URLStreamHandlerFactory.java \
classpath/java/net/UnknownHostException.java \
classpath/java/net/UnknownServiceException.java \
-java/net/VMNetworkInterface.java
+java/net/VMNetworkInterface.java \
+java/net/VMURLConnection.java
java_net_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_net_source_files)))
@@ -5584,16 +5883,29 @@ classpath/java/util/ConcurrentModificationException.java \
java/util/Currency.java \
classpath/java/util/Date.java \
classpath/java/util/Dictionary.java \
+classpath/java/util/DuplicateFormatFlagsException.java \
classpath/java/util/EmptyStackException.java \
classpath/java/util/Enumeration.java \
classpath/java/util/EventListener.java \
classpath/java/util/EventListenerProxy.java \
classpath/java/util/EventObject.java \
+classpath/java/util/FormatFlagsConversionMismatchException.java \
+classpath/java/util/Formattable.java \
+classpath/java/util/FormattableFlags.java \
+classpath/java/util/Formatter.java \
+classpath/java/util/FormatterClosedException.java \
java/util/GregorianCalendar.java \
classpath/java/util/HashMap.java \
classpath/java/util/HashSet.java \
classpath/java/util/Hashtable.java \
classpath/java/util/IdentityHashMap.java \
+classpath/java/util/IllegalFormatCodePointException.java \
+classpath/java/util/IllegalFormatConversionException.java \
+classpath/java/util/IllegalFormatException.java \
+classpath/java/util/IllegalFormatFlagsException.java \
+classpath/java/util/IllegalFormatPrecisionException.java \
+classpath/java/util/IllegalFormatWidthException.java \
+classpath/java/util/InputMismatchException.java \
classpath/java/util/InvalidPropertiesFormatException.java \
classpath/java/util/Iterator.java \
classpath/java/util/LinkedHashMap.java \
@@ -5604,6 +5916,8 @@ classpath/java/util/ListIterator.java \
classpath/java/util/ListResourceBundle.java \
java/util/Locale.java \
classpath/java/util/Map.java \
+classpath/java/util/MissingFormatArgumentException.java \
+classpath/java/util/MissingFormatWidthException.java \
classpath/java/util/MissingResourceException.java \
classpath/java/util/NoSuchElementException.java \
classpath/java/util/Observable.java \
@@ -5627,6 +5941,9 @@ classpath/java/util/TimerTask.java \
classpath/java/util/TooManyListenersException.java \
classpath/java/util/TreeMap.java \
classpath/java/util/TreeSet.java \
+classpath/java/util/UUID.java \
+classpath/java/util/UnknownFormatConversionException.java \
+classpath/java/util/UnknownFormatFlagsException.java \
java/util/VMTimeZone.java \
classpath/java/util/Vector.java \
classpath/java/util/WeakHashMap.java
@@ -5677,6 +5994,7 @@ classpath/java/util/logging/Level.java \
java/util/logging/LogManager.java \
classpath/java/util/logging/LogRecord.java \
java/util/logging/Logger.java \
+classpath/java/util/logging/LoggingMXBean.java \
classpath/java/util/logging/LoggingPermission.java \
classpath/java/util/logging/MemoryHandler.java \
classpath/java/util/logging/SimpleFormatter.java \
@@ -5956,7 +6274,33 @@ javax-imageio.lo: $(javax_imageio_source_files)
@rm -f javax-imageio.list
javax_management_source_files = \
-classpath/javax/management/Attribute.java
+classpath/javax/management/Attribute.java \
+classpath/javax/management/AttributeList.java \
+classpath/javax/management/AttributeNotFoundException.java \
+classpath/javax/management/DynamicMBean.java \
+classpath/javax/management/IntrospectionException.java \
+classpath/javax/management/InvalidAttributeValueException.java \
+classpath/javax/management/JMException.java \
+classpath/javax/management/JMRuntimeException.java \
+classpath/javax/management/ListenerNotFoundException.java \
+classpath/javax/management/MBeanAttributeInfo.java \
+classpath/javax/management/MBeanConstructorInfo.java \
+classpath/javax/management/MBeanException.java \
+classpath/javax/management/MBeanFeatureInfo.java \
+classpath/javax/management/MBeanInfo.java \
+classpath/javax/management/MBeanNotificationInfo.java \
+classpath/javax/management/MBeanOperationInfo.java \
+classpath/javax/management/MBeanParameterInfo.java \
+classpath/javax/management/NotCompliantMBeanException.java \
+classpath/javax/management/Notification.java \
+classpath/javax/management/NotificationBroadcaster.java \
+classpath/javax/management/NotificationEmitter.java \
+classpath/javax/management/NotificationFilter.java \
+classpath/javax/management/NotificationListener.java \
+classpath/javax/management/OperationsException.java \
+classpath/javax/management/ReflectionException.java \
+classpath/javax/management/RuntimeOperationsException.java \
+classpath/javax/management/StandardMBean.java
javax_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_management_source_files)))
@@ -5971,6 +6315,31 @@ javax/management.list: $(javax_management_source_files)
-include javax/management.deps
+javax_management_openmbean_source_files = \
+classpath/javax/management/openmbean/ArrayType.java \
+classpath/javax/management/openmbean/CompositeData.java \
+classpath/javax/management/openmbean/CompositeDataSupport.java \
+classpath/javax/management/openmbean/CompositeType.java \
+classpath/javax/management/openmbean/InvalidKeyException.java \
+classpath/javax/management/openmbean/OpenDataException.java \
+classpath/javax/management/openmbean/OpenType.java \
+classpath/javax/management/openmbean/SimpleType.java \
+classpath/javax/management/openmbean/TabularData.java \
+classpath/javax/management/openmbean/TabularType.java
+
+javax_management_openmbean_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_management_openmbean_source_files)))
+
+javax/management/openmbean.list: $(javax_management_openmbean_source_files)
+ @$(mkinstalldirs) $(dir $@)
+ @for file in $(javax_management_openmbean_source_files); do \
+ if test -f $(srcdir)/$$file; then \
+ echo $(srcdir)/$$file; \
+ else echo $$file; fi; \
+ done > javax/management/openmbean.list
+
+-include javax/management/openmbean.deps
+
+
javax_naming_source_files = \
classpath/javax/naming/AuthenticationException.java \
classpath/javax/naming/AuthenticationNotSupportedException.java \
@@ -6116,7 +6485,7 @@ classpath/javax/naming/spi/DirStateFactory.java \
classpath/javax/naming/spi/DirectoryManager.java \
classpath/javax/naming/spi/InitialContextFactory.java \
classpath/javax/naming/spi/InitialContextFactoryBuilder.java \
-classpath/javax/naming/spi/NamingManager.java \
+javax/naming/spi/NamingManager.java \
classpath/javax/naming/spi/ObjectFactory.java \
classpath/javax/naming/spi/ObjectFactoryBuilder.java \
classpath/javax/naming/spi/ResolveResult.java \
@@ -6391,7 +6760,9 @@ classpath/javax/rmi/CORBA/Util.java \
classpath/javax/rmi/CORBA/UtilDelegate.java \
classpath/javax/rmi/CORBA/ValueHandler.java \
classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java \
-classpath/javax/rmi/PortableRemoteObject.java
+classpath/javax/rmi/PortableRemoteObject.java \
+classpath/javax/rmi/ssl/SslRMIClientSocketFactory.java \
+classpath/javax/rmi/ssl/SslRMIServerSocketFactory.java
javax-rmi.lo: $(javax_rmi_source_files)
@find classpath/lib/javax/rmi -name '*.class' > javax-rmi.list
@@ -7287,6 +7658,7 @@ classpath/javax/swing/text/DocumentFilter.java \
classpath/javax/swing/text/EditorKit.java \
classpath/javax/swing/text/Element.java \
classpath/javax/swing/text/ElementIterator.java \
+classpath/javax/swing/text/EmptyAttributeSet.java \
classpath/javax/swing/text/FieldView.java \
classpath/javax/swing/text/FlowView.java \
classpath/javax/swing/text/GapContent.java \
@@ -7341,15 +7713,16 @@ javax/swing/text.list: $(javax_swing_text_source_files)
javax_swing_text_html_source_files = \
+classpath/javax/swing/text/html/BRView.java \
classpath/javax/swing/text/html/BlockView.java \
classpath/javax/swing/text/html/CSS.java \
classpath/javax/swing/text/html/CSSParser.java \
classpath/javax/swing/text/html/FormView.java \
+classpath/javax/swing/text/html/HRuleView.java \
classpath/javax/swing/text/html/HTML.java \
classpath/javax/swing/text/html/HTMLDocument.java \
classpath/javax/swing/text/html/HTMLEditorKit.java \
classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java \
-classpath/javax/swing/text/html/HTMLTableView.java \
classpath/javax/swing/text/html/ImageView.java \
classpath/javax/swing/text/html/InlineView.java \
classpath/javax/swing/text/html/ListView.java \
@@ -7358,7 +7731,8 @@ classpath/javax/swing/text/html/NullView.java \
classpath/javax/swing/text/html/ObjectView.java \
classpath/javax/swing/text/html/Option.java \
classpath/javax/swing/text/html/ParagraphView.java \
-classpath/javax/swing/text/html/StyleSheet.java
+classpath/javax/swing/text/html/StyleSheet.java \
+classpath/javax/swing/text/html/TableView.java
javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_text_html_source_files)))
@@ -8413,6 +8787,7 @@ all_packages_source_files = \
gnu/gcj/util.list \
gnu/java/awt.list \
gnu/java/awt/color.list \
+ gnu/java/awt/dnd.list \
gnu/java/awt/font.list \
gnu/java/awt/font/opentype.list \
gnu/java/awt/font/opentype/truetype.list \
@@ -8422,10 +8797,12 @@ all_packages_source_files = \
gnu/java/awt/print.list \
gnu/java/io.list \
gnu/java/lang.list \
+ gnu/java/lang/management.list \
gnu/java/lang/reflect.list \
gnu/java/locale.list \
gnu/java/math.list \
gnu/java/net.list \
+ gnu/java/net/loader.list \
gnu/java/net/local.list \
gnu/java/net/protocol/core.list \
gnu/java/net/protocol/file.list \
@@ -8467,6 +8844,7 @@ all_packages_source_files = \
gnu/java/util.list \
gnu/java/util/jar.list \
gnu/java/util/prefs.list \
+ gnu/java/util/regex.list \
gnu/javax/crypto.list \
gnu/javax/crypto/assembly.list \
gnu/javax/crypto/cipher.list \
@@ -8483,6 +8861,7 @@ all_packages_source_files = \
gnu/javax/crypto/key/dh.list \
gnu/javax/crypto/key/srp6.list \
gnu/javax/crypto/keyring.list \
+ gnu/javax/crypto/kwa.list \
gnu/javax/crypto/mac.list \
gnu/javax/crypto/mode.list \
gnu/javax/crypto/pad.list \
@@ -8492,7 +8871,11 @@ all_packages_source_files = \
gnu/javax/crypto/sasl/crammd5.list \
gnu/javax/crypto/sasl/plain.list \
gnu/javax/crypto/sasl/srp.list \
+ gnu/javax/imageio.list \
gnu/javax/imageio/bmp.list \
+ gnu/javax/imageio/gif.list \
+ gnu/javax/imageio/jpeg.list \
+ gnu/javax/imageio/png.list \
gnu/javax/net/ssl.list \
gnu/javax/net/ssl/provider.list \
gnu/javax/print.list \
@@ -8505,6 +8888,8 @@ all_packages_source_files = \
gnu/javax/security/auth.list \
gnu/javax/security/auth/callback.list \
gnu/javax/security/auth/login.list \
+ gnu/javax/sound/sampled/AU.list \
+ gnu/javax/sound/sampled/WAV.list \
gnu/javax/swing/plaf/gnu.list \
gnu/javax/swing/plaf/metal.list \
gnu/javax/swing/text/html.list \
@@ -8513,7 +8898,6 @@ all_packages_source_files = \
gnu/javax/swing/text/html/parser/support.list \
gnu/javax/swing/text/html/parser/support/low.list \
gnu/javax/swing/tree.list \
- gnu/regexp.list \
java/applet.list \
java/awt.list \
java/awt/color.list \
@@ -8535,6 +8919,7 @@ all_packages_source_files = \
java/lang.list \
java/lang/annotation.list \
java/lang/instrument.list \
+ java/lang/management.list \
java/lang/ref.list \
java/lang/reflect.list \
java/math.list \
@@ -8567,6 +8952,7 @@ all_packages_source_files = \
javax/crypto/interfaces.list \
javax/crypto/spec.list \
javax/management.list \
+ javax/management/openmbean.list \
javax/naming.list \
javax/naming/directory.list \
javax/naming/event.list \
@@ -8632,6 +9018,7 @@ ordinary_header_files = \
$(gnu_gcj_util_header_files) \
$(gnu_java_awt_header_files) \
$(gnu_java_awt_color_header_files) \
+ $(gnu_java_awt_dnd_header_files) \
$(gnu_java_awt_font_header_files) \
$(gnu_java_awt_font_opentype_header_files) \
$(gnu_java_awt_font_opentype_truetype_header_files) \
@@ -8641,10 +9028,12 @@ ordinary_header_files = \
$(gnu_java_awt_print_header_files) \
$(gnu_java_io_header_files) \
$(gnu_java_lang_header_files) \
+ $(gnu_java_lang_management_header_files) \
$(gnu_java_lang_reflect_header_files) \
$(gnu_java_locale_header_files) \
$(gnu_java_math_header_files) \
$(gnu_java_net_header_files) \
+ $(gnu_java_net_loader_header_files) \
$(gnu_java_net_local_header_files) \
$(gnu_java_net_protocol_core_header_files) \
$(gnu_java_net_protocol_file_header_files) \
@@ -8686,6 +9075,7 @@ ordinary_header_files = \
$(gnu_java_util_header_files) \
$(gnu_java_util_jar_header_files) \
$(gnu_java_util_prefs_header_files) \
+ $(gnu_java_util_regex_header_files) \
$(gnu_javax_crypto_header_files) \
$(gnu_javax_crypto_assembly_header_files) \
$(gnu_javax_crypto_cipher_header_files) \
@@ -8702,6 +9092,7 @@ ordinary_header_files = \
$(gnu_javax_crypto_key_dh_header_files) \
$(gnu_javax_crypto_key_srp6_header_files) \
$(gnu_javax_crypto_keyring_header_files) \
+ $(gnu_javax_crypto_kwa_header_files) \
$(gnu_javax_crypto_mac_header_files) \
$(gnu_javax_crypto_mode_header_files) \
$(gnu_javax_crypto_pad_header_files) \
@@ -8711,7 +9102,11 @@ ordinary_header_files = \
$(gnu_javax_crypto_sasl_crammd5_header_files) \
$(gnu_javax_crypto_sasl_plain_header_files) \
$(gnu_javax_crypto_sasl_srp_header_files) \
+ $(gnu_javax_imageio_header_files) \
$(gnu_javax_imageio_bmp_header_files) \
+ $(gnu_javax_imageio_gif_header_files) \
+ $(gnu_javax_imageio_jpeg_header_files) \
+ $(gnu_javax_imageio_png_header_files) \
$(gnu_javax_net_ssl_header_files) \
$(gnu_javax_net_ssl_provider_header_files) \
$(gnu_javax_print_header_files) \
@@ -8724,6 +9119,8 @@ ordinary_header_files = \
$(gnu_javax_security_auth_header_files) \
$(gnu_javax_security_auth_callback_header_files) \
$(gnu_javax_security_auth_login_header_files) \
+ $(gnu_javax_sound_sampled_AU_header_files) \
+ $(gnu_javax_sound_sampled_WAV_header_files) \
$(gnu_javax_swing_plaf_gnu_header_files) \
$(gnu_javax_swing_plaf_metal_header_files) \
$(gnu_javax_swing_text_html_header_files) \
@@ -8732,7 +9129,6 @@ ordinary_header_files = \
$(gnu_javax_swing_text_html_parser_support_header_files) \
$(gnu_javax_swing_text_html_parser_support_low_header_files) \
$(gnu_javax_swing_tree_header_files) \
- $(gnu_regexp_header_files) \
$(java_applet_header_files) \
$(java_awt_header_files) \
$(java_awt_color_header_files) \
@@ -8754,6 +9150,7 @@ ordinary_header_files = \
$(java_lang_header_files) \
$(java_lang_annotation_header_files) \
$(java_lang_instrument_header_files) \
+ $(java_lang_management_header_files) \
$(java_lang_ref_header_files) \
$(java_lang_reflect_header_files) \
$(java_math_header_files) \
@@ -8786,6 +9183,7 @@ ordinary_header_files = \
$(javax_crypto_interfaces_header_files) \
$(javax_crypto_spec_header_files) \
$(javax_management_header_files) \
+ $(javax_management_openmbean_header_files) \
$(javax_naming_header_files) \
$(javax_naming_directory_header_files) \
$(javax_naming_event_header_files) \
@@ -8833,10 +9231,12 @@ ordinary_header_files = \
bc_objects = \
gnu-CORBA.lo \
+ gnu-java-awt-dnd-peer-gtk.lo \
gnu-java-awt-peer-gtk.lo \
gnu-java-awt-peer-qt.lo \
gnu-java-awt-peer-swing.lo \
gnu-java-beans.lo \
+ gnu-java-util-prefs-gconf.lo \
gnu-javax-rmi.lo \
gnu-javax-sound-midi.lo \
gnu-xml.lo \
@@ -8858,16 +9258,22 @@ property_files = \
classpath/resource/gnu/classpath/tools/native2ascii/messages.properties \
classpath/resource/gnu/classpath/tools/serialver/messages.properties \
classpath/resource/gnu/java/awt/peer/gtk/font.properties \
+ classpath/resource/gnu/java/awt/peer/x/fonts.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties \
+ classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties \
classpath/resource/gnu/javax/print/PrinterDialog.properties \
classpath/resource/gnu/javax/print/PrinterDialog_de.properties \
classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties \
- classpath/resource/gnu/regexp/MessagesBundle.properties \
- classpath/resource/gnu/regexp/MessagesBundle_fr.properties \
- classpath/resource/gnu/regexp/MessagesBundle_it.properties \
classpath/resource/java/util/iso4217.properties \
classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties \
classpath/resource/org/ietf/jgss/MessagesBundle.properties \
+ classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory \
+ classpath/resource/META-INF/services/java.util.prefs.PreferencesFactory.in \
classpath/resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider \
+ classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileReader \
+ classpath/resource/META-INF/services/javax.sound.midi.spi.MidiFileWriter \
+ classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader \
classpath/resource/META-INF/services/javax.xml.parsers.DocumentBuilderFactory \
classpath/resource/META-INF/services/javax.xml.parsers.SAXParserFactory \
classpath/resource/META-INF/services/javax.xml.parsers.TransformerFactory \
diff --git a/libjava/testsuite/Makefile.in b/libjava/testsuite/Makefile.in
index a61199b9775..73026dd2246 100644
--- a/libjava/testsuite/Makefile.in
+++ b/libjava/testsuite/Makefile.in
@@ -239,6 +239,7 @@ bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
+build_libsubdir = @build_libsubdir@
build_os = @build_os@
build_subdir = @build_subdir@
build_vendor = @build_vendor@
OpenPOWER on IntegriCloud