提交 010ee870 编写于 作者: L lana

Merge

...@@ -131,6 +131,7 @@ CORE_PKGS = \ ...@@ -131,6 +131,7 @@ CORE_PKGS = \
java.util.concurrent \ java.util.concurrent \
java.util.concurrent.atomic \ java.util.concurrent.atomic \
java.util.concurrent.locks \ java.util.concurrent.locks \
java.util.function \
java.util.jar \ java.util.jar \
java.util.logging \ java.util.logging \
java.util.prefs \ java.util.prefs \
......
...@@ -147,6 +147,7 @@ JAVA_JAVA_java = \ ...@@ -147,6 +147,7 @@ JAVA_JAVA_java = \
java/lang/ref/PhantomReference.java \ java/lang/ref/PhantomReference.java \
java/lang/ref/ReferenceQueue.java \ java/lang/ref/ReferenceQueue.java \
java/lang/ref/Finalizer.java \ java/lang/ref/Finalizer.java \
java/util/Base64.java \
java/util/BitSet.java \ java/util/BitSet.java \
java/util/Calendar.java \ java/util/Calendar.java \
java/util/GregorianCalendar.java \ java/util/GregorianCalendar.java \
......
...@@ -37,6 +37,8 @@ SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true ...@@ -37,6 +37,8 @@ SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
JAVAC_MAX_WARNINGS=true JAVAC_MAX_WARNINGS=true
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
AUTO_FILES_JAVA_DIRS = java/util/function
# windows compiler flags # windows compiler flags
ifeq ($(PLATFORM),windows) ifeq ($(PLATFORM),windows)
OTHER_CFLAGS = OTHER_CFLAGS =
......
...@@ -77,6 +77,7 @@ ifeq ($(PLATFORM), windows) ...@@ -77,6 +77,7 @@ ifeq ($(PLATFORM), windows)
FILES_export += java/net/DualStackPlainSocketImpl.java FILES_export += java/net/DualStackPlainSocketImpl.java
FILES_export += java/net/TwoStacksPlainDatagramSocketImpl.java FILES_export += java/net/TwoStacksPlainDatagramSocketImpl.java
FILES_export += java/net/DualStackPlainDatagramSocketImpl.java FILES_export += java/net/DualStackPlainDatagramSocketImpl.java
FILES_export += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java
else else
FILES_export += java/net/PlainDatagramSocketImpl.java FILES_export += java/net/PlainDatagramSocketImpl.java
endif endif
......
...@@ -69,6 +69,7 @@ FILES_java += \ ...@@ -69,6 +69,7 @@ FILES_java += \
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\ \
sun/nio/fs/GnomeFileTypeDetector.java \ sun/nio/fs/GnomeFileTypeDetector.java \
sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/PollingWatchService.java \ sun/nio/fs/PollingWatchService.java \
sun/nio/fs/SolarisAclFileAttributeView.java \ sun/nio/fs/SolarisAclFileAttributeView.java \
sun/nio/fs/SolarisFileStore.java \ sun/nio/fs/SolarisFileStore.java \
...@@ -202,6 +203,8 @@ FILES_java += \ ...@@ -202,6 +203,8 @@ FILES_java += \
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\ \
sun/nio/fs/GnomeFileTypeDetector.java \ sun/nio/fs/GnomeFileTypeDetector.java \
sun/nio/fs/MagicFileTypeDetector.java \
sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/LinuxDosFileAttributeView.java \ sun/nio/fs/LinuxDosFileAttributeView.java \
sun/nio/fs/LinuxFileStore.java \ sun/nio/fs/LinuxFileStore.java \
sun/nio/fs/LinuxFileSystem.java \ sun/nio/fs/LinuxFileSystem.java \
...@@ -239,6 +242,7 @@ FILES_c += \ ...@@ -239,6 +242,7 @@ FILES_c += \
UnixAsynchronousSocketChannelImpl.c \ UnixAsynchronousSocketChannelImpl.c \
\ \
GnomeFileTypeDetector.c \ GnomeFileTypeDetector.c \
MagicFileTypeDetector.c \
LinuxNativeDispatcher.c \ LinuxNativeDispatcher.c \
LinuxWatchService.c \ LinuxWatchService.c \
UnixCopyFile.c \ UnixCopyFile.c \
...@@ -254,6 +258,7 @@ FILES_export += \ ...@@ -254,6 +258,7 @@ FILES_export += \
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\ \
sun/nio/fs/GnomeFileTypeDetector.java \ sun/nio/fs/GnomeFileTypeDetector.java \
sun/nio/fs/MagicFileTypeDetector.java \
sun/nio/fs/LinuxNativeDispatcher.java \ sun/nio/fs/LinuxNativeDispatcher.java \
sun/nio/fs/LinuxWatchService.java \ sun/nio/fs/LinuxWatchService.java \
sun/nio/fs/UnixCopyFile.java \ sun/nio/fs/UnixCopyFile.java \
...@@ -277,6 +282,7 @@ FILES_java += \ ...@@ -277,6 +282,7 @@ FILES_java += \
sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
\ \
sun/nio/fs/MimeTypesFileTypeDetector.java \
sun/nio/fs/BsdFileStore.java \ sun/nio/fs/BsdFileStore.java \
sun/nio/fs/BsdFileSystem.java \ sun/nio/fs/BsdFileSystem.java \
sun/nio/fs/BsdFileSystemProvider.java \ sun/nio/fs/BsdFileSystemProvider.java \
......
...@@ -130,6 +130,8 @@ SUNWprivate_1.1 { ...@@ -130,6 +130,8 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio; Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs; Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs; 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_eventSize;
Java_sun_nio_fs_LinuxWatchService_eventOffsets; Java_sun_nio_fs_LinuxWatchService_eventOffsets;
Java_sun_nio_fs_LinuxWatchService_inotifyInit; Java_sun_nio_fs_LinuxWatchService_inotifyInit;
......
...@@ -86,7 +86,6 @@ jprt.make.rule.core.test.targets= \ ...@@ -86,7 +86,6 @@ jprt.make.rule.core.test.targets= \
${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \ ${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \
${jprt.my.test.target.set:TESTNAME=jdk_text}, \ ${jprt.my.test.target.set:TESTNAME=jdk_text}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools}, \ ${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_jfr}, \
${jprt.my.test.target.set:TESTNAME=jdk_other} ${jprt.my.test.target.set:TESTNAME=jdk_other}
...@@ -103,6 +102,7 @@ jprt.make.rule.all.test.targets= \ ...@@ -103,6 +102,7 @@ jprt.make.rule.all.test.targets= \
${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \ ${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \
${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \ ${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \
${jprt.my.test.target.set:TESTNAME=jdk_beans3}, \ ${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_sound}, \
${jprt.my.test.target.set:TESTNAME=jdk_swing} ${jprt.my.test.target.set:TESTNAME=jdk_swing}
......
...@@ -121,6 +121,7 @@ ifneq ($(OPENJDK_TARGET_OS),linux) ...@@ -121,6 +121,7 @@ ifneq ($(OPENJDK_TARGET_OS),linux)
sun/nio/fs/LinuxFileStore.java \ sun/nio/fs/LinuxFileStore.java \
sun/nio/fs/LinuxFileSystem.java \ sun/nio/fs/LinuxFileSystem.java \
sun/nio/fs/LinuxFileSystemProvider.java \ sun/nio/fs/LinuxFileSystemProvider.java \
sun/nio/fs/MagicFileTypeDetector.java \
sun/nio/fs/LinuxNativeDispatcher.java \ sun/nio/fs/LinuxNativeDispatcher.java \
sun/nio/fs/LinuxUserDefinedFileAttributeView.java \ sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
sun/nio/fs/LinuxWatchService.java sun/nio/fs/LinuxWatchService.java
......
...@@ -1897,6 +1897,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) ...@@ -1897,6 +1897,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux)
UnixAsynchronousServerSocketChannelImpl.c \ UnixAsynchronousServerSocketChannelImpl.c \
UnixAsynchronousSocketChannelImpl.c \ UnixAsynchronousSocketChannelImpl.c \
GnomeFileTypeDetector.c \ GnomeFileTypeDetector.c \
MagicFileTypeDetector.c \
LinuxNativeDispatcher.c \ LinuxNativeDispatcher.c \
LinuxWatchService.c \ LinuxWatchService.c \
UnixCopyFile.c \ UnixCopyFile.c \
......
...@@ -130,6 +130,8 @@ SUNWprivate_1.1 { ...@@ -130,6 +130,8 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio; Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs; Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs; 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_eventSize;
Java_sun_nio_fs_LinuxWatchService_eventOffsets; Java_sun_nio_fs_LinuxWatchService_eventOffsets;
Java_sun_nio_fs_LinuxWatchService_inotifyInit; Java_sun_nio_fs_LinuxWatchService_inotifyInit;
......
...@@ -714,7 +714,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel { ...@@ -714,7 +714,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"PopupMenu.font", menuFont, "PopupMenu.font", menuFont,
"PopupMenu.background", menuBackgroundColor, "PopupMenu.background", menuBackgroundColor,
"PopupMenu.translucentBackground", translucentWhite, // Fix for 7154516: make popups opaque
"PopupMenu.translucentBackground", white,
"PopupMenu.foreground", menuForegroundColor, "PopupMenu.foreground", menuForegroundColor,
"PopupMenu.selectionBackground", menuSelectedBackgroundColor, "PopupMenu.selectionBackground", menuSelectedBackgroundColor,
"PopupMenu.selectionForeground", menuSelectedForegroundColor, "PopupMenu.selectionForeground", menuSelectedForegroundColor,
......
...@@ -31,13 +31,16 @@ import java.awt.image.*; ...@@ -31,13 +31,16 @@ import java.awt.image.*;
import sun.java2d.SurfaceData; import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer; import sun.java2d.opengl.CGLLayer;
import sun.lwawt.LWGraphicsConfig;
import sun.lwawt.macosx.CPlatformView; import sun.lwawt.macosx.CPlatformView;
public class CGraphicsConfig extends GraphicsConfiguration { public abstract class CGraphicsConfig extends GraphicsConfiguration
implements LWGraphicsConfig {
private final CGraphicsDevice device; private final CGraphicsDevice device;
private ColorModel colorModel; private ColorModel colorModel;
public CGraphicsConfig(CGraphicsDevice device) { protected CGraphicsConfig(CGraphicsDevice device) {
this.device = device; this.device = device;
} }
...@@ -84,88 +87,20 @@ public class CGraphicsConfig extends GraphicsConfiguration { ...@@ -84,88 +87,20 @@ public class CGraphicsConfig extends GraphicsConfiguration {
return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0); 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 * Creates a new SurfaceData that will be associated with the given
* LWWindowPeer. * LWWindowPeer.
*/ */
public SurfaceData createSurfaceData(CPlatformView pView) { public abstract SurfaceData createSurfaceData(CPlatformView pView);
throw new UnsupportedOperationException("not implemented");
}
/** /**
* Creates a new SurfaceData that will be associated with the given * Creates a new SurfaceData that will be associated with the given
* CGLLayer. * CGLLayer.
*/ */
public SurfaceData createSurfaceData(CGLLayer layer) { public abstract 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");
}
@Override @Override
public boolean isTranslucencyCapable() { public final boolean isTranslucencyCapable() {
//we know for sure we have capable config :) //we know for sure we have capable config :)
return true; return true;
} }
......
...@@ -27,7 +27,6 @@ package sun.java2d.opengl; ...@@ -27,7 +27,6 @@ package sun.java2d.opengl;
import java.awt.AWTException; import java.awt.AWTException;
import java.awt.BufferCapabilities; import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
...@@ -48,13 +47,10 @@ import java.awt.image.WritableRaster; ...@@ -48,13 +47,10 @@ import java.awt.image.WritableRaster;
import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice; import sun.awt.CGraphicsDevice;
import sun.awt.TextureSizeConstraining;
import sun.awt.image.OffScreenImage; import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage; import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
import sun.java2d.Disposer; import sun.java2d.Disposer;
import sun.java2d.DisposerRecord; import sun.java2d.DisposerRecord;
import sun.java2d.SunGraphics2D;
import sun.java2d.Surface; import sun.java2d.Surface;
import sun.java2d.SurfaceData; import sun.java2d.SurfaceData;
import sun.java2d.opengl.OGLContext.OGLContextCaps; import sun.java2d.opengl.OGLContext.OGLContextCaps;
...@@ -63,18 +59,19 @@ import sun.java2d.pipe.hw.AccelTypedVolatileImage; ...@@ -63,18 +59,19 @@ import sun.java2d.pipe.hw.AccelTypedVolatileImage;
import sun.java2d.pipe.hw.ContextCapabilities; import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.opengl.OGLSurfaceData.*; import static sun.java2d.opengl.OGLSurfaceData.*;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData;
import sun.java2d.pipe.hw.AccelDeviceEventListener; import sun.java2d.pipe.hw.AccelDeviceEventListener;
import sun.java2d.pipe.hw.AccelDeviceEventNotifier; import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.macosx.CPlatformView; import sun.lwawt.macosx.CPlatformView;
public class CGLGraphicsConfig extends CGraphicsConfig public final class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig, TextureSizeConstraining 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 private static final int kOpenGLSwapInterval = 0; // TODO
protected static boolean cglAvailable; private static boolean cglAvailable;
private static ImageCapabilities imageCaps = new CGLImageCaps(); private static ImageCapabilities imageCaps = new CGLImageCaps();
private int pixfmt; private int pixfmt;
...@@ -82,7 +79,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -82,7 +79,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig
private long pConfigInfo; private long pConfigInfo;
private ContextCapabilities oglCaps; private ContextCapabilities oglCaps;
private OGLContext context; private OGLContext context;
private Object disposerReferent = new Object(); private final Object disposerReferent = new Object();
public static native int getDefaultPixFmt(int screennum); public static native int getDefaultPixFmt(int screennum);
private static native boolean initCGL(); private static native boolean initCGL();
...@@ -94,7 +91,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -94,7 +91,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig
cglAvailable = initCGL(); cglAvailable = initCGL();
} }
protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt, private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
long configInfo, ContextCapabilities oglCaps) long configInfo, ContextCapabilities oglCaps)
{ {
super(device); super(device);
...@@ -170,11 +167,13 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -170,11 +167,13 @@ public class CGLGraphicsConfig extends CGraphicsConfig
* Returns true if the provided capability bit is present for this config. * Returns true if the provided capability bit is present for this config.
* See OGLContext.java for a list of supported capabilities. * 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); return ((oglCaps.getCaps() & cap) != 0);
} }
public final long getNativeConfigInfo() { @Override
public long getNativeConfigInfo() {
return pConfigInfo; return pConfigInfo;
} }
...@@ -183,7 +182,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -183,7 +182,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig
* *
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext * @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/ */
public final OGLContext getContext() { @Override
public OGLContext getContext() {
return context; return context;
} }
...@@ -257,145 +257,83 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -257,145 +257,83 @@ public class CGLGraphicsConfig extends CGraphicsConfig
return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]"); 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 @Override
public SurfaceData createSurfaceData(CPlatformView pView) { public SurfaceData createSurfaceData(CPlatformView pView) {
return CGLSurfaceData.createData(pView); return CGLSurfaceData.createData(pView);
} }
/**
* Creates a new SurfaceData that will be associated with the given
* CGLLayer.
*/
@Override @Override
public SurfaceData createSurfaceData(CGLLayer layer) { public SurfaceData createSurfaceData(CGLLayer layer) {
return CGLSurfaceData.createData(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 @Override
public Image createAcceleratedImage(Component target, public Image createAcceleratedImage(Component target,
int width, int height) int width, int height)
{ {
ColorModel model = getColorModel(Transparency.OPAQUE); ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr = WritableRaster wr = model.createCompatibleWritableRaster(width, height);
model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr, return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied()); 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 @Override
public long createBackBuffer(CPlatformView pView, public void assertOperationSupported(final int numBuffers,
int numBuffers, BufferCapabilities caps) final BufferCapabilities caps)
throws AWTException throws AWTException {
{ // Assume this method is never called with numBuffers != 2, as 0 is
if (numBuffers > 2) { // unsupported, and 1 corresponds to a SingleBufferStrategy which
throw new AWTException( // doesn't depend on the peer. Screen is considered as a separate
"Only double or single buffering is supported"); // "buffer".
if (numBuffers != 2) {
throw new AWTException("Only double buffering is supported");
} }
BufferCapabilities configCaps = getBufferCapabilities(); final BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) { if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported"); throw new AWTException("Page flipping is not supported");
} }
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) { if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported"); 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 @Override
public void destroyBackBuffer(long backBuffer) { 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);
} }
/**
* Creates a VolatileImage that essentially wraps the target Component's
* backbuffer (the provided backbuffer handle is essentially ignored).
*/
@Override @Override
public VolatileImage createBackBufferImage(Component target, public void destroyBackBuffer(final Image backBuffer) {
long backBuffer) if (backBuffer != null) {
{ backBuffer.flush();
return new SunVolatileImage(target, }
target.getWidth(), target.getHeight(),
Boolean.TRUE);
} }
/**
* Performs the native OGL flip operation for the given target Component.
*/
@Override @Override
public void flip(CPlatformView pView, public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
Component target, VolatileImage xBackBuffer, final int x1, final int y1, final int x2, final int y2,
int x1, int y1, int x2, int y2, final BufferCapabilities.FlipContents flipAction) {
BufferCapabilities.FlipContents flipAction) final Graphics g = peer.getGraphics();
{ try {
if (flipAction == BufferCapabilities.FlipContents.COPIED) { g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer); } finally {
SurfaceData sd = vsm.getPrimarySurfaceData(); g.dispose();
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;
} }
OGLSurfaceData.swapBuffers(pView.getAWTView());
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) { if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
Graphics g = xBackBuffer.getGraphics(); final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
try { try {
g.setColor(target.getBackground()); bg.setBackground(peer.getBackground());
g.fillRect(0, 0, bg.clearRect(0, 0, backBuffer.getWidth(null),
xBackBuffer.getWidth(), backBuffer.getHeight(null));
xBackBuffer.getHeight());
} finally { } finally {
g.dispose(); bg.dispose();
} }
} }
} }
...@@ -429,15 +367,10 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -429,15 +367,10 @@ public class CGLGraphicsConfig extends CGraphicsConfig
return imageCaps; return imageCaps;
} }
/** @Override
* {@inheritDoc} public VolatileImage createCompatibleVolatileImage(int width, int height,
* int transparency,
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage int type) {
*/
public VolatileImage
createCompatibleVolatileImage(int width, int height,
int transparency, int type)
{
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
transparency == Transparency.BITMASK) transparency == Transparency.BITMASK)
{ {
...@@ -473,15 +406,18 @@ public class CGLGraphicsConfig extends CGraphicsConfig ...@@ -473,15 +406,18 @@ public class CGLGraphicsConfig extends CGraphicsConfig
* *
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities * @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/ */
@Override
public ContextCapabilities getContextCapabilities() { public ContextCapabilities getContextCapabilities() {
return oglCaps; return oglCaps;
} }
@Override
public void addDeviceEventListener(AccelDeviceEventListener l) { public void addDeviceEventListener(AccelDeviceEventListener l) {
int screen = getDevice().getCoreGraphicsScreen(); int screen = getDevice().getCoreGraphicsScreen();
AccelDeviceEventNotifier.addListener(l, screen); AccelDeviceEventNotifier.addListener(l, screen);
} }
@Override
public void removeDeviceEventListener(AccelDeviceEventListener l) { public void removeDeviceEventListener(AccelDeviceEventListener l) {
AccelDeviceEventNotifier.removeListener(l); AccelDeviceEventNotifier.removeListener(l);
} }
......
...@@ -26,12 +26,9 @@ ...@@ -26,12 +26,9 @@
package sun.lwawt; package sun.lwawt;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GraphicsConfiguration; import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.peer.CanvasPeer; import java.awt.peer.CanvasPeer;
import javax.swing.JComponent; import javax.swing.JComponent;
...@@ -42,35 +39,10 @@ class LWCanvasPeer<T extends Component, D extends JComponent> ...@@ -42,35 +39,10 @@ class LWCanvasPeer<T extends Component, D extends JComponent>
LWCanvasPeer(final T target, final PlatformComponent platformComponent) { LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
super(target, 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 @Override
public final GraphicsConfiguration getAppropriateGraphicsConfiguration( public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
GraphicsConfiguration gc) final GraphicsConfiguration gc) {
{
// TODO // TODO
return gc; return gc;
} }
......
...@@ -138,6 +138,11 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -138,6 +138,11 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
*/ */
static final char WIDE_CHAR = '0'; static final char WIDE_CHAR = '0';
/**
* The back buffer provide user with a BufferStrategy.
*/
private Image backBuffer;
private final class DelegateContainer extends Container { private final class DelegateContainer extends Container {
{ {
enableEvents(0xFFFFFFFF); enableEvents(0xFFFFFFFF);
...@@ -389,6 +394,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -389,6 +394,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
} }
protected void disposeImpl() { protected void disposeImpl() {
destroyBuffers();
LWContainerPeer cp = getContainerPeer(); LWContainerPeer cp = getContainerPeer();
if (cp != null) { if (cp != null) {
cp.removeChildPeer(this); cp.removeChildPeer(this);
...@@ -415,6 +421,12 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -415,6 +421,12 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return getWindowPeer().getGraphicsConfiguration(); return getWindowPeer().getGraphicsConfiguration();
} }
// Just a helper method
public final LWGraphicsConfig getLWGC() {
return (LWGraphicsConfig) getGraphicsConfiguration();
}
/* /*
* Overridden in LWWindowPeer to replace its surface * Overridden in LWWindowPeer to replace its surface
* data and back buffer. * data and back buffer.
...@@ -506,31 +518,45 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -506,31 +518,45 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return getGraphicsConfiguration().getColorModel(); return getGraphicsConfiguration().getColorModel();
} }
public boolean isTranslucent() {
// Translucent windows of the top level are supported only
return false;
}
@Override @Override
public void createBuffers(int numBuffers, BufferCapabilities caps) public final void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException { throws AWTException {
throw new AWTException("Back buffers are only supported for " + getLWGC().assertOperationSupported(numBuffers, caps);
"Window or Canvas components."); final Image buffer = getLWGC().createBackBuffer(this);
synchronized (getStateLock()) {
backBuffer = buffer;
}
} }
/*
* To be overridden in LWWindowPeer and LWCanvasPeer.
*/
@Override @Override
public Image getBackBuffer() { public final Image getBackBuffer() {
// Return null or throw AWTException? synchronized (getStateLock()) {
return null; if (backBuffer != null) {
return backBuffer;
}
}
throw new IllegalStateException("Buffers have not been created");
} }
@Override @Override
public void flip(int x1, int y1, int x2, int y2, public final void flip(int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction) { BufferCapabilities.FlipContents flipAction) {
// Skip silently or throw AWTException? getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction);
} }
@Override @Override
public void destroyBuffers() { public final void destroyBuffers() {
// Do nothing final Image oldBB;
synchronized (getStateLock()) {
oldBB = backBuffer;
backBuffer = null;
}
getLWGC().destroyBackBuffer(oldBB);
} }
// Helper method // Helper method
...@@ -642,7 +668,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -642,7 +668,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
} }
} }
protected final Color getBackground() { public final Color getBackground() {
synchronized (getStateLock()) { synchronized (getStateLock()) {
return background; return background;
} }
...@@ -982,19 +1008,17 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -982,19 +1008,17 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
} }
@Override @Override
public Image createImage(ImageProducer producer) { public final Image createImage(final ImageProducer producer) {
return new ToolkitImage(producer); return new ToolkitImage(producer);
} }
@Override @Override
public Image createImage(int w, int h) { public final Image createImage(final int width, final int height) {
CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration(); return getLWGC().createAcceleratedImage(getTarget(), width, height);
return gc.createAcceleratedImage(getTarget(), w, h);
} }
@Override @Override
public VolatileImage createVolatileImage(int w, int h) { public final VolatileImage createVolatileImage(final int w, final int h) {
// TODO: is it a right/complete implementation?
return new SunVolatileImage(getTarget(), w, h); return new SunVolatileImage(getTarget(), w, h);
} }
...@@ -1105,8 +1129,6 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -1105,8 +1129,6 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* of target.setLocation() or as a result of user actions (window is * of target.setLocation() or as a result of user actions (window is
* dragged with mouse). * dragged with mouse).
* *
* To be overridden in LWWindowPeer to update its GraphicsConfig.
*
* This method could be called on the toolkit thread. * This method could be called on the toolkit thread.
*/ */
protected final void handleMove(final int x, final int y, protected final void handleMove(final int x, final int y,
...@@ -1122,13 +1144,19 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -1122,13 +1144,19 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* Called when this peer's size has been changed either as a result of * 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). * 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. * This method could be called on the toolkit thread.
*/ */
protected final void handleResize(final int w, final int h, protected final void handleResize(final int w, final int h,
final boolean updateTarget) { final boolean updateTarget) {
Image oldBB = null;
synchronized (getStateLock()) {
if (backBuffer != null) {
oldBB = backBuffer;
backBuffer = getLWGC().createBackBuffer(this);
}
}
getLWGC().destroyBackBuffer(oldBB);
if (updateTarget) { if (updateTarget) {
AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h); AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
} }
......
/*
* 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);
}
...@@ -27,7 +27,6 @@ package sun.lwawt; ...@@ -27,7 +27,6 @@ package sun.lwawt;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.awt.peer.*; import java.awt.peer.*;
import java.util.List; import java.util.List;
...@@ -75,17 +74,6 @@ public class LWWindowPeer ...@@ -75,17 +74,6 @@ public class LWWindowPeer
private SurfaceData surfaceData; private SurfaceData surfaceData;
private final Object surfaceDataLock = new Object(); 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; private volatile int windowState = Frame.NORMAL;
// check that the mouse is over the window // check that the mouse is over the window
...@@ -227,7 +215,6 @@ public class LWWindowPeer ...@@ -227,7 +215,6 @@ public class LWWindowPeer
if (isGrabbing()) { if (isGrabbing()) {
ungrab(); ungrab();
} }
destroyBuffers();
platformWindow.dispose(); platformWindow.dispose();
super.disposeImpl(); super.disposeImpl();
} }
...@@ -258,8 +245,10 @@ public class LWWindowPeer ...@@ -258,8 +245,10 @@ public class LWWindowPeer
} }
@Override @Override
public GraphicsConfiguration getGraphicsConfiguration() { public final GraphicsConfiguration getGraphicsConfiguration() {
return graphicsConfig; synchronized (getStateLock()) {
return graphicsConfig;
}
} }
@Override @Override
...@@ -284,48 +273,6 @@ public class LWWindowPeer ...@@ -284,48 +273,6 @@ public class LWWindowPeer
return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f)); return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
} }
@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 @Override
public void setBounds(int x, int y, int w, int h, int op) { public void setBounds(int x, int y, int w, int h, int op) {
if ((op & SET_CLIENT_SIZE) != 0) { if ((op & SET_CLIENT_SIZE) != 0) {
...@@ -343,16 +290,14 @@ public class LWWindowPeer ...@@ -343,16 +290,14 @@ public class LWWindowPeer
h = MINIMUM_HEIGHT; h = MINIMUM_HEIGHT;
} }
if (graphicsConfig instanceof TextureSizeConstraining) { final int maxW = getLWGC().getMaxTextureWidth();
final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth(); final int maxH = getLWGC().getMaxTextureHeight();
final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
if (w > maxW) { if (w > maxW) {
w = maxW; w = maxW;
} }
if (h > maxH) { if (h > maxH) {
h = maxH; h = maxH;
}
} }
// Don't post ComponentMoved/Resized and Paint events // Don't post ComponentMoved/Resized and Paint events
...@@ -431,21 +376,14 @@ public class LWWindowPeer ...@@ -431,21 +376,14 @@ public class LWWindowPeer
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT); 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; final Dimension max;
if (getTarget().isMaximumSizeSet()) { if (getTarget().isMaximumSizeSet()) {
max = getTarget().getMaximumSize(); max = getTarget().getMaximumSize();
max.width = Math.min(max.width, maxW); max.width = Math.min(max.width, getLWGC().getMaxTextureWidth());
max.height = Math.min(max.height, maxH); max.height = Math.min(max.height, getLWGC().getMaxTextureHeight());
} else { } else {
max = new Dimension(maxW, maxH); max = new Dimension(getLWGC().getMaxTextureWidth(),
getLWGC().getMaxTextureHeight());
} }
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height); platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
...@@ -1014,21 +952,10 @@ public class LWWindowPeer ...@@ -1014,21 +952,10 @@ public class LWWindowPeer
replaceSurfaceData(true); replaceSurfaceData(true);
} }
private void replaceSurfaceData(boolean blit) { private void replaceSurfaceData(final boolean blit) {
replaceSurfaceData(backBufferCount, backBufferCaps, blit);
}
private void replaceSurfaceData(int newBackBufferCount,
BufferCapabilities newBackBufferCaps,
boolean blit) {
synchronized (surfaceDataLock) { synchronized (surfaceDataLock) {
final SurfaceData oldData = getSurfaceData(); final SurfaceData oldData = getSurfaceData();
surfaceData = platformWindow.replaceSurfaceData(); surfaceData = platformWindow.replaceSurfaceData();
// TODO: volatile image
// VolatileImage oldBB = backBuffer;
BufferedImage oldBB = backBuffer;
backBufferCount = newBackBufferCount;
backBufferCaps = newBackBufferCaps;
final Rectangle size = getSize(); final Rectangle size = getSize();
if (getSurfaceData() != null && oldData != getSurfaceData()) { if (getSurfaceData() != null && oldData != getSurfaceData()) {
clearBackground(size.width, size.height); clearBackground(size.width, size.height);
...@@ -1043,35 +970,6 @@ public class LWWindowPeer ...@@ -1043,35 +970,6 @@ public class LWWindowPeer
// This can only happen when this peer is being created // This can only happen when this peer is being created
oldData.flush(); 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 class LWWindowPeer ...@@ -1092,14 +990,6 @@ public class LWWindowPeer
} }
} }
public int getBackBufferCount() {
return backBufferCount;
}
public BufferCapabilities getBackBufferCaps() {
return backBufferCaps;
}
/* /*
* Request the window insets from the delegate and compares it * Request the window insets from the delegate and compares it
* with the current one. This method is mostly called by the * with the current one. This method is mostly called by the
......
...@@ -97,17 +97,6 @@ public interface PlatformWindow { ...@@ -97,17 +97,6 @@ public interface PlatformWindow {
*/ */
public SurfaceData replaceSurfaceData(); 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 setModalBlocked(boolean blocked);
public void toFront(); public void toFront();
......
...@@ -31,12 +31,9 @@ import sun.lwawt.LWWindowPeer; ...@@ -31,12 +31,9 @@ import sun.lwawt.LWWindowPeer;
import sun.java2d.opengl.CGLLayer; import sun.java2d.opengl.CGLLayer;
import sun.java2d.SurfaceData; import sun.java2d.SurfaceData;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
import sun.awt.CausedFocusEvent; import sun.awt.CausedFocusEvent;
import java.awt.*; import java.awt.*;
import java.awt.BufferCapabilities.FlipContents;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
...@@ -112,22 +109,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow { ...@@ -112,22 +109,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
return windowLayer.replaceSurfaceData(); return windowLayer.replaceSurfaceData();
} }
@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 @Override
public void setVisible(boolean visible) {} public void setVisible(boolean visible) {}
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.*; import java.awt.*;
import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsConfig;
import sun.lwawt.LWWindowPeer; import sun.lwawt.LWWindowPeer;
...@@ -115,26 +114,6 @@ public class CPlatformView extends CFRetainedResource { ...@@ -115,26 +114,6 @@ public class CPlatformView extends CFRetainedResource {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// PAINTING METHODS // 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() { public SurfaceData replaceSurfaceData() {
if (!LWCToolkit.getSunAwtDisableCALayers()) { if (!LWCToolkit.getSunAwtDisableCALayers()) {
surfaceData = windowLayer.replaceSurfaceData(); surfaceData = windowLayer.replaceSurfaceData();
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.*; import java.awt.*;
import java.awt.Dialog.ModalityType; import java.awt.Dialog.ModalityType;
import java.awt.event.*; import java.awt.event.*;
...@@ -258,7 +257,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -258,7 +257,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
validateSurface(); validateSurface();
} }
protected int getInitialStyleBits() { private int getInitialStyleBits() {
// defaults style bits // defaults style bits
int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
...@@ -285,7 +284,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -285,7 +284,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
styleBits = SET(styleBits, RESIZABLE, resizable); styleBits = SET(styleBits, RESIZABLE, resizable);
if (!resizable) { if (!resizable) {
styleBits = SET(styleBits, RESIZABLE, false);
styleBits = SET(styleBits, ZOOMABLE, false); styleBits = SET(styleBits, ZOOMABLE, false);
} }
} }
...@@ -380,7 +378,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -380,7 +378,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
} }
// this is the counter-point to -[CWindow _nativeSetStyleBit:] // 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); nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
} }
...@@ -401,11 +399,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -401,11 +399,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
} }
} }
@Override // PlatformWindow
public Image createBackBuffer() {
return contentView.createBackBuffer();
}
@Override // PlatformWindow @Override // PlatformWindow
public void dispose() { public void dispose() {
if (owner != null) { if (owner != null) {
...@@ -416,12 +409,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -416,12 +409,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
CPlatformWindow.super.dispose(); CPlatformWindow.super.dispose();
} }
@Override // PlatformWindow
public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
// TODO: not implemented
(new RuntimeException("unimplemented")).printStackTrace();
}
@Override // PlatformWindow @Override // PlatformWindow
public FontMetrics getFontMetrics(Font f) { public FontMetrics getFontMetrics(Font f) {
// TODO: not implemented // TODO: not implemented
...@@ -668,15 +655,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -668,15 +655,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
} }
@Override @Override
public void setResizable(boolean resizable) { public void setResizable(final boolean resizable) {
setStyleBits(RESIZABLE, 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 @Override
...@@ -889,7 +869,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -889,7 +869,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
responder.handleWindowFocusEvent(gained, oppositePeer); 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 // when the content view enters the full-screen mode, the native
// move/resize notifications contain a bounds smaller than // move/resize notifications contain a bounds smaller than
// the whole screen and therefore we ignore the native notifications // the whole screen and therefore we ignore the native notifications
...@@ -901,7 +882,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor ...@@ -901,7 +882,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
final Rectangle oldB = nativeBounds; final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height); nativeBounds = new Rectangle(x, y, width, height);
peer.notifyReshape(x, y, width, height); peer.notifyReshape(x, y, width, height);
if (!oldB.getSize().equals(nativeBounds.getSize()) ) { if (byUser && !oldB.getSize().equals(nativeBounds.getSize())) {
flushBuffers(); flushBuffers();
} }
//TODO validateSurface already called from notifyReshape //TODO validateSurface already called from notifyReshape
......
...@@ -160,6 +160,10 @@ AWT_NS_WINDOW_IMPLEMENTATION ...@@ -160,6 +160,10 @@ AWT_NS_WINDOW_IMPLEMENTATION
BOOL resizable = IS(bits, RESIZABLE); BOOL resizable = IS(bits, RESIZABLE);
[self updateMinMaxSize:resizable]; [self updateMinMaxSize:resizable];
[self.nsWindow setShowsResizeIndicator: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)) { if (IS(mask, HAS_SHADOW)) {
...@@ -445,12 +449,13 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -445,12 +449,13 @@ AWT_ASSERT_APPKIT_THREAD;
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); 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, JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
(jint)frame.origin.x, (jint)frame.origin.x,
(jint)frame.origin.y, (jint)frame.origin.y,
(jint)frame.size.width, (jint)frame.size.width,
(jint)frame.size.height); (jint)frame.size.height,
(jboolean)[self.nsWindow inLiveResize]);
(*env)->DeleteLocalRef(env, platformWindow); (*env)->DeleteLocalRef(env, platformWindow);
} }
...@@ -784,7 +789,7 @@ AWT_ASSERT_NOT_APPKIT_THREAD; ...@@ -784,7 +789,7 @@ AWT_ASSERT_NOT_APPKIT_THREAD;
// calls methods on NSWindow to change other properties, based on the mask // calls methods on NSWindow to change other properties, based on the mask
if (mask & MASK(_METHOD_PROP_BITMASK)) { if (mask & MASK(_METHOD_PROP_BITMASK)) {
[window setPropertiesForStyleBits:bits mask:mask]; [window setPropertiesForStyleBits:newBits mask:mask];
} }
window.styleBits = newBits; window.styleBits = newBits;
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "debugLoop.h" #include "debugLoop.h"
#include "bag.h" #include "bag.h"
#include "invoker.h" #include "invoker.h"
#include "sys.h"
/* How the options get to OnLoad: */ /* How the options get to OnLoad: */
#define XDEBUG "-Xdebug" #define XDEBUG "-Xdebug"
...@@ -201,6 +202,8 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) ...@@ -201,6 +202,8 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
jint jvmtiCompileTimeMajorVersion; jint jvmtiCompileTimeMajorVersion;
jint jvmtiCompileTimeMinorVersion; jint jvmtiCompileTimeMinorVersion;
jint jvmtiCompileTimeMicroVersion; jint jvmtiCompileTimeMicroVersion;
char *boot_path = NULL;
char npt_lib[MAXPATHLEN];
/* See if it's already loaded */ /* See if it's already loaded */
if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) { if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) {
...@@ -227,18 +230,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) ...@@ -227,18 +230,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
vmInitialized = JNI_FALSE; vmInitialized = JNI_FALSE;
gdata->vmDead = 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(). */ /* Get the JVMTI Env, IMPORTANT: Do this first! For jvmtiAllocate(). */
error = JVM_FUNC_PTR(vm,GetEnv) error = JVM_FUNC_PTR(vm,GetEnv)
(vm, (void **)&(gdata->jvmti), JVMTI_VERSION_1); (vm, (void **)&(gdata->jvmti), JVMTI_VERSION_1);
...@@ -277,6 +268,24 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) ...@@ -277,6 +268,24 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
forceExit(1); /* Kill entire process, no core dump wanted */ 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 */ /* Parse input options */
if (!parseOptions(options)) { if (!parseOptions(options)) {
/* No message necessary, should have been printed out already */ /* No message necessary, should have been printed out already */
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -70,8 +70,13 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix, ...@@ -70,8 +70,13 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix,
len = (int)strlen((char*)utf8buf); len = (int)strlen((char*)utf8buf);
/* Convert to platform encoding (ignore errors, dangerous area) */ /* Convert to platform encoding (ignore errors, dangerous area) */
(void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, if (gdata->npt != NULL) {
utf8buf, len, pbuf, MAX_MESSAGE_LEN); (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); (void)fprintf(fp, "%s%s%s", prefix, pbuf, suffix);
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -144,7 +144,9 @@ loadTransport(char *name, jdwpTransportEnv **transportPtr) ...@@ -144,7 +144,9 @@ loadTransport(char *name, jdwpTransportEnv **transportPtr)
/* First, look in sun.boot.library.path. This should find the standard /* First, look in sun.boot.library.path. This should find the standard
* dt_socket and dt_shmem transport libraries, or any library * dt_socket and dt_shmem transport libraries, or any library
* that was delivered with the J2SE. * 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; libdir = gdata->property_sun_boot_library_path;
if (libdir == NULL) { if (libdir == NULL) {
......
...@@ -30,14 +30,10 @@ import java.awt.Rectangle; ...@@ -30,14 +30,10 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer; import java.awt.image.DataBuffer;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException; import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.imageio.IIOException; import javax.imageio.IIOException;
...@@ -48,6 +44,11 @@ import javax.imageio.metadata.IIOMetadata; ...@@ -48,6 +44,11 @@ import javax.imageio.metadata.IIOMetadata;
import javax.imageio.spi.ImageReaderSpi; import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.common.ReaderUtil; 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 { public class GIFImageReader extends ImageReader {
...@@ -194,6 +195,36 @@ public class GIFImageReader extends ImageReader { ...@@ -194,6 +195,36 @@ public class GIFImageReader extends ImageReader {
return imageMetadata.imageHeight; 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 { public Iterator getImageTypes(int imageIndex) throws IIOException {
checkIndex(imageIndex); checkIndex(imageIndex);
...@@ -239,22 +270,7 @@ public class GIFImageReader extends ImageReader { ...@@ -239,22 +270,7 @@ public class GIFImageReader extends ImageReader {
b[i] = colorTable[rgbIndex++]; b[i] = colorTable[rgbIndex++];
} }
byte[] a = null; l.add(createIndexed(r, g, b, bits));
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));
return l.iterator(); return l.iterator();
} }
......
...@@ -28,10 +28,6 @@ package com.sun.jmx.snmp; ...@@ -28,10 +28,6 @@ package com.sun.jmx.snmp;
import java.io.Serializable; import java.io.Serializable;
import java.util.Hashtable; 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 * This class is an internal class which is used to represent RowStatus
...@@ -263,30 +259,30 @@ public class EnumRowStatus extends Enumerated implements Serializable { ...@@ -263,30 +259,30 @@ public class EnumRowStatus extends Enumerated implements Serializable {
// Documented in Enumerated // Documented in Enumerated
// //
protected Hashtable getIntTable() { @Override
protected Hashtable<Integer, String> getIntTable() {
return EnumRowStatus.getRSIntTable(); return EnumRowStatus.getRSIntTable();
} }
// Documented in Enumerated // Documented in Enumerated
// //
protected Hashtable getStringTable() { @Override
protected Hashtable<String, Integer> getStringTable() {
return EnumRowStatus.getRSStringTable(); return EnumRowStatus.getRSStringTable();
} }
static final Hashtable getRSIntTable() { static Hashtable<Integer, String> getRSIntTable() {
return intTable ; return intTable ;
} }
static final Hashtable getRSStringTable() { static Hashtable<String, Integer> getRSStringTable() {
return stringTable ; return stringTable ;
} }
// Initialize the mapping tables. // Initialize the mapping tables.
// //
final static Hashtable<Integer, String> intTable = final static Hashtable<Integer, String> intTable = new Hashtable<>();
new Hashtable<Integer, String>(); final static Hashtable<String, Integer> stringTable = new Hashtable<>();
final static Hashtable<String, Integer> stringTable =
new Hashtable<String, Integer>();
static { static {
intTable.put(new Integer(0), "unspecified"); intTable.put(new Integer(0), "unspecified");
intTable.put(new Integer(3), "notReady"); intTable.put(new Integer(3), "notReady");
......
...@@ -54,9 +54,9 @@ abstract public class Enumerated implements Serializable { ...@@ -54,9 +54,9 @@ abstract public class Enumerated implements Serializable {
* @exception IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate. * @exception IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.
*/ */
public Enumerated() throws IllegalArgumentException { public Enumerated() throws IllegalArgumentException {
Enumeration e =getIntTable().keys() ; Enumeration<Integer> e =getIntTable().keys();
if (e.hasMoreElements()) { if (e.hasMoreElements()) {
value = ((Integer)e.nextElement()).intValue() ; value = e.nextElement().intValue() ;
} }
else { else {
throw new IllegalArgumentException() ; throw new IllegalArgumentException() ;
...@@ -100,7 +100,7 @@ abstract public class Enumerated implements Serializable { ...@@ -100,7 +100,7 @@ abstract public class Enumerated implements Serializable {
* to the method is illegal or inappropriate. * to the method is illegal or inappropriate.
*/ */
public Enumerated(String valueString) throws IllegalArgumentException { public Enumerated(String valueString) throws IllegalArgumentException {
Integer index = (Integer)getStringTable().get(valueString) ; Integer index = getStringTable().get(valueString) ;
if (index == null) { if (index == null) {
throw new IllegalArgumentException() ; throw new IllegalArgumentException() ;
} }
...@@ -127,7 +127,7 @@ abstract public class Enumerated implements Serializable { ...@@ -127,7 +127,7 @@ abstract public class Enumerated implements Serializable {
* @return An enumeration of Integer instances * @return An enumeration of Integer instances
*/ */
public Enumeration valueIndexes() { public Enumeration<Integer> valueIndexes() {
return getIntTable().keys() ; return getIntTable().keys() ;
} }
...@@ -138,7 +138,7 @@ abstract public class Enumerated implements Serializable { ...@@ -138,7 +138,7 @@ abstract public class Enumerated implements Serializable {
* @return An enumeration of String instances * @return An enumeration of String instances
*/ */
public Enumeration valueStrings() { public Enumeration<String> valueStrings() {
return getStringTable().keys() ; return getStringTable().keys() ;
} }
...@@ -153,6 +153,7 @@ abstract public class Enumerated implements Serializable { ...@@ -153,6 +153,7 @@ abstract public class Enumerated implements Serializable {
* *
* @return True if this and obj are the same; false otherwise * @return True if this and obj are the same; false otherwise
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return ((obj != null) && return ((obj != null) &&
...@@ -166,6 +167,7 @@ abstract public class Enumerated implements Serializable { ...@@ -166,6 +167,7 @@ abstract public class Enumerated implements Serializable {
* *
* @return A hash code value for this object. * @return A hash code value for this object.
*/ */
@Override
public int hashCode() { public int hashCode() {
String hashString = getClass().getName() + String.valueOf(value) ; String hashString = getClass().getName() + String.valueOf(value) ;
return hashString.hashCode() ; return hashString.hashCode() ;
...@@ -177,9 +179,9 @@ abstract public class Enumerated implements Serializable { ...@@ -177,9 +179,9 @@ abstract public class Enumerated implements Serializable {
* *
* @return The string for for this object. * @return The string for for this object.
*/ */
@Override
public String toString() { public String toString() {
return (String)getIntTable().get(new Integer(value)) ; return getIntTable().get(new Integer(value)) ;
} }
...@@ -193,7 +195,7 @@ abstract public class Enumerated implements Serializable { ...@@ -193,7 +195,7 @@ abstract public class Enumerated implements Serializable {
* @return An hashtable for read-only purpose * @return An hashtable for read-only purpose
*/ */
protected abstract Hashtable getIntTable() ; protected abstract Hashtable<Integer,String> getIntTable() ;
...@@ -207,12 +209,12 @@ abstract public class Enumerated implements Serializable { ...@@ -207,12 +209,12 @@ abstract public class Enumerated implements Serializable {
* @return An hashtable for read-only purpose * @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. * 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 ; protected int value ;
......
...@@ -66,7 +66,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -66,7 +66,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
*/ */
public AclImpl (PrincipalImpl owner, String name) { public AclImpl (PrincipalImpl owner, String name) {
super(owner); super(owner);
entryList = new Vector<AclEntry>(); entryList = new Vector<>();
aclName = name; aclName = name;
} }
...@@ -81,6 +81,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -81,6 +81,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* of this ACL. * of this ACL.
* @see java.security.Principal * @see java.security.Principal
*/ */
@Override
public void setName(Principal caller, String name) public void setName(Principal caller, String name)
throws NotOwnerException { throws NotOwnerException {
if (!isOwner(caller)) if (!isOwner(caller))
...@@ -93,6 +94,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -93,6 +94,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* *
* @return the name of this ACL. * @return the name of this ACL.
*/ */
@Override
public String getName(){ public String getName(){
return aclName; return aclName;
} }
...@@ -113,6 +115,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -113,6 +115,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* this ACL. * this ACL.
* @see java.security.Principal * @see java.security.Principal
*/ */
@Override
public boolean addEntry(Principal caller, AclEntry entry) public boolean addEntry(Principal caller, AclEntry entry)
throws NotOwnerException { throws NotOwnerException {
if (!isOwner(caller)) if (!isOwner(caller))
...@@ -144,6 +147,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -144,6 +147,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* @see java.security.Principal * @see java.security.Principal
* @see java.security.acl.AclEntry * @see java.security.acl.AclEntry
*/ */
@Override
public boolean removeEntry(Principal caller, AclEntry entry) public boolean removeEntry(Principal caller, AclEntry entry)
throws NotOwnerException { throws NotOwnerException {
if (!isOwner(caller)) if (!isOwner(caller))
...@@ -185,8 +189,9 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -185,8 +189,9 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* is allowed. * is allowed.
* @see java.security.Principal * @see java.security.Principal
*/ */
@Override
public Enumeration<Permission> getPermissions(Principal user){ 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();){ for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntry ent = e.nextElement(); AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user)) if (ent.getPrincipal().equals(user))
...@@ -201,6 +206,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -201,6 +206,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* *
* @return an enumeration of the entries in this ACL. * @return an enumeration of the entries in this ACL.
*/ */
@Override
public Enumeration<AclEntry> entries(){ public Enumeration<AclEntry> entries(){
return entryList.elements(); return entryList.elements();
} }
...@@ -221,10 +227,11 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -221,10 +227,11 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* @see java.security.Principal * @see java.security.Principal
* @see java.security.Permission * @see java.security.Permission
*/ */
@Override
public boolean checkPermission(Principal user, public boolean checkPermission(Principal user,
java.security.acl.Permission perm) { java.security.acl.Permission perm) {
for (Enumeration e = entryList.elements();e.hasMoreElements();){ for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntry ent = (AclEntry) e.nextElement(); AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user)) if (ent.getPrincipal().equals(user))
if (ent.checkPermission(perm)) return true; if (ent.checkPermission(perm)) return true;
} }
...@@ -250,7 +257,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -250,7 +257,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
*/ */
public boolean checkPermission(Principal user, String community, public boolean checkPermission(Principal user, String community,
java.security.acl.Permission perm) { 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(); AclEntryImpl ent = (AclEntryImpl) e.nextElement();
if (ent.getPrincipal().equals(user)) if (ent.getPrincipal().equals(user))
if (ent.checkPermission(perm) && ent.checkCommunity(community)) return true; if (ent.checkPermission(perm) && ent.checkCommunity(community)) return true;
...@@ -269,7 +276,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -269,7 +276,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* @see java.security.Permission * @see java.security.Permission
*/ */
public boolean checkCommunity(String community) { 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(); AclEntryImpl ent = (AclEntryImpl) e.nextElement();
if (ent.checkCommunity(community)) return true; if (ent.checkCommunity(community)) return true;
} }
...@@ -281,6 +288,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable { ...@@ -281,6 +288,7 @@ class AclImpl extends OwnerImpl implements Acl, Serializable {
* *
* @return a string representation of the ACL contents. * @return a string representation of the ACL contents.
*/ */
@Override
public String toString(){ public String toString(){
return ("AclImpl: "+ getName()); return ("AclImpl: "+ getName());
} }
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
package com.sun.jmx.snmp.IPAcl; package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector;
class JDMAclBlock extends SimpleNode { class JDMAclBlock extends SimpleNode {
JDMAclBlock(int id) { JDMAclBlock(int id) {
...@@ -51,11 +53,13 @@ class JDMAclBlock extends SimpleNode { ...@@ -51,11 +53,13 @@ class JDMAclBlock extends SimpleNode {
* Do no need to go through this part of the tree for * Do no need to go through this part of the tree for
* building TrapEntry. * 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 * Do no need to go through this part of the tree for
* building InformEntry. * building InformEntry.
*/ */
public void buildInformEntries(Hashtable dest) {} @Override
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
} }
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
package com.sun.jmx.snmp.IPAcl; package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector;
class JDMInformBlock extends SimpleNode { class JDMInformBlock extends SimpleNode {
JDMInformBlock(int id) { JDMInformBlock(int id) {
...@@ -50,11 +52,13 @@ class JDMInformBlock extends SimpleNode { ...@@ -50,11 +52,13 @@ class JDMInformBlock extends SimpleNode {
* Do no need to go through this part of the tree for * Do no need to go through this part of the tree for
* building AclEntry. * building AclEntry.
*/ */
@Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {} public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/** /**
* Do no need to go through this part of the tree for * Do no need to go through this part of the tree for
* building TrapEntry. * building TrapEntry.
*/ */
public void buildTrapEntries(Hashtable dest) {} @Override
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {}
} }
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
package com.sun.jmx.snmp.IPAcl; package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector;
class JDMTrapBlock extends SimpleNode { class JDMTrapBlock extends SimpleNode {
JDMTrapBlock(int id) { JDMTrapBlock(int id) {
...@@ -51,11 +53,13 @@ class JDMTrapBlock extends SimpleNode { ...@@ -51,11 +53,13 @@ class JDMTrapBlock extends SimpleNode {
* Do no need to go through this part of the tree for * Do no need to go through this part of the tree for
* building AclEntry. * building AclEntry.
*/ */
@Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {} public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/** /**
* Do no need to go through this part of the tree for * Do no need to go through this part of the tree for
* building InformEntry. * building InformEntry.
*/ */
public void buildInformEntries(Hashtable dest) {} @Override
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
} }
...@@ -27,18 +27,17 @@ ...@@ -27,18 +27,17 @@
package com.sun.jmx.snmp.IPAcl; package com.sun.jmx.snmp.IPAcl;
@SuppressWarnings("unchecked") // generated code, not worth fixing
class JJTParserState { class JJTParserState {
private java.util.Stack nodes; private java.util.Stack<Node> nodes;
private java.util.Stack marks; private java.util.Stack<Integer> marks;
private int sp; // number of nodes on stack private int sp; // number of nodes on stack
private int mk; // current mark private int mk; // current mark
private boolean node_created; private boolean node_created;
JJTParserState() { JJTParserState() {
nodes = new java.util.Stack(); nodes = new java.util.Stack<>();
marks = new java.util.Stack(); marks = new java.util.Stack<>();
sp = 0; sp = 0;
mk = 0; mk = 0;
} }
...@@ -62,7 +61,7 @@ class JJTParserState { ...@@ -62,7 +61,7 @@ class JJTParserState {
/* Returns the root node of the AST. It only makes sense to call /* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */ this after a successful parse. */
Node rootNode() { Node rootNode() {
return (Node)nodes.elementAt(0); return nodes.elementAt(0);
} }
/* Pushes a node on to the stack. */ /* Pushes a node on to the stack. */
...@@ -75,14 +74,14 @@ class JJTParserState { ...@@ -75,14 +74,14 @@ class JJTParserState {
stack. */ stack. */
Node popNode() { Node popNode() {
if (--sp < mk) { 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. */ /* Returns the node currently on the top of the stack. */
Node peekNode() { Node peekNode() {
return (Node)nodes.peek(); return nodes.peek();
} }
/* Returns the number of children on the stack in the current node /* Returns the number of children on the stack in the current node
...@@ -96,7 +95,7 @@ class JJTParserState { ...@@ -96,7 +95,7 @@ class JJTParserState {
while (sp > mk) { while (sp > mk) {
popNode(); popNode();
} }
mk = ((Integer)marks.pop()).intValue(); mk = marks.pop().intValue();
} }
...@@ -112,7 +111,7 @@ class JJTParserState { ...@@ -112,7 +111,7 @@ class JJTParserState {
made the children of the definite node. Then the definite node made the children of the definite node. Then the definite node
is pushed on to the stack. */ is pushed on to the stack. */
void closeNodeScope(Node n, int num) { void closeNodeScope(Node n, int num) {
mk = ((Integer)marks.pop()).intValue(); mk = marks.pop().intValue();
while (num-- > 0) { while (num-- > 0) {
Node c = popNode(); Node c = popNode();
c.jjtSetParent(n); c.jjtSetParent(n);
...@@ -132,7 +131,7 @@ class JJTParserState { ...@@ -132,7 +131,7 @@ class JJTParserState {
void closeNodeScope(Node n, boolean condition) { void closeNodeScope(Node n, boolean condition) {
if (condition) { if (condition) {
int a = nodeArity(); int a = nodeArity();
mk = ((Integer)marks.pop()).intValue(); mk = marks.pop().intValue();
while (a-- > 0) { while (a-- > 0) {
Node c = popNode(); Node c = popNode();
c.jjtSetParent(n); c.jjtSetParent(n);
...@@ -142,7 +141,7 @@ class JJTParserState { ...@@ -142,7 +141,7 @@ class JJTParserState {
pushNode(n); pushNode(n);
node_created = true; node_created = true;
} else { } else {
mk = ((Integer)marks.pop()).intValue(); mk = marks.pop().intValue();
node_created = false; node_created = false;
} }
} }
......
...@@ -1168,7 +1168,7 @@ jjtree.openNodeScope(jjtn000);Token t; ...@@ -1168,7 +1168,7 @@ jjtree.openNodeScope(jjtn000);Token t;
return (jj_ntk = jj_nt.kind); 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_expentry;
private int jj_kind = -1; private int jj_kind = -1;
private int[] jj_lasttokens = new int[100]; private int[] jj_lasttokens = new int[100];
...@@ -1184,8 +1184,8 @@ jjtree.openNodeScope(jjtn000);Token t; ...@@ -1184,8 +1184,8 @@ jjtree.openNodeScope(jjtn000);Token t;
jj_expentry[i] = jj_lasttokens[i]; jj_expentry[i] = jj_lasttokens[i];
} }
boolean exists = false; boolean exists = false;
for (java.util.Enumeration enumv = jj_expentries.elements(); enumv.hasMoreElements();) { for (java.util.Enumeration<int[]> enumv = jj_expentries.elements(); enumv.hasMoreElements();) {
int[] oldentry = (int[])(enumv.nextElement()); int[] oldentry = enumv.nextElement();
if (oldentry.length == jj_expentry.length) { if (oldentry.length == jj_expentry.length) {
exists = true; exists = true;
for (int i = 0; i < jj_expentry.length; i++) { for (int i = 0; i < jj_expentry.length; i++) {
...@@ -1236,7 +1236,7 @@ jjtree.openNodeScope(jjtn000);Token t; ...@@ -1236,7 +1236,7 @@ jjtree.openNodeScope(jjtn000);Token t;
jj_add_error_token(0, 0); jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][]; int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) { 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); return new ParseException(token, exptokseq, tokenImage);
} }
......
...@@ -126,7 +126,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -126,7 +126,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
* *
* @return An enumeration of the entries in this ACL. * @return An enumeration of the entries in this ACL.
*/ */
public Enumeration entries() { public Enumeration<AclEntry> entries() {
return acl.entries(); return acl.entries();
} }
...@@ -137,11 +137,11 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -137,11 +137,11 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
public Enumeration<String> communities() { public Enumeration<String> communities() {
HashSet<String> set = new HashSet<String>(); HashSet<String> set = new HashSet<String>();
Vector<String> res = new Vector<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(); AclEntryImpl entry = (AclEntryImpl) e.nextElement();
for (Enumeration cs = entry.communities(); for (Enumeration<String> cs = entry.communities();
cs.hasMoreElements() ;) { cs.hasMoreElements() ;) {
set.add((String) cs.nextElement()); set.add(cs.nextElement());
} }
} }
String[] objs = set.toArray(new String[0]); String[] objs = set.toArray(new String[0]);
...@@ -316,7 +316,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -316,7 +316,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
* *
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>). * @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
*/ */
public Enumeration getTrapDestinations() { public Enumeration<InetAddress> getTrapDestinations() {
return trapDestList.keys(); return trapDestList.keys();
} }
...@@ -327,16 +327,16 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -327,16 +327,16 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
* *
* @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>). * @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>).
*/ */
public Enumeration getTrapCommunities(InetAddress i) { public Enumeration<String> getTrapCommunities(InetAddress i) {
Vector list = null; Vector<String> list = null;
if ((list = (Vector)trapDestList.get(i)) != null ) { if ((list = trapDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is in list"); "getTrapCommunities", "["+i.toString()+"] is in list");
} }
return list.elements(); return list.elements();
} else { } else {
list = new Vector(); list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is not in list"); "getTrapCommunities", "["+i.toString()+"] is not in list");
...@@ -350,7 +350,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -350,7 +350,7 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
* *
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>). * @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
*/ */
public Enumeration getInformDestinations() { public Enumeration<InetAddress> getInformDestinations() {
return informDestList.keys(); return informDestList.keys();
} }
...@@ -361,16 +361,16 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -361,16 +361,16 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
* *
* @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>). * @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>).
*/ */
public Enumeration getInformCommunities(InetAddress i) { public Enumeration<String> getInformCommunities(InetAddress i) {
Vector list = null; Vector<String> list = null;
if ((list = (Vector)informDestList.get(i)) != null ) { if ((list = informDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is in list"); "getInformCommunities", "["+i.toString()+"] is in list");
} }
return list.elements(); return list.elements();
} else { } else {
list = new Vector(); list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is not in list"); "getInformCommunities", "["+i.toString()+"] is not in list");
...@@ -426,15 +426,15 @@ public class SnmpAcl implements InetAddressAcl, Serializable { ...@@ -426,15 +426,15 @@ public class SnmpAcl implements InetAddressAcl, Serializable {
throw new IllegalArgumentException(err.getMessage()); 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(); AclEntryImpl aa = (AclEntryImpl) e.nextElement();
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"readAuthorizedListFile", "readAuthorizedListFile",
"===> " + aa.getPrincipal().toString()); "===> " + aa.getPrincipal().toString());
} }
for (Enumeration eee = aa.permissions();eee.hasMoreElements();) { for (Enumeration<java.security.acl.Permission> eee = aa.permissions();eee.hasMoreElements();) {
java.security.acl.Permission perm = (java.security.acl.Permission)eee.nextElement(); java.security.acl.Permission perm = eee.nextElement();
if (SNMP_LOGGER.isLoggable(Level.FINER)) { if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(), SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"readAuthorizedListFile", "perm = " + perm); "readAuthorizedListFile", "perm = " + perm);
......
...@@ -99,7 +99,7 @@ public interface InetAddressAcl { ...@@ -99,7 +99,7 @@ public interface InetAddressAcl {
* *
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>). * @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. * Returns an enumeration of trap communities for a given host.
...@@ -108,14 +108,14 @@ public interface InetAddressAcl { ...@@ -108,14 +108,14 @@ public interface InetAddressAcl {
* *
* @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>). * @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. * Returns an enumeration of inform destinations.
* *
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>). * @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. * Returns an enumeration of inform communities for a given host.
...@@ -124,5 +124,5 @@ public interface InetAddressAcl { ...@@ -124,5 +124,5 @@ public interface InetAddressAcl {
* *
* @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>). * @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);
} }
...@@ -59,6 +59,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -59,6 +59,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception IllegalAccessException The MIB cannot be initialized. * @exception IllegalAccessException The MIB cannot be initialized.
*/ */
@Override
public void init() throws IllegalAccessException { public void init() throws IllegalAccessException {
} }
...@@ -74,6 +75,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -74,6 +75,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception java.lang.Exception * @exception java.lang.Exception
*/ */
@Override
public ObjectName preRegister(MBeanServer server, ObjectName name) public ObjectName preRegister(MBeanServer server, ObjectName name)
throws Exception { throws Exception {
return name; return name;
...@@ -87,6 +89,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -87,6 +89,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @return The returned oid is null. * @return The returned oid is null.
*/ */
@Override
public long[] getRootOid() { public long[] getRootOid() {
return null; return null;
} }
...@@ -99,6 +102,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -99,6 +102,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException { public void get(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
...@@ -108,9 +112,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -108,9 +112,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne) if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName); throw new SnmpStatusException(SnmpStatusException.noSuchName);
Enumeration l = inRequest.getElements(); Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) { while(l.hasMoreElements()) {
SnmpVarBind varbind = (SnmpVarBind) l.nextElement(); SnmpVarBind varbind = l.nextElement();
varbind.setNoSuchObject(); varbind.setNoSuchObject();
} }
} }
...@@ -128,6 +132,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -128,6 +132,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* cannot be performed. * cannot be performed.
*/ */
@Override
public void check(SnmpMibRequest inRequest) throws SnmpStatusException { public void check(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
...@@ -145,6 +150,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -145,6 +150,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public void set(SnmpMibRequest inRequest) throws SnmpStatusException { public void set(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
...@@ -162,6 +168,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -162,6 +168,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException { public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
...@@ -171,9 +178,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -171,9 +178,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne) if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName); throw new SnmpStatusException(SnmpStatusException.noSuchName);
Enumeration l = inRequest.getElements(); Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) { while(l.hasMoreElements()) {
SnmpVarBind varbind = (SnmpVarBind) l.nextElement(); SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView(); varbind.setEndOfMibView();
} }
} }
...@@ -186,6 +193,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -186,6 +193,7 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat) public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -196,9 +204,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent ...@@ -196,9 +204,9 @@ public class SnmpErrorHandlerAgent extends SnmpMibAgent
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne) if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0); throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0);
Enumeration l = inRequest.getElements(); Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) { while(l.hasMoreElements()) {
SnmpVarBind varbind = (SnmpVarBind) l.nextElement(); SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView(); varbind.setEndOfMibView();
} }
} }
......
...@@ -28,7 +28,6 @@ package com.sun.jmx.snmp.agent; ...@@ -28,7 +28,6 @@ package com.sun.jmx.snmp.agent;
// java imports // java imports
// //
import java.util.Vector;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
...@@ -149,8 +148,8 @@ public class SnmpGenericObjectServer { ...@@ -149,8 +148,8 @@ public class SnmpGenericObjectServer {
final long[] idList = new long[size]; final long[] idList = new long[size];
int i = 0; int i = 0;
for (Enumeration e=req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
final SnmpVarBind var= (SnmpVarBind) e.nextElement(); final SnmpVarBind var= e.nextElement();
try { try {
final long id = var.oid.getOidArc(depth); final long id = var.oid.getOidArc(depth);
nameList[i] = meta.getAttributeName(id); nameList[i] = meta.getAttributeName(id);
...@@ -190,7 +189,7 @@ public class SnmpGenericObjectServer { ...@@ -190,7 +189,7 @@ public class SnmpGenericObjectServer {
} }
final Iterator it = result.iterator(); final Iterator<?> it = result.iterator();
for (int j=0; j < i; j++) { for (int j=0; j < i; j++) {
if (!it.hasNext()) { if (!it.hasNext()) {
...@@ -312,8 +311,8 @@ public class SnmpGenericObjectServer { ...@@ -312,8 +311,8 @@ public class SnmpGenericObjectServer {
final long[] idList = new long[size]; final long[] idList = new long[size];
int i = 0; int i = 0;
for (Enumeration e=req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
final SnmpVarBind var= (SnmpVarBind) e.nextElement(); final SnmpVarBind var= e.nextElement();
try { try {
final long id = var.oid.getOidArc(depth); final long id = var.oid.getOidArc(depth);
final String attname = meta.getAttributeName(id); final String attname = meta.getAttributeName(id);
...@@ -330,7 +329,7 @@ public class SnmpGenericObjectServer { ...@@ -330,7 +329,7 @@ public class SnmpGenericObjectServer {
} }
} }
AttributeList result = null; AttributeList result;
int errorCode = SnmpStatusException.noAccess; int errorCode = SnmpStatusException.noAccess;
try { try {
...@@ -345,7 +344,7 @@ public class SnmpGenericObjectServer { ...@@ -345,7 +344,7 @@ public class SnmpGenericObjectServer {
result = new AttributeList(); result = new AttributeList();
} }
final Iterator it = result.iterator(); final Iterator<?> it = result.iterator();
for (int j=0; j < i; j++) { for (int j=0; j < i; j++) {
if (!it.hasNext()) { if (!it.hasNext()) {
...@@ -469,8 +468,8 @@ public class SnmpGenericObjectServer { ...@@ -469,8 +468,8 @@ public class SnmpGenericObjectServer {
final Object data = req.getUserData(); final Object data = req.getUserData();
for (Enumeration e=req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
final SnmpVarBind var= (SnmpVarBind) e.nextElement(); final SnmpVarBind var= e.nextElement();
try { try {
final long id = var.oid.getOidArc(depth); final long id = var.oid.getOidArc(depth);
// call meta.check() here, and meta.check will call check() // call meta.check() here, and meta.check will call check()
......
...@@ -164,11 +164,12 @@ public class SnmpIndex implements Serializable { ...@@ -164,11 +164,12 @@ public class SnmpIndex implements Serializable {
* *
* @return A string representation of the index. * @return A string representation of the index.
*/ */
@Override
public String toString() { public String toString() {
StringBuffer msg= new StringBuffer(); final StringBuilder msg= new StringBuilder();
for(Enumeration e= oids.elements(); e.hasMoreElements(); ) { for(Enumeration<SnmpOid> e= oids.elements(); e.hasMoreElements(); ) {
SnmpOid val= (SnmpOid) e.nextElement(); SnmpOid val= e.nextElement();
msg.append( "//" + val.toString()); msg.append("//").append( val.toString());
} }
return msg.toString(); return msg.toString();
} }
...@@ -180,7 +181,7 @@ public class SnmpIndex implements Serializable { ...@@ -180,7 +181,7 @@ public class SnmpIndex implements Serializable {
* The list of OIDs. * The list of OIDs.
* @serial * @serial
*/ */
private Vector<SnmpOid> oids = new Vector<SnmpOid>(); private Vector<SnmpOid> oids = new Vector<>();
/** /**
* The number of elements in the index. * The number of elements in the index.
......
...@@ -42,10 +42,6 @@ import com.sun.jmx.snmp.SnmpOid; ...@@ -42,10 +42,6 @@ import com.sun.jmx.snmp.SnmpOid;
import com.sun.jmx.snmp.SnmpVarBind; import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpDefinitions; import com.sun.jmx.snmp.SnmpDefinitions;
import com.sun.jmx.snmp.SnmpStatusException; 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. * Abstract class for representing an SNMP MIB.
...@@ -241,6 +237,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -241,6 +237,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc // for java-doc
// //
@Override
public void get(SnmpMibRequest req) throws SnmpStatusException { public void get(SnmpMibRequest req) throws SnmpStatusException {
// Builds the request tree: creation is not allowed, operation // Builds the request tree: creation is not allowed, operation
...@@ -259,8 +256,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -259,8 +256,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// For each sub-request stored in the request-tree, invoke the // For each sub-request stored in the request-tree, invoke the
// get() method. // get() method.
for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) { for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
h = (SnmpRequestTree.Handler) eh.nextElement(); h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a // Gets the Meta node. It can be either a Group Meta or a
// Table Meta. // Table Meta.
...@@ -270,11 +267,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -270,11 +267,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Gets the depth of the Meta node in the OID tree // Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h); final int depth = handlers.getOidDepth(h);
for (Enumeration rqs=handlers.getSubRequests(h); for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) { rqs.hasMoreElements();) {
// Invoke the get() operation. // Invoke the get() operation.
meta.get((SnmpMibSubRequest)rqs.nextElement(),depth); meta.get(rqs.nextElement(),depth);
} }
} }
} }
...@@ -286,6 +283,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -286,6 +283,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc // for java-doc
// //
@Override
public void set(SnmpMibRequest req) throws SnmpStatusException { public void set(SnmpMibRequest req) throws SnmpStatusException {
SnmpRequestTree handlers = null; SnmpRequestTree handlers = null;
...@@ -307,8 +305,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -307,8 +305,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
handlers.switchCreationFlag(false); handlers.switchCreationFlag(false);
handlers.setPduType(reqType); handlers.setPduType(reqType);
SnmpRequestTree.Handler h = null; SnmpRequestTree.Handler h;
SnmpMibNode meta = null; SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
...@@ -317,8 +315,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -317,8 +315,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// For each sub-request stored in the request-tree, invoke the // For each sub-request stored in the request-tree, invoke the
// get() method. // get() method.
for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) { for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
h = (SnmpRequestTree.Handler) eh.nextElement(); h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a // Gets the Meta node. It can be either a Group Meta or a
// Table Meta. // Table Meta.
...@@ -328,11 +326,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -328,11 +326,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Gets the depth of the Meta node in the OID tree // Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h); final int depth = handlers.getOidDepth(h);
for (Enumeration rqs=handlers.getSubRequests(h); for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) { rqs.hasMoreElements();) {
// Invoke the set() operation // Invoke the set() operation
meta.set((SnmpMibSubRequest)rqs.nextElement(),depth); meta.set(rqs.nextElement(),depth);
} }
} }
} }
...@@ -346,6 +344,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -346,6 +344,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc // for java-doc
// //
@Override
public void check(SnmpMibRequest req) throws SnmpStatusException { public void check(SnmpMibRequest req) throws SnmpStatusException {
final int reqType = SnmpDefinitions.pduWalkRequest; final int reqType = SnmpDefinitions.pduWalkRequest;
...@@ -353,8 +352,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -353,8 +352,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// is atomic. // is atomic.
SnmpRequestTree handlers = getHandlers(req,true,true,reqType); SnmpRequestTree handlers = getHandlers(req,true,true,reqType);
SnmpRequestTree.Handler h = null; SnmpRequestTree.Handler h;
SnmpMibNode meta = null; SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
...@@ -363,8 +362,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -363,8 +362,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// For each sub-request stored in the request-tree, invoke the // For each sub-request stored in the request-tree, invoke the
// check() method. // check() method.
for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) { for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
h = (SnmpRequestTree.Handler) eh.nextElement(); h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a // Gets the Meta node. It can be either a Group Meta or a
// Table Meta. // Table Meta.
...@@ -374,11 +373,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -374,11 +373,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Gets the depth of the Meta node in the OID tree // Gets the depth of the Meta node in the OID tree
final int depth = handlers.getOidDepth(h); final int depth = handlers.getOidDepth(h);
for (Enumeration rqs=handlers.getSubRequests(h); for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) { rqs.hasMoreElements();) {
// Invoke the check() operation // Invoke the check() operation
meta.check((SnmpMibSubRequest)rqs.nextElement(),depth); meta.check(rqs.nextElement(),depth);
} }
} }
...@@ -398,13 +397,14 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -398,13 +397,14 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc // for java-doc
// //
@Override
public void getNext(SnmpMibRequest req) throws SnmpStatusException { public void getNext(SnmpMibRequest req) throws SnmpStatusException {
// Build the request tree for the operation // Build the request tree for the operation
// The subrequest stored in the request tree are valid GET requests // The subrequest stored in the request tree are valid GET requests
SnmpRequestTree handlers = getGetNextHandlers(req); SnmpRequestTree handlers = getGetNextHandlers(req);
SnmpRequestTree.Handler h = null; SnmpRequestTree.Handler h;
SnmpMibNode meta = null; SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(), SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
...@@ -412,8 +412,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -412,8 +412,8 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
} }
// Now invoke get() for each subrequest of the request tree. // Now invoke get() for each subrequest of the request tree.
for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) { for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
h = (SnmpRequestTree.Handler) eh.nextElement(); h = eh.nextElement();
// Gets the Meta node. It can be either a Group Meta or a // Gets the Meta node. It can be either a Group Meta or a
// Table Meta. // Table Meta.
...@@ -423,11 +423,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -423,11 +423,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Gets the depth of the Meta node in the OID tree // Gets the depth of the Meta node in the OID tree
int depth = handlers.getOidDepth(h); int depth = handlers.getOidDepth(h);
for (Enumeration rqs=handlers.getSubRequests(h); for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) { rqs.hasMoreElements();) {
// Invoke the get() operation // Invoke the get() operation
meta.get((SnmpMibSubRequest)rqs.nextElement(),depth); meta.get(rqs.nextElement(),depth);
} }
} }
} }
...@@ -442,6 +442,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -442,6 +442,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc // for java-doc
// //
@Override
public void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat) public void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -456,10 +457,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -456,10 +457,11 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
* *
* @return The root object identifier. * @return The root object identifier.
*/ */
@Override
public long[] getRootOid() { public long[] getRootOid() {
if( rootOid == null) { if( rootOid == null) {
Vector<Integer> list= new Vector<Integer>(10); Vector<Integer> list= new Vector<>(10);
// Ask the tree to do the job ! // Ask the tree to do the job !
// //
...@@ -507,13 +509,13 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -507,13 +509,13 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
new SnmpRequestTree(req,createflag,type); new SnmpRequestTree(req,createflag,type);
int index=0; int index=0;
SnmpVarBind var = null; SnmpVarBind var;
final int ver= req.getVersion(); final int ver= req.getVersion();
// For each varbind in the list finds its handling node. // 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 { try {
// Find the handling node for this varbind. // Find the handling node for this varbind.
...@@ -657,10 +659,10 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { ...@@ -657,10 +659,10 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
// request into a valid GET request, replacing the OIDs in the // request into a valid GET request, replacing the OIDs in the
// original GET-NEXT request with the OID of the first leaf that // original GET-NEXT request with the OID of the first leaf that
// follows. // follows.
for (Enumeration e= req.getElements(); e.hasMoreElements(); index++) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements(); index++) {
var = (SnmpVarBind) e.nextElement(); var = e.nextElement();
SnmpOid result = null; SnmpOid result;
try { try {
// Find the node handling the OID that follows the varbind // Find the node handling the OID that follows the varbind
// OID. `result' contains this next leaf OID. // OID. `result' contains this next leaf OID.
......
...@@ -33,14 +33,12 @@ package com.sun.jmx.snmp.agent; ...@@ -33,14 +33,12 @@ package com.sun.jmx.snmp.agent;
import java.io.Serializable; import java.io.Serializable;
import java.util.Vector; import java.util.Vector;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Set;
// jmx imports // jmx imports
// //
import javax.management.MBeanServer; import javax.management.MBeanServer;
import javax.management.MBeanRegistration; import javax.management.MBeanRegistration;
import javax.management.ObjectName; import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
import javax.management.ServiceNotFoundException; import javax.management.ServiceNotFoundException;
import javax.management.ReflectionException; import javax.management.ReflectionException;
...@@ -94,6 +92,7 @@ public abstract class SnmpMibAgent ...@@ -94,6 +92,7 @@ public abstract class SnmpMibAgent
* *
* @exception java.lang.Exception * @exception java.lang.Exception
*/ */
@Override
public abstract ObjectName preRegister(MBeanServer server, public abstract ObjectName preRegister(MBeanServer server,
ObjectName name) ObjectName name)
throws java.lang.Exception; throws java.lang.Exception;
...@@ -101,18 +100,21 @@ public abstract class SnmpMibAgent ...@@ -101,18 +100,21 @@ public abstract class SnmpMibAgent
/** /**
* Not used in this context. * Not used in this context.
*/ */
@Override
public void postRegister (Boolean registrationDone) { public void postRegister (Boolean registrationDone) {
} }
/** /**
* Not used in this context. * Not used in this context.
*/ */
@Override
public void preDeregister() throws java.lang.Exception { public void preDeregister() throws java.lang.Exception {
} }
/** /**
* Not used in this context. * Not used in this context.
*/ */
@Override
public void postDeregister() { public void postDeregister() {
} }
...@@ -127,6 +129,7 @@ public abstract class SnmpMibAgent ...@@ -127,6 +129,7 @@ public abstract class SnmpMibAgent
* *
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public abstract void get(SnmpMibRequest req) public abstract void get(SnmpMibRequest req)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -141,6 +144,7 @@ public abstract class SnmpMibAgent ...@@ -141,6 +144,7 @@ public abstract class SnmpMibAgent
* *
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public abstract void getNext(SnmpMibRequest req) public abstract void getNext(SnmpMibRequest req)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -164,6 +168,7 @@ public abstract class SnmpMibAgent ...@@ -164,6 +168,7 @@ public abstract class SnmpMibAgent
* *
* @exception SnmpStatusException An error occured during the operation. * @exception SnmpStatusException An error occured during the operation.
*/ */
@Override
public abstract void getBulk(SnmpMibRequest req, int nonRepeat, public abstract void getBulk(SnmpMibRequest req, int nonRepeat,
int maxRepeat) int maxRepeat)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -185,6 +190,7 @@ public abstract class SnmpMibAgent ...@@ -185,6 +190,7 @@ public abstract class SnmpMibAgent
* the exception is thrown in the {@link #check(SnmpMibRequest)} * the exception is thrown in the {@link #check(SnmpMibRequest)}
* method instead. * method instead.
*/ */
@Override
public abstract void set(SnmpMibRequest req) public abstract void set(SnmpMibRequest req)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -203,6 +209,7 @@ public abstract class SnmpMibAgent ...@@ -203,6 +209,7 @@ public abstract class SnmpMibAgent
* @exception SnmpStatusException The <CODE>set</CODE> operation * @exception SnmpStatusException The <CODE>set</CODE> operation
* cannot be performed. * cannot be performed.
*/ */
@Override
public abstract void check(SnmpMibRequest req) public abstract void check(SnmpMibRequest req)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -226,6 +233,7 @@ public abstract class SnmpMibAgent ...@@ -226,6 +233,7 @@ public abstract class SnmpMibAgent
* @return The MBean server or null if the MIB is not registered in any * @return The MBean server or null if the MIB is not registered in any
* MBean server. * MBean server.
*/ */
@Override
public MBeanServer getMBeanServer() { public MBeanServer getMBeanServer() {
return server; return server;
} }
...@@ -236,6 +244,7 @@ public abstract class SnmpMibAgent ...@@ -236,6 +244,7 @@ public abstract class SnmpMibAgent
* *
* @return The SNMP MIB handler. * @return The SNMP MIB handler.
*/ */
@Override
public SnmpMibHandler getSnmpAdaptor() { public SnmpMibHandler getSnmpAdaptor() {
return adaptor; return adaptor;
} }
...@@ -246,6 +255,7 @@ public abstract class SnmpMibAgent ...@@ -246,6 +255,7 @@ public abstract class SnmpMibAgent
* *
* @param stack The SNMP MIB handler. * @param stack The SNMP MIB handler.
*/ */
@Override
public void setSnmpAdaptor(SnmpMibHandler stack) { public void setSnmpAdaptor(SnmpMibHandler stack) {
if (adaptor != null) { if (adaptor != null) {
adaptor.removeMib(this); adaptor.removeMib(this);
...@@ -266,6 +276,7 @@ public abstract class SnmpMibAgent ...@@ -266,6 +276,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptor(SnmpMibHandler stack, SnmpOid[] oids) { public void setSnmpAdaptor(SnmpMibHandler stack, SnmpOid[] oids) {
if (adaptor != null) { if (adaptor != null) {
adaptor.removeMib(this); adaptor.removeMib(this);
...@@ -288,6 +299,7 @@ public abstract class SnmpMibAgent ...@@ -288,6 +299,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptor(SnmpMibHandler stack, String contextName) { public void setSnmpAdaptor(SnmpMibHandler stack, String contextName) {
if (adaptor != null) { if (adaptor != null) {
adaptor.removeMib(this, contextName); adaptor.removeMib(this, contextName);
...@@ -309,6 +321,7 @@ public abstract class SnmpMibAgent ...@@ -309,6 +321,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptor(SnmpMibHandler stack, public void setSnmpAdaptor(SnmpMibHandler stack,
String contextName, String contextName,
SnmpOid[] oids) { SnmpOid[] oids) {
...@@ -327,6 +340,7 @@ public abstract class SnmpMibAgent ...@@ -327,6 +340,7 @@ public abstract class SnmpMibAgent
* *
* @return The name of the SNMP protocol adaptor. * @return The name of the SNMP protocol adaptor.
*/ */
@Override
public ObjectName getSnmpAdaptorName() { public ObjectName getSnmpAdaptorName() {
return adaptorName; return adaptorName;
} }
...@@ -344,6 +358,7 @@ public abstract class SnmpMibAgent ...@@ -344,6 +358,7 @@ public abstract class SnmpMibAgent
* @exception ServiceNotFoundException This SNMP MIB is not registered * @exception ServiceNotFoundException This SNMP MIB is not registered
* in the MBean server or the requested service is not supported. * in the MBean server or the requested service is not supported.
*/ */
@Override
public void setSnmpAdaptorName(ObjectName name) public void setSnmpAdaptorName(ObjectName name)
throws InstanceNotFoundException, ServiceNotFoundException { throws InstanceNotFoundException, ServiceNotFoundException {
...@@ -389,6 +404,7 @@ public abstract class SnmpMibAgent ...@@ -389,6 +404,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptorName(ObjectName name, SnmpOid[] oids) public void setSnmpAdaptorName(ObjectName name, SnmpOid[] oids)
throws InstanceNotFoundException, ServiceNotFoundException { throws InstanceNotFoundException, ServiceNotFoundException {
...@@ -434,6 +450,7 @@ public abstract class SnmpMibAgent ...@@ -434,6 +450,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptorName(ObjectName name, String contextName) public void setSnmpAdaptorName(ObjectName name, String contextName)
throws InstanceNotFoundException, ServiceNotFoundException { throws InstanceNotFoundException, ServiceNotFoundException {
...@@ -481,6 +498,7 @@ public abstract class SnmpMibAgent ...@@ -481,6 +498,7 @@ public abstract class SnmpMibAgent
* *
* @since 1.5 * @since 1.5
*/ */
@Override
public void setSnmpAdaptorName(ObjectName name, public void setSnmpAdaptorName(ObjectName name,
String contextName, SnmpOid[] oids) String contextName, SnmpOid[] oids)
throws InstanceNotFoundException, ServiceNotFoundException { throws InstanceNotFoundException, ServiceNotFoundException {
...@@ -522,6 +540,7 @@ public abstract class SnmpMibAgent ...@@ -522,6 +540,7 @@ public abstract class SnmpMibAgent
* @return <CODE>true</CODE> if the MIB module is bound, * @return <CODE>true</CODE> if the MIB module is bound,
* <CODE>false</CODE> otherwise. * <CODE>false</CODE> otherwise.
*/ */
@Override
public boolean getBindingState() { public boolean getBindingState() {
if (adaptor == null) if (adaptor == null)
return false; return false;
...@@ -534,6 +553,7 @@ public abstract class SnmpMibAgent ...@@ -534,6 +553,7 @@ public abstract class SnmpMibAgent
* *
* @return The MIB name. * @return The MIB name.
*/ */
@Override
public String getMibName() { public String getMibName() {
return mibName; return mibName;
} }
...@@ -681,7 +701,7 @@ public abstract class SnmpMibAgent ...@@ -681,7 +701,7 @@ public abstract class SnmpMibAgent
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) { private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {
int max= original.size(); int max= original.size();
Vector<SnmpVarBind> result= new Vector<SnmpVarBind>(max - limit); Vector<SnmpVarBind> result= new Vector<>(max - limit);
int i= limit; int i= limit;
// Ok the loop looks a bit strange. But in order to improve the // Ok the loop looks a bit strange. But in order to improve the
...@@ -697,21 +717,12 @@ public abstract class SnmpMibAgent ...@@ -697,21 +717,12 @@ public abstract class SnmpMibAgent
return result; return result;
} }
private void concatVector(SnmpMibRequest req, Vector source) { private void concatVector(SnmpMibRequest req, Vector<SnmpVarBind> 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) {
for(Enumeration<SnmpVarBind> e= source.elements(); e.hasMoreElements(); ) { for(Enumeration<SnmpVarBind> e= source.elements(); e.hasMoreElements(); ) {
SnmpVarBind var= e.nextElement(); SnmpVarBind var= e.nextElement();
// We need to duplicate the SnmpVarBind otherwise it is going // We need to duplicate the SnmpVarBind otherwise it is going
// to be overloaded by the next get Next ... // to be overloaded by the next get Next ...
target.addElement(new SnmpVarBind(var.oid, var.value)); req.addVarBind(new SnmpVarBind(var.oid, var.value));
} }
} }
......
...@@ -29,20 +29,13 @@ package com.sun.jmx.snmp.agent; ...@@ -29,20 +29,13 @@ package com.sun.jmx.snmp.agent;
// //
import java.io.Serializable; import java.io.Serializable;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;
// jmx imports // 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.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException; 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. * Represents a node in an SNMP MIB which corresponds to a group.
...@@ -174,6 +167,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -174,6 +167,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
* @exception SnmpStatusException An error occurred while accessing * @exception SnmpStatusException An error occurred while accessing
* the MIB node. * the MIB node.
*/ */
@Override
abstract public void get(SnmpMibSubRequest req, int depth) abstract public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -203,6 +197,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -203,6 +197,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
* @exception SnmpStatusException An error occurred while accessing * @exception SnmpStatusException An error occurred while accessing
* the MIB node. * the MIB node.
*/ */
@Override
abstract public void set(SnmpMibSubRequest req, int depth) abstract public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -234,6 +229,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -234,6 +229,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
* @exception SnmpStatusException An error occurred while accessing * @exception SnmpStatusException An error occurred while accessing
* the MIB node. * the MIB node.
*/ */
@Override
abstract public void check(SnmpMibSubRequest req, int depth) abstract public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException; throws SnmpStatusException;
...@@ -241,8 +237,8 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -241,8 +237,8 @@ public abstract class SnmpMibGroup extends SnmpMibOid
// If we reach this node, we are below the root OID, so we just // If we reach this node, we are below the root OID, so we just
// return. // return.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
public void getRootOid(Vector result) { @Override
return; public void getRootOid(Vector<Integer> result) {
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -264,7 +260,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -264,7 +260,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
*/ */
void registerNestedArc(long arc) { void registerNestedArc(long arc) {
Long obj = new 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. // registers the arc in the hashtable.
subgroups.put(obj,obj); subgroups.put(obj,obj);
} }
...@@ -312,6 +308,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -312,6 +308,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
* @param node The node being registered. * @param node The node being registered.
* *
*/ */
@Override
void registerNode(long[] oid, int cursor ,SnmpMibNode node) void registerNode(long[] oid, int cursor ,SnmpMibNode node)
throws IllegalAccessException { throws IllegalAccessException {
super.registerNode(oid,cursor,node); super.registerNode(oid,cursor,node);
...@@ -325,13 +322,13 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -325,13 +322,13 @@ public abstract class SnmpMibGroup extends SnmpMibOid
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// see comments in SnmpMibNode // see comments in SnmpMibNode
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
void findHandlingNode(SnmpVarBind varbind, void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth, long[] oid, int depth,
SnmpRequestTree handlers) SnmpRequestTree handlers)
throws SnmpStatusException { throws SnmpStatusException {
int length = oid.length; int length = oid.length;
SnmpMibNode node = null;
if (handlers == null) if (handlers == null)
throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr); throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
...@@ -349,7 +346,6 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -349,7 +346,6 @@ public abstract class SnmpMibGroup extends SnmpMibOid
// This arc leads to a subgroup: delegates the search to the // This arc leads to a subgroup: delegates the search to the
// method defined in SnmpMibOid // method defined in SnmpMibOid
super.findHandlingNode(varbind,oid,depth,handlers); super.findHandlingNode(varbind,oid,depth,handlers);
return;
} else if (isTable(arc)) { } else if (isTable(arc)) {
// This arc leads to a table: forward the search to the table. // This arc leads to a table: forward the search to the table.
...@@ -384,6 +380,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid ...@@ -384,6 +380,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// See comments in SnmpMibNode. // See comments in SnmpMibNode.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
long[] findNextHandlingNode(SnmpVarBind varbind, long[] findNextHandlingNode(SnmpVarBind varbind,
long[] oid, int pos, int depth, long[] oid, int pos, int depth,
SnmpRequestTree handlers, AcmChecker checker) SnmpRequestTree handlers, AcmChecker checker)
......
...@@ -37,7 +37,6 @@ import java.util.Enumeration; ...@@ -37,7 +37,6 @@ import java.util.Enumeration;
// jmx imports // jmx imports
// //
import com.sun.jmx.snmp.SnmpOid; import com.sun.jmx.snmp.SnmpOid;
import com.sun.jmx.snmp.SnmpValue;
import com.sun.jmx.snmp.SnmpVarBind; import com.sun.jmx.snmp.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException; import com.sun.jmx.snmp.SnmpStatusException;
...@@ -79,10 +78,11 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -79,10 +78,11 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
* @exception SnmpStatusException The default implementation (if not * @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException. * overridden) is to generate a SnmpStatusException.
*/ */
@Override
public void get(SnmpMibSubRequest req, int depth) public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
SnmpVarBind var= (SnmpVarBind) e.nextElement(); SnmpVarBind var= e.nextElement();
SnmpStatusException x = SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noSuchObject); new SnmpStatusException(SnmpStatusException.noSuchObject);
req.registerGetException(var,x); req.registerGetException(var,x);
...@@ -102,10 +102,11 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -102,10 +102,11 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
* @exception SnmpStatusException The default implementation (if not * @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException. * overridden) is to generate a SnmpStatusException.
*/ */
@Override
public void set(SnmpMibSubRequest req, int depth) public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
SnmpVarBind var= (SnmpVarBind) e.nextElement(); SnmpVarBind var= e.nextElement();
SnmpStatusException x = SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noAccess); new SnmpStatusException(SnmpStatusException.noAccess);
req.registerSetException(var,x); req.registerSetException(var,x);
...@@ -123,12 +124,13 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -123,12 +124,13 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
* @param depth The depth reached in the OID tree. * @param depth The depth reached in the OID tree.
* *
* @exception SnmpStatusException The default implementation (if not * @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) public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
SnmpVarBind var= (SnmpVarBind) e.nextElement(); SnmpVarBind var= e.nextElement();
SnmpStatusException x = SnmpStatusException x =
new SnmpStatusException(SnmpStatusException.noAccess); new SnmpStatusException(SnmpStatusException.noAccess);
req.registerCheckException(var,x); req.registerCheckException(var,x);
...@@ -143,6 +145,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -143,6 +145,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// //
@Override
void findHandlingNode(SnmpVarBind varbind, void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth, long[] oid, int depth,
SnmpRequestTree handlers) SnmpRequestTree handlers)
...@@ -191,6 +194,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -191,6 +194,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// //
@Override
long[] findNextHandlingNode(SnmpVarBind varbind, long[] findNextHandlingNode(SnmpVarBind varbind,
long[] oid, int pos, int depth, long[] oid, int pos, int depth,
SnmpRequestTree handlers, SnmpRequestTree handlers,
...@@ -267,6 +271,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -267,6 +271,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
/** /**
* Computes the root OID of the MIB. * Computes the root OID of the MIB.
*/ */
@Override
public void getRootOid(Vector<Integer> result) { public void getRootOid(Vector<Integer> result) {
// If a node has several children, let assume that we are one step to // If a node has several children, let assume that we are one step to
...@@ -359,7 +364,6 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -359,7 +364,6 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
// String.valueOf(var) + " position= " + cursor); // String.valueOf(var) + " position= " + cursor);
children.insertElementAt(child, newPos); children.insertElementAt(child, newPos);
child.registerNode(oid, cursor + 1, node); child.registerNode(oid, cursor + 1, node);
return;
} }
else { else {
// The node is already registered // The node is already registered
...@@ -404,7 +408,6 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -404,7 +408,6 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
} }
} }
children.setElementAt(node,pos); children.setElementAt(node,pos);
return;
} else { } else {
if (child == null) if (child == null)
throw new IllegalAccessException(); throw new IllegalAccessException();
...@@ -469,7 +472,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -469,7 +472,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
int max= varList.length -1 ; int max= varList.length -1 ;
int curr= low + (max-low)/2; int curr= low + (max-low)/2;
int elmt= 0; int elmt;
while (low <= max) { while (low <= max) {
elmt= varList[curr]; elmt= varList[curr];
if (cursor == elmt) { if (cursor == elmt) {
...@@ -494,7 +497,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -494,7 +497,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
if (varList == null) if (varList == null)
return -1; return -1;
int max= varList.length -1 ; int max= varList.length -1 ;
int elmt=0; int elmt;
//final int[] v = varList; //final int[] v = varList;
//if (index > a[max]) //if (index > a[max])
...@@ -528,7 +531,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable { ...@@ -528,7 +531,7 @@ public class SnmpMibOid extends SnmpMibNode implements Serializable {
/** /**
* Contains the list of sub nodes. * 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. * The number of sub nodes.
......
...@@ -50,7 +50,7 @@ public interface SnmpMibRequest { ...@@ -50,7 +50,7 @@ public interface SnmpMibRequest {
* @return The element of the enumeration are instances of * @return The element of the enumeration are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind} * {@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. * Returns the vector of varbind to be handled by the SNMP mib node.
......
...@@ -87,6 +87,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -87,6 +87,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* Returns the local engine. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned. * 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. * @return the local engine.
*/ */
@Override
public SnmpEngine getEngine() { public SnmpEngine getEngine() {
return engine; return engine;
} }
...@@ -95,6 +96,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -95,6 +96,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* Gets the incoming request principal. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned. * 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. * @return The request principal.
**/ **/
@Override
public String getPrincipal() { public String getPrincipal() {
return principal; return principal;
} }
...@@ -103,6 +105,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -103,6 +105,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* 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. * 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. * @return The security level.
*/ */
@Override
public int getSecurityLevel() { public int getSecurityLevel() {
return securityLevel; return securityLevel;
} }
...@@ -110,6 +113,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -110,6 +113,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* 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. * 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. * @return The security model.
*/ */
@Override
public int getSecurityModel() { public int getSecurityModel() {
return securityModel; return securityModel;
} }
...@@ -117,6 +121,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -117,6 +121,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* 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. * 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. * @return The context name.
*/ */
@Override
public byte[] getContextName() { public byte[] getContextName() {
return contextName; return contextName;
} }
...@@ -125,6 +130,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -125,6 +130,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
* 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. * 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. * @return The checked context.
*/ */
@Override
public byte[] getAccessContextName() { public byte[] getAccessContextName() {
return accessContextName; return accessContextName;
} }
...@@ -133,6 +139,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -133,6 +139,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final SnmpPdu getPdu() { public final SnmpPdu getPdu() {
return reqPdu; return reqPdu;
} }
...@@ -141,18 +148,21 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -141,18 +148,21 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // 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. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final Vector<SnmpVarBind> getSubList() {return varbinds;} public final Vector<SnmpVarBind> getSubList() {return varbinds;}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final int getSize() { public final int getSize() {
if (varbinds == null) return 0; if (varbinds == null) return 0;
return varbinds.size(); return varbinds.size();
...@@ -162,24 +172,28 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -162,24 +172,28 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final int getVersion() {return version;} public final int getVersion() {return version;}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final int getRequestPduVersion() {return reqPdu.version;} public final int getRequestPduVersion() {return reqPdu.version;}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final Object getUserData() {return data;} public final Object getUserData() {return data;}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public final int getVarIndex(SnmpVarBind varbind) { public final int getVarIndex(SnmpVarBind varbind) {
return varbinds.indexOf(varbind); return varbinds.indexOf(varbind);
} }
...@@ -188,6 +202,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -188,6 +202,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@Override
public void addVarBind(SnmpVarBind varbind) { public void addVarBind(SnmpVarBind varbind) {
varbinds.addElement(varbind); varbinds.addElement(varbind);
} }
...@@ -218,7 +233,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest { ...@@ -218,7 +233,7 @@ final class SnmpMibRequestImpl implements SnmpMibRequest {
// Returns the underlying vector of SNMP varbinds (used for algorithm // Returns the underlying vector of SNMP varbinds (used for algorithm
// optimization). // optimization).
// ------------------------------------------------------------------- // -------------------------------------------------------------------
final Vector getVarbinds() {return varbinds;} final Vector<SnmpVarBind> getVarbinds() {return varbinds;}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Private variables // Private variables
......
...@@ -65,7 +65,8 @@ public interface SnmpMibSubRequest extends SnmpMibRequest { ...@@ -65,7 +65,8 @@ public interface SnmpMibSubRequest extends SnmpMibRequest {
* @return The elements of the enumeration are instances of * @return The elements of the enumeration are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind} * {@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. * Return the list of varbind to be handled by the SNMP MIB node.
...@@ -85,6 +86,7 @@ public interface SnmpMibSubRequest extends SnmpMibRequest { ...@@ -85,6 +86,7 @@ public interface SnmpMibSubRequest extends SnmpMibRequest {
* @return The elements of the vector are instances of * @return The elements of the vector are instances of
* {@link com.sun.jmx.snmp.SnmpVarBind} * {@link com.sun.jmx.snmp.SnmpVarBind}
*/ */
@Override
public Vector<SnmpVarBind> getSubList(); public Vector<SnmpVarBind> getSubList();
/** /**
......
...@@ -266,6 +266,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -266,6 +266,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* <p> * <p>
* *
*/ */
@Override
public void get(SnmpMibSubRequest req, int depth) public void get(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -276,9 +277,9 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -276,9 +277,9 @@ public abstract class SnmpMibTable extends SnmpMibNode
// each varbind involved (nb: should not happen, the error // each varbind involved (nb: should not happen, the error
// should have been registered earlier) // should have been registered earlier)
if (isnew) { if (isnew) {
SnmpVarBind var = null; SnmpVarBind var;
for (Enumeration e= r.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= r.getElements(); e.hasMoreElements();) {
var = (SnmpVarBind) e.nextElement(); var = e.nextElement();
r.registerGetException(var,noSuchInstanceException); r.registerGetException(var,noSuchInstanceException);
} }
} }
...@@ -329,6 +330,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -329,6 +330,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* <p> * <p>
* *
*/ */
@Override
public void check(SnmpMibSubRequest req, int depth) public void check(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
final SnmpOid oid = req.getEntryOid(); final SnmpOid oid = req.getEntryOid();
...@@ -389,6 +391,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -389,6 +391,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* <p> * <p>
* *
*/ */
@Override
public void set(SnmpMibSubRequest req, int depth) public void set(SnmpMibSubRequest req, int depth)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -755,6 +758,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -755,6 +758,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* *
* @exception IllegalArgumentException Listener parameter is null. * @exception IllegalArgumentException Listener parameter is null.
*/ */
@Override
public synchronized void public synchronized void
addNotificationListener(NotificationListener listener, addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object handback) { NotificationFilter filter, Object handback) {
...@@ -768,13 +772,11 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -768,13 +772,11 @@ public abstract class SnmpMibTable extends SnmpMibNode
// looking for listener in handbackTable // looking for listener in handbackTable
// //
Vector<Object> handbackList = Vector<Object> handbackList = handbackTable.get(listener) ;
handbackTable.get(listener) ; Vector<NotificationFilter> filterList = filterTable.get(listener) ;
Vector<NotificationFilter> filterList =
filterTable.get(listener) ;
if ( handbackList == null ) { if ( handbackList == null ) {
handbackList = new Vector<Object>() ; handbackList = new Vector<>() ;
filterList = new Vector<NotificationFilter>() ; filterList = new Vector<>() ;
handbackTable.put(listener, handbackList) ; handbackTable.put(listener, handbackList) ;
filterTable.put(listener, filterList) ; filterTable.put(listener, filterList) ;
} }
...@@ -797,16 +799,14 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -797,16 +799,14 @@ public abstract class SnmpMibTable extends SnmpMibNode
* @exception ListenerNotFoundException The listener is not registered * @exception ListenerNotFoundException The listener is not registered
* in the MBean. * in the MBean.
*/ */
@Override
public synchronized void public synchronized void
removeNotificationListener(NotificationListener listener) removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException { throws ListenerNotFoundException {
// looking for listener in handbackTable // looking for listener in handbackTable
// //
java.util.Vector handbackList = java.util.Vector<?> handbackList = handbackTable.get(listener) ;
(java.util.Vector) handbackTable.get(listener) ;
java.util.Vector filterList =
(java.util.Vector) filterTable.get(listener) ;
if ( handbackList == null ) { if ( handbackList == null ) {
throw new ListenerNotFoundException("listener"); throw new ListenerNotFoundException("listener");
} }
...@@ -822,6 +822,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -822,6 +822,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* notification class and the notification type sent by the * notification class and the notification type sent by the
* <CODE>SnmpMibTable</CODE>. * <CODE>SnmpMibTable</CODE>.
*/ */
@Override
public MBeanNotificationInfo[] getNotificationInfo() { public MBeanNotificationInfo[] getNotificationInfo() {
String[] types = {SnmpTableEntryNotification.SNMP_ENTRY_ADDED, String[] types = {SnmpTableEntryNotification.SNMP_ENTRY_ADDED,
...@@ -1813,9 +1814,9 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -1813,9 +1814,9 @@ public abstract class SnmpMibTable extends SnmpMibNode
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
final static void checkRowStatusFail(SnmpMibSubRequest req, static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus)
int errorStatus)
throws SnmpStatusException { throws SnmpStatusException {
final SnmpVarBind statusvb = req.getRowStatusVarBind(); final SnmpVarBind statusvb = req.getRowStatusVarBind();
final SnmpStatusException x = new SnmpStatusException(errorStatus); final SnmpStatusException x = new SnmpStatusException(errorStatus);
req.registerCheckException(statusvb,x); req.registerCheckException(statusvb,x);
...@@ -1827,9 +1828,9 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -1827,9 +1828,9 @@ public abstract class SnmpMibTable extends SnmpMibNode
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
final static void setRowStatusFail(SnmpMibSubRequest req, static void setRowStatusFail(SnmpMibSubRequest req, int errorStatus)
int errorStatus)
throws SnmpStatusException { throws SnmpStatusException {
final SnmpVarBind statusvb = req.getRowStatusVarBind(); final SnmpVarBind statusvb = req.getRowStatusVarBind();
final SnmpStatusException x = new SnmpStatusException(errorStatus); final SnmpStatusException x = new SnmpStatusException(errorStatus);
req.registerSetException(statusvb,x); req.registerSetException(statusvb,x);
...@@ -1840,6 +1841,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -1840,6 +1841,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
// Implements the method defined in SnmpMibNode. // Implements the method defined in SnmpMibNode.
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@Override
final synchronized void findHandlingNode(SnmpVarBind varbind, final synchronized void findHandlingNode(SnmpVarBind varbind,
long[] oid, int depth, long[] oid, int depth,
SnmpRequestTree handlers) SnmpRequestTree handlers)
...@@ -1909,11 +1911,15 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -1909,11 +1911,15 @@ public abstract class SnmpMibTable extends SnmpMibNode
// largely inspired from the original getNext() method. // largely inspired from the original getNext() method.
// //
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@Override
final synchronized long[] findNextHandlingNode(SnmpVarBind varbind, final synchronized long[] findNextHandlingNode(SnmpVarBind varbind,
long[] oid, int pos, int depth, long[] oid,
SnmpRequestTree handlers, int pos,
AcmChecker checker) int depth,
SnmpRequestTree handlers,
AcmChecker checker)
throws SnmpStatusException { throws SnmpStatusException {
int length = oid.length; int length = oid.length;
if (handlers == null) if (handlers == null)
...@@ -1974,7 +1980,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -1974,7 +1980,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
} }
// Now that we've got everything right we can begin. // Now that we've got everything right we can begin.
SnmpOid entryoid = null ; SnmpOid entryoid;
if (pos == (length - 1)) { if (pos == (length - 1)) {
// pos points to the last arc in the oid, and this arc is // pos points to the last arc in the oid, and this arc is
...@@ -2200,28 +2206,25 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2200,28 +2206,25 @@ public abstract class SnmpMibTable extends SnmpMibNode
// loop on listener // loop on listener
// //
for(java.util.Enumeration k = handbackTable.keys(); for(java.util.Enumeration<NotificationListener> k = handbackTable.keys();
k.hasMoreElements(); ) { k.hasMoreElements(); ) {
NotificationListener listener = NotificationListener listener = k.nextElement();
(NotificationListener) k.nextElement();
// Get the associated handback list and the associated filter list // Get the associated handback list and the associated filter list
// //
java.util.Vector handbackList = java.util.Vector<?> handbackList = handbackTable.get(listener) ;
(java.util.Vector) handbackTable.get(listener) ; java.util.Vector<NotificationFilter> filterList =
java.util.Vector filterList = filterTable.get(listener) ;
(java.util.Vector) filterTable.get(listener) ;
// loop on handback // loop on handback
// //
java.util.Enumeration f = filterList.elements(); java.util.Enumeration<NotificationFilter> f = filterList.elements();
for(java.util.Enumeration h = handbackList.elements(); for(java.util.Enumeration<?> h = handbackList.elements();
h.hasMoreElements(); ) { h.hasMoreElements(); ) {
Object handback = h.nextElement(); Object handback = h.nextElement();
NotificationFilter filter = NotificationFilter filter = f.nextElement();
(NotificationFilter)f.nextElement();
if ((filter == null) || if ((filter == null) ||
(filter.isNotificationEnabled(notification))) { (filter.isNotificationEnabled(notification))) {
...@@ -2300,7 +2303,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2300,7 +2303,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* OID was not found. * OID was not found.
* *
**/ **/
private final int findObject(SnmpOid oid) { private int findObject(SnmpOid oid) {
int low= 0; int low= 0;
int max= size - 1; int max= size - 1;
SnmpOid pos; SnmpOid pos;
...@@ -2332,25 +2335,6 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2332,25 +2335,6 @@ public abstract class SnmpMibTable extends SnmpMibNode
return -1; return -1;
} }
/**
* 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.
*
* @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 * Search the position at which the given oid should be inserted
* in the OID table (tableoids). * in the OID table (tableoids).
...@@ -2371,7 +2355,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2371,7 +2355,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* table and <code>fail</code> is <code>true</code>. * 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 { throws SnmpStatusException {
final int failStatus = SnmpStatusException.snmpRspNotWritable; final int failStatus = SnmpStatusException.snmpRspNotWritable;
...@@ -2413,7 +2397,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2413,7 +2397,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* @param pos The position at which the OID to be removed is located. * @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 >= tablecount) return;
if (pos < 0) return; if (pos < 0) return;
final int l1 = --tablecount-pos; final int l1 = --tablecount-pos;
...@@ -2431,7 +2415,7 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2431,7 +2415,7 @@ public abstract class SnmpMibTable extends SnmpMibNode
* @param pos The position at which the OID to be added is located. * @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) { if (pos >= tablesize || tablecount == tablesize) {
// Vector must be enlarged // Vector must be enlarged
...@@ -2534,13 +2518,13 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2534,13 +2518,13 @@ public abstract class SnmpMibTable extends SnmpMibNode
* The list of entries. * The list of entries.
* @serial * @serial
*/ */
private final Vector<Object> entries= new Vector<Object>(); private final Vector<Object> entries= new Vector<>();
/** /**
* The list of object names. * The list of object names.
* @serial * @serial
*/ */
private final Vector<ObjectName> entrynames= new Vector<ObjectName>(); private final Vector<ObjectName> entrynames= new Vector<>();
/** /**
* Callback handlers * Callback handlers
...@@ -2548,17 +2532,16 @@ public abstract class SnmpMibTable extends SnmpMibNode ...@@ -2548,17 +2532,16 @@ public abstract class SnmpMibTable extends SnmpMibNode
// final Vector callbacks = new Vector(); // 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 = 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>> private Hashtable<NotificationListener, Vector<NotificationFilter>>
filterTable = filterTable = new Hashtable<>();
new Hashtable<NotificationListener, Vector<NotificationFilter>>();
// PACKAGE VARIABLES // PACKAGE VARIABLES
//------------------ //------------------
......
...@@ -25,11 +25,9 @@ ...@@ -25,11 +25,9 @@
package com.sun.jmx.snmp.agent; package com.sun.jmx.snmp.agent;
import java.util.Vector; import java.util.Vector;
import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
...@@ -77,7 +75,7 @@ final class SnmpRequestTree { ...@@ -77,7 +75,7 @@ final class SnmpRequestTree {
this.request = req; this.request = req;
this.version = req.getVersion(); this.version = req.getVersion();
this.creationflag = creationflag; this.creationflag = creationflag;
this.hashtable = new Hashtable<Object, Handler>(); this.hashtable = new Hashtable<>();
setPduType(pdutype); setPduType(pdutype);
} }
...@@ -191,7 +189,7 @@ final class SnmpRequestTree { ...@@ -191,7 +189,7 @@ final class SnmpRequestTree {
// SnmSubRequest associated with an Handler node. // SnmSubRequest associated with an Handler node.
//------------------------------------------------------------------- //-------------------------------------------------------------------
static final class Enum implements Enumeration { static final class Enum implements Enumeration<SnmpMibSubRequest> {
Enum(SnmpRequestTree hlist,Handler h) { Enum(SnmpRequestTree hlist,Handler h) {
handler = h; handler = h;
this.hlist = hlist; this.hlist = hlist;
...@@ -203,11 +201,13 @@ final class SnmpRequestTree { ...@@ -203,11 +201,13 @@ final class SnmpRequestTree {
private int iter = 0; private int iter = 0;
private int size = 0; private int size = 0;
@Override
public boolean hasMoreElements() { public boolean hasMoreElements() {
return iter < size; return iter < size;
} }
public Object nextElement() throws NoSuchElementException { @Override
public SnmpMibSubRequest nextElement() throws NoSuchElementException {
if (iter == 0) { if (iter == 0) {
if (handler.sublist != null) { if (handler.sublist != null) {
iter++; iter++;
...@@ -216,7 +216,7 @@ final class SnmpRequestTree { ...@@ -216,7 +216,7 @@ final class SnmpRequestTree {
} }
iter ++; iter ++;
if (iter > size) throw new NoSuchElementException(); if (iter > size) throw new NoSuchElementException();
Object result = hlist.getSubRequest(handler,entry); SnmpMibSubRequest result = hlist.getSubRequest(handler,entry);
entry++; entry++;
return result; return result;
} }
...@@ -252,7 +252,8 @@ final class SnmpRequestTree { ...@@ -252,7 +252,8 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
public Enumeration getElements() { @Override
public Enumeration<SnmpVarBind> getElements() {
return varbinds.elements(); return varbinds.elements();
} }
...@@ -260,6 +261,7 @@ final class SnmpRequestTree { ...@@ -260,6 +261,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public Vector<SnmpVarBind> getSubList() { public Vector<SnmpVarBind> getSubList() {
return varbinds; return varbinds;
} }
...@@ -268,6 +270,7 @@ final class SnmpRequestTree { ...@@ -268,6 +270,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public final int getSize() { public final int getSize() {
if (varbinds == null) return 0; if (varbinds == null) return 0;
return varbinds.size(); return varbinds.size();
...@@ -277,6 +280,7 @@ final class SnmpRequestTree { ...@@ -277,6 +280,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public void addVarBind(SnmpVarBind varbind) { public void addVarBind(SnmpVarBind varbind) {
// XXX not sure we must also add the varbind in the global // XXX not sure we must also add the varbind in the global
// request? or whether we should raise an exception: // request? or whether we should raise an exception:
...@@ -289,6 +293,7 @@ final class SnmpRequestTree { ...@@ -289,6 +293,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibSubRequest interface. // Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc. // See SnmpMibSubRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public boolean isNewEntry() { public boolean isNewEntry() {
return isnew; return isnew;
} }
...@@ -297,6 +302,7 @@ final class SnmpRequestTree { ...@@ -297,6 +302,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibSubRequest interface. // Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc. // See SnmpMibSubRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public SnmpOid getEntryOid() { public SnmpOid getEntryOid() {
return entryoid; return entryoid;
} }
...@@ -305,6 +311,7 @@ final class SnmpRequestTree { ...@@ -305,6 +311,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public int getVarIndex(SnmpVarBind varbind) { public int getVarIndex(SnmpVarBind varbind) {
if (varbind == null) return 0; if (varbind == null) return 0;
return global.getVarIndex(varbind); return global.getVarIndex(varbind);
...@@ -314,6 +321,7 @@ final class SnmpRequestTree { ...@@ -314,6 +321,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public Object getUserData() { return global.getUserData(); } public Object getUserData() { return global.getUserData(); }
...@@ -322,6 +330,7 @@ final class SnmpRequestTree { ...@@ -322,6 +330,7 @@ final class SnmpRequestTree {
// See SnmpMibSubRequest for the java doc. // See SnmpMibSubRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public void registerGetException(SnmpVarBind var, public void registerGetException(SnmpVarBind var,
SnmpStatusException exception) SnmpStatusException exception)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -364,6 +373,7 @@ final class SnmpRequestTree { ...@@ -364,6 +373,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibSubRequest interface. // Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc. // See SnmpMibSubRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public void registerSetException(SnmpVarBind var, public void registerSetException(SnmpVarBind var,
SnmpStatusException exception) SnmpStatusException exception)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -387,6 +397,7 @@ final class SnmpRequestTree { ...@@ -387,6 +397,7 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibSubRequest interface. // Implements the method defined in SnmpMibSubRequest interface.
// See SnmpMibSubRequest for the java doc. // See SnmpMibSubRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public void registerCheckException(SnmpVarBind var, public void registerCheckException(SnmpVarBind var,
SnmpStatusException exception) SnmpStatusException exception)
throws SnmpStatusException { throws SnmpStatusException {
...@@ -410,42 +421,52 @@ final class SnmpRequestTree { ...@@ -410,42 +421,52 @@ final class SnmpRequestTree {
// Implements the method defined in SnmpMibRequest interface. // Implements the method defined in SnmpMibRequest interface.
// See SnmpMibRequest for the java doc. // See SnmpMibRequest for the java doc.
// ------------------------------------------------------------- // -------------------------------------------------------------
@Override
public int getVersion() { public int getVersion() {
return version; return version;
} }
@Override
public SnmpVarBind getRowStatusVarBind() { public SnmpVarBind getRowStatusVarBind() {
return statusvb; return statusvb;
} }
@Override
public SnmpPdu getPdu() { public SnmpPdu getPdu() {
return global.getPdu(); return global.getPdu();
} }
@Override
public int getRequestPduVersion() { public int getRequestPduVersion() {
return global.getRequestPduVersion(); return global.getRequestPduVersion();
} }
@Override
public SnmpEngine getEngine() { public SnmpEngine getEngine() {
return global.getEngine(); return global.getEngine();
} }
@Override
public String getPrincipal() { public String getPrincipal() {
return global.getPrincipal(); return global.getPrincipal();
} }
@Override
public int getSecurityLevel() { public int getSecurityLevel() {
return global.getSecurityLevel(); return global.getSecurityLevel();
} }
@Override
public int getSecurityModel() { public int getSecurityModel() {
return global.getSecurityModel(); return global.getSecurityModel();
} }
@Override
public byte[] getContextName() { public byte[] getContextName() {
return global.getContextName(); return global.getContextName();
} }
@Override
public byte[] getAccessContextName() { public byte[] getAccessContextName() {
return global.getAccessContextName(); return global.getAccessContextName();
} }
...@@ -485,7 +506,7 @@ final class SnmpRequestTree { ...@@ -485,7 +506,7 @@ final class SnmpRequestTree {
* Adds a varbind in this node sublist. * Adds a varbind in this node sublist.
*/ */
public void addVarbind(SnmpVarBind varbind) { public void addVarbind(SnmpVarBind varbind) {
if (sublist == null) sublist = new Vector<SnmpVarBind>(); if (sublist == null) sublist = new Vector<>();
sublist.addElement(varbind); sublist.addElement(varbind);
} }
...@@ -503,7 +524,7 @@ final class SnmpRequestTree { ...@@ -503,7 +524,7 @@ final class SnmpRequestTree {
// Vectors are null: Allocate new vectors // Vectors are null: Allocate new vectors
entryoids = new SnmpOid[Delta]; entryoids = new SnmpOid[Delta];
entrylists = new Vector[Delta]; entrylists = (Vector<SnmpVarBind>[])new Vector<?>[Delta];
isentrynew = new boolean[Delta]; isentrynew = new boolean[Delta];
rowstatus = new SnmpVarBind[Delta]; rowstatus = new SnmpVarBind[Delta];
entrysize = Delta; entrysize = Delta;
...@@ -521,7 +542,7 @@ final class SnmpRequestTree { ...@@ -521,7 +542,7 @@ final class SnmpRequestTree {
// Allocate larger vectors // Allocate larger vectors
entrysize += Delta; entrysize += Delta;
entryoids = new SnmpOid[entrysize]; entryoids = new SnmpOid[entrysize];
entrylists = new Vector[entrysize]; entrylists = (Vector<SnmpVarBind>[])new Vector<?>[entrysize];
isentrynew = new boolean[entrysize]; isentrynew = new boolean[entrysize];
rowstatus = new SnmpVarBind[entrysize]; rowstatus = new SnmpVarBind[entrysize];
...@@ -595,7 +616,7 @@ final class SnmpRequestTree { ...@@ -595,7 +616,7 @@ final class SnmpRequestTree {
// entryoids = new ArrayList(); // entryoids = new ArrayList();
// entrylists = new ArrayList(); // entrylists = new ArrayList();
// isentrynew = new ArrayList(); // isentrynew = new ArrayList();
v = new Vector<SnmpVarBind>(); v = new Vector<>();
// entryoids.add(entryoid); // entryoids.add(entryoid);
// entrylists.add(v); // entrylists.add(v);
// isentrynew.add(new Boolean(isnew)); // isentrynew.add(new Boolean(isnew));
...@@ -614,7 +635,7 @@ final class SnmpRequestTree { ...@@ -614,7 +635,7 @@ final class SnmpRequestTree {
// if (pos == -1 || pos >= entrycount ) { // if (pos == -1 || pos >= entrycount ) {
// pos = getInsertionPoint(entryoids,entryoid); // pos = getInsertionPoint(entryoids,entryoid);
// pos = getInsertionPoint(entryoids,entrycount,entryoid); // pos = getInsertionPoint(entryoids,entrycount,entryoid);
v = new Vector<SnmpVarBind>(); v = new Vector<>();
// entryoids.add(pos,entryoid); // entryoids.add(pos,entryoid);
// entrylists.add(pos,v); // entrylists.add(pos,v);
// isentrynew.add(pos,new Boolean(isnew)); // isentrynew.add(pos,new Boolean(isnew));
...@@ -775,7 +796,7 @@ final class SnmpRequestTree { ...@@ -775,7 +796,7 @@ final class SnmpRequestTree {
// If it is a table, there will be one subrequest per entry involved. // 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); return new Enum(this,handler);
} }
...@@ -783,7 +804,7 @@ final class SnmpRequestTree { ...@@ -783,7 +804,7 @@ final class SnmpRequestTree {
// returns an enumeration of the Handlers stored in the Hashtable. // returns an enumeration of the Handlers stored in the Hashtable.
//------------------------------------------------------------------- //-------------------------------------------------------------------
public Enumeration getHandlers() { public Enumeration<Handler> getHandlers() {
return hashtable.elements(); return hashtable.elements();
} }
...@@ -1048,7 +1069,6 @@ final class SnmpRequestTree { ...@@ -1048,7 +1069,6 @@ final class SnmpRequestTree {
handler.addVarbind(varbind); handler.addVarbind(varbind);
else else
handler.addVarbind(varbind,entryoid,isnew,statusvb); handler.addVarbind(varbind,entryoid,isnew,statusvb);
return ;
} }
......
...@@ -27,14 +27,7 @@ package com.sun.jmx.snmp.agent; ...@@ -27,14 +27,7 @@ package com.sun.jmx.snmp.agent;
// java imports // java imports
// //
import java.io.Serializable; import java.io.Serializable;
import java.util.Hashtable;
import java.util.Enumeration; 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.SnmpVarBind;
import com.sun.jmx.snmp.SnmpStatusException; import com.sun.jmx.snmp.SnmpStatusException;
...@@ -121,8 +114,8 @@ public class SnmpStandardObjectServer implements Serializable { ...@@ -121,8 +114,8 @@ public class SnmpStandardObjectServer implements Serializable {
final Object data = req.getUserData(); final Object data = req.getUserData();
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
final SnmpVarBind var= (SnmpVarBind) e.nextElement(); final SnmpVarBind var= e.nextElement();
try { try {
final long id = var.oid.getOidArc(depth); final long id = var.oid.getOidArc(depth);
var.value = meta.get(id, data); var.value = meta.get(id, data);
...@@ -182,9 +175,8 @@ public class SnmpStandardObjectServer implements Serializable { ...@@ -182,9 +175,8 @@ public class SnmpStandardObjectServer implements Serializable {
final Object data = req.getUserData(); final Object data = req.getUserData();
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
SnmpVarBind var = null; SnmpVarBind var = e.nextElement();
var = (SnmpVarBind) e.nextElement();
try { try {
// This method will generate a SnmpStatusException // This method will generate a SnmpStatusException
// if `depth' is out of bounds. // if `depth' is out of bounds.
...@@ -248,8 +240,8 @@ public class SnmpStandardObjectServer implements Serializable { ...@@ -248,8 +240,8 @@ public class SnmpStandardObjectServer implements Serializable {
final Object data = req.getUserData(); final Object data = req.getUserData();
for (Enumeration e= req.getElements(); e.hasMoreElements();) { for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements();) {
final SnmpVarBind var = (SnmpVarBind) e.nextElement(); final SnmpVarBind var = e.nextElement();
try { try {
// This method will generate a SnmpStatusException // This method will generate a SnmpStatusException
// if `depth' is out of bounds. // if `depth' is out of bounds.
......
...@@ -33,7 +33,6 @@ package com.sun.jmx.snmp.daemon; ...@@ -33,7 +33,6 @@ package com.sun.jmx.snmp.daemon;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Enumeration;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.Vector; import java.util.Vector;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
...@@ -50,8 +49,6 @@ import javax.management.NotificationBroadcasterSupport; ...@@ -50,8 +49,6 @@ import javax.management.NotificationBroadcasterSupport;
import javax.management.MBeanNotificationInfo; import javax.management.MBeanNotificationInfo;
import javax.management.AttributeChangeNotification; import javax.management.AttributeChangeNotification;
import javax.management.ListenerNotFoundException; import javax.management.ListenerNotFoundException;
import javax.management.loading.ClassLoaderRepository;
import javax.management.MBeanServerFactory;
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER; import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
...@@ -225,9 +222,8 @@ public abstract class CommunicatorServer ...@@ -225,9 +222,8 @@ public abstract class CommunicatorServer
private transient Object stateLock = new Object(); private transient Object stateLock = new Object();
private transient Vector<ClientHandler> private transient Vector<ClientHandler>
clientHandlerVector = new Vector<ClientHandler>() ; clientHandlerVector = new Vector<>() ;
private transient Thread fatherThread = Thread.currentThread() ;
private transient Thread mainThread = null ; private transient Thread mainThread = null ;
private volatile boolean stopRequested = false ; private volatile boolean stopRequested = false ;
...@@ -328,6 +324,7 @@ public abstract class CommunicatorServer ...@@ -328,6 +324,7 @@ public abstract class CommunicatorServer
* Has no effect if this <CODE>CommunicatorServer</CODE> is * Has no effect if this <CODE>CommunicatorServer</CODE> is
* <CODE>ONLINE</CODE> or <CODE>STOPPING</CODE>. * <CODE>ONLINE</CODE> or <CODE>STOPPING</CODE>.
*/ */
@Override
public void start() { public void start() {
try { try {
start(0); start(0);
...@@ -346,6 +343,7 @@ public abstract class CommunicatorServer ...@@ -346,6 +343,7 @@ public abstract class CommunicatorServer
* Has no effect if this <CODE>CommunicatorServer</CODE> is * Has no effect if this <CODE>CommunicatorServer</CODE> is
* <CODE>OFFLINE</CODE> or <CODE>STOPPING</CODE>. * <CODE>OFFLINE</CODE> or <CODE>STOPPING</CODE>.
*/ */
@Override
public void stop() { public void stop() {
synchronized (stateLock) { synchronized (stateLock) {
if (state == OFFLINE || state == STOPPING) { if (state == OFFLINE || state == STOPPING) {
...@@ -393,6 +391,7 @@ public abstract class CommunicatorServer ...@@ -393,6 +391,7 @@ public abstract class CommunicatorServer
* *
* @return True if connector is <CODE>ONLINE</CODE>; false otherwise. * @return True if connector is <CODE>ONLINE</CODE>; false otherwise.
*/ */
@Override
public boolean isActive() { public boolean isActive() {
synchronized (stateLock) { synchronized (stateLock) {
return (state == ONLINE); return (state == ONLINE);
...@@ -431,6 +430,7 @@ public abstract class CommunicatorServer ...@@ -431,6 +430,7 @@ public abstract class CommunicatorServer
* @return true if the value of this MBean's State attribute is the * @return true if the value of this MBean's State attribute is the
* same as the <VAR>wantedState</VAR> parameter; false otherwise. * same as the <VAR>wantedState</VAR> parameter; false otherwise.
*/ */
@Override
public boolean waitState(int wantedState, long timeOut) { public boolean waitState(int wantedState, long timeOut) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
...@@ -595,6 +595,7 @@ public abstract class CommunicatorServer ...@@ -595,6 +595,7 @@ public abstract class CommunicatorServer
* @return <CODE>ONLINE</CODE>, <CODE>OFFLINE</CODE>, * @return <CODE>ONLINE</CODE>, <CODE>OFFLINE</CODE>,
* <CODE>STARTING</CODE> or <CODE>STOPPING</CODE>. * <CODE>STARTING</CODE> or <CODE>STOPPING</CODE>.
*/ */
@Override
public int getState() { public int getState() {
synchronized (stateLock) { synchronized (stateLock) {
return state ; return state ;
...@@ -607,6 +608,7 @@ public abstract class CommunicatorServer ...@@ -607,6 +608,7 @@ public abstract class CommunicatorServer
* @return One of the strings "ONLINE", "OFFLINE", "STARTING" or * @return One of the strings "ONLINE", "OFFLINE", "STARTING" or
* "STOPPING". * "STOPPING".
*/ */
@Override
public String getStateString() { public String getStateString() {
return getStringForState(state) ; return getStringForState(state) ;
} }
...@@ -616,6 +618,7 @@ public abstract class CommunicatorServer ...@@ -616,6 +618,7 @@ public abstract class CommunicatorServer
* *
* @return The host name used by this <CODE>CommunicatorServer</CODE>. * @return The host name used by this <CODE>CommunicatorServer</CODE>.
*/ */
@Override
public String getHost() { public String getHost() {
try { try {
host = InetAddress.getLocalHost().getHostName(); host = InetAddress.getLocalHost().getHostName();
...@@ -630,6 +633,7 @@ public abstract class CommunicatorServer ...@@ -630,6 +633,7 @@ public abstract class CommunicatorServer
* *
* @return The port number used by this <CODE>CommunicatorServer</CODE>. * @return The port number used by this <CODE>CommunicatorServer</CODE>.
*/ */
@Override
public int getPort() { public int getPort() {
synchronized (stateLock) { synchronized (stateLock) {
return port ; return port ;
...@@ -645,6 +649,7 @@ public abstract class CommunicatorServer ...@@ -645,6 +649,7 @@ public abstract class CommunicatorServer
* @exception java.lang.IllegalStateException This method has been invoked * @exception java.lang.IllegalStateException This method has been invoked
* while the communicator was ONLINE or STARTING. * while the communicator was ONLINE or STARTING.
*/ */
@Override
public void setPort(int port) throws java.lang.IllegalStateException { public void setPort(int port) throws java.lang.IllegalStateException {
synchronized (stateLock) { synchronized (stateLock) {
if ((state == ONLINE) || (state == STARTING)) if ((state == ONLINE) || (state == STARTING))
...@@ -659,7 +664,8 @@ public abstract class CommunicatorServer ...@@ -659,7 +664,8 @@ public abstract class CommunicatorServer
* Gets the protocol being used by this <CODE>CommunicatorServer</CODE>. * Gets the protocol being used by this <CODE>CommunicatorServer</CODE>.
* @return The protocol as a string. * @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 * Gets the number of clients that have been processed by this
...@@ -754,6 +760,7 @@ public abstract class CommunicatorServer ...@@ -754,6 +760,7 @@ public abstract class CommunicatorServer
* <p> * <p>
* The <CODE>run</CODE> method executed by this connector's main thread. * The <CODE>run</CODE> method executed by this connector's main thread.
*/ */
@Override
public void run() { public void run() {
// Fix jaw.00667.B // Fix jaw.00667.B
...@@ -851,7 +858,7 @@ public abstract class CommunicatorServer ...@@ -851,7 +858,7 @@ public abstract class CommunicatorServer
} finally { } finally {
synchronized (stateLock) { synchronized (stateLock) {
interrupted = true; interrupted = true;
Thread.currentThread().interrupted(); Thread.interrupted();
} }
// ---------------------- // ----------------------
...@@ -970,7 +977,7 @@ public abstract class CommunicatorServer ...@@ -970,7 +977,7 @@ public abstract class CommunicatorServer
"MBeanServer argument must be MBean server where this " + "MBeanServer argument must be MBean server where this " +
"server is registered, or an MBeanServerForwarder " + "server is registered, or an MBeanServerForwarder " +
"leading to that server"; "leading to that server";
Vector<MBeanServer> seenMBS = new Vector<MBeanServer>(); Vector<MBeanServer> seenMBS = new Vector<>();
for (MBeanServer mbs = newMBS; for (MBeanServer mbs = newMBS;
mbs != bottomMBS; mbs != bottomMBS;
mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) { mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) {
...@@ -1153,8 +1160,7 @@ public abstract class CommunicatorServer ...@@ -1153,8 +1160,7 @@ public abstract class CommunicatorServer
state = OFFLINE; state = OFFLINE;
stopRequested = false; stopRequested = false;
servedClientCount = 0; servedClientCount = 0;
clientHandlerVector = new Vector<ClientHandler>(); clientHandlerVector = new Vector<>();
fatherThread = Thread.currentThread();
mainThread = null; mainThread = null;
notifCount = 0; notifCount = 0;
notifInfos = null; notifInfos = null;
...@@ -1184,6 +1190,7 @@ public abstract class CommunicatorServer ...@@ -1184,6 +1190,7 @@ public abstract class CommunicatorServer
* *
* @exception IllegalArgumentException Listener parameter is null. * @exception IllegalArgumentException Listener parameter is null.
*/ */
@Override
public void addNotificationListener(NotificationListener listener, public void addNotificationListener(NotificationListener listener,
NotificationFilter filter, NotificationFilter filter,
Object handback) Object handback)
...@@ -1207,6 +1214,7 @@ public abstract class CommunicatorServer ...@@ -1207,6 +1214,7 @@ public abstract class CommunicatorServer
* *
* @exception ListenerNotFoundException The listener is not registered. * @exception ListenerNotFoundException The listener is not registered.
*/ */
@Override
public void removeNotificationListener(NotificationListener listener) public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException { throws ListenerNotFoundException {
...@@ -1225,6 +1233,7 @@ public abstract class CommunicatorServer ...@@ -1225,6 +1233,7 @@ public abstract class CommunicatorServer
* sent when the <tt>State</tt> attribute of this CommunicatorServer * sent when the <tt>State</tt> attribute of this CommunicatorServer
* changes. * changes.
*/ */
@Override
public MBeanNotificationInfo[] getNotificationInfo() { public MBeanNotificationInfo[] getNotificationInfo() {
// Initialize notifInfos on first call to getNotificationInfo() // Initialize notifInfos on first call to getNotificationInfo()
...@@ -1304,6 +1313,7 @@ public abstract class CommunicatorServer ...@@ -1304,6 +1313,7 @@ public abstract class CommunicatorServer
* the <CODE>MBeanServer</CODE> and re-thrown * the <CODE>MBeanServer</CODE> and re-thrown
* as an <CODE>MBeanRegistrationException</CODE>. * as an <CODE>MBeanRegistrationException</CODE>.
*/ */
@Override
public ObjectName preRegister(MBeanServer server, ObjectName name) public ObjectName preRegister(MBeanServer server, ObjectName name)
throws java.lang.Exception { throws java.lang.Exception {
objectName = name; objectName = name;
...@@ -1325,6 +1335,7 @@ public abstract class CommunicatorServer ...@@ -1325,6 +1335,7 @@ public abstract class CommunicatorServer
* successfully registered in the <CODE>MBeanServer</CODE>. * successfully registered in the <CODE>MBeanServer</CODE>.
* The value false means that the registration phase has failed. * The value false means that the registration phase has failed.
*/ */
@Override
public void postRegister(Boolean registrationDone) { public void postRegister(Boolean registrationDone) {
if (!registrationDone.booleanValue()) { if (!registrationDone.booleanValue()) {
synchronized (this) { synchronized (this) {
...@@ -1340,6 +1351,7 @@ public abstract class CommunicatorServer ...@@ -1340,6 +1351,7 @@ public abstract class CommunicatorServer
* the <CODE>MBeanServer</CODE> and re-thrown * the <CODE>MBeanServer</CODE> and re-thrown
* as an <CODE>MBeanRegistrationException</CODE>. * as an <CODE>MBeanRegistrationException</CODE>.
*/ */
@Override
public void preDeregister() throws java.lang.Exception { public void preDeregister() throws java.lang.Exception {
synchronized (this) { synchronized (this) {
topMBS = bottomMBS = null; topMBS = bottomMBS = null;
...@@ -1354,22 +1366,8 @@ public abstract class CommunicatorServer ...@@ -1354,22 +1366,8 @@ public abstract class CommunicatorServer
/** /**
* Do nothing. * Do nothing.
*/ */
@Override
public void postDeregister(){ 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);
}
}
} }
...@@ -140,6 +140,7 @@ public interface SnmpAdaptorServerMBean extends CommunicatorServerMBean { ...@@ -140,6 +140,7 @@ public interface SnmpAdaptorServerMBean extends CommunicatorServerMBean {
* *
* @return The string "snmp". * @return The string "snmp".
*/ */
@Override
public String getProtocol(); public String getProtocol();
/** /**
...@@ -636,7 +637,8 @@ public interface SnmpAdaptorServerMBean extends CommunicatorServerMBean { ...@@ -636,7 +637,8 @@ public interface SnmpAdaptorServerMBean extends CommunicatorServerMBean {
* @exception IOException An I/O error occurred while sending the inform request. * @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>. * @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; throws IllegalStateException, IOException, SnmpStatusException;
/** /**
......
...@@ -125,7 +125,7 @@ final class SnmpMibTree { ...@@ -125,7 +125,7 @@ final class SnmpMibTree {
TreeNode node= retrieveChild(oid, cursor); TreeNode node= retrieveChild(oid, cursor);
if (node == null) if (node == null)
return this; return this;
if (children.size() == 0) { if (children.isEmpty()) {
// In this case, the node does not have any children. So no point to // In this case, the node does not have any children. So no point to
// continue the search ... // continue the search ...
return node; return node;
...@@ -149,24 +149,24 @@ final class SnmpMibTree { ...@@ -149,24 +149,24 @@ final class SnmpMibTree {
public void printTree(String ident) { public void printTree(String ident) {
StringBuffer buff= new StringBuffer(); StringBuilder buff= new StringBuilder();
if (agents == null) { if (agents == null) {
return; return;
} }
for(Enumeration e= agents.elements(); e.hasMoreElements(); ) { for(Enumeration<SnmpMibAgent> e= agents.elements(); e.hasMoreElements(); ) {
SnmpMibAgent mib= (SnmpMibAgent) e.nextElement(); SnmpMibAgent mib= e.nextElement();
if (mib == null) if (mib == null)
buff.append("empty "); buff.append("empty ");
else else
buff.append(mib.getMibName() + " "); buff.append(mib.getMibName()).append(" ");
} }
ident+= " "; ident+= " ";
if (children == null) { if (children == null) {
return; return;
} }
for(Enumeration e= children.elements(); e.hasMoreElements(); ) { for(Enumeration<TreeNode> e= children.elements(); e.hasMoreElements(); ) {
TreeNode node= (TreeNode) e.nextElement(); TreeNode node= e.nextElement();
node.printTree(ident); node.printTree(ident);
} }
} }
...@@ -185,7 +185,7 @@ final class SnmpMibTree { ...@@ -185,7 +185,7 @@ final class SnmpMibTree {
} }
private void removeAgentFully(SnmpMibAgent agent) { private void removeAgentFully(SnmpMibAgent agent) {
Vector<TreeNode> v = new Vector<TreeNode>(); Vector<TreeNode> v = new Vector<>();
for(Enumeration<TreeNode> e= children.elements(); for(Enumeration<TreeNode> e= children.elements();
e.hasMoreElements(); ) { e.hasMoreElements(); ) {
...@@ -212,9 +212,9 @@ final class SnmpMibTree { ...@@ -212,9 +212,9 @@ final class SnmpMibTree {
} }
private void setAgent(SnmpMibAgent agent) { private void setAgent(SnmpMibAgent agent) {
this.agent = agent; this.agent = agent;
} }
private void registerNode(long[] oid, int cursor, SnmpMibAgent agent) { private void registerNode(long[] oid, int cursor, SnmpMibAgent agent) {
...@@ -247,20 +247,20 @@ final class SnmpMibTree { ...@@ -247,20 +247,20 @@ final class SnmpMibTree {
private TreeNode retrieveChild(long[] oid, int current) { private TreeNode retrieveChild(long[] oid, int current) {
long theValue= oid[current]; long theValue= oid[current];
for(Enumeration e= children.elements(); e.hasMoreElements(); ) { for(Enumeration<TreeNode> e= children.elements(); e.hasMoreElements(); ) {
TreeNode node= (TreeNode) e.nextElement(); TreeNode node= e.nextElement();
if (node.match(theValue)) if (node.match(theValue))
return node; return node;
} }
return null; return null;
} }
final private boolean match(long value) { private boolean match(long value) {
return (nodeValue == value) ? true : false; return (nodeValue == value) ? true : false;
} }
private Vector<TreeNode> children= new Vector<TreeNode>(); private Vector<TreeNode> children= new Vector<>();
private Vector<SnmpMibAgent> agents= new Vector<SnmpMibAgent>(); private Vector<SnmpMibAgent> agents= new Vector<>();
private long nodeValue; private long nodeValue;
private SnmpMibAgent agent; private SnmpMibAgent agent;
private TreeNode parent; private TreeNode parent;
......
...@@ -71,9 +71,9 @@ import com.sun.jmx.snmp.InetAddressAcl; ...@@ -71,9 +71,9 @@ import com.sun.jmx.snmp.InetAddressAcl;
class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
private transient DatagramSocket socket = null ; private transient DatagramSocket socket = null ;
private transient DatagramPacket packet = null ; private transient DatagramPacket packet = null ;
private transient Vector mibs = null ; private transient Vector<SnmpMibAgent> mibs = null ;
/** /**
* Contains the list of sub-requests associated to the current request. * Contains the list of sub-requests associated to the current request.
...@@ -85,7 +85,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -85,7 +85,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
*/ */
private transient SnmpMibTree root; private transient SnmpMibTree root;
private transient Object ipacl = null ; private transient InetAddressAcl ipacl = null ;
private transient SnmpPduFactory pduFactory = null ; private transient SnmpPduFactory pduFactory = null ;
private transient SnmpUserDataFactory userDataFactory = null ; private transient SnmpUserDataFactory userDataFactory = null ;
private transient SnmpAdaptorServer adaptor = null; private transient SnmpAdaptorServer adaptor = null;
...@@ -94,7 +94,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -94,7 +94,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
*/ */
public SnmpRequestHandler(SnmpAdaptorServer server, int id, public SnmpRequestHandler(SnmpAdaptorServer server, int id,
DatagramSocket s, DatagramPacket p, DatagramSocket s, DatagramPacket p,
SnmpMibTree tree, Vector m, Object a, SnmpMibTree tree, Vector<SnmpMibAgent> m,
InetAddressAcl a,
SnmpPduFactory factory, SnmpPduFactory factory,
SnmpUserDataFactory dataFactory, SnmpUserDataFactory dataFactory,
MBeanServer f, ObjectName n) MBeanServer f, ObjectName n)
...@@ -108,8 +109,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -108,8 +109,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
socket = s; socket = s;
packet = p; packet = p;
root= tree; root= tree;
mibs = (Vector) m.clone(); mibs = new Vector<>(m);
subs= new Hashtable<SnmpMibAgent, SnmpSubRequestHandler>(mibs.size()); subs= new Hashtable<>(mibs.size());
ipacl = a; ipacl = a;
pduFactory = factory ; pduFactory = factory ;
userDataFactory = dataFactory ; userDataFactory = dataFactory ;
...@@ -121,6 +122,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -121,6 +122,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
* back to the client. * back to the client.
* Note: we overwrite 'packet' with the response bytes. * Note: we overwrite 'packet' with the response bytes.
*/ */
@Override
public void doRun() { public void doRun() {
// Trace the input packet // Trace the input packet
...@@ -243,7 +245,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -243,7 +245,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Transform the request message into a request pdu // Transform the request message into a request pdu
// //
SnmpPduPacket reqPdu = null ; SnmpPduPacket reqPdu;
Object userData = null; Object userData = null;
try { try {
reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ; reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ;
...@@ -306,7 +308,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -306,7 +308,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"makeResponseMessage", "fail on element" + pos); "makeResponseMessage", "fail on element" + pos);
} }
int old= 0; int old;
while (true) { while (true) {
try { try {
respPdu = reduceResponsePdu(reqPdu, respPdu, pos) ; respPdu = reduceResponsePdu(reqPdu, respPdu, pos) ;
...@@ -580,20 +582,18 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -580,20 +582,18 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
Object userData) { Object userData) {
int errorStatus = SnmpDefinitions.snmpRspNoError ; 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 it's a set request, we must first check any varBind
// //
if (req.type == pduSetRequestPdu) { if (req.type == pduSetRequestPdu) {
i=0; 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 ... // Indicate to the sub request that a check must be invoked ...
// OK we should have defined out own tag for that ! // OK we should have defined out own tag for that !
// //
SnmpSubRequestHandler sub= (SnmpSubRequestHandler) SnmpSubRequestHandler sub= e.nextElement();
e.nextElement();
sub.setUserData(userData); sub.setUserData(userData);
sub.type= pduWalkRequest; sub.type= pduWalkRequest;
...@@ -618,8 +618,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -618,8 +618,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Let's start the sub-requests. // Let's start the sub-requests.
// //
i=0; i=0;
for(Enumeration e= subs.elements(); e.hasMoreElements() ;i++) { for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements() ;i++) {
SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement(); SnmpSubRequestHandler sub= e.nextElement();
/* NPCTE fix for bugId 4492741, esc 0, 16-August 2001 */ /* NPCTE fix for bugId 4492741, esc 0, 16-August 2001 */
sub.setUserData(userData); sub.setUserData(userData);
/* end of NPCTE fix for bugId 4492741 */ /* end of NPCTE fix for bugId 4492741 */
...@@ -650,7 +650,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -650,7 +650,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req, private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
Object userData) { Object userData) {
int errorStatus = SnmpDefinitions.snmpRspNoError ; int errorStatus;
SnmpSubRequestHandler sub = subs.elements().nextElement(); SnmpSubRequestHandler sub = subs.elements().nextElement();
sub.setUserData(userData); sub.setUserData(userData);
...@@ -707,7 +707,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -707,7 +707,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
private SnmpPduPacket makeGetBulkResponsePdu(SnmpPduBulk req, private SnmpPduPacket makeGetBulkResponsePdu(SnmpPduBulk req,
Object userData) { Object userData) {
SnmpVarBind[] respVarBindList = null ; SnmpVarBind[] respVarBindList;
// RFC 1905, Section 4.2.3, p14 // RFC 1905, Section 4.2.3, p14
int L = req.varBindList.length ; int L = req.varBindList.length ;
...@@ -761,7 +761,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -761,7 +761,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
*/ */
private boolean checkPduType(SnmpPduPacket pdu) { private boolean checkPduType(SnmpPduPacket pdu) {
boolean result = true ; boolean result;
switch(pdu.type) { switch(pdu.type) {
...@@ -798,8 +798,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -798,8 +798,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// //
if (ipacl != null) { if (ipacl != null) {
if (pdu.type == SnmpDefinitions.pduSetRequestPdu) { if (pdu.type == SnmpDefinitions.pduSetRequestPdu) {
if (!((InetAddressAcl)ipacl). if (!ipacl.checkWritePermission(pdu.address, community)) {
checkWritePermission(pdu.address, community)) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"checkAcl", "sender is " + pdu.address + "checkAcl", "sender is " + pdu.address +
...@@ -820,7 +819,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -820,7 +819,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
} }
} }
else { else {
if (!((InetAddressAcl)ipacl).checkReadPermission(pdu.address, community)) { if (!ipacl.checkReadPermission(pdu.address, community)) {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"checkAcl", "sender is " + pdu.address + "checkAcl", "sender is " + pdu.address +
...@@ -854,7 +853,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -854,7 +853,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
if (response != null) { if (response != null) {
SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ; SnmpAdaptorServer snmpServer = (SnmpAdaptorServer)adaptorServer ;
snmpServer.incSnmpInBadCommunityUses(1) ; snmpServer.incSnmpInBadCommunityUses(1) ;
if (((InetAddressAcl)ipacl).checkCommunity(community) == false) if (ipacl.checkCommunity(community) == false)
snmpServer.incSnmpInBadCommunityNames(1) ; snmpServer.incSnmpInBadCommunityNames(1) ;
} }
...@@ -873,7 +872,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -873,7 +872,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
result.port = reqPdu.port ; result.port = reqPdu.port ;
result.version = reqPdu.version ; result.version = reqPdu.version ;
result.community = reqPdu.community ; result.community = reqPdu.community ;
result.type = result.pduGetResponsePdu ; result.type = SnmpPduRequest.pduGetResponsePdu ;
result.requestId = reqPdu.requestId ; result.requestId = reqPdu.requestId ;
result.errorStatus = SnmpDefinitions.snmpRspNoError ; result.errorStatus = SnmpDefinitions.snmpRspNoError ;
result.errorIndex = 0 ; result.errorIndex = 0 ;
...@@ -904,7 +903,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -904,7 +903,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
private SnmpMessage newTooBigMessage(SnmpMessage reqMsg) private SnmpMessage newTooBigMessage(SnmpMessage reqMsg)
throws SnmpTooBigException { throws SnmpTooBigException {
SnmpMessage result = null ; SnmpMessage result = null ;
SnmpPduPacket reqPdu = null ; SnmpPduPacket reqPdu;
try { try {
reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ; reqPdu = (SnmpPduPacket)pduFactory.decodeSnmpPdu(reqMsg) ;
...@@ -941,7 +940,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -941,7 +940,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Reduction can be attempted only on bulk response // 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)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"reduceResponsePdu", "cannot remove anything"); "reduceResponsePdu", "cannot remove anything");
...@@ -961,7 +960,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -961,7 +960,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// * when it is 0 (in fact, acceptedVbCount is not available), // * when it is 0 (in fact, acceptedVbCount is not available),
// we split the varbindlist by 2. // we split the varbindlist by 2.
// //
int vbCount = resp.varBindList.length ; int vbCount;
if (acceptedVbCount >= 3) if (acceptedVbCount >= 3)
vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ; vbCount = Math.min(acceptedVbCount - 1, resp.varBindList.length) ;
else if (acceptedVbCount == 1) else if (acceptedVbCount == 1)
...@@ -998,7 +997,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -998,7 +997,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
private void splitRequest(SnmpPduRequest req) { private void splitRequest(SnmpPduRequest req) {
int nbAgents= mibs.size(); int nbAgents= mibs.size();
SnmpMibAgent agent= (SnmpMibAgent) mibs.firstElement(); SnmpMibAgent agent = mibs.firstElement();
if (nbAgents == 1) { if (nbAgents == 1) {
// Take all the oids contained in the request and // Take all the oids contained in the request and
// //
...@@ -1010,8 +1009,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1010,8 +1009,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// to all agents // to all agents
// //
if (req.type == pduGetNextRequestPdu) { if (req.type == pduGetNextRequestPdu) {
for(Enumeration e= mibs.elements(); e.hasMoreElements(); ) { for(Enumeration<SnmpMibAgent> e= mibs.elements(); e.hasMoreElements(); ) {
SnmpMibAgent ag= (SnmpMibAgent) e.nextElement(); final SnmpMibAgent ag= e.nextElement();
subs.put(ag, new SnmpSubNextRequestHandler(adaptor, ag, req)); subs.put(ag, new SnmpSubNextRequestHandler(adaptor, ag, req));
} }
return; return;
...@@ -1047,8 +1046,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1047,8 +1046,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
int R) { int R) {
// Send the getBulk to all agents // Send the getBulk to all agents
// //
for(Enumeration e= mibs.elements(); e.hasMoreElements(); ) { for(Enumeration<SnmpMibAgent> e= mibs.elements(); e.hasMoreElements(); ) {
SnmpMibAgent agent = (SnmpMibAgent) e.nextElement(); final SnmpMibAgent agent = e.nextElement();
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
...@@ -1064,7 +1063,6 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1064,7 +1063,6 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
maxRepetitions, maxRepetitions,
R)); R));
} }
return;
} }
private SnmpPduPacket mergeResponses(SnmpPduRequest req) { private SnmpPduPacket mergeResponses(SnmpPduRequest req) {
...@@ -1078,8 +1076,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1078,8 +1076,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Go through the list of subrequests and concatenate. // Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished // Hopefully, by now all the sub-requests should be finished
// //
for(Enumeration e= subs.elements(); e.hasMoreElements();) { for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement(); SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result); sub.updateResult(result);
} }
return newValidResponsePdu(req,result); return newValidResponsePdu(req,result);
...@@ -1092,8 +1090,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1092,8 +1090,8 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Go through the list of subrequests and concatenate. // Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished // Hopefully, by now all the sub-requests should be finished
// //
for(Enumeration e= subs.elements(); e.hasMoreElements();) { for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement(); SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result); sub.updateResult(result);
} }
...@@ -1127,19 +1125,21 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions { ...@@ -1127,19 +1125,21 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
// Go through the list of subrequests and concatenate. // Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished // Hopefully, by now all the sub-requests should be finished
// //
for(Enumeration e= subs.elements(); e.hasMoreElements();) { for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
SnmpSubRequestHandler sub= (SnmpSubRequestHandler) e.nextElement(); SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result); sub.updateResult(result);
} }
return result; return result;
} }
@Override
protected String makeDebugTag() { protected String makeDebugTag() {
return "SnmpRequestHandler[" + adaptorServer.getProtocol() + ":" + return "SnmpRequestHandler[" + adaptorServer.getProtocol() + ":" +
adaptorServer.getPort() + "]"; adaptorServer.getPort() + "]";
} }
@Override
Thread createThread(Runnable r) { Thread createThread(Runnable r) {
return null; return null;
} }
......
...@@ -31,7 +31,6 @@ package com.sun.jmx.snmp.daemon; ...@@ -31,7 +31,6 @@ package com.sun.jmx.snmp.daemon;
// java import // java import
// //
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector;
import java.util.logging.Level; import java.util.logging.Level;
// jmx imports // jmx imports
// //
...@@ -46,9 +45,6 @@ import com.sun.jmx.snmp.SnmpEngine; ...@@ -46,9 +45,6 @@ import com.sun.jmx.snmp.SnmpEngine;
// //
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER; import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
import com.sun.jmx.snmp.agent.SnmpMibAgent; 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.internal.SnmpIncomingRequest;
import com.sun.jmx.snmp.ThreadContext; import com.sun.jmx.snmp.ThreadContext;
...@@ -85,6 +81,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler { ...@@ -85,6 +81,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler {
init(server, req, nonRepeat, maxRepeat, R); init(server, req, nonRepeat, maxRepeat, R);
} }
@Override
public void run() { public void run() {
size= varBind.size(); size= varBind.size();
...@@ -259,11 +256,12 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler { ...@@ -259,11 +256,12 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler {
* successful. As such the method getErrorIndex or getErrorStatus should be * successful. As such the method getErrorIndex or getErrorStatus should be
* called. * called.
*/ */
@Override
protected void updateResult(SnmpVarBind[] result) { protected void updateResult(SnmpVarBind[] result) {
// we can assume that the run method is over ... // 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; final int max= result.length;
// First go through all the values once ... // First go through all the values once ...
...@@ -284,7 +282,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler { ...@@ -284,7 +282,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler {
continue; continue;
} }
final SnmpVarBind element= (SnmpVarBind) e.nextElement(); final SnmpVarBind element= e.nextElement();
if (element == null) continue; if (element == null) continue;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
...@@ -309,7 +307,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler { ...@@ -309,7 +307,7 @@ class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler {
return; return;
if (e.hasMoreElements() ==false) if (e.hasMoreElements() ==false)
return; return;
final SnmpVarBind element= (SnmpVarBind) e.nextElement(); final SnmpVarBind element= e.nextElement();
if (element == null) continue; if (element == null) continue;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
......
...@@ -60,7 +60,7 @@ public class SnmpProperties { ...@@ -60,7 +60,7 @@ public class SnmpProperties {
InputStream is = new FileInputStream(file); InputStream is = new FileInputStream(file);
props.load(is); props.load(is);
is.close(); is.close();
for (final Enumeration e = props.keys(); e.hasMoreElements() ; ) { for (final Enumeration<?> e = props.keys(); e.hasMoreElements() ; ) {
final String key = (String) e.nextElement(); final String key = (String) e.nextElement();
System.setProperty(key,props.getProperty(key)); System.setProperty(key,props.getProperty(key));
} }
......
...@@ -199,7 +199,7 @@ public class ThreadService implements TaskServer { ...@@ -199,7 +199,7 @@ public class ThreadService implements TaskServer {
// re-init // re-init
this.setPriority(priority); this.setPriority(priority);
this.interrupted(); Thread.interrupted();
this.setContextClassLoader(cloader); this.setContextClassLoader(cloader);
} }
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -46,8 +46,8 @@ import java.lang.SecurityManager; ...@@ -46,8 +46,8 @@ import java.lang.SecurityManager;
* convention follows the hierarchical property naming convention. * convention follows the hierarchical property naming convention.
* Also, an asterisk * Also, an asterisk
* may appear at the end of the name, following a ".", or by itself, to * may appear at the end of the name, following a ".", or by itself, to
* signify a wildcard match. For example: "foo.*" or "*" is valid, * signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
* "*foo" or "a*b" is not valid. * match, while "*foo" and "a*b" do not.
* <P> * <P>
* The following table lists all the possible SSLPermission target names, * The following table lists all the possible SSLPermission target names,
* and for each provides a description of what the permission allows * and for each provides a description of what the permission allows
......
...@@ -1435,7 +1435,15 @@ public class ICC_Profile implements Serializable { ...@@ -1435,7 +1435,15 @@ public class ICC_Profile implements Serializable {
int renderingIntent = intFromBigEndian(theHeader, icHdrRenderingIntent); int renderingIntent = intFromBigEndian(theHeader, icHdrRenderingIntent);
/* set the rendering intent */ /* 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);
} }
......
...@@ -732,10 +732,16 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { ...@@ -732,10 +732,16 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp {
private int getRenderingIntent (ICC_Profile profile) { private int getRenderingIntent (ICC_Profile profile) {
byte[] header = profile.getData(ICC_Profile.icSigHead); byte[] header = profile.getData(ICC_Profile.icSigHead);
int index = ICC_Profile.icHdrRenderingIntent; int index = ICC_Profile.icHdrRenderingIntent;
return (((header[index] & 0xff) << 24) |
((header[index+1] & 0xff) << 16) | /* According to ICC spec, only the least-significant 16 bits shall be
((header[index+2] & 0xff) << 8) | * used to encode the rendering intent. The most significant 16 bits
(header[index+3] & 0xff)); * 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);
} }
/** /**
......
...@@ -177,11 +177,10 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -177,11 +177,10 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
ensureCapacityInternal(newLength); ensureCapacityInternal(newLength);
if (count < newLength) { if (count < newLength) {
for (; count < newLength; count++) Arrays.fill(value, count, newLength, '\0');
value[count] = '\0';
} else {
count = newLength;
} }
count = newLength;
} }
/** /**
...@@ -1308,8 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -1308,8 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* {@code null}. * {@code null}.
*/ */
public int indexOf(String str, int fromIndex) { public int indexOf(String str, int fromIndex) {
return String.indexOf(value, 0, count, return String.indexOf(value, 0, count, str, fromIndex);
str.toCharArray(), 0, str.length(), fromIndex);
} }
/** /**
...@@ -1352,8 +1350,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -1352,8 +1350,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* {@code null}. * {@code null}.
*/ */
public int lastIndexOf(String str, int fromIndex) { public int lastIndexOf(String str, int fromIndex) {
return String.lastIndexOf(value, 0, count, return String.lastIndexOf(value, 0, count, str, fromIndex);
str.toCharArray(), 0, str.length(), fromIndex);
} }
/** /**
......
...@@ -48,6 +48,7 @@ import java.util.List; ...@@ -48,6 +48,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import sun.reflect.ConstantPool; import sun.reflect.ConstantPool;
import sun.reflect.Reflection; import sun.reflect.Reflection;
...@@ -3044,34 +3045,62 @@ public final ...@@ -3044,34 +3045,62 @@ public final
* @throws NullPointerException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
* @since 1.5 * @since 1.5
*/ */
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) { public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
if (annotationClass == null) Objects.requireNonNull(annotationClass);
throw new NullPointerException();
initAnnotationsIfNecessary(); initAnnotationsIfNecessary();
return (A) annotations.get(annotationClass); return AnnotationSupport.getOneAnnotation(annotations, annotationClass);
} }
/** /**
* @throws NullPointerException {@inheritDoc} * @throws NullPointerException {@inheritDoc}
* @since 1.5 * @since 1.5
*/ */
public boolean isAnnotationPresent( public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
Class<? extends Annotation> annotationClass) { Objects.requireNonNull(annotationClass);
if (annotationClass == null)
throw new NullPointerException();
return getAnnotation(annotationClass) != null; 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 * @since 1.5
*/ */
public Annotation[] getAnnotations() { public Annotation[] getAnnotations() {
initAnnotationsIfNecessary(); 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 final ...@@ -3079,7 +3108,17 @@ public final
*/ */
public Annotation[] getDeclaredAnnotations() { public Annotation[] getDeclaredAnnotations() {
initAnnotationsIfNecessary(); 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 // Annotations cache
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册