Hello all,

I am trying to wrap a simple C++ class hierarchy in Java, using directors.
The C++ is fairly trivial, but uses the clone() pattern, which is giving me
trouble:

class Base {
  ...

  Base(const Base& other)
  { ... };

  virtual Base* clone() {
     return Base(*this);
  }

  ...
}

class Extended : public Base {
 ...

 Extended(const Extended& other)
 { ... };

 virtual Base* clone() {
    return Extended(*this);
 }

 ...
}

Now, I can extend this using directors in Java, by just renaming clone() to
instance() and using the %newobject directive for clone().  The copy
constructor works fine, but whenever my C++ uses clone() and goes to the
Java version, I get access violation errors which crash the JVM.

Has anybody tried a similar pattern? I've tried refactoring this a bunch of
times that ended up messing up the design more than fixing it, so now I'd
like to get the above (original) design working.  My only half-baked
suspicion is that the renaming of clone() may be still creating some
conflict with Java's own clone() when called from C++.

Any input or ideas are welcome and thanks in advance.

Costas