Community
Participate
Working Groups
Build Identifier: 20110615-0604 The generated grammar access class (in my case VhdlGrammarAccess) is a singleton. It's used all over the place by multiple threads so needs good synchronization. I'm worried about the lazy initialization that occurs. For every grammar element, X, there is a pX field that is initialized to null. That field is then lazily initialized when getXAccess() is invoked. There is a serious risk that the pX field will be initialized multiple times and therefor that there are multiple XElements and ParserRules floating around corresponding to the same grammar entries. That means in turn that identity comparisons can fail. I haven't seen this actually occur in the wild but who knows. On a side note, I kind of doubt (but haven't checked this) that the lazy initialization does any good in this context. I would imagine that all grammar elements will be needed in any serious use case. Lazily initializing them seems to incur a continuous overhead that doesn't repay itself? Reproducible: Always
+1 for eager and thread safe initialization Btw.: It looks like org.eclipse.xtext.service.GrammarProvider.getGrammar(Object) was made thread safe on purpose but I doubt it is, because of the EPackage initialization. Comments?
(In reply to comment #1) > Btw.: It looks like > org.eclipse.xtext.service.GrammarProvider.getGrammar(Object) was made thread > safe on purpose but I doubt it is, because of the EPackage initialization. > Comments? Forget it, I missed the inner if block.
Pushed to review