jcoplien / trygve

The trygve language project - Building a DCI-centric language from the ground up
GNU General Public License v2.0
104 stars 15 forks source link

Exception in AWT-EventQueue #105

Closed mbrowne closed 8 years ago

mbrowne commented 8 years ago

When I run the code below, I get:

INTERNAL ERROR: Internal expression evaluated to a NULL Java object, line 18.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at info.fulloo.trygve.run_time.RTExpression$RTRelop$RTRelopPart2.run(RTExpression.java:1345)
    at info.fulloo.trygve.run_time.RunTimeEnvironment.runner(RunTimeEnvironment.java:420)
    at info.fulloo.trygve.graphics.GraphicsPanel.dispatchInterrupt(GraphicsPanel.java:219)
    at info.fulloo.trygve.graphics.GraphicsPanel.handleEventProgrammatically(GraphicsPanel.java:133)
    at info.fulloo.trygve.graphics.GraphicsPanel.handleEvent(GraphicsPanel.java:318)
    at java.awt.Component.postEvent(Component.java:5171)
    at java.awt.Component.dispatchEventImpl(Component.java:4888)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:740)
    at java.awt.EventQueue.access$300(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:699)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:713)
    at java.awt.EventQueue$4.run(EventQueue.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:710)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

But if I name the parameter of the handleEvent() event, then the error goes away. Naming it anything other than event causes the error to occur.

class CounterPanel extends Panel {
    private int counter_ = 0;

    public CounterPanel() {
        Panel();
        frame_  = new Frame("Counter");
        frame_.add("Center", this);
        frame_.resize(600, 400);

        setForeground(Color.blue);
        drawRect(50, 50, 10, 10);

        repaint();
        frame_.setVisible(true);
    }

    public boolean handleEvent(Event e) {
        if (e.id == Event.MOUSE_MOVE) {

        }
        return true;
    }

    public Frame frame() { return frame_ }
    private Frame frame_;
}

{
    new CounterPanel();
}
mbrowne commented 8 years ago

Thanks, the original error is gone, but now I'm getting a new error when running the same code (regardless of what the event parameter is named):

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: info.fulloo.trygve.run_time.RTExpression$RTMessage$RTPostReturnProcessing cannot be cast to info.fulloo.trygve.run_time.RTObject
    at info.fulloo.trygve.graphics.GraphicsPanel.handleEventProgrammatically(GraphicsPanel.java:142)
    at info.fulloo.trygve.graphics.GraphicsPanel.handleEvent(GraphicsPanel.java:324)
    at java.awt.Component.postEvent(Component.java:5171)
    at java.awt.Component.dispatchEventImpl(Component.java:4888)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:740)
    at java.awt.EventQueue.access$300(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:699)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:713)
    at java.awt.EventQueue$4.run(EventQueue.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:710)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
jcoplien commented 8 years ago

Fixed (again), I think.

Den 26/04/2016 kl. 15.15 skrev Matt Browne notifications@github.com:

Thanks, the original error is gone, but now I'm getting a new error when running the same code (regardless of what the event parameter is named):

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: info.fulloo.trygve.run_time.RTExpression$RTMessage$RTPostReturnProcessing cannot be cast to info.fulloo.trygve.run_time.RTObject at info.fulloo.trygve.graphics.GraphicsPanel.handleEventProgrammatically(GraphicsPanel.java:142) at info.fulloo.trygve.graphics.GraphicsPanel.handleEvent(GraphicsPanel.java:324) at java.awt.Component.postEvent(Component.java:5171) at java.awt.Component.dispatchEventImpl(Component.java:4888) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4698) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:740) at java.awt.EventQueue.access$300(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:699) at java.awt.EventQueue$3.run(EventQueue.java:697) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:713) at java.awt.EventQueue$4.run(EventQueue.java:711) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:710) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) — You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jcoplien/trygve/issues/105#issuecomment-214737054

mbrowne commented 8 years ago

Confirmed fixed. Thanks.

jcoplien commented 8 years ago

Thanks for your patience, Matt.

Den 27/04/2016 kl. 23.57 skrev Matt Browne notifications@github.com:

Closed #105 https://github.com/jcoplien/trygve/issues/105.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jcoplien/trygve/issues/105#event-643555381