Community
Participate
Working Groups
In bug 547665, I query IAnnotationAccessExtension.isPaintable() on a JavaMarkerAnnotation. This might happen quite early, before JDT is completely initialized. In this case, JavaPluginImages.getImageRegistry() creates a new ImageRegistry. According to the constructor's javadoc, this is invalid, leading to an NPE downstream. java.lang.NullPointerException at org.eclipse.jface.resource.JFaceResources.getResources(JFaceResources.java:213) at org.eclipse.jface.resource.ImageRegistry.<init>(ImageRegistry.java:150) at org.eclipse.jface.resource.ImageRegistry.<init>(ImageRegistry.java:122) at org.eclipse.jdt.internal.ui.JavaPluginImages.getImageRegistry(JavaPluginImages.java:669) at org.eclipse.jdt.internal.ui.JavaPluginImages.get(JavaPluginImages.java:626) at org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationImageProvider.getQuickFixErrorImage(JavaAnnotationImageProvider.java:100) at org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationImageProvider.getImage(JavaAnnotationImageProvider.java:155) at org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationImageProvider.getManagedImage(JavaAnnotationImageProvider.java:64) at org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess.getImage(DefaultMarkerAnnotationAccess.java:374) at org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess.isPaintable(DefaultMarkerAnnotationAccess.java:300) at org.eclipse.ui.internal.editors.text.codemining.annotation.AnnotationCodeMiningFilter.isPaintable(AnnotationCodeMiningFilter.java:110) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) at org.eclipse.ui.internal.editors.text.codemining.annotation.AnnotationCodeMiningProvider.createCodeMinings(AnnotationCodeMiningProvider.java:209) at org.eclipse.ui.internal.editors.text.codemining.annotation.AnnotationCodeMiningProvider.lambda$0(AnnotationCodeMiningProvider.java:183) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1582) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
What's your proposal to resolve this problem?
(In reply to Noopur Gupta from comment #1) > What's your proposal to resolve this problem? What about: At the beginning of org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationImageProvider.getImage(IJavaAnnotation, int) Check if Display.getCurrent() is null and abort. The upstream code seems to handle null results.
(In reply to Niko Stotz from comment #2) > (In reply to Noopur Gupta from comment #1) > > What's your proposal to resolve this problem? > > What about: > At the beginning of > org.eclipse.jdt.internal.ui.javaeditor.JavaAnnotationImageProvider. > getImage(IJavaAnnotation, int) > > Check if Display.getCurrent() is null and abort. > > The upstream code seems to handle null results. Please provide Gerrit.
Gerrit: https://git.eclipse.org/r/#/c/152898/
Gerrit change https://git.eclipse.org/r/152898 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=ebcfc6623310e06b2dc70668bf225aa4f73480e6
As this bug is fixed. Can we remove the workaround in AnnotationCodeMiningFilter#isPaintable currently it catches NPEs like this: private boolean isPaintable(Annotation a) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=552760 // (NPE on JavaAnnotationImageProvider.getQuickFixErrorImage(): No Display) try { return annotationAccess.isPaintable(a); } catch (NullPointerException e) { return false; } }
New Gerrit change created: https://git.eclipse.org/r/156822
Gerrit change https://git.eclipse.org/r/156822 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=b34d3e266290b9a685f957d6363fbeb6e3a9d31c