Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7750

@Lazy allows instantiation of abstract class

    XMLWordPrintableJSON

Details

    Description

      Given this code:

      @Lazy
      Foo foo
      
      abstract class Foo {}
      

      You'll get:

      java.lang.InstantiationException
      	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
      	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:239)
      

      This isn't really helpful. If I mistype a method name, Groovy will help me out with suggestions, why not here?

      MODIFICATION by blackdrag:
      @Lazy should recognize this and fail compilation to avoid the initialization of an abstract class.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              johann Johann
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: