tracker issue : CF-3558908

select a category, or use search below
(searches all categories and all time range)
Title:

"Abstract" parent classes don't work with interfaces

| View in Tracker

Status/Resolution/Reason: Closed/Deferred/EnhancementRequired

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 05/13/2013

Components: Language

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Normal / Few users will encounter

Locale/System: English / Win XP All

Vote Count: 0

Extracted from http://adamcameroncoldfusion.blogspot.co.uk/2013/05/interface-inheritance-what-one-can-and.html
[...]
However what if Parent didn't implement factory()? This should be OK, as we're not using a Parent object in this code, we're using a Child object and that does implement factory() correctly, and a Child object does fulfill the contract that I.cfc requires. But unfortunately this does not work in CFML. If I adjust Parent.cfc to be like this:

// Parent.cfc
component implements= "I" {

}

Then and re-run that code, I get an error:

CFC Parent does not implement the interface I.
The factory method is not implemented by the component or it is declared as private.

Whilst - strictly speaking - this is true, it should not matter. Consider this analogous Java example:

// I.java
public interface I {
        public Parent factory();
        public String greet();
}

// Parent.java
public abstract class Parent implements I {
}

// Child.java
public class Child extends Parent {

        public Parent factory() {
               return new Child();
       }

        public String greet(){
               return "G'day from " + this.getClass().getName();
       }

}

// test.java
public class Test {

        public static void main(String[] args) {
              
              Child c = new Child ();

              Parent result = test(c);
              
              System. out .println(result.greet());

       }
        public static Parent test(I object){
               return object.factory();
       }

}

Note that the Parent class is defined as abstract, which is obviously a construct CFML doesn't have. However one doesn't actually need that. Parent.java will give a warning if you try to compile it as non-abstract, but it will actually compile and run. So clearly the intent is that the concept in general should work, so it should also work in CFML.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3558908

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Currently CFC does not have the concept of abstract class. This needs to be considered & discussed along with other enhancement requests related to OO - such as dynamically implementing an interface by injecting methods in object etc. We will consider these together for the next release.
Comment by Rupesh K.
15432 | September 05, 2013 07:32:00 AM GMT