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

DiamondOperatorForVariableDefinitionCheck throws NullPointerException #348

Closed
stephanenicolas opened this Issue Jun 4, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@stephanenicolas

stephanenicolas commented Jun 4, 2015

When running 'com.github.sevntu.checkstyle:sevntu-checks:1.13.0', we get a stack trace :

java.lang.NullPointerException
    at com.github.sevntu.checkstyle.checks.coding.DiamondOperatorForVariableDefinitionCheck.isSameTypeArgsInVariableDef(DiamondOperatorForVariableDefinitionCheck.java:86)
    at com.github.sevntu.checkstyle.checks.coding.DiamondOperatorForVariableDefinitionCheck.visitToken(DiamondOperatorForVariableDefinitionCheck.java:65)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:393)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:482)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:322)

The problem comes from :

    private static boolean isSameTypeArgsInVariableDef(DetailAST variableDefNode,
            DetailAST typeArgs) {

        DetailAST typeNode = variableDefNode.findFirstToken(TokenTypes.TYPE);
        DetailAST variableDefTypeArgs = typeNode.findFirstToken(TokenTypes.TYPE_ARGUMENTS);

        return variableDefTypeArgs.equalsTree(typeArgs);        // <---     variableDefTypeArgs is null
    }
@stephanenicolas

This comment has been minimized.

Show comment
Hide comment
@stephanenicolas

stephanenicolas Jun 4, 2015

Btw, we have a lot of constructs using

Type<A> t = new Type<A> {}, that might be where it fails.

stephanenicolas commented Jun 4, 2015

Btw, we have a lot of constructs using

Type<A> t = new Type<A> {}, that might be where it fails.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 4, 2015

Member

@stephanenicolas , thanks a lot.

If you can send share with us exact file - it will be great help, we will recheck code chunk that you have provided.

Member

romani commented Jun 4, 2015

@stephanenicolas , thanks a lot.

If you can send share with us exact file - it will be great help, we will recheck code chunk that you have provided.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 7, 2015

Member

@stephanenicolas , we already have that case in our UTs - https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/test/resources/com/github/sevntu/checkstyle/checks/coding/InputDiamondOperatorForVariableDefinitionCheck.java#L62 , works fine.

please provide exact file to reproduce a problem, you can obfuscate code if you afraid to share source.

Member

romani commented Jun 7, 2015

@stephanenicolas , we already have that case in our UTs - https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/test/resources/com/github/sevntu/checkstyle/checks/coding/InputDiamondOperatorForVariableDefinitionCheck.java#L62 , works fine.

please provide exact file to reproduce a problem, you can obfuscate code if you afraid to share source.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 7, 2015

Member

reproduced on code:
Class<?>[] resolvedInterfaces = new Class<?>[5];

and

RuleViolation ruleViolation = new ParametricRuleViolation<Object>();
Member

romani commented Jun 7, 2015

reproduced on code:
Class<?>[] resolvedInterfaces = new Class<?>[5];

and

RuleViolation ruleViolation = new ParametricRuleViolation<Object>();
@stephanenicolas

This comment has been minimized.

Show comment
Hide comment
@stephanenicolas

stephanenicolas Jun 7, 2015

Thx guys, I couldn't have shared the code.
Le 2015-06-06 23:32, "Roman Ivanov" notifications@github.com a écrit :

reproduced on code:
Class[] resolvedInterfaces = new Class[5];


Reply to this email directly or view it on GitHub
#348 (comment)
.

stephanenicolas commented Jun 7, 2015

Thx guys, I couldn't have shared the code.
Le 2015-06-06 23:32, "Roman Ivanov" notifications@github.com a écrit :

reproduced on code:
Class[] resolvedInterfaces = new Class[5];


Reply to this email directly or view it on GitHub
#348 (comment)
.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 7, 2015

Member

fixed, released as 1.13.2

Member

romani commented Jun 7, 2015

fixed, released as 1.13.2

@romani romani closed this Jun 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment