• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmd / pmd / #3722

pending completion
#3722

push

github actions

adangel
Suppress MissingOverride for Chars::isEmpty (#4291)

67270 of 127658 relevant lines covered (52.7%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/JExecutableSymbol.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.symbols;
6

7
import java.lang.reflect.Constructor;
8
import java.lang.reflect.Method;
9
import java.lang.reflect.Modifier;
10
import java.util.List;
11

12
import org.checkerframework.checker.nullness.qual.NonNull;
13
import org.checkerframework.checker.nullness.qual.Nullable;
14

15
import net.sourceforge.pmd.lang.java.types.JTypeMirror;
16
import net.sourceforge.pmd.lang.java.types.Substitution;
17

18
/**
19
 * Common supertype for {@linkplain JMethodSymbol method}
20
 * and {@linkplain JConstructorSymbol constructor symbols}.
21
 */
22
public interface JExecutableSymbol extends JAccessibleElementSymbol, JTypeParameterOwnerSymbol {
23

24

25
    /**
26
     * Returns the formal parameters this executable declares. These are
27
     * only non-synthetic parameters. For example, a constructor for an
28
     * inner non-static class will not reflect a parameter for the enclosing
29
     * instance.
30
     */
31
    List<JFormalParamSymbol> getFormalParameters();
32

33

34
    default boolean isDefaultMethod() {
35
        // Default methods are public non-abstract instance methods
36
        // declared in an interface.
37
        return this instanceof JMethodSymbol
1✔
38
            && (getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC
1✔
39
            && getEnclosingClass().isInterface();
1✔
40
    }
41

42

43
    /** Returns true if the last formal parameter is a varargs parameter. */
44
    boolean isVarargs();
45

46

47
    /**
48
     * Returns the number of formal parameters expected. This must be the
49
     * length of {@link #getFormalParameters()} but if it can be implemented
50
     * without creating the formal parameters, it should.
51
     *
52
     * <p>A varargs parameter counts as a single parameter.
53
     */
54
    int getArity();
55

56

57
    /**
58
     * Return the receiver type with all type annotations, when viewed
59
     * under the given substitution. Return null if this method
60
     * {@linkplain #hasReceiver() has no receiver}.
61
     *
62
     * @throws IllegalArgumentException If the argument is not the receiver type of this type.
63
     */
64
    @Nullable JTypeMirror getAnnotatedReceiverType(Substitution subst);
65

66
    /**
67
     * Return true if this method needs to be called on a receiver instance.
68
     * This is not the case if the method is static, or a constructor of an
69
     * outer or static class.
70
     */
71
    default boolean hasReceiver() {
72
        if (isStatic()) {
1✔
73
            return false;
×
74
        }
75
        if (this instanceof JConstructorSymbol) {
1✔
76
            return !getEnclosingClass().isStatic()
×
77
                && getEnclosingClass().getEnclosingClass() != null;
×
78
        }
79
        return true;
1✔
80
    }
81

82

83
    /**
84
     * Returns the class symbol declaring this method or constructor.
85
     * This is similar to {@link Constructor#getDeclaringClass()}, resp.
86
     * {@link Method#getDeclaringClass()}. Never null.
87
     */
88
    @Override
89
    @NonNull
90
    JClassSymbol getEnclosingClass();
91

92

93
    @Override
94
    default @NonNull String getPackageName() {
95
        return getEnclosingClass().getPackageName();
1✔
96
    }
97

98

99
    /**
100
     * Returns the types of the formal parameters, when viewed under the
101
     * given substitution. The returned list has one item for each formal.
102
     *
103
     * @see #getFormalParameters()
104
     */
105
    List<JTypeMirror> getFormalParameterTypes(Substitution subst);
106

107
    /**
108
     * Returns the types of the thrown exceptions, when viewed under the
109
     * given substitution.
110
     */
111
    List<JTypeMirror> getThrownExceptionTypes(Substitution subst);
112

113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc