empty groovy classes generated

]]>

<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal

a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1

div.Section1

-->

Hi!

 

Today I tried starting using groovy support, I activated the JetGroovy plugin in the hope to being able to use all the new cool stuff ;-)

 

I am on diana 9825 (jdk 1.6.0_13 64-bit) and use jdk 1.6.0_13 (i586 or 64-bit makes no difference) for the project and Groovy-All 1.6.3.

I've configured the Groovy faces to compile the Groovy source.

 

 

Then, I started with a VERY simple Groovy bean

 

class MyFirstGroovy

{

    String textString;

 

    public String xyzString;

}

 

and tried using it from a java test class

 

    public void testPropertyChange()

    {

        MyFirstGroovy groovy = new MyFirstGroovy();

        groovy.xyzString = "abc";

        assertEquals("abc", groovy.xyzString);

 

        groovy.setTextString("any String");

        assertEquals("any String", groovy.getTextString()); // this failes as textString returns null instead of "any String"

    }

 

To my very surprise, this test failed at the second assertEquals, when I tried the setter/getter stuff.

I struggled around a little bit, and when trying groovyc from the command line it worked.

 

I then tried this and that, until I reached the point where I javaped the created class file.

 

As you can see from this output

 

D:\users\im\projects\opsxcited\premium\target\classes>"c:\Program Files\Java\jdk1.6.0_11\bin\javap.exe" -c com.ops.MyFir

stGroovy

Compiled from "MyFirstGroovy.java"

public class com.ops.MyFirstGroovy extends java.lang.Object implements groovy.lang.GroovyObject{

public java.lang.String xyzString;

 

public com.ops.MyFirstGroovy();

  Code:

   0:   aload_0

   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V

   4:   aload_0

   5:   aconst_null

   6:   putfield        #2; //Field textString:Ljava/lang/String;

   9:   aload_0

   10:  aconst_null

   11:  putfield        #3; //Field xyzString:Ljava/lang/String;

   14:  return

 

public java.lang.String getTextString();

  Code:

   0:   aconst_null

   1:   areturn

 

public void setTextString(java.lang.String);

  Code:

   0:   return

 

public groovy.lang.MetaClass getMetaClass();

  Code:

   0:   aconst_null

   1:   areturn

 

public void setMetaClass(groovy.lang.MetaClass);

  Code:

   0:   return

 

public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);

  Code:

   0:   aconst_null

   1:   areturn

 

public java.lang.Object getProperty(java.lang.String);

  Code:

   0:   aconst_null

   1:   areturn

 

public void setProperty(java.lang.String, java.lang.Object);

  Code:

   0:   return

 

}

 

The class code is almost empty. You have the class variables, the methods, but no method body. Cleary that this class wont work.

 

When doing a "rebuild all" then, a reasonable class has been generated and the test works. I then added an empty line to MyFirstGroovy and triggered a build. Voila, the class file is the dumb empty one again, the test failes.

 

Strange enough, when I create an all new IDEA project, this behaviour can not be seen.

 

An help will be appreciated.

 

Thanks!

Ciao,

Mario

]]>

Please sign in to leave a comment.