Description
Similar to #5593
For a static member type of a generic declaring type, getDeclaringType() reports the raw type. This is incorrect and also pretty problematic because raw types have a <> suffix in their name; therefore queries checking for a specific qualified name will most likely not match, causing false negatives. The most prominent example is probably java.util.Map.Entry; CodeQL currently reports the qualified name as java.util.Map<>$Entry.
This only affects static member types, non-static member types correctly report the generic type as getDeclaringType().
Example
class Generic<T> {
// BAD: Reports Generic<> (raw) as declaring type
static class Nested {}
// BAD: Reports Generic<> (raw) as declaring type
interface NestedInterface {}
// GOOD: Reports Generic as declaring type
class Inner {}
}
CodeQL query:
import java
from Member m
where
m.fromSource()
and m instanceof RefType
select m, m.getDeclaringType()