Skip to content

Java/C# Method/Field Access Specifiers #40

Description

@jsipahio

Access specifiers are individually applied to each field/method in Java and C#; there are no regions like in C++. Also, the default visibility (when there is no specifier) varies based on language and whether it is a struct/class/interface.

Activity

  1. jsipahio commented on Jul 14, 2025

    @jsipahio
    Author

    Leading specifiers for all languages are not collected for functions and decls.
    For example, the const will be collected for the function below, but not the virtual.

    class Foo {
    public:
        virtual void doSomething() const {}
    };

    I believe this is due to an the Type policy overriding the function/decl policy and collecting the specifiers there instead. The Python function below does collect the leading specifier, since it is not nested in a type:

    async def do_something():
        pass

    The isssue40 branch works around this by post-processing the type data when it is added to the function/decl, but it would be more efficient if there were a way to collect the specifiers during parsing.

  2. mjdecker commented on Oct 14, 2025

    @mjdecker
    Contributor

    I have known about this for a long time. I want srcML to be changed to not put these in the type, as they don't belong there. If not, I need a list of all specifiers that appear in type but apply to function/method.

  3. mjdecker commented on Oct 14, 2025

    @mjdecker
    Contributor

    I just noticed that the issue title is not related to the content.

  4. mjdecker commented on Oct 14, 2025

    @mjdecker
    Contributor

    List of specifiers that are currently in type tag:

    __block
    __strong
    __volatile__
    __weak
    _Atomic
    _Complex
    _Imaginary
    _Noreturn
    _Thread_local
    abstract
    async
    auto
    const
    const
    constexpr
    default
    delegate
    explicit
    extern
    final
    implicit
    in
    inline
    internal
    mutable
    native
    new
    override
    params
    partial
    private
    protected
    public
    readonly
    register
    restrict
    sealed
    static
    strictfp
    synchronized
    template
    this
    thread_local
    transient
    virtual
    volatile
    

    Which ones are valid type specifiers and which are function/declarations specifiers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions