-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
beta3
-
x86, sparc
-
generic, linux, solaris_2.6, windows_98
-
Verified
Name: asR10047 Date: 08/15/2001
Such behavior has been found during JCK test run against JDK-Merlin build b75.
NullPointerException is throwing from getOffscreenBuffer() and
getVolatileOffscreenBuffer() methods. Note, the exception is not throwing
when running with build b72 and early.
Here is the example demonstrating the bug:
------------------ RepaintManagerTest -----------------
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class RepaintManagerTest {
public static void main(String[] argv) {
TestComponent comp = new TestComponent();
RepaintManager c = new RepaintManager();
RepaintManager.setCurrentManager(c);
JFrame f = new JFrame();
f.getContentPane().add(comp);
f.setSize(100, 100);
comp.setSize(100, 100);
c.setDoubleBufferMaximumSize(new Dimension(300, 300));
for (int i = 1; i < 10; i++) {
c.getOffscreenBuffer(comp, i * 10, i * 20);
}
System.exit(0);
}
}
class TestComponent extends JRootPane {
boolean painted;
boolean validated;
public TestComponent() {
super();
painted = false;
validated = false;
}
public boolean isValidateRoot() {
return true;
}
synchronized public void paintImmediately(int x, int y, int w, int h) {
painted = true;
}
synchronized public void repaint(long tm, int x, int y, int width, int height) {
painted = true;
}
synchronized public void paint(Graphics g) {
painted = true;
}
synchronized public void paintAll(Graphics g) {
painted = true;
}
synchronized public boolean isPainted() {
boolean ret = painted;
painted = false;
return ret;
}
synchronized public void validate() {
validated = true;
}
synchronized public boolean isValidated() {
return validated;
}
public Image createImage(ImageProducer producer) {
return new StubImage();
}
public Image createImage(int width, int height) {
return new StubImage();
}
public VolatileImage createVolatileImage(int width, int height) {
return new StubVolatileImage();
}
public VolatileImage createVolatileImage(int width, int height,
ImageCapabilities caps) throws AWTException {
return new StubVolatileImage();
}
}
class StubImage extends java.awt.Image {
public int getWidth(ImageObserver observer) {
return 100;
}
public int getHeight(ImageObserver observer) {
return 100;
}
public ImageProducer getSource() {
return null;
}
public Graphics getGraphics() {
return null;
}
public Object getProperty(String name,
ImageObserver observer) {
return null;
}
public Image getScaledInstance(int width,
int height,
int hints) {
return this;
}
public void flush(){}
}
class StubVolatileImage extends java.awt.image.VolatileImage {
public int getWidth(ImageObserver observer) {
return 100;
}
public int getHeight(ImageObserver observer) {
return 100;
}
public ImageProducer getSource() {
return null;
}
public Graphics getGraphics() {
return null;
}
public Object getProperty(String name,
ImageObserver observer) {
return null;
}
public Image getScaledInstance(int width,
int height,
int hints) {
return new StubImage();
}
public void flush(){}
public BufferedImage getSnapshot() {
return null;
}
public int getWidth() {
return 100;
}
public int getHeight() {
return 100;
}
public Graphics2D createGraphics() {
return null;
}
public int validate(GraphicsConfiguration gc) {
return 0;
}
public boolean contentsLost() {
return false;
}
public ImageCapabilities getCapabilities() {
return null;
}
}
-------------- Output from the test -----------------
/set/jdk-builds/JDK1.4.0beta-b75/solaris/bin/java RepaintManagerTest
Exception in thread "main" java.lang.NullPointerException
at javax.swing.RepaintManager._getOffscreenBuffer(RepaintManager.java:596)
at javax.swing.RepaintManager.getOffscreenBuffer(RepaintManager.java:522)
at RepaintManagerTest.main(RepaintManagerTest.java:17)
1 returned
------------------------------------------------------
======================================================================
- duplicates
-
JDK-4491842 JCK13a, JCK14, api/javax_swing/RepaintManager/descriptions.html#getset,b75,c1,c2
-
- Closed
-