Exception when creating annotations

I'm getting a weird exception when my annotator creates an annotation. Here's the stack trace:

+java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Object;
at com.intellij.util.SmartList.add(SmartList.java:61)
at com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createAnnotation(AnnotationHolderImpl.java:20)
at com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createInfoAnnotation(AnnotationHolderImpl.java:17)
at com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.visitXmlTag(TemplateTagAnnotator.java:76)
at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.annotate(TemplateTagAnnotator.java:58)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitElement(HighlightVisitorImpl.java:447)
at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlElement(HighlightVisitorImpl.java:344)
at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54)
at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:372)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:136)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$600(GeneralHighlightingPass.java:76)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(GeneralHighlightingPass.java:6)
at com.intellij.codeInsight.daemon.impl.RefCountHolder.analyzeAndStoreReferences(RefCountHolder.java:66)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:87)
at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:11)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:50)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:12)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:286)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:1)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:75)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:5)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)+

Any idea what might be causing this ?

2 comments
Comment actions Permalink

Hello Hugo,

Make sure the AnnotationHolder instance passed to your annotator doesn't
leak elsewhere. Don't cache it between calls, and you may also need to mark
your annotate() method as synchronized.

I'm getting a weird exception when my annotator creates an annotation.
Here's the stack trace:

+java.lang.ClassCastException: java.util.ArrayList cannot be cast to
[Ljava.lang.Object;
at com.intellij.util.SmartList.add(SmartList.java:61)
at
com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createAnnota
tion(AnnotationHolderImpl.java:20)
at
com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createInfoAn
notation(AnnotationHolderImpl.java:17)
at
com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.visitXm
lTag(TemplateTagAnnotator.java:76)
at
com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at
com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.annotat
e(TemplateTagAnnotator.java:58)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
itElement(HighlightVisitorImpl.java:447)
at
com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.j
ava:22)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
itXmlElement(HighlightVisitorImpl.java:344)
at
com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:
54)
at
com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
it(HighlightVisitorImpl.java:372)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(General
HighlightingPass.java:136)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$60
0(GeneralHighlightingPass.java:76)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(Gen
eralHighlightingPass.java:6)
at
com.intellij.codeInsight.daemon.impl.RefCountHolder.analyzeAndStoreRef
erences(RefCountHolder.java:66)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectIn
formationWithProgress(GeneralHighlightingPass.java:87)
at
com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightin
gPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java
:11)
at
com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInform
ation(TextEditorHighlightingPass.java:50)
at
com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass
$1$1.run(PassExecutorService.java:12)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(Ap
plicationImpl.java:286)
at
com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass
$1.run(PassExecutorService.java:1)
at
com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessU
nderProgress(ProgressManagerImpl.java:75)
at
com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass
.run(PassExecutorService.java:5)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441
)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecu
tor.java:885)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
java:907)
at java.lang.Thread.run(Thread.java:619)+
Any idea what might be causing this ?

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Marking the annotate method as synchronized seems to have worked.

Thanks.

0

Please sign in to leave a comment.