Skip to content

Java: Clarify that RefType qualified name can include type parameters #3604

@Marcono1234

Description

@Marcono1234

Description of the issue
The JLS defines "fully qualified name" as:

The fully qualified name of a top level class or top level interface that is declared in a named package consists of the fully qualified name of the package, followed by ".", followed by the simple name of the class or interface.
[...]
The fully qualified name of the interface Enumeration, which is defined in the package java.util, is "java.util.Enumeration".
[...]
A local class or anonymous class does not have a fully qualified name.

Source: JLS §6.7

So the qualified name does not include type parameters.

However, QL's

  • RefType.getQualifiedName
  • RefType.hasQualifiedName

can contain type parameters and even type arguments and return results for local and anonymous classes.
This is not obvious from the documentation of these methods (except when looking at AnonymousClass::getQualifiedName, though a caller of RefType::getQualifiedName likely does not do that) so it would be good to add that.

Example query:

import java

from MethodAccess call
where
  call.getReceiverType().hasQualifiedName("java.util", "List<String>")
select call

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions