Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Cannot invoke "org.eclipse.cdt.core.parser.IToken.getType()" because "token" is null #660

Open
edisonluo0501 opened this issue Dec 25, 2023 · 0 comments

Comments

@edisonluo0501
Copy link

Describe the bug
java.lang.NullPointerException: Cannot invoke "org.eclipse.cdt.core.parser.IToken.getType()" because "token" is null
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.getContextSensitiveType(GNUCPPSourceParser.java:270)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.optionalVirtSpecifierSeq(GNUCPPSourceParser.java:4444)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.initDeclarator(GNUCPPSourceParser.java:4385)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.initDeclarator(GNUCPPSourceParser.java:4191)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declSpecifierSequence_initDeclarator(AbstractGNUSourceCodeParser.java:1746)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declSpecifierSequence_initDeclarator(AbstractGNUSourceCodeParser.java:1684)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.simpleDeclaration(GNUCPPSourceParser.java:3274)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declaration(GNUCPPSourceParser.java:3012)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationList(AbstractGNUSourceCodeParser.java:1429)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationListInBraces(AbstractGNUSourceCodeParser.java:1376)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.classSpecifier(GNUCPPSourceParser.java:5399)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declSpecifierSeq(GNUCPPSourceParser.java:3869)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declSpecifierSeq(GNUCPPSourceParser.java:3568)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declSpecifierSequence_initDeclarator(AbstractGNUSourceCodeParser.java:1716)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declSpecifierSequence_initDeclarator(AbstractGNUSourceCodeParser.java:1684)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.simpleDeclaration(GNUCPPSourceParser.java:3274)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declaration(GNUCPPSourceParser.java:3012)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationList(AbstractGNUSourceCodeParser.java:1429)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationListInBraces(AbstractGNUSourceCodeParser.java:1376)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.namespaceDefinitionOrAlias(GNUCPPSourceParser.java:3091)
at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declaration(GNUCPPSourceParser.java:2968)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationList(AbstractGNUSourceCodeParser.java:1429)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parseTranslationUnit(AbstractGNUSourceCodeParser.java:1368)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.translationUnit(AbstractGNUSourceCodeParser.java:1363)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parse(AbstractGNUSourceCodeParser.java:688)
at org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage.getASTTranslationUnit(AbstractCLikeLanguage.java:171)
at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:886)
at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:843)

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
java.lang.NullPointerException should be avoided.

Screenshots
I ensure the param of TranslationUnit.getAST is not null.
image
image
token maybes return null.
image
pls check whether there is a problem, if so, fix it thk.

Version Information (please complete the following information):

  • OS and OS Version/extra details: Linux
  • Eclipse Version from Help -> About -> 2023-06 (4.28.0)
  • CDT Version from Help -> About -> Installation Details -> 11.3.0.202309051907

Additional context
Add any other context about the problem here. For example the error log (in workspace/.metadata/.log) or for GDB interaction issues the GDB traces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant