Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6693307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:58:04+00:00 2026-05-26T05:58:04+00:00

I have three Groovy classes: M, A, & B. B exists as a mixin

  • 0

I have three Groovy classes: M, A, & B. B exists as a mixin of M and an extension of the abstract class A:

class M {
    def foo = 11
    def bar = 12
}

abstract class A {
    abstract foo
}

@Mixin(M)
class B extends A {
}

def b = new B()
print "${b.foo}\n"
print "${b.bar}\n"

Attempting to run this causes Groovy to complain with:
Can't have an abstract method in a non-abstract class. The class 'B' must be declared abstract or the method 'void setFoo(java.lang.Object)' must be implemented.
However, the method is implemented by the mixin M.

Furthermore, if I change B to be:

@Mixin(M)
class B extends A {
    def foo = 13
}

Then I get the printout:

11

12

And not:

13

12

Which is what I expect and seems to prove that M provides an acceptable implementation of the abstract methods of A.

So, why isn’t groovy happy with using the mixin M to satisfy the abstract class A, what am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:58:04+00:00Added an answer on May 26, 2026 at 5:58 am

    You’re doing nothing wrong. It’s the problem of the compiler performing this check before actually applying the AST transformations. You better post this on their issue tracker at http://jira.codehaus.org/secure/BrowseProject.jspa?id=10242.

    Since @Mixin transformation was actually created by the author of Groovy++ AFAIK, and since Groovy++ has much more extended support for categories, mixins and traits you could expect this to be a valid code there. You should try it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a package (foo.bar), is there some groovy sugar that makes it
If I have a comma separated file like the following: foo,bar,n ,a,bc,d one,two,three ,a,bc,d
I have a domain three domain class like this : Tasks.groovy class Tasks {
I have a simple groovy script that generates xml def builder = new groovy.xml.StreamingMarkupBuilder()
Say I have src/test/groovy/MyTest.groovy: class MyTest extends GroovyTestCase { void testDummy() { println 'DUMMY'
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
I have a String array in a Groovy class (args to a main method):
I have a map in groovy that looks like the following... def book =
I have a class in src/groovy in my grails project. How do i make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.