--- a/jdk/make/docs/CORE_PKGS.gmk Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/docs/CORE_PKGS.gmk Mon Dec 10 20:58:36 2012 -0800
@@ -131,6 +131,7 @@
java.util.concurrent \
java.util.concurrent.atomic \
java.util.concurrent.locks \
+ java.util.function \
java.util.jar \
java.util.logging \
java.util.prefs \
--- a/jdk/make/java/java/FILES_java.gmk Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/java/java/FILES_java.gmk Mon Dec 10 20:58:36 2012 -0800
@@ -147,6 +147,7 @@
java/lang/ref/PhantomReference.java \
java/lang/ref/ReferenceQueue.java \
java/lang/ref/Finalizer.java \
+ java/util/Base64.java \
java/util/BitSet.java \
java/util/Calendar.java \
java/util/GregorianCalendar.java \
--- a/jdk/make/java/java/Makefile Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/java/java/Makefile Mon Dec 10 20:58:36 2012 -0800
@@ -37,6 +37,8 @@
JAVAC_MAX_WARNINGS=true
include $(BUILDDIR)/common/Defs.gmk
+AUTO_FILES_JAVA_DIRS = java/util/function
+
# windows compiler flags
ifeq ($(PLATFORM),windows)
OTHER_CFLAGS =
--- a/jdk/make/java/net/Makefile Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/java/net/Makefile Mon Dec 10 20:58:36 2012 -0800
@@ -77,6 +77,7 @@
FILES_export += java/net/DualStackPlainSocketImpl.java
FILES_export += java/net/TwoStacksPlainDatagramSocketImpl.java
FILES_export += java/net/DualStackPlainDatagramSocketImpl.java
+ FILES_export += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java
else
FILES_export += java/net/PlainDatagramSocketImpl.java
endif
--- a/jdk/make/java/nio/Makefile Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/java/nio/Makefile Mon Dec 10 20:58:36 2012 -0800
@@ -69,6 +69,7 @@
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\
sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/PollingWatchService.java \
sun/nio/fs/SolarisAclFileAttributeView.java \
sun/nio/fs/SolarisFileStore.java \
@@ -202,6 +203,8 @@
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\
sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/MagicFileTypeDetector.java \
+ sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/LinuxDosFileAttributeView.java \
sun/nio/fs/LinuxFileStore.java \
sun/nio/fs/LinuxFileSystem.java \
@@ -239,6 +242,7 @@
UnixAsynchronousSocketChannelImpl.c \
\
GnomeFileTypeDetector.c \
+ MagicFileTypeDetector.c \
LinuxNativeDispatcher.c \
LinuxWatchService.c \
UnixCopyFile.c \
@@ -254,6 +258,7 @@
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\
sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/MagicFileTypeDetector.java \
sun/nio/fs/LinuxNativeDispatcher.java \
sun/nio/fs/LinuxWatchService.java \
sun/nio/fs/UnixCopyFile.java \
@@ -277,6 +282,7 @@
sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\
+ sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/BsdFileStore.java \
sun/nio/fs/BsdFileSystem.java \
sun/nio/fs/BsdFileSystemProvider.java \
--- a/jdk/make/java/nio/mapfile-linux Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/java/nio/mapfile-linux Mon Dec 10 20:58:36 2012 -0800
@@ -130,6 +130,8 @@
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
+ Java_sun_nio_fs_MagicFileTypeDetector_initialize0;
+ Java_sun_nio_fs_MagicFileTypeDetector_probe0;
Java_sun_nio_fs_LinuxWatchService_eventSize;
Java_sun_nio_fs_LinuxWatchService_eventOffsets;
Java_sun_nio_fs_LinuxWatchService_inotifyInit;
--- a/jdk/make/jprt.properties Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/make/jprt.properties Mon Dec 10 20:58:36 2012 -0800
@@ -86,7 +86,6 @@
${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \
${jprt.my.test.target.set:TESTNAME=jdk_text}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools}, \
- ${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \
${jprt.my.test.target.set:TESTNAME=jdk_jfr}, \
${jprt.my.test.target.set:TESTNAME=jdk_other}
@@ -103,6 +102,7 @@
${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \
${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \
${jprt.my.test.target.set:TESTNAME=jdk_beans3}, \
+ ${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \
${jprt.my.test.target.set:TESTNAME=jdk_sound}, \
${jprt.my.test.target.set:TESTNAME=jdk_swing}
--- a/jdk/makefiles/CompileJavaClasses.gmk Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/makefiles/CompileJavaClasses.gmk Mon Dec 10 20:58:36 2012 -0800
@@ -121,6 +121,7 @@
sun/nio/fs/LinuxFileStore.java \
sun/nio/fs/LinuxFileSystem.java \
sun/nio/fs/LinuxFileSystemProvider.java \
+ sun/nio/fs/MagicFileTypeDetector.java \
sun/nio/fs/LinuxNativeDispatcher.java \
sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
sun/nio/fs/LinuxWatchService.java
--- a/jdk/makefiles/CompileNativeLibraries.gmk Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/makefiles/CompileNativeLibraries.gmk Mon Dec 10 20:58:36 2012 -0800
@@ -1897,6 +1897,7 @@
UnixAsynchronousServerSocketChannelImpl.c \
UnixAsynchronousSocketChannelImpl.c \
GnomeFileTypeDetector.c \
+ MagicFileTypeDetector.c \
LinuxNativeDispatcher.c \
LinuxWatchService.c \
UnixCopyFile.c \
--- a/jdk/makefiles/mapfiles/libnio/mapfile-linux Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/makefiles/mapfiles/libnio/mapfile-linux Mon Dec 10 20:58:36 2012 -0800
@@ -130,6 +130,8 @@
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
+ Java_sun_nio_fs_MagicFileTypeDetector_initialize0;
+ Java_sun_nio_fs_MagicFileTypeDetector_probe0;
Java_sun_nio_fs_LinuxWatchService_eventSize;
Java_sun_nio_fs_LinuxWatchService_eventOffsets;
Java_sun_nio_fs_LinuxWatchService_inotifyInit;
--- a/jdk/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java Mon Dec 10 20:58:36 2012 -0800
@@ -714,7 +714,8 @@
"PopupMenu.font", menuFont,
"PopupMenu.background", menuBackgroundColor,
- "PopupMenu.translucentBackground", translucentWhite,
+ // Fix for 7154516: make popups opaque
+ "PopupMenu.translucentBackground", white,
"PopupMenu.foreground", menuForegroundColor,
"PopupMenu.selectionBackground", menuSelectedBackgroundColor,
"PopupMenu.selectionForeground", menuSelectedForegroundColor,
--- a/jdk/src/macosx/classes/sun/awt/CGraphicsConfig.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/awt/CGraphicsConfig.java Mon Dec 10 20:58:36 2012 -0800
@@ -31,13 +31,16 @@
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
+import sun.lwawt.LWGraphicsConfig;
import sun.lwawt.macosx.CPlatformView;
-public class CGraphicsConfig extends GraphicsConfiguration {
+public abstract class CGraphicsConfig extends GraphicsConfiguration
+ implements LWGraphicsConfig {
+
private final CGraphicsDevice device;
private ColorModel colorModel;
- public CGraphicsConfig(CGraphicsDevice device) {
+ protected CGraphicsConfig(CGraphicsDevice device) {
this.device = device;
}
@@ -84,88 +87,20 @@
return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
}
-
- /**
- * The following methods are invoked from CToolkit.java and
- * LWWindowPeer.java rather than having the native
- * implementations hardcoded in those classes. This way the appropriate
- * actions are taken based on the peer's GraphicsConfig, whether it is
- * an CGLGraphicsConfig or something else.
- */
-
/**
* Creates a new SurfaceData that will be associated with the given
* LWWindowPeer.
*/
- public SurfaceData createSurfaceData(CPlatformView pView) {
- throw new UnsupportedOperationException("not implemented");
- }
+ public abstract SurfaceData createSurfaceData(CPlatformView pView);
/**
* Creates a new SurfaceData that will be associated with the given
* CGLLayer.
*/
- public SurfaceData createSurfaceData(CGLLayer layer) {
- throw new UnsupportedOperationException("not implemented");
- }
-
- /**
- * Creates a new hidden-acceleration image of the given width and height
- * that is associated with the target Component.
- */
- public Image createAcceleratedImage(Component target,
- int width, int height)
- {
- throw new UnsupportedOperationException("not implemented");
- }
-
- /**
- * The following methods correspond to the multibuffering methods in
- * LWWindowPeer.java...
- */
-
- /**
- * Attempts to create a native backbuffer for the given peer. If
- * the requested configuration is not natively supported, an AWTException
- * is thrown. Otherwise, if the backbuffer creation is successful, a
- * handle to the native backbuffer is returned.
- */
- public long createBackBuffer(CPlatformView pView,
- int numBuffers, BufferCapabilities caps)
- throws AWTException
- {
- throw new UnsupportedOperationException("not implemented");
- }
-
- public void destroyBackBuffer(long backBuffer)
- throws AWTException
- {
- throw new UnsupportedOperationException("not implemented");
- }
-
- /**
- * Creates a VolatileImage that essentially wraps the target Component's
- * backbuffer, using the provided backbuffer handle.
- */
- public VolatileImage createBackBufferImage(Component target,
- long backBuffer)
- {
- throw new UnsupportedOperationException("not implemented");
- }
-
- /**
- * Performs the native flip operation for the given target Component.
- */
- public void flip(CPlatformView delegate,
- Component target, VolatileImage xBackBuffer,
- int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction)
- {
- throw new UnsupportedOperationException("not implemented");
- }
+ public abstract SurfaceData createSurfaceData(CGLLayer layer);
@Override
- public boolean isTranslucencyCapable() {
+ public final boolean isTranslucencyCapable() {
//we know for sure we have capable config :)
return true;
}
--- a/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,7 +27,6 @@
import java.awt.AWTException;
import java.awt.BufferCapabilities;
-import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -48,13 +47,10 @@
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
-import sun.awt.TextureSizeConstraining;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
-import sun.awt.image.SurfaceManager;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
-import sun.java2d.SunGraphics2D;
import sun.java2d.Surface;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.OGLContext.OGLContextCaps;
@@ -63,18 +59,19 @@
import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.opengl.OGLSurfaceData.*;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
-import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData;
import sun.java2d.pipe.hw.AccelDeviceEventListener;
import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
+import sun.lwawt.LWComponentPeer;
import sun.lwawt.macosx.CPlatformView;
-public class CGLGraphicsConfig extends CGraphicsConfig
- implements OGLGraphicsConfig, TextureSizeConstraining
+public final class CGLGraphicsConfig extends CGraphicsConfig
+ implements OGLGraphicsConfig
{
- //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
+ //private static final int kOpenGLSwapInterval =
+ // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
- protected static boolean cglAvailable;
+ private static boolean cglAvailable;
private static ImageCapabilities imageCaps = new CGLImageCaps();
private int pixfmt;
@@ -82,7 +79,7 @@
private long pConfigInfo;
private ContextCapabilities oglCaps;
private OGLContext context;
- private Object disposerReferent = new Object();
+ private final Object disposerReferent = new Object();
public static native int getDefaultPixFmt(int screennum);
private static native boolean initCGL();
@@ -94,7 +91,7 @@
cglAvailable = initCGL();
}
- protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
+ private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
long configInfo, ContextCapabilities oglCaps)
{
super(device);
@@ -170,11 +167,13 @@
* Returns true if the provided capability bit is present for this config.
* See OGLContext.java for a list of supported capabilities.
*/
- public final boolean isCapPresent(int cap) {
+ @Override
+ public boolean isCapPresent(int cap) {
return ((oglCaps.getCaps() & cap) != 0);
}
- public final long getNativeConfigInfo() {
+ @Override
+ public long getNativeConfigInfo() {
return pConfigInfo;
}
@@ -183,7 +182,8 @@
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
- public final OGLContext getContext() {
+ @Override
+ public OGLContext getContext() {
return context;
}
@@ -257,145 +257,83 @@
return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]");
}
-
- /**
- * The following methods are invoked from ComponentModel.java rather
- * than having the Mac OS X-dependent implementations hardcoded in that
- * class. This way the appropriate actions are taken based on the peer's
- * GraphicsConfig, whether it is a CGraphicsConfig or a
- * CGLGraphicsConfig.
- */
-
- /**
- * Creates a new SurfaceData that will be associated with the given
- * LWWindowPeer.
- */
@Override
public SurfaceData createSurfaceData(CPlatformView pView) {
return CGLSurfaceData.createData(pView);
}
- /**
- * Creates a new SurfaceData that will be associated with the given
- * CGLLayer.
- */
@Override
public SurfaceData createSurfaceData(CGLLayer layer) {
return CGLSurfaceData.createData(layer);
}
- /**
- * Creates a new hidden-acceleration image of the given width and height
- * that is associated with the target Component.
- */
@Override
public Image createAcceleratedImage(Component target,
int width, int height)
{
ColorModel model = getColorModel(Transparency.OPAQUE);
- WritableRaster wr =
- model.createCompatibleWritableRaster(width, height);
+ WritableRaster wr = model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied());
}
- /**
- * The following methods correspond to the multibuffering methods in
- * CWindowPeer.java...
- */
-
- /**
- * Attempts to create a OGL-based backbuffer for the given peer. If
- * the requested configuration is not natively supported, an AWTException
- * is thrown. Otherwise, if the backbuffer creation is successful, a
- * value of 1 is returned.
- */
@Override
- public long createBackBuffer(CPlatformView pView,
- int numBuffers, BufferCapabilities caps)
- throws AWTException
- {
- if (numBuffers > 2) {
- throw new AWTException(
- "Only double or single buffering is supported");
+ public void assertOperationSupported(final int numBuffers,
+ final BufferCapabilities caps)
+ throws AWTException {
+ // Assume this method is never called with numBuffers != 2, as 0 is
+ // unsupported, and 1 corresponds to a SingleBufferStrategy which
+ // doesn't depend on the peer. Screen is considered as a separate
+ // "buffer".
+ if (numBuffers != 2) {
+ throw new AWTException("Only double buffering is supported");
}
- BufferCapabilities configCaps = getBufferCapabilities();
+ final BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
-
- // non-zero return value means backbuffer creation was successful
- // (checked in CPlatformWindow.flip(), etc.)
- return 1;
}
- /**
- * Destroys the backbuffer object represented by the given handle value.
- */
@Override
- public void destroyBackBuffer(long backBuffer) {
- }
-
- /**
- * Creates a VolatileImage that essentially wraps the target Component's
- * backbuffer (the provided backbuffer handle is essentially ignored).
- */
- @Override
- public VolatileImage createBackBufferImage(Component target,
- long backBuffer)
- {
- return new SunVolatileImage(target,
- target.getWidth(), target.getHeight(),
- Boolean.TRUE);
+ public Image createBackBuffer(final LWComponentPeer<?, ?> peer) {
+ final Rectangle r = peer.getBounds();
+ // It is possible for the component to have size 0x0, adjust it to
+ // be at least 1x1 to avoid IAE
+ final int w = Math.max(1, r.width);
+ final int h = Math.max(1, r.height);
+ final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT
+ : Transparency.OPAQUE;
+ return new SunVolatileImage(this, w, h, transparency, null);
}
- /**
- * Performs the native OGL flip operation for the given target Component.
- */
@Override
- public void flip(CPlatformView pView,
- Component target, VolatileImage xBackBuffer,
- int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction)
- {
- if (flipAction == BufferCapabilities.FlipContents.COPIED) {
- SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
- SurfaceData sd = vsm.getPrimarySurfaceData();
+ public void destroyBackBuffer(final Image backBuffer) {
+ if (backBuffer != null) {
+ backBuffer.flush();
+ }
+ }
- if (sd instanceof CGLVSyncOffScreenSurfaceData) {
- CGLVSyncOffScreenSurfaceData vsd =
- (CGLVSyncOffScreenSurfaceData)sd;
- SurfaceData bbsd = vsd.getFlipSurface();
- Graphics2D bbg =
- new SunGraphics2D(bbsd, Color.black, Color.white, null);
- try {
- bbg.drawImage(xBackBuffer, 0, 0, null);
- } finally {
- bbg.dispose();
- }
- } else {
- pView.drawImageOnPeer(xBackBuffer, x1, y1, x2, y2);
- return;
- }
- } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
- // not supported by CGL...
- return;
+ @Override
+ public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
+ final int x1, final int y1, final int x2, final int y2,
+ final BufferCapabilities.FlipContents flipAction) {
+ final Graphics g = peer.getGraphics();
+ try {
+ g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
+ } finally {
+ g.dispose();
}
-
- OGLSurfaceData.swapBuffers(pView.getAWTView());
-
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
- Graphics g = xBackBuffer.getGraphics();
+ final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
try {
- g.setColor(target.getBackground());
- g.fillRect(0, 0,
- xBackBuffer.getWidth(),
- xBackBuffer.getHeight());
+ bg.setBackground(peer.getBackground());
+ bg.clearRect(0, 0, backBuffer.getWidth(null),
+ backBuffer.getHeight(null));
} finally {
- g.dispose();
+ bg.dispose();
}
}
}
@@ -429,15 +367,10 @@
return imageCaps;
}
- /**
- * {@inheritDoc}
- *
- * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
- */
- public VolatileImage
- createCompatibleVolatileImage(int width, int height,
- int transparency, int type)
- {
+ @Override
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ int transparency,
+ int type) {
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
transparency == Transparency.BITMASK)
{
@@ -473,15 +406,18 @@
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
+ @Override
public ContextCapabilities getContextCapabilities() {
return oglCaps;
}
+ @Override
public void addDeviceEventListener(AccelDeviceEventListener l) {
int screen = getDevice().getCoreGraphicsScreen();
AccelDeviceEventNotifier.addListener(l, screen);
}
+ @Override
public void removeDeviceEventListener(AccelDeviceEventListener l) {
AccelDeviceEventNotifier.removeListener(l);
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWCanvasPeer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/LWCanvasPeer.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,12 +26,9 @@
package sun.lwawt;
-import java.awt.AWTException;
-import java.awt.BufferCapabilities;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
-import java.awt.Image;
import java.awt.peer.CanvasPeer;
import javax.swing.JComponent;
@@ -42,35 +39,10 @@
LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
super(target, platformComponent);
}
- // ---- PEER METHODS ---- //
-
- @Override
- public void createBuffers(int numBuffers, BufferCapabilities caps)
- throws AWTException {
- // TODO
- }
-
- @Override
- public Image getBackBuffer() {
- // TODO
- return null;
- }
-
- @Override
- public void flip(int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction) {
- // TODO
- }
-
- @Override
- public void destroyBuffers() {
- // TODO
- }
@Override
public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
- GraphicsConfiguration gc)
- {
+ final GraphicsConfiguration gc) {
// TODO
return gc;
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Mon Dec 10 20:58:36 2012 -0800
@@ -138,6 +138,11 @@
*/
static final char WIDE_CHAR = '0';
+ /**
+ * The back buffer provide user with a BufferStrategy.
+ */
+ private Image backBuffer;
+
private final class DelegateContainer extends Container {
{
enableEvents(0xFFFFFFFF);
@@ -389,6 +394,7 @@
}
protected void disposeImpl() {
+ destroyBuffers();
LWContainerPeer cp = getContainerPeer();
if (cp != null) {
cp.removeChildPeer(this);
@@ -415,6 +421,12 @@
return getWindowPeer().getGraphicsConfiguration();
}
+
+ // Just a helper method
+ public final LWGraphicsConfig getLWGC() {
+ return (LWGraphicsConfig) getGraphicsConfiguration();
+ }
+
/*
* Overridden in LWWindowPeer to replace its surface
* data and back buffer.
@@ -506,31 +518,45 @@
return getGraphicsConfiguration().getColorModel();
}
- @Override
- public void createBuffers(int numBuffers, BufferCapabilities caps)
- throws AWTException {
- throw new AWTException("Back buffers are only supported for " +
- "Window or Canvas components.");
+ public boolean isTranslucent() {
+ // Translucent windows of the top level are supported only
+ return false;
}
- /*
- * To be overridden in LWWindowPeer and LWCanvasPeer.
- */
@Override
- public Image getBackBuffer() {
- // Return null or throw AWTException?
- return null;
+ public final void createBuffers(int numBuffers, BufferCapabilities caps)
+ throws AWTException {
+ getLWGC().assertOperationSupported(numBuffers, caps);
+ final Image buffer = getLWGC().createBackBuffer(this);
+ synchronized (getStateLock()) {
+ backBuffer = buffer;
+ }
}
@Override
- public void flip(int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction) {
- // Skip silently or throw AWTException?
+ public final Image getBackBuffer() {
+ synchronized (getStateLock()) {
+ if (backBuffer != null) {
+ return backBuffer;
+ }
+ }
+ throw new IllegalStateException("Buffers have not been created");
}
@Override
- public void destroyBuffers() {
- // Do nothing
+ public final void flip(int x1, int y1, int x2, int y2,
+ BufferCapabilities.FlipContents flipAction) {
+ getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction);
+ }
+
+ @Override
+ public final void destroyBuffers() {
+ final Image oldBB;
+ synchronized (getStateLock()) {
+ oldBB = backBuffer;
+ backBuffer = null;
+ }
+ getLWGC().destroyBackBuffer(oldBB);
}
// Helper method
@@ -642,7 +668,7 @@
}
}
- protected final Color getBackground() {
+ public final Color getBackground() {
synchronized (getStateLock()) {
return background;
}
@@ -982,19 +1008,17 @@
}
@Override
- public Image createImage(ImageProducer producer) {
+ public final Image createImage(final ImageProducer producer) {
return new ToolkitImage(producer);
}
@Override
- public Image createImage(int w, int h) {
- CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
- return gc.createAcceleratedImage(getTarget(), w, h);
+ public final Image createImage(final int width, final int height) {
+ return getLWGC().createAcceleratedImage(getTarget(), width, height);
}
@Override
- public VolatileImage createVolatileImage(int w, int h) {
- // TODO: is it a right/complete implementation?
+ public final VolatileImage createVolatileImage(final int w, final int h) {
return new SunVolatileImage(getTarget(), w, h);
}
@@ -1105,8 +1129,6 @@
* of target.setLocation() or as a result of user actions (window is
* dragged with mouse).
*
- * To be overridden in LWWindowPeer to update its GraphicsConfig.
- *
* This method could be called on the toolkit thread.
*/
protected final void handleMove(final int x, final int y,
@@ -1122,13 +1144,19 @@
* Called when this peer's size has been changed either as a result of
* target.setSize() or as a result of user actions (window is resized).
*
- * To be overridden in LWWindowPeer to update its SurfaceData and
- * GraphicsConfig.
- *
* This method could be called on the toolkit thread.
*/
protected final void handleResize(final int w, final int h,
final boolean updateTarget) {
+ Image oldBB = null;
+ synchronized (getStateLock()) {
+ if (backBuffer != null) {
+ oldBB = backBuffer;
+ backBuffer = getLWGC().createBackBuffer(this);
+ }
+ }
+ getLWGC().destroyBackBuffer(oldBB);
+
if (updateTarget) {
AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.lwawt;
+
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Image;
+
+/**
+ * As lwawt can be used on different platforms with different graphic
+ * configurations, the general set of methods is necessary. This interface
+ * collects the methods that should be provided by GraphicsConfiguration,
+ * simplifying use by the LWAWT.
+ *
+ * @author Sergey Bylokhov
+ */
+public interface LWGraphicsConfig {
+
+ /*
+ * A GraphicsConfiguration must implements following methods to indicate
+ * that it imposes certain limitations on the maximum size of supported
+ * textures.
+ */
+
+ /**
+ * Returns the maximum width of any texture image. By default return {@code
+ * Integer.MAX_VALUE}.
+ */
+ int getMaxTextureWidth();
+
+ /**
+ * Returns the maximum height of any texture image. By default return {@code
+ * Integer.MAX_VALUE}.
+ */
+ int getMaxTextureHeight();
+
+ /*
+ * The following methods correspond to the multi-buffering methods in
+ * LWComponentPeer.java.
+ */
+
+ /**
+ * Checks that the requested configuration is natively supported; if not, an
+ * AWTException is thrown.
+ */
+ void assertOperationSupported(int numBuffers, BufferCapabilities caps)
+ throws AWTException;
+
+ /**
+ * Creates a back buffer for the given peer and returns the image wrapper.
+ */
+ Image createBackBuffer(LWComponentPeer<?, ?> peer);
+
+ /**
+ * Destroys the back buffer object.
+ */
+ void destroyBackBuffer(Image backBuffer);
+
+ /**
+ * Performs the native flip operation for the given target Component. Our
+ * flip is implemented through normal drawImage() to the graphic object,
+ * because of our components uses a graphic object of the container(in this
+ * case we also apply necessary constrains)
+ */
+ void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
+ int x2, int y2, BufferCapabilities.FlipContents flipAction);
+
+ /**
+ * Creates a new hidden-acceleration image of the given width and height
+ * that is associated with the target Component.
+ */
+ Image createAcceleratedImage(Component target, int width, int height);
+}
--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,7 +27,6 @@
import java.awt.*;
import java.awt.event.*;
-import java.awt.image.BufferedImage;
import java.awt.peer.*;
import java.util.List;
@@ -75,17 +74,6 @@
private SurfaceData surfaceData;
private final Object surfaceDataLock = new Object();
- private int backBufferCount;
- private BufferCapabilities backBufferCaps;
-
- // The back buffer is used for two purposes:
- // 1. To render all the lightweight peers
- // 2. To provide user with a BufferStrategy
- // Need to check if a single back buffer can be used for both
-// TODO: VolatileImage
-// private VolatileImage backBuffer;
- private volatile BufferedImage backBuffer;
-
private volatile int windowState = Frame.NORMAL;
// check that the mouse is over the window
@@ -227,7 +215,6 @@
if (isGrabbing()) {
ungrab();
}
- destroyBuffers();
platformWindow.dispose();
super.disposeImpl();
}
@@ -258,8 +245,10 @@
}
@Override
- public GraphicsConfiguration getGraphicsConfiguration() {
- return graphicsConfig;
+ public final GraphicsConfiguration getGraphicsConfiguration() {
+ synchronized (getStateLock()) {
+ return graphicsConfig;
+ }
}
@Override
@@ -285,48 +274,6 @@
}
@Override
- public void createBuffers(int numBuffers, BufferCapabilities caps)
- throws AWTException
- {
- try {
- // Assume this method is never called with numBuffers <= 1, as 0 is
- // unsupported, and 1 corresponds to a SingleBufferStrategy which
- // doesn't depend on the peer. Screen is considered as a separate
- // "buffer", that's why numBuffers - 1
- assert numBuffers > 1;
-
- replaceSurfaceData(numBuffers - 1, caps, false);
- } catch (InvalidPipeException z) {
- throw new AWTException(z.toString());
- }
- }
-
- @Override
- public final Image getBackBuffer() {
- synchronized (getStateLock()) {
- return backBuffer;
- }
- }
-
- @Override
- public void flip(int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction)
- {
- platformWindow.flip(x1, y1, x2, y2, flipAction);
- }
-
- @Override
- public final void destroyBuffers() {
- final Image oldBB = getBackBuffer();
- synchronized (getStateLock()) {
- backBuffer = null;
- }
- if (oldBB != null) {
- oldBB.flush();
- }
- }
-
- @Override
public void setBounds(int x, int y, int w, int h, int op) {
if ((op & SET_CLIENT_SIZE) != 0) {
// SET_CLIENT_SIZE is only applicable to window peers, so handle it here
@@ -343,16 +290,14 @@
h = MINIMUM_HEIGHT;
}
- if (graphicsConfig instanceof TextureSizeConstraining) {
- final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
- final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
+ final int maxW = getLWGC().getMaxTextureWidth();
+ final int maxH = getLWGC().getMaxTextureHeight();
- if (w > maxW) {
- w = maxW;
- }
- if (h > maxH) {
- h = maxH;
- }
+ if (w > maxW) {
+ w = maxW;
+ }
+ if (h > maxH) {
+ h = maxH;
}
// Don't post ComponentMoved/Resized and Paint events
@@ -431,21 +376,14 @@
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
}
- final int maxW, maxH;
- if (graphicsConfig instanceof TextureSizeConstraining) {
- maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
- maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
- } else {
- maxW = maxH = Integer.MAX_VALUE;
- }
-
final Dimension max;
if (getTarget().isMaximumSizeSet()) {
max = getTarget().getMaximumSize();
- max.width = Math.min(max.width, maxW);
- max.height = Math.min(max.height, maxH);
+ max.width = Math.min(max.width, getLWGC().getMaxTextureWidth());
+ max.height = Math.min(max.height, getLWGC().getMaxTextureHeight());
} else {
- max = new Dimension(maxW, maxH);
+ max = new Dimension(getLWGC().getMaxTextureWidth(),
+ getLWGC().getMaxTextureHeight());
}
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
@@ -1014,21 +952,10 @@
replaceSurfaceData(true);
}
- private void replaceSurfaceData(boolean blit) {
- replaceSurfaceData(backBufferCount, backBufferCaps, blit);
- }
-
- private void replaceSurfaceData(int newBackBufferCount,
- BufferCapabilities newBackBufferCaps,
- boolean blit) {
+ private void replaceSurfaceData(final boolean blit) {
synchronized (surfaceDataLock) {
final SurfaceData oldData = getSurfaceData();
surfaceData = platformWindow.replaceSurfaceData();
- // TODO: volatile image
- // VolatileImage oldBB = backBuffer;
- BufferedImage oldBB = backBuffer;
- backBufferCount = newBackBufferCount;
- backBufferCaps = newBackBufferCaps;
final Rectangle size = getSize();
if (getSurfaceData() != null && oldData != getSurfaceData()) {
clearBackground(size.width, size.height);
@@ -1043,35 +970,6 @@
// This can only happen when this peer is being created
oldData.flush();
}
-
- // TODO: volatile image
- // backBuffer = (VolatileImage)delegate.createBackBuffer();
- backBuffer = (BufferedImage) platformWindow.createBackBuffer();
- if (backBuffer != null) {
- Graphics g = backBuffer.getGraphics();
- try {
- Rectangle r = getBounds();
- if (g instanceof Graphics2D) {
- ((Graphics2D) g).setComposite(AlphaComposite.Src);
- }
- g.setColor(nonOpaqueBackground);
- g.fillRect(0, 0, r.width, r.height);
- if (g instanceof SunGraphics2D) {
- SG2DConstraint((SunGraphics2D) g, getRegion());
- }
- if (!isTextured()) {
- g.setColor(getBackground());
- g.fillRect(0, 0, r.width, r.height);
- }
- if (oldBB != null) {
- // Draw the old back buffer to the new one
- g.drawImage(oldBB, 0, 0, null);
- oldBB.flush();
- }
- } finally {
- g.dispose();
- }
- }
}
}
@@ -1092,14 +990,6 @@
}
}
- public int getBackBufferCount() {
- return backBufferCount;
- }
-
- public BufferCapabilities getBackBufferCaps() {
- return backBufferCaps;
- }
-
/*
* Request the window insets from the delegate and compares it
* with the current one. This method is mostly called by the
--- a/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java Mon Dec 10 20:58:36 2012 -0800
@@ -97,17 +97,6 @@
*/
public SurfaceData replaceSurfaceData();
- /*
- * Creates a new image to serve as a back buffer.
- */
- public Image createBackBuffer();
-
- /*
- * Move the given part of the back buffer to the front buffer.
- */
- public void flip(int x1, int y1, int x2, int y2,
- BufferCapabilities.FlipContents flipAction);
-
public void setModalBlocked(boolean blocked);
public void toFront();
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Mon Dec 10 20:58:36 2012 -0800
@@ -31,12 +31,9 @@
import sun.java2d.opengl.CGLLayer;
import sun.java2d.SurfaceData;
-import sun.awt.CGraphicsConfig;
-import sun.awt.CGraphicsDevice;
import sun.awt.CausedFocusEvent;
import java.awt.*;
-import java.awt.BufferCapabilities.FlipContents;
import sun.util.logging.PlatformLogger;
@@ -113,22 +110,6 @@
}
@Override
- public Image createBackBuffer() {
- Rectangle r = peer.getBounds();
- Image im = null;
- if (!r.isEmpty()) {
- int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
- im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
- }
- return im;
- }
-
- @Override
- public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
- throw new RuntimeException("Not implemented");
- }
-
- @Override
public void setVisible(boolean visible) {}
@Override
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,7 +26,6 @@
package sun.lwawt.macosx;
import java.awt.*;
-import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig;
import sun.lwawt.LWWindowPeer;
@@ -115,26 +114,6 @@
// ----------------------------------------------------------------------
// PAINTING METHODS
// ----------------------------------------------------------------------
-
- public void drawImageOnPeer(VolatileImage xBackBuffer, int x1, int y1, int x2, int y2) {
- Graphics g = peer.getGraphics();
- try {
- g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
- } finally {
- g.dispose();
- }
- }
-
- public Image createBackBuffer() {
- Rectangle r = peer.getBounds();
- Image im = null;
- if (!r.isEmpty()) {
- int transparency = (isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT);
- im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
- }
- return im;
- }
-
public SurfaceData replaceSurfaceData() {
if (!LWCToolkit.getSunAwtDisableCALayers()) {
surfaceData = windowLayer.replaceSurfaceData();
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,7 +25,6 @@
package sun.lwawt.macosx;
-import java.awt.BufferCapabilities.FlipContents;
import java.awt.*;
import java.awt.Dialog.ModalityType;
import java.awt.event.*;
@@ -258,7 +257,7 @@
validateSurface();
}
- protected int getInitialStyleBits() {
+ private int getInitialStyleBits() {
// defaults style bits
int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
@@ -285,7 +284,6 @@
final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
styleBits = SET(styleBits, RESIZABLE, resizable);
if (!resizable) {
- styleBits = SET(styleBits, RESIZABLE, false);
styleBits = SET(styleBits, ZOOMABLE, false);
}
}
@@ -380,7 +378,7 @@
}
// this is the counter-point to -[CWindow _nativeSetStyleBit:]
- protected void setStyleBits(final int mask, final boolean value) {
+ private void setStyleBits(final int mask, final boolean value) {
nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
}
@@ -402,11 +400,6 @@
}
@Override // PlatformWindow
- public Image createBackBuffer() {
- return contentView.createBackBuffer();
- }
-
- @Override // PlatformWindow
public void dispose() {
if (owner != null) {
CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr());
@@ -417,12 +410,6 @@
}
@Override // PlatformWindow
- public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
- // TODO: not implemented
- (new RuntimeException("unimplemented")).printStackTrace();
- }
-
- @Override // PlatformWindow
public FontMetrics getFontMetrics(Font f) {
// TODO: not implemented
(new RuntimeException("unimplemented")).printStackTrace();
@@ -668,15 +655,8 @@
}
@Override
- public void setResizable(boolean resizable) {
+ public void setResizable(final boolean resizable) {
setStyleBits(RESIZABLE, resizable);
-
- // Re-apply the size constraints and the size to ensure the space
- // occupied by the grow box is counted properly
- peer.updateMinimumSize();
-
- Rectangle bounds = peer.getBounds();
- setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
@Override
@@ -889,7 +869,8 @@
responder.handleWindowFocusEvent(gained, oppositePeer);
}
- private void deliverMoveResizeEvent(int x, int y, int width, int height) {
+ private void deliverMoveResizeEvent(int x, int y, int width, int height,
+ boolean byUser) {
// when the content view enters the full-screen mode, the native
// move/resize notifications contain a bounds smaller than
// the whole screen and therefore we ignore the native notifications
@@ -901,7 +882,7 @@
final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height);
peer.notifyReshape(x, y, width, height);
- if (!oldB.getSize().equals(nativeBounds.getSize()) ) {
+ if (byUser && !oldB.getSize().equals(nativeBounds.getSize())) {
flushBuffers();
}
//TODO validateSurface already called from notifyReshape
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Mon Dec 10 20:58:36 2012 -0800
@@ -160,6 +160,10 @@
BOOL resizable = IS(bits, RESIZABLE);
[self updateMinMaxSize:resizable];
[self.nsWindow setShowsResizeIndicator:resizable];
+ // Zoom button should be disabled, if the window is not resizable,
+ // otherwise button should be restored to initial state.
+ BOOL zoom = resizable && IS(bits, ZOOMABLE);
+ [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:zoom];
}
if (IS(mask, HAS_SHADOW)) {
@@ -445,12 +449,13 @@
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
- static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V");
+ static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
(jint)frame.origin.x,
(jint)frame.origin.y,
(jint)frame.size.width,
- (jint)frame.size.height);
+ (jint)frame.size.height,
+ (jboolean)[self.nsWindow inLiveResize]);
(*env)->DeleteLocalRef(env, platformWindow);
}
@@ -784,7 +789,7 @@
// calls methods on NSWindow to change other properties, based on the mask
if (mask & MASK(_METHOD_PROP_BITMASK)) {
- [window setPropertiesForStyleBits:bits mask:mask];
+ [window setPropertiesForStyleBits:newBits mask:mask];
}
window.styleBits = newBits;
--- a/jdk/src/share/back/debugInit.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/back/debugInit.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
#include "debugLoop.h"
#include "bag.h"
#include "invoker.h"
+#include "sys.h"
/* How the options get to OnLoad: */
#define XDEBUG "-Xdebug"
@@ -201,6 +202,8 @@
jint jvmtiCompileTimeMajorVersion;
jint jvmtiCompileTimeMinorVersion;
jint jvmtiCompileTimeMicroVersion;
+ char *boot_path = NULL;
+ char npt_lib[MAXPATHLEN];
/* See if it's already loaded */
if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) {
@@ -227,18 +230,6 @@
vmInitialized = JNI_FALSE;
gdata->vmDead = JNI_FALSE;
- /* Npt and Utf function init */
- NPT_INITIALIZE(&(gdata->npt), NPT_VERSION, NULL);
- if (gdata->npt == NULL) {
- ERROR_MESSAGE(("JDWP: unable to initialize NPT library"));
- return JNI_ERR;
- }
- gdata->npt->utf = (gdata->npt->utfInitialize)(NULL);
- if (gdata->npt->utf == NULL) {
- ERROR_MESSAGE(("JDWP: UTF function initialization failed"));
- return JNI_ERR;
- }
-
/* Get the JVMTI Env, IMPORTANT: Do this first! For jvmtiAllocate(). */
error = JVM_FUNC_PTR(vm,GetEnv)
(vm, (void **)&(gdata->jvmti), JVMTI_VERSION_1);
@@ -277,6 +268,24 @@
forceExit(1); /* Kill entire process, no core dump wanted */
}
+ JVMTI_FUNC_PTR(gdata->jvmti, GetSystemProperty)
+ (gdata->jvmti, (const char *)"sun.boot.library.path",
+ &boot_path);
+
+ dbgsysBuildLibName(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME);
+ /* Npt and Utf function init */
+ NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL);
+ jvmtiDeallocate(boot_path);
+ if (gdata->npt == NULL) {
+ ERROR_MESSAGE(("JDWP: unable to initialize NPT library"));
+ return JNI_ERR;
+ }
+ gdata->npt->utf = (gdata->npt->utfInitialize)(NULL);
+ if (gdata->npt->utf == NULL) {
+ ERROR_MESSAGE(("JDWP: UTF function initialization failed"));
+ return JNI_ERR;
+ }
+
/* Parse input options */
if (!parseOptions(options)) {
/* No message necessary, should have been printed out already */
--- a/jdk/src/share/back/error_messages.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/back/error_messages.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -70,8 +70,13 @@
len = (int)strlen((char*)utf8buf);
/* Convert to platform encoding (ignore errors, dangerous area) */
- (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf,
- utf8buf, len, pbuf, MAX_MESSAGE_LEN);
+ if (gdata->npt != NULL) {
+ (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf,
+ utf8buf, len, pbuf, MAX_MESSAGE_LEN);
+ } else {
+ /* May be called before NPT is initialized so don't fault */
+ strncpy(pbuf, (char*)utf8buf, len);
+ }
(void)fprintf(fp, "%s%s%s", prefix, pbuf, suffix);
}
--- a/jdk/src/share/back/transport.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/back/transport.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -144,7 +144,9 @@
/* First, look in sun.boot.library.path. This should find the standard
* dt_socket and dt_shmem transport libraries, or any library
* that was delivered with the J2SE.
- * Note: Java property sun.boot.library.path contains a single directory.
+ * Note: Since 6819213 fixed, Java property sun.boot.library.path can
+ * contain multiple paths. Dll_dir is the first entry and
+ * -Dsun.boot.library.path entries are appended.
*/
libdir = gdata->property_sun_boot_library_path;
if (libdir == NULL) {
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java Mon Dec 10 20:58:36 2012 -0800
@@ -30,14 +30,10 @@
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.WritableRaster;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
import java.io.EOFException;
-import java.io.InputStream;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.imageio.IIOException;
@@ -48,6 +44,11 @@
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.common.ReaderUtil;
+import java.awt.image.ColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.SampleModel;
public class GIFImageReader extends ImageReader {
@@ -194,6 +195,36 @@
return imageMetadata.imageHeight;
}
+ // We don't check all parameters as ImageTypeSpecifier.createIndexed do
+ // since this method is private and we pass consistent data here
+ private ImageTypeSpecifier createIndexed(byte[] r, byte[] g, byte[] b,
+ int bits) {
+ ColorModel colorModel;
+ if (imageMetadata.transparentColorFlag) {
+ // Some files erroneously have a transparent color index
+ // of 255 even though there are fewer than 256 colors.
+ int idx = Math.min(imageMetadata.transparentColorIndex,
+ r.length - 1);
+ colorModel = new IndexColorModel(bits, r.length, r, g, b, idx);
+ } else {
+ colorModel = new IndexColorModel(bits, r.length, r, g, b);
+ }
+
+ SampleModel sampleModel;
+ if (bits == 8) {
+ int[] bandOffsets = {0};
+ sampleModel =
+ new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
+ 1, 1, 1, 1,
+ bandOffsets);
+ } else {
+ sampleModel =
+ new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ 1, 1, bits);
+ }
+ return new ImageTypeSpecifier(colorModel, sampleModel);
+ }
+
public Iterator getImageTypes(int imageIndex) throws IIOException {
checkIndex(imageIndex);
@@ -239,22 +270,7 @@
b[i] = colorTable[rgbIndex++];
}
- byte[] a = null;
- if (imageMetadata.transparentColorFlag) {
- a = new byte[lutLength];
- Arrays.fill(a, (byte)255);
-
- // Some files erroneously have a transparent color index
- // of 255 even though there are fewer than 256 colors.
- int idx = Math.min(imageMetadata.transparentColorIndex,
- lutLength - 1);
- a[idx] = (byte)0;
- }
-
- int[] bitsPerSample = new int[1];
- bitsPerSample[0] = bits;
- l.add(ImageTypeSpecifier.createIndexed(r, g, b, a, bits,
- DataBuffer.TYPE_BYTE));
+ l.add(createIndexed(r, g, b, bits));
return l.iterator();
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/EnumRowStatus.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/EnumRowStatus.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,10 +28,6 @@
import java.io.Serializable;
import java.util.Hashtable;
-import com.sun.jmx.snmp.SnmpValue;
-import com.sun.jmx.snmp.SnmpInt;
-
-import com.sun.jmx.snmp.Enumerated;
/**
* This class is an internal class which is used to represent RowStatus
@@ -263,30 +259,30 @@
// Documented in Enumerated
//
- protected Hashtable getIntTable() {
+ @Override
+ protected Hashtable<Integer, String> getIntTable() {
return EnumRowStatus.getRSIntTable();
}
// Documented in Enumerated
//
- protected Hashtable getStringTable() {
+ @Override
+ protected Hashtable<String, Integer> getStringTable() {
return EnumRowStatus.getRSStringTable();
}
- static final Hashtable getRSIntTable() {
+ static Hashtable<Integer, String> getRSIntTable() {
return intTable ;
}
- static final Hashtable getRSStringTable() {
+ static Hashtable<String, Integer> getRSStringTable() {
return stringTable ;
}
// Initialize the mapping tables.
//
- final static Hashtable<Integer, String> intTable =
- new Hashtable<Integer, String>();
- final static Hashtable<String, Integer> stringTable =
- new Hashtable<String, Integer>();
+ final static Hashtable<Integer, String> intTable = new Hashtable<>();
+ final static Hashtable<String, Integer> stringTable = new Hashtable<>();
static {
intTable.put(new Integer(0), "unspecified");
intTable.put(new Integer(3), "notReady");
--- a/jdk/src/share/classes/com/sun/jmx/snmp/Enumerated.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/Enumerated.java Mon Dec 10 20:58:36 2012 -0800
@@ -54,9 +54,9 @@
* @exception IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.
*/
public Enumerated() throws IllegalArgumentException {
- Enumeration e =getIntTable().keys() ;
+ Enumeration<Integer> e =getIntTable().keys();
if (e.hasMoreElements()) {
- value = ((Integer)e.nextElement()).intValue() ;
+ value = e.nextElement().intValue() ;
}
else {
throw new IllegalArgumentException() ;
@@ -100,7 +100,7 @@
* to the method is illegal or inappropriate.
*/
public Enumerated(String valueString) throws IllegalArgumentException {
- Integer index = (Integer)getStringTable().get(valueString) ;
+ Integer index = getStringTable().get(valueString) ;
if (index == null) {
throw new IllegalArgumentException() ;
}
@@ -127,7 +127,7 @@
* @return An enumeration of Integer instances
*/
- public Enumeration valueIndexes() {
+ public Enumeration<Integer> valueIndexes() {
return getIntTable().keys() ;
}
@@ -138,7 +138,7 @@
* @return An enumeration of String instances
*/
- public Enumeration valueStrings() {
+ public Enumeration<String> valueStrings() {
return getStringTable().keys() ;
}
@@ -153,6 +153,7 @@
*
* @return True if this and obj are the same; false otherwise
*/
+ @Override
public boolean equals(Object obj) {
return ((obj != null) &&
@@ -166,6 +167,7 @@
*
* @return A hash code value for this object.
*/
+ @Override
public int hashCode() {
String hashString = getClass().getName() + String.valueOf(value) ;
return hashString.hashCode() ;
@@ -177,9 +179,9 @@
*
* @return The string for for this object.
*/
-
+ @Override
public String toString() {
- return (String)getIntTable().get(new Integer(value)) ;
+ return getIntTable().get(new Integer(value)) ;
}
@@ -193,7 +195,7 @@
* @return An hashtable for read-only purpose
*/
- protected abstract Hashtable getIntTable() ;
+ protected abstract Hashtable<Integer,String> getIntTable() ;
@@ -207,12 +209,12 @@
* @return An hashtable for read-only purpose
*/
- protected abstract Hashtable getStringTable() ;
+ protected abstract Hashtable<String,Integer> getStringTable() ;
/**
* This variable keeps the integer form of the enumerated.
- * The string form is retreived using getIntTable().
+ * The string form is retrieved using getIntTable().
*/
protected int value ;
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/AclImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/AclImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -66,7 +66,7 @@
*/
public AclImpl (PrincipalImpl owner, String name) {
super(owner);
- entryList = new Vector<AclEntry>();
+ entryList = new Vector<>();
aclName = name;
}
@@ -81,6 +81,7 @@
* of this ACL.
* @see java.security.Principal
*/
+ @Override
public void setName(Principal caller, String name)
throws NotOwnerException {
if (!isOwner(caller))
@@ -93,6 +94,7 @@
*
* @return the name of this ACL.
*/
+ @Override
public String getName(){
return aclName;
}
@@ -113,6 +115,7 @@
* this ACL.
* @see java.security.Principal
*/
+ @Override
public boolean addEntry(Principal caller, AclEntry entry)
throws NotOwnerException {
if (!isOwner(caller))
@@ -144,6 +147,7 @@
* @see java.security.Principal
* @see java.security.acl.AclEntry
*/
+ @Override
public boolean removeEntry(Principal caller, AclEntry entry)
throws NotOwnerException {
if (!isOwner(caller))
@@ -185,8 +189,9 @@
* is allowed.
* @see java.security.Principal
*/
+ @Override
public Enumeration<Permission> getPermissions(Principal user){
- Vector<Permission> empty = new Vector<Permission>();
+ Vector<Permission> empty = new Vector<>();
for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user))
@@ -201,6 +206,7 @@
*
* @return an enumeration of the entries in this ACL.
*/
+ @Override
public Enumeration<AclEntry> entries(){
return entryList.elements();
}
@@ -221,10 +227,11 @@
* @see java.security.Principal
* @see java.security.Permission
*/
+ @Override
public boolean checkPermission(Principal user,
java.security.acl.Permission perm) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntry ent = (AclEntry) e.nextElement();
+ for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
+ AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user))
if (ent.checkPermission(perm)) return true;
}
@@ -250,7 +257,7 @@
*/
public boolean checkPermission(Principal user, String community,
java.security.acl.Permission perm) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
+ for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntryImpl ent = (AclEntryImpl) e.nextElement();
if (ent.getPrincipal().equals(user))
if (ent.checkPermission(perm) && ent.checkCommunity(community)) return true;
@@ -269,7 +276,7 @@
* @see java.security.Permission
*/
public boolean checkCommunity(String community) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
+ for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntryImpl ent = (AclEntryImpl) e.nextElement();
if (ent.checkCommunity(community)) return true;
}
@@ -281,6 +288,7 @@
*
* @return a string representation of the ACL contents.
*/
+ @Override
public String toString(){
return ("AclImpl: "+ getName());
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,9 @@
package com.sun.jmx.snmp.IPAcl;
+import java.net.InetAddress;
import java.util.Hashtable;
+import java.util.Vector;
class JDMAclBlock extends SimpleNode {
JDMAclBlock(int id) {
@@ -51,11 +53,13 @@
* Do no need to go through this part of the tree for
* building TrapEntry.
*/
- public void buildTrapEntries(Hashtable dest) {}
+ @Override
+ public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {}
/**
* Do no need to go through this part of the tree for
* building InformEntry.
*/
- public void buildInformEntries(Hashtable dest) {}
+ @Override
+ public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,7 +27,9 @@
package com.sun.jmx.snmp.IPAcl;
+import java.net.InetAddress;
import java.util.Hashtable;
+import java.util.Vector;
class JDMInformBlock extends SimpleNode {
JDMInformBlock(int id) {
@@ -50,11 +52,13 @@
* Do no need to go through this part of the tree for
* building AclEntry.
*/
+ @Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/**
* Do no need to go through this part of the tree for
* building TrapEntry.
*/
- public void buildTrapEntries(Hashtable dest) {}
+ @Override
+ public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,9 @@
package com.sun.jmx.snmp.IPAcl;
+import java.net.InetAddress;
import java.util.Hashtable;
+import java.util.Vector;
class JDMTrapBlock extends SimpleNode {
JDMTrapBlock(int id) {
@@ -51,11 +53,13 @@
* Do no need to go through this part of the tree for
* building AclEntry.
*/
+ @Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/**
* Do no need to go through this part of the tree for
* building InformEntry.
*/
- public void buildInformEntries(Hashtable dest) {}
+ @Override
+ public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JJTParserState.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/JJTParserState.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,18 +27,17 @@
package com.sun.jmx.snmp.IPAcl;
-@SuppressWarnings("unchecked") // generated code, not worth fixing
class JJTParserState {
- private java.util.Stack nodes;
- private java.util.Stack marks;
+ private java.util.Stack<Node> nodes;
+ private java.util.Stack<Integer> marks;
private int sp; // number of nodes on stack
private int mk; // current mark
private boolean node_created;
JJTParserState() {
- nodes = new java.util.Stack();
- marks = new java.util.Stack();
+ nodes = new java.util.Stack<>();
+ marks = new java.util.Stack<>();
sp = 0;
mk = 0;
}
@@ -62,7 +61,7 @@
/* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */
Node rootNode() {
- return (Node)nodes.elementAt(0);
+ return nodes.elementAt(0);
}
/* Pushes a node on to the stack. */
@@ -75,14 +74,14 @@
stack. */
Node popNode() {
if (--sp < mk) {
- mk = ((Integer)marks.pop()).intValue();
+ mk = marks.pop().intValue();
}
- return (Node)nodes.pop();
+ return nodes.pop();
}
/* Returns the node currently on the top of the stack. */
Node peekNode() {
- return (Node)nodes.peek();
+ return nodes.peek();
}
/* Returns the number of children on the stack in the current node
@@ -96,7 +95,7 @@
while (sp > mk) {
popNode();
}
- mk = ((Integer)marks.pop()).intValue();
+ mk = marks.pop().intValue();
}
@@ -112,7 +111,7 @@
made the children of the definite node. Then the definite node
is pushed on to the stack. */
void closeNodeScope(Node n, int num) {
- mk = ((Integer)marks.pop()).intValue();
+ mk = marks.pop().intValue();
while (num-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
@@ -132,7 +131,7 @@
void closeNodeScope(Node n, boolean condition) {
if (condition) {
int a = nodeArity();
- mk = ((Integer)marks.pop()).intValue();
+ mk = marks.pop().intValue();
while (a-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
@@ -142,7 +141,7 @@
pushNode(n);
node_created = true;
} else {
- mk = ((Integer)marks.pop()).intValue();
+ mk = marks.pop().intValue();
node_created = false;
}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java Mon Dec 10 20:58:36 2012 -0800
@@ -1168,7 +1168,7 @@
return (jj_ntk = jj_nt.kind);
}
- private java.util.Vector jj_expentries = new java.util.Vector();
+ private java.util.Vector<int[]> jj_expentries = new java.util.Vector<>();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
@@ -1184,8 +1184,8 @@
jj_expentry[i] = jj_lasttokens[i];
}
boolean exists = false;
- for (java.util.Enumeration enumv = jj_expentries.elements(); enumv.hasMoreElements();) {
- int[] oldentry = (int[])(enumv.nextElement());
+ for (java.util.Enumeration<int[]> enumv = jj_expentries.elements(); enumv.hasMoreElements();) {
+ int[] oldentry = enumv.nextElement();
if (oldentry.length == jj_expentry.length) {
exists = true;
for (int i = 0; i < jj_expentry.length; i++) {
@@ -1236,7 +1236,7 @@
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
- exptokseq[i] = (int[])jj_expentries.elementAt(i);
+ exptokseq[i] = jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java Mon Dec 10 20:58:36 2012 -0800
@@ -126,7 +126,7 @@
*
* @return An enumeration of the entries in this ACL.
*/
- public Enumeration entries() {
+ public Enumeration<AclEntry> entries() {
return acl.entries();
}
@@ -137,11 +137,11 @@
public Enumeration<String> communities() {
HashSet<String> set = new HashSet<String>();
Vector<String> res = new Vector<String>();
- for (Enumeration e = acl.entries() ; e.hasMoreElements() ;) {
+ for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
AclEntryImpl entry = (AclEntryImpl) e.nextElement();
- for (Enumeration cs = entry.communities();
+ for (Enumeration<String> cs = entry.communities();
cs.hasMoreElements() ;) {
- set.add((String) cs.nextElement());
+ set.add(cs.nextElement());
}
}
String[] objs = set.toArray(new String[0]);
@@ -316,7 +316,7 @@
*
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
*/
- public Enumeration getTrapDestinations() {
+ public Enumeration<InetAddress> getTrapDestinations() {
return trapDestList.keys();
}
@@ -327,16 +327,16 @@
*
* @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>).
*/
- public Enumeration getTrapCommunities(InetAddress i) {
- Vector list = null;
- if ((list = (Vector)trapDestList.get(i)) != null ) {
+ public Enumeration<String> getTrapCommunities(InetAddress i) {
+ Vector<String> list = null;
+ if ((list = trapDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is in list");
}
return list.elements();
} else {
- list = new Vector();
+ list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is not in list");
@@ -350,7 +350,7 @@
*
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
*/
- public Enumeration getInformDestinations() {
+ public Enumeration<InetAddress> getInformDestinations() {
return informDestList.keys();
}
@@ -361,16 +361,16 @@
*
* @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>).
*/
- public Enumeration getInformCommunities(InetAddress i) {
- Vector list = null;
- if ((list = (Vector)informDestList.get(i)) != null ) {
+ public Enumeration<String> getInformCommunities(InetAddress i) {
+ Vector<String> list = null;
+ if ((list = informDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is in list");
}
return list.elements();
} else {
- list = new Vector();
+ list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is not in list");
@@ -426,15 +426,15 @@
throw new IllegalArgumentException(err.getMessage());
}
- for(Enumeration e = acl.entries(); e.hasMoreElements();) {
+ for(Enumeration<AclEntry> e = acl.entries(); e.hasMoreElements();) {
AclEntryImpl aa = (AclEntryImpl) e.nextElement();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"readAuthorizedListFile",
"===> " + aa.getPrincipal().toString());
}
- for (Enumeration eee = aa.permissions();eee.hasMoreElements();) {
- java.security.acl.Permission perm = (java.security.acl.Permission)eee.nextElement();
+ for (Enumeration<java.security.acl.Permission> eee = aa.permissions();eee.hasMoreElements();) {
+ java.security.acl.Permission perm = eee.nextElement();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"readAuthorizedListFile", "perm = " + perm);
--- a/jdk/src/share/classes/com/sun/jmx/snmp/InetAddressAcl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/InetAddressAcl.java Mon Dec 10 20:58:36 2012 -0800
@@ -99,7 +99,7 @@
*
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
*/
- public Enumeration getTrapDestinations();
+ public Enumeration<InetAddress> getTrapDestinations();
/**
* Returns an enumeration of trap communities for a given host.
@@ -108,14 +108,14 @@
*
* @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>).
*/
- public Enumeration getTrapCommunities(InetAddress address);
+ public Enumeration<String> getTrapCommunities(InetAddress address);
/**
* Returns an enumeration of inform destinations.
*
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
*/
- public Enumeration getInformDestinations();
+ public Enumeration<InetAddress> getInformDestinations();
/**
* Returns an enumeration of inform communities for a given host.
@@ -124,5 +124,5 @@
*
* @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>).
*/
- public Enumeration getInformCommunities(InetAddress address);
+ public Enumeration<String> getInformCommunities(InetAddress address);
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpErrorHandlerAgent.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpErrorHandlerAgent.java Mon Dec 10 20:58:36 2012 -0800
@@ -59,6 +59,7 @@
* @exception IllegalAccessException The MIB cannot be initialized.
*/
+ @Override
public void init() throws IllegalAccessException {
}
@@ -74,6 +75,7 @@
* @exception java.lang.Exception
*/
+ @Override
public ObjectName preRegister(MBeanServer server, ObjectName name)
throws Exception {
return name;
@@ -87,6 +89,7 @@
* @return The returned oid is null.
*/
+ @Override
public long[] getRootOid() {
return null;
}
@@ -99,6 +102,7 @@
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
@@ -108,9 +112,9 @@
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName);
- Enumeration l = inRequest.getElements();
+ Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
- SnmpVarBind varbind = (SnmpVarBind) l.nextElement();
+ SnmpVarBind varbind = l.nextElement();
varbind.setNoSuchObject();
}
}
@@ -128,6 +132,7 @@
* cannot be performed.
*/
+ @Override
public void check(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
@@ -145,6 +150,7 @@
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public void set(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
@@ -162,6 +168,7 @@
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
@@ -171,9 +178,9 @@
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName);
- Enumeration l = inRequest.getElements();
+ Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
- SnmpVarBind varbind = (SnmpVarBind) l.nextElement();
+ SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView();
}
}
@@ -186,6 +193,7 @@
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
throws SnmpStatusException {
@@ -196,9 +204,9 @@
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0);
- Enumeration l = inRequest.getElements();
+ Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
- SnmpVarBind varbind = (SnmpVarBind) l.nextElement();
+ SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView();
}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpGenericObjectServer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpGenericObjectServer.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,6 @@
// java imports
//
-import java.util.Vector;
import java.util.Enumeration;
import java.util.Iterator;
@@ -149,8 +148,8 @@
final long[] idList = new long[size];
int i = 0;
- for (Enumeration e=req.getElements(); e.hasMoreElements();) {
- final SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
+ final SnmpVarBind var= e.nextElement();
try {
final long id = var.oid.getOidArc(depth);
nameList[i] = meta.getAttributeName(id);
@@ -190,7 +189,7 @@
}
- final Iterator it = result.iterator();
+ final Iterator<?> it = result.iterator();
for (int j=0; j < i; j++) {
if (!it.hasNext()) {
@@ -312,8 +311,8 @@
final long[] idList = new long[size];
int i = 0;
- for (Enumeration e=req.getElements(); e.hasMoreElements();) {
- final SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
+ final SnmpVarBind var= e.nextElement();
try {
final long id = var.oid.getOidArc(depth);
final String attname = meta.getAttributeName(id);
@@ -330,7 +329,7 @@
}
}
- AttributeList result = null;
+ AttributeList result;
int errorCode = SnmpStatusException.noAccess;
try {
@@ -345,7 +344,7 @@
result = new AttributeList();
}
- final Iterator it = result.iterator();
+ final Iterator<?> it = result.iterator();
for (int j=0; j < i; j++) {
if (!it.hasNext()) {
@@ -469,8 +468,8 @@
final Object data = req.getUserData();
- for (Enumeration e=req.getElements(); e.hasMoreElements();) {
- final SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
+ final SnmpVarBind var= e.nextElement();
try {
final long id = var.oid.getOidArc(depth);
// call meta.check() here, and meta.check will call check()
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpIndex.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpIndex.java Mon Dec 10 20:58:36 2012 -0800
@@ -164,11 +164,12 @@
*
* @return A string representation of the index.
*/
+ @Override
public String toString() {
- StringBuffer msg= new StringBuffer();
- for(Enumeration e= oids.elements(); e.hasMoreElements(); ) {
- SnmpOid val= (SnmpOid) e.nextElement();
- msg.append( "//" + val.toString());
+ final StringBuilder msg= new StringBuilder();
+ for(Enumeration<SnmpOid> e= oids.elements(); e.hasMoreElements(); ) {
+ SnmpOid val= e.nextElement();
+ msg.append("//").append( val.toString());
}
return msg.toString();
}
@@ -180,7 +181,7 @@
* The list of OIDs.
* @serial
*/
- private Vector<SnmpOid> oids = new Vector<SnmpOid>();
+ private Vector<SnmpOid> oids = new Vector<>();
/**
* The number of elements in the index.
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java Mon Dec 10 20:58:36 2012 -0800
@@ -42,10 +42,6 @@
import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpDefinitions;
import com.sun.jmx.snmp.SnmpStatusException;
-import com.sun.jmx.snmp.SnmpEngine;
-import com.sun.jmx.snmp.SnmpUnknownModelException;
-import com.sun.jmx.snmp.internal.SnmpAccessControlModel;
-import com.sun.jmx.snmp.internal.SnmpEngineImpl;
/**
* Abstract class for representing an SNMP MIB.
@@ -241,6 +237,7 @@
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
+ @Override
public void get(SnmpMibRequest req) throws SnmpStatusException {
// Builds the request tree: creation is not allowed, operation
@@ -259,8 +256,8 @@
// For each sub-request stored in the request-tree, invoke the
// get() method.
- for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) {
- h = (SnmpRequestTree.Handler) eh.nextElement();
+ for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
+ h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a
// Table Meta.
@@ -270,11 +267,11 @@
// Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h);
- for (Enumeration rqs=handlers.getSubRequests(h);
+ for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) {
// Invoke the get() operation.
- meta.get((SnmpMibSubRequest)rqs.nextElement(),depth);
+ meta.get(rqs.nextElement(),depth);
}
}
}
@@ -286,6 +283,7 @@
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
+ @Override
public void set(SnmpMibRequest req) throws SnmpStatusException {
SnmpRequestTree handlers = null;
@@ -307,8 +305,8 @@
handlers.switchCreationFlag(false);
handlers.setPduType(reqType);
- SnmpRequestTree.Handler h = null;
- SnmpMibNode meta = null;
+ SnmpRequestTree.Handler h;
+ SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
@@ -317,8 +315,8 @@
// For each sub-request stored in the request-tree, invoke the
// get() method.
- for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) {
- h = (SnmpRequestTree.Handler) eh.nextElement();
+ for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
+ h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a
// Table Meta.
@@ -328,11 +326,11 @@
// Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h);
- for (Enumeration rqs=handlers.getSubRequests(h);
+ for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) {
// Invoke the set() operation
- meta.set((SnmpMibSubRequest)rqs.nextElement(),depth);
+ meta.set(rqs.nextElement(),depth);
}
}
}
@@ -346,6 +344,7 @@
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
+ @Override
public void check(SnmpMibRequest req) throws SnmpStatusException {
final int reqType = SnmpDefinitions.pduWalkRequest;
@@ -353,8 +352,8 @@
// is atomic.
SnmpRequestTree handlers = getHandlers(req,true,true,reqType);
- SnmpRequestTree.Handler h = null;
- SnmpMibNode meta = null;
+ SnmpRequestTree.Handler h;
+ SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
@@ -363,8 +362,8 @@
// For each sub-request stored in the request-tree, invoke the
// check() method.
- for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) {
- h = (SnmpRequestTree.Handler) eh.nextElement();
+ for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
+ h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a
// Table Meta.
@@ -374,11 +373,11 @@
// Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h);
- for (Enumeration rqs=handlers.getSubRequests(h);
+ for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) {
// Invoke the check() operation
- meta.check((SnmpMibSubRequest)rqs.nextElement(),depth);
+ meta.check(rqs.nextElement(),depth);
}
}
@@ -398,13 +397,14 @@
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
+ @Override
public void getNext(SnmpMibRequest req) throws SnmpStatusException {
// Build the request tree for the operation
// The subrequest stored in the request tree are valid GET requests
SnmpRequestTree handlers = getGetNextHandlers(req);
- SnmpRequestTree.Handler h = null;
- SnmpMibNode meta = null;
+ SnmpRequestTree.Handler h;
+ SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
@@ -412,8 +412,8 @@
}
// Now invoke get() for each subrequest of the request tree.
- for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) {
- h = (SnmpRequestTree.Handler) eh.nextElement();
+ for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
+ h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a
// Table Meta.
@@ -423,11 +423,11 @@
// Gets the depth of the Meta node in the OID tree
int depth = handlers.getOidDepth(h);
- for (Enumeration rqs=handlers.getSubRequests(h);
+ for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) {
// Invoke the get() operation
- meta.get((SnmpMibSubRequest)rqs.nextElement(),depth);
+ meta.get(rqs.nextElement(),depth);
}
}
}
@@ -442,6 +442,7 @@
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
+ @Override
public void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)
throws SnmpStatusException {
@@ -456,10 +457,11 @@
*
* @return The root object identifier.
*/
+ @Override
public long[] getRootOid() {
if( rootOid == null) {
- Vector<Integer> list= new Vector<Integer>(10);
+ Vector<Integer> list= new Vector<>(10);
// Ask the tree to do the job !
//
@@ -507,13 +509,13 @@
new SnmpRequestTree(req,createflag,type);
int index=0;
- SnmpVarBind var = null;
+ SnmpVarBind var;
final int ver= req.getVersion();
// For each varbind in the list finds its handling node.
- for (Enumeration e= req.getElements(); e.hasMoreElements(); index++) {
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements(); index++) {
- var= (SnmpVarBind) e.nextElement();
+ var= e.nextElement();
try {
// Find the handling node for this varbind.
@@ -657,10 +659,10 @@
// request into a valid GET request, replacing the OIDs in the
// original GET-NEXT request with the OID of the first leaf that
// follows.
- for (Enumeration e= req.getElements(); e.hasMoreElements(); index++) {
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements(); index++) {
- var = (SnmpVarBind) e.nextElement();
- SnmpOid result = null;
+ var = e.nextElement();
+ SnmpOid result;
try {
// Find the node handling the OID that follows the varbind
// OID. `result' contains this next leaf OID.
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibAgent.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibAgent.java Mon Dec 10 20:58:36 2012 -0800
@@ -33,14 +33,12 @@
import java.io.Serializable;
import java.util.Vector;
import java.util.Enumeration;
-import java.util.Set;
// jmx imports
//
import javax.management.MBeanServer;
import javax.management.MBeanRegistration;
import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
import javax.management.InstanceNotFoundException;
import javax.management.ServiceNotFoundException;
import javax.management.ReflectionException;
@@ -94,6 +92,7 @@
*
* @exception java.lang.Exception
*/
+ @Override
public abstract ObjectName preRegister(MBeanServer server,
ObjectName name)
throws java.lang.Exception;
@@ -101,18 +100,21 @@
/**
* Not used in this context.
*/
+ @Override
public void postRegister (Boolean registrationDone) {
}
/**
* Not used in this context.
*/
+ @Override
public void preDeregister() throws java.lang.Exception {
}
/**
* Not used in this context.
*/
+ @Override
public void postDeregister() {
}
@@ -127,6 +129,7 @@
*
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public abstract void get(SnmpMibRequest req)
throws SnmpStatusException;
@@ -141,6 +144,7 @@
*
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public abstract void getNext(SnmpMibRequest req)
throws SnmpStatusException;
@@ -164,6 +168,7 @@
*
* @exception SnmpStatusException An error occured during the operation.
*/
+ @Override
public abstract void getBulk(SnmpMibRequest req, int nonRepeat,
int maxRepeat)
throws SnmpStatusException;
@@ -185,6 +190,7 @@
* the exception is thrown in the {@link #check(SnmpMibRequest)}
* method instead.
*/
+ @Override
public abstract void set(SnmpMibRequest req)
throws SnmpStatusException;
@@ -203,6 +209,7 @@
* @exception SnmpStatusException The <CODE>set</CODE> operation
* cannot be performed.
*/
+ @Override
public abstract void check(SnmpMibRequest req)
throws SnmpStatusException;
@@ -226,6 +233,7 @@
* @return The MBean server or null if the MIB is not registered in any
* MBean server.
*/
+ @Override
public MBeanServer getMBeanServer() {
return server;
}
@@ -236,6 +244,7 @@
*
* @return The SNMP MIB handler.
*/
+ @Override
public SnmpMibHandler getSnmpAdaptor() {
return adaptor;
}
@@ -246,6 +255,7 @@
*
* @param stack The SNMP MIB handler.
*/
+ @Override
public void setSnmpAdaptor(SnmpMibHandler stack) {
if (adaptor != null) {
adaptor.removeMib(this);
@@ -266,6 +276,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptor(SnmpMibHandler stack, SnmpOid[] oids) {
if (adaptor != null) {
adaptor.removeMib(this);
@@ -288,6 +299,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptor(SnmpMibHandler stack, String contextName) {
if (adaptor != null) {
adaptor.removeMib(this, contextName);
@@ -309,6 +321,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptor(SnmpMibHandler stack,
String contextName,
SnmpOid[] oids) {
@@ -327,6 +340,7 @@
*
* @return The name of the SNMP protocol adaptor.
*/
+ @Override
public ObjectName getSnmpAdaptorName() {
return adaptorName;
}
@@ -344,6 +358,7 @@
* @exception ServiceNotFoundException This SNMP MIB is not registered
* in the MBean server or the requested service is not supported.
*/
+ @Override
public void setSnmpAdaptorName(ObjectName name)
throws InstanceNotFoundException, ServiceNotFoundException {
@@ -389,6 +404,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptorName(ObjectName name, SnmpOid[] oids)
throws InstanceNotFoundException, ServiceNotFoundException {
@@ -434,6 +450,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptorName(ObjectName name, String contextName)
throws InstanceNotFoundException, ServiceNotFoundException {
@@ -481,6 +498,7 @@
*
* @since 1.5
*/
+ @Override
public void setSnmpAdaptorName(ObjectName name,
String contextName, SnmpOid[] oids)
throws InstanceNotFoundException, ServiceNotFoundException {
@@ -522,6 +540,7 @@
* @return <CODE>true</CODE> if the MIB module is bound,
* <CODE>false</CODE> otherwise.
*/
+ @Override
public boolean getBindingState() {
if (adaptor == null)
return false;
@@ -534,6 +553,7 @@
*
* @return The MIB name.
*/
+ @Override
public String getMibName() {
return mibName;
}
@@ -681,7 +701,7 @@
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {
int max= original.size();
- Vector<SnmpVarBind> result= new Vector<SnmpVarBind>(max - limit);
+ Vector<SnmpVarBind> result= new Vector<>(max - limit);
int i= limit;
// Ok the loop looks a bit strange. But in order to improve the
@@ -697,21 +717,12 @@
return result;
}
- private void concatVector(SnmpMibRequest req, Vector source) {
- for(Enumeration e= source.elements(); e.hasMoreElements(); ) {
- SnmpVarBind var= (SnmpVarBind) e.nextElement();
- // We need to duplicate the SnmpVarBind otherwise it is going
- // to be overloaded by the next get Next ...
- req.addVarBind(new SnmpVarBind(var.oid, var.value));
- }
- }
-
- private void concatVector(Vector<SnmpVarBind> target, Vector<SnmpVarBind> source) {
+ private void concatVector(SnmpMibRequest req, Vector<SnmpVarBind> source) {
for(Enumeration<SnmpVarBind> e= source.elements(); e.hasMoreElements(); ) {
SnmpVarBind var= e.nextElement();
// We need to duplicate the SnmpVarBind otherwise it is going
// to be overloaded by the next get Next ...
- target.addElement(new SnmpVarBind(var.oid, var.value));
+ req.addVarBind(new SnmpVarBind(var.oid, var.value));
}
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,20 +29,13 @@
//
import java.io.Serializable;
import java.util.Hashtable;
-import java.util.Enumeration;
import java.util.Vector;
// jmx imports
//
-import com.sun.jmx.snmp.SnmpOid;
-import com.sun.jmx.snmp.SnmpValue;
import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException;
-// SNMP Runtime imports
-//
-import com.sun.jmx.snmp.agent.SnmpMibOid;
-import com.sun.jmx.snmp.agent.SnmpMibNode;
/**
* Represents a node in an SNMP MIB which corresponds to a group.
@@ -174,6 +167,7 @@
* @exception SnmpStatusException An error occurred while accessing
* the MIB node.
*/
+ @Override
abstract public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException;
@@ -203,6 +197,7 @@
* @exception SnmpStatusException An error occurred while accessing
* the MIB node.
*/
+ @Override
abstract public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException;
@@ -234,6 +229,7 @@
* @exception SnmpStatusException An error occurred while accessing
* the MIB node.
*/
+ @Override
abstract public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException;
@@ -241,8 +237,8 @@
// If we reach this node, we are below the root OID, so we just
// return.
// --------------------------------------------------------------------
- public void getRootOid(Vector result) {
- return;
+ @Override
+ public void getRootOid(Vector<Integer> result) {
}
// -------------------------------------------------------------------
@@ -264,7 +260,7 @@
*/
void registerNestedArc(long arc) {
Long obj = new Long(arc);
- if (subgroups == null) subgroups = new Hashtable<Long, Long>();
+ if (subgroups == null) subgroups = new Hashtable<>();
// registers the arc in the hashtable.
subgroups.put(obj,obj);
}
@@ -312,6 +308,7 @@
* @param node The node being registered.
*
*/
+ @Override
void registerNode(long[] oid, int cursor ,SnmpMibNode node)
throws IllegalAccessException {
super.registerNode(oid,cursor,node);
@@ -325,13 +322,13 @@
// -------------------------------------------------------------------
// see comments in SnmpMibNode
// -------------------------------------------------------------------
+ @Override
void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth,
SnmpRequestTree handlers)
throws SnmpStatusException {
int length = oid.length;
- SnmpMibNode node = null;
if (handlers == null)
throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
@@ -349,7 +346,6 @@
// This arc leads to a subgroup: delegates the search to the
// method defined in SnmpMibOid
super.findHandlingNode(varbind,oid,depth,handlers);
- return;
} else if (isTable(arc)) {
// This arc leads to a table: forward the search to the table.
@@ -384,6 +380,7 @@
// -------------------------------------------------------------------
// See comments in SnmpMibNode.
// -------------------------------------------------------------------
+ @Override
long[] findNextHandlingNode(SnmpVarBind varbind,
long[] oid, int pos, int depth,
SnmpRequestTree handlers, AcmChecker checker)
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibOid.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibOid.java Mon Dec 10 20:58:36 2012 -0800
@@ -37,7 +37,6 @@
// jmx imports
//
import com.sun.jmx.snmp.SnmpOid;
-import com.sun.jmx.snmp.SnmpValue;
import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException;
@@ -79,10 +78,11 @@
* @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException.
*/
+ @Override
public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ SnmpVarBind var= e.nextElement();
SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noSuchObject);
req.registerGetException(var,x);
@@ -102,10 +102,11 @@
* @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException.
*/
+ @Override
public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ SnmpVarBind var= e.nextElement();
SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noAccess);
req.registerSetException(var,x);
@@ -123,12 +124,13 @@
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException The default implementation (if not
- * overriden) is to generate a SnmpStatusException.
+ * overridden) is to generate a SnmpStatusException.
*/
+ @Override
public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ SnmpVarBind var= e.nextElement();
SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noAccess);
req.registerCheckException(var,x);
@@ -143,6 +145,7 @@
//
// ---------------------------------------------------------------------
//
+ @Override
void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth,
SnmpRequestTree handlers)
@@ -191,6 +194,7 @@
//
// ---------------------------------------------------------------------
//
+ @Override
long[] findNextHandlingNode(SnmpVarBind varbind,
long[] oid, int pos, int depth,
SnmpRequestTree handlers,
@@ -267,6 +271,7 @@
/**
* Computes the root OID of the MIB.
*/
+ @Override
public void getRootOid(Vector<Integer> result) {
// If a node has several children, let assume that we are one step to
@@ -359,7 +364,6 @@
// String.valueOf(var) + " position= " + cursor);
children.insertElementAt(child, newPos);
child.registerNode(oid, cursor + 1, node);
- return;
}
else {
// The node is already registered
@@ -404,7 +408,6 @@
}
}
children.setElementAt(node,pos);
- return;
} else {
if (child == null)
throw new IllegalAccessException();
@@ -469,7 +472,7 @@
int max= varList.length -1 ;
int curr= low + (max-low)/2;
- int elmt= 0;
+ int elmt;
while (low <= max) {
elmt= varList[curr];
if (cursor == elmt) {
@@ -494,7 +497,7 @@
if (varList == null)
return -1;
int max= varList.length -1 ;
- int elmt=0;
+ int elmt;
//final int[] v = varList;
//if (index > a[max])
@@ -528,7 +531,7 @@
/**
* Contains the list of sub nodes.
*/
- private NonSyncVector<SnmpMibNode> children = new NonSyncVector<SnmpMibNode>(1);
+ private NonSyncVector<SnmpMibNode> children = new NonSyncVector<>(1);
/**
* The number of sub nodes.
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibRequest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibRequest.java Mon Dec 10 20:58:36 2012 -0800
@@ -50,7 +50,7 @@
* @return The element of the enumeration are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind}
*/
- public Enumeration getElements();
+ public Enumeration<SnmpVarBind> getElements();
/**
* Returns the vector of varbind to be handled by the SNMP mib node.
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibRequestImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibRequestImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -87,6 +87,7 @@
* Returns the local engine. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
* @return the local engine.
*/
+ @Override
public SnmpEngine getEngine() {
return engine;
}
@@ -95,6 +96,7 @@
* Gets the incoming request principal. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
* @return The request principal.
**/
+ @Override
public String getPrincipal() {
return principal;
}
@@ -103,6 +105,7 @@
* Gets the incoming request security level. This level is defined in {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise -1 is returned.
* @return The security level.
*/
+ @Override
public int getSecurityLevel() {
return securityLevel;
}
@@ -110,6 +113,7 @@
* Gets the incoming request security model. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise -1 is returned.
* @return The security model.
*/
+ @Override
public int getSecurityModel() {
return securityModel;
}
@@ -117,6 +121,7 @@
* Gets the incoming request context name. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
* @return The context name.
*/
+ @Override
public byte[] getContextName() {
return contextName;
}
@@ -125,6 +130,7 @@
* Gets the incoming request context name used by Access Control Model in order to allow or deny the access to OIDs. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
* @return The checked context.
*/
+ @Override
public byte[] getAccessContextName() {
return accessContextName;
}
@@ -133,6 +139,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final SnmpPdu getPdu() {
return reqPdu;
}
@@ -141,18 +148,21 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
- public final Enumeration getElements() {return varbinds.elements();}
+ @Override
+ public final Enumeration<SnmpVarBind> getElements() {return varbinds.elements();}
// -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final Vector<SnmpVarBind> getSubList() {return varbinds;}
// -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final int getSize() {
if (varbinds == null) return 0;
return varbinds.size();
@@ -162,24 +172,28 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final int getVersion() {return version;}
// -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final int getRequestPduVersion() {return reqPdu.version;}
// -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final Object getUserData() {return data;}
// -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public final int getVarIndex(SnmpVarBind varbind) {
return varbinds.indexOf(varbind);
}
@@ -188,6 +202,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------------
+ @Override
public void addVarBind(SnmpVarBind varbind) {
varbinds.addElement(varbind);
}
@@ -218,7 +233,7 @@
// Returns the underlying vector of SNMP varbinds (used for algorithm
// optimization).
// -------------------------------------------------------------------
- final Vector getVarbinds() {return varbinds;}
+ final Vector<SnmpVarBind> getVarbinds() {return varbinds;}
// -------------------------------------------------------------------
// Private variables
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibSubRequest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibSubRequest.java Mon Dec 10 20:58:36 2012 -0800
@@ -65,7 +65,8 @@
* @return The elements of the enumeration are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind}
*/
- public Enumeration getElements();
+ @Override
+ public Enumeration<SnmpVarBind> getElements();
/**
* Return the list of varbind to be handled by the SNMP MIB node.
@@ -85,6 +86,7 @@
* @return The elements of the vector are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind}
*/
+ @Override
public Vector<SnmpVarBind> getSubList();
/**
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibTable.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibTable.java Mon Dec 10 20:58:36 2012 -0800
@@ -266,6 +266,7 @@
* <p>
*
*/
+ @Override
public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
@@ -276,9 +277,9 @@
// each varbind involved (nb: should not happen, the error
// should have been registered earlier)
if (isnew) {
- SnmpVarBind var = null;
- for (Enumeration e= r.getElements(); e.hasMoreElements();) {
- var = (SnmpVarBind) e.nextElement();
+ SnmpVarBind var;
+ for (Enumeration<SnmpVarBind> e= r.getElements(); e.hasMoreElements();) {
+ var = e.nextElement();
r.registerGetException(var,noSuchInstanceException);
}
}
@@ -329,6 +330,7 @@
* <p>
*
*/
+ @Override
public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
final SnmpOid oid = req.getEntryOid();
@@ -389,6 +391,7 @@
* <p>
*
*/
+ @Override
public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException {
@@ -755,6 +758,7 @@
*
* @exception IllegalArgumentException Listener parameter is null.
*/
+ @Override
public synchronized void
addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object handback) {
@@ -768,13 +772,11 @@
// looking for listener in handbackTable
//
- Vector<Object> handbackList =
- handbackTable.get(listener) ;
- Vector<NotificationFilter> filterList =
- filterTable.get(listener) ;
+ Vector<Object> handbackList = handbackTable.get(listener) ;
+ Vector<NotificationFilter> filterList = filterTable.get(listener) ;
if ( handbackList == null ) {
- handbackList = new Vector<Object>() ;
- filterList = new Vector<NotificationFilter>() ;
+ handbackList = new Vector<>() ;
+ filterList = new Vector<>() ;
handbackTable.put(listener, handbackList) ;
filterTable.put(listener, filterList) ;
}
@@ -797,16 +799,14 @@
* @exception ListenerNotFoundException The listener is not registered
* in the MBean.
*/
+ @Override
public synchronized void
removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
// looking for listener in handbackTable
//
- java.util.Vector handbackList =
- (java.util.Vector) handbackTable.get(listener) ;
- java.util.Vector filterList =
- (java.util.Vector) filterTable.get(listener) ;
+ java.util.Vector<?> handbackList = handbackTable.get(listener) ;
if ( handbackList == null ) {
throw new ListenerNotFoundException("listener");
}
@@ -822,6 +822,7 @@
* notification class and the notification type sent by the
* <CODE>SnmpMibTable</CODE>.
*/
+ @Override
public MBeanNotificationInfo[] getNotificationInfo() {
String[] types = {SnmpTableEntryNotification.SNMP_ENTRY_ADDED,
@@ -1813,9 +1814,9 @@
//
// ---------------------------------------------------------------------
- final static void checkRowStatusFail(SnmpMibSubRequest req,
- int errorStatus)
+ static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus)
throws SnmpStatusException {
+
final SnmpVarBind statusvb = req.getRowStatusVarBind();
final SnmpStatusException x = new SnmpStatusException(errorStatus);
req.registerCheckException(statusvb,x);
@@ -1827,9 +1828,9 @@
//
// ---------------------------------------------------------------------
- final static void setRowStatusFail(SnmpMibSubRequest req,
- int errorStatus)
+ static void setRowStatusFail(SnmpMibSubRequest req, int errorStatus)
throws SnmpStatusException {
+
final SnmpVarBind statusvb = req.getRowStatusVarBind();
final SnmpStatusException x = new SnmpStatusException(errorStatus);
req.registerSetException(statusvb,x);
@@ -1840,6 +1841,7 @@
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
+ @Override
final synchronized void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth,
SnmpRequestTree handlers)
@@ -1909,11 +1911,15 @@
// largely inspired from the original getNext() method.
//
// ---------------------------------------------------------------------
+ @Override
final synchronized long[] findNextHandlingNode(SnmpVarBind varbind,
- long[] oid, int pos, int depth,
- SnmpRequestTree handlers,
- AcmChecker checker)
+ long[] oid,
+ int pos,
+ int depth,
+ SnmpRequestTree handlers,
+ AcmChecker checker)
throws SnmpStatusException {
+
int length = oid.length;
if (handlers == null)
@@ -1974,7 +1980,7 @@
}
// Now that we've got everything right we can begin.
- SnmpOid entryoid = null ;
+ SnmpOid entryoid;
if (pos == (length - 1)) {
// pos points to the last arc in the oid, and this arc is
@@ -2200,28 +2206,25 @@
// loop on listener
//
- for(java.util.Enumeration k = handbackTable.keys();
+ for(java.util.Enumeration<NotificationListener> k = handbackTable.keys();
k.hasMoreElements(); ) {
- NotificationListener listener =
- (NotificationListener) k.nextElement();
+ NotificationListener listener = k.nextElement();
// Get the associated handback list and the associated filter list
//
- java.util.Vector handbackList =
- (java.util.Vector) handbackTable.get(listener) ;
- java.util.Vector filterList =
- (java.util.Vector) filterTable.get(listener) ;
+ java.util.Vector<?> handbackList = handbackTable.get(listener) ;
+ java.util.Vector<NotificationFilter> filterList =
+ filterTable.get(listener) ;
// loop on handback
//
- java.util.Enumeration f = filterList.elements();
- for(java.util.Enumeration h = handbackList.elements();
+ java.util.Enumeration<NotificationFilter> f = filterList.elements();
+ for(java.util.Enumeration<?> h = handbackList.elements();
h.hasMoreElements(); ) {
Object handback = h.nextElement();
- NotificationFilter filter =
- (NotificationFilter)f.nextElement();
+ NotificationFilter filter = f.nextElement();
if ((filter == null) ||
(filter.isNotificationEnabled(notification))) {
@@ -2300,7 +2303,7 @@
* OID was not found.
*
**/
- private final int findObject(SnmpOid oid) {
+ private int findObject(SnmpOid oid) {
int low= 0;
int max= size - 1;
SnmpOid pos;
@@ -2339,25 +2342,6 @@
* <p>
* @param oid The OID we would like to insert.
*
- * @return The position at which the OID should be inserted in
- * the table.
- *
- * @exception SnmpStatusException if the OID is already present in the
- * table.
- *
- **/
- private final int getInsertionPoint(SnmpOid oid)
- throws SnmpStatusException {
- return getInsertionPoint(oid, true);
- }
-
- /**
- * Search the position at which the given oid should be inserted
- * in the OID table (tableoids).
- *
- * <p>
- * @param oid The OID we would like to insert.
- *
* @param fail Tells whether a SnmpStatusException must be generated
* if the given OID is already present in the table.
*
@@ -2371,7 +2355,7 @@
* table and <code>fail</code> is <code>true</code>.
*
**/
- private final int getInsertionPoint(SnmpOid oid, boolean fail)
+ private int getInsertionPoint(SnmpOid oid, boolean fail)
throws SnmpStatusException {
final int failStatus = SnmpStatusException.snmpRspNotWritable;
@@ -2413,7 +2397,7 @@
* @param pos The position at which the OID to be removed is located.
*
**/
- private final void removeOid(int pos) {
+ private void removeOid(int pos) {
if (pos >= tablecount) return;
if (pos < 0) return;
final int l1 = --tablecount-pos;
@@ -2431,7 +2415,7 @@
* @param pos The position at which the OID to be added is located.
*
**/
- private final void insertOid(int pos, SnmpOid oid) {
+ private void insertOid(int pos, SnmpOid oid) {
if (pos >= tablesize || tablecount == tablesize) {
// Vector must be enlarged
@@ -2534,13 +2518,13 @@
* The list of entries.
* @serial
*/
- private final Vector<Object> entries= new Vector<Object>();
+ private final Vector<Object> entries= new Vector<>();
/**
* The list of object names.
* @serial
*/
- private final Vector<ObjectName> entrynames= new Vector<ObjectName>();
+ private final Vector<ObjectName> entrynames= new Vector<>();
/**
* Callback handlers
@@ -2548,17 +2532,16 @@
// final Vector callbacks = new Vector();
/**
- * Listener hastable containing the hand-back objects.
+ * Listener hashtable containing the hand-back objects.
*/
private Hashtable<NotificationListener, Vector<Object>> handbackTable =
- new Hashtable<NotificationListener, Vector<Object>>();
+ new Hashtable<>();
/**
- * Listener hastable containing the filter objects.
+ * Listener hashtable containing the filter objects.
*/
private Hashtable<NotificationListener, Vector<NotificationFilter>>
- filterTable =
- new Hashtable<NotificationListener, Vector<NotificationFilter>>();
+ filterTable = new Hashtable<>();
// PACKAGE VARIABLES
//------------------
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,11 +25,9 @@
package com.sun.jmx.snmp.agent;
import java.util.Vector;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.List;
import java.util.NoSuchElementException;
import java.util.Arrays;
import java.util.logging.Level;
@@ -77,7 +75,7 @@
this.request = req;
this.version = req.getVersion();
this.creationflag = creationflag;
- this.hashtable = new Hashtable<Object, Handler>();
+ this.hashtable = new Hashtable<>();
setPduType(pdutype);
}
@@ -191,7 +189,7 @@
// SnmSubRequest associated with an Handler node.
//-------------------------------------------------------------------
- static final class Enum implements Enumeration {
+ static final class Enum implements Enumeration<SnmpMibSubRequest> {
Enum(SnmpRequestTree hlist,Handler h) {
handler = h;
this.hlist = hlist;
@@ -203,11 +201,13 @@
private int iter = 0;
private int size = 0;
+ @Override
public boolean hasMoreElements() {
return iter < size;
}
- public Object nextElement() throws NoSuchElementException {
+ @Override
+ public SnmpMibSubRequest nextElement() throws NoSuchElementException {
if (iter == 0) {
if (handler.sublist != null) {
iter++;
@@ -216,7 +216,7 @@
}
iter ++;
if (iter > size) throw new NoSuchElementException();
- Object result = hlist.getSubRequest(handler,entry);
+ SnmpMibSubRequest result = hlist.getSubRequest(handler,entry);
entry++;
return result;
}
@@ -252,7 +252,8 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
- public Enumeration getElements() {
+ @Override
+ public Enumeration<SnmpVarBind> getElements() {
return varbinds.elements();
}
@@ -260,6 +261,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public Vector<SnmpVarBind> getSubList() {
return varbinds;
}
@@ -268,6 +270,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public final int getSize() {
if (varbinds == null) return 0;
return varbinds.size();
@@ -277,6 +280,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public void addVarBind(SnmpVarBind varbind) {
// XXX not sure we must also add the varbind in the global
// request? or whether we should raise an exception:
@@ -289,6 +293,7 @@
// Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public boolean isNewEntry() {
return isnew;
}
@@ -297,6 +302,7 @@
// Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public SnmpOid getEntryOid() {
return entryoid;
}
@@ -305,6 +311,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public int getVarIndex(SnmpVarBind varbind) {
if (varbind == null) return 0;
return global.getVarIndex(varbind);
@@ -314,6 +321,7 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public Object getUserData() { return global.getUserData(); }
@@ -322,6 +330,7 @@
// See SnmpMibSubRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public void registerGetException(SnmpVarBind var,
SnmpStatusException exception)
throws SnmpStatusException {
@@ -364,6 +373,7 @@
// Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public void registerSetException(SnmpVarBind var,
SnmpStatusException exception)
throws SnmpStatusException {
@@ -387,6 +397,7 @@
// Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public void registerCheckException(SnmpVarBind var,
SnmpStatusException exception)
throws SnmpStatusException {
@@ -410,42 +421,52 @@
// Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc.
// -------------------------------------------------------------
+ @Override
public int getVersion() {
return version;
}
+ @Override
public SnmpVarBind getRowStatusVarBind() {
return statusvb;
}
+ @Override
public SnmpPdu getPdu() {
return global.getPdu();
}
+ @Override
public int getRequestPduVersion() {
return global.getRequestPduVersion();
}
+ @Override
public SnmpEngine getEngine() {
return global.getEngine();
}
+ @Override
public String getPrincipal() {
return global.getPrincipal();
}
+ @Override
public int getSecurityLevel() {
return global.getSecurityLevel();
}
+ @Override
public int getSecurityModel() {
return global.getSecurityModel();
}
+ @Override
public byte[] getContextName() {
return global.getContextName();
}
+ @Override
public byte[] getAccessContextName() {
return global.getAccessContextName();
}
@@ -485,7 +506,7 @@
* Adds a varbind in this node sublist.
*/
public void addVarbind(SnmpVarBind varbind) {
- if (sublist == null) sublist = new Vector<SnmpVarBind>();
+ if (sublist == null) sublist = new Vector<>();
sublist.addElement(varbind);
}
@@ -503,7 +524,7 @@
// Vectors are null: Allocate new vectors
entryoids = new SnmpOid[Delta];
- entrylists = new Vector[Delta];
+ entrylists = (Vector<SnmpVarBind>[])new Vector<?>[Delta];
isentrynew = new boolean[Delta];
rowstatus = new SnmpVarBind[Delta];
entrysize = Delta;
@@ -521,7 +542,7 @@
// Allocate larger vectors
entrysize += Delta;
entryoids = new SnmpOid[entrysize];
- entrylists = new Vector[entrysize];
+ entrylists = (Vector<SnmpVarBind>[])new Vector<?>[entrysize];
isentrynew = new boolean[entrysize];
rowstatus = new SnmpVarBind[entrysize];
@@ -595,7 +616,7 @@
// entryoids = new ArrayList();
// entrylists = new ArrayList();
// isentrynew = new ArrayList();
- v = new Vector<SnmpVarBind>();
+ v = new Vector<>();
// entryoids.add(entryoid);
// entrylists.add(v);
// isentrynew.add(new Boolean(isnew));
@@ -614,7 +635,7 @@
// if (pos == -1 || pos >= entrycount ) {
// pos = getInsertionPoint(entryoids,entryoid);
// pos = getInsertionPoint(entryoids,entrycount,entryoid);
- v = new Vector<SnmpVarBind>();
+ v = new Vector<>();
// entryoids.add(pos,entryoid);
// entrylists.add(pos,v);
// isentrynew.add(pos,new Boolean(isnew));
@@ -775,7 +796,7 @@
// If it is a table, there will be one subrequest per entry involved.
//-------------------------------------------------------------------
- public Enumeration getSubRequests(Handler handler) {
+ public Enumeration<SnmpMibSubRequest> getSubRequests(Handler handler) {
return new Enum(this,handler);
}
@@ -783,7 +804,7 @@
// returns an enumeration of the Handlers stored in the Hashtable.
//-------------------------------------------------------------------
- public Enumeration getHandlers() {
+ public Enumeration<Handler> getHandlers() {
return hashtable.elements();
}
@@ -1048,7 +1069,6 @@
handler.addVarbind(varbind);
else
handler.addVarbind(varbind,entryoid,isnew,statusvb);
- return ;
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpStandardObjectServer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpStandardObjectServer.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,14 +27,7 @@
// java imports
//
import java.io.Serializable;
-import java.util.Hashtable;
import java.util.Enumeration;
-import java.util.Vector;
-
-// jmx imports
-//
-import com.sun.jmx.snmp.SnmpOid;
-import com.sun.jmx.snmp.SnmpValue;
import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException;
@@ -121,8 +114,8 @@
final Object data = req.getUserData();
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- final SnmpVarBind var= (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ final SnmpVarBind var= e.nextElement();
try {
final long id = var.oid.getOidArc(depth);
var.value = meta.get(id, data);
@@ -182,9 +175,8 @@
final Object data = req.getUserData();
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- SnmpVarBind var = null;
- var = (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ SnmpVarBind var = e.nextElement();
try {
// This method will generate a SnmpStatusException
// if `depth' is out of bounds.
@@ -248,8 +240,8 @@
final Object data = req.getUserData();
- for (Enumeration e= req.getElements(); e.hasMoreElements();) {
- final SnmpVarBind var = (SnmpVarBind) e.nextElement();
+ for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
+ final SnmpVarBind var = e.nextElement();
try {
// This method will generate a SnmpStatusException
// if `depth' is out of bounds.
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java Mon Dec 10 20:58:36 2012 -0800
@@ -33,7 +33,6 @@
import java.io.ObjectInputStream;
import java.io.IOException;
import java.net.InetAddress;
-import java.util.Enumeration;
import java.util.logging.Level;
import java.util.Vector;
import java.util.NoSuchElementException;
@@ -50,8 +49,6 @@
import javax.management.MBeanNotificationInfo;
import javax.management.AttributeChangeNotification;
import javax.management.ListenerNotFoundException;
-import javax.management.loading.ClassLoaderRepository;
-import javax.management.MBeanServerFactory;
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
@@ -225,9 +222,8 @@
private transient Object stateLock = new Object();
private transient Vector<ClientHandler>
- clientHandlerVector = new Vector<ClientHandler>() ;
+ clientHandlerVector = new Vector<>() ;
- private transient Thread fatherThread = Thread.currentThread() ;
private transient Thread mainThread = null ;
private volatile boolean stopRequested = false ;
@@ -328,6 +324,7 @@
* Has no effect if this <CODE>CommunicatorServer</CODE> is
* <CODE>ONLINE</CODE> or <CODE>STOPPING</CODE>.
*/
+ @Override
public void start() {
try {
start(0);
@@ -346,6 +343,7 @@
* Has no effect if this <CODE>CommunicatorServer</CODE> is
* <CODE>OFFLINE</CODE> or <CODE>STOPPING</CODE>.
*/
+ @Override
public void stop() {
synchronized (stateLock) {
if (state == OFFLINE || state == STOPPING) {
@@ -393,6 +391,7 @@
*
* @return True if connector is <CODE>ONLINE</CODE>; false otherwise.
*/
+ @Override
public boolean isActive() {
synchronized (stateLock) {
return (state == ONLINE);
@@ -431,6 +430,7 @@
* @return true if the value of this MBean's State attribute is the
* same as the <VAR>wantedState</VAR> parameter; false otherwise.
*/
+ @Override
public boolean waitState(int wantedState, long timeOut) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
@@ -595,6 +595,7 @@
* @return <CODE>ONLINE</CODE>, <CODE>OFFLINE</CODE>,
* <CODE>STARTING</CODE> or <CODE>STOPPING</CODE>.
*/
+ @Override
public int getState() {
synchronized (stateLock) {
return state ;
@@ -607,6 +608,7 @@
* @return One of the strings "ONLINE", "OFFLINE", "STARTING" or
* "STOPPING".
*/
+ @Override
public String getStateString() {
return getStringForState(state) ;
}
@@ -616,6 +618,7 @@
*
* @return The host name used by this <CODE>CommunicatorServer</CODE>.
*/
+ @Override
public String getHost() {
try {
host = InetAddress.getLocalHost().getHostName();
@@ -630,6 +633,7 @@
*
* @return The port number used by this <CODE>CommunicatorServer</CODE>.
*/
+ @Override
public int getPort() {
synchronized (stateLock) {
return port ;
@@ -645,6 +649,7 @@
* @exception java.lang.IllegalStateException This method has been invoked
* while the communicator was ONLINE or STARTING.
*/
+ @Override
public void setPort(int port) throws java.lang.IllegalStateException {
synchronized (stateLock) {
if ((state == ONLINE) || (state == STARTING))
@@ -659,7 +664,8 @@
* Gets the protocol being used by this <CODE>CommunicatorServer</CODE>.
* @return The protocol as a string.
*/
- public abstract String getProtocol() ;
+ @Override
+ public abstract String getProtocol();
/**
* Gets the number of clients that have been processed by this
@@ -754,6 +760,7 @@
* <p>
* The <CODE>run</CODE> method executed by this connector's main thread.
*/
+ @Override
public void run() {
// Fix jaw.00667.B
@@ -851,7 +858,7 @@
} finally {
synchronized (stateLock) {
interrupted = true;
- Thread.currentThread().interrupted();
+ Thread.interrupted();
}
// ----------------------
@@ -970,7 +977,7 @@
"MBeanServer argument must be MBean server where this " +
"server is registered, or an MBeanServerForwarder " +
"leading to that server";
- Vector<MBeanServer> seenMBS = new Vector<MBeanServer>();
+ Vector<MBeanServer> seenMBS = new Vector<>();
for (MBeanServer mbs = newMBS;
mbs != bottomMBS;
mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) {
@@ -1153,8 +1160,7 @@
state = OFFLINE;
stopRequested = false;
servedClientCount = 0;
- clientHandlerVector = new Vector<ClientHandler>();
- fatherThread = Thread.currentThread();
+ clientHandlerVector = new Vector<>();
mainThread = null;
notifCount = 0;
notifInfos = null;
@@ -1184,6 +1190,7 @@
*
* @exception IllegalArgumentException Listener parameter is null.
*/
+ @Override
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
@@ -1207,6 +1214,7 @@
*
* @exception ListenerNotFoundException The listener is not registered.
*/
+ @Override
public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
@@ -1225,6 +1233,7 @@
* sent when the <tt>State</tt> attribute of this CommunicatorServer
* changes.
*/
+ @Override
public MBeanNotificationInfo[] getNotificationInfo() {
// Initialize notifInfos on first call to getNotificationInfo()
@@ -1304,6 +1313,7 @@
* the <CODE>MBeanServer</CODE> and re-thrown
* as an <CODE>MBeanRegistrationException</CODE>.
*/
+ @Override
public ObjectName preRegister(MBeanServer server, ObjectName name)
throws java.lang.Exception {
objectName = name;
@@ -1325,6 +1335,7 @@
* successfully registered in the <CODE>MBeanServer</CODE>.
* The value false means that the registration phase has failed.
*/
+ @Override
public void postRegister(Boolean registrationDone) {
if (!registrationDone.booleanValue()) {
synchronized (this) {
@@ -1340,6 +1351,7 @@
* the <CODE>MBeanServer</CODE> and re-thrown
* as an <CODE>MBeanRegistrationException</CODE>.
*/
+ @Override
public void preDeregister() throws java.lang.Exception {
synchronized (this) {
topMBS = bottomMBS = null;
@@ -1354,22 +1366,8 @@
/**
* Do nothing.
*/
+ @Override
public void postDeregister(){
}
- /**
- * Load a class using the default loader repository
- **/
- Class loadClass(String className)
- throws ClassNotFoundException {
- try {
- return Class.forName(className);
- } catch (ClassNotFoundException e) {
- final ClassLoaderRepository clr =
- MBeanServerFactory.getClassLoaderRepository(bottomMBS);
- if (clr == null) throw new ClassNotFoundException(className);
- return clr.loadClass(className);
- }
- }
-
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,6 @@
import javax.management.MBeanServer;
import javax.management.MBeanRegistration;
import javax.management.ObjectName;
-import javax.management.InstanceAlreadyExistsException;
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
import com.sun.jmx.snmp.SnmpIpAddress;
import com.sun.jmx.snmp.SnmpMessage;
@@ -157,7 +156,7 @@
/**
* The IP address based ACL used by this SNMP protocol adaptor.
*/
- private Object ipacl = null;
+ private InetAddressAcl ipacl = null;
/**
* The factory object.
@@ -199,7 +198,7 @@
transient DatagramSocket trapSocket = null;
private transient SnmpSession informSession = null;
private transient DatagramPacket packet = null;
- transient Vector<SnmpMibAgent> mibs = new Vector<SnmpMibAgent>();
+ transient Vector<SnmpMibAgent> mibs = new Vector<>();
private transient SnmpMibTree root;
/**
@@ -482,8 +481,7 @@
//
if (acl == null && forceAcl) {
try {
- acl = (InetAddressAcl)
- new SnmpAcl("SNMP protocol adaptor IP ACL");
+ acl = new SnmpAcl("SNMP protocol adaptor IP ACL");
} catch (UnknownHostException e) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
@@ -508,6 +506,7 @@
* since its creation. This counter is not reset by the <CODE>stop</CODE>
* method.
*/
+ @Override
public int getServedClientCount() {
return super.getServedClientCount();
}
@@ -519,6 +518,7 @@
* @return The number of managers currently being processed by this
* SNMP protocol adaptor.
*/
+ @Override
public int getActiveClientCount() {
return super.getActiveClientCount();
}
@@ -530,6 +530,7 @@
* @return The maximum number of managers that this SNMP protocol adaptor
* can process concurrently.
*/
+ @Override
public int getMaxActiveClientCount() {
return super.getMaxActiveClientCount();
}
@@ -543,6 +544,7 @@
* @exception java.lang.IllegalStateException This method has been invoked
* while the communicator was <CODE>ONLINE</CODE> or <CODE>STARTING</CODE>.
*/
+ @Override
public void setMaxActiveClientCount(int c)
throws java.lang.IllegalStateException {
super.setMaxActiveClientCount(c);
@@ -554,8 +556,9 @@
*
* @since 1.5
*/
+ @Override
public InetAddressAcl getInetAddressAcl() {
- return (InetAddressAcl)ipacl;
+ return ipacl;
}
/**
@@ -564,6 +567,7 @@
*
* @return The port number for sending SNMP traps.
*/
+ @Override
public Integer getTrapPort() {
return new Integer(trapPort) ;
}
@@ -573,6 +577,7 @@
*
* @param port The port number for sending SNMP traps.
*/
+ @Override
public void setTrapPort(Integer port) {
setTrapPort(port.intValue());
}
@@ -595,6 +600,7 @@
*
* @return The port number for sending SNMP inform requests.
*/
+ @Override
public int getInformPort() {
return informPort;
}
@@ -605,6 +611,7 @@
*
* @param port The port number for sending SNMP inform requests.
*/
+ @Override
public void setInformPort(int port) {
if (port < 0)
throw new IllegalArgumentException("Inform request port "+
@@ -617,6 +624,7 @@
*
* @return The string "snmp".
*/
+ @Override
public String getProtocol() {
return "snmp";
}
@@ -629,6 +637,7 @@
*
* @return The buffer size.
*/
+ @Override
public Integer getBufferSize() {
return new Integer(bufferSize) ;
}
@@ -643,6 +652,7 @@
* @exception java.lang.IllegalStateException This method has been invoked
* while the communicator was <CODE>ONLINE</CODE> or <CODE>STARTING</CODE>.
*/
+ @Override
public void setBufferSize(Integer s)
throws java.lang.IllegalStateException {
if ((state == ONLINE) || (state == STARTING)) {
@@ -658,6 +668,7 @@
* By default, a maximum of 3 tries is used.
* @return The maximun number of tries.
*/
+ @Override
final public int getMaxTries() {
return maxTries;
}
@@ -667,6 +678,7 @@
* request before giving up.
* @param newMaxTries The maximun number of tries.
*/
+ @Override
final public synchronized void setMaxTries(int newMaxTries) {
if (newMaxTries < 0)
throw new IllegalArgumentException();
@@ -678,6 +690,7 @@
* By default, a timeout of 3 seconds is used.
* @return The value of the timeout property.
*/
+ @Override
final public int getTimeout() {
return timeout;
}
@@ -686,6 +699,7 @@
* Changes the timeout to wait for an inform response from the manager.
* @param newTimeout The timeout (in milliseconds).
*/
+ @Override
final public synchronized void setTimeout(int newTimeout) {
if (newTimeout < 0)
throw new IllegalArgumentException();
@@ -697,6 +711,7 @@
*
* @return The factory object.
*/
+ @Override
public SnmpPduFactory getPduFactory() {
return pduFactory ;
}
@@ -706,6 +721,7 @@
*
* @param factory The factory object (null means the default factory).
*/
+ @Override
public void setPduFactory(SnmpPduFactory factory) {
if (factory == null)
pduFactory = new SnmpPduFactoryBER() ;
@@ -719,6 +735,7 @@
* @param factory The factory object (null means no factory).
* @see com.sun.jmx.snmp.agent.SnmpUserDataFactory
*/
+ @Override
public void setUserDataFactory(SnmpUserDataFactory factory) {
userDataFactory = factory ;
}
@@ -729,6 +746,7 @@
* @return The factory object (null means no factory).
* @see com.sun.jmx.snmp.agent.SnmpUserDataFactory
*/
+ @Override
public SnmpUserDataFactory getUserDataFactory() {
return userDataFactory;
}
@@ -745,6 +763,7 @@
* @return <CODE>true</CODE> if authentication traps are enabled,
* <CODE>false</CODE> otherwise.
*/
+ @Override
public boolean getAuthTrapEnabled() {
return authTrapEnabled ;
}
@@ -755,6 +774,7 @@
*
* @param enabled Flag indicating if traps need to be sent.
*/
+ @Override
public void setAuthTrapEnabled(boolean enabled) {
authTrapEnabled = enabled ;
}
@@ -772,6 +792,7 @@
*
* @return <CODE>true</CODE> if responses are sent.
*/
+ @Override
public boolean getAuthRespEnabled() {
return authRespEnabled ;
}
@@ -782,6 +803,7 @@
*
* @param enabled Flag indicating if responses need to be sent.
*/
+ @Override
public void setAuthRespEnabled(boolean enabled) {
authRespEnabled = enabled ;
}
@@ -793,6 +815,7 @@
*
* @return The OID in string format "x.x.x.x".
*/
+ @Override
public String getEnterpriseOid() {
return enterpriseOid.toString() ;
}
@@ -804,6 +827,7 @@
*
* @exception IllegalArgumentException The string format is incorrect
*/
+ @Override
public void setEnterpriseOid(String oid) throws IllegalArgumentException {
enterpriseOid = new SnmpOid(oid) ;
}
@@ -813,11 +837,12 @@
*
* @return An array of MIB names.
*/
+ @Override
public String[] getMibs() {
String[] result = new String[mibs.size()] ;
int i = 0 ;
- for (Enumeration e = mibs.elements() ; e.hasMoreElements() ;) {
- SnmpMibAgent mib = (SnmpMibAgent)e.nextElement() ;
+ for (Enumeration<SnmpMibAgent> e = mibs.elements() ; e.hasMoreElements() ;) {
+ SnmpMibAgent mib = e.nextElement() ;
result[i++] = mib.getMibName();
}
return result ;
@@ -831,6 +856,7 @@
*
* @return The <CODE>snmpOutTraps</CODE> value.
*/
+ @Override
public Long getSnmpOutTraps() {
return new Long(snmpOutTraps);
}
@@ -840,6 +866,7 @@
*
* @return The <CODE>snmpOutGetResponses</CODE> value.
*/
+ @Override
public Long getSnmpOutGetResponses() {
return new Long(snmpOutGetResponses);
}
@@ -849,6 +876,7 @@
*
* @return The <CODE>snmpOutGenErrs</CODE> value.
*/
+ @Override
public Long getSnmpOutGenErrs() {
return new Long(snmpOutGenErrs);
}
@@ -858,6 +886,7 @@
*
* @return The <CODE>snmpOutBadValues</CODE> value.
*/
+ @Override
public Long getSnmpOutBadValues() {
return new Long(snmpOutBadValues);
}
@@ -867,6 +896,7 @@
*
* @return The <CODE>snmpOutNoSuchNames</CODE> value.
*/
+ @Override
public Long getSnmpOutNoSuchNames() {
return new Long(snmpOutNoSuchNames);
}
@@ -876,6 +906,7 @@
*
* @return The <CODE>snmpOutTooBigs</CODE> value.
*/
+ @Override
public Long getSnmpOutTooBigs() {
return new Long(snmpOutTooBigs);
}
@@ -885,6 +916,7 @@
*
* @return The <CODE>snmpInASNParseErrs</CODE> value.
*/
+ @Override
public Long getSnmpInASNParseErrs() {
return new Long(snmpInASNParseErrs);
}
@@ -894,6 +926,7 @@
*
* @return The <CODE>snmpInBadCommunityUses</CODE> value.
*/
+ @Override
public Long getSnmpInBadCommunityUses() {
return new Long(snmpInBadCommunityUses);
}
@@ -904,6 +937,7 @@
*
* @return The <CODE>snmpInBadCommunityNames</CODE> value.
*/
+ @Override
public Long getSnmpInBadCommunityNames() {
return new Long(snmpInBadCommunityNames);
}
@@ -913,6 +947,7 @@
*
* @return The <CODE>snmpInBadVersions</CODE> value.
*/
+ @Override
public Long getSnmpInBadVersions() {
return new Long(snmpInBadVersions);
}
@@ -922,6 +957,7 @@
*
* @return The <CODE>snmpOutPkts</CODE> value.
*/
+ @Override
public Long getSnmpOutPkts() {
return new Long(snmpOutPkts);
}
@@ -931,6 +967,7 @@
*
* @return The <CODE>snmpInPkts</CODE> value.
*/
+ @Override
public Long getSnmpInPkts() {
return new Long(snmpInPkts);
}
@@ -940,6 +977,7 @@
*
* @return The <CODE>snmpInGetRequests</CODE> value.
*/
+ @Override
public Long getSnmpInGetRequests() {
return new Long(snmpInGetRequests);
}
@@ -949,6 +987,7 @@
*
* @return The <CODE>snmpInGetNexts</CODE> value.
*/
+ @Override
public Long getSnmpInGetNexts() {
return new Long(snmpInGetNexts);
}
@@ -958,6 +997,7 @@
*
* @return The <CODE>snmpInSetRequests</CODE> value.
*/
+ @Override
public Long getSnmpInSetRequests() {
return new Long(snmpInSetRequests);
}
@@ -967,6 +1007,7 @@
*
* @return The <CODE>snmpInTotalSetVars</CODE> value.
*/
+ @Override
public Long getSnmpInTotalSetVars() {
return new Long(snmpInTotalSetVars);
}
@@ -976,6 +1017,7 @@
*
* @return The <CODE>snmpInTotalReqVars</CODE> value.
*/
+ @Override
public Long getSnmpInTotalReqVars() {
return new Long(snmpInTotalReqVars);
}
@@ -988,6 +1030,7 @@
*
* @since 1.5
*/
+ @Override
public Long getSnmpSilentDrops() {
return new Long(snmpSilentDrops);
}
@@ -1000,6 +1043,7 @@
*
* @since 1.5
*/
+ @Override
public Long getSnmpProxyDrops() {
return new Long(0);
}
@@ -1027,6 +1071,7 @@
*
* @exception java.lang.Exception
*/
+ @Override
public ObjectName preRegister(MBeanServer server, ObjectName name)
throws java.lang.Exception {
@@ -1040,6 +1085,7 @@
/**
* Not used in this context.
*/
+ @Override
public void postRegister (Boolean registrationDone) {
super.postRegister(registrationDone);
}
@@ -1047,6 +1093,7 @@
/**
* Not used in this context.
*/
+ @Override
public void preDeregister() throws java.lang.Exception {
super.preDeregister();
}
@@ -1054,6 +1101,7 @@
/**
* Not used in this context.
*/
+ @Override
public void postDeregister() {
super.postDeregister();
}
@@ -1067,6 +1115,7 @@
*
* @exception IllegalArgumentException If the parameter is null.
*/
+ @Override
public SnmpMibHandler addMib(SnmpMibAgent mib)
throws IllegalArgumentException {
if (mib == null) {
@@ -1097,6 +1146,7 @@
*
* @since 1.5
*/
+ @Override
public SnmpMibHandler addMib(SnmpMibAgent mib, SnmpOid[] oids)
throws IllegalArgumentException {
if (mib == null) {
@@ -1129,6 +1179,7 @@
*
* @since 1.5
*/
+ @Override
public SnmpMibHandler addMib(SnmpMibAgent mib, String contextName)
throws IllegalArgumentException {
return addMib(mib);
@@ -1150,10 +1201,12 @@
*
* @since 1.5
*/
+ @Override
public SnmpMibHandler addMib(SnmpMibAgent mib,
String contextName,
SnmpOid[] oids)
throws IllegalArgumentException {
+
return addMib(mib, oids);
}
@@ -1171,6 +1224,7 @@
*
* @since 1.5
*/
+ @Override
public boolean removeMib(SnmpMibAgent mib, String contextName) {
return removeMib(mib);
}
@@ -1183,6 +1237,7 @@
* @return <CODE>true</CODE> if the specified <CODE>mib</CODE> was a MIB
* included in the SNMP MIB handler, <CODE>false</CODE> otherwise.
*/
+ @Override
public boolean removeMib(SnmpMibAgent mib) {
root.unregister(mib);
return (mibs.removeElement(mib)) ;
@@ -1199,6 +1254,7 @@
*
* @since 1.5
*/
+ @Override
public boolean removeMib(SnmpMibAgent mib, SnmpOid[] oids) {
root.unregister(mib, oids);
return (mibs.removeElement(mib)) ;
@@ -1216,6 +1272,7 @@
*
* @since 1.5
*/
+ @Override
public boolean removeMib(SnmpMibAgent mib,
String contextName,
SnmpOid[] oids) {
@@ -1228,6 +1285,7 @@
/**
* Creates the datagram socket.
*/
+ @Override
protected void doBind()
throws CommunicationException, InterruptedException {
@@ -1255,6 +1313,7 @@
* that port number was 0.
* @return the actual port to which the adaptor is bound.
**/
+ @Override
public int getPort() {
synchronized (this) {
if (socket != null) return socket.getLocalPort();
@@ -1265,6 +1324,7 @@
/**
* Closes the datagram socket.
*/
+ @Override
protected void doUnbind()
throws CommunicationException, InterruptedException {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
@@ -1282,12 +1342,17 @@
closeInformSocketIfNeeded() ;
}
- void createSnmpRequestHandler(SnmpAdaptorServer server, int id,
- DatagramSocket s, DatagramPacket p,
- SnmpMibTree tree, Vector m, Object a,
- SnmpPduFactory factory,
- SnmpUserDataFactory dataFactory,
- MBeanServer f, ObjectName n) {
+ private void createSnmpRequestHandler(SnmpAdaptorServer server,
+ int id,
+ DatagramSocket s,
+ DatagramPacket p,
+ SnmpMibTree tree,
+ Vector<SnmpMibAgent> m,
+ InetAddressAcl a,
+ SnmpPduFactory factory,
+ SnmpUserDataFactory dataFactory,
+ MBeanServer f,
+ ObjectName n) {
final SnmpRequestHandler handler =
new SnmpRequestHandler(this, id, s, p, tree, m, a, factory,
dataFactory, f, n);
@@ -1298,6 +1363,7 @@
* Reads a packet from the datagram socket and creates a request
* handler which decodes and processes the request.
*/
+ @Override
protected void doReceive()
throws CommunicationException, InterruptedException {
@@ -1339,13 +1405,14 @@
}
}
+ @Override
protected void doError(Exception e) throws CommunicationException {
- return;
}
/**
* Not used in this context.
*/
+ @Override
protected void doProcess()
throws CommunicationException, InterruptedException {
}
@@ -1357,6 +1424,7 @@
* We attempt only once...
* @return 1
**/
+ @Override
protected int getBindTries() {
return 1;
}
@@ -1368,6 +1436,7 @@
* Has no effect if this SNMP protocol adaptor is <CODE>OFFLINE</CODE> or
* <CODE>STOPPING</CODE>.
*/
+ @Override
public void stop(){
final int port = getPort();
@@ -1424,6 +1493,7 @@
* @exception SnmpStatusException If the trap exceeds the limit defined
* by <CODE>bufferSize</CODE>.
*/
+ @Override
public void snmpV1Trap(int generic, int specific,
SnmpVarBindList varBindList)
throws IOException, SnmpStatusException {
@@ -1499,6 +1569,7 @@
* @exception SnmpStatusException If the trap exceeds the limit defined
* by <CODE>bufferSize</CODE>.
*/
+ @Override
public void snmpV1Trap(InetAddress addr, String cs, int generic,
int specific, SnmpVarBindList varBindList)
throws IOException, SnmpStatusException {
@@ -1617,6 +1688,7 @@
*
* @since 1.5
*/
+ @Override
public void snmpV1Trap(SnmpPeer peer,
SnmpIpAddress agentAddr,
SnmpOid enterpOid,
@@ -1625,6 +1697,7 @@
SnmpVarBindList varBindList,
SnmpTimeticks time)
throws IOException, SnmpStatusException {
+
SnmpParameters p = (SnmpParameters) peer.getParams();
snmpV1Trap(peer.getDestAddr(),
peer.getDestPort(),
@@ -1745,11 +1818,13 @@
*
* @since 1.5
*/
+ @Override
public void snmpV2Trap(SnmpPeer peer,
SnmpOid trapOid,
SnmpVarBindList varBindList,
SnmpTimeticks time)
throws IOException, SnmpStatusException {
+
SnmpParameters p = (SnmpParameters) peer.getParams();
snmpV2Trap(peer.getDestAddr(),
peer.getDestPort(),
@@ -1781,6 +1856,7 @@
* @exception SnmpStatusException If the trap exceeds the limit defined
* by <CODE>bufferSize</CODE>.
*/
+ @Override
public void snmpV2Trap(SnmpOid trapOid, SnmpVarBindList varBindList)
throws IOException, SnmpStatusException {
@@ -1801,7 +1877,7 @@
SnmpVarBindList fullVbl ;
if (varBindList != null)
- fullVbl = (SnmpVarBindList)varBindList.clone() ;
+ fullVbl = varBindList.clone() ;
else
fullVbl = new SnmpVarBindList(2) ;
SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime()) ;
@@ -1840,6 +1916,7 @@
* @exception SnmpStatusException If the trap exceeds the limit
* defined by <CODE>bufferSize</CODE>.
*/
+ @Override
public void snmpV2Trap(InetAddress addr, String cs, SnmpOid trapOid,
SnmpVarBindList varBindList)
throws IOException, SnmpStatusException {
@@ -1865,7 +1942,7 @@
SnmpVarBindList fullVbl ;
if (varBindList != null)
- fullVbl = (SnmpVarBindList)varBindList.clone() ;
+ fullVbl = varBindList.clone() ;
else
fullVbl = new SnmpVarBindList(2) ;
SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime()) ;
@@ -1964,12 +2041,12 @@
SnmpVarBindList fullVbl ;
if (varBindList != null)
- fullVbl = (SnmpVarBindList)varBindList.clone() ;
+ fullVbl = varBindList.clone() ;
else
fullVbl = new SnmpVarBindList(2) ;
// Only difference with other
- SnmpTimeticks sysUpTimeValue = null;
+ SnmpTimeticks sysUpTimeValue;
if(time != null)
sysUpTimeValue = time;
else
@@ -2002,6 +2079,7 @@
*
* @since 1.5
*/
+ @Override
public void snmpPduTrap(InetAddress address, SnmpPduPacket pdu)
throws IOException, SnmpStatusException {
@@ -2021,6 +2099,7 @@
* by <CODE>bufferSize</CODE>.
* @since 1.5
*/
+ @Override
public void snmpPduTrap(SnmpPeer peer,
SnmpPduPacket pdu)
throws IOException, SnmpStatusException {
@@ -2066,13 +2145,12 @@
int sendingCount = 0 ;
openTrapSocketIfNeeded() ;
if (ipacl != null) {
- Enumeration ed = ((InetAddressAcl)ipacl).getTrapDestinations() ;
+ Enumeration<InetAddress> ed = ipacl.getTrapDestinations() ;
while (ed.hasMoreElements()) {
- msg.address = (InetAddress)ed.nextElement() ;
- Enumeration ec = ((InetAddressAcl)ipacl).
- getTrapCommunities(msg.address) ;
+ msg.address = ed.nextElement() ;
+ Enumeration<String> ec = ipacl.getTrapCommunities(msg.address) ;
while (ec.hasMoreElements()) {
- msg.community = ((String)ec.nextElement()).getBytes() ;
+ msg.community = ec.nextElement().getBytes() ;
try {
sendTrapMessage(msg) ;
sendingCount++ ;
@@ -2164,6 +2242,7 @@
*/
private void sendTrapMessage(SnmpMessage msg)
throws IOException, SnmpTooBigException {
+
byte[] buffer = new byte[bufferSize] ;
DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ;
int encodingLength = msg.encodeMessage(buffer) ;
@@ -2245,8 +2324,10 @@
* @exception SnmpStatusException If the inform request exceeds the
* limit defined by <CODE>bufferSize</CODE>.
*/
- public Vector snmpInformRequest(SnmpInformHandler cb, SnmpOid trapOid,
- SnmpVarBindList varBindList)
+ @Override
+ public Vector<SnmpInformRequest> snmpInformRequest(SnmpInformHandler cb,
+ SnmpOid trapOid,
+ SnmpVarBindList varBindList)
throws IllegalStateException, IOException, SnmpStatusException {
if (!isActive()) {
@@ -2263,7 +2344,7 @@
//
SnmpVarBindList fullVbl ;
if (varBindList != null)
- fullVbl = (SnmpVarBindList)varBindList.clone() ;
+ fullVbl = varBindList.clone() ;
else
fullVbl = new SnmpVarBindList(2) ;
SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime()) ;
@@ -2277,17 +2358,16 @@
// Now send the SNMP message to each destination
//
- Vector<SnmpInformRequest> informReqList = new Vector<SnmpInformRequest>();
- InetAddress addr = null;
- String cs = null;
+ Vector<SnmpInformRequest> informReqList = new Vector<>();
+ InetAddress addr;
+ String cs;
if (ipacl != null) {
- Enumeration ed = ((InetAddressAcl)ipacl).getInformDestinations() ;
+ Enumeration<InetAddress> ed = ipacl.getInformDestinations() ;
while (ed.hasMoreElements()) {
- addr = (InetAddress)ed.nextElement() ;
- Enumeration ec = ((InetAddressAcl)ipacl).
- getInformCommunities(addr) ;
+ addr = ed.nextElement() ;
+ Enumeration<String> ec = ipacl.getInformCommunities(addr) ;
while (ec.hasMoreElements()) {
- cs = (String)ec.nextElement() ;
+ cs = ec.nextElement() ;
informReqList.addElement(
informSession.makeAsyncRequest(addr, cs, cb,
fullVbl,getInformPort())) ;
@@ -2330,6 +2410,7 @@
* @exception SnmpStatusException If the inform request exceeds the
* limit defined by <CODE>bufferSize</CODE>.
*/
+ @Override
public SnmpInformRequest snmpInformRequest(InetAddress addr,
String cs,
SnmpInformHandler cb,
@@ -2380,11 +2461,13 @@
*
* @since 1.5
*/
+ @Override
public SnmpInformRequest snmpInformRequest(SnmpPeer peer,
SnmpInformHandler cb,
SnmpOid trapOid,
SnmpVarBindList varBindList)
throws IllegalStateException, IOException, SnmpStatusException {
+
SnmpParameters p = (SnmpParameters) peer.getParams();
return snmpInformRequest(peer.getDestAddr(),
peer.getDestPort(),
@@ -2401,9 +2484,9 @@
* @param protocolVersion The protocol version.
* @param reqPduType The pdu type.
*/
- public static final int mapErrorStatus(int errorStatus,
- int protocolVersion,
- int reqPduType) {
+ public static int mapErrorStatus(int errorStatus,
+ int protocolVersion,
+ int reqPduType) {
return SnmpSubRequestHandler.mapErrorStatus(errorStatus,
protocolVersion,
reqPduType);
@@ -2416,6 +2499,7 @@
SnmpOid trapOid,
SnmpVarBindList varBindList)
throws IllegalStateException, IOException, SnmpStatusException {
+
if (!isActive()) {
throw new IllegalStateException(
"Start SNMP adaptor server before carrying out this operation");
@@ -2430,7 +2514,7 @@
//
SnmpVarBindList fullVbl ;
if (varBindList != null)
- fullVbl = (SnmpVarBindList)varBindList.clone() ;
+ fullVbl = varBindList.clone() ;
else
fullVbl = new SnmpVarBindList(2) ;
SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime()) ;
@@ -2489,6 +2573,7 @@
* references to the object.
* <P>Closes the datagram socket associated to this SNMP protocol adaptor.
*/
+ @Override
protected void finalize() {
try {
if (socket != null) {
@@ -2511,6 +2596,7 @@
/**
* Returns the string used in debug traces.
*/
+ @Override
String makeDebugTag() {
return "SnmpAdaptorServer["+ getProtocol() + ":" + getPort() + "]";
}
@@ -2615,13 +2701,13 @@
// This is for transient structures to be initialized to specific
// default values.
//
- mibs = new Vector<SnmpMibAgent>() ;
+ mibs = new Vector<>() ;
}
/**
* Common initializations.
*/
- private void init(Object acl, int p, InetAddress a) {
+ private void init(InetAddressAcl acl, int p, InetAddress a) {
root= new SnmpMibTree();
@@ -2650,6 +2736,7 @@
return root.getAgentMib(oid);
}
+ @Override
protected Thread createMainThread() {
final Thread t = super.createMainThread();
t.setDaemon(true);
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServerMBean.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServerMBean.java Mon Dec 10 20:58:36 2012 -0800
@@ -140,6 +140,7 @@
*
* @return The string "snmp".
*/
+ @Override
public String getProtocol();
/**
@@ -636,7 +637,8 @@
* @exception IOException An I/O error occurred while sending the inform request.
* @exception SnmpStatusException If the inform request exceeds the limit defined by <CODE>bufferSize</CODE>.
*/
- public Vector snmpInformRequest(SnmpInformHandler cb, SnmpOid trapOid, SnmpVarBindList varBindList)
+ public Vector<?> snmpInformRequest(SnmpInformHandler cb, SnmpOid trapOid,
+ SnmpVarBindList varBindList)
throws IllegalStateException, IOException, SnmpStatusException;
/**
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpMibTree.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpMibTree.java Mon Dec 10 20:58:36 2012 -0800
@@ -125,7 +125,7 @@
TreeNode node= retrieveChild(oid, cursor);
if (node == null)
return this;
- if (children.size() == 0) {
+ if (children.isEmpty()) {
// In this case, the node does not have any children. So no point to
// continue the search ...
return node;
@@ -149,24 +149,24 @@
public void printTree(String ident) {
- StringBuffer buff= new StringBuffer();
+ StringBuilder buff= new StringBuilder();
if (agents == null) {
return;
}
- for(Enumeration e= agents.elements(); e.hasMoreElements(); ) {
- SnmpMibAgent mib= (SnmpMibAgent) e.nextElement();
+ for(Enumeration<SnmpMibAgent> e= agents.elements(); e.hasMoreElements(); ) {
+ SnmpMibAgent mib= e.nextElement();
if (mib == null)
buff.append("empty ");
else
- buff.append(mib.getMibName() + " ");
+ buff.append(mib.getMibName()).append(" ");
}
ident+= " ";
if (children == null) {
return;
}
- for(Enumeration e= children.elements(); e.hasMoreElements(); ) {
- TreeNode node= (TreeNode) e.nextElement();
+ for(Enumeration<TreeNode> e= children.elements(); e.hasMoreElements(); ) {
+ TreeNode node= e.nextElement();
node.printTree(ident);
}
}
@@ -185,7 +185,7 @@
}
private void removeAgentFully(SnmpMibAgent agent) {
- Vector<TreeNode> v = new Vector<TreeNode>();
+ Vector<TreeNode> v = new Vector<>();
for(Enumeration<TreeNode> e= children.elements();
e.hasMoreElements(); ) {
@@ -212,9 +212,9 @@
}
- private void setAgent(SnmpMibAgent agent) {
- this.agent = agent;
- }
+ private void setAgent(SnmpMibAgent agent) {
+ this.agent = agent;
+ }
private void registerNode(long[] oid, int cursor, SnmpMibAgent agent) {
@@ -247,20 +247,20 @@
private TreeNode retrieveChild(long[] oid, int current) {
long theValue= oid[current];
- for(Enumeration e= children.elements(); e.hasMoreElements(); ) {
- TreeNode node= (TreeNode) e.nextElement();
+ for(Enumeration<TreeNode> e= children.elements(); e.hasMoreElements(); ) {
+ TreeNode node= e.nextElement();
if (node.match(theValue))
return node;
}
return null;
}
- final private boolean match(long value) {
+ private boolean match(long value) {
return (nodeValue == value) ? true : false;
}
- private Vector<TreeNode> children= new Vector<TreeNode>();
- private Vector<SnmpMibAgent> agents= new Vector<SnmpMibAgent>();
+ private Vector<TreeNode> children= new Vector<>();
+ private Vector<SnmpMibAgent> agents= new Vector<>();
private long nodeValue;
private SnmpMibAgent agent;
private TreeNode parent;
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpRequestHandler.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpRequestHandler.java Mon Dec 10 20:58:36 2012 -0800
@@ -71,9 +71,9 @@
class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
- private transient DatagramSocket socket = null ;
- private transient DatagramPacket packet = null ;
- private transient Vector mibs = null ;
+ private transient DatagramSocket socket = null ;
+ private transient DatagramPacket packet = null ;
+ private transient Vector<SnmpMibAgent> mibs = null ;
/**
* Contains the list of sub-requests associated to the current request.
@@ -85,7 +85,7 @@
*/
private transient SnmpMibTree root;
- private transient Object ipacl = null ;
+ private transient InetAddressAcl ipacl = null ;
private transient SnmpPduFactory pduFactory = null ;
private transient SnmpUserDataFactory userDataFactory = null ;
private transient SnmpAdaptorServer adaptor = null;
@@ -94,7 +94,8 @@
*/
public SnmpRequestHandler(SnmpAdaptorServer server, int id,
DatagramSocket s, DatagramPacket p,
- SnmpMibTree tree, Vector m, Object a,
+ SnmpMibTree tree, Vector<SnmpMibAgent> m,
+ InetAddressAcl a,
SnmpPduFactory factory,
SnmpUserDataFactory dataFactory,
MBeanServer f, ObjectName n)
@@ -108,8 +109,8 @@
socket = s;
packet = p;
root= tree;
- mibs = (Vector) m.clone();
- subs= new Hashtable<SnmpMibAgent, SnmpSubRequestHandler>(mibs.size());
+ mibs = new Vector<>(m);
+ subs= new Hashtable<>(mibs.size());
ipacl = a;
pduFactory = factory ;
userDataFactory = dataFactory ;
@@ -121,6 +122,7 @@
* back to the client.
* Note: we overwrite 'packet' with the response bytes.
*/
+ @Override
public void doRun() {
// Trace the input packet
@@ -243,7 +245,7 @@
// Transform the request message into a request pdu
//
- SnmpPduPacket reqPdu = null ;
+ SnmpPduPacket reqPdu;
Object userData = null;
try {
reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ;
@@ -306,7 +308,7 @@
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"makeResponseMessage", "fail on element" + pos);
}
- int old= 0;
+ int old;
while (true) {
try {
respPdu = reduceResponsePdu(reqPdu, respPdu, pos) ;
@@ -580,20 +582,18 @@
Object userData) {
int errorStatus = SnmpDefinitions.snmpRspNoError ;
- int nbSubRequest= subs.size();
- int i=0;
+ int i;
// If it's a set request, we must first check any varBind
//
if (req.type == pduSetRequestPdu) {
i=0;
- for(Enumeration e= subs.elements(); e.hasMoreElements() ; i++) {
+ for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements() ; i++) {
// Indicate to the sub request that a check must be invoked ...
// OK we should have defined out own tag for that !
//
- SnmpSubRequestHandler sub= (SnmpSubRequestHandler)
- e.nextElement();
+ SnmpSubRequestHandler sub= e.nextElement();
sub.setUserData(userData);
sub.type= pduWalkRequest;
@@ -618,8 +618,8 @@
// Let's start the sub-requests.
//
i=0;
- for(Enumeration e= subs.elements(); e.hasMoreElements() ;i++) {
- SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement();
+ for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements() ;i++) {
+ SnmpSubRequestHandler sub= e.nextElement();
/* NPCTE fix for bugId 4492741, esc 0, 16-August 2001 */
sub.setUserData(userData);
/* end of NPCTE fix for bugId 4492741 */
@@ -650,7 +650,7 @@
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
Object userData) {
- int errorStatus = SnmpDefinitions.snmpRspNoError ;
+ int errorStatus;
SnmpSubRequestHandler sub = subs.elements().nextElement();
sub.setUserData(userData);
@@ -707,7 +707,7 @@
private SnmpPduPacket makeGetBulkResponsePdu(SnmpPduBulk req,
Object userData) {
- SnmpVarBind[] respVarBindList = null ;
+ SnmpVarBind[] respVarBindList;
// RFC 1905, Section 4.2.3, p14
int L = req.varBindList.length ;
@@ -761,7 +761,7 @@
*/
private boolean checkPduType(SnmpPduPacket pdu) {
- boolean result = true ;
+ boolean result;
switch(pdu.type) {
@@ -798,8 +798,7 @@
//
if (ipacl != null) {
if (pdu.type == SnmpDefinitions.pduSetRequestPdu) {
- if (!((InetAddressAcl)ipacl).
- checkWritePermission(pdu.address, community)) {
+ if (!ipacl.checkWritePermission(pdu.address, community)) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"checkAcl", "sender is " + pdu.address +
@@ -820,7 +819,7 @@
}
}
else {
- if (!((InetAddressAcl)ipacl).checkReadPermission(pdu.address, community)) {
+ if (!ipacl.checkReadPermission(pdu.address, community)) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"checkAcl", "sender is " + pdu.address +
@@ -854,7 +853,7 @@
if (response != null) {
SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ;
snmpServer.incSnmpInBadCommunityUses(1) ;
- if (((InetAddressAcl)ipacl).checkCommunity(community) == false)
+ if (ipacl.checkCommunity(community) == false)
snmpServer.incSnmpInBadCommunityNames(1) ;
}
@@ -873,7 +872,7 @@
result.port = reqPdu.port ;
result.version = reqPdu.version ;
result.community = reqPdu.community ;
- result.type = result.pduGetResponsePdu ;
+ result.type = SnmpPduRequest.pduGetResponsePdu ;
result.requestId = reqPdu.requestId ;
result.errorStatus = SnmpDefinitions.snmpRspNoError ;
result.errorIndex = 0 ;
@@ -904,7 +903,7 @@
private SnmpMessage newTooBigMessage(SnmpMessage reqMsg)
throws SnmpTooBigException {
SnmpMessage result = null ;
- SnmpPduPacket reqPdu = null ;
+ SnmpPduPacket reqPdu;
try {
reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ;
@@ -941,7 +940,7 @@
// Reduction can be attempted only on bulk response
//
- if (req.type != req.pduGetBulkRequestPdu) {
+ if (req.type != SnmpPduPacket.pduGetBulkRequestPdu) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"reduceResponsePdu", "cannot remove anything");
@@ -961,7 +960,7 @@
// * when it is 0 (in fact, acceptedVbCount is not available),
// we split the varbindlist by 2.
//
- int vbCount = resp.varBindList.length ;
+ int vbCount;
if (acceptedVbCount >= 3)
vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ;
else if (acceptedVbCount == 1)
@@ -998,7 +997,7 @@
private void splitRequest(SnmpPduRequest req) {
int nbAgents= mibs.size();
- SnmpMibAgent agent= (SnmpMibAgent) mibs.firstElement();
+ SnmpMibAgent agent = mibs.firstElement();
if (nbAgents == 1) {
// Take all the oids contained in the request and
//
@@ -1010,8 +1009,8 @@
// to all agents
//
if (req.type == pduGetNextRequestPdu) {
- for(Enumeration e= mibs.elements(); e.hasMoreElements(); ) {
- SnmpMibAgent ag= (SnmpMibAgent) e.nextElement();
+ for(Enumeration<SnmpMibAgent> e= mibs.elements(); e.hasMoreElements(); ) {
+ final SnmpMibAgent ag= e.nextElement();
subs.put(ag, new SnmpSubNextRequestHandler(adaptor, ag, req));
}
return;
@@ -1047,8 +1046,8 @@
int R) {
// Send the getBulk to all agents
//
- for(Enumeration e= mibs.elements(); e.hasMoreElements(); ) {
- SnmpMibAgent agent = (SnmpMibAgent) e.nextElement();
+ for(Enumeration<SnmpMibAgent> e= mibs.elements(); e.hasMoreElements(); ) {
+ final SnmpMibAgent agent = e.nextElement();
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
@@ -1064,7 +1063,6 @@
maxRepetitions,
R));
}
- return;
}
private SnmpPduPacket mergeResponses(SnmpPduRequest req) {
@@ -1078,8 +1076,8 @@
// Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished
//
- for(Enumeration e= subs.elements(); e.hasMoreElements();) {
- SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement();
+ for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
+ SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result);
}
return newValidResponsePdu(req,result);
@@ -1092,8 +1090,8 @@
// Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished
//
- for(Enumeration e= subs.elements(); e.hasMoreElements();) {
- SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement();
+ for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
+ SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result);
}
@@ -1127,19 +1125,21 @@
// Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished
//
- for(Enumeration e= subs.elements(); e.hasMoreElements();) {
- SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement();
+ for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
+ SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result);
}
return result;
}
+ @Override
protected String makeDebugTag() {
return "SnmpRequestHandler[" + adaptorServer.getProtocol() + ":" +
adaptorServer.getPort() + "]";
}
+ @Override
Thread createThread(Runnable r) {
return null;
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpSubBulkRequestHandler.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpSubBulkRequestHandler.java Mon Dec 10 20:58:36 2012 -0800
@@ -31,7 +31,6 @@
// java import
//
import java.util.Enumeration;
-import java.util.Vector;
import java.util.logging.Level;
// jmx imports
//
@@ -46,9 +45,6 @@
//
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
import com.sun.jmx.snmp.agent.SnmpMibAgent;
-import com.sun.jmx.snmp.agent.SnmpMibRequest;
-import com.sun.jmx.snmp.ThreadContext;
-import com.sun.jmx.snmp.daemon.SnmpAdaptorServer;
import com.sun.jmx.snmp.internal.SnmpIncomingRequest;
import com.sun.jmx.snmp.ThreadContext;
@@ -85,6 +81,7 @@
init(server, req, nonRepeat, maxRepeat, R);
}
+ @Override
public void run() {
size= varBind.size();
@@ -259,11 +256,12 @@
* successful. As such the method getErrorIndex or getErrorStatus should be
* called.
*/
+ @Override
protected void updateResult(SnmpVarBind[] result) {
// we can assume that the run method is over ...
//
- final Enumeration e= varBind.elements();
+ final Enumeration<SnmpVarBind> e= varBind.elements();
final int max= result.length;
// First go through all the values once ...
@@ -284,7 +282,7 @@
continue;
}
- final SnmpVarBind element= (SnmpVarBind) e.nextElement();
+ final SnmpVarBind element= e.nextElement();
if (element == null) continue;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
@@ -309,7 +307,7 @@
return;
if (e.hasMoreElements() ==false)
return;
- final SnmpVarBind element= (SnmpVarBind) e.nextElement();
+ final SnmpVarBind element= e.nextElement();
if (element == null) continue;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
--- a/jdk/src/share/classes/com/sun/jmx/snmp/defaults/SnmpProperties.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/defaults/SnmpProperties.java Mon Dec 10 20:58:36 2012 -0800
@@ -60,7 +60,7 @@
InputStream is = new FileInputStream(file);
props.load(is);
is.close();
- for (final Enumeration e = props.keys(); e.hasMoreElements() ; ) {
+ for (final Enumeration<?> e = props.keys(); e.hasMoreElements() ; ) {
final String key = (String) e.nextElement();
System.setProperty(key,props.getProperty(key));
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/tasks/ThreadService.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/tasks/ThreadService.java Mon Dec 10 20:58:36 2012 -0800
@@ -199,7 +199,7 @@
// re-init
this.setPriority(priority);
- this.interrupted();
+ Thread.interrupted();
this.setContextClassLoader(cloader);
}
}
--- a/jdk/src/share/classes/com/sun/net/ssl/SSLPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/com/sun/net/ssl/SSLPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,8 +46,8 @@
* convention follows the hierarchical property naming convention.
* Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "foo.*" or "*" is valid,
- * "*foo" or "a*b" is not valid.
+ * signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
+ * match, while "*foo" and "a*b" do not.
* <P>
* The following table lists all the possible SSLPermission target names,
* and for each provides a description of what the permission allows
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Mon Dec 10 20:58:36 2012 -0800
@@ -1435,7 +1435,15 @@
int renderingIntent = intFromBigEndian(theHeader, icHdrRenderingIntent);
/* set the rendering intent */
- return renderingIntent;
+
+ /* According to ICC spec, only the least-significant 16 bits shall be
+ * used to encode the rendering intent. The most significant 16 bits
+ * shall be set to zero. Thus, we are ignoring two most significant
+ * bytes here.
+ *
+ * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15.
+ */
+ return (0xffff & renderingIntent);
}
--- a/jdk/src/share/classes/java/awt/image/ColorConvertOp.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/awt/image/ColorConvertOp.java Mon Dec 10 20:58:36 2012 -0800
@@ -732,10 +732,16 @@
private int getRenderingIntent (ICC_Profile profile) {
byte[] header = profile.getData(ICC_Profile.icSigHead);
int index = ICC_Profile.icHdrRenderingIntent;
- return (((header[index] & 0xff) << 24) |
- ((header[index+1] & 0xff) << 16) |
- ((header[index+2] & 0xff) << 8) |
- (header[index+3] & 0xff));
+
+ /* According to ICC spec, only the least-significant 16 bits shall be
+ * used to encode the rendering intent. The most significant 16 bits
+ * shall be set to zero. Thus, we are ignoring two most significant
+ * bytes here.
+ *
+ * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15.
+ */
+ return ((header[index+2] & 0xff) << 8) |
+ (header[index+3] & 0xff);
}
/**
--- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java Mon Dec 10 20:58:36 2012 -0800
@@ -177,11 +177,10 @@
ensureCapacityInternal(newLength);
if (count < newLength) {
- for (; count < newLength; count++)
- value[count] = '\0';
- } else {
- count = newLength;
+ Arrays.fill(value, count, newLength, '\0');
}
+
+ count = newLength;
}
/**
@@ -1308,8 +1307,7 @@
* {@code null}.
*/
public int indexOf(String str, int fromIndex) {
- return String.indexOf(value, 0, count,
- str.toCharArray(), 0, str.length(), fromIndex);
+ return String.indexOf(value, 0, count, str, fromIndex);
}
/**
@@ -1352,8 +1350,7 @@
* {@code null}.
*/
public int lastIndexOf(String str, int fromIndex) {
- return String.lastIndexOf(value, 0, count,
- str.toCharArray(), 0, str.length(), fromIndex);
+ return String.lastIndexOf(value, 0, count, str, fromIndex);
}
/**
--- a/jdk/src/share/classes/java/lang/Class.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Class.java Mon Dec 10 20:58:36 2012 -0800
@@ -48,6 +48,7 @@
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
+import java.util.Objects;
import sun.misc.Unsafe;
import sun.reflect.ConstantPool;
import sun.reflect.Reflection;
@@ -3044,34 +3045,62 @@
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- @SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
+ Objects.requireNonNull(annotationClass);
initAnnotationsIfNecessary();
- return (A) annotations.get(annotationClass);
+ return AnnotationSupport.getOneAnnotation(annotations, annotationClass);
}
/**
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- public boolean isAnnotationPresent(
- Class<? extends Annotation> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+ Objects.requireNonNull(annotationClass);
return getAnnotation(annotationClass) != null;
}
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A[] getAnnotations(Class<A> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ initAnnotationsIfNecessary();
+ return AnnotationSupport.getMultipleAnnotations(annotations, annotationClass);
+ }
/**
* @since 1.5
*/
public Annotation[] getAnnotations() {
initAnnotationsIfNecessary();
- return AnnotationParser.toArray(annotations);
+ return AnnotationSupport.unpackToArray(annotations);
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ initAnnotationsIfNecessary();
+ return AnnotationSupport.getOneAnnotation(declaredAnnotations, annotationClass);
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A[] getDeclaredAnnotations(Class<A> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ initAnnotationsIfNecessary();
+ return AnnotationSupport.getMultipleAnnotations(declaredAnnotations, annotationClass);
}
/**
@@ -3079,7 +3108,17 @@
*/
public Annotation[] getDeclaredAnnotations() {
initAnnotationsIfNecessary();
- return AnnotationParser.toArray(declaredAnnotations);
+ return AnnotationSupport.unpackToArray(declaredAnnotations);
+ }
+
+ /** Returns one "directly" present annotation or null */
+ <A extends Annotation> A getDirectDeclaredAnnotation(Class<A> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ initAnnotationsIfNecessary();
+ @SuppressWarnings("unchecked") // TODO check safe
+ A ret = (A)declaredAnnotations.get(annotationClass);
+ return ret;
}
// Annotations cache
--- a/jdk/src/share/classes/java/lang/Package.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Package.java Mon Dec 10 20:58:36 2012 -0800
@@ -395,6 +395,14 @@
}
/**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A[] getAnnotations(Class<A> annotationClass) {
+ return getPackageInfo().getAnnotations(annotationClass);
+ }
+
+ /**
* @since 1.5
*/
public Annotation[] getAnnotations() {
@@ -402,6 +410,22 @@
}
/**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
+ return getPackageInfo().getDeclaredAnnotation(annotationClass);
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <A extends Annotation> A[] getDeclaredAnnotations(Class<A> annotationClass) {
+ return getPackageInfo().getDeclaredAnnotations(annotationClass);
+ }
+
+ /**
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations() {
--- a/jdk/src/share/classes/java/lang/RuntimePermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/RuntimePermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,8 +41,8 @@
* naming convention follows the hierarchical property naming convention.
* Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "loadLibrary.*" or "*" is valid,
- * "*loadLibrary" or "a*b" is not valid.
+ * signify a wildcard match. For example: "loadLibrary.*" and "*" signify a
+ * wildcard match, while "*loadLibrary" and "a*b" do not.
* <P>
* The following table lists all the possible RuntimePermission target names,
* and for each provides a description of what the permission allows
--- a/jdk/src/share/classes/java/lang/String.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/String.java Mon Dec 10 20:58:36 2012 -0800
@@ -1706,6 +1706,24 @@
}
/**
+ * Code shared by String and AbstractStringBuilder to do searches. The
+ * source is the character array being searched, and the target
+ * is the string being searched for.
+ *
+ * @param source the characters being searched.
+ * @param sourceOffset offset of the source string.
+ * @param sourceCount count of the source string.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ */
+ static int indexOf(char[] source, int sourceOffset, int sourceCount,
+ String target, int fromIndex) {
+ return indexOf(source, sourceOffset, sourceCount,
+ target.value, 0, target.value.length,
+ fromIndex);
+ }
+
+ /**
* Code shared by String and StringBuffer to do searches. The
* source is the character array being searched, and the target
* is the string being searched for.
@@ -1797,6 +1815,24 @@
}
/**
+ * Code shared by String and AbstractStringBuilder to do searches. The
+ * source is the character array being searched, and the target
+ * is the string being searched for.
+ *
+ * @param source the characters being searched.
+ * @param sourceOffset offset of the source string.
+ * @param sourceCount count of the source string.
+ * @param target the characters being searched for.
+ * @param fromIndex the index to begin searching from.
+ */
+ static int lastIndexOf(char[] source, int sourceOffset, int sourceCount,
+ String target, int fromIndex) {
+ return lastIndexOf(source, sourceOffset, sourceCount,
+ target.value, 0, target.value.length,
+ fromIndex);
+ }
+
+ /**
* Code shared by String and StringBuffer to do searches. The
* source is the character array being searched, and the target
* is the string being searched for.
--- a/jdk/src/share/classes/java/lang/System.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/System.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,6 +25,7 @@
package java.lang;
import java.io.*;
+import java.lang.annotation.Annotation;
import java.util.Properties;
import java.util.PropertyPermission;
import java.util.StringTokenizer;
@@ -1195,6 +1196,9 @@
public AnnotationType getAnnotationType(Class<?> klass) {
return klass.getAnnotationType();
}
+ public <A extends Annotation> A getDirectDeclaredAnnotation(Class<?> klass, Class<A> anno) {
+ return klass.getDirectDeclaredAnnotation(anno);
+ }
public <E extends Enum<E>>
E[] getEnumConstantsShared(Class<E> klass) {
return klass.getEnumConstantsShared();
--- a/jdk/src/share/classes/java/lang/annotation/ContainedBy.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/annotation/ContainedBy.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,10 +26,35 @@
package java.lang.annotation;
/**
- * A meta-annotation to indicate which annotation type should be used
- * as a container for repeated values of the annotation type modified
- * by the {@code ContainedBy} annotation.
+ * The annotation type {@code java.lang.annotation.ContainedBy} is
+ * used to indicate that the annotation type whose declaration it
+ * (meta-)annotates is <em>repeatable</em>. The value of
+ * {@code @ContainedBy} indicates the <em>containing annotation
+ * type</em> for the repeatable annotation type.
+ *
+ * <p>The pair of annotation types {@code @ContainedBy} and
+ * {@link java.lang.annotation.ContainerFor @ContainerFor} are used to
+ * indicate that annotation types are repeatable. Specifically:
+ *
+ * <ul>
+ * <li>The annotation type {@code @ContainedBy} is used on the
+ * declaration of a repeatable annotation type (JLS 9.6) to indicate
+ * its containing annotation type.
*
+ * <li>The annotation type {@code @ContainerFor} is used on the
+ * declaration of a containing annotation type (JLS 9.6) to indicate
+ * the repeatable annotation type for which it serves as the
+ * containing annotation type.
+ * </ul>
+ *
+ * <p>
+ * An inconsistent pair of {@code @ContainedBy} and
+ * {@code @ContainerFor} annotations on a repeatable annotation type
+ * and its containing annotation type (JLS 9.6) will lead to
+ * compile-time errors and runtime exceptions when using reflection to
+ * read annotations of a repeatable type.
+ *
+ * @see java.lang.annotation.ContainerFor
* @since 1.8
* @jls 9.6 Annotation Types
* @jls 9.7 Annotations
@@ -39,8 +64,8 @@
@Target(ElementType.ANNOTATION_TYPE)
public @interface ContainedBy {
/**
- * The annotation type to use to store repeated values of another
- * annotation.
+ * Indicates the <em>containing annotation type</em> for the
+ * repeatable annotation type.
*/
Class<? extends Annotation> value();
}
--- a/jdk/src/share/classes/java/lang/annotation/ContainerFor.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/annotation/ContainerFor.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,10 +26,36 @@
package java.lang.annotation;
/**
- * Indicates that an annotation type is a container for repeated
- * instances of annotations of the type of the value of the
- * {@code ContainerFor}'s value element.
+ * The annotation type {@code java.lang.annotation.ContainerFor} is
+ * used to indicate that the annotation type whose declaration it
+ * (meta-)annotates is a <em>containing annotation type</em>. The
+ * value of {@code @ContainerFor} indicates the <em>repeatable
+ * annotation type</em> for the containing annotation type.
+ *
+ * <p>The pair of annotation types {@link
+ * java.lang.annotation.ContainedBy @ContainedBy} and
+ * {@code @ContainerFor} are used to indicate that annotation types
+ * are repeatable. Specifically:
*
+ * <ul>
+ * <li>The annotation type {@code @ContainedBy} is used on the
+ * declaration of a repeatable annotation type (JLS 9.6) to indicate
+ * its containing annotation type.
+ *
+ * <li>The annotation type {@code @ContainerFor} is used on the
+ * declaration of a containing annotation type (JLS 9.6) to indicate
+ * the repeatable annotation type for which it serves as the
+ * containing annotation type.
+ * </ul>
+ *
+ * <p>
+ * An inconsistent pair of {@code @ContainedBy} and
+ * {@code @ContainerFor} annotations on a repeatable annotation type
+ * and its containing annotation type (JLS 9.6) will lead to
+ * compile-time errors and runtime exceptions when using reflection to
+ * read annotations of a repeatable type.
+ *
+ * @see java.lang.annotation.ContainedBy
* @since 1.8
* @jls 9.6 Annotation Types
* @jls 9.7 Annotations
@@ -38,9 +64,10 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface ContainerFor {
+
/**
- * The repeating annotation type that the annotation type
- * annotated with this annotation is a container for.
+ * Indicates the repeatable annotation type for the containing
+ * annotation type.
*/
Class<? extends Annotation> value();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang.annotation;
+
+import java.util.Objects;
+
+/**
+ * Thrown to indicate that an annotation type whose declaration is
+ * (meta-)annotated with a {@link ContainerFor} annotation is not, in
+ * fact, the <em>containing annotation type of the type named by {@link
+ * ContainerFor}</em>.
+ *
+ * @see java.lang.reflect.AnnotatedElement
+ * @since 1.8
+ * @jls 9.6 Annotation Types
+ * @jls 9.7 Annotations
+ */
+public class InvalidContainerAnnotationError extends AnnotationFormatError {
+ private static final long serialVersionUID = 5023L;
+
+ /**
+ * The instance of the erroneous container.
+ */
+ private transient Annotation container;
+
+ /**
+ * The type of the annotation that should be contained in the
+ * container.
+ */
+ private transient Class<? extends Annotation> annotationType;
+
+ /**
+ * Constructs a new InvalidContainerAnnotationError with the
+ * specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public InvalidContainerAnnotationError(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new InvalidContainerAnnotationError with the specified
+ * detail message and cause. Note that the detail message associated
+ * with {@code cause} is <i>not</i> automatically incorporated in
+ * this error's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, may be {@code null}
+ */
+ public InvalidContainerAnnotationError(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a new InvalidContainerAnnotationError with the
+ * specified cause and a detail message of {@code (cause == null ?
+ * null : cause.toString())} (which typically contains the class
+ * and detail message of {@code cause}).
+ *
+ * @param cause the cause, may be {@code null}
+ */
+ public InvalidContainerAnnotationError(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs InvalidContainerAnnotationError for the specified
+ * container instance and contained annotation type.
+ *
+ * @param message the detail message
+ * @param cause the cause, may be {@code null}
+ * @param container the erroneous container instance, may be
+ * {@code null}
+ * @param annotationType the annotation type intended to be
+ * contained, may be {@code null}
+ */
+ public InvalidContainerAnnotationError(String message,
+ Throwable cause,
+ Annotation container,
+ Class<? extends Annotation> annotationType) {
+ super(message, cause);
+ this.container = container;
+ this.annotationType = annotationType;
+ }
+
+ /**
+ * Returns the erroneous container.
+ *
+ * @return the erroneous container, may return {@code null}
+ */
+ public Annotation getContainer() {
+ return container;
+ }
+
+ /**
+ * Returns the annotation type intended to be contained. Returns
+ * {@code null} if the annotation type intended to be contained
+ * could not be determined.
+ *
+ * @return the annotation type intended to be contained, or {@code
+ * null} if unknown
+ */
+ public Class<? extends Annotation> getAnnotationType() {
+ return annotationType;
+ }
+}
--- a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Mon Dec 10 20:58:36 2012 -0800
@@ -30,8 +30,7 @@
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
import jdk.internal.org.objectweb.asm.*;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import sun.misc.Unsafe;
@@ -192,7 +191,7 @@
try (FileOutputStream fos = new FileOutputStream(lambdaClassName.replace('/', '.') + ".class")) {
fos.write(classBytes);
} catch (IOException ex) {
- Logger.getLogger(InnerClassLambdaMetafactory.class.getName()).log(Level.SEVERE, null, ex);
+ PlatformLogger.getLogger(InnerClassLambdaMetafactory.class.getName()).severe(ex.getMessage(), ex);
}
}
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java Mon Dec 10 20:58:36 2012 -0800
@@ -448,7 +448,7 @@
case "getDriver":
case "getDrivers":
case "deregisterDriver":
- return defc == java.sql.DriverManager.class;
+ return defc == getClass("java.sql.DriverManager");
case "newUpdater":
if (defc == java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class) return true;
if (defc == java.util.concurrent.atomic.AtomicLongFieldUpdater.class) return true;
@@ -482,4 +482,14 @@
}
return false;
}
+
+ // avoid static dependency to a class in other modules
+ private static Class<?> getClass(String cn) {
+ try {
+ return Class.forName(cn, false,
+ MethodHandleNatives.class.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new InternalError(e);
+ }
+ }
}
--- a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -184,12 +184,19 @@
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- public boolean isAnnotationPresent(
- Class<? extends Annotation> annotationClass) {
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
return getAnnotation(annotationClass) != null;
}
/**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
+ throw new AssertionError("All subclasses should override this method");
+ }
+
+ /**
* @since 1.5
*/
public Annotation[] getAnnotations() {
@@ -197,6 +204,28 @@
}
/**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
+ // Only annotations on classes are inherited, for all other
+ // objects getDeclaredAnnotation is the same as
+ // getAnnotation.
+ return getAnnotation(annotationClass);
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
+ // Only annotations on classes are inherited, for all other
+ // objects getDeclaredAnnotations is the same as
+ // getAnnotations.
+ return getAnnotations(annotationClass);
+ }
+
+ /**
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations() {
--- a/jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,11 @@
* a {@link EnumConstantNotPresentException} if the enum constant in the
* annotation is no longer present in the enum type.
*
+ * <p>Attempting to read annotations of a repeatable annotation type T
+ * that are contained in an annotation whose type is not, in fact, the
+ * containing annotation type of T will result in an
+ * InvalidContainerAnnotationError.
+ *
* <p>Finally, Attempting to read a member whose definition has evolved
* incompatibly will result in a {@link
* java.lang.annotation.AnnotationTypeMismatchException} or an
@@ -55,6 +60,7 @@
* @see java.lang.annotation.AnnotationFormatError
* @see java.lang.annotation.AnnotationTypeMismatchException
* @see java.lang.annotation.IncompleteAnnotationException
+ * @see java.lang.annotation.InvalidContainerAnnotationError
* @since 1.5
* @author Josh Bloch
*/
@@ -87,6 +93,23 @@
<T extends Annotation> T getAnnotation(Class<T> annotationClass);
/**
+ * Returns an array of all this element's annotations for the
+ * specified type if one or more of such annotation is present,
+ * else an array of length zero.
+ *
+ * The caller of this method is free to modify the returned array;
+ * it will have no effect on the arrays returned to other callers.
+ *
+ * @param annotationClass the Class object corresponding to the
+ * annotation type
+ * @return all this element's annotations for the specified annotation type if
+ * present on this element, else an array of length zero
+ * @throws NullPointerException if the given annotation class is null
+ * @since 1.8
+ */
+ <T extends Annotation> T[] getAnnotations(Class<T> annotationClass);
+
+ /**
* Returns all annotations present on this element. (Returns an array
* of length zero if this element has no annotations.) The caller of
* this method is free to modify the returned array; it will have no
@@ -98,12 +121,48 @@
Annotation[] getAnnotations();
/**
+ * Returns this element's annotation for the specified type if
+ * such an annotation is present, else null.
+ *
+ * This method ignores inherited annotations. (Returns null if no
+ * annotations are directly present on this element.)
+ *
+ * @param annotationClass the Class object corresponding to the
+ * annotation type
+ * @return this element's annotation for the specified annotation type if
+ * present on this element, else null
+ * @throws NullPointerException if the given annotation class is null
+ * @since 1.8
+ */
+ <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass);
+
+ /**
+ * Returns an array of all this element's annotations for the
+ * specified type if one or more of such annotation is directly
+ * present, else an array of length zero.
+ *
+ * This method ignores inherited annotations. (Returns
+ * an array of length zero if no annotations are directly present
+ * on this element.) The caller of this method is free to modify
+ * the returned array; it will have no effect on the arrays
+ * returned to other callers.
+ *
+ * @param annotationClass the Class object corresponding to the
+ * annotation type
+ * @return all this element's annotations for the specified annotation type if
+ * present on this element, else an array of length zero
+ * @throws NullPointerException if the given annotation class is null
+ * @since 1.8
+ */
+ <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass);
+
+ /**
* Returns all annotations that are directly present on this
- * element. Unlike the other methods in this interface, this method
- * ignores inherited annotations. (Returns an array of length zero if
- * no annotations are directly present on this element.) The caller of
- * this method is free to modify the returned array; it will have no
- * effect on the arrays returned to other callers.
+ * element. This method ignores inherited annotations. (Returns
+ * an array of length zero if no annotations are directly present
+ * on this element.) The caller of this method is free to modify
+ * the returned array; it will have no effect on the arrays
+ * returned to other callers.
*
* @return All annotations directly present on this element
* @since 1.5
--- a/jdk/src/share/classes/java/lang/reflect/Executable.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/Executable.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,11 @@
package java.lang.reflect;
import java.lang.annotation.*;
+import java.util.Collections;
import java.util.Map;
+import java.util.Objects;
import sun.reflect.annotation.AnnotationParser;
+import sun.reflect.annotation.AnnotationSupport;
import sun.reflect.generics.repository.ConstructorRepository;
/**
@@ -363,19 +366,28 @@
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
+ Objects.requireNonNull(annotationClass);
+
+ return AnnotationSupport.getOneAnnotation(declaredAnnotations(), annotationClass);
+ }
- return (T) declaredAnnotations().get(annotationClass);
+ /**
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
}
/**
* {@inheritDoc}
*/
public Annotation[] getDeclaredAnnotations() {
- return AnnotationParser.toArray(declaredAnnotations());
+ return AnnotationSupport.unpackToArray(declaredAnnotations());
}
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
--- a/jdk/src/share/classes/java/lang/reflect/Field.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/lang/reflect/Field.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,9 @@
import sun.reflect.generics.scope.ClassScope;
import java.lang.annotation.Annotation;
import java.util.Map;
+import java.util.Objects;
import sun.reflect.annotation.AnnotationParser;
+import sun.reflect.annotation.AnnotationSupport;
/**
@@ -1012,19 +1014,28 @@
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
+ Objects.requireNonNull(annotationClass);
- return (T) declaredAnnotations().get(annotationClass);
+ return AnnotationSupport.getOneAnnotation(declaredAnnotations(), annotationClass);
}
/**
- * @since 1.5
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.8
+ */
+ public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+
+ return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
+ }
+
+ /**
+ * {@inheritDoc}
*/
public Annotation[] getDeclaredAnnotations() {
- return AnnotationParser.toArray(declaredAnnotations());
+ return AnnotationSupport.unpackToArray(declaredAnnotations());
}
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
--- a/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -411,14 +411,13 @@
* Gets an InputStream for this socket.
*/
protected synchronized InputStream getInputStream() throws IOException {
- if (isClosedOrPending()) {
- throw new IOException("Socket Closed");
- }
- if (shut_rd) {
- throw new IOException("Socket input is shutdown");
- }
- if (socketInputStream == null) {
- socketInputStream = new SocketInputStream(this);
+ synchronized (fdLock) {
+ if (isClosedOrPending())
+ throw new IOException("Socket Closed");
+ if (shut_rd)
+ throw new IOException("Socket input is shutdown");
+ if (socketInputStream == null)
+ socketInputStream = new SocketInputStream(this);
}
return socketInputStream;
}
@@ -431,14 +430,13 @@
* Gets an OutputStream for this socket.
*/
protected synchronized OutputStream getOutputStream() throws IOException {
- if (isClosedOrPending()) {
- throw new IOException("Socket Closed");
- }
- if (shut_wr) {
- throw new IOException("Socket output is shutdown");
- }
- if (socketOutputStream == null) {
- socketOutputStream = new SocketOutputStream(this);
+ synchronized (fdLock) {
+ if (isClosedOrPending())
+ throw new IOException("Socket Closed");
+ if (shut_wr)
+ throw new IOException("Socket output is shutdown");
+ if (socketOutputStream == null)
+ socketOutputStream = new SocketOutputStream(this);
}
return socketOutputStream;
}
--- a/jdk/src/share/classes/java/net/NetPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/net/NetPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,8 +40,8 @@
* convention follows the hierarchical property naming convention.
* Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "foo.*" or "*" is valid,
- * "*foo" or "a*b" is not valid.
+ * signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
+ * match, while "*foo" and "a*b" do not.
* <P>
* The following table lists all the possible NetPermission target names,
* and for each provides a description of what the permission allows
--- a/jdk/src/share/classes/java/security/BasicPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/security/BasicPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -46,8 +46,8 @@
* convention follows the hierarchical property naming convention.
* An asterisk may appear by itself, or if immediately preceded by a "."
* may appear at the end of the name, to signify a wildcard match.
- * For example, "*" and "java.*" are valid, while "*java", "a*b",
- * and "java*" are not valid.
+ * For example, "*" and "java.*" signify a wildcard match, while "*java", "a*b",
+ * and "java*" do not.
* <P>
* The action string (inherited from Permission) is unused.
* Thus, BasicPermission is commonly used as the base class for
--- a/jdk/src/share/classes/java/sql/SQLPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/sql/SQLPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,8 +49,8 @@
* In addition, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
* signify a wildcard match. For example: <code>loadLibrary.*</code>
- * or <code>*</code> is valid,
- * but <code>*loadLibrary</code> or <code>a*b</code> is not valid.
+ * and <code>*</code> signify a wildcard match,
+ * while <code>*loadLibrary</code> and <code>a*b</code> do not.
* <P>
* The following table lists all the possible <code>SQLPermission</code> target names.
* The table gives a description of what the permission allows
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/Base64.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,1316 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import java.io.FilterOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * This class consists exclusively of static methods for obtaining
+ * encoders and decoders for the Base64 encoding scheme. The
+ * implementation of this class supports the following types of Base64
+ * as specified in
+ * <a href="http://www.ietf.org/rfc/rfc4648.txt">RFC 4648</a> and
+ * <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>.
+ *
+ * <p>
+ * <ul>
+ * <a name="basic">
+ * <li><b>Basic</b>
+ * <p> Uses "The Base64 Alphabet" as specified in Table 1 of
+ * RFC 4648 and RFC 2045 for encoding and decoding operation.
+ * The encoder does not add any line feed (line separator)
+ * character. The decoder rejects data that contains characters
+ * outside the base64 alphabet.</p></li>
+ *
+ * <a name="url">
+ * <li><b>URL and Filename safe</b>
+ * <p> Uses the "URL and Filename safe Base64 Alphabet" as specified
+ * in Table 2 of RFC 4648 for encoding and decoding. The
+ * encoder does not add any line feed (line separator) character.
+ * The decoder rejects data that contains characters outside the
+ * base64 alphabet.</p></li>
+ *
+ * <a name="mime">
+ * <li><b>MIME</b>
+ * <p> Uses the "The Base64 Alphabet" as specified in Table 1 of
+ * RFC 2045 for encoding and decoding operation. The encoded output
+ * must be represented in lines of no more than 76 characters each
+ * and uses a carriage return {@code '\r'} followed immediately by
+ * a linefeed {@code '\n'} as the line separator. All line separators
+ * or other characters not found in the base64 alphabet table are
+ * ignored in decoding operation.</p></li>
+ * </ul>
+ *
+ * <p> Unless otherwise noted, passing a {@code null} argument to a
+ * method of this class will cause a {@link java.lang.NullPointerException
+ * NullPointerException} to be thrown.
+ *
+ * @author Xueming Shen
+ * @since 1.8
+ */
+
+public class Base64 {
+
+ private Base64() {}
+
+ /**
+ * Returns a {@link Encoder} that encodes using the
+ * <a href="#basic">Basic</a> type base64 encoding scheme.
+ *
+ * @return A Base64 encoder.
+ */
+ public static Encoder getEncoder() {
+ return Encoder.RFC4648;
+ }
+
+ /**
+ * Returns a {@link Encoder} that encodes using the
+ * <a href="#url">URL and Filename safe</a> type base64
+ * encoding scheme.
+ *
+ * @return A Base64 encoder.
+ */
+ public static Encoder getUrlEncoder() {
+ return Encoder.RFC4648_URLSAFE;
+ }
+
+ /**
+ * Returns a {@link Encoder} that encodes using the
+ * <a href="#mime">MIME</a> type base64 encoding scheme.
+ *
+ * @return A Base64 encoder.
+ */
+ public static Encoder getMimeEncoder() {
+ return Encoder.RFC2045;
+ }
+
+ /**
+ * Returns a {@link Encoder} that encodes using the
+ * <a href="#mime">MIME</a> type base64 encoding scheme
+ * with specified line length and line separators.
+ *
+ * @param lineLength
+ * the length of each output line (rounded down to nearest multiple
+ * of 4). If {@code lineLength <= 0} the output will not be separated
+ * in lines
+ * @param lineSeparator
+ * the line separator for each output line
+ *
+ * @return A Base64 encoder.
+ *
+ * @throws IllegalArgumentException if {@code lineSeparator} includes any
+ * character of "The Base64 Alphabet" as specified in Table 1 of
+ * RFC 2045.
+ */
+ public static Encoder getEncoder(int lineLength, byte[] lineSeparator) {
+ Objects.requireNonNull(lineSeparator);
+ int[] base64 = Decoder.fromBase64;
+ for (byte b : lineSeparator) {
+ if (base64[b & 0xff] != -1)
+ throw new IllegalArgumentException(
+ "Illegal base64 line separator character 0x" + Integer.toString(b, 16));
+ }
+ return new Encoder(false, lineSeparator, lineLength >> 2 << 2);
+ }
+
+ /**
+ * Returns a {@link Decoder} that decodes using the
+ * <a href="#basic">Basic</a> type base64 encoding scheme.
+ *
+ * @return A Base64 decoder.
+ */
+ public static Decoder getDecoder() {
+ return Decoder.RFC4648;
+ }
+
+ /**
+ * Returns a {@link Decoder} that decodes using the
+ * <a href="#url">URL and Filename safe</a> type base64
+ * encoding scheme.
+ *
+ * @return A Base64 decoder.
+ */
+ public static Decoder getUrlDecoder() {
+ return Decoder.RFC4648_URLSAFE;
+ }
+
+ /**
+ * Returns a {@link Decoder} that decodes using the
+ * <a href="#mime">MIME</a> type base64 decoding scheme.
+ *
+ * @return A Base64 decoder.
+ */
+ public static Decoder getMimeDecoder() {
+ return Decoder.RFC2045;
+ }
+
+ /**
+ * This class implements an encoder for encoding byte data using
+ * the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
+ *
+ * <p> Instances of {@link Encoder} class are safe for use by
+ * multiple concurrent threads.
+ *
+ * <p> Unless otherwise noted, passing a {@code null} argument to
+ * a method of this class will cause a
+ * {@link java.lang.NullPointerException NullPointerException} to
+ * be thrown.
+ *
+ * @see Decoder
+ * @since 1.8
+ */
+ public static class Encoder {
+
+ private final byte[] newline;
+ private final int linemax;
+ private final boolean isURL;
+
+ private Encoder(boolean isURL, byte[] newline, int linemax) {
+ this.isURL = isURL;
+ this.newline = newline;
+ this.linemax = linemax;
+ }
+
+ /**
+ * This array is a lookup table that translates 6-bit positive integer
+ * index values into their "Base64 Alphabet" equivalents as specified
+ * in "Table 1: The Base64 Alphabet" of RFC 2045 (and RFC 4648).
+ */
+ private static final char[] toBase64 = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
+ };
+
+ /**
+ * It's the lookup table for "URL and Filename safe Base64" as specified
+ * in Table 2 of the RFC 4648, with the '+' and '/' changed to '-' and
+ * '_'. This table is used when BASE64_URL is specified.
+ */
+ private static final char[] toBase64URL = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'
+ };
+
+ private static final int MIMELINEMAX = 76;
+ private static final byte[] CRLF = new byte[] {'\r', '\n'};
+
+ static final Encoder RFC4648 = new Encoder(false, null, -1);
+ static final Encoder RFC4648_URLSAFE = new Encoder(true, null, -1);
+ static final Encoder RFC2045 = new Encoder(false, CRLF, MIMELINEMAX);
+
+ /**
+ * Encodes all bytes from the specified byte array into a newly-allocated
+ * byte array using the {@link Base64} encoding scheme. The returned byte
+ * array is of the length of the resulting bytes.
+ *
+ * @param src
+ * the byte array to encode
+ * @return A newly-allocated byte array containing the resulting
+ * encoded bytes.
+ */
+ public byte[] encode(byte[] src) {
+ int len = 4 * ((src.length + 2) / 3); // dst array size
+ if (linemax > 0) // line separators
+ len += (len - 1) / linemax * newline.length;
+ byte[] dst = new byte[len];
+ int ret = encode0(src, 0, src.length, dst);
+ if (ret != dst.length)
+ return Arrays.copyOf(dst, ret);
+ return dst;
+ }
+
+ /**
+ * Encodes all bytes from the specified byte array using the
+ * {@link Base64} encoding scheme, writing the resulting bytes to the
+ * given output byte array, starting at offset 0.
+ *
+ * <p> It is the responsibility of the invoker of this method to make
+ * sure the output byte array {@code dst} has enough space for encoding
+ * all bytes from the input byte array. No bytes will be written to the
+ * output byte array if the output byte array is not big enough.
+ *
+ * @param src
+ * the byte array to encode
+ * @param dst
+ * the output byte array
+ * @return The number of bytes written to the output byte array
+ *
+ * @throws IllegalArgumentException if {@code dst} does not have enough
+ * space for encoding all input bytes.
+ */
+ public int encode(byte[] src, byte[] dst) {
+ int len = 4 * ((src.length + 2) / 3); // dst array size
+ if (linemax > 0) {
+ len += (len - 1) / linemax * newline.length;
+ }
+ if (dst.length < len)
+ throw new IllegalArgumentException(
+ "Output byte array is too small for encoding all input bytes");
+ return encode0(src, 0, src.length, dst);
+ }
+
+ /**
+ * Encodes the specified byte array into a String using the {@link Base64}
+ * encoding scheme.
+ *
+ * <p> This method first encodes all input bytes into a base64 encoded
+ * byte array and then constructs a new String by using the encoded byte
+ * array and the {@link java.nio.charset.StandardCharsets.ISO_8859_1 ISO-8859-1}
+ * charset.
+ *
+ * <p> In other words, an invocation of this method has exactly the same
+ * effect as invoking
+ * {@code new String(encode(src), StandardCharsets.ISO_8859_1)}.
+ *
+ * @param src
+ * the byte array to encode
+ * @return A String containing the resulting Base64 encoded characters
+ */
+ @SuppressWarnings("deprecation")
+ public String encodeToString(byte[] src) {
+ byte[] encoded = encode(src);
+ return new String(encoded, 0, 0, encoded.length);
+ }
+
+ /**
+ * Encodes all remaining bytes from the specified byte buffer into
+ * a newly-allocated ByteBuffer using the {@link Base64} encoding
+ * scheme.
+ *
+ * Upon return, the source buffer's position will be updated to
+ * its limit; its limit will not have been changed. The returned
+ * output buffer's position will be zero and its limit will be the
+ * number of resulting encoded bytes.
+ *
+ * @param buffer
+ * the source ByteBuffer to encode
+ * @return A newly-allocated byte buffer containing the encoded bytes.
+ */
+ public ByteBuffer encode(ByteBuffer buffer) {
+ int len = 4 * ((buffer.remaining() + 2) / 3);
+ if (linemax > 0)
+ len += (len - 1) / linemax * newline.length;
+ byte[] dst = new byte[len];
+ int ret = 0;
+ if (buffer.hasArray()) {
+ ret = encode0(buffer.array(),
+ buffer.arrayOffset() + buffer.position(),
+ buffer.arrayOffset() + buffer.limit(),
+ dst);
+ buffer.position(buffer.limit());
+ } else {
+ byte[] src = new byte[buffer.remaining()];
+ buffer.get(src);
+ ret = encode0(src, 0, src.length, dst);
+ }
+ if (ret != dst.length)
+ dst = Arrays.copyOf(dst, ret);
+ return ByteBuffer.wrap(dst);
+ }
+
+ /**
+ * Encodes as many bytes as possible from the input byte buffer
+ * using the {@link Base64} encoding scheme, writing the resulting
+ * bytes to the given output byte buffer.
+ *
+ * <p>The buffers are read from, and written to, starting at their
+ * current positions. Upon return, the input and output buffers'
+ * positions will be advanced to reflect the bytes read and written,
+ * but their limits will not be modified.
+ *
+ * <p>The encoding operation will stop and return if either all
+ * remaining bytes in the input buffer have been encoded and written
+ * to the output buffer, or the output buffer has insufficient space
+ * to encode any more input bytes. The encoding operation can be
+ * continued, if there is more bytes in input buffer to be encoded,
+ * by invoking this method again with an output buffer that has more
+ * {@linkplain Buffer#remaining remaining} bytes. This is typically
+ * done by draining any encoded bytes from the output buffer. The
+ * value returned from last invocation needs to be passed in as the
+ * third parameter {@code bytesOut} if it is to continue an unfinished
+ * encoding, 0 otherwise.
+ *
+ * <p><b>Recommended Usage Example</b>
+ * <pre>
+ * ByteBuffer src = ...;
+ * ByteBuffer dst = ...;
+ * Base64.Encoder enc = Base64.getMimeDecoder();
+ *
+ * int bytesOut = 0;
+ * while (src.hasRemaining()) {
+ * // clear output buffer for decoding
+ * dst.clear();
+ * bytesOut = enc.encode(src, dst, bytesOut);
+ *
+ * // read encoded bytes out of "dst"
+ * dst.flip();
+ * ...
+ * }
+ * </pre>
+ *
+ * @param src
+ * the input byte buffer to encode
+ * @param dst
+ * the output byte buffer
+ * @param bytesOut
+ * the return value of last invocation if this is to continue
+ * an unfinished encoding operation, 0 otherwise
+ * @return The sum total of {@code bytesOut} and the number of bytes
+ * written to the output ByteBuffer during this invocation.
+ */
+ public int encode(ByteBuffer src, ByteBuffer dst, int bytesOut) {
+ if (src.hasArray() && dst.hasArray())
+ return encodeArray(src, dst, bytesOut);
+ return encodeBuffer(src, dst, bytesOut);
+ }
+
+ /**
+ * Wraps an output stream for encoding byte data using the {@link Base64}
+ * encoding scheme.
+ *
+ * <p> It is recommended to promptly close the returned output stream after
+ * use, during which it will flush all possible leftover bytes to the underlying
+ * output stream. Closing the returned output stream will close the underlying
+ * output stream.
+ *
+ * @param os
+ * the output stream.
+ * @return the output stream for encoding the byte data into the
+ * specified Base64 encoded format
+ */
+ public OutputStream wrap(OutputStream os) {
+ return new EncOutputStream(os, isURL ? toBase64URL : toBase64,
+ newline, linemax);
+ }
+
+ private int encodeArray(ByteBuffer src, ByteBuffer dst, int bytesOut) {
+ char[] base64 = isURL? toBase64URL : toBase64;
+ byte[] sa = src.array();
+ int sp = src.arrayOffset() + src.position();
+ int sl = src.arrayOffset() + src.limit();
+ byte[] da = dst.array();
+ int dp = dst.arrayOffset() + dst.position();
+ int dl = dst.arrayOffset() + dst.limit();
+ int dp00 = dp;
+ int dpos = 0; // dp of each line
+ if (linemax > 0 && bytesOut > 0)
+ dpos = bytesOut % (linemax + newline.length);
+ try {
+ if (dpos == linemax && sp < src.limit()) {
+ if (dp + newline.length > dl)
+ return dp - dp00 + bytesOut;
+ for (byte b : newline){
+ dst.put(dp++, b);
+ }
+ dpos = 0;
+ }
+ sl = sp + (sl - sp) / 3 * 3;
+ while (sp < sl) {
+ int slen = (linemax > 0) ? (linemax - dpos) / 4 * 3
+ : sl - sp;
+ int sl0 = Math.min(sp + slen, sl);
+ for (int sp0 = sp, dp0 = dp ; sp0 < sl0; ) {
+ if (dp0 + 4 > dl) {
+ sp = sp0; dp = dp0;
+ return dp0 - dp00 + bytesOut;
+ }
+ int bits = (sa[sp0++] & 0xff) << 16 |
+ (sa[sp0++] & 0xff) << 8 |
+ (sa[sp0++] & 0xff);
+ da[dp0++] = (byte)base64[(bits >>> 18) & 0x3f];
+ da[dp0++] = (byte)base64[(bits >>> 12) & 0x3f];
+ da[dp0++] = (byte)base64[(bits >>> 6) & 0x3f];
+ da[dp0++] = (byte)base64[bits & 0x3f];
+ }
+ int n = (sl0 - sp) / 3 * 4;
+ dpos += n;
+ dp += n;
+ sp = sl0;
+ if (dpos == linemax && sp < src.limit()) {
+ if (dp + newline.length > dl)
+ return dp - dp00 + bytesOut;
+ for (byte b : newline){
+ da[dp++] = b;
+ }
+ dpos = 0;
+ }
+ }
+ sl = src.arrayOffset() + src.limit();
+ if (sp < sl && dl >= dp + 4) { // 1 or 2 leftover bytes
+ int b0 = sa[sp++] & 0xff;
+ da[dp++] = (byte)base64[b0 >> 2];
+ if (sp == sl) {
+ da[dp++] = (byte)base64[(b0 << 4) & 0x3f];
+ da[dp++] = '=';
+ da[dp++] = '=';
+ } else {
+ int b1 = sa[sp++] & 0xff;
+ da[dp++] = (byte)base64[(b0 << 4) & 0x3f | (b1 >> 4)];
+ da[dp++] = (byte)base64[(b1 << 2) & 0x3f];
+ da[dp++] = '=';
+ }
+ }
+ return dp - dp00 + bytesOut;
+ } finally {
+ src.position(sp - src.arrayOffset());
+ dst.position(dp - dst.arrayOffset());
+ }
+ }
+
+ private int encodeBuffer(ByteBuffer src, ByteBuffer dst, int bytesOut) {
+ char[] base64 = isURL? toBase64URL : toBase64;
+ int sp = src.position();
+ int sl = src.limit();
+ int dp = dst.position();
+ int dl = dst.limit();
+ int dp00 = dp;
+
+ int dpos = 0; // dp of each line
+ if (linemax > 0 && bytesOut > 0)
+ dpos = bytesOut % (linemax + newline.length);
+ try {
+ if (dpos == linemax && sp < src.limit()) {
+ if (dp + newline.length > dl)
+ return dp - dp00 + bytesOut;
+ for (byte b : newline){
+ dst.put(dp++, b);
+ }
+ dpos = 0;
+ }
+ sl = sp + (sl - sp) / 3 * 3;
+ while (sp < sl) {
+ int slen = (linemax > 0) ? (linemax - dpos) / 4 * 3
+ : sl - sp;
+ int sl0 = Math.min(sp + slen, sl);
+ for (int sp0 = sp, dp0 = dp ; sp0 < sl0; ) {
+ if (dp0 + 4 > dl) {
+ sp = sp0; dp = dp0;
+ return dp0 - dp00 + bytesOut;
+ }
+ int bits = (src.get(sp0++) & 0xff) << 16 |
+ (src.get(sp0++) & 0xff) << 8 |
+ (src.get(sp0++) & 0xff);
+ dst.put(dp0++, (byte)base64[(bits >>> 18) & 0x3f]);
+ dst.put(dp0++, (byte)base64[(bits >>> 12) & 0x3f]);
+ dst.put(dp0++, (byte)base64[(bits >>> 6) & 0x3f]);
+ dst.put(dp0++, (byte)base64[bits & 0x3f]);
+ }
+ int n = (sl0 - sp) / 3 * 4;
+ dpos += n;
+ dp += n;
+ sp = sl0;
+ if (dpos == linemax && sp < src.limit()) {
+ if (dp + newline.length > dl)
+ return dp - dp00 + bytesOut;
+ for (byte b : newline){
+ dst.put(dp++, b);
+ }
+ dpos = 0;
+ }
+ }
+ if (sp < src.limit() && dl >= dp + 4) { // 1 or 2 leftover bytes
+ int b0 = src.get(sp++) & 0xff;
+ dst.put(dp++, (byte)base64[b0 >> 2]);
+ if (sp == src.limit()) {
+ dst.put(dp++, (byte)base64[(b0 << 4) & 0x3f]);
+ dst.put(dp++, (byte)'=');
+ dst.put(dp++, (byte)'=');
+ } else {
+ int b1 = src.get(sp++) & 0xff;
+ dst.put(dp++, (byte)base64[(b0 << 4) & 0x3f | (b1 >> 4)]);
+ dst.put(dp++, (byte)base64[(b1 << 2) & 0x3f]);
+ dst.put(dp++, (byte)'=');
+ }
+ }
+ return dp - dp00 + bytesOut;
+ } finally {
+ src.position(sp);
+ dst.position(dp);
+ }
+ }
+
+ private int encode0(byte[] src, int off, int end, byte[] dst) {
+ char[] base64 = isURL ? toBase64URL : toBase64;
+ int sp = off;
+ int slen = (end - off) / 3 * 3;
+ int sl = off + slen;
+ if (linemax > 0 && slen > linemax / 4 * 3)
+ slen = linemax / 4 * 3;
+ int dp = 0;
+ while (sp < sl) {
+ int sl0 = Math.min(sp + slen, sl);
+ for (int sp0 = sp, dp0 = dp ; sp0 < sl0; ) {
+ int bits = (src[sp0++] & 0xff) << 16 |
+ (src[sp0++] & 0xff) << 8 |
+ (src[sp0++] & 0xff);
+ dst[dp0++] = (byte)base64[(bits >>> 18) & 0x3f];
+ dst[dp0++] = (byte)base64[(bits >>> 12) & 0x3f];
+ dst[dp0++] = (byte)base64[(bits >>> 6) & 0x3f];
+ dst[dp0++] = (byte)base64[bits & 0x3f];
+ }
+ int dlen = (sl0 - sp) / 3 * 4;
+ dp += dlen;
+ sp = sl0;
+ if (dlen == linemax && sp < end) {
+ for (byte b : newline){
+ dst[dp++] = b;
+ }
+ }
+ }
+ if (sp < end) { // 1 or 2 leftover bytes
+ int b0 = src[sp++] & 0xff;
+ dst[dp++] = (byte)base64[b0 >> 2];
+ if (sp == end) {
+ dst[dp++] = (byte)base64[(b0 << 4) & 0x3f];
+ dst[dp++] = '=';
+ dst[dp++] = '=';
+ } else {
+ int b1 = src[sp++] & 0xff;
+ dst[dp++] = (byte)base64[(b0 << 4) & 0x3f | (b1 >> 4)];
+ dst[dp++] = (byte)base64[(b1 << 2) & 0x3f];
+ dst[dp++] = '=';
+ }
+ }
+ return dp;
+ }
+ }
+
+ /**
+ * This class implements a decoder for decoding byte data using the
+ * Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
+ *
+ * <p> Instances of {@link Decoder} class are safe for use by
+ * multiple concurrent threads.
+ *
+ * <p> Unless otherwise noted, passing a {@code null} argument to
+ * a method of this class will cause a
+ * {@link java.lang.NullPointerException NullPointerException} to
+ * be thrown.
+ *
+ * @see Encoder
+ * @since 1.8
+ */
+ public static class Decoder {
+
+ private final boolean isURL;
+ private final boolean isMIME;
+
+ private Decoder(boolean isURL, boolean isMIME) {
+ this.isURL = isURL;
+ this.isMIME = isMIME;
+ }
+
+ /**
+ * Lookup table for decoding unicode characters drawn from the
+ * "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into
+ * their 6-bit positive integer equivalents. Characters that
+ * are not in the Base64 alphabet but fall within the bounds of
+ * the array are encoded to -1.
+ *
+ */
+ private static final int[] fromBase64 = new int[256];
+ static {
+ Arrays.fill(fromBase64, -1);
+ for (int i = 0; i < Encoder.toBase64.length; i++)
+ fromBase64[Encoder.toBase64[i]] = i;
+ fromBase64['='] = -2;
+ }
+
+ /**
+ * Lookup table for decoding "URL and Filename safe Base64 Alphabet"
+ * as specified in Table2 of the RFC 4648.
+ */
+ private static final int[] fromBase64URL = new int[256];
+
+ static {
+ Arrays.fill(fromBase64URL, -1);
+ for (int i = 0; i < Encoder.toBase64URL.length; i++)
+ fromBase64URL[Encoder.toBase64URL[i]] = i;
+ fromBase64URL['='] = -2;
+ }
+
+ static final Decoder RFC4648 = new Decoder(false, false);
+ static final Decoder RFC4648_URLSAFE = new Decoder(true, false);
+ static final Decoder RFC2045 = new Decoder(false, true);
+
+ /**
+ * Decodes all bytes from the input byte array using the {@link Base64}
+ * encoding scheme, writing the results into a newly-allocated output
+ * byte array. The returned byte array is of the length of the resulting
+ * bytes.
+ *
+ * @param src
+ * the byte array to decode
+ *
+ * @return A newly-allocated byte array containing the decoded bytes.
+ *
+ * @throws IllegalArgumentException
+ * if {@code src} is not in valid Base64 scheme
+ */
+ public byte[] decode(byte[] src) {
+ byte[] dst = new byte[outLength(src, 0, src.length)];
+ int ret = decode0(src, 0, src.length, dst);
+ if (ret != dst.length) {
+ dst = Arrays.copyOf(dst, ret);
+ }
+ return dst;
+ }
+
+ /**
+ * Decodes a Base64 encoded String into a newly-allocated byte array
+ * using the {@link Base64} encoding scheme.
+ *
+ * <p> An invocation of this method has exactly the same effect as invoking
+ * {@code return decode(src.getBytes(StandardCharsets.ISO_8859_1))}
+ *
+ * @param src
+ * the string to decode
+ *
+ * @return A newly-allocated byte array containing the decoded bytes.
+ *
+ * @throws IllegalArgumentException
+ * if {@code src} is not in valid Base64 scheme
+ */
+ public byte[] decode(String src) {
+ return decode(src.getBytes(StandardCharsets.ISO_8859_1));
+ }
+
+ /**
+ * Decodes all bytes from the input byte array using the {@link Base64}
+ * encoding scheme, writing the results into the given output byte array,
+ * starting at offset 0.
+ *
+ * <p> It is the responsibility of the invoker of this method to make
+ * sure the output byte array {@code dst} has enough space for decoding
+ * all bytes from the input byte array. No bytes will be be written to
+ * the output byte array if the output byte array is not big enough.
+ *
+ * <p> If the input byte array is not in valid Base64 encoding scheme
+ * then some bytes may have been written to the output byte array before
+ * IllegalargumentException is thrown.
+ *
+ * @param src
+ * the byte array to decode
+ * @param dst
+ * the output byte array
+ *
+ * @return The number of bytes written to the output byte array
+ *
+ * @throws IllegalArgumentException
+ * if {@code src} is not in valid Base64 scheme, or {@code dst}
+ * does not have enough space for decoding all input bytes.
+ */
+ public int decode(byte[] src, byte[] dst) {
+ int len = outLength(src, 0, src.length);
+ if (dst.length < len)
+ throw new IllegalArgumentException(
+ "Output byte array is too small for decoding all input bytes");
+ return decode0(src, 0, src.length, dst);
+ }
+
+ /**
+ * Decodes all bytes from the input byte buffer using the {@link Base64}
+ * encoding scheme, writing the results into a newly-allocated ByteBuffer.
+ *
+ * <p> Upon return, the source buffer's position will be updated to
+ * its limit; its limit will not have been changed. The returned
+ * output buffer's position will be zero and its limit will be the
+ * number of resulting decoded bytes
+ *
+ * @param buffer
+ * the ByteBuffer to decode
+ *
+ * @return A newly-allocated byte buffer containing the decoded bytes
+ *
+ * @throws IllegalArgumentException
+ * if {@code src} is not in valid Base64 scheme.
+ */
+ public ByteBuffer decode(ByteBuffer buffer) {
+ int pos0 = buffer.position();
+ try {
+ byte[] src;
+ int sp, sl;
+ if (buffer.hasArray()) {
+ src = buffer.array();
+ sp = buffer.arrayOffset() + buffer.position();
+ sl = buffer.arrayOffset() + buffer.limit();
+ buffer.position(buffer.limit());
+ } else {
+ src = new byte[buffer.remaining()];
+ buffer.get(src);
+ sp = 0;
+ sl = src.length;
+ }
+ byte[] dst = new byte[outLength(src, sp, sl)];
+ return ByteBuffer.wrap(dst, 0, decode0(src, sp, sl, dst));
+ } catch (IllegalArgumentException iae) {
+ buffer.position(pos0);
+ throw iae;
+ }
+ }
+
+ /**
+ * Decodes as many bytes as possible from the input byte buffer
+ * using the {@link Base64} encoding scheme, writing the resulting
+ * bytes to the given output byte buffer.
+ *
+ * <p>The buffers are read from, and written to, starting at their
+ * current positions. Upon return, the input and output buffers'
+ * positions will be advanced to reflect the bytes read and written,
+ * but their limits will not be modified.
+ *
+ * <p> If the input buffer is not in valid Base64 encoding scheme
+ * then some bytes may have been written to the output buffer
+ * before IllegalArgumentException is thrown. The positions of
+ * both input and output buffer will not be advanced in this case.
+ *
+ * <p>The decoding operation will end and return if all remaining
+ * bytes in the input buffer have been decoded and written to the
+ * output buffer.
+ *
+ * <p> The decoding operation will stop and return if the output
+ * buffer has insufficient space to decode any more input bytes.
+ * The decoding operation can be continued, if there is more bytes
+ * in input buffer to be decoded, by invoking this method again with
+ * an output buffer that has more {@linkplain Buffer#remaining remaining}
+ * bytes.This is typically done by draining any decoded bytes from the
+ * output buffer.
+ *
+ * <p><b>Recommended Usage Example</b>
+ * <pre>
+ * ByteBuffer src = ...;
+ * ByteBuffer dst = ...;
+ * Base64.Decoder dec = Base64.getDecoder();
+ *
+ * while (src.hasRemaining()) {
+ *
+ * // prepare the output byte buffer
+ * dst.clear();
+ * dec.decode(src, dst);
+ *
+ * // read bytes from the output buffer
+ * dst.flip();
+ * ...
+ * }
+ * </pre>
+ *
+ * @param src
+ * the input byte buffer to decode
+ * @param dst
+ * the output byte buffer
+ *
+ * @return The number of bytes written to the output byte buffer during
+ * this decoding invocation
+ *
+ * @throws IllegalArgumentException
+ * if {@code src} is not in valid Base64 scheme.
+ */
+ public int decode(ByteBuffer src, ByteBuffer dst) {
+ int sp0 = src.position();
+ int dp0 = dst.position();
+ try {
+ if (src.hasArray() && dst.hasArray())
+ return decodeArray(src, dst);
+ return decodeBuffer(src, dst);
+ } catch (IllegalArgumentException iae) {
+ src.position(sp0);
+ dst.position(dp0);
+ throw iae;
+ }
+ }
+
+ /**
+ * Returns an input stream for decoding {@link Base64} encoded byte stream.
+ *
+ * <p> Closing the returned input stream will close the underlying
+ * input stream.
+ *
+ * @param is
+ * the input stream
+ *
+ * @return the input stream for decoding the specified Base64 encoded
+ * byte stream
+ */
+ public InputStream wrap(InputStream is) {
+ return new DecInputStream(is, isURL ? fromBase64URL : fromBase64, isMIME);
+ }
+
+ private int decodeArray(ByteBuffer src, ByteBuffer dst) {
+ int[] base64 = isURL ? fromBase64URL : fromBase64;
+ int bits = 0;
+ int shiftto = 18; // pos of first byte of 4-byte atom
+ byte[] sa = src.array();
+ int sp = src.arrayOffset() + src.position();
+ int sl = src.arrayOffset() + src.limit();
+ byte[] da = dst.array();
+ int dp = dst.arrayOffset() + dst.position();
+ int dl = dst.arrayOffset() + dst.limit();
+ int dp0 = dp;
+ int mark = sp;
+ boolean padding = false;
+ try {
+ while (sp < sl) {
+ int b = sa[sp++] & 0xff;
+ if ((b = base64[b]) < 0) {
+ if (b == -2) { // padding byte
+ padding = true;
+ break;
+ }
+ if (isMIME) // skip if for rfc2045
+ continue;
+ else
+ throw new IllegalArgumentException(
+ "Illegal base64 character " +
+ Integer.toString(sa[sp - 1], 16));
+ }
+ bits |= (b << shiftto);
+ shiftto -= 6;
+ if (shiftto < 0) {
+ if (dl < dp + 3)
+ return dp - dp0;
+ da[dp++] = (byte)(bits >> 16);
+ da[dp++] = (byte)(bits >> 8);
+ da[dp++] = (byte)(bits);
+ shiftto = 18;
+ bits = 0;
+ mark = sp;
+ }
+ }
+ if (shiftto == 6) {
+ if (dl - dp < 1)
+ return dp - dp0;
+ if (padding && (sp + 1 != sl || sa[sp++] != '='))
+ throw new IllegalArgumentException(
+ "Input buffer has wrong 4-byte ending unit");
+ da[dp++] = (byte)(bits >> 16);
+ mark = sp;
+ } else if (shiftto == 0) {
+ if (dl - dp < 2)
+ return dp - dp0;
+ if (padding && sp != sl)
+ throw new IllegalArgumentException(
+ "Input buffer has wrong 4-byte ending unit");
+ da[dp++] = (byte)(bits >> 16);
+ da[dp++] = (byte)(bits >> 8);
+ mark = sp;
+ } else if (padding || shiftto != 18) {
+ throw new IllegalArgumentException(
+ "Last unit does not have enough valid bits");
+ }
+ return dp - dp0;
+ } finally {
+ src.position(mark);
+ dst.position(dp);
+ }
+ }
+
+ private int decodeBuffer(ByteBuffer src, ByteBuffer dst) {
+ int[] base64 = isURL ? fromBase64URL : fromBase64;
+ int bits = 0;
+ int shiftto = 18; // pos of first byte of 4-byte atom
+ int sp = src.position();
+ int sl = src.limit();
+ int dp = dst.position();
+ int dl = dst.limit();
+ int dp0 = dp;
+ int mark = sp;
+ boolean padding = false;
+
+ try {
+ while (sp < sl) {
+ int b = src.get(sp++) & 0xff;
+ if ((b = base64[b]) < 0) {
+ if (b == -2) { // padding byte
+ padding = true;
+ break;
+ }
+ if (isMIME) // skip if for rfc2045
+ continue;
+ else
+ throw new IllegalArgumentException(
+ "Illegal base64 character " +
+ Integer.toString(src.get(sp - 1), 16));
+ }
+ bits |= (b << shiftto);
+ shiftto -= 6;
+ if (shiftto < 0) {
+ if (dl < dp + 3)
+ return dp - dp0;
+ dst.put(dp++, (byte)(bits >> 16));
+ dst.put(dp++, (byte)(bits >> 8));
+ dst.put(dp++, (byte)(bits));
+ shiftto = 18;
+ bits = 0;
+ mark = sp;
+ }
+ }
+ if (shiftto == 6) {
+ if (dl - dp < 1)
+ return dp - dp0;
+ if (padding && (sp + 1 != sl || src.get(sp++) != '='))
+ throw new IllegalArgumentException(
+ "Input buffer has wrong 4-byte ending unit");
+ dst.put(dp++, (byte)(bits >> 16));
+ mark = sp;
+ } else if (shiftto == 0) {
+ if (dl - dp < 2)
+ return dp - dp0;
+ if (padding && sp != sl)
+ throw new IllegalArgumentException(
+ "Input buffer has wrong 4-byte ending unit");
+ dst.put(dp++, (byte)(bits >> 16));
+ dst.put(dp++, (byte)(bits >> 8));
+ mark = sp;
+ } else if (padding || shiftto != 18) {
+ throw new IllegalArgumentException(
+ "Last unit does not have enough valid bits");
+ }
+ return dp - dp0;
+ } finally {
+ src.position(mark);
+ dst.position(dp);
+ }
+ }
+
+ private int outLength(byte[] src, int sp, int sl) {
+ int[] base64 = isURL ? fromBase64URL : fromBase64;
+ int paddings = 0;
+ int len = sl - sp;
+ if (len == 0)
+ return 0;
+ if (len < 2)
+ throw new IllegalArgumentException(
+ "Input byte[] should at least have 2 bytes for base64 bytes");
+ if (src[sl - 1] == '=') {
+ paddings++;
+ if (src[sl - 2] == '=')
+ paddings++;
+ }
+ if (isMIME) {
+ // scan all bytes to fill out all non-alphabet. a performance
+ // trade-off of pre-scan or Arrays.copyOf
+ int n = 0;
+ while (sp < sl) {
+ int b = src[sp++] & 0xff;
+ if (b == '=')
+ break;
+ if ((b = base64[b]) == -1)
+ n++;
+ }
+ len -= n;
+ }
+ if (paddings == 0 && (len & 0x3) != 0)
+ paddings = 4 - (len & 0x3);
+ return 3 * ((len + 3) / 4) - paddings;
+ }
+
+ private int decode0(byte[] src, int sp, int sl, byte[] dst) {
+ int[] base64 = isURL ? fromBase64URL : fromBase64;
+ int dp = 0;
+ int bits = 0;
+ int shiftto = 18; // pos of first byte of 4-byte atom
+ boolean padding = false;
+ while (sp < sl) {
+ int b = src[sp++] & 0xff;
+ if ((b = base64[b]) < 0) {
+ if (b == -2) { // padding byte
+ padding = true;
+ break;
+ }
+ if (isMIME) // skip if for rfc2045
+ continue;
+ else
+ throw new IllegalArgumentException(
+ "Illegal base64 character " +
+ Integer.toString(src[sp - 1], 16));
+ }
+ bits |= (b << shiftto);
+ shiftto -= 6;
+ if (shiftto < 0) {
+ dst[dp++] = (byte)(bits >> 16);
+ dst[dp++] = (byte)(bits >> 8);
+ dst[dp++] = (byte)(bits);
+ shiftto = 18;
+ bits = 0;
+ }
+ }
+ // reach end of byte arry or hit padding '=' characters.
+ // if '=' presents, they must be the last one or two.
+ if (shiftto == 6) { // xx==
+ if (padding && (sp + 1 != sl || src[sp] != '='))
+ throw new IllegalArgumentException(
+ "Input byte array has wrong 4-byte ending unit");
+ dst[dp++] = (byte)(bits >> 16);
+ } else if (shiftto == 0) { // xxx=
+ if (padding && sp != sl)
+ throw new IllegalArgumentException(
+ "Input byte array has wrong 4-byte ending unit");
+ dst[dp++] = (byte)(bits >> 16);
+ dst[dp++] = (byte)(bits >> 8);
+ } else if (padding || shiftto != 18) {
+ throw new IllegalArgumentException(
+ "last unit does not have enough bytes");
+ }
+ return dp;
+ }
+ }
+
+ /*
+ * An output stream for encoding bytes into the Base64.
+ */
+ private static class EncOutputStream extends FilterOutputStream {
+
+ private int leftover = 0;
+ private int b0, b1, b2;
+ private boolean closed = false;
+
+ private final char[] base64; // byte->base64 mapping
+ private final byte[] newline; // line separator, if needed
+ private final int linemax;
+ private int linepos = 0;
+
+ EncOutputStream(OutputStream os,
+ char[] base64, byte[] newline, int linemax) {
+ super(os);
+ this.base64 = base64;
+ this.newline = newline;
+ this.linemax = linemax;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ byte[] buf = new byte[1];
+ buf[0] = (byte)(b & 0xff);
+ write(buf, 0, 1);
+ }
+
+ private void checkNewline() throws IOException {
+ if (linepos == linemax) {
+ out.write(newline);
+ linepos = 0;
+ }
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (closed)
+ throw new IOException("Stream is closed");
+ if (off < 0 || len < 0 || off + len > b.length)
+ throw new ArrayIndexOutOfBoundsException();
+ if (len == 0)
+ return;
+ if (leftover != 0) {
+ if (leftover == 1) {
+ b1 = b[off++] & 0xff;
+ len--;
+ if (len == 0) {
+ leftover++;
+ return;
+ }
+ }
+ b2 = b[off++] & 0xff;
+ len--;
+ checkNewline();
+ out.write(base64[b0 >> 2]);
+ out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]);
+ out.write(base64[(b1 << 2) & 0x3f | (b2 >> 6)]);
+ out.write(base64[b2 & 0x3f]);
+ linepos += 4;
+ }
+ int nBits24 = len / 3;
+ leftover = len - (nBits24 * 3);
+ while (nBits24-- > 0) {
+ checkNewline();
+ int bits = (b[off++] & 0xff) << 16 |
+ (b[off++] & 0xff) << 8 |
+ (b[off++] & 0xff);
+ out.write(base64[(bits >>> 18) & 0x3f]);
+ out.write(base64[(bits >>> 12) & 0x3f]);
+ out.write(base64[(bits >>> 6) & 0x3f]);
+ out.write(base64[bits & 0x3f]);
+ linepos += 4;
+ }
+ if (leftover == 1) {
+ b0 = b[off++] & 0xff;
+ } else if (leftover == 2) {
+ b0 = b[off++] & 0xff;
+ b1 = b[off++] & 0xff;
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ if (leftover == 1) {
+ checkNewline();
+ out.write(base64[b0 >> 2]);
+ out.write(base64[(b0 << 4) & 0x3f]);
+ out.write('=');
+ out.write('=');
+ } else if (leftover == 2) {
+ checkNewline();
+ out.write(base64[b0 >> 2]);
+ out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]);
+ out.write(base64[(b1 << 2) & 0x3f]);
+ out.write('=');
+ }
+ leftover = 0;
+ out.close();
+ }
+ }
+ }
+
+ /*
+ * An input stream for decoding Base64 bytes
+ */
+ private static class DecInputStream extends InputStream {
+
+ private final InputStream is;
+ private final boolean isMIME;
+ private final int[] base64; // base64 -> byte mapping
+ private int bits = 0; // 24-bit buffer for decoding
+ private int nextin = 18; // next available "off" in "bits" for input;
+ // -> 18, 12, 6, 0
+ private int nextout = -8; // next available "off" in "bits" for output;
+ // -> 8, 0, -8 (no byte for output)
+ private boolean eof = false;
+ private boolean closed = false;
+
+ DecInputStream(InputStream is, int[] base64, boolean isMIME) {
+ this.is = is;
+ this.base64 = base64;
+ this.isMIME = isMIME;
+ }
+
+ private byte[] sbBuf = new byte[1];
+
+ @Override
+ public int read() throws IOException {
+ return read(sbBuf, 0, 1) == -1 ? -1 : sbBuf[0] & 0xff;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (closed)
+ throw new IOException("Stream is closed");
+ if (eof && nextout < 0) // eof and no leftover
+ return -1;
+ if (off < 0 || len < 0 || len > b.length - off)
+ throw new IndexOutOfBoundsException();
+ int oldOff = off;
+ if (nextout >= 0) { // leftover output byte(s) in bits buf
+ do {
+ if (len == 0)
+ return off - oldOff;
+ b[off++] = (byte)(bits >> nextout);
+ len--;
+ nextout -= 8;
+ } while (nextout >= 0);
+ bits = 0;
+ }
+ while (len > 0) {
+ int v = is.read();
+ if (v == -1) {
+ eof = true;
+ if (nextin != 18)
+ throw new IOException("Base64 stream has un-decoded dangling byte(s).");
+ if (off == oldOff)
+ return -1;
+ else
+ return off - oldOff;
+ }
+ if (v == '=') { // padding byte(s)
+ if (nextin != 6 && nextin != 0) {
+ throw new IOException("Illegal base64 ending sequence:" + nextin);
+ }
+ b[off++] = (byte)(bits >> (16));
+ len--;
+ if (nextin == 0) { // only one padding byte
+ if (len == 0) { // no enough output space
+ bits >>= 8; // shift to lowest byte
+ nextout = 0;
+ } else {
+ b[off++] = (byte) (bits >> 8);
+ }
+ }
+ eof = true;
+ break;
+ }
+ if ((v = base64[v]) == -1) {
+ if (isMIME) // skip if for rfc2045
+ continue;
+ else
+ throw new IOException("Illegal base64 character " +
+ Integer.toString(v, 16));
+ }
+ bits |= (v << nextin);
+ if (nextin == 0) {
+ nextin = 18; // clear for next
+ nextout = 16;
+ while (nextout >= 0) {
+ b[off++] = (byte)(bits >> nextout);
+ len--;
+ nextout -= 8;
+ if (len == 0 && nextout >= 0) { // don't clean "bits"
+ return off - oldOff;
+ }
+ }
+ bits = 0;
+ } else {
+ nextin -= 6;
+ }
+ }
+ return off - oldOff;
+ }
+
+ @Override
+ public int available() throws IOException {
+ if (closed)
+ throw new IOException("Stream is closed");
+ return is.available(); // TBD:
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ is.close();
+ }
+ }
+ }
+}
--- a/jdk/src/share/classes/java/util/Currency.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/util/Currency.java Mon Dec 10 20:58:36 2012 -0800
@@ -56,12 +56,13 @@
* no public constructor. You obtain a <code>Currency</code> instance using
* the <code>getInstance</code> methods.
* <p>
- * Users can supersede the Java runtime currency data by creating a properties
- * file named <code><JAVA_HOME>/lib/currency.properties</code>. The contents
- * of the properties file are key/value pairs of the ISO 3166 country codes
- * and the ISO 4217 currency data respectively. The value part consists of
- * three ISO 4217 values of a currency, i.e., an alphabetic code, a numeric
- * code, and a minor unit. Those three ISO 4217 values are separated by commas.
+ * Users can supersede the Java runtime currency data by means of the system
+ * property {@code java.util.currency.data}. If this system property is
+ * defined then its value is the location of a properties file, the contents of
+ * which are key/value pairs of the ISO 3166 country codes and the ISO 4217
+ * currency data respectively. The value part consists of three ISO 4217 values
+ * of a currency, i.e., an alphabetic code, a numeric code, and a minor unit.
+ * Those three ISO 4217 values are separated by commas.
* The lines which start with '#'s are considered comment lines. An optional UTC
* timestamp may be specified per currency entry if users need to specify a
* cutover date indicating when the new data comes into effect. The timestamp is
@@ -246,10 +247,13 @@
}
// look for the properties file for overrides
+ String propsFile = System.getProperty("java.util.currency.data");
+ if (propsFile == null) {
+ propsFile = homeDir + File.separator + "lib" +
+ File.separator + "currency.properties";
+ }
try {
- File propFile = new File(homeDir + File.separator +
- "lib" + File.separator +
- "currency.properties");
+ File propFile = new File(propsFile);
if (propFile.exists()) {
Properties props = new Properties();
try (FileReader fr = new FileReader(propFile)) {
--- a/jdk/src/share/classes/java/util/PropertyPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/util/PropertyPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -48,8 +48,8 @@
* convention follows the hierarchical property naming convention.
* Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "java.*" or "*" is valid,
- * "*java" or "a*b" is not valid.
+ * signify a wildcard match. For example: "java.*" and "*" signify a wildcard
+ * match, while "*java" and "a*b" do not.
* <P>
* <P>
* The actions to be granted are passed to the constructor in a string containing
--- a/jdk/src/share/classes/java/util/TreeMap.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/util/TreeMap.java Mon Dec 10 20:58:36 2012 -0800
@@ -1759,7 +1759,7 @@
public Set<Map.Entry<K,V>> entrySet() {
EntrySetView es = entrySetView;
- return (es != null) ? es : new AscendingEntrySetView();
+ return (es != null) ? es : (entrySetView = new AscendingEntrySetView());
}
TreeMap.Entry<K,V> subLowest() { return absLowest(); }
@@ -1840,7 +1840,7 @@
public Set<Map.Entry<K,V>> entrySet() {
EntrySetView es = entrySetView;
- return (es != null) ? es : new DescendingEntrySetView();
+ return (es != null) ? es : (entrySetView = new DescendingEntrySetView());
}
TreeMap.Entry<K,V> subLowest() { return absHighest(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/BinaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon two operands yielding a result. The operands and the result
+ * are all of the same type.
+ *
+ * @param <T> the type of operands to {@code operate} and of the result
+ *
+ * @since 1.8
+ */
+public interface BinaryOperator<T> {
+
+ /**
+ * Returns the result of the operation upon the operands.
+ * The operands are named {@code left} and {@code right} for operations
+ * where the order of operands matters.
+ *
+ * @param left the left operand
+ * @param right the right operand
+ * @return the result of the operation
+ */
+ public T operate(T left, T right);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/Block.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon an input object. The operation may modify that object or
+ * external state (other objects).
+ *
+ * @param <T> The type of input objects to {@code accept}
+ *
+ * @since 1.8
+ */
+public interface Block<T> {
+
+ /**
+ * Use the input object in operations which may modify that object or
+ * external state (other objects).
+ *
+ * @param t the input object
+ */
+ public void accept(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/DoubleBinaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on two {@code double} operands yielding a {@code double} result.
+ *
+ * @since 1.8
+ */
+public interface DoubleBinaryOperator /* extends BinaryOperator<Double> */ {
+//
+// @Override
+// public default Double operate(Double left, Double right) { return operateAsDouble((double) left, (double) right); }
+
+ /**
+ * Returns the {@code double} result of the operation upon the
+ * {@code double} operands. The parameters are named {@code left} and
+ * {@code right} for operations where the order of parameters matters.
+ *
+ * @param left the left operand value
+ * @param right the right operand value
+ * @return the result of the operation
+ */
+ public double operateAsDouble(double left, double right);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/DoubleBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon a {@code double} input value. The operation may modify
+ * external state.
+ *
+ * <p/>This is the primitive type specialization of {@link Block} for
+ * {@code double} and also may be used as a {@code Block<Double>}.
+ *
+ * @since 1.8
+ */
+public interface DoubleBlock {
+
+ /**
+ * Use the {@code double} input value in an operation which may modify
+ * external state.
+ *
+ * @param t the input value
+ */
+ public void accept(double t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/DoubleFunction.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * Apply a function to the input object yielding an appropriate {@code double}
+ * value; this is the {@code double}-bearing specialization for {@link Function}.
+ *
+ * @param <T> the type of input objects to the function
+ *
+ * @since 1.8
+ */
+public interface DoubleFunction<T> {
+
+ /**
+ * Apply a function to the input object yielding an appropriate
+ * {@code double} value.
+ *
+ * @param t the input object
+ * @return the function result value
+ */
+ public double applyAsDouble(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/DoubleSupplier.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * A supplier of {@code double} values.
+ *
+ * <p/>This is the primitive type specialization of {@link Supplier} for
+ * {@code double} and also may be used as a {@code Supplier<Double>}.
+ *
+ * @since 1.8
+ */
+public interface DoubleSupplier {
+
+ /**
+ * Returns a {@code double} value.
+ *
+ * @return a {@code double} value
+ */
+ public double getAsDouble();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/DoubleUnaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on a single {@code double} operand yielding a {@code double}
+ * result.
+ *
+ * @since 1.8
+ */
+public interface DoubleUnaryOperator {
+
+ /**
+ * Returns the {@code double} result of the operation upon the
+ * {@code double} operand.
+ *
+ * @param operand the operand value
+ * @return the operation result value
+ */
+ public double operateAsDouble(double operand);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/Function.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * Apply a function to the input object yielding an appropriate result object. A
+ * function may variously provide a mapping between types, object instances or
+ * keys and values or any other form of transformation upon the input.
+ *
+ * @param <T> the type of input objects to the {@code apply} operation
+ * @param <R> the type of result objects from the {@code apply} operation. May
+ * be the same type as {@code <T>}.
+ *
+ * @since 1.8
+ */
+public interface Function<T, R> {
+
+ /**
+ * Yield an appropriate result object for the input object.
+ *
+ * @param t the input object
+ * @return the function result
+ */
+ public R apply(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/IntBinaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on two {@code int} operands yielding an {@code int} result.
+ *
+ * @since 1.8
+ */
+public interface IntBinaryOperator {
+
+ /**
+ * Returns the {@code int} result of the operation upon the {@code int}
+ * operands. The parameters are named {@code left} and {@code right} for
+ * operations where the order of parameters matters.
+ *
+ * @param left the left operand value
+ * @param right the right operand value
+ * @return the result of the operation
+ */
+ public int operateAsInt(int left, int right);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/IntBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon an {@code int} input value. The operation may modify
+ * external state.
+ *
+ * <p/>This is the primitive type specialization of {@link Block} for
+ * {@code int} and also may be used as a {@code Block<Integer>}.
+ *
+ * @since 1.8
+ */
+public interface IntBlock {
+
+ /**
+ * Use the {@code int} input value in an operation which may modify external
+ * state.
+ *
+ * @param t the input value
+ */
+ public void accept(int t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/IntFunction.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * Apply a function to the input object yielding an appropriate {@code int}
+ * value; this is the {@code int}-bearing specialization for {@link Function}.
+ *
+ * @param <T> the type of input objects to the function
+ *
+ * @since 1.8
+ */
+public interface IntFunction<T> {
+
+ /**
+ * Apply a function to the input object yielding an appropriate {@code int}
+ * value.
+ *
+ * @param t the input object
+ * @return the function result value
+ */
+ public int applyAsInt(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/IntSupplier.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * A supplier of {@code int} values.
+ *
+ * <p/>This is the primitive type specialization of {@link Supplier} for
+ * {@code int} and also may be used as a {@code Supplier<Integer>}.
+ *
+ * @since 1.8
+ */
+public interface IntSupplier {
+
+ /**
+ * Returns an {@code int} value.
+ *
+ * @return an {@code int} value
+ */
+ public int getAsInt();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/IntUnaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on a single {@code int} operand yielding an {@code int} result.
+ *
+ * @since 1.8
+ */
+public interface IntUnaryOperator {
+
+ /**
+ * Returns the {@code int} result of the operation upon the {@code int}
+ * operand.
+ *
+ * @param operand the operand value
+ * @return the operation result value
+ */
+ public int operateAsInt(int operand);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/LongBinaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on two {@code long} operands yielding a {@code long} result.
+ *
+ * @since 1.8
+ */
+public interface LongBinaryOperator {
+
+ /**
+ * Returns the {@code long} result of the operation upon the {@code long}
+ * operands. The parameters are named {@code left} and {@code right} for
+ * operations where the order of parameters matters.
+ *
+ * @param left the left operand value
+ * @param right the right operand value
+ * @return the result of the operation
+ */
+ public long operateAsLong(long left, long right);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/LongBlock.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon a {@code long} input value. The operation may modify
+ * external state.
+ *
+ * <p/>This is the primitive type specialization of {@link Block} for
+ * {@code long} and also may be used as a {@code Block<Long>}.
+ *
+ * @since 1.8
+ */
+public interface LongBlock {
+
+ /**
+ * Use the {@code long} input value in an operation which may modify
+ * external state.
+ *
+ * @param t the input value
+ */
+ public void accept(long t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/LongFunction.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * Apply a function to the input object yielding an appropriate {@code long}
+ * value; this is the {@code long}-bearing specialization for {@link Function}.
+ *
+ * @param <T> the type of input objects to the function
+ *
+ * @since 1.8
+ */
+public interface LongFunction<T> {
+
+ /**
+ * Apply a function to the input object yielding an appropriate {@code long}
+ * value.
+ *
+ * @param t the input object
+ * @return the function result value
+ */
+ public long applyAsLong(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/LongSupplier.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * A supplier of {@code long} values.
+ *
+ * <p/>This is the primitive type specialization of {@link Supplier} for
+ * {@code long} and also may be used as a {@code Supplier<Long>}.
+ *
+ * @since 1.8
+ */
+public interface LongSupplier {
+
+ /**
+ * Returns a {@code long} value.
+ *
+ * @return a {@code long} value.
+ */
+ public long getAsLong();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/LongUnaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation on a single {@code long} operand yielding a {@code long} result.
+ *
+ * @since 1.8
+ */
+public interface LongUnaryOperator {
+
+ /**
+ * Returns the {@code long} result of the operation upon the {@code long}
+ * operand.
+ *
+ * @param operand the operand value
+ * @return the operation result value
+ */
+ public long operateAsLong(long operand);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/Predicate.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * Determines if the input object matches some criteria.
+ *
+ * @param <T> the type of input objects to {@code test}
+ *
+ * @since 1.8
+ */
+public interface Predicate<T> {
+
+ /**
+ * Returns {@code true} if the input object matches some criteria.
+ *
+ * @param t the input object
+ * @return {@code true} if the input object matches some criteria, otherwise
+ * {@code false}
+ */
+ public boolean test(T t);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/Supplier.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * A supplier of objects. The result objects are either created during the
+ * invocation of {@link #get} or by some prior action.
+ *
+ * @param <T> The type of objects returned by {@code get}
+ *
+ * @since 1.8
+ */
+public interface Supplier<T> {
+
+ /**
+ * Returns an object.
+ *
+ * @return an object
+ */
+ public T get();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/UnaryOperator.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.function;
+
+/**
+ * An operation upon a single operand yielding a result. The operand and the
+ * result are of the same type.
+ *
+ * @param <T> the type of operand to {@code operate} and of the result
+ *
+ * @since 1.8
+ */
+public interface UnaryOperator<T> {
+
+ /**
+ * Returns the result of the operation upon the operand.
+ *
+ * @param operand the operand
+ * @return the operation result
+ */
+ public T operate(T operand);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/function/package-info.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/**
+ * <em>Functional interfaces</em> provide typing for lambda expressions. Each
+ * functional interface provides a single abstract method to which the lambda
+ * expression's parameter and return types are matched.
+ *
+ * <p>The interfaces in this package are all functional interfaces used with the
+ * collections and streams frameworks. The operation identified by each
+ * interface is generally applied to a collection or stream of objects.
+ *
+ * <p>All functional interface implementations are expected to ensure that:
+ * <ul>
+ * <li>When used for aggregate operations upon many elements it should not be
+ * assumed that the operation will be called upon elements in any specific order.
+ * </li>
+ * <li>{@code null} values are accepted and returned by these functional
+ * interfaces according to the constraints of the specification in which the
+ * functional interfaces are used. The functional interfaces themselves do not
+ * constrain or mandate use of {@code null} values. Most usages of the
+ * functional interfaces will define the role, if any, of {@code null} for that
+ * context.
+ * </li>
+ * </ul>
+ */
+package java.util.function;
--- a/jdk/src/share/classes/java/util/logging/LogManager.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java Mon Dec 10 20:58:36 2012 -0800
@@ -56,20 +56,14 @@
* At startup the LogManager class is located using the
* java.util.logging.manager system property.
* <p>
- * By default, the LogManager reads its initial configuration from
- * a properties file "lib/logging.properties" in the JRE directory.
- * If you edit that property file you can change the default logging
- * configuration for all uses of that JRE.
- * <p>
- * In addition, the LogManager uses two optional system properties that
- * allow more control over reading the initial configuration:
+ * The LogManager defines two optional system properties that allow control over
+ * the initial configuration:
* <ul>
* <li>"java.util.logging.config.class"
* <li>"java.util.logging.config.file"
* </ul>
- * These two properties may be set via the Preferences API, or as
- * command line property definitions to the "java" command, or as
- * system property definitions passed to JNI_CreateJavaVM.
+ * These two properties may be specified on the command line to the "java"
+ * command, or as system property definitions passed to JNI_CreateJavaVM.
* <p>
* If the "java.util.logging.config.class" property is set, then the
* property value is treated as a class name. The given class will be
@@ -84,9 +78,10 @@
* to specify a properties file (in java.util.Properties format). The
* initial logging configuration will be read from this file.
* <p>
- * If neither of these properties is defined then, as described
- * above, the LogManager will read its initial configuration from
- * a properties file "lib/logging.properties" in the JRE directory.
+ * If neither of these properties is defined then the LogManager uses its
+ * default configuration. The default configuration is typically loaded from the
+ * properties file "{@code lib/logging.properties}" in the Java installation
+ * directory.
* <p>
* The properties for loggers and Handlers will have names starting
* with the dot-separated name for the handler or logger.
--- a/jdk/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html Mon Dec 10 20:58:36 2012 -0800
@@ -90,7 +90,7 @@
<!-- Max value: 8 (inclusive) -->
<!ATTLIST "LogicalScreenDescriptor" "pixelAspectRatio" #CDATA
#REQUIRED>
- <!-- If 0, indicates square pixels, else W/H = (value + 16)/64 -->
+ <!-- If 0, indicates square pixels, else W/H = (value + 15)/64 -->
<!-- Data type: Integer -->
<!-- Min value: 0 (inclusive) -->
<!-- Max value: 255 (inclusive) -->
--- a/jdk/src/share/classes/javax/net/ssl/HostnameVerifier.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/HostnameVerifier.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@
* verification fail.
*
* @author Brad R. Wetmore
- * @see HostnameVerifierFactory
* @since 1.4
*/
--- a/jdk/src/share/classes/javax/net/ssl/SNIHostName.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SNIHostName.java Mon Dec 10 20:58:36 2012 -0800
@@ -135,7 +135,8 @@
* <A HREF="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1123.txt">RFC 1123</A>)
- * for {@code encoded} argument, or use {@link SNIHostName(String)} instead.
+ * for {@code encoded} argument, or use
+ * {@link SNIHostName#SNIHostName(String)} instead.
* <P>
* The {@code encoded} argument is illegal if it:
* <ul>
--- a/jdk/src/share/classes/javax/net/ssl/SNIMatcher.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SNIMatcher.java Mon Dec 10 20:58:36 2012 -0800
@@ -44,7 +44,7 @@
* @see SNIServerName
* @see SNIHostName
* @see SSLParameters#getSNIMatchers()
- * @see SSLParameters#setSNIMatchers(Collection<SNIMatcher>)
+ * @see SSLParameters#setSNIMatchers(Collection)
*
* @since 1.8
*/
--- a/jdk/src/share/classes/javax/net/ssl/SNIServerName.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SNIServerName.java Mon Dec 10 20:58:36 2012 -0800
@@ -40,7 +40,7 @@
* methods that can change the state of an instance once it has been created.
*
* @see SSLParameters#getServerNames()
- * @see SSLParameters#setServerNames(List<SNIServerName>)
+ * @see SSLParameters#setServerNames(List)
*
* @since 1.8
*/
--- a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Mon Dec 10 20:58:36 2012 -0800
@@ -343,7 +343,7 @@
* @return null or an immutable list of non-null {@link SNIServerName}s
*
* @see List
- * @see #setServerNames(List<SNIServerName>)
+ * @see #setServerNames(List)
*
* @since 1.8
*/
@@ -418,7 +418,7 @@
* @return null or an immutable collection of non-null {@link SNIMatcher}s
*
* @see SNIMatcher
- * @see #setSNIMatchers(Collection<SNIMatcher>)
+ * @see #setSNIMatchers(Collection)
*
* @since 1.8
*/
--- a/jdk/src/share/classes/javax/net/ssl/SSLPermission.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SSLPermission.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,8 +37,8 @@
* convention follows the hierarchical property naming convention.
* Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "foo.*" or "*" is valid,
- * "*foo" or "a*b" is not valid.
+ * signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
+ * match, while "*foo" and "a*b" do not.
* <P>
* The following table lists all the possible SSLPermission target names,
* and for each provides a description of what the permission allows
--- a/jdk/src/share/classes/javax/net/ssl/SSLSocketFactory.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SSLSocketFactory.java Mon Dec 10 20:58:36 2012 -0800
@@ -198,8 +198,8 @@
* (RFC6066)</A>). Data that has been already removed from the
* underlying {@link InputStream} should be loaded into the
* {@code consumed} stream before this method is called, perhaps
- * using a {@link ByteArrayInputStream}. When this {@link Socket}
- * begins handshaking, it will read all of the data in
+ * using a {@link java.io.ByteArrayInputStream}. When this
+ * {@link Socket} begins handshaking, it will read all of the data in
* {@code consumed} until it reaches {@code EOF}, then all further
* data is read from the underlying {@link InputStream} as
* usual.
--- a/jdk/src/share/classes/javax/swing/JColorChooser.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/JColorChooser.java Mon Dec 10 20:58:36 2012 -0800
@@ -182,6 +182,7 @@
dialog = new ColorChooserDialog((Dialog)window, title, modal, c, chooserPane,
okListener, cancelListener);
}
+ dialog.getAccessibleContext().setAccessibleDescription(title);
return dialog;
}
@@ -647,6 +648,7 @@
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton okButton = new JButton(okString);
getRootPane().setDefaultButton(okButton);
+ okButton.getAccessibleContext().setAccessibleDescription(okString);
okButton.setActionCommand("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -659,6 +661,7 @@
buttonPane.add(okButton);
cancelButton = new JButton(cancelString);
+ cancelButton.getAccessibleContext().setAccessibleDescription(cancelString);
// The following few lines are used to register esc to close the dialog
Action cancelKeyAction = new AbstractAction() {
@@ -688,6 +691,7 @@
buttonPane.add(cancelButton);
JButton resetButton = new JButton(resetString);
+ resetButton.getAccessibleContext().setAccessibleDescription(resetString);
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
reset();
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java Mon Dec 10 20:58:36 2012 -0800
@@ -135,6 +135,7 @@
String label = this.model.getText(this, "HexCode"); // NON-NLS: suffix
boolean visible = label != null;
this.text.setVisible(visible);
+ this.text.getAccessibleContext().setAccessibleDescription(label);
this.label.setVisible(visible);
if (visible) {
this.label.setText(label);
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java Mon Dec 10 20:58:36 2012 -0800
@@ -37,6 +37,7 @@
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
+import javax.swing.JSpinner.DefaultEditor;
final class ColorPanel extends JPanel implements ActionListener {
@@ -119,17 +120,26 @@
int count = this.model.getCount();
this.spinners[4].setVisible(count > 4);
for (int i = 0; i < count; i++) {
+ String text = this.model.getLabel(this, i);
Object object = this.spinners[i].getLabel();
if (object instanceof JRadioButton) {
JRadioButton button = (JRadioButton) object;
- button.setText(this.model.getLabel(this, i));
+ button.setText(text);
+ button.getAccessibleContext().setAccessibleDescription(text);
}
else if (object instanceof JLabel) {
JLabel label = (JLabel) object;
- label.setText(this.model.getLabel(this, i));
+ label.setText(text);
}
this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
this.spinners[i].setValue(this.values[i]);
+ this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
+ this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
+ DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
+ editor.getTextField().getAccessibleContext().setAccessibleName(text);
+ this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
+ this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
+ editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
}
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java Mon Dec 10 20:58:36 2012 -0800
@@ -94,6 +94,7 @@
tabbedPane = new JTabbedPane();
tabbedPane.setName("ColorChooser.tabPane");
tabbedPane.setInheritsPopupMenu(true);
+ tabbedPane.getAccessibleContext().setAccessibleDescription(tabbedPane.getName());
singlePanel = new JPanel(new CenterLayout());
singlePanel.setName("ColorChooser.panel");
singlePanel.setInheritsPopupMenu(true);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Mon Dec 10 20:58:36 2012 -0800
@@ -1941,6 +1941,9 @@
for(int counter = beginRow + 1; counter <= endRow; counter++) {
testRect = getPathBounds(tree,
getPathForRow(tree, counter));
+ if (testRect == null) {
+ return;
+ }
if((testRect.y + testRect.height) > maxY)
counter = endRow;
}
@@ -2069,7 +2072,7 @@
treeState.invalidatePathBounds(oldPath);
updateSize();
}
- else {
+ else if (editingBounds != null) {
editingBounds.x = 0;
editingBounds.width = tree.getSize().width;
tree.repaint(editingBounds);
@@ -2114,6 +2117,9 @@
tree.isPathSelected(path), tree.isExpanded(path),
treeModel.isLeaf(path.getLastPathComponent()), row);
Rectangle nodeBounds = getPathBounds(tree, path);
+ if (nodeBounds == null) {
+ return false;
+ }
editingRow = row;
@@ -2134,6 +2140,9 @@
// To make sure x/y are updated correctly, fetch
// the bounds again.
nodeBounds = getPathBounds(tree, path);
+ if (nodeBounds == null) {
+ return false;
+ }
}
else
editorHasDifferentSize = false;
@@ -3570,7 +3579,7 @@
if(pressedPath != null) {
Rectangle bounds = getPathBounds(tree, pressedPath);
- if(e.getY() >= (bounds.y + bounds.height)) {
+ if (bounds == null || e.getY() >= (bounds.y + bounds.height)) {
return;
}
@@ -3832,6 +3841,10 @@
// And repaint
Rectangle newMinBounds = getPathBounds(tree, minPath);
+ if (minBounds == null || newMinBounds == null) {
+ return;
+ }
+
if (indices.length == 1 &&
newMinBounds.height == minBounds.height) {
tree.repaint(0, minBounds.y, tree.getWidth(),
@@ -4466,27 +4479,28 @@
}
}
Rectangle newRect = ui.getPathBounds(tree, newPath);
-
- newRect.x = visRect.x;
- newRect.width = visRect.width;
- if(direction == -1) {
- newRect.height = visRect.height;
- }
- else {
- newRect.y -= (visRect.height - newRect.height);
- newRect.height = visRect.height;
+ if (newRect != null) {
+ newRect.x = visRect.x;
+ newRect.width = visRect.width;
+ if(direction == -1) {
+ newRect.height = visRect.height;
+ }
+ else {
+ newRect.y -= (visRect.height - newRect.height);
+ newRect.height = visRect.height;
+ }
+
+ if(addToSelection) {
+ ui.extendSelection(newPath);
+ }
+ else if(changeSelection) {
+ tree.setSelectionPath(newPath);
+ }
+ else {
+ ui.setLeadSelectionPath(newPath, true);
+ }
+ tree.scrollRectToVisible(newRect);
}
-
- if(addToSelection) {
- ui.extendSelection(newPath);
- }
- else if(changeSelection) {
- tree.setSelectionPath(newPath);
- }
- else {
- ui.setLeadSelectionPath(newPath, true);
- }
- tree.scrollRectToVisible(newRect);
}
}
--- a/jdk/src/share/classes/sun/awt/TextureSizeConstraining.java Thu Dec 06 12:04:35 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt;
-
-/**
- * A GraphicsConfiguration implements the TextureSizeConstraining
- * interface to indicate that it imposes certain limitations on the
- * maximum size of supported textures.
- */
-public interface TextureSizeConstraining {
-
- /**
- * Returns the maximum width of any texture image.
- */
- public int getMaxTextureWidth();
-
- /**
- * Returns the maximum height of any texture image.
- */
- public int getMaxTextureHeight();
-
-}
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,6 +25,7 @@
package sun.java2d.opengl;
+import java.awt.AlphaComposite;
import java.awt.Composite;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
@@ -99,6 +100,8 @@
CompositeType.AnyAlpha,
blitIntArgbPreToSurface),
+ new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLSurface),
+
new OGLSwToSurfaceScale(SurfaceType.IntRgb,
OGLSurfaceData.PF_INT_RGB),
new OGLSwToSurfaceScale(SurfaceType.IntRgbx,
@@ -175,6 +178,9 @@
new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture,
CompositeType.SrcNoEa,
blitIntArgbPreToTexture),
+
+ new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLTexture),
+
};
GraphicsPrimitiveMgr.register(primitives);
}
@@ -763,3 +769,49 @@
}
}
}
+
+class OGLAnyCompositeBlit extends Blit {
+ private WeakReference<SurfaceData> dstTmp;
+
+ public OGLAnyCompositeBlit(SurfaceType dstType) {
+ super(SurfaceType.Any, CompositeType.Any, dstType);
+ }
+ public synchronized void Blit(SurfaceData src, SurfaceData dst,
+ Composite comp, Region clip,
+ int sx, int sy, int dx, int dy,
+ int w, int h)
+ {
+ Blit convertdst = Blit.getFromCache(dst.getSurfaceType(),
+ CompositeType.SrcNoEa,
+ SurfaceType.IntArgbPre);
+
+ SurfaceData cachedDst = null;
+
+ if (dstTmp != null) {
+ // use cached intermediate surface, if available
+ cachedDst = dstTmp.get();
+ }
+
+ // convert source to IntArgbPre
+ SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h,
+ cachedDst, BufferedImage.TYPE_INT_ARGB_PRE);
+
+ Blit performop = Blit.getFromCache(src.getSurfaceType(),
+ CompositeType.Any, dstBuffer.getSurfaceType());
+
+ performop.Blit(src, dstBuffer, comp, clip,
+ sx, sy, 0, 0, w, h);
+
+ if (dstBuffer != cachedDst) {
+ // cache the intermediate surface
+ dstTmp = new WeakReference(dstBuffer);
+ }
+
+ // now blit the buffer back to the destination
+ convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(),
+ CompositeType.SrcNoEa,
+ dst.getSurfaceType());
+ convertdst.Blit(dstBuffer, dst, AlphaComposite.Src,
+ clip, 0, 0, dx, dy, w, h);
+ }
+}
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java Mon Dec 10 20:58:36 2012 -0800
@@ -76,6 +76,7 @@
CompositeType comp,
Color bgColor)
{
- return (bgColor == null || transparency == Transparency.OPAQUE);
+ return comp.isDerivedFrom(CompositeType.AnyAlpha) &&
+ (bgColor == null || transparency == Transparency.OPAQUE);
}
}
--- a/jdk/src/share/classes/sun/management/snmp/AdaptorBootstrap.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/management/snmp/AdaptorBootstrap.java Mon Dec 10 20:58:36 2012 -0800
@@ -127,13 +127,13 @@
if (log.isDebugOn())
log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing"));
- final Enumeration td = acl.getTrapDestinations();
+ final Enumeration<InetAddress> td = acl.getTrapDestinations();
for (; td.hasMoreElements() ;) {
- final InetAddress targetAddr = (InetAddress)td.nextElement();
- final Enumeration tc =
+ final InetAddress targetAddr = td.nextElement();
+ final Enumeration<String> tc =
acl.getTrapCommunities(targetAddr);
for (;tc.hasMoreElements() ;) {
- final String community = (String)tc.nextElement();
+ final String community = tc.nextElement();
final NotificationTarget target =
new NotificationTargetImpl(targetAddr,
defaultTrapPort,
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package sun.misc;
+import java.lang.annotation.Annotation;
import sun.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;
@@ -83,4 +84,9 @@
* Returns the ith StackTraceElement for the given throwable.
*/
StackTraceElement getStackTraceElement(Throwable t, int i);
+
+ /**
+ * Returns a directly present annotation.
+ */
+ public <A extends Annotation> A getDirectDeclaredAnnotation(Class<?> klass, Class<A> anno);
}
--- a/jdk/src/share/classes/sun/nio/ch/ThreadPool.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/ThreadPool.java Mon Dec 10 20:58:36 2012 -0800
@@ -102,11 +102,7 @@
if (threadFactory == null)
threadFactory = defaultThreadFactory;
// create thread pool
- ExecutorService executor =
- new ThreadPoolExecutor(0, Integer.MAX_VALUE,
- Long.MAX_VALUE, TimeUnit.MILLISECONDS,
- new SynchronousQueue<Runnable>(),
- threadFactory);
+ ExecutorService executor = Executors.newCachedThreadPool(threadFactory);
return new ThreadPool(executor, false, initialSize);
}
--- a/jdk/src/share/classes/sun/print/PathGraphics.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/print/PathGraphics.java Mon Dec 10 20:58:36 2012 -0800
@@ -1025,7 +1025,8 @@
continue;
}
glyph = font2D.charToGlyph(c);
- if (glyph != missingGlyph && glyph < numGlyphs &&
+ if (glyph != missingGlyph &&
+ glyph >= 0 && glyph < numGlyphs &&
(glyphToCharMap[glyph] ==
CharToGlyphMapper.INVISIBLE_GLYPH_ID)) {
glyphToCharMap[glyph] = c;
--- a/jdk/src/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -43,7 +43,7 @@
new String[] { "base" });
}
- protected Object base; // base
+ protected final Object base; // base
UnsafeStaticFieldAccessorImpl(Field field) {
super(field);
--- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -806,4 +806,6 @@
public static Annotation[] toArray(Map<Class<? extends Annotation>, Annotation> annotations) {
return annotations.values().toArray(EMPTY_ANNOTATION_ARRAY);
}
+
+ static Annotation[] getEmptyAnnotationArray() { return EMPTY_ANNOTATION_ARRAY; }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationSupport.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.reflect.annotation;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import sun.reflect.Reflection;
+import sun.misc.JavaLangAccess;
+
+public final class AnnotationSupport {
+ private static final JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
+
+ /**
+ * Finds and returns _one_ annotation of the type indicated by
+ * {@code annotationClass} from the {@code Map} {@code
+ * annotationMap}. Looks into containers of the {@code
+ * annotationClass} (as specified by an the {@code
+ * annotationClass} type being meta-annotated with an {@code
+ * ContainedBy} annotation).
+ *
+ * @param annotationMap the {@code Map} used to store annotations and indexed by their type
+ * @param annotationClass the type of annotation to search for
+ *
+ * @return in instance of {@code annotationClass} or {@code null} if none were found
+ */
+ public static <A extends Annotation> A getOneAnnotation(final Map<Class<? extends Annotation>, Annotation> annotationMap,
+ final Class<A> annotationClass) {
+ @SuppressWarnings("unchecked")
+ final A candidate = (A)annotationMap.get(annotationClass);
+ if (candidate != null) {
+ return candidate;
+ }
+
+ final Class<? extends Annotation> containerClass = getContainer(annotationClass);
+ if (containerClass != null) {
+ return unpackOne(annotationMap.get(containerClass), annotationClass);
+ }
+
+ return null; // found none
+ }
+
+ /**
+ * Finds and returns all annotation of the type indicated by
+ * {@code annotationClass} from the {@code Map} {@code
+ * annotationMap}. Looks into containers of the {@code
+ * annotationClass} (as specified by an the {@code
+ * annotationClass} type being meta-annotated with an {@code
+ * ContainedBy} annotation).
+ *
+ * @param annotationMap the {@code Map} used to store annotations indexed by their type
+ * @param annotationClass the type of annotation to search for
+ *
+ * @return an array of instances of {@code annotationClass} or an empty array if none were found
+ */
+ public static <A extends Annotation> A[] getMultipleAnnotations(final Map<Class<? extends Annotation>, Annotation> annotationMap,
+ final Class<A> annotationClass) {
+ final ArrayList<A> res = new ArrayList<A>();
+
+ @SuppressWarnings("unchecked")
+ final A candidate = (A)annotationMap.get(annotationClass);
+ if (candidate != null) {
+ res.add(candidate);
+ }
+
+ final Class<? extends Annotation> containerClass = getContainer(annotationClass);
+ if (containerClass != null) {
+ res.addAll(unpackAll(annotationMap.get(containerClass), annotationClass));
+ }
+
+ @SuppressWarnings("unchecked") // should be safe annotationClass is a token for A
+ final A[] emptyTemplateArray = (A[])Array.newInstance(annotationClass, 0);
+ return res.isEmpty() ? emptyTemplateArray : res.toArray(emptyTemplateArray);
+ }
+
+ /**
+ * Unpacks the {@code annotationMap} parameter into an array of
+ * {@code Annotation}s. This method will unpack all repeating
+ * annotations containers (once). An annotation type is marked as a
+ * container by meta-annotating it the with the {@code
+ * ContainerFor} annotation.
+ *
+ * @param annotationMap the {@code Map} from where the annotations are unpacked
+ *
+ * @return an array of Annotation
+ */
+ public static Annotation[] unpackToArray(Map<Class<? extends Annotation>, Annotation> annotationMap) {
+ List<Annotation> res = new ArrayList<>();
+ for (Map.Entry<Class<? extends Annotation>, Annotation> e : annotationMap.entrySet()) {
+ Class<? extends Annotation> annotationClass = e.getKey();
+ Annotation annotationInstance = e.getValue();
+ Class<? extends Annotation> containee = getContainee(e.getKey());
+ boolean isContainer = javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainerFor.class) != null;
+
+ if (isContainer) {
+ res.addAll(unpackAll(annotationInstance, containee));
+ } else {
+ res.add(annotationInstance);
+ }
+ }
+
+ return res.isEmpty()
+ ? AnnotationParser.getEmptyAnnotationArray()
+ : res.toArray(AnnotationParser.getEmptyAnnotationArray());
+ }
+
+ /** Helper to get the container, or null if none, of an annotation. */
+ private static <A extends Annotation> Class<? extends Annotation> getContainer(Class<A> annotationClass) {
+ ContainedBy containerAnnotation =
+ javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainedBy.class);
+ return (containerAnnotation == null) ? null : containerAnnotation.value();
+ }
+
+ /** Helper to get the containee, or null if this isn't a container, of a possible container annotation. */
+ private static <A extends Annotation> Class<? extends Annotation> getContainee(Class<A> annotationClass) {
+ ContainerFor containerAnnotation =
+ javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainerFor.class);
+ return (containerAnnotation == null) ? null : containerAnnotation.value();
+ }
+
+ /** Reflectively look up and get the returned array from the the
+ * invocation of the value() element on an instance of an
+ * Annotation.
+ */
+ private static <A extends Annotation> A[] getValueArray(Annotation containerInstance) {
+ try {
+ // the spec tells us the container must have an array-valued
+ // value element. Get the AnnotationType, get the "value" element
+ // and invoke it to get the contents.
+
+ Class<?> containerClass = containerInstance.annotationType();
+ AnnotationType annoType = javaLangAccess.getAnnotationType(containerClass);
+ if (annoType == null)
+ throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations");
+
+ Method m = annoType.members().get("value");
+ if (m == null)
+ throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations");
+ m.setAccessible(true);
+
+ @SuppressWarnings("unchecked") // not provably safe, but we catch the ClassCastException
+ A[] a = (A[])m.invoke(containerInstance); // this will erase to (Annotation[]) but we
+ // do a runtime cast on the return-value
+ // in the methods that call this method
+ return a;
+ } catch (IllegalAccessException | // couldnt loosen security
+ IllegalArgumentException | // parameters doesn't match
+ InvocationTargetException | // the value method threw an exception
+ ClassCastException e) { // well, a cast failed ...
+ throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations",
+ e,
+ containerInstance,
+ null);
+ }
+ }
+
+ /* Sanity check type of and return the first annotation instance
+ * of type {@code annotationClass} from {@code
+ * containerInstance}.
+ */
+ private static <A extends Annotation> A unpackOne(Annotation containerInstance, Class<A> annotationClass) {
+ if (containerInstance == null) {
+ return null;
+ }
+
+ try {
+ return annotationClass.cast(getValueArray(containerInstance)[0]);
+ } catch (ArrayIndexOutOfBoundsException | // empty array
+ ClassCastException | // well, a cast failed ...
+ NullPointerException e) { // can this NP? for good meassure
+ throw new InvalidContainerAnnotationError(String.format("%s is an invalid container for repeating annotations of type: %s",
+ containerInstance, annotationClass),
+ e,
+ containerInstance,
+ annotationClass);
+ }
+ }
+
+ /* Sanity check type of and return a list of all the annotation
+ * instances of type {@code annotationClass} from {@code
+ * containerInstance}.
+ */
+ private static <A extends Annotation> List<A> unpackAll(Annotation containerInstance, Class<A> annotationClass) {
+ if (containerInstance == null) {
+ return Collections.emptyList(); // container not present
+ }
+
+ try {
+ A[] a = getValueArray(containerInstance);
+ ArrayList<A> l = new ArrayList<>(a.length);
+ for (int i = 0; i < a.length; i++)
+ l.add(annotationClass.cast(a[i]));
+ return l;
+ } catch (ClassCastException |
+ NullPointerException e) {
+ throw new InvalidContainerAnnotationError(String.format("%s is an invalid container for repeating annotations of type: %s",
+ containerInstance, annotationClass),
+ e,
+ containerInstance,
+ annotationClass);
+ }
+ }
+}
--- a/jdk/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package sun.reflect.generics.reflectiveObjects;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
@@ -192,6 +193,25 @@
return null;
}
+ public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+ // safe because annotationClass is the class for T
+ return (T[])Array.newInstance(annotationClass, 0);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
+ Objects.requireNonNull(annotationClass);
+ // safe because annotationClass is the class for T
+ return (T[])Array.newInstance(annotationClass, 0);
+ }
+
public Annotation[] getAnnotations() {
// Since zero-length, don't need defensive clone
return EMPTY_ANNOTATION_ARRAY;
--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSP.java Mon Dec 10 20:58:36 2012 -0800
@@ -43,6 +43,7 @@
import java.util.Map;
import static sun.security.provider.certpath.OCSPResponse.*;
+import sun.security.action.GetIntegerAction;
import sun.security.util.Debug;
import sun.security.util.ObjectIdentifier;
import sun.security.x509.AccessDescription;
@@ -69,7 +70,31 @@
private static final Debug debug = Debug.getInstance("certpath");
- private static final int CONNECT_TIMEOUT = 15000; // 15 seconds
+ private static final int DEFAULT_CONNECT_TIMEOUT = 15000;
+
+ /**
+ * Integer value indicating the timeout length, in seconds, to be
+ * used for the OCSP check. A timeout of zero is interpreted as
+ * an infinite timeout.
+ */
+ private static final int CONNECT_TIMEOUT = initializeTimeout();
+
+ /**
+ * Initialize the timeout length by getting the OCSP timeout
+ * system property. If the property has not been set, or if its
+ * value is negative, set the timeout length to the default.
+ */
+ private static int initializeTimeout() {
+ int tmp = java.security.AccessController.doPrivileged(
+ new GetIntegerAction("com.sun.security.ocsp.timeout",
+ DEFAULT_CONNECT_TIMEOUT));
+ if (tmp < 0) {
+ tmp = DEFAULT_CONNECT_TIMEOUT;
+ }
+ // Convert to milliseconds, as the system property will be
+ // specified in seconds
+ return tmp * 1000;
+ }
private OCSP() {}
--- a/jdk/src/share/classes/sun/security/ssl/AppInputStream.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/AppInputStream.java Mon Dec 10 20:58:36 2012 -0800
@@ -55,6 +55,7 @@
* Return the minimum number of bytes that can be read without blocking.
* Currently not synchronized.
*/
+ @Override
public int available() throws IOException {
if (c.checkEOF() || (r.isAppDataValid() == false)) {
return 0;
@@ -65,6 +66,7 @@
/**
* Read a single byte, returning -1 on non-fault EOF status.
*/
+ @Override
public synchronized int read() throws IOException {
int n = read(oneByte, 0, 1);
if (n <= 0) { // EOF
@@ -79,6 +81,7 @@
* are responsible only for blocking to fill at most one buffer,
* and returning "-1" on non-fault EOF status.
*/
+ @Override
public synchronized int read(byte b[], int off, int len)
throws IOException {
if (b == null) {
@@ -124,6 +127,7 @@
* is static and may garbled by concurrent use, but we are not interested
* in the data anyway.
*/
+ @Override
public synchronized long skip(long n) throws IOException {
long skipped = 0;
while (n > 0) {
@@ -141,6 +145,7 @@
/*
* Socket close is already synchronized, no need to block here.
*/
+ @Override
public void close() throws IOException {
c.close();
}
--- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Mon Dec 10 20:58:36 2012 -0800
@@ -56,6 +56,7 @@
/**
* Write the data out, NOW.
*/
+ @Override
synchronized public void write(byte b[], int off, int len)
throws IOException {
if (b == null) {
@@ -131,6 +132,7 @@
/**
* Write one byte now.
*/
+ @Override
synchronized public void write(int i) throws IOException {
oneByte[0] = (byte)i;
write(oneByte, 0, 1);
@@ -139,6 +141,7 @@
/*
* Socket close is already synchronized, no need to block here.
*/
+ @Override
public void close() throws IOException {
c.close();
}
--- a/jdk/src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -102,6 +102,7 @@
* associated with this socket, if any.
* @see java.net.Socket#getChannel
*/
+ @Override
public final SocketChannel getChannel() {
if (self == this) {
return super.getChannel();
@@ -114,6 +115,7 @@
* Binds the address to the socket.
* @see java.net.Socket#bind
*/
+ @Override
public void bind(SocketAddress bindpoint) throws IOException {
/*
* Bind to this socket
@@ -131,6 +133,7 @@
* Returns the address of the endpoint this socket is connected to
* @see java.net.Socket#getLocalSocketAddress
*/
+ @Override
public SocketAddress getLocalSocketAddress() {
if (self == this) {
return super.getLocalSocketAddress();
@@ -143,6 +146,7 @@
* Returns the address of the endpoint this socket is connected to
* @see java.net.Socket#getRemoteSocketAddress
*/
+ @Override
public SocketAddress getRemoteSocketAddress() {
if (self == this) {
return super.getRemoteSocketAddress();
@@ -164,6 +168,7 @@
* @param endpoint the <code>SocketAddress</code>
* @throws IOException if an error occurs during the connection
*/
+ @Override
public final void connect(SocketAddress endpoint) throws IOException {
connect(endpoint, 0);
}
@@ -172,6 +177,7 @@
* Returns the connection state of the socket.
* @see java.net.Socket#isConnected
*/
+ @Override
public final boolean isConnected() {
if (self == this) {
return super.isConnected();
@@ -184,6 +190,7 @@
* Returns the binding state of the socket.
* @see java.net.Socket#isBound
*/
+ @Override
public final boolean isBound() {
if (self == this) {
return super.isBound();
@@ -203,6 +210,7 @@
*
* @throws UnsupportedOperationException
*/
+ @Override
public final void shutdownInput() throws IOException {
throw new UnsupportedOperationException("The method shutdownInput()" +
" is not supported in SSLSocket");
@@ -215,6 +223,7 @@
*
* @throws UnsupportedOperationException
*/
+ @Override
public final void shutdownOutput() throws IOException {
throw new UnsupportedOperationException("The method shutdownOutput()" +
" is not supported in SSLSocket");
@@ -225,6 +234,7 @@
* Returns the input state of the socket
* @see java.net.Socket#isInputShutdown
*/
+ @Override
public final boolean isInputShutdown() {
if (self == this) {
return super.isInputShutdown();
@@ -237,6 +247,7 @@
* Returns the output state of the socket
* @see java.net.Socket#isOutputShutdown
*/
+ @Override
public final boolean isOutputShutdown() {
if (self == this) {
return super.isOutputShutdown();
@@ -252,6 +263,7 @@
* rather than forcing them to be explicitly reclaimed at
* the penalty of prematurly killing SSL sessions.
*/
+ @Override
protected final void finalize() throws Throwable {
try {
close();
@@ -281,6 +293,7 @@
/**
* Returns the address of the remote peer for this connection.
*/
+ @Override
public final InetAddress getInetAddress() {
if (self == this) {
return super.getInetAddress();
@@ -295,6 +308,7 @@
* @return the local address to which the socket is bound.
* @since JDK1.1
*/
+ @Override
public final InetAddress getLocalAddress() {
if (self == this) {
return super.getLocalAddress();
@@ -306,6 +320,7 @@
/**
* Returns the number of the remote port that this connection uses.
*/
+ @Override
public final int getPort() {
if (self == this) {
return super.getPort();
@@ -317,6 +332,7 @@
/**
* Returns the number of the local port that this connection uses.
*/
+ @Override
public final int getLocalPort() {
if (self == this) {
return super.getLocalPort();
@@ -333,6 +349,7 @@
* Enables or disables the Nagle optimization.
* @see java.net.Socket#setTcpNoDelay
*/
+ @Override
public final void setTcpNoDelay(boolean value) throws SocketException {
if (self == this) {
super.setTcpNoDelay(value);
@@ -348,6 +365,7 @@
*
* @see java.net.Socket#getTcpNoDelay
*/
+ @Override
public final boolean getTcpNoDelay() throws SocketException {
if (self == this) {
return super.getTcpNoDelay();
@@ -360,6 +378,7 @@
* Assigns the socket's linger timeout.
* @see java.net.Socket#setSoLinger
*/
+ @Override
public final void setSoLinger(boolean flag, int linger)
throws SocketException {
if (self == this) {
@@ -373,6 +392,7 @@
* Returns the socket's linger timeout.
* @see java.net.Socket#getSoLinger
*/
+ @Override
public final int getSoLinger() throws SocketException {
if (self == this) {
return super.getSoLinger();
@@ -388,6 +408,7 @@
* this for an SSLSocket. An implementation can be provided if a need
* arises in future.
*/
+ @Override
public final void sendUrgentData(int data) throws SocketException {
throw new SocketException("This method is not supported "
+ "by SSLSockets");
@@ -401,6 +422,7 @@
* Setting OOBInline does not have any effect on SSLSocket,
* since currently we don't support sending urgent data.
*/
+ @Override
public final void setOOBInline(boolean on) throws SocketException {
throw new SocketException("This method is ineffective, since"
+ " sending urgent data is not supported by SSLSockets");
@@ -410,6 +432,7 @@
* Tests if OOBINLINE is enabled.
* @see java.net.Socket#getOOBInline
*/
+ @Override
public final boolean getOOBInline() throws SocketException {
throw new SocketException("This method is ineffective, since"
+ " sending urgent data is not supported by SSLSockets");
@@ -419,6 +442,7 @@
* Returns the socket timeout.
* @see java.net.Socket#getSoTimeout
*/
+ @Override
public final int getSoTimeout() throws SocketException {
if (self == this) {
return super.getSoTimeout();
@@ -427,6 +451,7 @@
}
}
+ @Override
public final void setSendBufferSize(int size) throws SocketException {
if (self == this) {
super.setSendBufferSize(size);
@@ -435,6 +460,7 @@
}
}
+ @Override
public final int getSendBufferSize() throws SocketException {
if (self == this) {
return super.getSendBufferSize();
@@ -443,6 +469,7 @@
}
}
+ @Override
public final void setReceiveBufferSize(int size) throws SocketException {
if (self == this) {
super.setReceiveBufferSize(size);
@@ -451,6 +478,7 @@
}
}
+ @Override
public final int getReceiveBufferSize() throws SocketException {
if (self == this) {
return super.getReceiveBufferSize();
@@ -463,6 +491,7 @@
* Enable/disable SO_KEEPALIVE.
* @see java.net.Socket#setKeepAlive
*/
+ @Override
public final void setKeepAlive(boolean on) throws SocketException {
if (self == this) {
super.setKeepAlive(on);
@@ -475,6 +504,7 @@
* Tests if SO_KEEPALIVE is enabled.
* @see java.net.Socket#getKeepAlive
*/
+ @Override
public final boolean getKeepAlive() throws SocketException {
if (self == this) {
return super.getKeepAlive();
@@ -488,6 +518,7 @@
* packets sent from this Socket.
* @see java.net.Socket#setTrafficClass
*/
+ @Override
public final void setTrafficClass(int tc) throws SocketException {
if (self == this) {
super.setTrafficClass(tc);
@@ -501,6 +532,7 @@
* sent from this Socket.
* @see java.net.Socket#getTrafficClass
*/
+ @Override
public final int getTrafficClass() throws SocketException {
if (self == this) {
return super.getTrafficClass();
@@ -513,6 +545,7 @@
* Enable/disable SO_REUSEADDR.
* @see java.net.Socket#setReuseAddress
*/
+ @Override
public final void setReuseAddress(boolean on) throws SocketException {
if (self == this) {
super.setReuseAddress(on);
@@ -525,6 +558,7 @@
* Tests if SO_REUSEADDR is enabled.
* @see java.net.Socket#getReuseAddress
*/
+ @Override
public final boolean getReuseAddress() throws SocketException {
if (self == this) {
return super.getReuseAddress();
@@ -538,6 +572,7 @@
*
* @see java.net.Socket#setPerformancePreferences(int, int, int)
*/
+ @Override
public void setPerformancePreferences(int connectionTime,
int latency, int bandwidth) {
if (self == this) {
--- a/jdk/src/share/classes/sun/security/ssl/ByteBufferInputStream.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ByteBufferInputStream.java Mon Dec 10 20:58:36 2012 -0800
@@ -50,6 +50,7 @@
*
* Increments position().
*/
+ @Override
public int read() throws IOException {
if (bb == null) {
@@ -67,6 +68,7 @@
*
* Increments position().
*/
+ @Override
public int read(byte b[]) throws IOException {
if (bb == null) {
@@ -81,6 +83,7 @@
*
* Increments position().
*/
+ @Override
public int read(byte b[], int off, int len) throws IOException {
if (bb == null) {
@@ -108,6 +111,7 @@
* Skips over and discards <code>n</code> bytes of data from this input
* stream.
*/
+ @Override
public long skip(long n) throws IOException {
if (bb == null) {
@@ -135,6 +139,7 @@
* from this input stream without blocking by the next caller of a
* method for this input stream.
*/
+ @Override
public int available() throws IOException {
if (bb == null) {
@@ -150,6 +155,7 @@
*
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void close() throws IOException {
bb = null;
}
@@ -157,12 +163,14 @@
/**
* Marks the current position in this input stream.
*/
+ @Override
public synchronized void mark(int readlimit) {}
/**
* Repositions this stream to the position at the time the
* <code>mark</code> method was last called on this input stream.
*/
+ @Override
public synchronized void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
@@ -171,6 +179,7 @@
* Tests if this input stream supports the <code>mark</code> and
* <code>reset</code> methods.
*/
+ @Override
public boolean markSupported() {
return false;
}
--- a/jdk/src/share/classes/sun/security/ssl/CipherBox.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/CipherBox.java Mon Dec 10 20:58:36 2012 -0800
@@ -32,7 +32,6 @@
import java.security.*;
import javax.crypto.*;
-import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.nio.*;
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Mon Dec 10 20:58:36 2012 -0800
@@ -37,7 +37,6 @@
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
-import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
import static sun.security.ssl.CipherSuite.PRF.*;
import static sun.security.ssl.JsseJce.*;
@@ -203,6 +202,7 @@
* Note that for unsupported CipherSuites parsed from a handshake
* message we violate the equals() contract.
*/
+ @Override
public int compareTo(CipherSuite o) {
return o.priority - priority;
}
@@ -210,6 +210,7 @@
/**
* Returns this.name.
*/
+ @Override
public String toString() {
return name;
}
@@ -378,6 +379,7 @@
}
}
+ @Override
public String toString() {
return name;
}
@@ -527,6 +529,7 @@
return b.booleanValue();
}
+ @Override
public String toString() {
return description;
}
@@ -562,6 +565,7 @@
return new MAC(this, protocolVersion, secret);
}
+ @Override
public String toString() {
return name;
}
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuiteList.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuiteList.java Mon Dec 10 20:58:36 2012 -0800
@@ -177,6 +177,7 @@
return suiteNames.clone();
}
+ @Override
public String toString() {
return cipherSuites.toString();
}
--- a/jdk/src/share/classes/sun/security/ssl/ClientHandshaker.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ClientHandshaker.java Mon Dec 10 20:58:36 2012 -0800
@@ -45,7 +45,6 @@
import javax.security.auth.Subject;
import sun.security.ssl.HandshakeMessage.*;
-import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
@@ -128,6 +127,7 @@
* is processed, and writes responses as needed using the connection
* in the constructor.
*/
+ @Override
void processMessage(byte type, int messageLen) throws IOException {
if (state > type
&& (type != HandshakeMessage.ht_hello_request
@@ -505,6 +505,7 @@
try {
subject = AccessController.doPrivileged(
new PrivilegedExceptionAction<Subject>() {
+ @Override
public Subject run() throws Exception {
return Krb5Helper.getClientSubject(getAccSE());
}});
@@ -556,10 +557,6 @@
}
if (resumingSession && session != null) {
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- handshakeHash.setCertificateVerifyAlg(null);
- }
-
setHandshakeSessionSE(session);
return;
}
@@ -974,8 +971,6 @@
throw new SSLHandshakeException(
"No supported hash algorithm");
}
-
- handshakeHash.setCertificateVerifyAlg(hashAlg);
}
m3 = new CertificateVerify(protocolVersion, handshakeHash,
@@ -993,10 +988,6 @@
}
m3.write(output);
output.doHashes();
- } else {
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- handshakeHash.setCertificateVerifyAlg(null);
- }
}
/*
@@ -1104,6 +1095,7 @@
/*
* Returns a ClientHello message to kickstart renegotiations
*/
+ @Override
HandshakeMessage getKickstartMessage() throws SSLException {
// session ID of the ClientHello message
SessionId sessionId = SSLSessionImpl.nullSession.getSessionId();
@@ -1279,6 +1271,7 @@
/*
* Fault detected during handshake.
*/
+ @Override
void handshakeAlert(byte description) throws SSLProtocolException {
String message = Alerts.alertDescription(description);
--- a/jdk/src/share/classes/sun/security/ssl/DHClientKeyExchange.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/DHClientKeyExchange.java Mon Dec 10 20:58:36 2012 -0800
@@ -39,6 +39,7 @@
*/
final class DHClientKeyExchange extends HandshakeMessage {
+ @Override
int messageType() {
return ht_client_key_exchange;
}
@@ -75,6 +76,7 @@
dh_Yc = input.getBytes16();
}
+ @Override
int messageLength() {
if (dh_Yc == null) {
return 0;
@@ -83,10 +85,12 @@
}
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(dh_Yc);
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** ClientKeyExchange, DH");
--- a/jdk/src/share/classes/sun/security/ssl/ECDHClientKeyExchange.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ECDHClientKeyExchange.java Mon Dec 10 20:58:36 2012 -0800
@@ -41,6 +41,7 @@
*/
final class ECDHClientKeyExchange extends HandshakeMessage {
+ @Override
int messageType() {
return ht_client_key_exchange;
}
@@ -63,14 +64,17 @@
encodedPoint = input.getBytes8();
}
+ @Override
int messageLength() {
return encodedPoint.length + 1;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes8(encodedPoint);
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** ECDHClientKeyExchange");
--- a/jdk/src/share/classes/sun/security/ssl/ECDHCrypt.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ECDHCrypt.java Mon Dec 10 20:58:36 2012 -0800
@@ -31,7 +31,6 @@
import javax.crypto.SecretKey;
import javax.crypto.KeyAgreement;
-import javax.crypto.spec.*;
/**
* Helper class for the ECDH key exchange. It generates the appropriate
--- a/jdk/src/share/classes/sun/security/ssl/EngineInputRecord.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/EngineInputRecord.java Mon Dec 10 20:58:36 2012 -0800
@@ -64,6 +64,7 @@
this.engine = engine;
}
+ @Override
byte contentType() {
if (internalData) {
return super.contentType();
@@ -271,6 +272,7 @@
* data to be generated/output before the exception is ever
* generated.
*/
+ @Override
void writeBuffer(OutputStream s, byte [] buf, int off, int len)
throws IOException {
/*
--- a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,9 +29,6 @@
import java.io.*;
import java.nio.*;
-import javax.net.ssl.SSLException;
-import sun.misc.HexDumpEncoder;
-
/**
* A OutputRecord class extension which uses external ByteBuffers
@@ -95,6 +92,7 @@
finishedMsg = true;
}
+ @Override
public void flush() throws IOException {
finishedMsg = false;
}
--- a/jdk/src/share/classes/sun/security/ssl/EngineWriter.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/EngineWriter.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,7 +25,6 @@
package sun.security.ssl;
-import javax.net.ssl.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
--- a/jdk/src/share/classes/sun/security/ssl/ExtensionType.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ExtensionType.java Mon Dec 10 20:58:36 2012 -0800
@@ -38,6 +38,7 @@
this.name = name;
}
+ @Override
public String toString() {
return name;
}
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeHash.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeHash.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,11 +28,7 @@
import java.io.ByteArrayOutputStream;
import java.security.*;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Locale;
-import java.util.Set;
/**
* Abstraction for the SSL/TLS hash of all handshake messages that is
@@ -52,28 +48,23 @@
* 1. protocolDetermined(version) should be called when the negotiated
* protocol version is determined.
*
- * 2. Before protocolDetermined() is called, only update(), reset(),
- * restrictCertificateVerifyAlgs(), setFinishedAlg(), and
- * setCertificateVerifyAlg() can be called.
+ * 2. Before protocolDetermined() is called, only update(), and reset()
+ * and setFinishedAlg() can be called.
*
* 3. After protocolDetermined() is called, reset() cannot be called.
*
* 4. After protocolDetermined() is called, if the version is pre-TLS 1.2,
- * getFinishedHash() and getCertificateVerifyHash() cannot be called. Otherwise,
+ * getFinishedHash() cannot be called. Otherwise,
* getMD5Clone() and getSHAClone() cannot be called.
*
* 5. getMD5Clone() and getSHAClone() can only be called after
* protocolDetermined() is called and version is pre-TLS 1.2.
*
- * 6. getFinishedHash() and getCertificateVerifyHash() can only be called after
- * all protocolDetermined(), setCertificateVerifyAlg() and setFinishedAlg()
- * have been called and the version is TLS 1.2. If a CertificateVerify message
- * is to be used, call setCertificateVerifyAlg() with the hash algorithm as the
- * argument. Otherwise, you still must call setCertificateVerifyAlg(null) before
- * calculating any hash value.
+ * 6. getFinishedHash() can only be called after protocolDetermined()
+ * and setFinishedAlg() have been called and the version is TLS 1.2.
*
- * Suggestions: Call protocolDetermined(), restrictCertificateVerifyAlgs(),
- * setFinishedAlg(), and setCertificateVerifyAlg() as early as possible.
+ * Suggestion: Call protocolDetermined() and setFinishedAlg()
+ * as early as possible.
*
* Example:
* <pre>
@@ -83,21 +74,13 @@
* hh.setFinishedAlg("SHA-256");
* hh.update(serverHelloBytes);
* ...
- * hh.setCertificateVerifyAlg("SHA-384");
* hh.update(CertificateVerifyBytes);
- * byte[] cvDigest = hh.getCertificateVerifyHash();
* ...
* hh.update(finished1);
* byte[] finDigest1 = hh.getFinishedHash();
* hh.update(finished2);
* byte[] finDigest2 = hh.getFinishedHash();
* </pre>
- * If no CertificateVerify message is to be used, call
- * <pre>
- * hh.setCertificateVerifyAlg(null);
- * </pre>
- * This call can be made once you are certain that this message
- * will never be used.
*/
final class HandshakeHash {
@@ -108,28 +91,19 @@
// 2: TLS 1.2
private int version = -1;
private ByteArrayOutputStream data = new ByteArrayOutputStream();
- private final boolean isServer;
// For TLS 1.1
private MessageDigest md5, sha;
private final int clonesNeeded; // needs to be saved for later use
// For TLS 1.2
- // cvAlgDetermined == true means setCertificateVerifyAlg() is called
- private boolean cvAlgDetermined = false;
- private String cvAlg;
private MessageDigest finMD;
/**
* Create a new HandshakeHash. needCertificateVerify indicates whether
- * a hash for the certificate verify message is required. The argument
- * algs is a set of all possible hash algorithms that might be used in
- * TLS 1.2. If the caller is sure that TLS 1.2 won't be used or no
- * CertificateVerify message will be used, leave it null or empty.
+ * a hash for the certificate verify message is required.
*/
- HandshakeHash(boolean isServer, boolean needCertificateVerify,
- Set<String> algs) {
- this.isServer = isServer;
+ HandshakeHash(boolean needCertificateVerify) {
clonesNeeded = needCertificateVerify ? 3 : 2;
}
@@ -259,47 +233,11 @@
finMD.update(data.toByteArray());
}
- /**
- * Restricts the possible algorithms for the CertificateVerify. Called by
- * the server based on info in CertRequest. The argument must be a subset
- * of the argument with the same name in the constructor. The method can be
- * called multiple times. If the caller is sure that no CertificateVerify
- * message will be used, leave this argument null or empty.
- */
- void restrictCertificateVerifyAlgs(Set<String> algs) {
- if (version == 1) {
- throw new RuntimeException(
- "setCertificateVerifyAlg() cannot be called for TLS 1.1");
- }
- // Not used yet
- }
-
- /**
- * Specifies the hash algorithm used in CertificateVerify.
- * Can be called multiple times.
- */
- void setCertificateVerifyAlg(String s) {
-
- // Can be called multiple times, but only set once
- if (cvAlgDetermined) return;
-
- cvAlg = s == null ? null : normalizeAlgName(s);
- cvAlgDetermined = true;
- }
-
byte[] getAllHandshakeMessages() {
return data.toByteArray();
}
/**
- * Calculates the hash in the CertificateVerify. Must be called right
- * after setCertificateVerifyAlg()
- */
- /*byte[] getCertificateVerifyHash() {
- throw new Error("Do not call getCertificateVerifyHash()");
- }*/
-
- /**
* Calculates the hash in Finished. Must be called after setFinishedAlg().
* This method can be called twice, for Finished messages of the server
* side and client side respectively.
@@ -391,11 +329,13 @@
// }
}
+ @Override
protected int engineGetDigestLength() {
checkState();
return digests[0].getDigestLength();
}
+ @Override
protected void engineUpdate(byte b) {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
@@ -403,6 +343,7 @@
}
}
+ @Override
protected void engineUpdate(byte[] b, int offset, int len) {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
@@ -410,6 +351,7 @@
}
}
+ @Override
protected byte[] engineDigest() {
checkState();
byte[] digest = digests[0].digest();
@@ -417,6 +359,7 @@
return digest;
}
+ @Override
protected int engineDigest(byte[] buf, int offset, int len)
throws DigestException {
checkState();
@@ -436,6 +379,7 @@
}
}
+ @Override
protected void engineReset() {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
@@ -443,6 +387,7 @@
}
}
+ @Override
public Object clone() {
checkState();
for (int i = digests.length - 1; i >= 0; i--) {
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,6 @@
import java.io.InputStream;
import java.io.IOException;
-import java.security.MessageDigest;
import javax.net.ssl.SSLException;
@@ -74,6 +73,7 @@
* Note that this returns the bytes remaining in the buffer, not
* the bytes remaining in the current handshake message.
*/
+ @Override
public int available() {
return r.available();
}
@@ -81,6 +81,7 @@
/*
* Get a byte of handshake data.
*/
+ @Override
public int read() throws IOException {
int n = r.read();
if (n == -1) {
@@ -92,6 +93,7 @@
/*
* Get a bunch of bytes of handshake data.
*/
+ @Override
public int read(byte b [], int off, int len) throws IOException {
// we read from a ByteArrayInputStream, it always returns the
// data in a single read if enough is available
@@ -105,6 +107,7 @@
/*
* Skip some handshake data.
*/
+ @Override
public long skip(long n) throws IOException {
return r.skip(n);
}
@@ -117,6 +120,7 @@
* read, data that has already been consumed is lost even if marked).
*/
+ @Override
public void mark(int readlimit) {
r.mark(readlimit);
}
@@ -126,6 +130,7 @@
r.reset();
}
+ @Override
public boolean markSupported() {
return true;
}
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java Mon Dec 10 20:58:36 2012 -0800
@@ -170,6 +170,7 @@
* session parameters after a connection has been (re)established.
*/
static final class HelloRequest extends HandshakeMessage {
+ @Override
int messageType() { return ht_hello_request; }
HelloRequest() { }
@@ -179,13 +180,16 @@
// nothing in this message
}
+ @Override
int messageLength() { return 0; }
+ @Override
void send(HandshakeOutStream out) throws IOException
{
// nothing in this messaage
}
+ @Override
void print(PrintStream out) throws IOException
{
out.println("*** HelloRequest (empty)");
@@ -329,6 +333,7 @@
static final
class ServerHello extends HandshakeMessage
{
+ @Override
int messageType() { return ht_server_hello; }
ProtocolVersion protocolVersion;
@@ -355,6 +360,7 @@
}
}
+ @Override
int messageLength()
{
// almost fixed size, except session ID and extensions:
@@ -366,6 +372,7 @@
return 38 + sessionId.length() + extensions.length();
}
+ @Override
void send(HandshakeOutStream s) throws IOException
{
s.putInt8(protocolVersion.major);
@@ -378,6 +385,7 @@
extensions.send(s);
}
+ @Override
void print(PrintStream s) throws IOException
{
s.println("*** ServerHello, " + protocolVersion);
@@ -386,8 +394,6 @@
s.print("RandomCookie: ");
svr_random.print(s);
- int i;
-
s.print("Session ID: ");
s.println(sessionId);
@@ -416,6 +422,7 @@
static final
class CertificateMsg extends HandshakeMessage
{
+ @Override
int messageType() { return ht_certificate; }
private X509Certificate[] chain;
@@ -450,6 +457,7 @@
chain = v.toArray(new X509Certificate[v.size()]);
}
+ @Override
int messageLength() {
if (encodedChain == null) {
messageLength = 3;
@@ -468,6 +476,7 @@
return messageLength;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt24(messageLength() - 3);
for (byte[] b : encodedChain) {
@@ -475,6 +484,7 @@
}
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** Certificate chain");
@@ -528,6 +538,7 @@
*/
static abstract class ServerKeyExchange extends HandshakeMessage
{
+ @Override
int messageType() { return ht_server_key_exchange; }
}
@@ -635,17 +646,20 @@
return signature.verify(signatureBytes);
}
+ @Override
int messageLength() {
return 6 + rsa_modulus.length + rsa_exponent.length
+ signatureBytes.length;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(rsa_modulus);
s.putBytes16(rsa_exponent);
s.putBytes16(signatureBytes);
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** RSA ServerKeyExchange");
@@ -874,6 +888,7 @@
dh_Ys = toByteArray(obj.getPublicKey());
}
+ @Override
int messageLength() {
int temp = 6; // overhead for p, g, y(s) values.
@@ -895,6 +910,7 @@
return temp;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(dh_p);
s.putBytes16(dh_g);
@@ -914,6 +930,7 @@
}
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** Diffie-Hellman ServerKeyExchange");
@@ -1118,6 +1135,7 @@
sig.update(pointBytes);
}
+ @Override
int messageLength() {
int sigLen = 0;
if (signatureBytes != null) {
@@ -1130,6 +1148,7 @@
return 4 + pointBytes.length + sigLen;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt8(CURVE_NAMED_CURVE);
s.putInt16(curveId);
@@ -1145,6 +1164,7 @@
}
}
+ @Override
void print(PrintStream s) throws IOException {
s.println("*** ECDH ServerKeyExchange");
@@ -1479,6 +1499,7 @@
static final
class ServerHelloDone extends HandshakeMessage
{
+ @Override
int messageType() { return ht_server_hello_done; }
ServerHelloDone() { }
@@ -1488,16 +1509,19 @@
// nothing to do
}
+ @Override
int messageLength()
{
return 0;
}
+ @Override
void send(HandshakeOutStream s) throws IOException
{
// nothing to send
}
+ @Override
void print(PrintStream s) throws IOException
{
s.println("*** ServerHelloDone");
@@ -1712,6 +1736,7 @@
private static void makeAccessible(final AccessibleObject o) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
public Object run() {
o.setAccessible(true);
return null;
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeOutStream.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeOutStream.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,6 @@
import java.io.OutputStream;
import java.io.IOException;
-import java.security.MessageDigest;
/**
* Output stream for handshake data. This is used only internally
@@ -87,6 +86,7 @@
* Hashes are updated automatically if something gets flushed to the
* network (e.g. a big cert message etc).
*/
+ @Override
public void write(byte buf[], int off, int len) throws IOException {
while (len > 0) {
int howmuch = Math.min(len, r.availableDataBytes());
@@ -104,6 +104,7 @@
/*
* write-a-byte
*/
+ @Override
public void write(int i) throws IOException {
if (r.availableDataBytes() < 1) {
flush();
@@ -111,6 +112,7 @@
r.write(i);
}
+ @Override
public void flush() throws IOException {
if (socket != null) {
try {
--- a/jdk/src/share/classes/sun/security/ssl/Handshaker.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/Handshaker.java Mon Dec 10 20:58:36 2012 -0800
@@ -489,11 +489,7 @@
// We accumulate digests of the handshake messages so that
// we can read/write CertificateVerify and Finished messages,
// getting assurance against some particular active attacks.
- Set<String> localSupportedHashAlgorithms =
- SignatureAndHashAlgorithm.getHashAlgorithmNames(
- getLocalSupportedSignAlgs());
- handshakeHash = new HandshakeHash(!isClient, needCertVerify,
- localSupportedHashAlgorithms);
+ handshakeHash = new HandshakeHash(needCertVerify);
// Generate handshake input/output stream.
input = new HandshakeInStream(handshakeHash);
@@ -820,6 +816,7 @@
processLoop();
} else {
delegateTask(new PrivilegedExceptionAction<Void>() {
+ @Override
public Void run() throws Exception {
processLoop();
return null;
--- a/jdk/src/share/classes/sun/security/ssl/HelloExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HelloExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -40,6 +40,7 @@
abstract void send(HandshakeOutStream s) throws IOException;
+ @Override
public abstract String toString();
}
--- a/jdk/src/share/classes/sun/security/ssl/HelloExtensions.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/HelloExtensions.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,8 +29,6 @@
import java.io.PrintStream;
import java.util.*;
import javax.net.ssl.*;
-import java.nio.charset.StandardCharsets;
-import java.security.spec.ECParameterSpec;
/**
* This file contains all the classes relevant to TLS Extensions for the
--- a/jdk/src/share/classes/sun/security/ssl/InputRecord.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/InputRecord.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,8 +28,6 @@
import java.io.*;
import java.nio.*;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
import javax.crypto.BadPaddingException;
@@ -285,6 +283,7 @@
* Prevent any more data from being read into this record,
* and flag the record as holding no data.
*/
+ @Override
public void close() {
appDataValid = false;
isClosed = true;
--- a/jdk/src/share/classes/sun/security/ssl/JsseJce.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/JsseJce.java Mon Dec 10 20:58:36 2012 -0800
@@ -54,8 +54,6 @@
*/
final class JsseJce {
- private final static Debug debug = Debug.getInstance("ssl");
-
private final static ProviderList fipsProviderList;
// Flag indicating whether EC crypto is available.
@@ -71,6 +69,7 @@
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>() {
+ @Override
public Void run() throws Exception {
// Test for Kerberos using the bootstrap class loader
Class.forName("sun.security.krb5.PrincipalName", true,
@@ -114,6 +113,7 @@
SunCertificates(final Provider p) {
super("SunCertificates", 1.0d, "SunJSSE internal");
AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
public Object run() {
// copy certificate related services from the Sun provider
for (Map.Entry<Object,Object> entry : p.entrySet()) {
--- a/jdk/src/share/classes/sun/security/ssl/KerberosClientKeyExchange.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/KerberosClientKeyExchange.java Mon Dec 10 20:58:36 2012 -0800
@@ -44,6 +44,7 @@
private static final Class<?> implClass = AccessController.doPrivileged(
new PrivilegedAction<Class<?>>() {
+ @Override
public Class<?> run() {
try {
return Class.forName(IMPL_CLASS, true, null);
--- a/jdk/src/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -45,6 +45,7 @@
/**
* Returns one key manager for each type of key material.
*/
+ @Override
protected KeyManager[] engineGetKeyManagers() {
if (!isInitialized) {
throw new IllegalStateException(
@@ -56,6 +57,7 @@
// Factory for the SunX509 keymanager
public static final class SunX509 extends KeyManagerFactoryImpl {
+ @Override
protected void engineInit(KeyStore ks, char[] password) throws
KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException {
@@ -69,6 +71,7 @@
isInitialized = true;
}
+ @Override
protected void engineInit(ManagerFactoryParameters spec) throws
InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException(
@@ -80,6 +83,7 @@
// Factory for the X509 keymanager
public static final class X509 extends KeyManagerFactoryImpl {
+ @Override
protected void engineInit(KeyStore ks, char[] password) throws
KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException {
@@ -102,6 +106,7 @@
isInitialized = true;
}
+ @Override
protected void engineInit(ManagerFactoryParameters params) throws
InvalidAlgorithmParameterException {
if (params instanceof KeyStoreBuilderParameters == false) {
--- a/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java Mon Dec 10 20:58:36 2012 -0800
@@ -47,6 +47,7 @@
private static final Krb5Proxy proxy =
AccessController.doPrivileged(new PrivilegedAction<Krb5Proxy>() {
+ @Override
public Krb5Proxy run() {
try {
Class<?> c = Class.forName(IMPL_CLASS, true, null);
--- a/jdk/src/share/classes/sun/security/ssl/MAC.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/MAC.java Mon Dec 10 20:58:36 2012 -0800
@@ -58,9 +58,6 @@
// Value of the null MAC is fixed
private static final byte nullMAC[] = new byte[0];
- // internal identifier for the MAC algorithm
- private final MacAlg macAlg;
-
// stuff defined by the kind of MAC algorithm
private final int macSize;
@@ -85,7 +82,6 @@
private MAC() {
macSize = 0;
- macAlg = M_NULL;
mac = null;
block = null;
}
@@ -95,7 +91,6 @@
*/
MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
throws NoSuchAlgorithmException, InvalidKeyException {
- this.macAlg = macAlg;
this.macSize = macAlg.size;
String algorithm;
--- a/jdk/src/share/classes/sun/security/ssl/OutputRecord.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/OutputRecord.java Mon Dec 10 20:58:36 2012 -0800
@@ -116,6 +116,7 @@
* Reset the record so that it can be refilled, starting
* immediately after the header.
*/
+ @Override
public synchronized void reset() {
super.reset();
count = headerSize;
--- a/jdk/src/share/classes/sun/security/ssl/ProtocolList.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ProtocolList.java Mon Dec 10 20:58:36 2012 -0800
@@ -147,6 +147,7 @@
return protocolNames.clone();
}
+ @Override
public String toString() {
return protocols.toString();
}
--- a/jdk/src/share/classes/sun/security/ssl/ProtocolVersion.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ProtocolVersion.java Mon Dec 10 20:58:36 2012 -0800
@@ -165,6 +165,7 @@
}
}
+ @Override
public String toString() {
return name;
}
@@ -172,6 +173,7 @@
/**
* Compares this object with the specified object for order.
*/
+ @Override
public int compareTo(ProtocolVersion protocolVersion) {
return this.v - protocolVersion.v;
}
--- a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,10 +28,8 @@
import java.io.*;
import java.security.*;
-import java.security.interfaces.*;
import javax.crypto.*;
-import javax.crypto.spec.*;
import javax.net.ssl.*;
--- a/jdk/src/share/classes/sun/security/ssl/RSASignature.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/RSASignature.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,8 +26,6 @@
package sun.security.ssl;
-import java.util.Arrays;
-
import java.security.*;
/**
@@ -106,6 +104,7 @@
}
}
+ @Override
protected void engineInitVerify(PublicKey publicKey)
throws InvalidKeyException {
checkNull(publicKey);
@@ -113,11 +112,13 @@
rawRsa.initVerify(publicKey);
}
+ @Override
protected void engineInitSign(PrivateKey privateKey)
throws InvalidKeyException {
engineInitSign(privateKey, null);
}
+ @Override
protected void engineInitSign(PrivateKey privateKey, SecureRandom random)
throws InvalidKeyException {
checkNull(privateKey);
@@ -133,6 +134,7 @@
}
}
+ @Override
protected void engineUpdate(byte b) {
initDigests();
isReset = false;
@@ -140,6 +142,7 @@
sha.update(b);
}
+ @Override
protected void engineUpdate(byte[] b, int off, int len) {
initDigests();
isReset = false;
@@ -161,21 +164,25 @@
}
}
+ @Override
protected byte[] engineSign() throws SignatureException {
rawRsa.update(getDigest());
return rawRsa.sign();
}
+ @Override
protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
return engineVerify(sigBytes, 0, sigBytes.length);
}
+ @Override
protected boolean engineVerify(byte[] sigBytes, int offset, int length)
throws SignatureException {
rawRsa.update(getDigest());
return rawRsa.verify(sigBytes, offset, length);
}
+ @Override
protected void engineSetParameter(String param, Object value)
throws InvalidParameterException {
if (param.equals("hashes") == false) {
@@ -191,6 +198,7 @@
sha = digests[1];
}
+ @Override
protected Object engineGetParameter(String param)
throws InvalidParameterException {
throw new InvalidParameterException("Parameters not supported");
--- a/jdk/src/share/classes/sun/security/ssl/RenegotiationInfoExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/RenegotiationInfoExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -85,10 +85,12 @@
// Length of the encoded extension, including the type and length fields
+ @Override
int length() {
return 5 + renegotiated_connection.length;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putInt16(renegotiated_connection.length + 1);
@@ -103,6 +105,7 @@
return renegotiated_connection;
}
+ @Override
public String toString() {
return "Extension " + type + ", renegotiated_connection: " +
(renegotiated_connection.length == 0 ? "<empty>" :
--- a/jdk/src/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Mon Dec 10 20:58:36 2012 -0800
@@ -111,6 +111,7 @@
}
}
+ @Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
@@ -139,6 +140,7 @@
return permitted;
}
+ @Override
public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
boolean permitted = true;
@@ -162,6 +164,7 @@
return permitted;
}
+ @Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
@@ -204,6 +207,7 @@
}
}
+ @Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
@@ -237,10 +241,12 @@
return false;
}
+ @Override
final public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
return true;
}
+ @Override
final public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
--- a/jdk/src/share/classes/sun/security/ssl/SSLContextImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLContextImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -71,6 +71,7 @@
serverCache = new SSLSessionContextImpl();
}
+ @Override
protected void engineInit(KeyManager[] km, TrustManager[] tm,
SecureRandom sr) throws KeyManagementException {
isInitialized = false;
@@ -177,6 +178,7 @@
return DummyX509KeyManager.INSTANCE;
}
+ @Override
protected SSLSocketFactory engineGetSocketFactory() {
if (!isInitialized) {
throw new IllegalStateException(
@@ -185,6 +187,7 @@
return new SSLSocketFactoryImpl(this);
}
+ @Override
protected SSLServerSocketFactory engineGetServerSocketFactory() {
if (!isInitialized) {
throw new IllegalStateException("SSLContext is not initialized");
@@ -192,6 +195,7 @@
return new SSLServerSocketFactoryImpl(this);
}
+ @Override
protected SSLEngine engineCreateSSLEngine() {
if (!isInitialized) {
throw new IllegalStateException(
@@ -200,6 +204,7 @@
return new SSLEngineImpl(this);
}
+ @Override
protected SSLEngine engineCreateSSLEngine(String host, int port) {
if (!isInitialized) {
throw new IllegalStateException(
@@ -208,10 +213,12 @@
return new SSLEngineImpl(this, host, port);
}
+ @Override
protected SSLSessionContext engineGetClientSessionContext() {
return clientCache;
}
+ @Override
protected SSLSessionContext engineGetServerSessionContext() {
return serverCache;
}
@@ -463,14 +470,17 @@
}
}
+ @Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
+ @Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
+ @Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
@@ -506,6 +516,7 @@
}
}
+ @Override
protected void engineInit(KeyManager[] km, TrustManager[] tm,
SecureRandom sr) throws KeyManagementException {
throw new KeyManagementException
@@ -544,6 +555,7 @@
final Map<String,String> props = new HashMap<>();
AccessController.doPrivileged(
new PrivilegedExceptionAction<Object>() {
+ @Override
public Object run() throws Exception {
props.put("keyStore", System.getProperty(
"javax.net.ssl.keyStore", ""));
@@ -583,6 +595,7 @@
!NONE.equals(defaultKeyStore)) {
fs = AccessController.doPrivileged(
new PrivilegedExceptionAction<FileInputStream>() {
+ @Override
public FileInputStream run() throws Exception {
return new FileInputStream(defaultKeyStore);
}
@@ -697,14 +710,17 @@
}
}
+ @Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
+ @Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
+ @Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
@@ -761,14 +777,17 @@
}
}
+ @Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
+ @Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
+ @Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
@@ -1041,28 +1060,34 @@
this.km = km;
}
+ @Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return km.getClientAliases(keyType, issuers);
}
+ @Override
public String chooseClientAlias(String[] keyType, Principal[] issuers,
Socket socket) {
return km.chooseClientAlias(keyType, issuers, socket);
}
+ @Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return km.getServerAliases(keyType, issuers);
}
+ @Override
public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) {
return km.chooseServerAlias(keyType, issuers, socket);
}
+ @Override
public X509Certificate[] getCertificateChain(String alias) {
return km.getCertificateChain(alias);
}
+ @Override
public PrivateKey getPrivateKey(String alias) {
return km.getPrivateKey(alias);
}
@@ -1087,6 +1112,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return null;
}
@@ -1096,6 +1122,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
return null;
@@ -1106,6 +1133,7 @@
* engine given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseEngineClientAlias(
String[] keyTypes, Principal[] issuers, SSLEngine engine) {
return null;
@@ -1116,6 +1144,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return null;
}
@@ -1125,6 +1154,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) {
return null;
@@ -1135,6 +1165,7 @@
* given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseEngineServerAlias(
String keyType, Principal[] issuers, SSLEngine engine) {
return null;
@@ -1148,6 +1179,7 @@
* @return the certificate chain (ordered with the user's certificate first
* and the root certificate authority last)
*/
+ @Override
public X509Certificate[] getCertificateChain(String alias) {
return null;
}
@@ -1160,6 +1192,7 @@
*
* @return the requested key
*/
+ @Override
public PrivateKey getPrivateKey(String alias) {
return null;
}
--- a/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -553,6 +553,7 @@
/*
* Is a handshake currently underway?
*/
+ @Override
public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
return getHSStatus(null);
}
@@ -736,6 +737,7 @@
/*
* Start a SSLEngine handshake
*/
+ @Override
public void beginHandshake() throws SSLException {
try {
kickstartHandshake();
@@ -755,6 +757,7 @@
* Unwraps a buffer. Does a variety of checks before grabbing
* the unwrapLock, which blocks multiple unwraps from occuring.
*/
+ @Override
public SSLEngineResult unwrap(ByteBuffer netData, ByteBuffer [] appData,
int offset, int length) throws SSLException {
@@ -1155,6 +1158,7 @@
* Wraps a buffer. Does a variety of checks before grabbing
* the wrapLock, which blocks multiple wraps from occuring.
*/
+ @Override
public SSLEngineResult wrap(ByteBuffer [] appData,
int offset, int length, ByteBuffer netData) throws SSLException {
@@ -1476,6 +1480,7 @@
connectionState = cs_CLOSED;
}
+ @Override
synchronized public void closeOutbound() {
/*
* Dump out a close_notify to the remote side
@@ -1491,6 +1496,7 @@
/**
* Returns the outbound application data closure state
*/
+ @Override
public boolean isOutboundDone() {
return writer.isOutboundDone();
}
@@ -1527,6 +1533,7 @@
* lock here, and do the real work in the internal verison.
* We do check for truncation attacks.
*/
+ @Override
synchronized public void closeInbound() throws SSLException {
/*
* Currently closes the outbound side as well. The IETF TLS
@@ -1559,6 +1566,7 @@
/**
* Returns the network inbound data closure state
*/
+ @Override
synchronized public boolean isInboundDone() {
return inboundDone;
}
@@ -1576,6 +1584,7 @@
* These can be long lived, and frequently correspond to an
* entire login session for some user.
*/
+ @Override
synchronized public SSLSession getSession() {
return sess;
}
@@ -1593,6 +1602,7 @@
* Returns a delegated <code>Runnable</code> task for
* this <code>SSLEngine</code>.
*/
+ @Override
synchronized public Runnable getDelegatedTask() {
if (handshaker != null) {
return handshaker.getTask();
@@ -1847,6 +1857,7 @@
* whether we enable session creations. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
@@ -1859,6 +1870,7 @@
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
+ @Override
synchronized public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
@@ -1872,6 +1884,7 @@
* whether client authentication is needed. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
@@ -1883,6 +1896,7 @@
}
}
+ @Override
synchronized public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
@@ -1895,6 +1909,7 @@
* whether client authentication is requested. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
@@ -1906,6 +1921,7 @@
}
}
+ @Override
synchronized public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
@@ -1916,6 +1932,7 @@
* client or server mode. Must be called before any SSL
* traffic has started.
*/
+ @Override
@SuppressWarnings("fallthrough")
synchronized public void setUseClientMode(boolean flag) {
switch (connectionState) {
@@ -1979,6 +1996,7 @@
}
}
+ @Override
synchronized public boolean getUseClientMode() {
return !roleIsServer;
}
@@ -1994,6 +2012,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
@@ -2007,6 +2026,7 @@
*
* @param suites Names of all the cipher suites to enable.
*/
+ @Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
if ((handshaker != null) && !handshaker.activated()) {
@@ -2024,6 +2044,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
@@ -2034,6 +2055,7 @@
* A subset of the supported protocols may be enabled for this connection
* @return an array of protocol names.
*/
+ @Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
@@ -2047,6 +2069,7 @@
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
+ @Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
if ((handshaker != null) && !handshaker.activated()) {
@@ -2054,6 +2077,7 @@
}
}
+ @Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
@@ -2061,6 +2085,7 @@
/**
* Returns the SSLParameters in effect for this SSLEngine.
*/
+ @Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
@@ -2076,6 +2101,7 @@
/**
* Applies SSLParameters to this engine.
*/
+ @Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
@@ -2107,6 +2133,7 @@
/**
* Returns a printable representation of this end of the connection.
*/
+ @Override
public String toString() {
StringBuilder retval = new StringBuilder(80);
--- a/jdk/src/share/classes/sun/security/ssl/SSLServerSocketFactoryImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLServerSocketFactoryImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -67,10 +67,12 @@
* @throws IOException if the socket cannot be created
* @see java.net.Socket#bind(java.net.SocketAddress)
*/
+ @Override
public ServerSocket createServerSocket() throws IOException {
return new SSLServerSocketImpl(context);
}
+ @Override
public ServerSocket createServerSocket (int port)
throws IOException
{
@@ -78,12 +80,14 @@
}
+ @Override
public ServerSocket createServerSocket (int port, int backlog)
throws IOException
{
return new SSLServerSocketImpl (port, backlog, context);
}
+ @Override
public ServerSocket
createServerSocket (int port, int backlog, InetAddress ifAddress)
throws IOException
@@ -98,6 +102,7 @@
* (preventing person-in-the-middle attacks) and where traffic
* is encrypted to provide confidentiality.
*/
+ @Override
public String[] getDefaultCipherSuites() {
return context.getDefaultCipherSuiteList(true).toStringArray();
}
@@ -112,6 +117,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
public String[] getSupportedCipherSuites() {
return context.getSupportedCipherSuiteList().toStringArray();
}
--- a/jdk/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,13 +29,11 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
-import java.net.ServerSocket;
import java.security.AlgorithmConstraints;
import java.util.*;
-import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLParameters;
@@ -84,9 +82,6 @@
/* which protocol to use by default */
private ProtocolList enabledProtocols = null;
- /* could enabledCipherSuites ever complete handshaking? */
- private boolean checkedEnabled = false;
-
// the endpoint identification protocol to use by default
private String identificationProtocol = null;
@@ -172,6 +167,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
@@ -181,6 +177,7 @@
* for use by newly accepted connections. A null return indicates
* that the system defaults are in effect.
*/
+ @Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
@@ -192,11 +189,12 @@
* @param suites Names of all the cipher suites to enable; null
* means to accept system defaults.
*/
+ @Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
- checkedEnabled = false;
}
+ @Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
@@ -210,10 +208,12 @@
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
+ @Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
}
+ @Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
@@ -222,11 +222,13 @@
* Controls whether the connections which are accepted must include
* client authentication.
*/
+ @Override
public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
}
+ @Override
public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
@@ -235,11 +237,13 @@
* Controls whether the connections which are accepted should request
* client authentication.
*/
+ @Override
public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
}
+ @Override
public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
@@ -250,6 +254,7 @@
* FTP clients, which accept connections from servers and should be
* rejoining the already-negotiated SSL connection.
*/
+ @Override
public void setUseClientMode(boolean flag) {
/*
* If we need to change the socket mode and the enabled
@@ -264,6 +269,7 @@
useServerMode = !flag;
}
+ @Override
public boolean getUseClientMode() {
return !useServerMode;
}
@@ -273,6 +279,7 @@
* Controls whether new connections may cause creation of new SSL
* sessions.
*/
+ @Override
public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
}
@@ -281,6 +288,7 @@
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
+ @Override
public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
@@ -288,6 +296,7 @@
/**
* Returns the SSLParameters in effect for newly accepted connections.
*/
+ @Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
@@ -302,6 +311,7 @@
/**
* Applies SSLParameters to newly accepted connections.
*/
+ @Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
@@ -319,6 +329,7 @@
* information provided in the authentication context which was
* presented during construction.
*/
+ @Override
public Socket accept() throws IOException {
SSLSocketImpl s = new SSLSocketImpl(sslContext, useServerMode,
enabledCipherSuites, doClientAuth, enableSessionCreation,
@@ -333,6 +344,7 @@
/**
* Provides a brief description of this SSL socket.
*/
+ @Override
public String toString() {
return "[SSL: "+ super.toString() + "]";
}
--- a/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,24 +26,14 @@
package sun.security.ssl;
-import java.io.*;
-import java.net.*;
-import java.util.Date;
import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.NoSuchElementException;
import java.util.Vector;
import java.util.Locale;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
-import javax.net.ssl.SSLSessionBindingListener;
-import javax.net.ssl.SSLSessionBindingEvent;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSession;
import sun.security.util.Cache;
-import sun.security.util.Cache.CacheVisitor;
final class SSLSessionContextImpl implements SSLSessionContext {
@@ -54,8 +44,6 @@
private int cacheLimit; // the max cache size
private int timeout; // timeout in seconds
- private static final Debug debug = Debug.getInstance("ssl");
-
// package private
SSLSessionContextImpl() {
cacheLimit = getDefaultCacheLimit(); // default cache size
@@ -69,6 +57,7 @@
/**
* Returns the <code>SSLSession</code> bound to the specified session id.
*/
+ @Override
public SSLSession getSession(byte[] sessionId) {
if (sessionId == null) {
throw new NullPointerException("session id cannot be null");
@@ -85,6 +74,7 @@
/**
* Returns an enumeration of the active SSL sessions.
*/
+ @Override
public Enumeration<byte[]> getIds() {
SessionCacheVisitor scVisitor = new SessionCacheVisitor();
sessionCache.accept(scVisitor);
@@ -99,6 +89,7 @@
* should be timed within the shorter one of the old timeout and the
* new timeout.
*/
+ @Override
public void setSessionTimeout(int seconds)
throws IllegalArgumentException {
if (seconds < 0) {
@@ -115,6 +106,7 @@
/**
* Gets the timeout limit for cached <code>SSLSession</code> objects
*/
+ @Override
public int getSessionTimeout() {
return timeout;
}
@@ -123,6 +115,7 @@
* Sets the size of the cache used for storing
* <code>SSLSession</code> objects.
*/
+ @Override
public void setSessionCacheSize(int size)
throws IllegalArgumentException {
if (size < 0)
@@ -139,6 +132,7 @@
* Gets the size of the cache used for storing
* <code>SSLSession</code> objects.
*/
+ @Override
public int getSessionCacheSize() {
return cacheLimit;
}
@@ -207,6 +201,7 @@
try {
String s = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
+ @Override
public String run() {
return System.getProperty(
"javax.net.ssl.sessionCacheSize");
@@ -238,6 +233,7 @@
Vector<byte[]> ids = null;
// public void visit(java.util.Map<K,V> map) {}
+ @Override
public void visit(java.util.Map<SessionId, SSLSessionImpl> map) {
ids = new Vector<>(map.size());
--- a/jdk/src/share/classes/sun/security/ssl/SSLSessionImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSessionImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,12 +26,10 @@
package sun.security.ssl;
-import java.io.*;
import java.net.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -45,20 +43,14 @@
import javax.crypto.SecretKey;
-import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.SSLSessionBindingListener;
import javax.net.ssl.SSLSessionBindingEvent;
import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLPermission;
-import javax.net.ssl.SSLException;
import javax.net.ssl.ExtendedSSLSession;
import javax.net.ssl.SNIServerName;
-import javax.security.auth.x500.X500Principal;
-
-import static sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
@@ -250,6 +242,7 @@
!invalidated && isLocalAuthenticationValid();
}
+ @Override
public synchronized boolean isValid() {
return isRejoinable();
}
@@ -277,6 +270,7 @@
* Returns the ID for this session. The ID is fixed for the
* duration of the session; neither it, nor its value, changes.
*/
+ @Override
public byte[] getId() {
return sessionId.getId();
}
@@ -286,6 +280,7 @@
* are currently valid in this process. For client sessions,
* this returns null.
*/
+ @Override
public SSLSessionContext getSessionContext() {
/*
* An interim security policy until we can do something
@@ -332,6 +327,7 @@
/**
* Returns the name of the cipher suite in use on this session
*/
+ @Override
public String getCipherSuite() {
return getSuite().name;
}
@@ -343,6 +339,7 @@
/**
* Returns the standard name of the protocol in use on this session
*/
+ @Override
public String getProtocol() {
return getProtocolVersion().name;
}
@@ -357,6 +354,7 @@
/**
* Returns the hashcode for this session
*/
+ @Override
public int hashCode() {
return sessionId.hashCode();
}
@@ -365,6 +363,7 @@
/**
* Returns true if sessions have same ids, false otherwise.
*/
+ @Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -391,6 +390,7 @@
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
+ @Override
public java.security.cert.Certificate[] getPeerCertificates()
throws SSLPeerUnverifiedException {
//
@@ -421,6 +421,7 @@
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
+ @Override
public java.security.cert.Certificate[] getLocalCertificates() {
//
// clone to preserve integrity of session ... caller can't
@@ -440,6 +441,7 @@
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
+ @Override
public javax.security.cert.X509Certificate[] getPeerCertificateChain()
throws SSLPeerUnverifiedException {
//
@@ -511,6 +513,7 @@
* @throws SSLPeerUnverifiedException if the peer's identity has not
* been verified
*/
+ @Override
public Principal getPeerPrincipal()
throws SSLPeerUnverifiedException
{
@@ -537,6 +540,7 @@
* Principal for Kerberos cipher suites. If no principal was
* sent, then null is returned.
*/
+ @Override
public Principal getLocalPrincipal() {
if ((cipherSuite.keyExchange == K_KRB5) ||
@@ -551,6 +555,7 @@
/**
* Returns the time this session was created.
*/
+ @Override
public long getCreationTime() {
return creationTime;
}
@@ -559,6 +564,7 @@
* Returns the last time this session was used to initialize
* a connection.
*/
+ @Override
public long getLastAccessedTime() {
return (lastUsedTime != 0) ? lastUsedTime : creationTime;
}
@@ -582,6 +588,7 @@
}
}
+ @Override
public String getPeerHost() {
return host;
}
@@ -590,6 +597,7 @@
* Need to provide the port info for caching sessions based on
* host and port. Accessed by SSLSessionContextImpl
*/
+ @Override
public int getPeerPort() {
return port;
}
@@ -604,6 +612,7 @@
* Invalidate a session. Active connections may still exist, but
* no connections will be able to rejoin this session.
*/
+ @Override
synchronized public void invalidate() {
//
// Can't invalidate the NULL session -- this would be
@@ -634,6 +643,7 @@
* Assigns a session value. Session change events are given if
* appropriate, to any original value as well as the new value.
*/
+ @Override
public void putValue(String key, Object value) {
if ((key == null) || (value == null)) {
throw new IllegalArgumentException("arguments can not be null");
@@ -660,6 +670,7 @@
/**
* Returns the specified session value.
*/
+ @Override
public Object getValue(String key) {
if (key == null) {
throw new IllegalArgumentException("argument can not be null");
@@ -674,6 +685,7 @@
* Removes the specified session value, delivering a session changed
* event as appropriate.
*/
+ @Override
public void removeValue(String key) {
if (key == null) {
throw new IllegalArgumentException("argument can not be null");
@@ -694,6 +706,7 @@
/**
* Lists the names of the session values.
*/
+ @Override
public String[] getValueNames() {
Enumeration<SecureKey> e;
Vector<Object> v = new Vector<>();
@@ -741,6 +754,7 @@
* Gets the current size of the largest SSL/TLS packet that is expected
* when using this session.
*/
+ @Override
public synchronized int getPacketBufferSize() {
return acceptLargeFragments ?
Record.maxLargeRecordSize : Record.maxRecordSize;
@@ -750,6 +764,7 @@
* Gets the current size of the largest application data that is
* expected when using this session.
*/
+ @Override
public synchronized int getApplicationBufferSize() {
return getPacketBufferSize() - Record.headerSize;
}
@@ -795,6 +810,7 @@
}
/** Returns a string representation of this SSL session */
+ @Override
public String toString() {
return "[Session-" + sessionCount
+ ", " + getCipherSuite()
@@ -805,6 +821,7 @@
* When SSL sessions are finalized, all values bound to
* them are removed.
*/
+ @Override
public void finalize() {
String[] names = getValueNames();
for (int i = 0; i < names.length; i++) {
@@ -847,10 +864,12 @@
return securityCtx;
}
+ @Override
public int hashCode() {
return appKey.hashCode() ^ securityCtx.hashCode();
}
+ @Override
public boolean equals(Object o) {
return o instanceof SecureKey && ((SecureKey)o).appKey.equals(appKey)
&& ((SecureKey)o).securityCtx.equals(securityCtx);
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketFactoryImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketFactoryImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,6 @@
import java.io.*;
import java.net.*;
import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.SSLSocket;
/**
@@ -44,7 +43,6 @@
*/
final public class SSLSocketFactoryImpl extends SSLSocketFactory {
- private static SSLContextImpl defaultContext;
private SSLContextImpl context;
/**
@@ -69,6 +67,7 @@
* @return the unconnected socket
* @see java.net.Socket#connect(java.net.SocketAddress, int)
*/
+ @Override
public Socket createSocket() {
return new SSLSocketImpl(context);
}
@@ -82,6 +81,7 @@
* @param host name of the host with which to connect
* @param port number of the server's port
*/
+ @Override
public Socket createSocket(String host, int port)
throws IOException, UnknownHostException
{
@@ -104,6 +104,7 @@
* @exception IOException if the connection can't be established
* @exception UnknownHostException if the host is not known
*/
+ @Override
public Socket createSocket(Socket s, String host, int port,
boolean autoClose) throws IOException {
return new SSLSocketImpl(context, s, host, port, autoClose);
@@ -129,6 +130,7 @@
* @param address the server's host
* @param port its port
*/
+ @Override
public Socket createSocket(InetAddress address, int port)
throws IOException
{
@@ -143,6 +145,7 @@
* has been configured. The socket will also bind() to the local
* address and port supplied.
*/
+ @Override
public Socket createSocket(String host, int port,
InetAddress clientAddress, int clientPort)
throws IOException
@@ -158,6 +161,7 @@
* context which has been configured. The socket will also bind() to
* the local address and port supplied.
*/
+ @Override
public Socket createSocket(InetAddress address, int port,
InetAddress clientAddress, int clientPort)
throws IOException
@@ -174,6 +178,7 @@
* (preventing person-in-the-middle attacks) and where traffic
* is encrypted to provide confidentiality.
*/
+ @Override
public String[] getDefaultCipherSuites() {
return context.getDefaultCipherSuiteList(false).toStringArray();
}
@@ -186,6 +191,7 @@
* which do not protect data confidentiality. Servers may also need
* certain kinds of certificates to use certain cipher suites.
*/
+ @Override
public String[] getSupportedCipherSuites() {
return context.getSupportedCipherSuiteList().toStringArray();
}
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -36,7 +36,6 @@
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
-import java.nio.charset.StandardCharsets;
import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
@@ -626,6 +625,7 @@
* @throws IOException if an error occurs during the connection
* @throws SocketTimeoutException if timeout expires before connecting
*/
+ @Override
public void connect(SocketAddress endpoint, int timeout)
throws IOException {
@@ -1357,6 +1357,7 @@
/**
* Starts an SSL handshake on this connection.
*/
+ @Override
public void startHandshake() throws IOException {
// start an ssl handshake that could be resumed from timeout exception
startHandshake(true);
@@ -1481,6 +1482,7 @@
/**
* Return whether the socket has been explicitly closed by the application.
*/
+ @Override
public boolean isClosed() {
return getConnectionState() == cs_APP_CLOSED;
}
@@ -1567,6 +1569,7 @@
* rather than leaving it for finalization, so that your remote
* peer does not experience a protocol error.
*/
+ @Override
public void close() throws IOException {
if ((debug != null) && Debug.isOn("ssl")) {
System.out.println(Thread.currentThread().getName() +
@@ -2155,6 +2158,7 @@
* Data read from this stream was always integrity protected in
* transit, and will usually have been confidentiality protected.
*/
+ @Override
synchronized public InputStream getInputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
@@ -2176,6 +2180,7 @@
* Data written on this stream is always integrity protected, and
* will usually be confidentiality protected.
*/
+ @Override
synchronized public OutputStream getOutputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
@@ -2197,6 +2202,7 @@
* be long lived, and frequently correspond to an entire login session
* for some user.
*/
+ @Override
public SSLSession getSession() {
/*
* Force a synchronous handshake, if appropriate.
@@ -2235,6 +2241,7 @@
* whether we enable session creations. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
@@ -2247,6 +2254,7 @@
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
+ @Override
synchronized public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
@@ -2260,6 +2268,7 @@
* whether client authentication is needed. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
@@ -2271,6 +2280,7 @@
}
}
+ @Override
synchronized public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
@@ -2283,6 +2293,7 @@
* whether client authentication is requested. Otherwise,
* we will need to wait for the next handshake.
*/
+ @Override
synchronized public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
@@ -2294,6 +2305,7 @@
}
}
+ @Override
synchronized public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
@@ -2304,6 +2316,7 @@
* client or server mode. Must be called before any SSL
* traffic has started.
*/
+ @Override
@SuppressWarnings("fallthrough")
synchronized public void setUseClientMode(boolean flag) {
switch (connectionState) {
@@ -2359,6 +2372,7 @@
}
}
+ @Override
synchronized public boolean getUseClientMode() {
return !roleIsServer;
}
@@ -2374,6 +2388,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
@@ -2387,6 +2402,7 @@
*
* @param suites Names of all the cipher suites to enable.
*/
+ @Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
if ((handshaker != null) && !handshaker.activated()) {
@@ -2404,6 +2420,7 @@
*
* @return an array of cipher suite names
*/
+ @Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
@@ -2414,6 +2431,7 @@
* A subset of the supported protocols may be enabled for this connection
* @return an array of protocol names.
*/
+ @Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
@@ -2427,6 +2445,7 @@
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
+ @Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
if ((handshaker != null) && !handshaker.activated()) {
@@ -2434,6 +2453,7 @@
}
}
+ @Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
@@ -2442,6 +2462,7 @@
* Assigns the socket timeout.
* @see java.net.Socket#setSoTimeout
*/
+ @Override
public void setSoTimeout(int timeout) throws SocketException {
if ((debug != null) && Debug.isOn("ssl")) {
System.out.println(Thread.currentThread().getName() +
@@ -2455,6 +2476,7 @@
* Registers an event listener to receive notifications that an
* SSL handshake has completed on this connection.
*/
+ @Override
public synchronized void addHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (listener == null) {
@@ -2471,6 +2493,7 @@
/**
* Removes a previously registered handshake completion listener.
*/
+ @Override
public synchronized void removeHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (handshakeListeners == null) {
@@ -2487,6 +2510,7 @@
/**
* Returns the SSLParameters in effect for this SSLSocket.
*/
+ @Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
@@ -2502,6 +2526,7 @@
/**
* Applies SSLParameters to this socket.
*/
+ @Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
@@ -2550,6 +2575,7 @@
event = e;
}
+ @Override
public void run() {
// Don't need to synchronize, as it only runs in one thread.
for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
@@ -2558,6 +2584,7 @@
final HandshakeCompletedListener l = entry.getKey();
AccessControlContext acc = entry.getValue();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
public Void run() {
l.handshakeCompleted(event);
return null;
@@ -2570,6 +2597,7 @@
/**
* Returns a printable representation of this end of the connection.
*/
+ @Override
public String toString() {
StringBuffer retval = new StringBuffer(80);
--- a/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java Mon Dec 10 20:58:36 2012 -0800
@@ -43,7 +43,6 @@
import sun.security.ssl.HandshakeMessage.*;
import sun.security.ssl.CipherSuite.*;
import sun.security.ssl.SignatureAndHashAlgorithm.*;
-import static sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
@@ -144,6 +143,7 @@
* It updates the state machine as each message is processed, and writes
* responses as needed using the connection in the constructor.
*/
+ @Override
void processMessage(byte type, int message_len)
throws IOException {
//
@@ -526,6 +526,7 @@
try {
subject = AccessController.doPrivileged(
new PrivilegedExceptionAction<Subject>() {
+ @Override
public Subject run() throws Exception {
return
Krb5Helper.getServerSubject(getAccSE());
@@ -669,9 +670,6 @@
}
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- if (resumingSession) {
- handshakeHash.setCertificateVerifyAlg(null);
- }
handshakeHash.setFinishedAlg(cipherSuite.prfAlg.getPRFHashAlg());
}
@@ -881,7 +879,6 @@
throw new SSLHandshakeException(
"No supported signature algorithm");
}
- handshakeHash.restrictCertificateVerifyAlgs(localHashAlgs);
}
caCerts = sslContext.getX509TrustManager().getAcceptedIssuers();
@@ -892,10 +889,6 @@
m4.print(System.out);
}
m4.write(output);
- } else {
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- handshakeHash.setCertificateVerifyAlg(null);
- }
}
/*
@@ -1329,6 +1322,7 @@
kerberosKeys = AccessController.doPrivileged(
// Eliminate dependency on KerberosKey
new PrivilegedExceptionAction<SecretKey[]>() {
+ @Override
public SecretKey[] run() throws Exception {
// get kerberos key for the default principal
return Krb5Helper.getServerKeys(acc);
@@ -1454,8 +1448,6 @@
throw new SSLHandshakeException(
"No supported hash algorithm");
}
-
- handshakeHash.setCertificateVerifyAlg(hashAlg);
}
try {
@@ -1600,6 +1592,7 @@
/*
* Returns a HelloRequest message to kickstart renegotiations
*/
+ @Override
HandshakeMessage getKickstartMessage() {
return new HelloRequest();
}
@@ -1608,6 +1601,7 @@
/*
* Fault detected during handshake.
*/
+ @Override
void handshakeAlert(byte description) throws SSLProtocolException {
String message = Alerts.alertDescription(description);
@@ -1668,11 +1662,6 @@
* not *REQUIRED*, this is an acceptable condition.)
*/
if (doClientAuth == SSLEngineImpl.clauth_requested) {
- // Smart (aka stupid) to forecast that no CertificateVerify
- // message will be received.
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- handshakeHash.setCertificateVerifyAlg(null);
- }
return;
} else {
fatalSE(Alerts.alert_bad_certificate,
--- a/jdk/src/share/classes/sun/security/ssl/ServerNameExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/ServerNameExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -243,10 +243,12 @@
return false;
}
+ @Override
int length() {
return listLength == 0 ? 4 : 6 + listLength;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
if (listLength == 0) {
@@ -262,6 +264,7 @@
}
}
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
for (SNIServerName sniName : sniMap.values()) {
--- a/jdk/src/share/classes/sun/security/ssl/SessionId.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SessionId.java Mon Dec 10 20:58:36 2012 -0800
@@ -68,6 +68,7 @@
}
/** Returns the ID as a string */
+ @Override
public String toString ()
{
int len = sessionId.length;
@@ -85,6 +86,7 @@
/** Returns a value which is the same for session IDs which are equal */
+ @Override
public int hashCode ()
{
int retval = 0;
@@ -95,6 +97,7 @@
}
/** Returns true if the parameter is the same session ID */
+ @Override
public boolean equals (Object obj)
{
if (!(obj instanceof SessionId))
--- a/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java Mon Dec 10 20:58:36 2012 -0800
@@ -77,9 +77,6 @@
// the hash algorithm
private HashAlgorithm hash;
- // the signature algorithm
- private SignatureAlgorithm signature;
-
// id in 16 bit MSB format, i.e. 0x0603 for SHA512withECDSA
private int id;
@@ -96,7 +93,6 @@
private SignatureAndHashAlgorithm(HashAlgorithm hash,
SignatureAlgorithm signature, String algorithm, int priority) {
this.hash = hash;
- this.signature = signature;
this.algorithm = algorithm;
this.id = ((hash.value & 0xFF) << 8) | (signature.value & 0xFF);
this.priority = priority;
@@ -105,11 +101,10 @@
// constructor for unsupported algorithm
private SignatureAndHashAlgorithm(String algorithm, int id, int sequence) {
this.hash = HashAlgorithm.valueOf((id >> 8) & 0xFF);
- this.signature = SignatureAlgorithm.valueOf(id & 0xFF);
this.algorithm = algorithm;
this.id = id;
- // add one more to the sequece number, in case that the number is zero
+ // add one more to the sequence number, in case that the number is zero
this.priority = SUPPORTED_ALG_PRIORITY_MAX_NUM + sequence + 1;
}
--- a/jdk/src/share/classes/sun/security/ssl/SunJSSE.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SunJSSE.java Mon Dec 10 20:58:36 2012 -0800
@@ -148,6 +148,7 @@
private void registerAlgorithms(final boolean isfips) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
public Object run() {
doRegister(isfips);
return null;
--- a/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -166,6 +166,7 @@
* @return the certificate chain (ordered with the user's certificate first
* and the root certificate authority last)
*/
+ @Override
public X509Certificate[] getCertificateChain(String alias) {
if (alias == null) {
return null;
@@ -181,6 +182,7 @@
/*
* Returns the key associated with the given alias
*/
+ @Override
public PrivateKey getPrivateKey(String alias) {
if (alias == null) {
return null;
@@ -198,6 +200,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
/*
@@ -228,6 +231,7 @@
*
* @since 1.5
*/
+ @Override
public String chooseEngineClientAlias(String[] keyType,
Principal[] issuers, SSLEngine engine) {
/*
@@ -242,6 +246,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String chooseServerAlias(String keyType,
Principal[] issuers, Socket socket) {
/*
@@ -283,6 +288,7 @@
*
* @since 1.5
*/
+ @Override
public String chooseEngineServerAlias(String keyType,
Principal[] issuers, SSLEngine engine) {
/*
@@ -297,6 +303,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers);
}
@@ -306,6 +313,7 @@
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
+ @Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers);
}
--- a/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -94,10 +94,12 @@
return curveIds;
}
+ @Override
int length() {
return 6 + (curveIds.length << 1);
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
int k = curveIds.length << 1;
@@ -108,6 +110,7 @@
}
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Extension " + type + ", curve names: {");
--- a/jdk/src/share/classes/sun/security/ssl/SupportedEllipticPointFormatsExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/SupportedEllipticPointFormatsExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -67,10 +67,12 @@
}
}
+ @Override
int length() {
return 5 + formats.length;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putInt16(formats.length + 1);
@@ -91,6 +93,7 @@
}
}
+ @Override
public String toString() {
List<String> list = new ArrayList<String>();
for (byte format : formats) {
--- a/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,11 +27,9 @@
import java.util.*;
import java.io.*;
-import java.math.*;
import java.security.*;
import java.security.cert.*;
import javax.net.ssl.*;
-import java.security.spec.AlgorithmParameterSpec;
import sun.security.validator.Validator;
@@ -45,6 +43,7 @@
// empty
}
+ @Override
protected void engineInit(KeyStore ks) throws KeyStoreException {
if (ks == null) {
try {
@@ -85,6 +84,7 @@
abstract X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException;
+ @Override
protected void engineInit(ManagerFactoryParameters spec) throws
InvalidAlgorithmParameterException {
trustManager = getInstance(spec);
@@ -94,6 +94,7 @@
/**
* Returns one trust manager for each type of trust material.
*/
+ @Override
protected TrustManager[] engineGetTrustManagers() {
if (!isInitialized) {
throw new IllegalStateException(
@@ -109,6 +110,7 @@
throws Exception {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<FileInputStream>() {
+ @Override
public FileInputStream run() throws Exception {
try {
if (file.exists()) {
@@ -139,6 +141,7 @@
KeyStore ks = null;
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+ @Override
public Void run() throws Exception {
props.put("trustStore", System.getProperty(
"javax.net.ssl.trustStore"));
@@ -239,9 +242,11 @@
}
public static final class SimpleFactory extends TrustManagerFactoryImpl {
+ @Override
X509TrustManager getInstance(KeyStore ks) throws KeyStoreException {
return new X509TrustManagerImpl(Validator.TYPE_SIMPLE, ks);
}
+ @Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException
@@ -251,9 +256,11 @@
}
public static final class PKIXFactory extends TrustManagerFactoryImpl {
+ @Override
X509TrustManager getInstance(KeyStore ks) throws KeyStoreException {
return new X509TrustManagerImpl(Validator.TYPE_PKIX, ks);
}
+ @Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException {
if (spec instanceof CertPathTrustManagerParameters == false) {
--- a/jdk/src/share/classes/sun/security/ssl/UnknownExtension.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/UnknownExtension.java Mon Dec 10 20:58:36 2012 -0800
@@ -41,15 +41,18 @@
}
}
+ @Override
int length() {
return 4 + data.length;
}
+ @Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putBytes16(data);
}
+ @Override
public String toString() {
return "Unsupported extension " + type + ", data: " +
Debug.toString(data);
--- a/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -102,29 +102,34 @@
// public methods
//
+ @Override
public X509Certificate[] getCertificateChain(String alias) {
PrivateKeyEntry entry = getEntry(alias);
return entry == null ? null :
(X509Certificate[])entry.getCertificateChain();
}
+ @Override
public PrivateKey getPrivateKey(String alias) {
PrivateKeyEntry entry = getEntry(alias);
return entry == null ? null : entry.getPrivateKey();
}
+ @Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
return chooseAlias(getKeyTypes(keyTypes), issuers, CheckType.CLIENT,
getAlgorithmConstraints(socket));
}
+ @Override
public String chooseEngineClientAlias(String[] keyTypes,
Principal[] issuers, SSLEngine engine) {
return chooseAlias(getKeyTypes(keyTypes), issuers, CheckType.CLIENT,
getAlgorithmConstraints(engine));
}
+ @Override
public String chooseServerAlias(String keyType,
Principal[] issuers, Socket socket) {
return chooseAlias(getKeyTypes(keyType), issuers, CheckType.SERVER,
@@ -142,6 +147,7 @@
// It is not a really HTTPS endpoint identification.
}
+ @Override
public String chooseEngineServerAlias(String keyType,
Principal[] issuers, SSLEngine engine) {
return chooseAlias(getKeyTypes(keyType), issuers, CheckType.SERVER,
@@ -159,10 +165,12 @@
// It is not a really HTTPS endpoint identification.
}
+ @Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers, CheckType.CLIENT, null);
}
+ @Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers, CheckType.SERVER, null);
}
@@ -488,11 +496,13 @@
this.checkResult = checkResult;
}
+ @Override
public int compareTo(EntryStatus other) {
int result = this.checkResult.compareTo(other.checkResult);
return (result == 0) ? (this.keyIndex - other.keyIndex) : result;
}
+ @Override
public String toString() {
String s = alias + " (verified: " + checkResult + ")";
if (builderIndex == 0) {
--- a/jdk/src/share/classes/sun/security/ssl/X509TrustManagerImpl.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/X509TrustManagerImpl.java Mon Dec 10 20:58:36 2012 -0800
@@ -28,7 +28,6 @@
import java.net.Socket;
import javax.net.ssl.SSLSession;
-import java.nio.charset.StandardCharsets;
import java.util.*;
import java.security.*;
@@ -347,7 +346,6 @@
} catch (IllegalArgumentException iae) {
// unlikely to happen, just in case ...
if ((debug != null) && Debug.isOn("trustmanager")) {
- byte[] encoded = hostname.getEncoded();
System.out.println("Illegal server name: " + sniName);
}
}
--- a/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java Mon Dec 10 20:58:36 2012 -0800
@@ -256,6 +256,7 @@
if (getFileChooser().getControlButtonsAreShown()) {
approveButton.setText(getApproveButtonText(getFileChooser()));
approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
+ approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
}
}
--- a/jdk/src/share/demo/jvmti/hprof/hprof.h Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/demo/jvmti/hprof/hprof.h Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -65,6 +65,7 @@
#include "jni.h"
#include "jvmti.h"
#include "classfile_constants.h"
+#include "jvm_md.h"
#ifndef SKIP_NPT
#include "npt.h" /* To get NptEnv for doing character conversions */
--- a/jdk/src/share/demo/jvmti/hprof/hprof_init.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_init.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -1899,6 +1899,7 @@
*/
getSystemProperty("sun.boot.library.path", &boot_path);
md_build_library_name(lname, FILENAME_MAX, boot_path, name);
+ jvmtiDeallocate(boot_path);
handle = md_load_library(lname, err_buf, (int)sizeof(err_buf));
if ( handle == NULL ) {
/* This may be necessary on Windows. */
@@ -1941,6 +1942,9 @@
JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
{
+ char *boot_path = NULL;
+ char npt_lib[JVM_MAXPATHLEN];
+
/* See if it's already loaded */
if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) {
HPROF_ERROR(JNI_TRUE, "Cannot load this JVM TI agent twice, check your java command line for duplicate hprof options.");
@@ -1957,9 +1961,15 @@
gdata->jvm = vm;
+ /* Get the JVMTI environment */
+ getJvmti();
+
#ifndef SKIP_NPT
+ getSystemProperty("sun.boot.library.path", &boot_path);
/* Load in NPT library for character conversions */
- NPT_INITIALIZE(&(gdata->npt), NPT_VERSION, NULL);
+ md_build_library_name(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME);
+ jvmtiDeallocate(boot_path);
+ NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL);
if ( gdata->npt == NULL ) {
HPROF_ERROR(JNI_TRUE, "Cannot load npt library");
}
@@ -1969,9 +1979,6 @@
}
#endif
- /* Get the JVMTI environment */
- getJvmti();
-
/* Lock needed to protect debug_malloc() code, which is not MT safe */
#ifdef DEBUG
gdata->debug_malloc_lock = createRawMonitor("HPROF debug_malloc lock");
--- a/jdk/src/solaris/back/linker_md.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/back/linker_md.c Mon Dec 10 20:58:36 2012 -0800
@@ -54,6 +54,32 @@
#define LIB_SUFFIX "so"
#endif
+static void dll_build_name(char* buffer, size_t buflen,
+ const char* pname, const char* fname) {
+ // Based on os_solaris.cpp
+
+ char *path_sep = PATH_SEPARATOR;
+ char *pathname = (char *)pname;
+ while (strlen(pathname) > 0) {
+ char *p = strchr(pathname, *path_sep);
+ if (p == NULL) {
+ p = pathname + strlen(pathname);
+ }
+ /* check for NULL path */
+ if (p == pathname) {
+ continue;
+ }
+ (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (p - pathname),
+ pathname, fname);
+
+ if (access(buffer, F_OK) == 0) {
+ break;
+ }
+ pathname = p + 1;
+ *buffer = '\0';
+ }
+}
+
/*
* create a string for the JNI native function name by adding the
* appropriate decorations.
@@ -76,16 +102,16 @@
{
const int pnamelen = pname ? strlen(pname) : 0;
+ *holder = '\0';
/* Quietly truncate on buffer overflow. Should be an error. */
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
- *holder = '\0';
return;
}
if (pnamelen == 0) {
(void)snprintf(holder, holderlen, "lib%s." LIB_SUFFIX, fname);
} else {
- (void)snprintf(holder, holderlen, "%s/lib%s." LIB_SUFFIX, pname, fname);
+ dll_build_name(holder, holderlen, pname, fname);
}
}
--- a/jdk/src/solaris/bin/java_md_solinux.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/bin/java_md_solinux.c Mon Dec 10 20:58:36 2012 -0800
@@ -811,7 +811,6 @@
jboolean
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
{
- Dl_info dlinfo;
void *libjvm;
JLI_TraceLauncher("JVM path is %s\n", jvmpath);
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Mon Dec 10 20:58:36 2012 -0800
@@ -1332,6 +1332,15 @@
return new XInputMethodDescriptor();
}
+ /**
+ * Returns whether enableInputMethods should be set to true for peered
+ * TextComponent instances on this platform. True by default.
+ */
+ @Override
+ public boolean enableInputMethodsForTextComponent() {
+ return true;
+ }
+
static int getMultiClickTime() {
if (awt_multiclick_time == 0) {
initializeMultiClickTime();
--- a/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,8 +25,6 @@
package sun.nio.fs;
-import java.nio.file.*;
-import java.nio.file.attribute.*;
import java.io.IOException;
/**
--- a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,6 +29,8 @@
import java.nio.file.attribute.*;
import java.nio.file.spi.FileTypeDetector;
import java.io.IOException;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
/**
* Linux implementation of FileSystemProvider
@@ -100,6 +102,13 @@
@Override
FileTypeDetector getFileTypeDetector() {
- return new GnomeFileTypeDetector();
+ Path userMimeTypes = Paths.get(AccessController.doPrivileged(
+ new GetPropertyAction("user.home")), ".mime.types");
+ Path etcMimeTypes = Paths.get("/etc/mime.types");
+
+ return chain(new GnomeFileTypeDetector(),
+ new MimeTypesFileTypeDetector(userMimeTypes),
+ new MimeTypesFileTypeDetector(etcMimeTypes),
+ new MagicFileTypeDetector());
}
}
--- a/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/MacOSXFileSystemProvider.java Mon Dec 10 20:58:36 2012 -0800
@@ -25,9 +25,11 @@
package sun.nio.fs;
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.spi.FileTypeDetector;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
/**
* MacOSX implementation of FileSystemProvider
@@ -42,4 +44,11 @@
MacOSXFileSystem newFileSystem(String dir) {
return new MacOSXFileSystem(this, dir);
}
+
+ @Override
+ FileTypeDetector getFileTypeDetector() {
+ Path userMimeTypes = Paths.get(AccessController.doPrivileged(
+ new GetPropertyAction("user.home")), ".mime.types");
+ return new MimeTypesFileTypeDetector(userMimeTypes);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/fs/MagicFileTypeDetector.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.fs;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * File type detector that uses the libmagic to guess the MIME type of a file.
+ */
+
+class MagicFileTypeDetector extends AbstractFileTypeDetector {
+
+ private static final String UNKNOW_MIME_TYPE = "application/octet-stream";
+
+ // true if libmagic is available and successfully loaded
+ private final boolean libmagicAvailable;
+
+ public MagicFileTypeDetector() {
+ libmagicAvailable = initialize0();
+ }
+
+ @Override
+ protected String implProbeContentType(Path obj) throws IOException {
+ if (!libmagicAvailable || !(obj instanceof UnixPath))
+ return null;
+
+ UnixPath path = (UnixPath) obj;
+ path.checkRead();
+
+ NativeBuffer buffer = NativeBuffers.asNativeBuffer(path.getByteArrayForSysCalls());
+ try {
+ byte[] type = probe0(buffer.address());
+ String mimeType = (type == null) ? null : new String(type);
+ return UNKNOW_MIME_TYPE.equals(mimeType) ? null : mimeType;
+ } finally {
+ buffer.release();
+ }
+ }
+
+ private static native boolean initialize0();
+
+ private static native byte[] probe0(long pathAddress);
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ System.loadLibrary("nio");
+ return null;
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/fs/MimeTypesFileTypeDetector.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.fs;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * File type detector that uses a file extension to look up its MIME type
+ * based on a mime.types file.
+ */
+
+class MimeTypesFileTypeDetector extends AbstractFileTypeDetector {
+
+ // path to mime.types file
+ private final Path mimeTypesFile;
+
+ // map of extension to MIME type
+ private Map<String,String> mimeTypeMap;
+
+ // set to true when file loaded
+ private volatile boolean loaded = false;
+
+ public MimeTypesFileTypeDetector(Path filePath) {
+ mimeTypesFile = filePath;
+ }
+
+ @Override
+ protected String implProbeContentType(Path path) {
+ Path fn = path.getFileName();
+ if (fn == null)
+ return null; // no file name
+
+ String ext = getExtension(fn.toString());
+ if (ext.isEmpty())
+ return null; // no extension
+
+ loadMimeTypes();
+ if (mimeTypeMap == null || mimeTypeMap.isEmpty())
+ return null;
+
+ // Case-sensitive search
+ String mimeType;
+ do {
+ mimeType = mimeTypeMap.get(ext);
+ if (mimeType == null)
+ ext = getExtension(ext);
+ } while (mimeType == null && !ext.isEmpty());
+
+ return mimeType;
+ }
+
+ // Get the extension of a file name.
+ private static String getExtension(String name) {
+ String ext = "";
+ if (name != null && !name.isEmpty()) {
+ int dot = name.indexOf('.');
+ if ((dot >= 0) && (dot < name.length() - 1)) {
+ ext = name.substring(dot + 1);
+ }
+ }
+ return ext;
+ }
+
+ /**
+ * Parse the mime types file, and store the type-extension mappings into
+ * mimeTypeMap. The mime types file is not loaded until the first probe
+ * to achieve the lazy initialization. It adopts double-checked locking
+ * optimization to reduce the locking overhead.
+ */
+ private void loadMimeTypes() {
+ if (!loaded) {
+ synchronized (this) {
+ if (!loaded) {
+ List<String> lines = AccessController.doPrivileged(
+ new PrivilegedAction<List<String>>() {
+ @Override
+ public List<String> run() {
+ try {
+ return Files.readAllLines(mimeTypesFile,
+ Charset.defaultCharset());
+ } catch (IOException ignore) {
+ return Collections.emptyList();
+ }
+ }
+ });
+
+ mimeTypeMap = new HashMap<>(lines.size());
+ String entry = "";
+ for (String line : lines) {
+ entry += line;
+ if (entry.endsWith("\\")) {
+ entry = entry.substring(0, entry.length() - 1);
+ continue;
+ }
+ parseMimeEntry(entry);
+ entry = "";
+ }
+ if (!entry.isEmpty()) {
+ parseMimeEntry(entry);
+ }
+ loaded = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Parse a mime-types entry, which can have the following formats.
+ * 1) Simple space-delimited format
+ * image/jpeg jpeg jpg jpe JPG
+ *
+ * 2) Netscape key-value pair format
+ * type=application/x-java-jnlp-file desc="Java Web Start" exts="jnlp"
+ * or
+ * type=text/html exts=htm,html
+ */
+ private void parseMimeEntry(String entry) {
+ entry = entry.trim();
+ if (entry.isEmpty() || entry.charAt(0) == '#')
+ return;
+
+ entry = entry.replaceAll("\\s*#.*", "");
+ int equalIdx = entry.indexOf('=');
+ if (equalIdx > 0) {
+ // Parse a mime-types command having the key-value pair format
+ final String TYPEEQUAL = "type=";
+ String typeRegex = "\\b" + TYPEEQUAL +
+ "(\"\\p{Graph}+?/\\p{Graph}+?\"|\\p{Graph}+/\\p{Graph}+\\b)";
+ Pattern typePattern = Pattern.compile(typeRegex);
+ Matcher typeMatcher = typePattern.matcher(entry);
+
+ if (typeMatcher.find()) {
+ String type = typeMatcher.group().substring(TYPEEQUAL.length());
+ if (type.charAt(0) == '"') {
+ type = type.substring(1, type.length() - 1);
+ }
+
+ final String EXTEQUAL = "exts=";
+ String extRegex = "\\b" + EXTEQUAL +
+ "(\"[\\p{Graph}|\\p{Blank}]+?\"|\\p{Graph}+\\b)";
+ Pattern extPattern = Pattern.compile(extRegex);
+ Matcher extMatcher = extPattern.matcher(entry);
+
+ if (extMatcher.find()) {
+ String exts =
+ extMatcher.group().substring(EXTEQUAL.length());
+ if (exts.charAt(0) == '"') {
+ exts = exts.substring(1, exts.length() - 1);
+ }
+ String[] extList = exts.split("[\\p{Blank}|\\p{Punct}]+");
+ for (String ext : extList) {
+ putIfAbsent(ext, type);
+ }
+ }
+ }
+ } else {
+ // Parse a mime-types command having the space-delimited format
+ String[] elements = entry.split("\\s+");
+ int i = 1;
+ while (i < elements.length) {
+ putIfAbsent(elements[i++], elements[0]);
+ }
+ }
+ }
+
+ private void putIfAbsent(String key, String value) {
+ if (key != null && !key.isEmpty() &&
+ value != null && !value.isEmpty() &&
+ !mimeTypeMap.containsKey(key))
+ {
+ mimeTypeMap.put(key, value);
+ }
+ }
+}
--- a/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java Mon Dec 10 20:58:36 2012 -0800
@@ -29,6 +29,8 @@
import java.nio.file.attribute.*;
import java.nio.file.spi.FileTypeDetector;
import java.io.IOException;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
/**
* Solaris implementation of FileSystemProvider
@@ -83,6 +85,12 @@
@Override
FileTypeDetector getFileTypeDetector() {
- return new GnomeFileTypeDetector();
+ Path userMimeTypes = Paths.get(AccessController.doPrivileged(
+ new GetPropertyAction("user.home")), ".mime.types");
+ Path etcMimeTypes = Paths.get("/etc/mime.types");
+
+ return chain(new GnomeFileTypeDetector(),
+ new MimeTypesFileTypeDetector(userMimeTypes),
+ new MimeTypesFileTypeDetector(etcMimeTypes));
}
}
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java Mon Dec 10 20:58:36 2012 -0800
@@ -509,4 +509,24 @@
};
}
+ /**
+ * Returns a {@code FileTypeDetector} that chains the given array of file
+ * type detectors. When the {@code implProbeContentType} method is invoked
+ * then each of the detectors is invoked in turn, the result from the
+ * first to detect the file type is returned.
+ */
+ final FileTypeDetector chain(final AbstractFileTypeDetector... detectors) {
+ return new AbstractFileTypeDetector() {
+ @Override
+ protected String implProbeContentType(Path file) throws IOException {
+ for (AbstractFileTypeDetector detector : detectors) {
+ String result = detector.implProbeContentType(file);
+ if (result != null && !result.isEmpty()) {
+ return result;
+ }
+ }
+ return null;
+ }
+ };
+ }
}
--- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c Mon Dec 10 20:58:36 2012 -0800
@@ -380,6 +380,31 @@
return ntohl(l);
}
+static void dll_build_name(char* buffer, size_t buflen,
+ const char* pname, const char* fname) {
+ // Loosely based on os_solaris.cpp
+
+ char *pathname = (char *)pname;
+ while (strlen(pathname) > 0) {
+ char *p = strchr(pathname, ':');
+ if (p == NULL) {
+ p = pathname + strlen(pathname);
+ }
+ /* check for NULL path */
+ if (p == pathname) {
+ continue;
+ }
+ (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
+ (p - pathname), pathname, fname);
+
+ if (access(buffer, F_OK) == 0) {
+ break;
+ }
+ pathname = p + 1;
+ *buffer = '\0';
+ }
+}
+
/* Create the actual fill filename for a dynamic library. */
void
md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
@@ -389,9 +414,9 @@
/* Length of options directory location. */
pnamelen = pname ? strlen(pname) : 0;
+ *holder = '\0';
/* Quietly truncate on buffer overflow. Should be an error. */
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
- *holder = '\0';
return;
}
@@ -399,7 +424,7 @@
if (pnamelen == 0) {
(void)snprintf(holder, holderlen, "lib%s" JNI_LIB_SUFFIX, fname);
} else {
- (void)snprintf(holder, holderlen, "%s/lib%s" JNI_LIB_SUFFIX, pname, fname);
+ dll_build_name(holder, holderlen, pname, fname);
}
}
--- a/jdk/src/solaris/native/java/lang/java_props_macosx.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/native/java/lang/java_props_macosx.c Mon Dec 10 20:58:36 2012 -0800
@@ -129,10 +129,6 @@
return true;
}
-static bool isXDisplayDefined() {
- return getenv("DISPLAY") != NULL;
-}
-
PreferredToolkit getPreferredToolkit() {
static PreferredToolkit pref = unset;
if (pref != unset) return pref;
@@ -141,7 +137,6 @@
if (prefFromEnv != unset) return pref = prefFromEnv;
if (isInAquaSession()) return pref = CToolkit;
- if (isXDisplayDefined()) return pref = XToolkit;
return pref = HToolkit;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/fs/MagicFileTypeDetector.c Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "jni.h"
+#include "jni_util.h"
+#include "jvm.h"
+#include "jlong.h"
+
+#include <dlfcn.h>
+#include <string.h>
+
+#define MAGIC_MIME_TYPE 0x000010 /* Return the MIME type */
+
+typedef struct magic_set magic_t;
+
+typedef magic_t* (*magic_open_func)(int flags);
+typedef int (*magic_load_func)(magic_t* cookie, const char* filename);
+typedef const char* (*magic_file_func)(magic_t* cookie, const char* filename);
+typedef void (*magic_close_func)(magic_t* cookie);
+
+static void* magic_handle;
+static magic_open_func magic_open;
+static magic_load_func magic_load;
+static magic_file_func magic_file;
+static magic_close_func magic_close;
+
+#include "sun_nio_fs_MagicFileTypeDetector.h"
+
+JNIEXPORT jboolean JNICALL
+Java_sun_nio_fs_MagicFileTypeDetector_initialize0
+ (JNIEnv* env, jclass this)
+{
+ magic_handle = dlopen("libmagic.so", RTLD_LAZY);
+ if (magic_handle == NULL) {
+ magic_handle = dlopen("libmagic.so.1", RTLD_LAZY);
+ if (magic_handle == NULL) {
+ return JNI_FALSE;
+ }
+ }
+
+ magic_open = (magic_open_func)dlsym(magic_handle, "magic_open");
+
+ magic_load = (magic_load_func)dlsym(magic_handle, "magic_load");
+
+ magic_file = (magic_file_func)dlsym(magic_handle, "magic_file");
+
+ magic_close = (magic_close_func)dlsym(magic_handle, "magic_close");
+
+ if (magic_open == NULL ||
+ magic_load == NULL ||
+ magic_file == NULL ||
+ magic_close == NULL)
+ {
+ dlclose(magic_handle);
+ return JNI_FALSE;
+ }
+
+ return JNI_TRUE;
+}
+
+JNIEXPORT jbyteArray JNICALL
+Java_sun_nio_fs_MagicFileTypeDetector_probe0
+ (JNIEnv* env, jclass this, jlong pathAddress)
+{
+ char* path = (char*)jlong_to_ptr(pathAddress);
+ magic_t* cookie;
+ jbyteArray result = NULL;
+
+ cookie = (*magic_open)(MAGIC_MIME_TYPE);
+
+ if (cookie != NULL) {
+ if ((*magic_load)(cookie, NULL) != -1) {
+ const char* type = (*magic_file)(cookie, path);
+ if (type != NULL) {
+ jsize len = strlen(type);
+ result = (*env)->NewByteArray(env, len);
+ if (result != NULL) {
+ (*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)type);
+ }
+ }
+ }
+ (*magic_close)(cookie);
+ }
+
+ return result;
+}
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Mon Dec 10 20:58:36 2012 -0800
@@ -1260,13 +1260,15 @@
JavaVM* jvm = NULL;
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
+ JNIEnv * env;
if (jvm != NULL) {
- JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
- ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
- } else {
- return 0;
+ env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ if (env) {
+ return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
+ ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
+ }
}
+ return 0;
}
/*
--- a/jdk/src/solaris/npt/npt_md.h Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/solaris/npt/npt_md.h Mon Dec 10 20:58:36 2012 -0800
@@ -36,14 +36,14 @@
#define NPT_LIBNAME "npt"
-#define NPT_INITIALIZE(pnpt,version,options) \
+#define NPT_INITIALIZE(path,pnpt,version,options) \
{ \
void *_handle; \
void *_sym; \
\
if ( (pnpt) == NULL ) NPT_ERROR("NptEnv* is NULL"); \
*(pnpt) = NULL; \
- _handle = dlopen(JNI_LIB_NAME(NPT_LIBNAME), RTLD_LAZY); \
+ _handle = dlopen(path, RTLD_LAZY); \
if ( _handle == NULL ) NPT_ERROR("Cannot open library"); \
_sym = dlsym(_handle, "nptInitialize"); \
if ( _sym == NULL ) NPT_ERROR("Cannot find nptInitialize"); \
--- a/jdk/src/windows/back/linker_md.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/back/linker_md.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,11 +32,42 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <io.h>
#include "sys.h"
#include "path_md.h"
+static void dll_build_name(char* buffer, size_t buflen,
+ const char* pname, const char* fname) {
+ // Based on os_windows.cpp
+
+ char *path_sep = PATH_SEPARATOR;
+ char *pathname = (char *)pname;
+ while (strlen(pathname) > 0) {
+ char *p = strchr(pathname, *path_sep);
+ if (p == NULL) {
+ p = pathname + strlen(pathname);
+ }
+ /* check for NULL path */
+ if (p == pathname) {
+ continue;
+ }
+ if (*(p-1) == ':' || *(p-1) == '\\') {
+ (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
+ pathname, fname);
+ } else {
+ (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
+ pathname, fname);
+ }
+ if (_access(buffer, 0) == 0) {
+ break;
+ }
+ pathname = p + 1;
+ *buffer = '\0';
+ }
+}
+
/*
* From system_md.c v1.54
*/
@@ -80,20 +111,17 @@
dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname)
{
const int pnamelen = pname ? (int)strlen(pname) : 0;
- const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0;
+ *holder = '\0';
/* Quietly truncates on buffer overflow. Should be an error. */
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
- *holder = '\0';
return;
}
if (pnamelen == 0) {
sprintf(holder, "%s.dll", fname);
- } else if (c == ':' || c == '\\') {
- sprintf(holder, "%s%s.dll", pname, fname);
} else {
- sprintf(holder, "%s\\%s.dll", pname, fname);
+ dll_build_name(holder, holderlen, pname, fname);
}
}
--- a/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java Mon Dec 10 20:58:36 2012 -0800
@@ -45,15 +45,25 @@
private long ctxHandle;
static {
- initFirst();
+ initFirst(Status.class);
}
+ // Used by native code to indicate when a particular protocol sequence is completed
+ // and must not be re-used.
+
+ class Status {
+ boolean sequenceComplete;
+ }
+
+ Status status;
+
NTLMAuthSequence (String username, String password, String ntdomain)
throws IOException
{
this.username = username;
this.password = password;
this.ntdomain = ntdomain;
+ this.status = new Status();
state = 0;
crdHandle = getCredentialsHandle (username, ntdomain, password);
if (crdHandle == 0) {
@@ -63,19 +73,26 @@
public String getAuthHeader (String token) throws IOException {
byte[] input = null;
+
+ assert !status.sequenceComplete;
+
if (token != null)
input = (new BASE64Decoder()).decodeBuffer(token);
- byte[] b = getNextToken (crdHandle, input);
+ byte[] b = getNextToken (crdHandle, input, status);
if (b == null)
throw new IOException ("Internal authentication error");
return (new B64Encoder()).encode (b);
}
- private native static void initFirst ();
+ public boolean isComplete() {
+ return status.sequenceComplete;
+ }
+
+ private native static void initFirst (Class<NTLMAuthSequence.Status> clazz);
private native long getCredentialsHandle (String user, String domain, String password);
- private native byte[] getNextToken (long crdHandle, byte[] lastToken);
+ private native byte[] getNextToken (long crdHandle, byte[] lastToken, Status returned);
}
class B64Encoder extends BASE64Encoder {
--- a/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java Mon Dec 10 20:58:36 2012 -0800
@@ -193,8 +193,12 @@
}
String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null);
conn.setAuthenticationProperty(getHeaderName(), response);
+ if (seq.isComplete()) {
+ conn.authObj(null);
+ }
return true;
} catch (IOException e) {
+ conn.authObj(null);
return false;
}
}
--- a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -367,28 +367,53 @@
return 0;
}
+static void dll_build_name(char* buffer, size_t buflen,
+ const char* pname, const char* fname) {
+ // Loosley based on os_windows.cpp
+
+ char *pathname = (char *)pname;
+ while (strlen(pathname) > 0) {
+ char *p = strchr(pathname, ';');
+ if (p == NULL) {
+ p = pathname + strlen(pathname);
+ }
+ /* check for NULL path */
+ if (p == pathname) {
+ continue;
+ }
+ if (*(p-1) == ':' || *(p-1) == '\\') {
+ (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
+ pathname, fname);
+ } else {
+ (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
+ pathname, fname);
+ }
+ if (_access(buffer, 0) == 0) {
+ break;
+ }
+ pathname = p + 1;
+ *buffer = '\0';
+ }
+}
+
/* Build a machine dependent library name out of a path and file name. */
void
md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
{
int pnamelen;
- char c;
pnamelen = pname ? (int)strlen(pname) : 0;
- c = (pnamelen > 0) ? pname[pnamelen-1] : 0;
+ *holder = '\0';
/* Quietly truncates on buffer overflow. Should be an error. */
if (pnamelen + strlen(fname) + 10 > (unsigned int)holderlen) {
- *holder = '\0';
return;
}
if (pnamelen == 0) {
sprintf(holder, "%s.dll", fname);
- } else if (c == ':' || c == '\\') {
- sprintf(holder, "%s%s.dll", pname, fname);
} else {
- sprintf(holder, "%s\\%s.dll", pname, fname);
+ dll_build_name(holder, holderlen, pname, fname);
}
}
--- a/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,18 +41,20 @@
#define SECURITY_WIN32
#include "sspi.h"
-static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle);
+static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, JNIEnv *env, jobject status);
static jfieldID ntlm_ctxHandleID;
static jfieldID ntlm_crdHandleID;
+static jfieldID status_seqCompleteID;
static HINSTANCE lib = NULL;
JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst
-(JNIEnv *env, jclass clazz)
+(JNIEnv *env, jclass authseq_clazz, jclass status_clazz)
{
- ntlm_ctxHandleID = (*env)->GetFieldID(env, clazz, "ctxHandle", "J");
- ntlm_crdHandleID = (*env)->GetFieldID(env, clazz, "crdHandle", "J");
+ ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J");
+ ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J");
+ status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z");
}
/*
@@ -145,8 +147,14 @@
}
}
+
+/*
+ * Class: sun_net_www_protocol_http_ntlm_NTLMAuthSequence
+ * Method: getNextToken
+ * Signature: (J[BLsun/net/www/protocol/http/ntlm/NTLMAuthSequence/Status;)[B
+ */
JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_getNextToken
-(JNIEnv *env, jobject this, jlong crdHandle, jbyteArray lastToken)
+(JNIEnv *env, jobject this, jlong crdHandle, jbyteArray lastToken, jobject status)
{
VOID *pInput = 0;
@@ -217,7 +225,7 @@
}
if (ss < 0) {
- endSequence (pCred, pCtx);
+ endSequence (pCred, pCtx, env, status);
return 0;
}
@@ -225,7 +233,7 @@
ss = CompleteAuthToken( pCtx, &OutBuffDesc );
if (ss < 0) {
- endSequence (pCred, pCtx);
+ endSequence (pCred, pCtx, env, status);
return 0;
}
}
@@ -235,18 +243,18 @@
(*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
OutSecBuff.pvBuffer);
if (lastToken != 0) // 2nd stage
- endSequence (pCred, pCtx);
+ endSequence (pCred, pCtx, env, status);
result = ret;
}
if ((ss != SEC_I_CONTINUE_NEEDED) && (ss == SEC_I_COMPLETE_AND_CONTINUE)) {
- endSequence (pCred, pCtx);
+ endSequence (pCred, pCtx, env, status);
}
return result;
}
-static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) {
+static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, JNIEnv *env, jobject status) {
if (credHand != 0) {
FreeCredentialsHandle(credHand);
free(credHand);
@@ -256,4 +264,7 @@
DeleteSecurityContext(ctxHandle);
free(ctxHandle);
}
+
+ /* Sequence is complete so set flag */
+ (*env)->SetBooleanField(env, status, status_seqCompleteID, JNI_TRUE);
}
--- a/jdk/src/windows/npt/npt_md.h Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/src/windows/npt/npt_md.h Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,30 +33,16 @@
#include <string.h>
#include <errno.h>
-#define NPT_LIBNAME "npt.dll"
+#define NPT_LIBNAME "npt"
-#define NPT_INITIALIZE(pnpt,version,options) \
+#define NPT_INITIALIZE(path,pnpt,version,options) \
{ \
- HINSTANCE jvm; \
void *_handle; \
void *_sym; \
- char buf[FILENAME_MAX+32]; \
- char *lastSlash; \
\
if ( (pnpt) == NULL ) NPT_ERROR("NptEnv* is NULL"); \
- _handle = NULL; \
*(pnpt) = NULL; \
- buf[0] = 0; \
- jvm = GetModuleHandle("jvm.dll"); \
- if ( jvm == NULL ) NPT_ERROR("Cannot find jvm.dll"); \
- GetModuleFileName(jvm, buf, FILENAME_MAX); \
- lastSlash = strrchr(buf, '\\'); \
- if ( lastSlash != NULL ) { \
- *lastSlash = '\0'; \
- (void)strcat(buf, "\\..\\"); \
- (void)strcat(buf, NPT_LIBNAME); \
- _handle = LoadLibrary(buf); \
- } \
+ _handle = LoadLibrary(path); \
if ( _handle == NULL ) NPT_ERROR("Cannot open library"); \
_sym = GetProcAddress(_handle, "nptInitialize"); \
if ( _sym == NULL ) NPT_ERROR("Cannot find nptInitialize"); \
--- a/jdk/test/ProblemList.txt Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/ProblemList.txt Mon Dec 10 20:58:36 2012 -0800
@@ -141,6 +141,9 @@
# jdk_management
+# 7158614
+sun/management/jmxremote/startstop/JMXStartStopTest.sh linux-all
+
############################################################################
# jdk_jmx
@@ -162,26 +165,9 @@
# 6988950
demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
-# 7162111
-demo/jvmti/mtrace/TraceJFrame.java macosx-all
-javax/script/CauseExceptionTest.java macosx-all
-javax/script/GetInterfaceTest.java macosx-all
-javax/script/JavaScriptScopeTest.java macosx-all
-javax/script/NullUndefinedVarTest.java macosx-all
-javax/script/PluggableContextTest.java macosx-all
-javax/script/ProviderTest.sh macosx-all
-javax/script/RhinoExceptionTest.java macosx-all
-javax/script/StringWriterPrintTest.java macosx-all
-javax/script/Test1.java macosx-all
-javax/script/Test2.java macosx-all
-javax/script/Test3.java macosx-all
-javax/script/Test4.java macosx-all
-javax/script/Test5.java macosx-all
-javax/script/Test6.java macosx-all
-javax/script/Test7.java macosx-all
-javax/script/Test8.java macosx-all
-javax/script/UnescapedBracketRegExTest.java macosx-all
-javax/script/VersionTest.java macosx-all
+# 7027502
+demo/jvmti/hprof/MonitorTest.java generic-all
+
############################################################################
# jdk_net
@@ -224,10 +210,8 @@
# jdk_io
-# 7162111 - these tests need to be updated to run headless
-java/io/Serializable/resolveClass/deserializeButton/run.sh macosx-all
-java/io/Serializable/serialver/classpath/run.sh macosx-all
-java/io/Serializable/serialver/nested/run.sh macosx-all
+# 7160013
+java/io/File/MaxPathLength.java windows-all
############################################################################
@@ -250,6 +234,9 @@
# 7132677
java/nio/channels/Selector/OutOfBand.java macosx-all
+# 8003895
+java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-amd64
+
############################################################################
# jdk_rmi
@@ -267,7 +254,7 @@
java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
# 7195095
-sun/rmi/transport/proxy/EagerHttpFallback.java linux-all
+sun/rmi/transport/proxy/EagerHttpFallback.java generic-all
############################################################################
@@ -308,6 +295,12 @@
# 8000439: NPG: REGRESSION : sun/security/krb5/auto/MaxRetries.java fails with timeout
sun/security/krb5/auto/MaxRetries.java solaris-sparcv9
+# 7194428
+sun/security/mscapi/ShortRSAKey1024.sh windows-all
+
+# 8000897, vm crash
+sun/security/provider/DSA/TestAlgParameterGenerator.java generic-all
+
############################################################################
# jdk_sound
@@ -364,9 +357,6 @@
# jdk_util
-# 7162111 - test needs to be changed to run headless
-java/util/ResourceBundle/Control/Bug6530694.java macosx-all
-
# Filed 6933803
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
--- a/jdk/test/demo/jvmti/mtrace/TraceJFrame.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/demo/jvmti/mtrace/TraceJFrame.java Mon Dec 10 20:58:36 2012 -0800
@@ -32,21 +32,26 @@
* @run main TraceJFrame JFrameCreateTime
*/
-public class TraceJFrame {
+import java.awt.GraphicsEnvironment;
+public class TraceJFrame {
public static void main(String args[]) throws Exception {
- DemoRun demo;
+ if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
+ System.out.println("JFrame test was skipped due to headless mode");
+ } else {
+ DemoRun demo;
- /* Run demo that uses JVMTI mtrace agent (no options) */
- demo = new DemoRun("mtrace", "" /* options to mtrace */ );
- demo.runit(args[0]);
+ /* Run demo that uses JVMTI mtrace agent (no options) */
+ demo = new DemoRun("mtrace", "" /* options to mtrace */ );
+ demo.runit(args[0]);
- /* Make sure patterns in output look ok */
- if (demo.output_contains("ERROR")) {
- throw new RuntimeException("Test failed - ERROR seen in output");
+ /* Make sure patterns in output look ok */
+ if (demo.output_contains("ERROR")) {
+ throw new RuntimeException("Test failed - ERROR seen in output");
+ }
+
+ /* Must be a pass. */
+ System.out.println("Test passed - cleanly terminated");
}
-
- /* Must be a pass. */
- System.out.println("Test passed - cleanly terminated");
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/FrameSetSizeStressTest/FrameSetSizeStressTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Frame;
+
+/*
+ @test
+ @bug 7177173
+ @summary setBounds can cause StackOverflow in case of the considerable loading
+ @author Sergey Bylokhov
+*/
+public final class FrameSetSizeStressTest {
+
+ public static void main(final String[] args) {
+ final Frame frame = new Frame();
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ for (int i = 0; i < 1000; ++i) {
+ frame.setSize(100, 100);
+ frame.setSize(200, 200);
+ frame.setSize(300, 300);
+ }
+ frame.dispose();
+ }
+}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Foo.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Foo.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,27 +26,26 @@
* @summary Verify that class loaded outside of application class loader is
* correctly resolved during deserialization when read in by custom
* readObject() method of a bootstrap class (in this case,
- * java.awt.Button).
+ * java.util.Vector).
*/
-import java.awt.Button;
-import java.awt.event.MouseAdapter;
import java.io.*;
+import java.util.Vector;
public class Foo implements Runnable {
- static class Adapter extends MouseAdapter implements Serializable {}
+ static class TestElement extends Object implements Serializable {}
public void run() {
try {
- Button button = new Button();
- button.addMouseListener(new Adapter());
+ Vector<TestElement> container = new Vector<TestElement>();
+ container.add(new TestElement());
// iterate to trigger java.lang.reflect code generation
for (int i = 0; i < 100; i++) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(button);
+ oout.writeObject(container);
oout.close();
ObjectInputStream oin = new ObjectInputStream(
new ByteArrayInputStream(bout.toByteArray()));
@@ -54,7 +53,7 @@
}
} catch (Exception ex) {
throw new Error(
- "Error occured while (de)serializing Button: " + ex);
+ "Error occured while (de)serializing container: ", ex);
}
}
}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java Mon Dec 10 20:58:36 2012 -0800
@@ -26,7 +26,7 @@
* @summary Verify that class loaded outside of application class loader is
* correctly resolved during deserialization when read in by custom
* readObject() method of a bootstrap class (in this case,
- * java.awt.Button).
+ * java.util.Vector).
*/
import java.io.*;
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh Mon Dec 10 20:58:36 2012 -0800
@@ -26,7 +26,7 @@
# @summary Verify that class loaded outside of application class loader is
# correctly resolved during deserialization when read in by custom
# readObject() method of a bootstrap class (in this case,
-# java.awt.Button).
+# java.util.Vector).
if [ "${TESTJAVA}" = "" ]
then
--- a/jdk/test/java/lang/Math/DivModTests.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/lang/Math/DivModTests.java Mon Dec 10 20:58:36 2012 -0800
@@ -65,7 +65,7 @@
* Math and StrictMath tested and the same results are expected for both.
*/
static void testIntFloorDivMod() {
- testIntFloorDivMod(4, 0, new ArithmeticException("/ by zero"), new ArithmeticException("/ by zero")); // Should throw ArithmeticException
+ testIntFloorDivMod(4, 0, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException
testIntFloorDivMod(4, 3, 1, 1);
testIntFloorDivMod(3, 3, 1, 0);
testIntFloorDivMod(2, 3, 0, 2);
@@ -151,7 +151,7 @@
* Test the floorDiv and floorMod methods for primitive long.
*/
static void testLongFloorDivMod() {
- testLongFloorDivMod(4L, 0L, new ArithmeticException("/ by zero"), new ArithmeticException("/ by zero")); // Should throw ArithmeticException
+ testLongFloorDivMod(4L, 0L, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException
testLongFloorDivMod(4L, 3L, 1L, 1L);
testLongFloorDivMod(3L, 3L, 1L, 0L);
testLongFloorDivMod(2L, 3L, 0L, 2L);
@@ -385,9 +385,7 @@
}
// Handle special case to compare ArithmeticExceptions
if (result instanceof ArithmeticException && expected instanceof ArithmeticException) {
- ArithmeticException ae1 = (ArithmeticException)result;
- ArithmeticException ae2 = (ArithmeticException)expected;
- return ae1.getMessage().equals(ae2.getMessage());
+ return true;
}
return false;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7154390
+ * @summary Unit test for repeated annotation reflection
+ *
+ * @compile RepeatedUnitTest.java subpackage/package-info.java subpackage/Container.java subpackage/Containee.java subpackage/NonRepeated.java subpackage/InheritedContainee.java subpackage/InheritedContainer.java subpackage/InheritedNonRepeated.java
+ * @run main RepeatedUnitTest
+ */
+
+import subpackage.*;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+public class RepeatedUnitTest {
+ public static void main(String[] args) throws Exception {
+ // PACKAGE ANNOTATIONS
+ Class c = Class.forName("subpackage.NonRepeated"); // force package "subpackage" load
+ Package p = Package.getPackage("subpackage");
+ packageNonRepeated(p);
+ packageRepeated(p);
+ packageContainer(p);
+
+ // INHERITED/NON-INHERITED ON CLASS
+ inheritedMe1();
+ inheritedMe2();
+ inheritedMe3();
+ inheritedMe4();
+
+ // CONSTRUCTOR
+ checkMultiplier(Me1.class.getConstructor(new Class[0]), 10);
+
+ // FIELD
+ checkMultiplier(Me1.class.getField("foo"), 1);
+
+ // METHOD
+ checkMultiplier(Me1.class.getDeclaredMethod("mee", null), 100);
+
+ // INNER CLASS
+ checkMultiplier(Me1.MiniMee.class, 1000);
+
+ // ENUM ELEMENT
+ checkMultiplier(Me1.E.class.getField("EE"), 10000);
+
+ // ENUM
+ checkMultiplier(Me1.E.class, 100000);
+ }
+
+ static void packageNonRepeated(AnnotatedElement e) {
+ NonRepeated nr = e.getAnnotation(NonRepeated.class);
+ check(nr.value() == 10);
+
+ check(1 == countAnnotation(e, NonRepeated.class));
+
+ nr = e.getAnnotations(NonRepeated.class)[0];
+ check(nr.value() == 10);
+
+ check(1 == containsAnnotationOfType(e.getAnnotations(), NonRepeated.class));
+ }
+
+ static void packageRepeated(AnnotatedElement e) {
+ Containee c = e.getAnnotation(Containee.class);
+ check(c.value() == 1);
+
+ check(2 == countAnnotation(e, Containee.class));
+
+ c = e.getAnnotations(Containee.class)[0];
+ check(c.value() == 1);
+ c = e.getAnnotations(Containee.class)[1];
+ check(c.value() == 2);
+
+ check(2 == containsAnnotationOfType(e.getAnnotations(), Containee.class));
+ }
+
+ static void packageContainer(AnnotatedElement e) {
+ Container cr = e.getAnnotation(Container.class);
+ check(null != cr);
+ check(1 == containsAnnotationOfType(e.getAnnotations(Container.class), Container.class));
+ check(1 == countAnnotation(e, Container.class));
+ }
+
+ static void inheritedMe1() {
+ AnnotatedElement e = Me1.class;
+ check(null == e.getAnnotation(NonRepeated.class));
+ check(e.getAnnotation(InheritedNonRepeated.class).value() == 20);
+ check(0 == countAnnotation(e, Containee.class));
+ check(4 == countAnnotation(e, InheritedContainee.class));
+ check(0 == countAnnotation(e, Container.class));
+ check(1 == countAnnotation(e, InheritedContainer.class));
+ }
+
+ static void inheritedMe2() {
+ AnnotatedElement e = Me2.class;
+ check(e.getAnnotation(NonRepeated.class).value() == 100);
+ check(e.getAnnotation(InheritedNonRepeated.class).value() == 200);
+ check(4 == countAnnotation(e, Containee.class));
+ check(4 == countAnnotation(e, InheritedContainee.class));
+ check(1 == countAnnotation(e, Container.class));
+ check(1 == countAnnotation(e, InheritedContainer.class));
+ check(1 == countAnnotation(e, NonRepeated.class));
+ check(1 == countAnnotation(e, InheritedNonRepeated.class));
+
+ check(e.getAnnotations(Containee.class)[2].value() == 300);
+ check(e.getAnnotations(InheritedContainee.class)[2].value() == 300);
+ check(e.getAnnotations(InheritedNonRepeated.class)[0].value() == 200);
+ check(e.getAnnotations(NonRepeated.class)[0].value() == 100);
+ }
+
+ static void inheritedMe3() {
+ AnnotatedElement e = Me3.class;
+ check(null == e.getAnnotation(NonRepeated.class));
+
+ check(0 == countAnnotation(e, Containee.class));
+ check(4 == countAnnotation(e, InheritedContainee.class));
+ check(0 == countAnnotation(e, Container.class));
+ check(1 == countAnnotation(e, InheritedContainer.class));
+
+ check(e.getAnnotations(InheritedContainee.class)[2].value() == 350);
+ check(e.getAnnotations(InheritedNonRepeated.class)[0].value() == 15);
+ }
+
+ static void inheritedMe4() {
+ AnnotatedElement e = Me4.class;
+ check(e.getAnnotation(NonRepeated.class).value() == 1000);
+ check(e.getAnnotation(InheritedNonRepeated.class).value() == 2000);
+ check(4 == countAnnotation(e, Containee.class));
+ check(4 == countAnnotation(e, InheritedContainee.class));
+ check(1 == countAnnotation(e, Container.class));
+ check(1 == countAnnotation(e, InheritedContainer.class));
+ check(1 == countAnnotation(e, NonRepeated.class));
+ check(1 == countAnnotation(e, InheritedNonRepeated.class));
+
+ check(e.getAnnotations(Containee.class)[2].value() == 3000);
+ check(e.getAnnotations(InheritedContainee.class)[2].value() == 3000);
+ check(e.getAnnotations(InheritedNonRepeated.class)[0].value() == 2000);
+ check(e.getAnnotations(NonRepeated.class)[0].value() == 1000);
+ }
+
+ static void checkMultiplier(AnnotatedElement e, int m) {
+ check(e.getAnnotation(NonRepeated.class).value() == 5 * m);
+
+ check(4 == countAnnotation(e, Containee.class));
+ check(1 == countAnnotation(e, Container.class));
+ check(1 == countAnnotation(e, NonRepeated.class));
+
+ check(e.getAnnotations(Containee.class)[2].value() == 3 * m);
+ check(e.getAnnotations(NonRepeated.class)[0].value() == 5 * m);
+ }
+
+ static void check(Boolean b) {
+ if (!b) throw new RuntimeException();
+ }
+
+ static int countAnnotation(AnnotatedElement e, Class<? extends Annotation> c) {
+ return containsAnnotationOfType(e.getAnnotations(c), c);
+ }
+
+ static <A extends Annotation> int containsAnnotationOfType(A[] l, Class<? extends Annotation> a) {
+ int count = 0;
+ for (Annotation an : l) {
+ if (an.annotationType().equals(a))
+ count++;
+ }
+ return count;
+ }
+}
+
+@NonRepeated @InheritedNonRepeated
+@InheritedContainee(1) @InheritedContainee(2) @InheritedContainee(3) @InheritedContainee(4)
+@Containee(1) @Containee(2) @Containee(3) @Containee(4)
+class Grandma {}
+
+class Mother extends Grandma {}
+
+@NonRepeated(5) @InheritedNonRepeated(15)
+@InheritedContainee(150) @InheritedContainee(250) @InheritedContainee(350) @InheritedContainee(450)
+@Containee(150) @Containee(250) @Containee(350) @Containee(450)
+class Father extends Grandma {}
+
+class Me1 extends Mother {
+
+ @NonRepeated(5)
+ @Containee(1) @Containee(2) @Containee(3) @Containee(4)
+ public String foo = "";
+
+ @NonRepeated(50)
+ @Containee(10) @Containee(20) @Containee(30) @Containee(40)
+ public Me1() {
+ }
+
+ @NonRepeated(500)
+ @Containee(100) @Containee(200) @Containee(300) @Containee(400)
+ public void mee() {
+ }
+
+ @NonRepeated(5000)
+ @Containee(1000) @Containee(2000) @Containee(3000) @Containee(4000)
+ public class MiniMee {}
+
+ @NonRepeated(500000)
+ @Containee(100000) @Containee(200000) @Containee(300000) @Containee(400000)
+ public enum E {
+ @NonRepeated(50000)
+ @Containee(10000) @Containee(20000) @Containee(30000) @Containee(40000)
+ EE(),
+ }
+}
+
+@NonRepeated(100) @InheritedNonRepeated(200)
+@InheritedContainee(100) @InheritedContainee(200) @InheritedContainee(300) @InheritedContainee(400)
+@Containee(100) @Containee(200) @Containee(300) @Containee(400)
+class Me2 extends Mother {}
+
+class Me3 extends Father {}
+
+@NonRepeated(1000) @InheritedNonRepeated(2000)
+@InheritedContainee(1000) @InheritedContainee(2000) @InheritedContainee(3000) @InheritedContainee(4000)
+@Containee(1000) @Containee(2000) @Containee(3000) @Containee(4000)
+class Me4 extends Father {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/Containee.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Container.class)
+public @interface Containee {
+ int value();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/Container.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainerFor(Containee.class)
+public @interface Container {
+ Containee[] value();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainee.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(InheritedContainer.class)
+public @interface InheritedContainee {
+ int value();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainer.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@ContainerFor(InheritedContainee.class)
+public @interface InheritedContainer {
+ InheritedContainee[] value();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedNonRepeated.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InheritedNonRepeated {
+ int value() default 20;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/NonRepeated.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package subpackage;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NonRepeated {
+ int value() default 10;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/repeatingAnnotations/subpackage/package-info.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@NonRepeated @Containee(1) @Containee(2)
+package subpackage;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/ResponseCache/Test.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary Fixed a potential NullPointerException when setting a ResponseCache that returns a null CacheRequest
+ * @bug 4837267
+ * @author Michael McMahon
+ */
+
+import com.sun.net.httpserver.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+public class Test
+{
+
+ static class MyHandler implements HttpHandler {
+ public void handle(HttpExchange t) throws IOException {
+ byte[] b = new byte[1024];
+ int r = 0;
+ InputStream is = t.getRequestBody();
+ while (is.read(b) != -1) ;
+ String response = "This is the response";
+ t.sendResponseHeaders(200, response.length());
+ OutputStream os = t.getResponseBody();
+ os.write(response.getBytes());
+ os.close();
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+ HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
+ server.createContext("/", new MyHandler());
+ server.start();
+ ResponseCache bak = ResponseCache.getDefault();
+
+ try {
+ ResponseCache.setDefault (new ResponseCache() {
+ public CacheResponse get (URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders)
+ throws IOException {
+ return null;
+ }
+ public CacheRequest put(URI uri, URLConnection conn) throws IOException
+ {
+ return null;
+ }
+ });
+
+ URL url = new URL ("http://localhost:" + server.getAddress().getPort() + "/");
+ URLConnection urlc = url.openConnection ();
+ InputStream is = urlc.getInputStream();
+ while (is.read() != -1) ;
+ is.close();
+ } finally {
+ ResponseCache.setDefault(bak);
+ server.stop(0);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Socket/B6210227.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6210227
+ * @summary REGRESSION: Socket.getLocalAddress() returns address of 0.0.0.0 on outbound TCP
+ */
+
+import java.util.*;
+import java.net.*;
+
+public class B6210227 {
+ public static void main(String[] args) throws Exception
+ {
+ ServerSocket ss = new ServerSocket(0);
+ int port = ss.getLocalPort();
+
+ byte[] bad = {0,0,0,0};
+ try {
+ InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+ Socket s = new Socket();
+ s.connect( isa, 1000 );
+ InetAddress iaLocal = s.getLocalAddress(); // if this comes back as 0.0. 0.0 this would demonstrate issue
+ String sLocalHostname = iaLocal.getHostName();
+ if (Arrays.equals (iaLocal.getAddress(), bad)) {
+ throw new RuntimeException ("0.0.0.0 returned");
+ }
+ System.out.println("local hostname is "+sLocalHostname );
+ } catch(Exception e) {
+ System.out.println("Exception happened");
+ throw e;
+ } finally {
+ ss.close();
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Socket/Streams.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003833
+ * @summary Spurious NPE from Socket.getIn/OutputStream
+ */
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.Phaser;
+
+// Racey test, will not always fail, but if it does then there is a problem.
+
+public class Streams {
+ static final int NUM_THREADS = 100;
+ static volatile boolean failed;
+ static final Phaser startingGate = new Phaser(NUM_THREADS + 1);
+
+ public static void main(String[] args) throws Exception {
+
+ try (ServerSocket ss = new ServerSocket(0)) {
+ runTest(OutputStreamGetter.class, ss);
+ runTest(InputStreamGetter.class, ss);
+ }
+
+ if (failed)
+ throw new RuntimeException("Failed, check output");
+ }
+
+ static void runTest(Class<? extends StreamGetter> klass, ServerSocket ss)
+ throws Exception
+ {
+ final int port = ss.getLocalPort();
+ Socket[] sockets = new Socket[NUM_THREADS];
+ for (int i=0; i<NUM_THREADS; i++) {
+ sockets[i] = new Socket("localhost", port);
+ try (Socket socket = ss.accept()) {}
+ }
+
+ Constructor<? extends StreamGetter> ctr = klass.getConstructor(Socket.class);
+
+ Thread[] threads = new Thread[NUM_THREADS];
+ for (int i=0; i<NUM_THREADS; i++)
+ threads[i] = ctr.newInstance(sockets[i]);
+ for (int i=0; i<NUM_THREADS; i++)
+ threads[i].start();
+
+ startingGate.arriveAndAwaitAdvance();
+ for (int i=0; i<NUM_THREADS; i++)
+ sockets[i].close();
+
+ for (int i=0; i<NUM_THREADS; i++)
+ threads[i].join();
+ }
+
+ static abstract class StreamGetter extends Thread {
+ final Socket socket;
+ StreamGetter(Socket s) { socket = s; }
+
+ @Override
+ public void run() {
+ try {
+ startingGate.arriveAndAwaitAdvance();
+ getStream();
+ } catch (IOException x) {
+ // OK, socket may be closed
+ } catch (NullPointerException x) {
+ x.printStackTrace();
+ failed = true;
+ }
+ }
+
+ abstract void getStream() throws IOException;
+ }
+
+ static class InputStreamGetter extends StreamGetter {
+ public InputStreamGetter(Socket s) { super(s); }
+ void getStream() throws IOException {
+ socket.getInputStream();
+ }
+ }
+
+ static class OutputStreamGetter extends StreamGetter {
+ public OutputStreamGetter(Socket s) { super(s); }
+ void getStream() throws IOException {
+ socket.getOutputStream();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/BasicPermission/Wildcard.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.RuntimePermission;
+import java.net.NetPermission;
+import java.sql.SQLPermission;
+import java.util.PropertyPermission;
+import javax.net.ssl.SSLPermission;
+
+/*
+ * @test
+ * @bug 7167056
+ * @summary Check that BasicPermission subclasses don't throw exception if name
+ * contains wildcard character ("*") but does not signify a
+ * wildcard match
+ */
+
+public class Wildcard {
+
+ public static void main(String[] args) throws Exception {
+ wildcard("*java");
+ wildcard("java*");
+ wildcard("ja*va");
+ }
+
+ private static void wildcard(String wildcard) throws Exception {
+ new RuntimePermission(wildcard);
+ new NetPermission(wildcard);
+ new SQLPermission(wildcard);
+ new PropertyPermission(wildcard, "read");
+ new SSLPermission(wildcard);
+ new com.sun.net.ssl.SSLPermission(wildcard);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/TestBase64.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,532 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test 4235519 8004212
+ * @summary tests java.util.Base64
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Random;
+
+public class TestBase64 {
+
+ public static void main(String args[]) throws Throwable {
+ int numRuns = 10;
+ int numBytes = 200;
+ if (args.length > 1) {
+ numRuns = Integer.parseInt(args[0]);
+ numBytes = Integer.parseInt(args[1]);
+ }
+
+ test(Base64.getEncoder(), Base64.getDecoder(),
+ numRuns, numBytes);
+ test(Base64.getUrlEncoder(), Base64.getUrlDecoder(),
+ numRuns, numBytes);
+ test(Base64.getMimeEncoder(), Base64.getMimeDecoder(),
+ numRuns, numBytes);
+
+ Random rnd = new java.util.Random();
+ byte[] nl_1 = new byte[] {'\n'};
+ byte[] nl_2 = new byte[] {'\n', '\r'};
+ byte[] nl_3 = new byte[] {'\n', '\r', '\n'};
+ for (int i = 0; i < 10; i++) {
+ int len = rnd.nextInt(200) + 4;
+ test(Base64.getEncoder(len, nl_1),
+ Base64.getMimeDecoder(),
+ numRuns, numBytes);
+ test(Base64.getEncoder(len, nl_2),
+ Base64.getMimeDecoder(),
+ numRuns, numBytes);
+ test(Base64.getEncoder(len, nl_3),
+ Base64.getMimeDecoder(),
+ numRuns, numBytes);
+ }
+
+ testNull(Base64.getEncoder());
+ testNull(Base64.getUrlEncoder());
+ testNull(Base64.getMimeEncoder());
+ testNull(Base64.getEncoder(10, new byte[]{'\n'}));
+ testNull(Base64.getDecoder());
+ testNull(Base64.getUrlDecoder());
+ testNull(Base64.getMimeDecoder());
+ checkNull(new Runnable() { public void run() { Base64.getEncoder(10, null); }});
+
+ testIOE(Base64.getEncoder());
+ testIOE(Base64.getUrlEncoder());
+ testIOE(Base64.getMimeEncoder());
+ testIOE(Base64.getEncoder(10, new byte[]{'\n'}));
+
+ byte[] src = new byte[1024];
+ new Random().nextBytes(src);
+ final byte[] decoded = Base64.getEncoder().encode(src);
+ testIOE(Base64.getDecoder(), decoded);
+ testIOE(Base64.getMimeDecoder(), decoded);
+ testIOE(Base64.getUrlDecoder(), Base64.getUrlEncoder().encode(src));
+
+ // illegal line separator
+ checkIAE(new Runnable() { public void run() { Base64.getEncoder(10, new byte[]{'\r', 'N'}); }});
+
+ // illegal base64 character
+ decoded[2] = (byte)0xe0;
+ checkIAE(new Runnable() {
+ public void run() { Base64.getDecoder().decode(decoded); }});
+ checkIAE(new Runnable() {
+ public void run() { Base64.getDecoder().decode(decoded, new byte[1024]); }});
+ checkIAE(new Runnable() { public void run() {
+ Base64.getDecoder().decode(ByteBuffer.wrap(decoded)); }});
+ checkIAE(new Runnable() { public void run() {
+ Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocate(1024)); }});
+ checkIAE(new Runnable() { public void run() {
+ Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocateDirect(1024)); }});
+
+ // test return value from decode(ByteBuffer, ByteBuffer)
+ testDecBufRet();
+ }
+
+ private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder();
+
+ private static void test(Base64.Encoder enc, Base64.Decoder dec,
+ int numRuns, int numBytes) throws Throwable {
+ Random rnd = new java.util.Random();
+
+ enc.encode(new byte[0]);
+ dec.decode(new byte[0]);
+
+ for (int i=0; i<numRuns; i++) {
+ for (int j=1; j<numBytes; j++) {
+ byte[] orig = new byte[j];
+ rnd.nextBytes(orig);
+
+ // --------testing encode/decode(byte[])--------
+ byte[] encoded = enc.encode(orig);
+ byte[] decoded = dec.decode(encoded);
+
+ checkEqual(orig, decoded,
+ "Base64 array encoding/decoding failed!");
+
+ // compare to sun.misc.BASE64Encoder
+ byte[] encoded2 = sunmisc.encode(orig).getBytes("ASCII");
+ checkEqual(normalize(encoded),
+ normalize(encoded2),
+ "Base64 enc.encode() does not match sun.misc.base64!");
+
+ // remove padding '=' to test non-padding decoding case
+ if (encoded[encoded.length -2] == '=')
+ encoded2 = Arrays.copyOf(encoded, encoded.length -2);
+ else if (encoded[encoded.length -1] == '=')
+ encoded2 = Arrays.copyOf(encoded, encoded.length -1);
+ else
+ encoded2 = null;
+
+ // --------testing encodetoString(byte[])/decode(String)--------
+ String str = enc.encodeToString(orig);
+ if (!Arrays.equals(str.getBytes("ASCII"), encoded)) {
+ throw new RuntimeException(
+ "Base64 encodingToString() failed!");
+ }
+ byte[] buf = dec.decode(new String(encoded, "ASCII"));
+ checkEqual(buf, orig, "Base64 decoding(String) failed!");
+
+ if (encoded2 != null) {
+ buf = dec.decode(new String(encoded2, "ASCII"));
+ checkEqual(buf, orig, "Base64 decoding(String) failed!");
+ }
+
+ //-------- testing encode/decode(Buffer)--------
+ testEncode(enc, ByteBuffer.wrap(orig), encoded);
+ ByteBuffer bin = ByteBuffer.allocateDirect(orig.length);
+ bin.put(orig).flip();
+ testEncode(enc, bin, encoded);
+
+ testDecode(dec, ByteBuffer.wrap(encoded), orig);
+ bin = ByteBuffer.allocateDirect(encoded.length);
+ bin.put(encoded).flip();
+ testDecode(dec, bin, orig);
+
+ if (encoded2 != null)
+ testDecode(dec, ByteBuffer.wrap(encoded2), orig);
+
+ // -------- testing encode(Buffer, Buffer)--------
+ testEncode(enc, encoded,
+ ByteBuffer.wrap(orig),
+ ByteBuffer.allocate(encoded.length + 10));
+
+ testEncode(enc, encoded,
+ ByteBuffer.wrap(orig),
+ ByteBuffer.allocateDirect(encoded.length + 10));
+
+ // --------testing decode(Buffer, Buffer);--------
+ testDecode(dec, orig,
+ ByteBuffer.wrap(encoded),
+ ByteBuffer.allocate(orig.length + 10));
+
+ testDecode(dec, orig,
+ ByteBuffer.wrap(encoded),
+ ByteBuffer.allocateDirect(orig.length + 10));
+
+ // --------testing decode.wrap(input stream)--------
+ // 1) random buf length
+ ByteArrayInputStream bais = new ByteArrayInputStream(encoded);
+ InputStream is = dec.wrap(bais);
+ buf = new byte[orig.length + 10];
+ int len = orig.length;
+ int off = 0;
+ while (true) {
+ int n = rnd.nextInt(len);
+ if (n == 0)
+ n = 1;
+ n = is.read(buf, off, n);
+ if (n == -1) {
+ checkEqual(off, orig.length,
+ "Base64 stream decoding failed");
+ break;
+ }
+ off += n;
+ len -= n;
+ if (len == 0)
+ break;
+ }
+ buf = Arrays.copyOf(buf, off);
+ checkEqual(buf, orig, "Base64 stream decoding failed!");
+
+ // 2) read one byte each
+ bais.reset();
+ is = dec.wrap(bais);
+ buf = new byte[orig.length + 10];
+ off = 0;
+ int b;
+ while ((b = is.read()) != -1) {
+ buf[off++] = (byte)b;
+ }
+ buf = Arrays.copyOf(buf, off);
+ checkEqual(buf, orig, "Base64 stream decoding failed!");
+
+ // --------testing encode.wrap(output stream)--------
+ ByteArrayOutputStream baos = new ByteArrayOutputStream((orig.length + 2) / 3 * 4 + 10);
+ OutputStream os = enc.wrap(baos);
+ off = 0;
+ len = orig.length;
+ for (int k = 0; k < 5; k++) {
+ if (len == 0)
+ break;
+ int n = rnd.nextInt(len);
+ if (n == 0)
+ n = 1;
+ os.write(orig, off, n);
+ off += n;
+ len -= n;
+ }
+ if (len != 0)
+ os.write(orig, off, len);
+ os.close();
+ buf = baos.toByteArray();
+ checkEqual(buf, encoded, "Base64 stream encoding failed!");
+
+ // 2) write one byte each
+ baos.reset();
+ os = enc.wrap(baos);
+ off = 0;
+ while (off < orig.length) {
+ os.write(orig[off++]);
+ }
+ os.close();
+ buf = baos.toByteArray();
+ checkEqual(buf, encoded, "Base64 stream encoding failed!");
+
+ // --------testing encode(in, out); -> bigger buf--------
+ buf = new byte[encoded.length + rnd.nextInt(100)];
+ int ret = enc.encode(orig, buf);
+ checkEqual(ret, encoded.length,
+ "Base64 enc.encode(src, null) returns wrong size!");
+ buf = Arrays.copyOf(buf, ret);
+ checkEqual(buf, encoded,
+ "Base64 enc.encode(src, dst) failed!");
+
+ // --------testing decode(in, out); -> bigger buf--------
+ buf = new byte[orig.length + rnd.nextInt(100)];
+ ret = dec.decode(encoded, buf);
+ checkEqual(ret, orig.length,
+ "Base64 enc.encode(src, null) returns wrong size!");
+ buf = Arrays.copyOf(buf, ret);
+ checkEqual(buf, orig,
+ "Base64 dec.decode(src, dst) failed!");
+
+ }
+ }
+ }
+
+ private static final byte[] ba_null = null;
+ private static final String str_null = null;
+ private static final ByteBuffer bb_null = null;
+
+ private static void testNull(final Base64.Encoder enc) {
+ checkNull(new Runnable() { public void run() { enc.encode(ba_null); }});
+ checkNull(new Runnable() { public void run() { enc.encodeToString(ba_null); }});
+ checkNull(new Runnable() { public void run() { enc.encode(ba_null, new byte[10]); }});
+ checkNull(new Runnable() { public void run() { enc.encode(new byte[10], ba_null); }});
+ checkNull(new Runnable() { public void run() { enc.encode(bb_null); }});
+ checkNull(new Runnable() { public void run() { enc.encode(bb_null, ByteBuffer.allocate(10), 0); }});
+ checkNull(new Runnable() { public void run() { enc.encode(ByteBuffer.allocate(10), bb_null, 0); }});
+ }
+
+ private static void testNull(final Base64.Decoder dec) {
+ checkNull(new Runnable() { public void run() { dec.decode(ba_null); }});
+ checkNull(new Runnable() { public void run() { dec.decode(str_null); }});
+ checkNull(new Runnable() { public void run() { dec.decode(ba_null, new byte[10]); }});
+ checkNull(new Runnable() { public void run() { dec.decode(new byte[10], ba_null); }});
+ checkNull(new Runnable() { public void run() { dec.decode(bb_null); }});
+ checkNull(new Runnable() { public void run() { dec.decode(bb_null, ByteBuffer.allocate(10)); }});
+ checkNull(new Runnable() { public void run() { dec.decode(ByteBuffer.allocate(10), bb_null); }});
+ }
+
+ private static interface Testable {
+ public void test() throws Throwable;
+ }
+
+ private static void testIOE(final Base64.Encoder enc) throws Throwable {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
+ final OutputStream os = enc.wrap(baos);
+ os.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
+ os.close();
+ checkIOE(new Testable() { public void test() throws Throwable { os.write(10); }});
+ checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}); }});
+ checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}, 1, 4); }});
+ }
+
+ private static void testIOE(final Base64.Decoder dec, byte[] decoded) throws Throwable {
+ ByteArrayInputStream bais = new ByteArrayInputStream(decoded);
+ final InputStream is = dec.wrap(bais);
+ is.read(new byte[10]);
+ is.close();
+ checkIOE(new Testable() { public void test() throws Throwable { is.read(); }});
+ checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}); }});
+ checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}, 1, 4); }});
+ checkIOE(new Testable() { public void test() throws Throwable { is.available(); }});
+ checkIOE(new Testable() { public void test() throws Throwable { is.skip(20); }});
+ }
+
+ private static final void checkNull(Runnable r) {
+ try {
+ r.run();
+ throw new RuntimeException("NPE is not thrown as expected");
+ } catch (NullPointerException npe) {}
+ }
+
+ private static final void checkIOE(Testable t) throws Throwable {
+ try {
+ t.test();
+ throw new RuntimeException("IOE is not thrown as expected");
+ } catch (IOException ioe) {}
+ }
+
+ private static final void checkIAE(Runnable r) throws Throwable {
+ try {
+ r.run();
+ throw new RuntimeException("IAE is not thrown as expected");
+ } catch (IllegalArgumentException iae) {}
+ }
+
+
+ private static void testDecBufRet() throws Throwable {
+ Random rnd = new java.util.Random();
+ Base64.Encoder encoder = Base64.getEncoder();
+ Base64.Decoder decoder = Base64.getDecoder();
+ // src pos, len expected
+ int[][] tests = { { 6, 3, 3, 3}, // xxx xxx -> yyyy yyyy
+ { 6, 3, 4, 3},
+ { 6, 3, 5, 3},
+ { 6, 3, 6, 6},
+ { 6, 11, 4, 3},
+ { 6, 11, 4, 3},
+ { 6, 11, 5, 3},
+ { 6, 11, 6, 6},
+ { 7, 3, 6, 6}, // xxx xxx x -> yyyy yyyy yy==
+ { 7, 3, 7, 7},
+ { 7, 11, 6, 6},
+ { 7, 11, 7, 7},
+ { 8, 3, 6, 6}, // xxx xxx xx -> yyyy yyyy yyy=
+ { 8, 3, 7, 6},
+ { 8, 3, 8, 8},
+ { 8, 13, 6, 6},
+ { 8, 13, 7, 6},
+ { 8, 13, 8, 8},
+
+ };
+ ByteBuffer dstBuf = ByteBuffer.allocate(100);
+ for (boolean direct : new boolean[] { false, true}) {
+ for (int[] test : tests) {
+ byte[] src = new byte[test[0]];
+ rnd.nextBytes(src);
+ ByteBuffer srcBuf = direct ? ByteBuffer.allocate(100)
+ : ByteBuffer.allocateDirect(100);
+ srcBuf.put(encoder.encode(src)).flip();
+ dstBuf.clear().position(test[1]).limit(test[1]+ test[2]);
+ int ret = decoder.decode(srcBuf, dstBuf);
+ if (ret != test[3]) {
+ System.out.printf(" [%6s] src=%d, pos=%d, len=%d, expected=%d, ret=%d%n",
+ direct?"direct":"",
+ test[0], test[1], test[2], test[3], ret);
+ throw new RuntimeException("ret != expected");
+ }
+ }
+ }
+ }
+
+ private static final void testEncode(Base64.Encoder enc, ByteBuffer bin, byte[] expected)
+ throws Throwable {
+
+ ByteBuffer bout = enc.encode(bin);
+ byte[] buf = new byte[bout.remaining()];
+ bout.get(buf);
+ if (bin.hasRemaining()) {
+ throw new RuntimeException(
+ "Base64 enc.encode(ByteBuffer) failed!");
+ }
+ checkEqual(buf, expected, "Base64 enc.encode(bf, bf) failed!");
+ }
+
+ private static final void testDecode(Base64.Decoder dec, ByteBuffer bin, byte[] expected)
+ throws Throwable {
+
+ ByteBuffer bout = dec.decode(bin);
+ byte[] buf = new byte[bout.remaining()];
+ bout.get(buf);
+ checkEqual(buf, expected, "Base64 dec.decode(bf) failed!");
+ }
+
+ private static final void testEncode(Base64.Encoder enc, byte[] expected,
+ ByteBuffer ibb, ByteBuffer obb)
+ throws Throwable {
+ Random rnd = new Random();
+ int bytesOut = enc.encode(ibb, obb, 0);
+ if (ibb.hasRemaining()) {
+ throw new RuntimeException(
+ "Base64 enc.encode(bf, bf) failed with wrong return!");
+ }
+ obb.flip();
+ byte[] buf = new byte[obb.remaining()];
+ obb.get(buf);
+ checkEqual(buf, expected, "Base64 enc.encode(bf, bf) failed!");
+ ibb.rewind();
+ obb.position(0);
+ obb.limit(0);
+ bytesOut = 0;
+
+ do { // increase the "limit" incrementally & randomly
+ int n = rnd.nextInt(expected.length - obb.position());
+ if (n == 0)
+ n = 1;
+ obb.limit(obb.limit() + n);
+ //obb.limit(Math.min(obb.limit() + n, expected.length));
+ bytesOut = enc.encode(ibb, obb, bytesOut);
+ } while (ibb.hasRemaining());
+ obb.flip();
+ buf = new byte[obb.remaining()];
+ obb.get(buf);
+ checkEqual(buf, expected, "Base64 enc.encode(bf, bf) failed!");
+ }
+
+ private static final void testDecode(Base64.Decoder dec, byte[] expected,
+ ByteBuffer ibb, ByteBuffer obb)
+ throws Throwable {
+ Random rnd = new Random();
+
+ dec.decode(ibb, obb);
+ if (ibb.hasRemaining()) {
+ throw new RuntimeException(
+ "Base64 dec.decode(bf, bf) failed with un-decoded ibb!");
+ }
+ obb.flip();
+ byte[] buf = new byte[obb.remaining()];
+ obb.get(buf);
+ checkEqual(buf, expected, "Base64 dec.decode(bf, bf) failed!");
+
+ ibb.rewind();
+ obb.position(0);
+ obb.limit(0);
+ do { // increase the "limit" incrementally & randomly
+ int n = rnd.nextInt(expected.length - obb.position());
+ if (n == 0)
+ n = 1;
+ obb.limit(obb.limit() + n);
+ dec.decode(ibb, obb);
+ } while (ibb.hasRemaining());
+
+
+ obb.flip();
+ buf = new byte[obb.remaining()];
+ obb.get(buf);
+ checkEqual(buf, expected, "Base64 dec.decode(bf, bf) failed!");
+ }
+
+ private static final void checkEqual(int v1, int v2, String msg)
+ throws Throwable {
+ if (v1 != v2) {
+ System.out.printf(" v1=%d%n", v1);
+ System.out.printf(" v2=%d%n", v2);
+ throw new RuntimeException(msg);
+ }
+ }
+
+ private static final void checkEqual(byte[] r1, byte[] r2, String msg)
+ throws Throwable {
+ if (!Arrays.equals(r1, r2)) {
+ System.out.printf(" r1[%d]=[%s]%n", r1.length, new String(r1));
+ System.out.printf(" r2[%d]=[%s]%n", r2.length, new String(r2));
+ throw new RuntimeException(msg);
+ }
+ }
+
+ // remove line feeds,
+ private static final byte[] normalize(byte[] src) {
+ int n = 0;
+ boolean hasUrl = false;
+ for (int i = 0; i < src.length; i++) {
+ if (src[i] == '\r' || src[i] == '\n')
+ n++;
+ if (src[i] == '-' || src[i] == '_')
+ hasUrl = true;
+ }
+ if (n == 0 && hasUrl == false)
+ return src;
+ byte[] ret = new byte[src.length - n];
+ int j = 0;
+ for (int i = 0; i < src.length; i++) {
+ if (src[i] == '-')
+ ret[j++] = '+';
+ else if (src[i] == '_')
+ ret[j++] = '/';
+ else if (src[i] != '\r' && src[i] != '\n')
+ ret[j++] = src[i];
+ }
+ return ret;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/TestBase64Golden.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test 4235519
+ * @author Eric Wang <yiming.wang@oracle.com>
+ * @summary tests java.util.Base64
+ */
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Base64;
+import java.util.Base64.Decoder;
+import java.util.Base64.Encoder;
+import java.util.Objects;
+import java.util.Random;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+public class TestBase64Golden {
+
+ public static void main(String[] args) throws Exception {
+ test0(Base64Type.BASIC, Base64.getEncoder(), Base64.getDecoder(),
+ "plain.txt", "baseEncode.txt");
+
+ test0(Base64Type.URLSAFE, Base64.getUrlEncoder(), Base64.getUrlDecoder(),
+ "plain.txt", "urlEncode.txt");
+
+ test0(Base64Type.MIME, Base64.getMimeEncoder(), Base64.getMimeDecoder(),
+ "plain.txt", "mimeEncode.txt");
+ test1();
+ test2();
+ }
+
+ public static void test0(Base64Type type, Encoder encoder, Decoder decoder,
+ String srcFile, String encodedFile) throws Exception {
+
+ String[] srcLns = Files.readAllLines(Paths.get(SRCDIR, srcFile), DEF_CHARSET)
+ .toArray(new String[0]);
+ String[] encodedLns = Files.readAllLines(Paths.get(SRCDIR, encodedFile),
+ DEF_CHARSET)
+ .toArray(new String[0]);
+ int lns = 0;
+ for (String srcStr : srcLns) {
+ String encodedStr = null;
+ if (type != Base64Type.MIME) {
+ encodedStr = encodedLns[lns++];
+ } else {
+ while (lns < encodedLns.length) {
+ String s = encodedLns[lns++];
+ if (s.length() == 0)
+ break;
+ if (encodedStr != null) {
+ encodedStr += DEFAULT_CRLF + s;
+ } else {
+ encodedStr = s;
+ }
+ }
+ if (encodedStr == null && srcStr.length() == 0) {
+ encodedStr = "";
+ }
+ }
+ System.out.printf("%n src[%d]: %s%n", srcStr.length(), srcStr);
+ System.out.printf("encoded[%d]: %s%n", encodedStr.length(), encodedStr);
+
+ byte[] srcArr = srcStr.getBytes(DEF_CHARSET);
+ byte[] encodedArr = encodedStr.getBytes(DEF_CHARSET);
+
+ ByteBuffer srcBuf = ByteBuffer.wrap(srcArr);
+ ByteBuffer encodedBuf = ByteBuffer.wrap(encodedArr);
+ byte[] resArr = new byte[encodedArr.length];
+
+ // test int encode(byte[], byte[])
+ int len = encoder.encode(srcArr, resArr);
+ assertEqual(len, encodedArr.length);
+ assertEqual(resArr, encodedArr);
+
+ // test byte[] encode(byte[])
+ resArr = encoder.encode(srcArr);
+ assertEqual(resArr, encodedArr);
+
+ // test ByteBuffer encode(ByteBuffer)
+ int limit = srcBuf.limit();
+ ByteBuffer resBuf = encoder.encode(srcBuf);
+ assertEqual(srcBuf.position(), limit);
+ assertEqual(srcBuf.limit(), limit);
+ assertEqual(resBuf, encodedBuf);
+ srcBuf.rewind(); // reset for next test
+
+ // test encode(ByteBuffer, ByteBuffer, bytesOut)
+ resBuf.clear();
+ len = encoder.encode(srcBuf, resBuf, 0);
+ assertEqual(len, encodedArr.length);
+ assertEqual(srcBuf.position(), limit);
+ assertEqual(srcBuf.limit(), limit);
+ assertEqual(resBuf.position(), len);
+ resBuf.flip();
+ assertEqual(resBuf, encodedBuf);
+ srcBuf.rewind();
+
+ // test encode(ByteBuffer, ByteBuffer, bytesOut)[direct]
+ ByteBuffer resBuf_d = ByteBuffer.allocateDirect(encodedArr.length);
+ len = encoder.encode(srcBuf, resBuf_d, 0);
+ assertEqual(len, encodedArr.length);
+ assertEqual(srcBuf.position(), limit);
+ assertEqual(srcBuf.limit(), limit);
+ assertEqual(resBuf_d.position(), len);
+ resBuf_d.flip();
+ assertEqual(resBuf_d, encodedBuf);
+ srcBuf.rewind();
+
+ // test String encodeToString(byte[])
+ String resEncodeStr = encoder.encodeToString(srcArr);
+ assertEqual(resEncodeStr, encodedStr);
+
+ // test int decode(byte[], byte[])
+ resArr = new byte[srcArr.length];
+ len = decoder.decode(encodedArr, resArr);
+ assertEqual(len, srcArr.length);
+ assertEqual(resArr, srcArr);
+
+ // test byte[] decode(byte[])
+ resArr = decoder.decode(encodedArr);
+ assertEqual(resArr, srcArr);
+
+ // test ByteBuffer decode(ByteBuffer)
+ limit = encodedBuf.limit();
+ resBuf = decoder.decode(encodedBuf);
+ assertEqual(encodedBuf.position(), limit);
+ assertEqual(encodedBuf.limit(), limit);
+ assertEqual(resBuf, srcBuf);
+ encodedBuf.rewind(); // reset for next test
+
+ // test int decode(ByteBuffer, ByteBuffer)
+ resBuf.clear();
+ len = decoder.decode(encodedBuf, resBuf);
+ assertEqual(len, srcArr.length);
+ assertEqual(encodedBuf.position(), limit);
+ assertEqual(encodedBuf.limit(), limit);
+ assertEqual(resBuf.position(), len);
+ resBuf.flip();
+ assertEqual(resBuf, srcBuf);
+ encodedBuf.rewind(); // reset for next test
+
+ // test int decode(ByteBuffer, ByteBuffer)[direct]
+ resBuf_d = ByteBuffer.allocateDirect(srcArr.length);
+ len = decoder.decode(encodedBuf, resBuf_d);
+ assertEqual(len, srcArr.length);
+ assertEqual(encodedBuf.position(), limit);
+ assertEqual(encodedBuf.limit(), limit);
+ assertEqual(resBuf_d.position(), len);
+ resBuf_d.flip();
+ assertEqual(resBuf_d, srcBuf);
+ encodedBuf.rewind(); // reset for next test
+
+ // test byte[] decode(String)
+ resArr = decoder.decode(encodedStr);
+ assertEqual(resArr, srcArr);
+
+ // test compatible with sun.misc.Base64Encoder
+ if (type == Base64Type.MIME) {
+ sun.misc.BASE64Encoder miscEncoder = new BASE64Encoder();
+ sun.misc.BASE64Decoder miscDecoder = new BASE64Decoder();
+ resArr = decoder.decode(miscEncoder.encode(srcArr));
+ assertEqual(resArr, srcArr);
+
+ resArr = encoder.encode(miscDecoder.decodeBuffer(encodedStr));
+ assertEqual(new String(resArr, DEF_CHARSET), encodedStr);
+ }
+ }
+ }
+
+ private static void test1() throws Exception {
+ byte[] src = new byte[6];
+ new Random().nextBytes(src);
+
+ ByteBuffer srcBuf = ByteBuffer.allocate(10);
+ srcBuf.position(2);
+ srcBuf.mark();
+ srcBuf.limit(8);
+ srcBuf.put(src);
+ srcBuf.reset();
+
+ ByteBuffer dstBuf = ByteBuffer.allocate((src.length + 2) / 3 * 4);
+ Base64.getEncoder().encode(srcBuf, dstBuf, 0);
+ dstBuf.rewind();
+ byte[] dst = new byte[dstBuf.limit()];
+ dstBuf.get(dst);
+ System.out.printf("%n src[%d]: %s%n", src.length, new String(src));
+ System.out.printf("encoded[%d]: %s%n", dst.length, new String(dst));
+ assertEqual(src, Base64.getDecoder().decode(dst));
+
+ dstBuf = ByteBuffer.allocateDirect((src.length + 2) / 3 * 4);
+ srcBuf.reset();
+ Base64.getEncoder().encode(srcBuf, dstBuf, 0);
+ dstBuf.rewind();
+ dst = new byte[dstBuf.limit()];
+ dstBuf.get(dst);
+ assertEqual(src, Base64.getDecoder().decode(dst));
+ }
+
+ private static void test2() throws Exception {
+ byte[] src = new byte[] {
+ 46, -97, -35, -44, 127, -60, -39, -4, -112, 34, -57, 47, -14, 67,
+ 40, 18, 90, -59, 68, 112, 23, 121, -91, 94, 35, 49, 104, 17, 30,
+ -80, -104, -3, -53, 27, 38, -72, -47, 113, -52, 18, 5, -126 };
+ Encoder encoder = Base64.getEncoder(49, new byte[] { 0x7e });
+ byte[] encoded = encoder.encode(src);
+ Decoder decoder = Base64.getMimeDecoder();
+ byte[] decoded = decoder.decode(encoded);
+ if (!Objects.deepEquals(src, decoded)) {
+ throw new RuntimeException();
+ }
+ }
+
+ // helper
+ enum Base64Type {
+ BASIC, URLSAFE, MIME
+ }
+
+ private static final String SRCDIR = System.getProperty("test.src", ".");
+ private static final Charset DEF_CHARSET = StandardCharsets.US_ASCII;
+ private static final String DEF_EXCEPTION_MSG =
+ "Assertion failed! The result is not same as expected";
+ private static final String DEFAULT_CRLF = "\r\n";
+
+ private static void assertEqual(Object result, Object expect) {
+ if (!Objects.deepEquals(result, expect)) {
+ String resultStr = result.toString();
+ String expectStr = expect.toString();
+ if (result instanceof byte[]) {
+ resultStr = new String((byte[]) result, DEF_CHARSET);
+ }
+ if (expect instanceof byte[]) {
+ expectStr = new String((byte[]) expect, DEF_CHARSET);
+ }
+ throw new RuntimeException(DEF_EXCEPTION_MSG +
+ " result: " + resultStr + " expected: " + expectStr);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/baseEncode.txt Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,183 @@
+VGhpcyB0ZXN0IGRhdGEgaXMgcGFydCBvZiByZmMyMDQ1IHdoaWNoIGluY2x1ZGVzIGFsbCBjaGFyYWN0ZXJzIGF+eiBBflosIDB+OSBhbmQgYWxsIHN5bWJvbHMs
+SXQgaXMgdXNlZCB0byB0ZXN0IGphdmEudXRpbC5CYXNlNjQuRW5jb2RlciwgYW5kIHdpbGwgYmUgZW5jb2RlZCBieSBvcmcuYXBhY2hlLmNvbW1vbnMuY29kZWMuYmluYXJ5LkJhc2U2NC5qYXZh
+dG8gdGVzdCBqYXZhLnV0aWwuQmFzZTY0LkRlY29kZXI7
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgIFtQYWdlIDFd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+ICAgVGhlc2UgZG9jdW1lbnRzIGFyZSByZXZpc2lvbnMgb2YgUkZDcyAxNTIxLCAxNTIyLCBhbmQgMTU5MCwgd2hpY2g=
+ICAgdGhlbXNlbHZlcyB3ZXJlIHJldmlzaW9ucyBvZiBSRkNzIDEzNDEgYW5kIDEzNDIuICBBbiBhcHBlbmRpeCBpbiBSRkM=
+ICAgMjA0OSBkZXNjcmliZXMgZGlmZmVyZW5jZXMgYW5kIGNoYW5nZXMgZnJvbSBwcmV2aW91cyB2ZXJzaW9ucy4=
+
+VGFibGUgb2YgQ29udGVudHM=
+
+ICAgMS4gSW50cm9kdWN0aW9uIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDM=
+ICAgMi4gRGVmaW5pdGlvbnMsIENvbnZlbnRpb25zLCBhbmQgR2VuZXJpYyBCTkYgR3JhbW1hciAuLi4uICAgIDU=
+ICAgMy4gTUlNRSBIZWFkZXIgRmllbGRzIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDg=
+ICAgNC4gTUlNRS1WZXJzaW9uIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDg=
+ICAgNS4gQ29udGVudC1UeXBlIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMTA=
+ICAgNi4gQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uICAgMTQ=
+ICAgNy4gQ29udGVudC1JRCBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjY=
+ICAgOC4gQ29udGVudC1EZXNjcmlwdGlvbiBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgOS4gQWRkaXRpb25hbCBNSU1FIEhlYWRlciBGaWVsZHMgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTAuIFN1bW1hcnkgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTEuIFNlY3VyaXR5IENvbnNpZGVyYXRpb25zIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTIuIEF1dGhvcnMnIEFkZHJlc3NlcyAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjg=
+ICAgQS4gQ29sbGVjdGVkIEdyYW1tYXIgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjk=
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgIFtQYWdlIDdd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+My4gIE1JTUUgSGVhZGVyIEZpZWxkcw==
+
+ICAgTUlNRSBkZWZpbmVzIGEgbnVtYmVyIG9mIG5ldyBSRkMgODIyIGhlYWRlciBmaWVsZHMgdGhhdCBhcmUgdXNlZCB0bw==
+ICAgZGVzY3JpYmUgdGhlIGNvbnRlbnQgb2YgYSBNSU1FIGVudGl0eS4gIFRoZXNlIGhlYWRlciBmaWVsZHMgb2NjdXIgaW4=
+ICAgYXQgbGVhc3QgdHdvIGNvbnRleHRzOg==
+
+ICAgICgxKSAgIEFzIHBhcnQgb2YgYSByZWd1bGFyIFJGQyA4MjIgbWVzc2FnZSBoZWFkZXIu
+
+ICAgICgyKSAgIEluIGEgTUlNRSBib2R5IHBhcnQgaGVhZGVyIHdpdGhpbiBhIG11bHRpcGFydA==
+ICAgICAgICAgIGNvbnN0cnVjdC4=
+
+ICAgVGhlIGZvcm1hbCBkZWZpbml0aW9uIG9mIHRoZXNlIGhlYWRlciBmaWVsZHMgaXMgYXMgZm9sbG93czo=
+
+ICAgICBNSU1FLW1lc3NhZ2UtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHM=
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uIENSTEY=
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9yZWQu
+
+ICAgICBNSU1FLXBhcnQtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+ICAgICAgICAgICAgICAgICAgICAgICAgICBbIGZpZWxkcyBd
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IEFueSBmaWVsZCBub3QgYmVnaW5uaW5nIHdpdGg=
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7ICJjb250ZW50LSIgY2FuIGhhdmUgbm8gZGVmaW5lZA==
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IG1lYW5pbmcgYW5kIG1heSBiZSBpZ25vcmVkLg==
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9yZWQu
+
+ICAgVGhlIHN5bnRheCBvZiB0aGUgdmFyaW91cyBzcGVjaWZpYyBNSU1FIGhlYWRlciBmaWVsZHMgd2lsbCBiZQ==
+ICAgZGVzY3JpYmVkIGluIHRoZSBmb2xsb3dpbmcgc2VjdGlvbnMu
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgW1BhZ2UgMTFd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+NS4xLiAgU3ludGF4IG9mIHRoZSBDb250ZW50LVR5cGUgSGVhZGVyIEZpZWxk
+
+ICAgSW4gdGhlIEF1Z21lbnRlZCBCTkYgbm90YXRpb24gb2YgUkZDIDgyMiwgYSBDb250ZW50LVR5cGUgaGVhZGVyIGZpZWxk
+ICAgdmFsdWUgaXMgZGVmaW5lZCBhcyBmb2xsb3dzOg==
+
+ICAgICBjb250ZW50IDo9ICJDb250ZW50LVR5cGUiICI6IiB0eXBlICIvIiBzdWJ0eXBl
+ICAgICAgICAgICAgICAgICooIjsiIHBhcmFtZXRlcik=
+ICAgICAgICAgICAgICAgIDsgTWF0Y2hpbmcgb2YgbWVkaWEgdHlwZSBhbmQgc3VidHlwZQ==
+ICAgICAgICAgICAgICAgIDsgaXMgQUxXQVlTIGNhc2UtaW5zZW5zaXRpdmUu
+
+ICAgICB0eXBlIDo9IGRpc2NyZXRlLXR5cGUgLyBjb21wb3NpdGUtdHlwZQ==
+
+ICAgICBkaXNjcmV0ZS10eXBlIDo9ICJ0ZXh0IiAvICJpbWFnZSIgLyAiYXVkaW8iIC8gInZpZGVvIiAv
+ICAgICAgICAgICAgICAgICAgICAgICJhcHBsaWNhdGlvbiIgLyBleHRlbnNpb24tdG9rZW4=
+
+ICAgICBjb21wb3NpdGUtdHlwZSA6PSAibWVzc2FnZSIgLyAibXVsdGlwYXJ0IiAvIGV4dGVuc2lvbi10b2tlbg==
+
+ICAgICBleHRlbnNpb24tdG9rZW4gOj0gaWV0Zi10b2tlbiAvIHgtdG9rZW4=
+
+ICAgICBpZXRmLXRva2VuIDo9IDxBbiBleHRlbnNpb24gdG9rZW4gZGVmaW5lZCBieSBh
+ICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZHMtdHJhY2sgUkZDIGFuZCByZWdpc3RlcmVk
+ICAgICAgICAgICAgICAgICAgICB3aXRoIElBTkEuPg==
+
+ICAgICB4LXRva2VuIDo9IDxUaGUgdHdvIGNoYXJhY3RlcnMgIlgtIiBvciAieC0iIGZvbGxvd2VkLCB3aXRo
+ICAgICAgICAgICAgICAgICBubyBpbnRlcnZlbmluZyB3aGl0ZSBzcGFjZSwgYnkgYW55IHRva2VuPg==
+
+ICAgICBzdWJ0eXBlIDo9IGV4dGVuc2lvbi10b2tlbiAvIGlhbmEtdG9rZW4=
+
+ICAgICBpYW5hLXRva2VuIDo9IDxBIHB1YmxpY2x5LWRlZmluZWQgZXh0ZW5zaW9uIHRva2VuLiBUb2tlbnM=
+ICAgICAgICAgICAgICAgICAgICBvZiB0aGlzIGZvcm0gbXVzdCBiZSByZWdpc3RlcmVkIHdpdGggSUFOQQ==
+ICAgICAgICAgICAgICAgICAgICBhcyBzcGVjaWZpZWQgaW4gUkZDIDIwNDguPg==
+
+ICAgICBwYXJhbWV0ZXIgOj0gYXR0cmlidXRlICI9IiB2YWx1ZQ==
+
+ICAgICBhdHRyaWJ1dGUgOj0gdG9rZW4=
+ICAgICAgICAgICAgICAgICAgOyBNYXRjaGluZyBvZiBhdHRyaWJ1dGVz
+ICAgICAgICAgICAgICAgICAgOyBpcyBBTFdBWVMgY2FzZS1pbnNlbnNpdGl2ZS4=
+
+ICAgICB2YWx1ZSA6PSB0b2tlbiAvIHF1b3RlZC1zdHJpbmc=
+
+ICAgICB0b2tlbiA6PSAxKjxhbnkgKFVTLUFTQ0lJKSBDSEFSIGV4Y2VwdCBTUEFDRSwgQ1RMcyw=
+ICAgICAgICAgICAgICAgICBvciB0c3BlY2lhbHM+
+
+ICAgICB0c3BlY2lhbHMgOj0gICIoIiAvICIpIiAvICI8IiAvICI+IiAvICJAIiAv
+ICAgICAgICAgICAgICAgICAgICIsIiAvICI7IiAvICI6IiAvICJcIiAvIDwiPg==
+ICAgICAgICAgICAgICAgICAgICIvIiAvICJbIiAvICJdIiAvICI/IiAvICI9Ig==
+ICAgICAgICAgICAgICAgICAgIDsgTXVzdCBiZSBpbiBxdW90ZWQtc3RyaW5nLA==
+ICAgICAgICAgICAgICAgICAgIDsgdG8gdXNlIHdpdGhpbiBwYXJhbWV0ZXIgdmFsdWVz
+
+ICAgICBkZXNjcmlwdGlvbiA6PSAiQ29udGVudC1EZXNjcmlwdGlvbiIgIjoiICp0ZXh0
+
+ICAgICBlbmNvZGluZyA6PSAiQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyIgIjoiIG1lY2hhbmlzbQ==
+
+ICAgICBlbnRpdHktaGVhZGVycyA6PSBbIGNvbnRlbnQgQ1JMRiBd
+ICAgICAgICAgICAgICAgICAgICBbIGVuY29kaW5nIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICBbIGlkIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICBbIGRlc2NyaXB0aW9uIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICAqKCBNSU1FLWV4dGVuc2lvbi1maWVsZCBDUkxGICk=
+
+ICAgICBoZXgtb2N0ZXQgOj0gIj0iIDIoRElHSVQgLyAiQSIgLyAiQiIgLyAiQyIgLyAiRCIgLyAiRSIgLyAiRiIp
+ICAgICAgICAgICAgICAgOyBPY3RldCBtdXN0IGJlIHVzZWQgZm9yIGNoYXJhY3RlcnMgPiAxMjcsID0s
+ICAgICAgICAgICAgICAgOyBTUEFDRXMgb3IgVEFCcyBhdCB0aGUgZW5kcyBvZiBsaW5lcywgYW5kIGlz
+ICAgICAgICAgICAgICAgOyByZWNvbW1lbmRlZCBmb3IgYW55IGNoYXJhY3RlciBub3QgbGlzdGVkIGlu
+ICAgICAgICAgICAgICAgOyBSRkMgMjA0OSBhcyAibWFpbC1zYWZlIi4=
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+ICAgICAgICAgIG11c3QgYmUgdXNlZC4gIEFuIGVxdWFsIHNpZ24gYXMgdGhlIGxhc3QgY2hhcmFjdGVyIG9uIGE=
+ICAgICAgICAgIGVuY29kZWQgbGluZSBpbmRpY2F0ZXMgc3VjaCBhIG5vbi1zaWduaWZpY2FudCAoInNvZnQiKQ==
+ICAgICAgICAgIGxpbmUgYnJlYWsgaW4gdGhlIGVuY29kZWQgdGV4dC4=
+
+ICAgVGh1cyBpZiB0aGUgInJhdyIgZm9ybSBvZiB0aGUgbGluZSBpcyBhIHNpbmdsZSB1bmVuY29kZWQgbGluZSB0aGF0
+ICAgc2F5czo=
+
+ICAgICBOb3cncyB0aGUgdGltZSBmb3IgYWxsIGZvbGsgdG8gY29tZSB0byB0aGUgYWlkIG9mIHRoZWlyIGNvdW50cnku
+
+ICAgVGhpcyBjYW4gYmUgcmVwcmVzZW50ZWQsIGluIHRoZSBRdW90ZWQtUHJpbnRhYmxlIGVuY29kaW5nLCBhczo=
+
+ICAgICBOb3cncyB0aGUgdGltZSA9
+ICAgICBmb3IgYWxsIGZvbGsgdG8gY29tZT0=
+ICAgICAgdG8gdGhlIGFpZCBvZiB0aGVpciBjb3VudHJ5Lg==
+
+ICAgU2luY2UgdGhlIGh5cGhlbiBjaGFyYWN0ZXIgKCItIikgbWF5IGJlIHJlcHJlc2VudGVkIGFzIGl0c2VsZiBpbiB0aGU=
+ICAgUXVvdGVkLVByaW50YWJsZSBlbmNvZGluZywgY2FyZSBtdXN0IGJlIHRha2VuLCB3aGVuIGVuY2Fwc3VsYXRpbmcgYQ==
+ICAgcXVvdGVkLXByaW50YWJsZSBlbmNvZGVkIGJvZHkgaW5zaWRlIG9uZSBvciBtb3JlIG11bHRpcGFydCBlbnRpdGllcyw=
+ICAgdG8gZW5zdXJlIHRoYXQgdGhlIGJvdW5kYXJ5IGRlbGltaXRlciBkb2VzIG5vdCBhcHBlYXIgYW55d2hlcmUgaW4gdGhl
+ICAgZW5jb2RlZCBib2R5LiAgKEEgZ29vZCBzdHJhdGVneSBpcyB0byBjaG9vc2UgYSBib3VuZGFyeSB0aGF0IGluY2x1ZGVz
+ICAgYSBjaGFyYWN0ZXIgc2VxdWVuY2Ugc3VjaCBhcyAiPV8iIHdoaWNoIGNhbiBuZXZlciBhcHBlYXIgaW4gYQ==
+ICAgcXVvdGVkLXByaW50YWJsZSBib2R5LiAgU2VlIHRoZSBkZWZpbml0aW9uIG9mIG11bHRpcGFydCBtZXNzYWdlcyBpbg==
+ICAgUkZDIDIwNDYuKQ==
+
+ICAgICAhIiMkQFtcXV5ge3x9fiU=
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgW1BhZ2UgMjRd
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+
+ICAgICAgICAgICAgICAgICAgICBUYWJsZSAxOiBUaGUgQmFzZTY0IEFscGhhYmV0
+
+ICAgICBWYWx1ZSBFbmNvZGluZyAgVmFsdWUgRW5jb2RpbmcgIFZhbHVlIEVuY29kaW5nICBWYWx1ZSBFbmNvZGluZw==
+ICAgICAgICAgMCBBICAgICAgICAgICAgMTcgUiAgICAgICAgICAgIDM0IGkgICAgICAgICAgICA1MSB6
+ICAgICAgICAgMSBCICAgICAgICAgICAgMTggUyAgICAgICAgICAgIDM1IGogICAgICAgICAgICA1MiAw
+ICAgICAgICAgMiBDICAgICAgICAgICAgMTkgVCAgICAgICAgICAgIDM2IGsgICAgICAgICAgICA1MyAx
+ICAgICAgICAgMyBEICAgICAgICAgICAgMjAgVSAgICAgICAgICAgIDM3IGwgICAgICAgICAgICA1NCAy
+ICAgICAgICAgNCBFICAgICAgICAgICAgMjEgViAgICAgICAgICAgIDM4IG0gICAgICAgICAgICA1NSAz
+ICAgICAgICAgNSBGICAgICAgICAgICAgMjIgVyAgICAgICAgICAgIDM5IG4gICAgICAgICAgICA1NiA0
+ICAgICAgICAgNiBHICAgICAgICAgICAgMjMgWCAgICAgICAgICAgIDQwIG8gICAgICAgICAgICA1NyA1
+ICAgICAgICAgNyBIICAgICAgICAgICAgMjQgWSAgICAgICAgICAgIDQxIHAgICAgICAgICAgICA1OCA2
+ICAgICAgICAgOCBJICAgICAgICAgICAgMjUgWiAgICAgICAgICAgIDQyIHEgICAgICAgICAgICA1OSA3
+ICAgICAgICAgOSBKICAgICAgICAgICAgMjYgYSAgICAgICAgICAgIDQzIHIgICAgICAgICAgICA2MCA4
+ICAgICAgICAxMCBLICAgICAgICAgICAgMjcgYiAgICAgICAgICAgIDQ0IHMgICAgICAgICAgICA2MSA5
+ICAgICAgICAxMSBMICAgICAgICAgICAgMjggYyAgICAgICAgICAgIDQ1IHQgICAgICAgICAgICA2MiAr
+ICAgICAgICAxMiBNICAgICAgICAgICAgMjkgZCAgICAgICAgICAgIDQ2IHUgICAgICAgICAgICA2MyAv
+ICAgICAgICAxMyBOICAgICAgICAgICAgMzAgZSAgICAgICAgICAgIDQ3IHY=
+ICAgICAgICAxNCBPICAgICAgICAgICAgMzEgZiAgICAgICAgICAgIDQ4IHcgICAgICAgICAocGFkKSA9
+ICAgICAgICAxNSBQICAgICAgICAgICAgMzIgZyAgICAgICAgICAgIDQ5IHg=
+ICAgICAgICAxNiBRICAgICAgICAgICAgMzMgaCAgICAgICAgICAgIDUwIHk=
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/mimeEncode.txt Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,391 @@
+VGhpcyB0ZXN0IGRhdGEgaXMgcGFydCBvZiByZmMyMDQ1IHdoaWNoIGluY2x1ZGVzIGFsbCBjaGFy
+YWN0ZXJzIGF+eiBBflosIDB+OSBhbmQgYWxsIHN5bWJvbHMs
+
+SXQgaXMgdXNlZCB0byB0ZXN0IGphdmEudXRpbC5CYXNlNjQuRW5jb2RlciwgYW5kIHdpbGwgYmUg
+ZW5jb2RlZCBieSBvcmcuYXBhY2hlLmNvbW1vbnMuY29kZWMuYmluYXJ5LkJhc2U2NC5qYXZh
+
+dG8gdGVzdCBqYXZhLnV0aWwuQmFzZTY0LkRlY29kZXI7
+
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAg
+ICAgICAgIFtQYWdlIDFd
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAg
+ICBOb3ZlbWJlciAxOTk2
+
+
+ICAgVGhlc2UgZG9jdW1lbnRzIGFyZSByZXZpc2lvbnMgb2YgUkZDcyAxNTIxLCAxNTIyLCBhbmQg
+MTU5MCwgd2hpY2g=
+
+ICAgdGhlbXNlbHZlcyB3ZXJlIHJldmlzaW9ucyBvZiBSRkNzIDEzNDEgYW5kIDEzNDIuICBBbiBh
+cHBlbmRpeCBpbiBSRkM=
+
+ICAgMjA0OSBkZXNjcmliZXMgZGlmZmVyZW5jZXMgYW5kIGNoYW5nZXMgZnJvbSBwcmV2aW91cyB2
+ZXJzaW9ucy4=
+
+
+VGFibGUgb2YgQ29udGVudHM=
+
+
+ICAgMS4gSW50cm9kdWN0aW9uIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgIDM=
+
+ICAgMi4gRGVmaW5pdGlvbnMsIENvbnZlbnRpb25zLCBhbmQgR2VuZXJpYyBCTkYgR3JhbW1hciAu
+Li4uICAgIDU=
+
+ICAgMy4gTUlNRSBIZWFkZXIgRmllbGRzIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgIDg=
+
+ICAgNC4gTUlNRS1WZXJzaW9uIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgIDg=
+
+ICAgNS4gQ29udGVudC1UeXBlIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMTA=
+
+ICAgNi4gQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4u
+Li4uICAgMTQ=
+
+ICAgNy4gQ29udGVudC1JRCBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjY=
+
+ICAgOC4gQ29udGVudC1EZXNjcmlwdGlvbiBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjc=
+
+ICAgOS4gQWRkaXRpb25hbCBNSU1FIEhlYWRlciBGaWVsZHMgLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjc=
+
+ICAgMTAuIFN1bW1hcnkgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjc=
+
+ICAgMTEuIFNlY3VyaXR5IENvbnNpZGVyYXRpb25zIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjc=
+
+ICAgMTIuIEF1dGhvcnMnIEFkZHJlc3NlcyAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjg=
+
+ICAgQS4gQ29sbGVjdGVkIEdyYW1tYXIgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
+Li4uICAgMjk=
+
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAg
+ICAgICAgIFtQYWdlIDdd
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAg
+ICBOb3ZlbWJlciAxOTk2
+
+
+My4gIE1JTUUgSGVhZGVyIEZpZWxkcw==
+
+
+ICAgTUlNRSBkZWZpbmVzIGEgbnVtYmVyIG9mIG5ldyBSRkMgODIyIGhlYWRlciBmaWVsZHMgdGhh
+dCBhcmUgdXNlZCB0bw==
+
+ICAgZGVzY3JpYmUgdGhlIGNvbnRlbnQgb2YgYSBNSU1FIGVudGl0eS4gIFRoZXNlIGhlYWRlciBm
+aWVsZHMgb2NjdXIgaW4=
+
+ICAgYXQgbGVhc3QgdHdvIGNvbnRleHRzOg==
+
+
+ICAgICgxKSAgIEFzIHBhcnQgb2YgYSByZWd1bGFyIFJGQyA4MjIgbWVzc2FnZSBoZWFkZXIu
+
+
+ICAgICgyKSAgIEluIGEgTUlNRSBib2R5IHBhcnQgaGVhZGVyIHdpdGhpbiBhIG11bHRpcGFydA==
+
+ICAgICAgICAgIGNvbnN0cnVjdC4=
+
+
+ICAgVGhlIGZvcm1hbCBkZWZpbml0aW9uIG9mIHRoZXNlIGhlYWRlciBmaWVsZHMgaXMgYXMgZm9s
+bG93czo=
+
+
+ICAgICBNSU1FLW1lc3NhZ2UtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHM=
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uIENSTEY=
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9y
+ZWQu
+
+
+ICAgICBNSU1FLXBhcnQtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICBbIGZpZWxkcyBd
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IEFueSBmaWVsZCBub3QgYmVnaW5uaW5nIHdpdGg=
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7ICJjb250ZW50LSIgY2FuIGhhdmUgbm8gZGVmaW5l
+ZA==
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IG1lYW5pbmcgYW5kIG1heSBiZSBpZ25vcmVkLg==
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9yZWQu
+
+
+ICAgVGhlIHN5bnRheCBvZiB0aGUgdmFyaW91cyBzcGVjaWZpYyBNSU1FIGhlYWRlciBmaWVsZHMg
+d2lsbCBiZQ==
+
+ICAgZGVzY3JpYmVkIGluIHRoZSBmb2xsb3dpbmcgc2VjdGlvbnMu
+
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAg
+ICAgICAgW1BhZ2UgMTFd
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAg
+ICBOb3ZlbWJlciAxOTk2
+
+
+NS4xLiAgU3ludGF4IG9mIHRoZSBDb250ZW50LVR5cGUgSGVhZGVyIEZpZWxk
+
+
+ICAgSW4gdGhlIEF1Z21lbnRlZCBCTkYgbm90YXRpb24gb2YgUkZDIDgyMiwgYSBDb250ZW50LVR5
+cGUgaGVhZGVyIGZpZWxk
+
+ICAgdmFsdWUgaXMgZGVmaW5lZCBhcyBmb2xsb3dzOg==
+
+
+ICAgICBjb250ZW50IDo9ICJDb250ZW50LVR5cGUiICI6IiB0eXBlICIvIiBzdWJ0eXBl
+
+ICAgICAgICAgICAgICAgICooIjsiIHBhcmFtZXRlcik=
+
+ICAgICAgICAgICAgICAgIDsgTWF0Y2hpbmcgb2YgbWVkaWEgdHlwZSBhbmQgc3VidHlwZQ==
+
+ICAgICAgICAgICAgICAgIDsgaXMgQUxXQVlTIGNhc2UtaW5zZW5zaXRpdmUu
+
+
+ICAgICB0eXBlIDo9IGRpc2NyZXRlLXR5cGUgLyBjb21wb3NpdGUtdHlwZQ==
+
+
+ICAgICBkaXNjcmV0ZS10eXBlIDo9ICJ0ZXh0IiAvICJpbWFnZSIgLyAiYXVkaW8iIC8gInZpZGVv
+IiAv
+
+ICAgICAgICAgICAgICAgICAgICAgICJhcHBsaWNhdGlvbiIgLyBleHRlbnNpb24tdG9rZW4=
+
+
+ICAgICBjb21wb3NpdGUtdHlwZSA6PSAibWVzc2FnZSIgLyAibXVsdGlwYXJ0IiAvIGV4dGVuc2lv
+bi10b2tlbg==
+
+
+ICAgICBleHRlbnNpb24tdG9rZW4gOj0gaWV0Zi10b2tlbiAvIHgtdG9rZW4=
+
+
+ICAgICBpZXRmLXRva2VuIDo9IDxBbiBleHRlbnNpb24gdG9rZW4gZGVmaW5lZCBieSBh
+
+ICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZHMtdHJhY2sgUkZDIGFuZCByZWdpc3RlcmVk
+
+ICAgICAgICAgICAgICAgICAgICB3aXRoIElBTkEuPg==
+
+
+ICAgICB4LXRva2VuIDo9IDxUaGUgdHdvIGNoYXJhY3RlcnMgIlgtIiBvciAieC0iIGZvbGxvd2Vk
+LCB3aXRo
+
+ICAgICAgICAgICAgICAgICBubyBpbnRlcnZlbmluZyB3aGl0ZSBzcGFjZSwgYnkgYW55IHRva2Vu
+Pg==
+
+
+ICAgICBzdWJ0eXBlIDo9IGV4dGVuc2lvbi10b2tlbiAvIGlhbmEtdG9rZW4=
+
+
+ICAgICBpYW5hLXRva2VuIDo9IDxBIHB1YmxpY2x5LWRlZmluZWQgZXh0ZW5zaW9uIHRva2VuLiBU
+b2tlbnM=
+
+ICAgICAgICAgICAgICAgICAgICBvZiB0aGlzIGZvcm0gbXVzdCBiZSByZWdpc3RlcmVkIHdpdGgg
+SUFOQQ==
+
+ICAgICAgICAgICAgICAgICAgICBhcyBzcGVjaWZpZWQgaW4gUkZDIDIwNDguPg==
+
+
+ICAgICBwYXJhbWV0ZXIgOj0gYXR0cmlidXRlICI9IiB2YWx1ZQ==
+
+
+ICAgICBhdHRyaWJ1dGUgOj0gdG9rZW4=
+
+ICAgICAgICAgICAgICAgICAgOyBNYXRjaGluZyBvZiBhdHRyaWJ1dGVz
+
+ICAgICAgICAgICAgICAgICAgOyBpcyBBTFdBWVMgY2FzZS1pbnNlbnNpdGl2ZS4=
+
+
+ICAgICB2YWx1ZSA6PSB0b2tlbiAvIHF1b3RlZC1zdHJpbmc=
+
+
+ICAgICB0b2tlbiA6PSAxKjxhbnkgKFVTLUFTQ0lJKSBDSEFSIGV4Y2VwdCBTUEFDRSwgQ1RMcyw=
+
+ICAgICAgICAgICAgICAgICBvciB0c3BlY2lhbHM+
+
+
+ICAgICB0c3BlY2lhbHMgOj0gICIoIiAvICIpIiAvICI8IiAvICI+IiAvICJAIiAv
+
+ICAgICAgICAgICAgICAgICAgICIsIiAvICI7IiAvICI6IiAvICJcIiAvIDwiPg==
+
+ICAgICAgICAgICAgICAgICAgICIvIiAvICJbIiAvICJdIiAvICI/IiAvICI9Ig==
+
+ICAgICAgICAgICAgICAgICAgIDsgTXVzdCBiZSBpbiBxdW90ZWQtc3RyaW5nLA==
+
+ICAgICAgICAgICAgICAgICAgIDsgdG8gdXNlIHdpdGhpbiBwYXJhbWV0ZXIgdmFsdWVz
+
+
+ICAgICBkZXNjcmlwdGlvbiA6PSAiQ29udGVudC1EZXNjcmlwdGlvbiIgIjoiICp0ZXh0
+
+
+ICAgICBlbmNvZGluZyA6PSAiQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyIgIjoiIG1lY2hhbmlz
+bQ==
+
+
+ICAgICBlbnRpdHktaGVhZGVycyA6PSBbIGNvbnRlbnQgQ1JMRiBd
+
+ICAgICAgICAgICAgICAgICAgICBbIGVuY29kaW5nIENSTEYgXQ==
+
+ICAgICAgICAgICAgICAgICAgICBbIGlkIENSTEYgXQ==
+
+ICAgICAgICAgICAgICAgICAgICBbIGRlc2NyaXB0aW9uIENSTEYgXQ==
+
+ICAgICAgICAgICAgICAgICAgICAqKCBNSU1FLWV4dGVuc2lvbi1maWVsZCBDUkxGICk=
+
+
+ICAgICBoZXgtb2N0ZXQgOj0gIj0iIDIoRElHSVQgLyAiQSIgLyAiQiIgLyAiQyIgLyAiRCIgLyAi
+RSIgLyAiRiIp
+
+ICAgICAgICAgICAgICAgOyBPY3RldCBtdXN0IGJlIHVzZWQgZm9yIGNoYXJhY3RlcnMgPiAxMjcs
+ID0s
+
+ICAgICAgICAgICAgICAgOyBTUEFDRXMgb3IgVEFCcyBhdCB0aGUgZW5kcyBvZiBsaW5lcywgYW5k
+IGlz
+
+ICAgICAgICAgICAgICAgOyByZWNvbW1lbmRlZCBmb3IgYW55IGNoYXJhY3RlciBub3QgbGlzdGVk
+IGlu
+
+ICAgICAgICAgICAgICAgOyBSRkMgMjA0OSBhcyAibWFpbC1zYWZlIi4=
+
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAg
+ICBOb3ZlbWJlciAxOTk2
+
+
+ICAgICAgICAgIG11c3QgYmUgdXNlZC4gIEFuIGVxdWFsIHNpZ24gYXMgdGhlIGxhc3QgY2hhcmFj
+dGVyIG9uIGE=
+
+ICAgICAgICAgIGVuY29kZWQgbGluZSBpbmRpY2F0ZXMgc3VjaCBhIG5vbi1zaWduaWZpY2FudCAo
+InNvZnQiKQ==
+
+ICAgICAgICAgIGxpbmUgYnJlYWsgaW4gdGhlIGVuY29kZWQgdGV4dC4=
+
+
+ICAgVGh1cyBpZiB0aGUgInJhdyIgZm9ybSBvZiB0aGUgbGluZSBpcyBhIHNpbmdsZSB1bmVuY29k
+ZWQgbGluZSB0aGF0
+
+ICAgc2F5czo=
+
+
+ICAgICBOb3cncyB0aGUgdGltZSBmb3IgYWxsIGZvbGsgdG8gY29tZSB0byB0aGUgYWlkIG9mIHRo
+ZWlyIGNvdW50cnku
+
+
+ICAgVGhpcyBjYW4gYmUgcmVwcmVzZW50ZWQsIGluIHRoZSBRdW90ZWQtUHJpbnRhYmxlIGVuY29k
+aW5nLCBhczo=
+
+
+ICAgICBOb3cncyB0aGUgdGltZSA9
+
+ICAgICBmb3IgYWxsIGZvbGsgdG8gY29tZT0=
+
+ICAgICAgdG8gdGhlIGFpZCBvZiB0aGVpciBjb3VudHJ5Lg==
+
+
+ICAgU2luY2UgdGhlIGh5cGhlbiBjaGFyYWN0ZXIgKCItIikgbWF5IGJlIHJlcHJlc2VudGVkIGFz
+IGl0c2VsZiBpbiB0aGU=
+
+ICAgUXVvdGVkLVByaW50YWJsZSBlbmNvZGluZywgY2FyZSBtdXN0IGJlIHRha2VuLCB3aGVuIGVu
+Y2Fwc3VsYXRpbmcgYQ==
+
+ICAgcXVvdGVkLXByaW50YWJsZSBlbmNvZGVkIGJvZHkgaW5zaWRlIG9uZSBvciBtb3JlIG11bHRp
+cGFydCBlbnRpdGllcyw=
+
+ICAgdG8gZW5zdXJlIHRoYXQgdGhlIGJvdW5kYXJ5IGRlbGltaXRlciBkb2VzIG5vdCBhcHBlYXIg
+YW55d2hlcmUgaW4gdGhl
+
+ICAgZW5jb2RlZCBib2R5LiAgKEEgZ29vZCBzdHJhdGVneSBpcyB0byBjaG9vc2UgYSBib3VuZGFy
+eSB0aGF0IGluY2x1ZGVz
+
+ICAgYSBjaGFyYWN0ZXIgc2VxdWVuY2Ugc3VjaCBhcyAiPV8iIHdoaWNoIGNhbiBuZXZlciBhcHBl
+YXIgaW4gYQ==
+
+ICAgcXVvdGVkLXByaW50YWJsZSBib2R5LiAgU2VlIHRoZSBkZWZpbml0aW9uIG9mIG11bHRpcGFy
+dCBtZXNzYWdlcyBpbg==
+
+ICAgUkZDIDIwNDYuKQ==
+
+
+ICAgICAhIiMkQFtcXV5ge3x9fiU=
+
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAg
+ICAgICAgW1BhZ2UgMjRd
+
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAg
+ICBOb3ZlbWJlciAxOTk2
+
+
+
+ICAgICAgICAgICAgICAgICAgICBUYWJsZSAxOiBUaGUgQmFzZTY0IEFscGhhYmV0
+
+
+ICAgICBWYWx1ZSBFbmNvZGluZyAgVmFsdWUgRW5jb2RpbmcgIFZhbHVlIEVuY29kaW5nICBWYWx1
+ZSBFbmNvZGluZw==
+
+ICAgICAgICAgMCBBICAgICAgICAgICAgMTcgUiAgICAgICAgICAgIDM0IGkgICAgICAgICAgICA1
+MSB6
+
+ICAgICAgICAgMSBCICAgICAgICAgICAgMTggUyAgICAgICAgICAgIDM1IGogICAgICAgICAgICA1
+MiAw
+
+ICAgICAgICAgMiBDICAgICAgICAgICAgMTkgVCAgICAgICAgICAgIDM2IGsgICAgICAgICAgICA1
+MyAx
+
+ICAgICAgICAgMyBEICAgICAgICAgICAgMjAgVSAgICAgICAgICAgIDM3IGwgICAgICAgICAgICA1
+NCAy
+
+ICAgICAgICAgNCBFICAgICAgICAgICAgMjEgViAgICAgICAgICAgIDM4IG0gICAgICAgICAgICA1
+NSAz
+
+ICAgICAgICAgNSBGICAgICAgICAgICAgMjIgVyAgICAgICAgICAgIDM5IG4gICAgICAgICAgICA1
+NiA0
+
+ICAgICAgICAgNiBHICAgICAgICAgICAgMjMgWCAgICAgICAgICAgIDQwIG8gICAgICAgICAgICA1
+NyA1
+
+ICAgICAgICAgNyBIICAgICAgICAgICAgMjQgWSAgICAgICAgICAgIDQxIHAgICAgICAgICAgICA1
+OCA2
+
+ICAgICAgICAgOCBJICAgICAgICAgICAgMjUgWiAgICAgICAgICAgIDQyIHEgICAgICAgICAgICA1
+OSA3
+
+ICAgICAgICAgOSBKICAgICAgICAgICAgMjYgYSAgICAgICAgICAgIDQzIHIgICAgICAgICAgICA2
+MCA4
+
+ICAgICAgICAxMCBLICAgICAgICAgICAgMjcgYiAgICAgICAgICAgIDQ0IHMgICAgICAgICAgICA2
+MSA5
+
+ICAgICAgICAxMSBMICAgICAgICAgICAgMjggYyAgICAgICAgICAgIDQ1IHQgICAgICAgICAgICA2
+MiAr
+
+ICAgICAgICAxMiBNICAgICAgICAgICAgMjkgZCAgICAgICAgICAgIDQ2IHUgICAgICAgICAgICA2
+MyAv
+
+ICAgICAgICAxMyBOICAgICAgICAgICAgMzAgZSAgICAgICAgICAgIDQ3IHY=
+
+ICAgICAgICAxNCBPICAgICAgICAgICAgMzEgZiAgICAgICAgICAgIDQ4IHcgICAgICAgICAocGFk
+KSA9
+
+ICAgICAgICAxNSBQICAgICAgICAgICAgMzIgZyAgICAgICAgICAgIDQ5IHg=
+
+ICAgICAgICAxNiBRICAgICAgICAgICAgMzMgaCAgICAgICAgICAgIDUwIHk=
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/plain.txt Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,183 @@
+This test data is part of rfc2045 which includes all characters a~z A~Z, 0~9 and all symbols,
+It is used to test java.util.Base64.Encoder, and will be encoded by org.apache.commons.codec.binary.Base64.java
+to test java.util.Base64.Decoder;
+
+Freed & Borenstein Standards Track [Page 1]
+RFC 2045 Internet Message Bodies November 1996
+
+ These documents are revisions of RFCs 1521, 1522, and 1590, which
+ themselves were revisions of RFCs 1341 and 1342. An appendix in RFC
+ 2049 describes differences and changes from previous versions.
+
+Table of Contents
+
+ 1. Introduction ......................................... 3
+ 2. Definitions, Conventions, and Generic BNF Grammar .... 5
+ 3. MIME Header Fields ................................... 8
+ 4. MIME-Version Header Field ............................ 8
+ 5. Content-Type Header Field ............................ 10
+ 6. Content-Transfer-Encoding Header Field ............... 14
+ 7. Content-ID Header Field .............................. 26
+ 8. Content-Description Header Field ..................... 27
+ 9. Additional MIME Header Fields ........................ 27
+ 10. Summary ............................................. 27
+ 11. Security Considerations ............................. 27
+ 12. Authors' Addresses .................................. 28
+ A. Collected Grammar .................................... 29
+
+Freed & Borenstein Standards Track [Page 7]
+RFC 2045 Internet Message Bodies November 1996
+
+3. MIME Header Fields
+
+ MIME defines a number of new RFC 822 header fields that are used to
+ describe the content of a MIME entity. These header fields occur in
+ at least two contexts:
+
+ (1) As part of a regular RFC 822 message header.
+
+ (2) In a MIME body part header within a multipart
+ construct.
+
+ The formal definition of these header fields is as follows:
+
+ MIME-message-headers := entity-headers
+ fields
+ version CRLF
+ ; The ordering of the header
+ ; fields implied by this BNF
+ ; definition should be ignored.
+
+ MIME-part-headers := entity-headers
+ [ fields ]
+ ; Any field not beginning with
+ ; "content-" can have no defined
+ ; meaning and may be ignored.
+ ; The ordering of the header
+ ; fields implied by this BNF
+ ; definition should be ignored.
+
+ The syntax of the various specific MIME header fields will be
+ described in the following sections.
+
+Freed & Borenstein Standards Track [Page 11]
+RFC 2045 Internet Message Bodies November 1996
+
+5.1. Syntax of the Content-Type Header Field
+
+ In the Augmented BNF notation of RFC 822, a Content-Type header field
+ value is defined as follows:
+
+ content := "Content-Type" ":" type "/" subtype
+ *(";" parameter)
+ ; Matching of media type and subtype
+ ; is ALWAYS case-insensitive.
+
+ type := discrete-type / composite-type
+
+ discrete-type := "text" / "image" / "audio" / "video" /
+ "application" / extension-token
+
+ composite-type := "message" / "multipart" / extension-token
+
+ extension-token := ietf-token / x-token
+
+ ietf-token := <An extension token defined by a
+ standards-track RFC and registered
+ with IANA.>
+
+ x-token := <The two characters "X-" or "x-" followed, with
+ no intervening white space, by any token>
+
+ subtype := extension-token / iana-token
+
+ iana-token := <A publicly-defined extension token. Tokens
+ of this form must be registered with IANA
+ as specified in RFC 2048.>
+
+ parameter := attribute "=" value
+
+ attribute := token
+ ; Matching of attributes
+ ; is ALWAYS case-insensitive.
+
+ value := token / quoted-string
+
+ token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
+ or tspecials>
+
+ tspecials := "(" / ")" / "<" / ">" / "@" /
+ "," / ";" / ":" / "\" / <">
+ "/" / "[" / "]" / "?" / "="
+ ; Must be in quoted-string,
+ ; to use within parameter values
+
+ description := "Content-Description" ":" *text
+
+ encoding := "Content-Transfer-Encoding" ":" mechanism
+
+ entity-headers := [ content CRLF ]
+ [ encoding CRLF ]
+ [ id CRLF ]
+ [ description CRLF ]
+ *( MIME-extension-field CRLF )
+
+ hex-octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
+ ; Octet must be used for characters > 127, =,
+ ; SPACEs or TABs at the ends of lines, and is
+ ; recommended for any character not listed in
+ ; RFC 2049 as "mail-safe".
+
+RFC 2045 Internet Message Bodies November 1996
+
+ must be used. An equal sign as the last character on a
+ encoded line indicates such a non-significant ("soft")
+ line break in the encoded text.
+
+ Thus if the "raw" form of the line is a single unencoded line that
+ says:
+
+ Now's the time for all folk to come to the aid of their country.
+
+ This can be represented, in the Quoted-Printable encoding, as:
+
+ Now's the time =
+ for all folk to come=
+ to the aid of their country.
+
+ Since the hyphen character ("-") may be represented as itself in the
+ Quoted-Printable encoding, care must be taken, when encapsulating a
+ quoted-printable encoded body inside one or more multipart entities,
+ to ensure that the boundary delimiter does not appear anywhere in the
+ encoded body. (A good strategy is to choose a boundary that includes
+ a character sequence such as "=_" which can never appear in a
+ quoted-printable body. See the definition of multipart messages in
+ RFC 2046.)
+
+ !"#$@[\]^`{|}~%
+
+Freed & Borenstein Standards Track [Page 24]
+
+RFC 2045 Internet Message Bodies November 1996
+
+
+ Table 1: The Base64 Alphabet
+
+ Value Encoding Value Encoding Value Encoding Value Encoding
+ 0 A 17 R 34 i 51 z
+ 1 B 18 S 35 j 52 0
+ 2 C 19 T 36 k 53 1
+ 3 D 20 U 37 l 54 2
+ 4 E 21 V 38 m 55 3
+ 5 F 22 W 39 n 56 4
+ 6 G 23 X 40 o 57 5
+ 7 H 24 Y 41 p 58 6
+ 8 I 25 Z 42 q 59 7
+ 9 J 26 a 43 r 60 8
+ 10 K 27 b 44 s 61 9
+ 11 L 28 c 45 t 62 +
+ 12 M 29 d 46 u 63 /
+ 13 N 30 e 47 v
+ 14 O 31 f 48 w (pad) =
+ 15 P 32 g 49 x
+ 16 Q 33 h 50 y
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Base64/urlEncode.txt Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,183 @@
+VGhpcyB0ZXN0IGRhdGEgaXMgcGFydCBvZiByZmMyMDQ1IHdoaWNoIGluY2x1ZGVzIGFsbCBjaGFyYWN0ZXJzIGF-eiBBflosIDB-OSBhbmQgYWxsIHN5bWJvbHMs
+SXQgaXMgdXNlZCB0byB0ZXN0IGphdmEudXRpbC5CYXNlNjQuRW5jb2RlciwgYW5kIHdpbGwgYmUgZW5jb2RlZCBieSBvcmcuYXBhY2hlLmNvbW1vbnMuY29kZWMuYmluYXJ5LkJhc2U2NC5qYXZh
+dG8gdGVzdCBqYXZhLnV0aWwuQmFzZTY0LkRlY29kZXI7
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgIFtQYWdlIDFd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+ICAgVGhlc2UgZG9jdW1lbnRzIGFyZSByZXZpc2lvbnMgb2YgUkZDcyAxNTIxLCAxNTIyLCBhbmQgMTU5MCwgd2hpY2g=
+ICAgdGhlbXNlbHZlcyB3ZXJlIHJldmlzaW9ucyBvZiBSRkNzIDEzNDEgYW5kIDEzNDIuICBBbiBhcHBlbmRpeCBpbiBSRkM=
+ICAgMjA0OSBkZXNjcmliZXMgZGlmZmVyZW5jZXMgYW5kIGNoYW5nZXMgZnJvbSBwcmV2aW91cyB2ZXJzaW9ucy4=
+
+VGFibGUgb2YgQ29udGVudHM=
+
+ICAgMS4gSW50cm9kdWN0aW9uIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDM=
+ICAgMi4gRGVmaW5pdGlvbnMsIENvbnZlbnRpb25zLCBhbmQgR2VuZXJpYyBCTkYgR3JhbW1hciAuLi4uICAgIDU=
+ICAgMy4gTUlNRSBIZWFkZXIgRmllbGRzIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDg=
+ICAgNC4gTUlNRS1WZXJzaW9uIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgIDg=
+ICAgNS4gQ29udGVudC1UeXBlIEhlYWRlciBGaWVsZCAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMTA=
+ICAgNi4gQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uICAgMTQ=
+ICAgNy4gQ29udGVudC1JRCBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjY=
+ICAgOC4gQ29udGVudC1EZXNjcmlwdGlvbiBIZWFkZXIgRmllbGQgLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgOS4gQWRkaXRpb25hbCBNSU1FIEhlYWRlciBGaWVsZHMgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTAuIFN1bW1hcnkgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTEuIFNlY3VyaXR5IENvbnNpZGVyYXRpb25zIC4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjc=
+ICAgMTIuIEF1dGhvcnMnIEFkZHJlc3NlcyAuLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjg=
+ICAgQS4gQ29sbGVjdGVkIEdyYW1tYXIgLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgMjk=
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgIFtQYWdlIDdd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+My4gIE1JTUUgSGVhZGVyIEZpZWxkcw==
+
+ICAgTUlNRSBkZWZpbmVzIGEgbnVtYmVyIG9mIG5ldyBSRkMgODIyIGhlYWRlciBmaWVsZHMgdGhhdCBhcmUgdXNlZCB0bw==
+ICAgZGVzY3JpYmUgdGhlIGNvbnRlbnQgb2YgYSBNSU1FIGVudGl0eS4gIFRoZXNlIGhlYWRlciBmaWVsZHMgb2NjdXIgaW4=
+ICAgYXQgbGVhc3QgdHdvIGNvbnRleHRzOg==
+
+ICAgICgxKSAgIEFzIHBhcnQgb2YgYSByZWd1bGFyIFJGQyA4MjIgbWVzc2FnZSBoZWFkZXIu
+
+ICAgICgyKSAgIEluIGEgTUlNRSBib2R5IHBhcnQgaGVhZGVyIHdpdGhpbiBhIG11bHRpcGFydA==
+ICAgICAgICAgIGNvbnN0cnVjdC4=
+
+ICAgVGhlIGZvcm1hbCBkZWZpbml0aW9uIG9mIHRoZXNlIGhlYWRlciBmaWVsZHMgaXMgYXMgZm9sbG93czo=
+
+ICAgICBNSU1FLW1lc3NhZ2UtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHM=
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uIENSTEY=
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9yZWQu
+
+ICAgICBNSU1FLXBhcnQtaGVhZGVycyA6PSBlbnRpdHktaGVhZGVycw==
+ICAgICAgICAgICAgICAgICAgICAgICAgICBbIGZpZWxkcyBd
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IEFueSBmaWVsZCBub3QgYmVnaW5uaW5nIHdpdGg=
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7ICJjb250ZW50LSIgY2FuIGhhdmUgbm8gZGVmaW5lZA==
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IG1lYW5pbmcgYW5kIG1heSBiZSBpZ25vcmVkLg==
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IFRoZSBvcmRlcmluZyBvZiB0aGUgaGVhZGVy
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGZpZWxkcyBpbXBsaWVkIGJ5IHRoaXMgQk5G
+ICAgICAgICAgICAgICAgICAgICAgICAgICA7IGRlZmluaXRpb24gc2hvdWxkIGJlIGlnbm9yZWQu
+
+ICAgVGhlIHN5bnRheCBvZiB0aGUgdmFyaW91cyBzcGVjaWZpYyBNSU1FIGhlYWRlciBmaWVsZHMgd2lsbCBiZQ==
+ICAgZGVzY3JpYmVkIGluIHRoZSBmb2xsb3dpbmcgc2VjdGlvbnMu
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgW1BhZ2UgMTFd
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+NS4xLiAgU3ludGF4IG9mIHRoZSBDb250ZW50LVR5cGUgSGVhZGVyIEZpZWxk
+
+ICAgSW4gdGhlIEF1Z21lbnRlZCBCTkYgbm90YXRpb24gb2YgUkZDIDgyMiwgYSBDb250ZW50LVR5cGUgaGVhZGVyIGZpZWxk
+ICAgdmFsdWUgaXMgZGVmaW5lZCBhcyBmb2xsb3dzOg==
+
+ICAgICBjb250ZW50IDo9ICJDb250ZW50LVR5cGUiICI6IiB0eXBlICIvIiBzdWJ0eXBl
+ICAgICAgICAgICAgICAgICooIjsiIHBhcmFtZXRlcik=
+ICAgICAgICAgICAgICAgIDsgTWF0Y2hpbmcgb2YgbWVkaWEgdHlwZSBhbmQgc3VidHlwZQ==
+ICAgICAgICAgICAgICAgIDsgaXMgQUxXQVlTIGNhc2UtaW5zZW5zaXRpdmUu
+
+ICAgICB0eXBlIDo9IGRpc2NyZXRlLXR5cGUgLyBjb21wb3NpdGUtdHlwZQ==
+
+ICAgICBkaXNjcmV0ZS10eXBlIDo9ICJ0ZXh0IiAvICJpbWFnZSIgLyAiYXVkaW8iIC8gInZpZGVvIiAv
+ICAgICAgICAgICAgICAgICAgICAgICJhcHBsaWNhdGlvbiIgLyBleHRlbnNpb24tdG9rZW4=
+
+ICAgICBjb21wb3NpdGUtdHlwZSA6PSAibWVzc2FnZSIgLyAibXVsdGlwYXJ0IiAvIGV4dGVuc2lvbi10b2tlbg==
+
+ICAgICBleHRlbnNpb24tdG9rZW4gOj0gaWV0Zi10b2tlbiAvIHgtdG9rZW4=
+
+ICAgICBpZXRmLXRva2VuIDo9IDxBbiBleHRlbnNpb24gdG9rZW4gZGVmaW5lZCBieSBh
+ICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZHMtdHJhY2sgUkZDIGFuZCByZWdpc3RlcmVk
+ICAgICAgICAgICAgICAgICAgICB3aXRoIElBTkEuPg==
+
+ICAgICB4LXRva2VuIDo9IDxUaGUgdHdvIGNoYXJhY3RlcnMgIlgtIiBvciAieC0iIGZvbGxvd2VkLCB3aXRo
+ICAgICAgICAgICAgICAgICBubyBpbnRlcnZlbmluZyB3aGl0ZSBzcGFjZSwgYnkgYW55IHRva2VuPg==
+
+ICAgICBzdWJ0eXBlIDo9IGV4dGVuc2lvbi10b2tlbiAvIGlhbmEtdG9rZW4=
+
+ICAgICBpYW5hLXRva2VuIDo9IDxBIHB1YmxpY2x5LWRlZmluZWQgZXh0ZW5zaW9uIHRva2VuLiBUb2tlbnM=
+ICAgICAgICAgICAgICAgICAgICBvZiB0aGlzIGZvcm0gbXVzdCBiZSByZWdpc3RlcmVkIHdpdGggSUFOQQ==
+ICAgICAgICAgICAgICAgICAgICBhcyBzcGVjaWZpZWQgaW4gUkZDIDIwNDguPg==
+
+ICAgICBwYXJhbWV0ZXIgOj0gYXR0cmlidXRlICI9IiB2YWx1ZQ==
+
+ICAgICBhdHRyaWJ1dGUgOj0gdG9rZW4=
+ICAgICAgICAgICAgICAgICAgOyBNYXRjaGluZyBvZiBhdHRyaWJ1dGVz
+ICAgICAgICAgICAgICAgICAgOyBpcyBBTFdBWVMgY2FzZS1pbnNlbnNpdGl2ZS4=
+
+ICAgICB2YWx1ZSA6PSB0b2tlbiAvIHF1b3RlZC1zdHJpbmc=
+
+ICAgICB0b2tlbiA6PSAxKjxhbnkgKFVTLUFTQ0lJKSBDSEFSIGV4Y2VwdCBTUEFDRSwgQ1RMcyw=
+ICAgICAgICAgICAgICAgICBvciB0c3BlY2lhbHM-
+
+ICAgICB0c3BlY2lhbHMgOj0gICIoIiAvICIpIiAvICI8IiAvICI-IiAvICJAIiAv
+ICAgICAgICAgICAgICAgICAgICIsIiAvICI7IiAvICI6IiAvICJcIiAvIDwiPg==
+ICAgICAgICAgICAgICAgICAgICIvIiAvICJbIiAvICJdIiAvICI_IiAvICI9Ig==
+ICAgICAgICAgICAgICAgICAgIDsgTXVzdCBiZSBpbiBxdW90ZWQtc3RyaW5nLA==
+ICAgICAgICAgICAgICAgICAgIDsgdG8gdXNlIHdpdGhpbiBwYXJhbWV0ZXIgdmFsdWVz
+
+ICAgICBkZXNjcmlwdGlvbiA6PSAiQ29udGVudC1EZXNjcmlwdGlvbiIgIjoiICp0ZXh0
+
+ICAgICBlbmNvZGluZyA6PSAiQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZyIgIjoiIG1lY2hhbmlzbQ==
+
+ICAgICBlbnRpdHktaGVhZGVycyA6PSBbIGNvbnRlbnQgQ1JMRiBd
+ICAgICAgICAgICAgICAgICAgICBbIGVuY29kaW5nIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICBbIGlkIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICBbIGRlc2NyaXB0aW9uIENSTEYgXQ==
+ICAgICAgICAgICAgICAgICAgICAqKCBNSU1FLWV4dGVuc2lvbi1maWVsZCBDUkxGICk=
+
+ICAgICBoZXgtb2N0ZXQgOj0gIj0iIDIoRElHSVQgLyAiQSIgLyAiQiIgLyAiQyIgLyAiRCIgLyAiRSIgLyAiRiIp
+ICAgICAgICAgICAgICAgOyBPY3RldCBtdXN0IGJlIHVzZWQgZm9yIGNoYXJhY3RlcnMgPiAxMjcsID0s
+ICAgICAgICAgICAgICAgOyBTUEFDRXMgb3IgVEFCcyBhdCB0aGUgZW5kcyBvZiBsaW5lcywgYW5kIGlz
+ICAgICAgICAgICAgICAgOyByZWNvbW1lbmRlZCBmb3IgYW55IGNoYXJhY3RlciBub3QgbGlzdGVkIGlu
+ICAgICAgICAgICAgICAgOyBSRkMgMjA0OSBhcyAibWFpbC1zYWZlIi4=
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+ICAgICAgICAgIG11c3QgYmUgdXNlZC4gIEFuIGVxdWFsIHNpZ24gYXMgdGhlIGxhc3QgY2hhcmFjdGVyIG9uIGE=
+ICAgICAgICAgIGVuY29kZWQgbGluZSBpbmRpY2F0ZXMgc3VjaCBhIG5vbi1zaWduaWZpY2FudCAoInNvZnQiKQ==
+ICAgICAgICAgIGxpbmUgYnJlYWsgaW4gdGhlIGVuY29kZWQgdGV4dC4=
+
+ICAgVGh1cyBpZiB0aGUgInJhdyIgZm9ybSBvZiB0aGUgbGluZSBpcyBhIHNpbmdsZSB1bmVuY29kZWQgbGluZSB0aGF0
+ICAgc2F5czo=
+
+ICAgICBOb3cncyB0aGUgdGltZSBmb3IgYWxsIGZvbGsgdG8gY29tZSB0byB0aGUgYWlkIG9mIHRoZWlyIGNvdW50cnku
+
+ICAgVGhpcyBjYW4gYmUgcmVwcmVzZW50ZWQsIGluIHRoZSBRdW90ZWQtUHJpbnRhYmxlIGVuY29kaW5nLCBhczo=
+
+ICAgICBOb3cncyB0aGUgdGltZSA9
+ICAgICBmb3IgYWxsIGZvbGsgdG8gY29tZT0=
+ICAgICAgdG8gdGhlIGFpZCBvZiB0aGVpciBjb3VudHJ5Lg==
+
+ICAgU2luY2UgdGhlIGh5cGhlbiBjaGFyYWN0ZXIgKCItIikgbWF5IGJlIHJlcHJlc2VudGVkIGFzIGl0c2VsZiBpbiB0aGU=
+ICAgUXVvdGVkLVByaW50YWJsZSBlbmNvZGluZywgY2FyZSBtdXN0IGJlIHRha2VuLCB3aGVuIGVuY2Fwc3VsYXRpbmcgYQ==
+ICAgcXVvdGVkLXByaW50YWJsZSBlbmNvZGVkIGJvZHkgaW5zaWRlIG9uZSBvciBtb3JlIG11bHRpcGFydCBlbnRpdGllcyw=
+ICAgdG8gZW5zdXJlIHRoYXQgdGhlIGJvdW5kYXJ5IGRlbGltaXRlciBkb2VzIG5vdCBhcHBlYXIgYW55d2hlcmUgaW4gdGhl
+ICAgZW5jb2RlZCBib2R5LiAgKEEgZ29vZCBzdHJhdGVneSBpcyB0byBjaG9vc2UgYSBib3VuZGFyeSB0aGF0IGluY2x1ZGVz
+ICAgYSBjaGFyYWN0ZXIgc2VxdWVuY2Ugc3VjaCBhcyAiPV8iIHdoaWNoIGNhbiBuZXZlciBhcHBlYXIgaW4gYQ==
+ICAgcXVvdGVkLXByaW50YWJsZSBib2R5LiAgU2VlIHRoZSBkZWZpbml0aW9uIG9mIG11bHRpcGFydCBtZXNzYWdlcyBpbg==
+ICAgUkZDIDIwNDYuKQ==
+
+ICAgICAhIiMkQFtcXV5ge3x9fiU=
+
+RnJlZWQgJiBCb3JlbnN0ZWluICAgICAgICAgIFN0YW5kYXJkcyBUcmFjayAgICAgICAgICAgICAgICAgICAgW1BhZ2UgMjRd
+
+UkZDIDIwNDUgICAgICAgICAgICAgICAgSW50ZXJuZXQgTWVzc2FnZSBCb2RpZXMgICAgICAgICAgICBOb3ZlbWJlciAxOTk2
+
+
+ICAgICAgICAgICAgICAgICAgICBUYWJsZSAxOiBUaGUgQmFzZTY0IEFscGhhYmV0
+
+ICAgICBWYWx1ZSBFbmNvZGluZyAgVmFsdWUgRW5jb2RpbmcgIFZhbHVlIEVuY29kaW5nICBWYWx1ZSBFbmNvZGluZw==
+ICAgICAgICAgMCBBICAgICAgICAgICAgMTcgUiAgICAgICAgICAgIDM0IGkgICAgICAgICAgICA1MSB6
+ICAgICAgICAgMSBCICAgICAgICAgICAgMTggUyAgICAgICAgICAgIDM1IGogICAgICAgICAgICA1MiAw
+ICAgICAgICAgMiBDICAgICAgICAgICAgMTkgVCAgICAgICAgICAgIDM2IGsgICAgICAgICAgICA1MyAx
+ICAgICAgICAgMyBEICAgICAgICAgICAgMjAgVSAgICAgICAgICAgIDM3IGwgICAgICAgICAgICA1NCAy
+ICAgICAgICAgNCBFICAgICAgICAgICAgMjEgViAgICAgICAgICAgIDM4IG0gICAgICAgICAgICA1NSAz
+ICAgICAgICAgNSBGICAgICAgICAgICAgMjIgVyAgICAgICAgICAgIDM5IG4gICAgICAgICAgICA1NiA0
+ICAgICAgICAgNiBHICAgICAgICAgICAgMjMgWCAgICAgICAgICAgIDQwIG8gICAgICAgICAgICA1NyA1
+ICAgICAgICAgNyBIICAgICAgICAgICAgMjQgWSAgICAgICAgICAgIDQxIHAgICAgICAgICAgICA1OCA2
+ICAgICAgICAgOCBJICAgICAgICAgICAgMjUgWiAgICAgICAgICAgIDQyIHEgICAgICAgICAgICA1OSA3
+ICAgICAgICAgOSBKICAgICAgICAgICAgMjYgYSAgICAgICAgICAgIDQzIHIgICAgICAgICAgICA2MCA4
+ICAgICAgICAxMCBLICAgICAgICAgICAgMjcgYiAgICAgICAgICAgIDQ0IHMgICAgICAgICAgICA2MSA5
+ICAgICAgICAxMSBMICAgICAgICAgICAgMjggYyAgICAgICAgICAgIDQ1IHQgICAgICAgICAgICA2MiAr
+ICAgICAgICAxMiBNICAgICAgICAgICAgMjkgZCAgICAgICAgICAgIDQ2IHUgICAgICAgICAgICA2MyAv
+ICAgICAgICAxMyBOICAgICAgICAgICAgMzAgZSAgICAgICAgICAgIDQ3IHY=
+ICAgICAgICAxNCBPICAgICAgICAgICAgMzEgZiAgICAgICAgICAgIDQ4IHcgICAgICAgICAocGFkKSA9
+ICAgICAgICAxNSBQICAgICAgICAgICAgMzIgZyAgICAgICAgICAgIDQ5IHg=
+ICAgICAgICAxNiBRICAgICAgICAgICAgMzMgaCAgICAgICAgICAgIDUwIHk=
--- a/jdk/test/java/util/Currency/PropertiesTest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/Currency/PropertiesTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -27,22 +27,15 @@
import java.util.regex.*;
public class PropertiesTest {
- public static void main(String[] s) throws Exception {
- for (int i = 0; i < s.length; i ++) {
- if ("-d".equals(s[i])) {
- i++;
- if (i == s.length) {
- throw new RuntimeException("-d needs output file name");
- } else {
- dump(s[i]);
- }
- } else if ("-c".equals(s[i])) {
- if (i+2 == s.length) {
- throw new RuntimeException("-d needs two file name arguments, before and after respectively");
- } else {
- compare(s[++i], s[++i]);
- }
- }
+ public static void main(String[] args) throws Exception {
+ if (args.length == 2 && args[0].equals("-d")) {
+ dump(args[1]);
+ } else if (args.length == 4 && args[0].equals("-c")) {
+ compare(args[1], args[2], args[3]);
+ } else {
+ System.err.println("Usage: java PropertiesTest -d <dumpfile>");
+ System.err.println(" java PropertiesTest -c <beforedump> <afterdump> <propsfile>");
+ System.exit(-1);
}
}
@@ -77,15 +70,17 @@
pw.close();
}
- private static void compare(String beforeFile, String afterFile) throws Exception {
+ private static void compare(String beforeFile, String afterFile, String propsFile)
+ throws IOException
+ {
// load file contents
Properties before = new Properties();
+ try (Reader reader = new FileReader(beforeFile)) {
+ before.load(reader);
+ }
Properties after = new Properties();
- try {
- before.load(new FileReader(beforeFile));
- after.load(new FileReader(afterFile));
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
+ try (Reader reader = new FileReader(afterFile)) {
+ after.load(reader);
}
// remove the same contents from the 'after' properties
@@ -103,13 +98,9 @@
}
// now look at the currency.properties
- String propFileName = System.getProperty("java.home") + File.separator +
- "lib" + File.separator + "currency.properties";
Properties p = new Properties();
- try {
- p.load(new FileReader(propFileName));
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
+ try (Reader reader = new FileReader(propsFile)) {
+ p.load(reader);
}
// test each replacements
--- a/jdk/test/java/util/Currency/PropertiesTest.sh Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/Currency/PropertiesTest.sh Mon Dec 10 20:58:36 2012 -0800
@@ -1,7 +1,29 @@
#!/bin/sh
+
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
# @test
-# @bug 6332666 7180362
+# @bug 6332666 7180362 8003846
# @summary tests the capability of replacing the currency data with user
# specified currency properties file
# @build PropertiesTest
@@ -36,7 +58,7 @@
;;
Windows* | CYGWIN* )
PS=";"
- FS="\\"
+ FS="/"
;;
* )
echo "Unrecognized system!"
@@ -44,23 +66,31 @@
;;
esac
-# Currency dump path #1. Just dump currencies with the bare JRE
+failures=0
-# run
-RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -d dump1"
+run() {
+ echo ''
+ sh -xc "${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} $*" 2>&1
+ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+}
-echo ${RUNCMD}
-${RUNCMD}
-result=$?
+PROPS=${TESTSRC}${FS}currency.properties
+
+
+# Dump built-in currency data
-if [ $result -eq 0 ]
-then
- echo "Execution successful"
-else
- echo "Execution of the test case failed."
-fi
+run PropertiesTest -d dump1
+
+
+# Dump built-in currency data + overrides in properties file specified
+# by system property.
-# Currency dump path #2. Dump currencies using the JRE with replacement currencies
+run -Djava.util.currency.data=${PROPS} PropertiesTest -d dump2
+run PropertiesTest -c dump1 dump2 ${PROPS}
+
+
+# Dump built-in currency data + overrides in properties file copied into
+# JRE image.
# copy the test properties file
COPIED=0
@@ -79,44 +109,27 @@
else
PROPLOCATION=${WRITABLEJDK}${FS}lib
fi
-cp ${TESTSRC}${FS}currency.properties $PROPLOCATION
+cp ${PROPS} $PROPLOCATION
# run
-RUNCMD="${WRITABLEJDK}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -d dump2"
-
-echo ${RUNCMD}
-${RUNCMD}
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Execution successful"
-else
- echo "Execution of the test case failed."
-fi
-
-# Now compare the two dump files
-
-RUNCMD="${WRITABLEJDK}${FS}bin${FS}java -classpath ${TESTCLASSES} PropertiesTest -c dump1 dump2"
-
-echo ${RUNCMD}
-${RUNCMD}
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Execution successful"
-else
- echo "Execution of the test case failed."
-fi
+echo ''
+sh -xc "${WRITABLEJDK}${FS}bin${FS}java -cp ${TESTCLASSES} PropertiesTest -d dump3"
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# Cleanup
-rm -f dump1
-rm -f dump2
rm -f ${PROPLOCATION}${FS}currency.properties
if [ $COPIED -eq 1 ]
then
rm -rf $WRITABLEJDK
fi
-exit $result
+# compare the two dump files
+run PropertiesTest -c dump1 dump3 ${PROPS}
+
+
+# Results
+echo ''
+if [ $failures -gt 0 ];
+ then echo "$failures tests failed";
+ else echo "All tests passed"; fi
+exit $failures
--- a/jdk/test/java/util/TimeZone/Bug6912560.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/TimeZone/Bug6912560.java Mon Dec 10 20:58:36 2012 -0800
@@ -40,6 +40,9 @@
// set the user.timezone property
String tzname = "Asia/Tokyo";
System.setProperty("user.timezone", tzname);
+ // make sure the timezone will be initialized by
+ // the next call to TimeZone.getDefault()
+ TimeZone.setDefault(null);
System.setSecurityManager(new SecurityManager());
TimeZone tz = TimeZone.getDefault();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TreeMap/Clone.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7198904
+ * @summary Verify that cloned TreeMap gets new keyset
+ * @author david.buck@oracle.com
+ * @run main/othervm Clone
+ * @run main/othervm -XX:+AggressiveOpts Clone
+ */
+
+import java.util.TreeMap;
+
+public class Clone {
+
+ public static void main(String[] args) throws Exception {
+ TreeMap<String,Object> m1 = new TreeMap<String,Object>();
+ m1.put( "one", 1 );
+ m1.keySet();
+ TreeMap<String,Object> m2 = (TreeMap<String,Object>)m1.clone();
+ m1.put( "two", 2 );
+ m2.put( "three", 3 );
+ // iterate over the clone (m2) and we should get "one" and "three"
+ for( final String key : m2.keySet() ) {
+ if( !"one".equals( key ) && !"three".equals( key ) ) {
+ throw new IllegalStateException( "Unexpected key: " + key );
+ }
+ }
+ // iterate over the original (m1) and we should get "one" and "two"
+ for( final String key : m1.keySet() ) {
+ if( !"one".equals( key ) && !"two".equals( key ) ) {
+ throw new IllegalStateException( "Unexpected key: " + key );
+ }
+ }
+ }
+
+}
--- a/jdk/test/java/util/logging/ClassLoaderLeakTest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/ClassLoaderLeakTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@
import java.net.URLClassLoader;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Logger;
-import java.util.logging.Logger;
public class ClassLoaderLeakTest {
@@ -59,11 +58,11 @@
try {
ClassLoader cl =
Thread.currentThread().getContextClassLoader();
- Class appMain = cl.loadClass("AppTest");
+ Class<?> appMain = cl.loadClass("AppTest");
Method launch =
appMain.getDeclaredMethod("launch", doneSignal.getClass());
- Constructor c = appMain.getConstructor();
+ Constructor<?> c = appMain.getConstructor();
Object o = c.newInstance();
@@ -80,8 +79,7 @@
/* prepare test class loader */
URL pwd = null;
try {
-
- pwd = new File(System.getProperty("test.classes",".")).toURL();
+ pwd = new File(System.getProperty("test.classes",".")).toURI().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException("Test failed.", e);
}
@@ -139,7 +137,7 @@
uniqClassName = uniq;
}
- public Class loadClass(String name) throws ClassNotFoundException {
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
if (verbose) {
System.out.printf("%s: load class %s\n", uniqClassName, name);
}
--- a/jdk/test/java/util/logging/Listeners.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/Listeners.java Mon Dec 10 20:58:36 2012 -0800
@@ -88,6 +88,7 @@
}
}
+ @SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
LogManager logman = LogManager.getLogManager();
--- a/jdk/test/java/util/logging/ListenersWithSM.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/ListenersWithSM.java Mon Dec 10 20:58:36 2012 -0800
@@ -35,6 +35,7 @@
public class ListenersWithSM {
+ @SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
boolean granted = args[0].equals("grant");
--- a/jdk/test/java/util/logging/LoggerResourceBundleRace.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggerResourceBundleRace.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,10 @@
* @run main LoggerResourceBundleRace
*/
+import java.util.ListResourceBundle;
+import java.util.MissingResourceException;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.ListResourceBundle;
import java.util.logging.Logger;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
public class LoggerResourceBundleRace extends RacingThreadsTest {
--- a/jdk/test/java/util/logging/LoggingDeadlock2.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggingDeadlock2.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -103,7 +103,7 @@
// This may or may not result in a first call to
// Runtime.addShutdownHook after shutdown has already
// commenced.
- LogManager log = LogManager.getLogManager();
+ LogManager.getLogManager();
if (dojoin) {
exiter.join();
@@ -148,7 +148,6 @@
public String out() { return out; }
public String err() { return err; }
public int exitValue() { return exitValue; }
- public Throwable throwable() { return throwable; }
public String toString() {
StringBuilder sb = new StringBuilder();
--- a/jdk/test/java/util/logging/LoggingDeadlock3.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggingDeadlock3.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
public static class GetLogger implements Runnable {
public void run() {
for (int cnt = 0; cnt < ITER_CNT * 8; cnt++) {
- Logger logger = Logger.getLogger("com.sun.Hello"+cnt/10);
+ Logger.getLogger("com.sun.Hello"+cnt/10);
if (cnt % 1000 == 0) out.print("1");
if (cnt % 10000 == 0) out.println();
}
--- a/jdk/test/java/util/logging/LoggingDeadlock4.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggingDeadlock4.java Mon Dec 10 20:58:36 2012 -0800
@@ -30,7 +30,6 @@
* @run main/othervm/timeout=15 -Djava.awt.headless=true LoggingDeadlock4
*/
-import java.awt.Container;
import java.util.concurrent.CountDownLatch;
import java.util.logging.LogManager;
import java.util.logging.Logger;
@@ -68,7 +67,7 @@
} catch (InterruptedException e) {
}
- LogManager manager = LogManager.getLogManager();
+ LogManager.getLogManager();
}
};
lmThread.start();
@@ -86,7 +85,7 @@
} catch (InterruptedException e) {
}
- Logger foo = Logger.getLogger("foo logger");
+ Logger.getLogger("foo logger");
}
};
logThread.start();
--- a/jdk/test/java/util/logging/LoggingMXBeanTest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggingMXBeanTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -208,7 +208,7 @@
String levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
l = Level.parse(levelName);
System.out.print(" Logger1: " );
- if ( l.equals( l.ALL ) ) {
+ if ( l.equals( Level.ALL ) ) {
System.out.println("Level Set to ALL: PASSED" );
log1 = true;
}
@@ -226,7 +226,7 @@
levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
l = Level.parse(levelName);
System.out.print(" Logger2: " );
- if ( l.equals( l.FINER ) ) {
+ if ( l.equals( Level.FINER ) ) {
System.out.println("Level Set to FINER: PASSED" );
log2 = true;
}
@@ -247,6 +247,6 @@
}
public static void main(String[] argv) throws Exception {
- LoggingMXBeanTest p = new LoggingMXBeanTest();
+ new LoggingMXBeanTest();
}
}
--- a/jdk/test/java/util/logging/LoggingMXBeanTest2.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/LoggingMXBeanTest2.java Mon Dec 10 20:58:36 2012 -0800
@@ -37,7 +37,6 @@
public class LoggingMXBeanTest2
{
-
static LoggingMXBean mbean = LogManager.getLoggingMXBean();
static String LOGGER_NAME_1 = "com.sun.management.Logger";
static String LOGGER_NAME_2 = "com.sun.management.Logger.Logger2";
@@ -57,14 +56,14 @@
*/
System.out.println("Test Logger Name retrieval (getLoggerNames)");
boolean log1 = false, log2 = false;
- List loggers = mbean.getLoggerNames();
+ List<String> loggers = mbean.getLoggerNames();
if (loggers == null || loggers.size() < 2) {
throw new RuntimeException(
"Could not Detect the presense of the new Loggers");
}
- for (ListIterator iter = loggers.listIterator(); iter.hasNext(); ) {
- String logger = (String) iter.next();
+ for (ListIterator<String> iter = loggers.listIterator(); iter.hasNext(); ) {
+ String logger = iter.next();
if (logger.equals(LOGGER_NAME_1)) {
log1 = true;
System.out.println(" : Found new Logger : " + logger);
@@ -187,6 +186,6 @@
}
public static void main(String[] argv) throws Exception {
- LoggingMXBeanTest2 p = new LoggingMXBeanTest2();
+ new LoggingMXBeanTest2();
}
}
--- a/jdk/test/java/util/logging/MemoryHandlerTest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/MemoryHandlerTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -48,7 +48,7 @@
File fname = new File(tstSrc, LM_PROP_FNAME);
String prop = fname.getCanonicalPath();
System.setProperty(CFG_FILE_PROP, prop);
- LogManager logMgr = LogManager.getLogManager();
+ LogManager.getLogManager();
// create a logger
logger = Logger.getLogger(MemoryHandlerTest.class.getName());
// don't have parent handlers get log messages
--- a/jdk/test/java/util/logging/ParentLoggersTest.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/ParentLoggersTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
/*
* @test
* @bug 6498300
@@ -86,12 +109,12 @@
Vector<String> expectedLoggerNames = new Vector<String>(getDefaultLoggerNames());
// Create the logger LOGGER_NAME_1
- Logger logger1 = Logger.getLogger(LOGGER_NAME_1);
+ Logger.getLogger(LOGGER_NAME_1);
expectedLoggerNames.addElement(PARENT_NAME_1);
expectedLoggerNames.addElement(LOGGER_NAME_1);
// Create the logger LOGGER_NAME_2
- Logger logger2 = Logger.getLogger(LOGGER_NAME_2);
+ Logger.getLogger(LOGGER_NAME_2);
expectedLoggerNames.addElement(PARENT_NAME_2);
expectedLoggerNames.addElement(LOGGER_NAME_2);
--- a/jdk/test/java/util/logging/SimpleFormatterFormat.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/logging/SimpleFormatterFormat.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -92,8 +92,9 @@
System.out.println("Checking log records in file: " + log);
Pattern p = Pattern.compile("([\\.a-zA-Z:]+) (.*) \\[.*\\] source: (.*)");
- try (FileInputStream in = new FileInputStream(log)) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ try (FileInputStream in = new FileInputStream(log);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ ) {
String line;
int i = 0;
while (i < messages.length &&
--- a/jdk/test/java/util/prefs/AddNodeChangeListener.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/AddNodeChangeListener.java Mon Dec 10 20:58:36 2012 -0800
@@ -24,9 +24,10 @@
*/
/* @test
- * @bug 7160252
+ * @bug 7160252 7197662
* @summary Checks if events are delivered to a listener
* when a child node is added or removed
+ * @run main/othervm -Djava.util.prefs.userRoot=. AddNodeChangeListener
*/
import java.util.prefs.*;
--- a/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh Mon Dec 10 20:58:36 2012 -0800
@@ -22,10 +22,10 @@
#
# @test
-# @bug 7198073
+# @bug 7198073 7197662
# @build CheckUserPrefFirst CheckUserPrefLater
# @run shell CheckUserPrefsStorage.sh
-# @summary Tests that user preferences are stored in the
+# @summary Tests that user preferences are stored in the
# permanent storage
#
@@ -50,14 +50,14 @@
esac
# run CheckUserPrefFirst - creates and stores a user pref
-${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} CheckUserPrefFirst
+${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefFirst
result=$?
if [ "$result" -ne "0" ]; then
exit 1
fi
# run CheckUserPrefLater - Looks for the stored pref
-${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} CheckUserPrefLater
+${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} -Djava.util.prefs.userRoot=. CheckUserPrefLater
result=$?
if [ "$result" -ne "0" ]; then
exit 1
--- a/jdk/test/java/util/prefs/CommentsInXml.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/CommentsInXml.java Mon Dec 10 20:58:36 2012 -0800
@@ -23,8 +23,9 @@
/*
* @test
- * @bug 4619564
+ * @bug 4619564 7197662
* @summary XMl Comments in Preferences File lead to ClassCastException
+ * @run main/othervm -Djava.util.prefs.userRoot=. CommentsInXml
* @author kladko
*/
--- a/jdk/test/java/util/prefs/ConflictInFlush.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/ConflictInFlush.java Mon Dec 10 20:58:36 2012 -0800
@@ -23,8 +23,9 @@
/*
* @test
- * @bug 4703132
+ * @bug 4703132 7197662
* @summary flush() throws an IllegalStateException on a removed node
+ * @run main/othervm -Djava.util.prefs.userRoot=. ConflictInFlush
* @author Sucheta Dambalkar
*/
--- a/jdk/test/java/util/prefs/ExportNode.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/ExportNode.java Mon Dec 10 20:58:36 2012 -0800
@@ -24,9 +24,10 @@
/*
* @test
- * @bug 4387136 4947349
+ * @bug 4387136 4947349 7197662
* @summary Due to a bug in XMLSupport.putPreferencesInXml(...),
* node's keys would not get exported.
+ * @run main/othervm -Djava.util.prefs.userRoot=. ExportNode
* @author Konstantin Kladko
*/
import java.util.prefs.*;
--- a/jdk/test/java/util/prefs/ExportSubtree.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/ExportSubtree.java Mon Dec 10 20:58:36 2012 -0800
@@ -23,9 +23,10 @@
/* @test
- @bug 6203576 4700020
- @summary checks if the output of exportSubtree() is identical to
- the output from previous release.
+ * @bug 6203576 4700020 7197662
+ * @summary checks if the output of exportSubtree() is identical to
+ * the output from previous release.
+ * @run main/othervm -Djava.util.prefs.userRoot=. ExportSubtree
*/
import java.io.*;
--- a/jdk/test/java/util/prefs/PrefsSpi.sh Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/PrefsSpi.sh Mon Dec 10 20:58:36 2012 -0800
@@ -24,7 +24,7 @@
#
# @test
-# @bug 4991526 6514993
+# @bug 4991526 6514993 7197662
# @summary Unit test for Preferences jar providers
#
# @build PrefsSpi
@@ -89,12 +89,16 @@
Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \
-Djava.util.prefs.PreferencesFactory=StubPreferencesFactory \
+ -Djava.util.prefs.userRoot=. \
PrefsSpi "StubPreferences"
Sys "$java" "-cp" "$TESTCLASSES" \
+ -Djava.util.prefs.userRoot=. \
PrefsSpi "java.util.prefs.*"
Sys "$java" "-cp" "$TESTCLASSES${CPS}extDir/PrefsSpi.jar" \
+ -Djava.util.prefs.userRoot=. \
PrefsSpi "StubPreferences"
Sys "$java" "-cp" "$TESTCLASSES" "-Djava.ext.dirs=extDir" \
+ -Djava.util.prefs.userRoot=. \
PrefsSpi "StubPreferences"
rm -rf jarDir extDir
--- a/jdk/test/java/util/prefs/RemoveNullKeyCheck.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/RemoveNullKeyCheck.java Mon Dec 10 20:58:36 2012 -0800
@@ -22,9 +22,10 @@
*/
/* @test
- * @bug 7160242 7165118
+ * @bug 7160242 7165118 7197662
* @summary Check if NullPointerException is thrown if the key passed
* to remove() is null.
+ * @run main/othervm -Djava.util.prefs.userRoot=. RemoveNullKeyCheck
*/
import java.util.prefs.Preferences;
--- a/jdk/test/java/util/prefs/RemoveReadOnlyNode.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/RemoveReadOnlyNode.java Mon Dec 10 20:58:36 2012 -0800
@@ -23,10 +23,11 @@
/* @test
- @bug 6178148
- @summary check if wrong exception gets thrown if one of the child
- nodes is readonly on underlying filesystem when node is
- being removed.
+ * @bug 6178148 7197662
+ * @summary check if wrong exception gets thrown if one of the child
+ * nodes is readonly on underlying filesystem when node is
+ * being removed.
+ * @run main/othervm -Djava.util.prefs.userRoot=. RemoveReadOnlyNode
*/
import java.io.*;
--- a/jdk/test/java/util/prefs/RemoveUnregedListener.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/java/util/prefs/RemoveUnregedListener.java Mon Dec 10 20:58:36 2012 -0800
@@ -23,9 +23,10 @@
/* @test
- * @bug 4705094
+ * @bug 4705094 7197662
* @summary Checks if correct exception gets thrown when removing an
* unregistered NodeChangeListener .
+ * @run main/othervm -Djava.util.prefs.userRoot=. RemoveUnregedListener
*/
import java.util.prefs.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/8003830/bug8003830.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.EventQueue;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import javax.swing.JTree;
+import javax.swing.plaf.basic.BasicTreeUI;
+import javax.swing.tree.TreePath;
+
+
+/* Originally reported as NetBeans bug 222081.
+ *
+ * @test
+ * @bug 8003830
+ * @summary NullPointerException in BasicTreeUI.Actions when getPathBounds returns null
+ * @author Jaroslav Tulach
+ * @run main bug8003830
+ */
+
+public class bug8003830 implements Runnable {
+ public static void main(String[] args) throws Exception {
+ EventQueue.invokeAndWait(new bug8003830());
+ }
+ @Override
+ public void run() {
+ testNPEAtActionsPage();
+ }
+
+ public void testNPEAtActionsPage() {
+ JTree tree = new JTree();
+ BasicTreeUI ui = new NullReturningTreeUI();
+ tree.setUI(ui);
+ BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
+ tpa.actionPerformed(new ActionEvent(tree, 0, ""));
+ }
+
+ private static final class NullReturningTreeUI extends BasicTreeUI {
+ @Override
+ public Rectangle getPathBounds(JTree tree, TreePath path) {
+ // the method can return null and callers have to be ready for
+ // that. Simulate the case by returning null for unknown reason.
+ return null;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/dnd/7171812/JListWithScroll.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.dnd.Autoscroll;
+
+public class JListWithScroll<E> extends JList<E> implements Autoscroll {
+ private Insets scrollInsets;
+
+ public JListWithScroll(E[] listData) {
+ super(listData);
+ scrollInsets = new Insets(50, 50, 50, 50);
+ }
+
+ @Override
+ public Insets getAutoscrollInsets() {
+ return scrollInsets;
+ }
+
+ @Override
+ public void autoscroll(Point cursorLoc) {
+ JViewport viewport = getViewport();
+
+ if (viewport == null) {
+ return;
+ }
+
+ Point viewPos = viewport.getViewPosition();
+ int viewHeight = viewport.getExtentSize().height;
+ int viewWidth = viewport.getExtentSize().width;
+
+ if ((cursorLoc.y - viewPos.y) < scrollInsets.top) {
+ viewport.setViewPosition(new Point(viewPos.x, Math.max(viewPos.y - scrollInsets.top, 0)));
+ } else if (((viewPos.y + viewHeight) - cursorLoc.y) < scrollInsets.bottom) {
+ viewport.setViewPosition(
+ new Point(viewPos.x, Math.min(viewPos.y + scrollInsets.bottom, this.getHeight() - viewHeight))
+ );
+ } else if ((cursorLoc.x - viewPos.x) < scrollInsets.left) {
+ viewport.setViewPosition(new Point(Math.max(viewPos.x - scrollInsets.left, 0), viewPos.y));
+ } else if (((viewPos.x + viewWidth) - cursorLoc.x) < scrollInsets.right) {
+ viewport.setViewPosition(
+ new Point(Math.min(viewPos.x + scrollInsets.right, this.getWidth() - viewWidth), viewPos.y)
+ );
+ }
+
+ }
+
+ public JViewport getViewport() {
+ Component curComp = this;
+
+ while (!(curComp instanceof JViewport) && (curComp != null)) {
+ curComp = curComp.getParent();
+ }
+ if(curComp instanceof JViewport) {
+ return (JViewport) curComp;
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/dnd/7171812/bug7171812.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 7171812
+ @summary [macosx] Views keep scrolling back to the drag position after DnD
+ @author Alexander Zuev
+ @run main bug7171812
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.event.InputEvent;
+import javax.swing.*;
+
+public class bug7171812 {
+ static JFrame mainFrame;
+ static String listData[];
+ static JListWithScroll<String> list;
+ static JScrollPane scrollPane;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception{
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ setupGUI();
+ }
+ });
+ toolkit.realSync();
+
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+ robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
+ robot.mouseMove(scrollPane.getLocationOnScreen().x+5, scrollPane.getLocationOnScreen().y+offset);
+ }
+ for(int offset = 5; offset < 195; offset++) {
+ robot.mouseMove(scrollPane.getLocationOnScreen().x+offset, scrollPane.getLocationOnScreen().y+scrollPane.getHeight()-20);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if(scrollPane.getViewport().getViewPosition().getY() < 30) {
+ throw new RuntimeException("Incorrect view position.");
+ };
+ }
+ });
+ } catch (java.lang.reflect.InvocationTargetException ite) {
+ throw new RuntimeException("Test failed, scroll on drag doesn't work!");
+ }
+ }
+
+ public static void setupGUI() {
+ listData = new String[100];
+ for (int i=0; i<100; i++) {
+ listData[i] = "Long Line With Item "+i;
+ }
+ mainFrame = new JFrame("Rest frame");
+ mainFrame.setSize(300, 500);
+ mainFrame.setLayout(new BorderLayout());
+ list = new JListWithScroll(listData);
+ list.setDragEnabled(true);
+ list.setAutoscrolls(true);
+ final DropTarget dropTarget = new DropTarget(list, DnDConstants.ACTION_MOVE, new DropTargetListener() {
+ @Override
+ public void dragEnter(DropTargetDragEvent dtde) {
+ dragOver(dtde);
+ }
+
+ @Override
+ public void dragOver(DropTargetDragEvent dtde) {
+ dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+ }
+
+ @Override
+ public void dropActionChanged(DropTargetDragEvent dtde) {
+ }
+
+ @Override
+ public void dragExit(DropTargetEvent dte) {
+ }
+
+ @Override
+ public void drop(DropTargetDropEvent dtde) {
+ }
+ }, true);
+ scrollPane = new JScrollPane(list);
+ mainFrame.add(scrollPane, BorderLayout.CENTER);
+ mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ mainFrame.setLocation(100, 100);
+ mainFrame.setVisible(true);
+ }
+}
--- a/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6796710
+ * @bug 6796710 7124242
* @summary Html content in JEditorPane is overlapping on swing components while resizing the application.
* @library ../../../regtesthelpers
* @build Util
@@ -31,11 +31,10 @@
@run main bug6796710
*/
-import sun.awt.SunToolkit;
-
-import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
+import javax.swing.*;
+import sun.awt.SunToolkit;
public class bug6796710 {
// The page is inlined because we want to be sure that the JEditorPane filled synchronously
@@ -68,9 +67,12 @@
robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
frame = new JFrame();
+ frame.setUndecorated(true);
+
pnBottom = new JPanel();
pnBottom.add(new JLabel("Some label"));
pnBottom.add(new JButton("A button"));
@@ -95,9 +97,13 @@
((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+ // This delay should be added for MacOSX, realSync is not enough
+ Thread.sleep(1000);
+
BufferedImage bufferedImage = getPnBottomImage();
SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
public void run() {
frame.setSize(400, 150);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/OpenGL/CustomCompositeTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7124347
+ * @summary Verifies that rendering with XOR composite, and arbitraty
+ * custom composite doesn not cause internal errors.
+ *
+ * @run main/othervm -Dsun.java2d.opengl=True CustomCompositeTest
+ */
+
+import java.awt.AWTException;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.CompositeContext;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.ImageCapabilities;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBufferInt;
+import java.awt.image.Raster;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.VolatileImage;
+import java.awt.image.WritableRaster;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+public class CustomCompositeTest {
+
+ private static JFrame frame;
+ private static CountDownLatch paintLatch;
+ private static Throwable paintError;
+
+ public static void main(String[] args) {
+
+ paintLatch = new CountDownLatch(1);
+ paintError = null;
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ initGUI();
+ }
+ });
+
+ try {
+ paintLatch.await();
+ } catch (InterruptedException e) {
+ };
+ System.out.println("Paint is done!");
+ if (paintError != null) {
+ frame.dispose();
+ throw new RuntimeException("Test FAILED.", paintError);
+ }
+
+ System.out.println("Phase 1: PASSED.");
+
+ // now resise the frame in order to cause re-paint with accelerated
+ // source images.
+ paintError = null;
+ paintLatch = new CountDownLatch(1);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Dimension size = frame.getSize();
+ size.width += 50;
+ size.height += 50;
+
+ frame.setSize(size);
+ }
+ });
+
+ try {
+ paintLatch.await();
+ } catch (InterruptedException e) {
+ };
+ if (paintError != null) {
+ frame.dispose();
+ throw new RuntimeException("Resize test FAILED.", paintError);
+ }
+ frame.dispose();
+ System.out.println("Phase 2: PASSED.");
+
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsConfiguration cfg = env.getDefaultScreenDevice().getDefaultConfiguration();
+ // test rendering to accelerated volatile image
+ testVolatileImage(cfg, true);
+ System.out.println("Phase 3: PASSED.");
+
+ // test rendering to unaccelerated volatile image
+ testVolatileImage(cfg, false);
+ System.out.println("Phase 4: PASSED.");
+ }
+
+ private static void testVolatileImage(GraphicsConfiguration cfg,
+ boolean accelerated)
+ {
+ VolatileImage dst = null;
+ try {
+ dst = cfg.createCompatibleVolatileImage(640, 480,
+ new ImageCapabilities(accelerated));
+ } catch (AWTException e) {
+ System.out.println("Unable to create volatile image, skip the test.");
+ return;
+ }
+ renderToVolatileImage(dst);
+ }
+
+ private static void renderToVolatileImage(VolatileImage dst) {
+ Graphics2D g = dst.createGraphics();
+ do {
+ System.out.println("Render to volatile image..");
+ try {
+ MyComp.renderTest(g, dst.getHeight(), dst.getHeight());
+ } catch (Throwable e) {
+ throw new RuntimeException("Test FAILED.", e);
+ }
+ } while (dst.contentsLost());
+ System.out.println("Done.");
+ }
+
+ private static void initGUI() {
+ frame = new JFrame("Silly composite");
+ frame.getContentPane().add(new MyComp());
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private static class MyComp extends JComponent {
+
+ private static BufferedImage theImage;
+
+ public MyComp() {
+ }
+
+ private static BufferedImage getTestImage() {
+ if (theImage == null) {
+ theImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = theImage.createGraphics();
+ g2d.setColor(Color.red);
+ g2d.fillRect(0, 0, 256, 256);
+
+ g2d.setPaint(new GradientPaint(0, 0, Color.red, 256, 256, Color.blue));
+ g2d.fillRect(0, 100, 256, 256);
+ g2d.dispose();
+ }
+ return theImage;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(640, 375);
+ }
+
+ public void paintComponent(Graphics g) {
+
+
+ Graphics2D g2d = (Graphics2D) g;
+ try {
+ renderTest(g2d, getWidth(), getHeight());
+ } catch (Throwable e) {
+ paintError = e;
+ }
+ if (paintLatch != null) {
+ paintLatch.countDown();
+ }
+ }
+
+ public static void renderTest(Graphics2D g2d, int w, int h) {
+ g2d.setColor(Color.yellow);
+ g2d.fillRect(0, 0, w, h);
+
+ BufferedImage image = getTestImage();
+ // draw original image
+ g2d.drawRenderedImage(image, null);
+
+ // draw image with custom composite
+ g2d.translate(175, 25);
+ Composite currentComposite = g2d.getComposite();
+ g2d.setComposite(new TestComposite());
+ g2d.drawRenderedImage(image, null);
+ g2d.setComposite(currentComposite);
+
+ // draw image with XOR
+ g2d.translate(175, 25);
+ g2d.setXORMode(Color.red);
+ g2d.drawRenderedImage(image, null);
+
+
+ System.out.println("Painting is done...");
+ }
+ }
+
+ // A silly custom Composite to demonstrate the problem - just inverts the RGB
+ private static class TestComposite implements Composite {
+
+ public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints) {
+ return new TestCompositeContext();
+ }
+ }
+
+ private static class TestCompositeContext implements CompositeContext {
+
+ public void dispose() {
+ }
+
+ public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
+ int w = src.getWidth();
+ int h = src.getHeight();
+
+ DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
+ DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
+ int srcRGB[] = srcDB.getBankData()[0];
+ int dstOutRGB[] = dstOutDB.getBankData()[0];
+ int srcOffset = srcDB.getOffset();
+ int dstOutOffset = dstOutDB.getOffset();
+ int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
+ int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
+ int srcAdjust = srcScanStride - w;
+ int dstOutAdjust = dstOutScanStride - w;
+
+ int si = srcOffset;
+ int doi = dstOutOffset;
+
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
+ dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
+ si++;
+ doi++;
+ }
+
+ si += srcAdjust;
+ doi += dstOutAdjust;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/InvalidRenderIntentTest.java Mon Dec 10 20:58:36 2012 -0800
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7064516
+ * @summary Test verifies that incorrect profile rendering intent
+ * does not cause an failure of color conversion op.
+ * @run main InvalidRenderIntentTest
+ */
+
+import java.awt.color.CMMException;
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.BufferedImage;
+
+import static java.awt.color.ColorSpace.CS_sRGB;
+import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR;
+
+public class InvalidRenderIntentTest {
+
+ public static void main(String[] args) {
+ ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);
+
+ byte[] raw_data = pSRGB.getData();
+
+ setRenderingIntent(0x1000000, raw_data);
+
+ ICC_Profile p = ICC_Profile.getInstance(raw_data);
+
+ ICC_ColorSpace cs = new ICC_ColorSpace(p);
+
+ // perfrom test color conversion
+ ColorConvertOp op = new ColorConvertOp(cs,
+ ColorSpace.getInstance(CS_sRGB), null);
+ BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
+ BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
+
+ try {
+ op.filter(src.getRaster(), dst.getRaster());
+ } catch (CMMException e) {
+ throw new RuntimeException("Test failed.", e);
+ }
+ System.out.println("Test passed.");
+ }
+
+ private static void setRenderingIntent(int intent, byte[] data) {
+ final int pos = ICC_Profile.icHdrRenderingIntent;
+
+ data[pos + 0] = (byte) (0xff & (intent >> 24));
+ data[pos + 1] = (byte) (0xff & (intent >> 16));
+ data[pos + 2] = (byte) (0xff & (intent >> 8));
+ data[pos + 3] = (byte) (0xff & (intent));
+ }
+}
--- a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Mon Dec 10 20:58:36 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,11 @@
* questions.
*/
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
/*
* @test
* @bug 6405536
@@ -28,6 +33,7 @@
* @author Andreas Sterbenz
* @library ..
* @library ../../../../java/security/testlibrary
+ * @run main/othervm ClientJSSEServerJSSE
*/
import java.security.*;
--- a/jdk/test/sun/security/tools/keytool/console.sh Thu Dec 06 12:04:35 2012 -0800
+++ b/jdk/test/sun/security/tools/keytool/console.sh Mon Dec 10 20:58:36 2012 -0800
@@ -31,62 +31,101 @@
# @run shell/manual console.sh
if [ "$ALT_PASS" = "" ]; then
- export PASS=äöäöäöäö
+ PASSW=äöäöäö
else
- export PASS=$ALT_PASS
+ PASSW=$ALT_PASS
+fi
+
+KS=/tmp/kkk.$$
+
+cat <<____
+
+ATTENTION
+===============================================================
+
+This test is about non-ASCII password input compatibility between
+JDK 5.0 and later versions. Before running the test, make sure that --
+
+ \$J5 points to a JDK 5.0 installation
+ \$JM points to the current installation
+
+The password string used in this test is $PASSW. If you find difficulty
+entering it in in your system, feel free to change it to something else
+by providing \$ALT_PASS. It should be no less than 6 characters and include
+some non-ASCII characters.
+
+For each test, type into the characters as described in the test header.
+<R> means the RETURN (or ENTER key). Please wait for a little while
+after <R> is pressed each time.
+
+\$J5 is now $J5
+\$JM is now $JM
+
+____
+
+
+if [ "$J5" = "" -o "$JM" = "" ]; then
+ echo "Define \$J5 and \$JM first"
+ exit 1
fi
-echo "ATTENTION"
-echo "==============================================================="
+echo "Press ENTER to start the test, or Ctrl-C to stop it"
+read x
+
echo
-echo "This test is about console password input compatibility between"
-echo "Tiger and Mustang. Before running the test, make sure that --"
-echo "\$J5 points to a JDK 5.0 installation"
-echo "\$JM points to a JDK 6 installation".
-echo
-echo "The password string used in this test is $PASS. If you find difficulty"
-echo "entering it in in your system, feel free to change it to something else"
-echo "by providing \$ALT_PASS (should be not less than 6 characters)"
+echo "=========================================="
+echo "Test #1: 5->6, non-prompt. Please type <R>"
+echo "=========================================="
echo
-echo "For all prompt of \"Enter keystore password\", type $PASS and press ENTER"
-echo "For all prompt of \"Enter key password for <mykey> (RETURN if same as keystore password)\", press ENTER"
-echo "If you see both the prompts appear, say --"
-echo " Enter key password for <mykey>"
-echo " (RETURN if same as keystore password): Enter keystore password:"
-echo "only response to the last prompt by typing $PASS and press ENTER"
+rm $KS 2> /dev/null
+$J5/bin/keytool -keystore $KS -genkey -dname CN=olala -storepass $PASSW || exit 1
+$JM/bin/keytool -keystore $KS -list -storepass $PASSW || exit 2
+
+echo "=========================================="
+echo "Test #2: 6->5, non-prompt. Please type <R>"
+echo "=========================================="
echo
-echo "Only if all the command run correctly without showing any error "
-echo "or warning, this test passes."
-echo
-echo "Press ENTER to start the test, or Ctrl-C to stop it"
-read
+
+rm $KS 2> /dev/null
+$JM/bin/keytool -keystore $KS -genkey -dname CN=olala -storepass $PASSW || exit 3
+$J5/bin/keytool -keystore $KS -list -storepass $PASSW || exit 4
+
+echo "============================================================"
+echo "Test #3: 5->6, prompt. Please type $PASSW <R> <R> $PASSW <R>"
+echo "============================================================"
echo
-echo "Test #1: 5->6, non-prompt"
-rm kkk
-$J5/bin/keytool -keystore kkk -genkey -dname CN=olala -storepass $PASS
-$JM/bin/keytool -keystore kkk -list -storepass $PASS
-echo "Test #2: 6->5, non-prompt"
-rm kkk
-$JM/bin/keytool -keystore kkk -genkey -dname CN=olala -storepass $PASS
-$J5/bin/keytool -keystore kkk -list -storepass $PASS
-echo "Test #3: 5->6, prompt"
-rm kkk
-$J5/bin/keytool -keystore kkk -genkey -dname CN=olala
-$JM/bin/keytool -keystore kkk -list
-echo $PASS| $J5/bin/keytool -keystore kkk -list
-echo $PASS| $JM/bin/keytool -keystore kkk -list
-echo "Test #4: 6->5, prompt"
-rm kkk
-$JM/bin/keytool -keystore kkk -genkey -dname CN=olala
-$J5/bin/keytool -keystore kkk -list
-echo $PASS| $JM/bin/keytool -keystore kkk -list
-echo $PASS| $J5/bin/keytool -keystore kkk -list
-echo "Test #5: 5->6, pipe"
-rm kkk
-echo $PASS| $J5/bin/keytool -keystore kkk -genkey -dname CN=olala
-$JM/bin/keytool -keystore kkk -list
-echo $PASS| $J5/bin/keytool -keystore kkk -list
-echo $PASS| $JM/bin/keytool -keystore kkk -list
-rm kkk
+
+rm $KS 2> /dev/null
+$J5/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 5
+$JM/bin/keytool -keystore $KS -list || exit 6
+echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 7
+echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 8
+
+echo "======================================================================="
+echo "Test #4: 6->5, prompt. Please type $PASSW <R> $PASSW <R> <R> $PASSW <R>"
+echo "======================================================================="
+echo
+
+rm $KS 2> /dev/null
+$JM/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 9
+$J5/bin/keytool -keystore $KS -list || exit 10
+echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 11
+echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 12
+
+echo "==========================================="
+echo "Test #5: 5->6, pipe. Please type $PASSW <R>"
+echo "==========================================="
+echo
+
+rm $KS 2> /dev/null
+echo $PASSW| $J5/bin/keytool -keystore $KS -genkey -dname CN=olala || exit 13
+$JM/bin/keytool -keystore $KS -list || exit 14
+echo $PASSW| $J5/bin/keytool -keystore $KS -list || exit 15
+echo $PASSW| $JM/bin/keytool -keystore $KS -list || exit 16
+
+rm $KS 2> /dev/null
+
+echo
+echo "Success"
exit 0