Re: Extending Java classes

Kevin Reid <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
On Jul 22, 2009, at 20:03, Robert Krahn wrote:

> Hi,
>
> I found old posts on this mailing discussing the inheritance of Java  
> classes. Is this possible now?
>
> What I would like to do is something like (excuse my naivete): def  
> list extends  
> <unsafe:org.erights.e.elib.tables.ConstListImpl>.asType() {}

It is not currently possible to create a new Java class from E. You  
can, however, implement any Java interface.

What I recommend for taming purposes is writing, in Java, a subclass  
which overrides all the methods you want to instead call another  
object, a handler. The handler is then implemented in E.

interface EFooHandler {
   public void bar();
}

class EFoo extends Foo {
   private EFooHandler handler;

   public EFoo(EFooHandler h) {
     handler = h;
   }

   /* overrides bar() in Foo */
   public void bar() {
     handler.bar();
   }
}


-- 
Kevin Reid                                  <http://switchb.org/kpreid/>
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.