Duplicate :
|
FULL PRODUCT VERSION : java version "1.8.0_40-ea" Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b06) Java HotSpot(TM) Client VM (build 25.40-b10, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : Due to a missing AppContext in headless mode, the creation of various Swing components fails, where previously it succeeded REGRESSION. Last worked in version 8u20 ADDITIONAL REGRESSION INFORMATION: java version "1.8.0_40-ea" Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b06) Java HotSpot(TM) Client VM (build 25.40-b10, mixed mode, sharing) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the attached program in headless mode (-Djava.awt.headless=true) EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Program should execute without exceptions ACTUAL - An exception is thrown ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.NullPointerException at javax.swing.RepaintManager.currentManager(RepaintManager.java:262) at javax.swing.JComponent.repaint(JComponent.java:4799) at java.awt.Component.repaint(Component.java:3303) at javax.swing.AbstractButton.setModel(AbstractButton.java:1784) at javax.swing.JButton.<init>(JButton.java:134) at javax.swing.JButton.<init>(JButton.java:91) at bug.Bug.main(Bug.java:5) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javax.swing.JButton; public class Bug { public static void main(String... argv) throws Exception { new JButton(); } } ---------- END SOURCE ----------