Hi –

 

I am hoping I can get an explanation regarding an issue I have.  I have found a work around, however I do not understand why the issue is occurring and why the work around even resolves it.  Below I have a very simple interface in Java and a jython object that implements that interface.  If I try something to access the length property from Java by doing:

 

      MessageInterface message = (MessageInterface)factory.createObject();

      System.out.println("Message length:" + message.getLength());

 

I get the following error:

 

Exception in thread "main" Traceback (most recent call last):

  File "__pyclasspath__/message_interface.py", line 90, in __init__

AttributeError: read-only attr: length

 

 

If I add a setter method for length and expose that through the interface, I get a max recursion depth error.  If I change self.length to instead be self.msg_length the problem goes away.  If I put an underscore in front of length the problem goes away.  I have this same issue with self.source instead of self.msg_source.  However, I don’t have any problems with self.target and other attributes.  Why is it an issue for some attributes and not others? I would like to understand this problem so if anyone can explain what is going on to me I would really appreciate it.

 

Thank you.

 

public interface MessageInterface {

     

      public int getSource();

      public int getDestination();

      public int getLength();

      public int getVersion();

      public int getMessageID();

}

 

 

class Message(MessageInterface):

      def __init__(self):

            """@sig Message()"""

           

            self.length = 0

            self.msg_version = 0

            self.msg_source = 0

            self.target = 0

            self.Message_ID = 0

 

 

 

def getLength(self):

            return self.length

     

     

      def getSource(self):

            return self.msg_source

     

      def getDestination(self):

            return self.target

     

      def getMessageID(self):

            return self.Message_ID

     

      def getVersion(self):

            return self.msg_version