ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

NoSuchMethodError for type bound generic method #405

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If had a type bound generic method defined in pure Java class then @Typed 
groovy fails at runtime with NoSuchMethodError.

Here is an example:
---------------------------
public class Hello {
   ...
}
---------------------------
public class HelloTools {

   public static <T extends Hello> T say(T hello) {

   ...
   }
}
---------------------------

Then following groovy code fails at runtime:

---------------------------
class HelloTest {

    @Test
    void test1() {
        def hello = new Hello()
        HelloTools.say(hell)
    }

    @Typed
    @Test
    void test2() {
        def hello = new Hello()
        HelloTools.say(hell)
    }
}
---------------------------

The second test will fail with the NoSuchMethodError

I am using the latest release of Groovy++ with Groovy 1.8.2

Original issue reported on code.google.com by mendapar...@gmail.com on 19 Dec 2011 at 8:16

GoogleCodeExporter commented 8 years ago
Here I am attaching a test project.

Original comment by mendapar...@gmail.com on 19 Dec 2011 at 8:16

Attachments:

GoogleCodeExporter commented 8 years ago
You can also test with getAnnotation method defined in Class. The signature of 
this method is:

public <A extends Annotation> A getAnnotation(Class<A> annotationClass)

Original comment by mendapar...@gmail.com on 19 Dec 2011 at 8:37

GoogleCodeExporter commented 8 years ago
Look at the project activity @mendapar

After Groovy/Spring announced they are working on their own static Groovy 
(completely undermining g++ in the process), g++ activity stopped.

Really unfortunate, g++ had nice momentum and provided strong typing + speed 
with Groovy concision. Oh well, big companies tend to ruin the open source 
party.

I believe g++ project lead is working on JetBrains' Kotlin project.

Anyway, would be nice if there were some confirmation as to what is going on 
(or not) with g++ project.

Original comment by sit1...@gmail.com on 29 Dec 2011 at 12:07