Java can't access methods on created robot

Issue #28 wontfix
Doug Blank created an issue

This works:

import Myro;
Myro.makeRobot("Finch");
Myro.setLED("front", "#FF0000");

But this does not:

import Myro;
robot = Myro.makeRobot("Finch");
robot.setLED("front", "#FF0000");
ExecutionError: No method in Object has name 'setLED'

Comments (13)

  1. Doug Blank reporter

    To test without a Finch:

    import Myro;
    sim = Myro.Simulation();
    sim = Myro.makeRobot("SimScribbler", sim);
    sim.forward(1, 1);
    
  2. Keith O'Hara

    Shouldn't it be:

    import Myro.*;
    sim = Myro.Simulation();
    sim = Myro.makeRobot("SimScribbler", sim);
    sim.forward(1, 1);
    

    In that case I get a similar error to the one in Graphics:

    tried to access class cli.Myro$$$003CdoTogether$$003Ec__DynamicSite1 from class cli.Myro

  3. Doug Blank reporter

    No, this works:

    import Myro;
    Myro.init("sim");
    

    Something has changed in accessing methods of created objects.

  4. Keith O'Hara

    I get the error with this as well:

    java>>>>> Myro.Simulation tried to access class cli.Myro$$$003CdoTogether$$003Ec__DynamicSite1 from class cli.Myro

  5. Keith O'Hara

    This example still works:

    import cli.Gtk.*;
    
    window = new Window("Title");
    window.Show();
    button = new Button("Press me!");
    button.Show();
    window.Add(button);
    
  6. Doug Blank reporter

    No, I don't think it is related. I think it has to do with Java figuring out the type automatically. For example, this works:

    import Myro;
    Myro.init("sim");
    sim = Myro.getSimulation();
    Myro.Robot robot = (Myro.Robot)Myro.makeRobot("SimScribbler", sim);
    robot.forward(1,1);
    

    But robot is supposed to be SimScribbler specific, which it is in Python. I guess a limitation of either Java, or of the interpreter.

    I think we can close this as just a limitation of the system.

  7. Keith O'Hara

    OK. This also works:

    import Myro;
    sim = new Myro.Simulation();
    robot = (Myro.Robot)Myro.makeRobot("SimScribbler", sim);
    robot.forward(1,1);
    
  8. Doug Blank reporter

    Right. As long as it knows how to cast it. I added Myro.getRobotType("SimScribbler") a while back in case we needed it. Not sure what to do with it in Java though...

  9. Doug Blank reporter

    I don't think anything changed; I think this is how DynamicJava works. It can figure out some types, but not all.

  10. Log in to comment