Skip to content

Java: StringLiteral matches String concatenation of two String literals #5469

Open
@Marcono1234

Description

@Marcono1234

It appears the class StringLiteral matches String concatenation of two String literals.
This is not how the JLS defines a String literal. Instead they should be matched as separate String literals being operands of an AddExpr (which is a CompileTimeConstantExpr).

Query finding these erroneous StringLiterals:

import java

from StringLiteral s
where
  exists(s.getLiteral().indexOf("+"))
  and not exists(s.getValue().indexOf("+"))
select s

Query Console link

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions