-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
21, 25
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
openjdk version "17.0.16" 2025-07-15
OpenJDK Runtime Environment Temurin-17.0.16+8 (build 17.0.16+8)
OpenJDK 64-Bit Server VM Temurin-17.0.16+8 (build 17.0.16+8, mixed mode, sharing)
openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment Temurin-21.0.8+9 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.8+9 (build 21.0.8+9-LTS, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When I try to call the getFontMetrics() method of javax.swing.DebugGraphics (which is under the java.desktop module), I've found that the behavior in OpenJDK 21 is different from other OpenJDK versions.
For example, OpenJDK 8 reports a NullPointerException, which is because getFontMetrics attempts to access a null object. OpenJDK 11 and OpenJDK 17 provide a more detailed error message: Cannot invoke "java.awt.Graphics.getFontMetrics()" because "this.graphics" is null.
However, when executing this with OpenJDK 21, it produces no output at all. Does this imply that the check for this condition is missing in OpenJDK 21?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.NullPointerException
---------- BEGIN SOURCE ----------
import javax.swing.DebugGraphics;
public class test {
public static void main(String[] var0) {
DebugGraphics var = new DebugGraphics();
var.getFontMetrics();
}
}
---------- END SOURCE ----------
openjdk version "17.0.16" 2025-07-15
OpenJDK Runtime Environment Temurin-17.0.16+8 (build 17.0.16+8)
OpenJDK 64-Bit Server VM Temurin-17.0.16+8 (build 17.0.16+8, mixed mode, sharing)
openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment Temurin-21.0.8+9 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.8+9 (build 21.0.8+9-LTS, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When I try to call the getFontMetrics() method of javax.swing.DebugGraphics (which is under the java.desktop module), I've found that the behavior in OpenJDK 21 is different from other OpenJDK versions.
For example, OpenJDK 8 reports a NullPointerException, which is because getFontMetrics attempts to access a null object. OpenJDK 11 and OpenJDK 17 provide a more detailed error message: Cannot invoke "java.awt.Graphics.getFontMetrics()" because "this.graphics" is null.
However, when executing this with OpenJDK 21, it produces no output at all. Does this imply that the check for this condition is missing in OpenJDK 21?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.NullPointerException
---------- BEGIN SOURCE ----------
import javax.swing.DebugGraphics;
public class test {
public static void main(String[] var0) {
DebugGraphics var = new DebugGraphics();
var.getFontMetrics();
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8291634 DebugGraphics NPE @ setFont();
-
- Closed
-