Java events

I have problems using events with latest release. Does not the compiler generate proper code for Java to handle events anymore? Here is test case that used to work :

namespace ClassLibrary3;

interface

uses
  java.util;

type

  TShapeEvent = public procedure( 
    _sender : Object ;
    _e      : Object
  ) of object ;

  TLayerVector = public class
  private
    FOnPaintShape : TShapeEvent ;
  assembly or protected  
    procedure add_TestEvent    ( const _e : TShapeEvent
                                ) ;
    procedure remove_TestEvent ( const _e : TShapeEvent
                                ) ;
  published
     event PaintShapeEvent : TShapeEvent add addPaintShapeEvent remove removePaintShapeEvent;
     event TestEvent       : TShapeEvent add add_TestEvent remove remove_TestEvent;
     event Test2Event      : TShapeEvent ;
     property Test         : TShapeEvent read FOnPaintShape write FOnPaintShape;
  end;

implementation

method TLayerVector.add_TestEvent(const _e: TShapeEvent);
begin
  FOnPaintShape := _e ;
end;

method TLayerVector.remove_TestEvent(const _e: TShapeEvent);
begin
  FOnPaintShape := nil ;
end;

end.

I tried to declare an event in different ways but in generated jar there is no public method to handle the event (like add,remove), only raise method. Can you please verify this issue ?

Regards
Artur

Hrmm somehow they’re “synthetic”;they’re there, but a java ide won’t show/let you compile against them. I’ll investgiate.

Thanks, logged as bugs://81233

Here is v10 output :

package ClassLibrary3;

import java.util.ArrayList;

public class TLayerVector
{
  private TShapeEvent FOnPaintShape;
  private ArrayList<TShapeEvent> $_Test2Event;
  
  public void raiseTest2Event(Object _sender, Object _e)
  {
    if (self.$_Test2Event == null) {
      return;
    }
    int i = self.$_Test2Event.size() - 1;int i = 0;
    if (i <= i)
    {
      i += 1;
      do
      {
        ((TShapeEvent)self.$_Test2Event.get(i)).Invoke(_sender, _e);i += 1;
      } while (i != i);
    }
  }
  
  public TShapeEvent getTest()
  {
    return self.FOnPaintShape;
  }
  
  public void setTest(TShapeEvent value)
  {
    self.FOnPaintShape = value;
  }
  
  protected void add_TestEvent(TShapeEvent _e)
  {
    self.FOnPaintShape = _e;
  }
  
  protected void remove_TestEvent(TShapeEvent _e)
  {
    self.FOnPaintShape = null;
  }
  
  public void raisePaintShapeEvent(Object _sender, Object _e) {}
  
  public void raiseTestEvent(Object _sender, Object _e) {}
}

and this one is last v9 :

package classlibrary3;

import java.util.ArrayList;

public class TLayerVector
{
  private TShapeEvent FOnPaintShape;
  
  public void addPaintShapeEvent(TShapeEvent value)
  {
    self.addPaintShapeEvent(value);
  }
  
  public void removePaintShapeEvent(TShapeEvent value)
  {
    self.removePaintShapeEvent(value);
  }
  
  public void addTestEvent(TShapeEvent value)
  {
    self.add_TestEvent(value);
  }
  
  public void removeTestEvent(TShapeEvent value)
  {
    self.remove_TestEvent(value);
  }
  
  public void addTest2Event(TShapeEvent value)
  {
    if (value == null) {
      return;
    }
    if (self.$e_Test2Event == null) {
      self.$e_Test2Event = new ArrayList();
    }
    self.$e_Test2Event.add(value);
  }
  
  public void removeTest2Event(TShapeEvent value)
  {
    if (self.$e_Test2Event == null) {
      return;
    }
    self.$e_Test2Event.remove(value);
    if (self.$e_Test2Event.size() == 0) {
      self.$e_Test2Event = null;
    }
  }
  
  public void raiseTest2Event(Object _sender, Object _e)
  {
    if (self.$e_Test2Event == null) {
      return;
    }
    int i = self.$e_Test2Event.size() - 1;int i = 0;
    if (i <= i)
    {
      i += 1;
      do
      {
        ((TShapeEvent)self.$e_Test2Event.get(i)).Invoke(_sender, _e);i += 1;
      } while (i != i);
    }
  }
  
  public TShapeEvent getTest()
  {
    return self.FOnPaintShape;
  }
  
  public void setTest(TShapeEvent value)
  {
    self.FOnPaintShape = value;
  }
  
  protected void add_TestEvent(TShapeEvent _e)
  {
    self.FOnPaintShape = _e;
  }
  
  protected void remove_TestEvent(TShapeEvent _e)
  {
    self.FOnPaintShape = null;
  }
}

Here we have missing addxxx and removexxx methods as public.

Yeah. The methods are there if you use a different decompiler. It just has a flag that makes it hide it. Fixed.

bugs://81233 got closed with status fixed.

Oh, thanks. Which decompiler you use ?

ByteCode Viewer https://github.com/Konloch/bytecode-viewer
if I want to decompile things

jclasslib bytecode viewer
if I want a lowlevel class overview.