Community
Participate
Working Groups
java.lang.NullPointerException at org.eclipse.swt.graphics.Image.internal_new_GC(Image.java:1597) at org.eclipse.swt.graphics.GC.<init>(GC.java:262) at org.eclipse.swt.graphics.GC.<init>(GC.java:223) at org.eclipse.jface.text.source.AnnotationRulerColumn.doubleBufferPaint(AnnotationRulerColumn.java:531) at org.eclipse.jface.text.source.AnnotationRulerColumn.lambda$1(AnnotationRulerColumn.java:266) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4364) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520) at org.eclipse.swt.widgets.Control.drawWidget(Control.java:1278) at org.eclipse.swt.widgets.Canvas.drawWidget(Canvas.java:176) at org.eclipse.swt.widgets.Widget.drawRect(Widget.java:776) at org.eclipse.swt.widgets.Canvas.drawRect(Canvas.java:170) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5996) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:5242) at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5674) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:97) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:635) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597) at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
eclipse.buildId=4.12.0.I20190605-1800 java.version=11.0.1 java.vendor=Azul Systems, Inc. BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US Framework arguments: -product org.eclipse.epp.package.committers.product -keyring ... Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.committers.product -keyring ...
Similar backtrace (from OverviewRuler): Eclipse IDE for Eclipse Committers Version: 2019-09 R (4.13.0) Build id: 20190917-1200 macOS 10.14.6 (18G1012) java version "11.0.2" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.2+7-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode) Image.internal_new_GC(GCData) line: 1598 GC.<init>(Drawable, int) line: 262 GC.<init>(Drawable) line: 223 OverviewRuler.doubleBufferPaint(GC) line: 675 OverviewRuler.lambda$1(PaintEvent) line: 585 1744871240.paintControl(PaintEvent) line: not available TypedListener.handleEvent(Event) line: 234 EventTable.sendEvent(Event) line: 89 Display.sendEvent(EventTable, Event) line: 4406 Canvas(Widget).sendEvent(Event) line: 1512 Canvas(Widget).sendEvent(int, Event, boolean) line: 1535 Canvas(Widget).sendEvent(int, Event) line: 1520 Canvas(Control).drawWidget(long, NSGraphicsContext, NSRect) line: 1278 Canvas.drawWidget(long, NSGraphicsContext, NSRect) line: 176 Canvas(Widget).drawRect(long, long, NSRect) line: 776 Canvas.drawRect(long, long, NSRect) line: 170 Display.windowProc(long, long, long) line: 6043 OS.objc_msgSendSuper(objc_super, long, long, long, long, boolean) line: not available [native method] Display.applicationNextEventMatchingMask(long, long, long, long, long, long) line: 5284 Display.applicationProc(long, long, long, long, long, long) line: 5716 OS.objc_msgSend(long, long, long, long, long, boolean) line: not available [native method] NSApplication.nextEventMatchingMask(long, NSDate, NSString, boolean) line: 97 Display.readAndDispatch() line: 3804 PartRenderingEngine$5.run() line: 1160 Realm.runWithDefault(Realm, Runnable) line: 338 PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1049 E4Workbench.createAndRunUI(MApplicationElement) line: 155 Workbench.lambda$3(Display, WorkbenchAdvisor, int[]) line: 633 952172944.run() line: not available Realm.runWithDefault(Realm, Runnable) line: 338 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 557 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150 IDEApplication.start(IApplicationContext) line: 150 EclipseAppHandle.run(Object) line: 203 EclipseAppLauncher.runApplication(Object) line: 137 EclipseAppLauncher.start(Object) line: 107 EclipseStarter.run(Object) line: 400 EclipseStarter.run(String[], Runnable) line: 255 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43 Method.invoke(Object, Object...) line: 566 Main.invokeFramework(String[], URL[]) line: 660 Main.basicRun(String[]) line: 597 Main.run(String[]) line: 1468 Main.main(String[]) line: 1441
This must be a race condition. The lines affected here are: ------------------------- if (fBuffer == null) fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y); GC gc= new GC(fBuffer); ------------------------- The NPE is raised when fBuffer is null. But is initialised just above. fBuffer will be set to null inn handleDispose. So the dispose event comes right while doubleBufferPaint() is processed. We need some synchronization here. Would synchronized(this) from before creation of GC until last usage of fBuffer be correct here?
(In reply to Karsten Thoms from comment #3) > We need some synchronization here. Would synchronized(this) from before > creation of GC until last usage of fBuffer be correct here? I'd go with a local variable avoiding synchronization. ------------------------- Image buffer = fBuffer if (buffer == null) buffer = fBuffer = new Image(fCanvas.getDisplay(), size.x, size.y); GC gc= new GC(buffer); ------------------------- Of course, some regular checks for "disposed" should be done as well.
In my code, line 1597 and 1598 in Image are: NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(imageRep); NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(context.graphicsPort(), true); (my NPE is when context comes back null from graphicsContextWithBitmapImageRep()). I am using a newer version of Eclipse (and swt?) than the original reporter, so perhaps the code has changed a lot. Please let me know and I can create a new report instead.
Downloaded Version: 2019-06 (4.12.0) Build id: 20190614-1200 (which is the same version as the original report, but Build id is a few days later). It has the following lines as 1596 and 1597 NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(imageRep); NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(context.graphicsPort(), true); So, as far as I can tell both the original reporter (in 4.12, line 1597) and I (in 4.13, line 1598) get the NPE when context comes back null from graphicsContextWithBitmapImageRep(). This does not look like the code "if (fBuffer == null) ..." cited above.
Per, you are right. I have assumed that this could be provoked when GC gets a null reference. I have provoked this with the debugger, the error trace is different then. So you are right, the NPE occurs when NSGraphicsContext.graphicsContextWithBitmapImageRep(imageRep) returns null. Sorry, I have no clue what could cause this. Anything special you have done? Is this occurring frequently?
This is coming frequently. This is a MacBook Pro that I move between two locations, one with two external screens, one with a single external screen. This could be relevant but I do not know (i.e. I do not remember) whether the problem happens when I have moved the machine (e.g. with a running Eclipse that wakes up to a new screen configuration).
I have a similar hardware setup, but am still on macOS 10.14.2. I have not such a problem. I'll check once I have upgraded macOS.
I have found now this NPE in my own error log. I'll set a breakpoint and observe when it happens again. java.lang.NullPointerException at org.eclipse.swt.graphics.Image.internal_new_GC(Image.java:1598) at org.eclipse.swt.graphics.GC.<init>(GC.java:262) at org.eclipse.swt.graphics.GC.<init>(GC.java:223) at org.eclipse.compare.internal.BufferedCanvas.doubleBufferPaint(BufferedCanvas.java:89) at org.eclipse.compare.internal.BufferedCanvas.lambda$0(BufferedCanvas.java:40) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4406) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520) at org.eclipse.swt.widgets.Control.drawWidget(Control.java:1278) at org.eclipse.swt.widgets.Canvas.drawWidget(Canvas.java:176) at org.eclipse.swt.widgets.Widget.drawRect(Widget.java:776) at org.eclipse.swt.widgets.Canvas.drawRect(Canvas.java:170) at org.eclipse.swt.widgets.Display.windowProc(Display.java:6043) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:5284) at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5716) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:97) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3804) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) 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:498) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594) at org.eclipse.equinox.launcher.Main.run(Main.java:1465) at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Created attachment 281590 [details] Screenshot of missing annotation rulers I get this quite frequently in 2019-12. I have to close and re-open the Java Editor when it occurs.
So this is a Mac specific issue and probably a change (bug?) in Mac that might cause this. The context can be null of OSX fails to respond here: public static NSGraphicsContext graphicsContextWithBitmapImageRep(NSBitmapImageRep bitmapRep) { long result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithBitmapImageRep_, bitmapRep != null ? bitmapRep.id : 0); return result != 0 ? new NSGraphicsContext(result) : null; }
*** This bug has been marked as a duplicate of bug 548430 ***