Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33291
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Oo questions |
| Date | 2015-12-03 19:04 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n3qlaa$2gq$2@speranza.aioe.org> (permalink) |
| References | <64d27264-1b2d-49cb-8492-71306709f92e@googlegroups.com> |
On 12/3/2015 6:33 AM, mike wrote:
> This is the code users have:
>
> <code>
> ObjectAttribute attr = retriever.getAttr("name");
> </code>
> ObjectAttribute is an abstract class with a method called getValue().
>
> We found a fault, when we had a sequence with one element, that
> getAttr(String) returned wrong type for certain "name".
>
> Before getAttr() returned ValueAttribute but so after fix we return
> SequenceAttribute which is the correct type. Both ValueAttribute and
> SequenceAttribute are implementations of ObjectAttribute.
>
> When this was fixed we could see that the impact for end-user would
> behuge so we would like to give them a grace period, since users do
>
> <code>
> attr.getValue()
> </code>
> which now gives a different outputformat SequenceAttribute is used.
>
> So we created a SequenceAttributeProxy ( since SequenceAttribute is
> used in other libraries that don't need this) that extends
> SequenceAttribute and returns the old value like:
> When we checked user code we discovered that some user have done it correct:
>
> <code>
> SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
> </code>
>
> So users have both:
>
> 1. ObjectAttribute attr = retriever.getAttr("name");
>
>
> 2. SequenceAttribute attr = (SequenceAttribute)retriever.getAttr("name");
>
>
> But we only want users of 1. to see logging and return the old value.
>
> Problem is that getAttr() now returns SequenceAttribute for both 1 and 2.
>
> And we have not found a way to distinguish between them so we can use that in our Proxy.
I don't think you can as it is.
#1 is executed as:
1) call retriever.getAttr("name")
2) assign to attr
#2 is executed as as:
1) call retriever.getAttr("name")
2) cast
3) assign to attr
You need to change something else.
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Oo questions mike <mikaelpetterson@hotmail.com> - 2015-12-03 03:33 -0800 Re: Oo questions Arne Vajhøj <arne@vajhoej.dk> - 2015-12-03 19:04 -0500 Re: Oo questions mike <mikaelpetterson@hotmail.com> - 2015-12-04 00:22 -0800
csiph-web