managed-commons / stab-language

Automatically exported from code.google.com/p/stab-language
Apache License 2.0
5 stars 3 forks source link

Class annotation duplication #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The class file generated by the code:

using java.lang;
using stab.lang;

package examples {

    [StaticClass]
    public final class StringUtil {

        [ExtensionMethod]
        public static boolean isNullOrEmpty(this String str) {
            return (str == null) || (str.length() == 0);
        }
    }
}

when it is decompiled shows that the annotation is duplicated:

@StaticClass
public final class StringUtil
{
  @ExtensionMethod
  @ExtensionMethod
  public static final boolean isNullOrEmpty(String str)
  {
    return (str == null) || (str.length() == 0);
  }
}

Original issue reported on code.google.com by ice.ta...@gmail.com on 19 Jun 2010 at 1:17

GoogleCodeExporter commented 9 years ago
A compiler error or warning is missing here. But to avoid the duplication your 
code should be:

package examples {
    public static class StringUtil {
        public static boolean isNullOrEmpty(this String str) {
            return (str == null) || (str.length() == 0);
        }
    }
}

You dont have to specify any annotation explicitly for static classes and 
extension methods.

Original comment by stab.hac...@gmail.com on 26 Jun 2010 at 11:42