Re: Why are the header classes final?

"M. Ranganathan" <[email protected]>
Newsgroups gmane.comp.voip.nist-sip
Message-ID <[email protected]>
Hmmm... ;learn something new every day. I never knew that non final 
classes would degrade performance. Thanks for the tip!

Jeroen is correct in that there could well be class cast exceptions 
generated as well. A bit of experimentation would help determine this is 
indeed true. The one concern I had was that equals would break but 
Jeroen has converted all equals to to use the interface directly and not 
the class ( thus making the tck work across implementations - which is 
highly desirable :-) ). Now that I am aware of the performance 
implications, I will go ahead and convert this and all other header 
classes  back to final because indeed performance is a very important 
consideration.


To make a long story short. I suppose what I could do is be gentle about 
encoding Display Name strings and not put the quotes around the String 
if the String has no white spaces (but just for display name). Please 
bring up this issue in the Asterisk mailing list if indeed this is the 
problem because the quotes should not matter.  David, please experiment 
and report back to this list.  Does removing the quotes work for you?

Regards,

Ranga

Jeroen van Bemmel wrote:

> final helps improve performance, and it also helps us to detect when 
> people are trying to do things that they shouldn't (no offence). 
> Trying to add a subclassed header to a message will possibly give 
> ClassCastExceptions. It would actually be better to make all header 
> implementations final
>
> jeroen
>
> M. Rangnathan wrote:
>
>> Well, Asterisk seems to have a bug. The quotes should not matter.  I
>> can see no good reason for not making the class final. However, there
>> is also no good reason to make that class final so I  just remove the
>> final keyword. :-)
>>
>> Its quite simple you see...
>>
>>
>> Ranga
>>
>> [email protected] wrote:
>>
>>> On Wed, 8 Nov 2006 at 20:53, Jeroen van Bemmel wrote:
>>>
>>>> They are not all final, but in any case the public interfaces of
>>>> this library are in javax.sip (and javax.sdp). The design is such
>>>> that an application would only deal with those packages.
>>>
>>>
>>>
>>> So why is gov.nist.javax.sip.header.Contact final if not all the
>>> headers are?  Like I said, I'm new to Java so I don't know the
>>> motivations for using final.
>>>
>>>> Which need do you have that it cannot be done using the public API?
>>>
>>>
>>>
>>> Well, we're trying to send a Response.MOVED_TEMPORARILY to Asterix
>>> boxes, and we were told on the Asterix mailing list that Asterix
>>> wouldn't recognize it unless the form of the Contact header
>>> in the response was:
>>>
>>>     Contact: Transfer <uri>
>>>
>>> I tried just using Transfer as the DisplayName, but that produces:
>>>
>>>     Contact: "Transfer" <uri>
>>>
>>> and that doesn't seem to be good enough.  Now, I'm not personally
>>> convinced that even getting rid of the quotes is going to fix the
>>> problem with Asterix, but I need to run the experiment.  So I was
>>> going to subclass Contact and change the toString so that there
>>> were no quotes around Transfer, and use my custom header in
>>> constructing the response.
>>>
>>> --David
>>> _______________________________________________
>>> nist-sip mailing list
>>> [email protected]
>>> http://www-x.antd.nist.gov/mailman/listinfo/nist-sip 
>>
>
>


-- 
M. Ranganathan 

Advanced Networking Technologies Division,
National Institute of Standards and Technology (NIST),
100 Bureau Drive, Stop 8920, Gaithersburg, MD 20899. 
tel:301 975 3664 , fax:301 590 0932 http://w3.antd.nist.gov/
Advanced Networking Technologies For the People!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.