Skip to content

GROOVY-11237: Support static interface methods#2001

Merged
paulk-asert merged 1 commit intoapache:masterfrom
paulk-asert:groovy11237
Nov 29, 2023
Merged

GROOVY-11237: Support static interface methods#2001
paulk-asert merged 1 commit intoapache:masterfrom
paulk-asert:groovy11237

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@eric-milles eric-milles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also JavaStubGenerator needs to write "static". And if you support non-public static methods, the visibility modifier.

    private void printMethod(final PrintWriter out, final ClassNode classNode, final MethodNode methodNode) {
        if (methodNode.isStaticConstructor()) return;
        if (methodNode.isPrivate() || !Utilities.isJavaIdentifier(methodNode.getName())) return;
        if (methodNode.isSynthetic() && (methodNode.getName().equals("$getStaticMetaClass"))) return;

        printAnnotations(out, methodNode);
        if (!isInterfaceOrTrait(classNode)) {
            int modifiers = methodNode.getModifiers();
            if (classNode.isEnum()) modifiers &= ~Opcodes.ACC_ABSTRACT;
            else if (isDefaultTraitImpl(methodNode)) modifiers ^= Opcodes.ACC_ABSTRACT;
            if (methodNode.isSyntheticPublic() && hasPackageScopeXform(methodNode, PackageScopeTarget.METHODS)) modifiers &= ~Opcodes.ACC_PUBLIC;

            printModifiers(out, modifiers);
        } else if (methodNode.isDefault()) {
            out.print("default ");
        } else if (methodNode.isStatic()) { // ADDED
            out.print("static ");
        }

@eric-milles
Copy link
Copy Markdown
Member

With static method support so close at hand, did you think of re-rolling 5.0.0-alpha-3?

@eric-milles
Copy link
Copy Markdown
Member

I have all these changes together locally if you'd like me to push a branch or commit.

@paulk-asert
Copy link
Copy Markdown
Contributor Author

With static method support so close at hand, did you think of re-rolling 5.0.0-alpha-3?

Let's go with the current release and shoot for another before the end of the year.

@paulk-asert
Copy link
Copy Markdown
Contributor Author

I have all these changes together locally if you'd like me to push a branch or commit.

I've included some of them with tweaks. I'll merge when ready but feel free to amend further if needed.

@paulk-asert paulk-asert merged commit 9719b24 into apache:master Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants