Forums > Java

attributes set w/ java instantiation unavailable n constructor, set() not called

September 6, 2011 | 5:54 pm

Java member variables which are declared as attributes using declareAttribute() fail to have values set using the @ object instantiation
syntax. In addition, the custom setter() method is not later called.

Together, these create a situation where:

1) Attribute values set using @ syntax that are needed in the constructor do not have those values. Only default values set within the java variable declaration are there.

2) Can’t handle it in a custom getter() because custom getters() are not called with @ syntax.

Requested/expected behavior:

1) After any call to declareAttribute() where there is a @attribute set in the object instantiation in Max, the matching member variable will have the value set with the @ syntax.
2) Immediately after the constructor completes…if there is a custom setter() for an attribute declared with declareAttribute() that has a matching @attribute set in the object instantiation in Max…then the custom setter() will be called.

Personally, I like request #2. That’s the intention of a person writing the patch, they are setting that attribute. Therefore, I believe that the custom setter should be called.

This is related to another old post http://cycling74.com/forums/topic.php?id=9709


September 6, 2011 | 8:30 pm

Option (2) is what happens, depending on your definition of "immediately". Once the constructor is done execution passes back into the bowels of MaxObject to set up inlets and outlets, then attribute setters are called.


Viewing 2 posts - 1 through 2 (of 2 total)