Skip to content

Java: Same type specified multiple times in throws clause is modeled as single CodeQL Exception with multiple locations #7309

@Marcono1234

Description

@Marcono1234

Description

When a callable declares the same exception type multiple times in a throws clause, it is represented by CodeQL as a single Exception with multiple getLocation() results. This is rather counterintuitive and confusing.
Expected would be that each exception type specified in the throws clause has its own Exception element with a single location, even if the same exception type occurs multiple times.

Example

Java code:

public void doSomething() throws IllegalArgumentException, IllegalArgumentException {
}

CodeQL query:

import java

from Exception e
where
  e.fromSource()
  and count(e.getLocation()) > 1
select e, e.getLocation()

Query Console link

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions