Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods
Summary: ClassCastException in ClassTypeHelper.getOwnMethods
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0.1   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
: 354312 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-08-30 14:49 EDT by Sergey Prigogin CLA
Modified: 2011-09-08 17:23 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Prigogin CLA 2011-08-30 14:49:45 EDT
java.lang.ClassCastException: org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownScope cannot be cast to org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.getOwnMethods(ClassTypeHelper.java:319)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.collectPureVirtualMethods(ClassTypeHelper.java:873)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.getPureVirtualMethods(ClassTypeHelper.java:822)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.reportProblemsIfAbstract(AbstractClassInstantiationChecker.java:191)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.checkClassConstructor(AbstractClassInstantiationChecker.java:155)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.visit(AbstractClassInstantiationChecker.java:141)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression.accept(CPPASTFunctionCallExpression.java:173)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement.accept(CPPASTReturnStatement.java:84)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement.accept(CPPASTCompoundStatement.java:79)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:187)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration.accept(CPPASTTemplateDeclaration.java:119)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier.accept(CPPASTCompositeTypeSpecifier.java:172)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration.accept(CPPASTSimpleDeclaration.java:96)
	at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:279)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker.processAst(AbstractClassInstantiationChecker.java:64)
	at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processModel(AbstractIndexAstChecker.java:103)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:149)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.runInEditor(CodanBuilder.java:218)
	at org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler.reconciledAst(CxxCodanReconciler.java:38)
	at org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler.reconciled(CodanCReconciler.java:81)
	at org.eclipse.cdt.internal.ui.editor.CEditor.reconciled(CEditor.java:3198)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:108)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:73)
	at org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:84)
	at org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy.reconcile(CCompositeReconcilingStrategy.java:90)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
	at org.eclipse.cdt.internal.ui.text.CReconciler.process(CReconciler.java:408)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 1 Sergey Prigogin CLA 2011-08-30 14:53:36 EDT
Another variation of the problem:

java.lang.ClassCastException: org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType$CPPClassTypeProblem cannot be cast to org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.getOwnMethods(ClassTypeHelper.java:319)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.collectPureVirtualMethods(ClassTypeHelper.java:873)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.collectPureVirtualMethods(ClassTypeHelper.java:859)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.getPureVirtualMethods(ClassTypeHelper.java:822)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.reportProblemsIfAbstract(AbstractClassInstantiationChecker.java:191)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.checkClassConstructor(AbstractClassInstantiationChecker.java:155)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker$OnEachClass.visit(AbstractClassInstantiationChecker.java:132)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNewExpression.accept(CPPASTNewExpression.java:184)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorInitializer.accept(CPPASTConstructorInitializer.java:87)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorChainInitializer.accept(CPPASTConstructorChainInitializer.java:124)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:183)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier.accept(CPPASTCompositeTypeSpecifier.java:172)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration.accept(CPPASTSimpleDeclaration.java:96)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition.accept(CPPASTNamespaceDefinition.java:129)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition.accept(CPPASTNamespaceDefinition.java:129)
	at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:279)
	at org.eclipse.cdt.codan.internal.checkers.AbstractClassInstantiationChecker.processAst(AbstractClassInstantiationChecker.java:64)
	at org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker.processModel(AbstractIndexAstChecker.java:103)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.processResource(CodanBuilder.java:149)
	at org.eclipse.cdt.codan.internal.core.CodanBuilder.runInEditor(CodanBuilder.java:218)
	at org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler.reconciledAst(CxxCodanReconciler.java:38)
	at org.eclipse.cdt.codan.internal.ui.cxx.CodanCReconciler.reconciled(CodanCReconciler.java:81)
	at org.eclipse.cdt.internal.ui.editor.CEditor.reconciled(CEditor.java:3198)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:108)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:73)
	at org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:84)
	at org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy.reconcile(CCompositeReconcilingStrategy.java:90)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
	at org.eclipse.cdt.internal.ui.text.CReconciler.process(CReconciler.java:408)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 2 Sergey Prigogin CLA 2011-08-30 17:58:34 EDT
Fixed in master and cdt_8_0 > 20110830.
Comment 3 CDT Genie CLA 2011-08-30 18:23:02 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=fb7d64098f16af1f10c4699807783bd4784d7037
Comment 4 CDT Genie CLA 2011-08-30 18:23:04 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=29a103a4e76481ac25b13b6adebe25c18a559670
Comment 5 Marc-André Laperle CLA 2011-08-30 19:34:05 EDT
*** Bug 354312 has been marked as a duplicate of this bug. ***
Comment 6 Marc-André Laperle CLA 2011-09-06 16:50:36 EDT
I just updated to the nightly build and it still happens. classType.getCompositeScope() can return a PDOMCPPUnknownScope even without a IProblemBinding
Comment 7 Andrew Gvozdev CLA 2011-09-08 10:17:34 EDT
Here is a code snippet from where it triggers exception from codan. See stack trace in bug 356493 comment 3. I suspect that this exception causes codan to generate about 50 bogus warnings in the file I am dealing with.

template <typename T>
void f()
{
    typename T::type t;
}
Comment 8 Sergey Prigogin CLA 2011-09-08 16:43:16 EDT
Fixed the PDOMCPPUnknownScope case.
Comment 9 CDT Genie CLA 2011-09-08 17:23:01 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=d93f3d35328ad3b24d9452019ae76eba4ec4cd8f
Comment 10 CDT Genie CLA 2011-09-08 17:23:03 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=7d5892884bfb0bdef9cad28cf8c59c7331099f5d