Using importObject()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using importObject()

Aaron Wadley
I'm trying to use importObject() to simulate multiple inheratence.  I can get
it to work in the global namespace when I play from the bsh prompt, but I
can't get any actual objects to do it.  If I define this class:

class A {
  boolean a = true;
}

Then run this:
bsh % importObject(eval("new A()"));
bsh % show();
bsh % a;
<true>

It works.  But if I try this:

class Thing {
  public void mixin(String mixinClass) {
    importObject(eval("new " + mixinClass + "()"));
  }
}

bsh % show();
bsh % t = new Thing();
bsh % t.mixin("A");
bsh % t.a;
// Error: EvalError: Cannot access field: a, on object: Thing@e1d5ea : at
Line: 1 : in file: <unknown file> : t .a

Am I just missing something about how importObject() is supposed to work?

--
==============================================================================
Aaron Wadley                                          [hidden email]
CyberLizard Industries                                  www.cyberlizard.org
==============================================================================



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users