Re: [mdr-users] proplem with the custom implementation of abstract classes

Richard Ciglansky <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.mdr.user
Message-ID <[email protected]>
ludger goeke wrote:

>Hi Martin,
>
>I got still a proplem with the custom implementation of abstract classes.
>I got the class Port that extends the abstract class StructuralFeature.
>I create the custom implementation StructuralFeatureImpl 
>that owns the method getText( ).
>
>When I try to run the following code 
>  
>
                    "run" or probably "compile"  ?

>Port port =factory.createPort();  
>port.getText();
>
>
>
> cannot resolve symbol
>    [javac] symbol  : method getText ()
>    [javac] location: interface uml2module.ports.Port
>    [javac]          port.getText();
>  
>
Does abstract class StructuralFeature contain method "getText()" or just 
its implementation contains this method ?

>__________________________________________________
>
>When I try to run the following code 
>
>StructuralFeatureImpl feature =  factory.createPort();    
>
>  
>
Interface for factory surely creates just Port, which is in no relation 
to its implementation, so compiler does not know, that this assignment 
will be type safe.
Probably you can do :

StructuralFeatureImpl feature =  (StructuralFeatureImpl)factory.createPort(); 

but should this code appear in client code ( not in you impl.* package for customized implementation ) I would highly discourage such thing. I think you can you such constructs just in your impl.* package where you really know, that the object returned from "createPort()" will be your say "PortImpl" which extends "StructuralFeatureImpl", therefore it's OK. But outside your "impl.*" package this should not be done.




>I get the following compiler error
>incompatible types
>    [javac] found   : uml2module.ports.Port
>    [javac] required: impl.uml2module.kernel.StructuralFeatureImpl
>    [javac]          StructuralFeatureImpl feature =  factory.createPort();
>
>
>It seems that the Custom Implementation don`t get mentioned. 
>  
>
Custom implementation is bound to "interfaces" in runtime and compiler 
really does not know anything about which particular implementation will 
be used.

Richard

>Do you have an idea what could be the error ?
>
>Regards Ludger
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.