Skip to content

Fix Interface methods default attributes#210

Merged
RomainDeg merged 3 commits intomoosetechnology:v4from
guillep:interfaces
Apr 10, 2026
Merged

Fix Interface methods default attributes#210
RomainDeg merged 3 commits intomoosetechnology:v4from
guillep:interfaces

Conversation

@guillep
Copy link
Copy Markdown
Contributor

@guillep guillep commented Apr 2, 2026

Interface methods are not properly marked as abstract or public.
Differently from abstract classes, interfaces can have empty methods, working as abstract method declarations, even though they are not explicitly marked as abstract. Moreover, even though java now allows private interface methods, by default they are public. An example as follows:

public interface Collection {

	//Just an abstract method here 
	int implicitAbstractMethod();
	
	//Just an abstract method here, but explicit 
	abstract int explicitAbstractMethod();

	// Method with body! 
	default int methodWithBody() {
		return 0;
	}
}

In this case, the first two methods should be marked as abstract, the third not.
All of them are public

Now, the current version

  • looks at the abstract keyword, only identifying the second one!
  • treats interfaces like classes for the default visibility, marking them as package

@guillep guillep changed the title Fix Interface methods' isAbstract Fix Interface methods default attributes Apr 2, 2026
@RomainDeg RomainDeg merged commit 18fc691 into moosetechnology:v4 Apr 10, 2026
2 checks passed
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