Community
Participate
Working Groups
+++ This bug was initially created as a clone of Bug #434393 +++ We've got following exception sent by a user of our SWT-based application (SWT version 4.333, Mac OS X 10.9.2, java 1.7.0_45): java.lang.NullPointerException at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2134) at org.eclipse.swt.graphics.GC.<init>(GC.java:171) at org.eclipse.swt.graphics.GC.<init>(GC.java:134) at com.syntevo.q.swt.QTabFolder.updateItems(SourceFile:806) ... The 2134th line of Control.java reads: NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(graphicsContext.graphicsPort(), true); so it looks like under certain conditions graphicsContext might be null.
NPE occurs when GC constructor is called in some cases. For ex: https://dev.eclipse.org/recommenders/committers/confess/#/problems/55cc3af7e4b0176300a7b2b0/ -- https://dev.eclipse.org/recommenders/committers/confess/#/problems/56434cf9e4b0c02da2cfeb42/ From https://bugs.eclipse.org/bugs/show_bug.cgi?id=434393#c35 java.lang.NullPointerException at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2174) at org.eclipse.swt.graphics.GC.<init>(GC.java:174) at org.eclipse.swt.graphics.GC.<init>(GC.java:135) at org.eclipse.swt.custom.StyledTextRenderer.setFont(StyledTextRenderer.java:1108) at org.eclipse.swt.custom.StyledText.<init>(StyledText.java:1252) ...
I consistently get this on osx. Context: I am working on an XText project, and test it by launching an Eclipse runtime instance from my main eclipse instance. The error then regularly shows up in the main instance. Please contact me if I can help get you any data. Here is the most recent stack trace: !ENTRY org.eclipse.ui 4 0 2016-03-02 11:58:01.754 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.NullPointerException at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2124) at org.eclipse.swt.graphics.GC.cocoa_new(GC.java:210) at org.eclipse.swt.widgets.Tree.sendMeasureItem(Tree.java:2596) at org.eclipse.swt.widgets.Tree.cellSize(Tree.java:288) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5582) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper_stret(Native Method) at org.eclipse.swt.widgets.Widget.expansionFrameWithFrame_inView(Widget.java:814) at org.eclipse.swt.widgets.Tree.expansionFrameWithFrame_inView(Tree.java:1274) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5961) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method) at org.eclipse.swt.internal.cocoa.NSRunLoop.runMode(NSRunLoop.java:42) at org.eclipse.swt.widgets.Display.sleep(Display.java:4740) at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopIdle(WorkbenchAdvisor.java:368) at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor.eventLoopIdle(IDEWorkbenchAdvisor.java:858) at org.eclipse.ui.internal.Workbench$3.eventLoopIdle(Workbench.java:517) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1132) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) at org.eclipse.equinox.launcher.Main.run(Main.java:1515) at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Adding version and os info: Eclipse: Version: Mars.1 (4.5.1) Build id: M20150904-0015 OSX 10.11.2
(In reply to Larry LeBron from comment #2) > I consistently get this on osx. > > Here is the most recent stack trace: > > !ENTRY org.eclipse.ui 4 0 2016-03-02 11:58:01.754 > !MESSAGE Unhandled event loop exception > !STACK 0 > java.lang.NullPointerException > at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2124) > at org.eclipse.swt.graphics.GC.cocoa_new(GC.java:210) > at org.eclipse.swt.widgets.Tree.sendMeasureItem(Tree.java:2596) > at org.eclipse.swt.widgets.Tree.cellSize(Tree.java:288) > at org.eclipse.swt.widgets.Display.windowProc(Display.java:5582) > at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper_stret(Native Method) > at > org.eclipse.swt.widgets.Widget.expansionFrameWithFrame_inView(Widget.java: > 814) This problem has been fixed in Eclipse 4.5.2 through bug 434393. Please try with the latest 4.5.2 version.
Can this bug be closed?
I am no longer seeing the issue.
*** This bug has been marked as a duplicate of bug 434393 ***
We've got this stacktrace again with SWT version 4.756: java.lang.NullPointerException at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2176) at org.eclipse.swt.graphics.GC.<init>(GC.java:174) at org.eclipse.swt.graphics.GC.<init>(GC.java:135) at org.eclipse.swt.custom.StyledTextRenderer.setFont(StyledTextRenderer.java:1118) at org.eclipse.swt.custom.StyledText.<init>(StyledText.java:1256) The code reads: graphicsContext = NSGraphicsContext.graphicsContextWithWindow (window); NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(graphicsContext.graphicsPort(), true); graphicsContext = flippedContext; where graphicsContext seems to be null which is possible in NSGraphicsContext.graphicsContextWithWindow().
Users (still) report it with SWT version 4.919: java.lang.NullPointerException at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2180) at org.eclipse.swt.graphics.GC.<init>(GC.java:177) at org.eclipse.swt.graphics.GC.<init>(GC.java:138) at org.eclipse.swt.custom.CTabFolder.updateTabHeight(CTabFolder.java:3810) Happens in the same code fragment as reported in comment #8.
(In reply to Andreas Buchen from comment #9) > Users (still) report it with SWT version 4.919: > > java.lang.NullPointerException > at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2180) > at org.eclipse.swt.graphics.GC.<init>(GC.java:177) > at org.eclipse.swt.graphics.GC.<init>(GC.java:138) > at org.eclipse.swt.custom.CTabFolder.updateTabHeight(CTabFolder.java:3810) > This is probably bug 547399