You should be able to implement clone(), you just can't have the
@Override annotation on it.


mmoossen wrote:
> hi Paul!
>
> thanks for the insight!
> but would it make more sense to have that method throwing by default
> an UnsupportedOperationException or something similar so that people
> that override that method can compile their classes?
> (btw, i now that you should not use the clone() pattern, but this is a
> legacy class i can not change)
>
> issue created:
> http://code.google.com/p/google-web-toolkit/issues/detail?id=4972
>
> regards,
> Michael
>
> On May 25, 2:56 pm, Paul Robinson <ukcue...@gmail.com> wrote:
>   
>> GWT does not emulate the clone() method on Object, so when you compile
>> client-side code there is no method for your clone() to override.
>>
>> Paul
>>
>>
>>
>> mmoossen wrote:
>>     
>>> hi Sri!
>>>       
>>> i thought it was something like that but:
>>> - i am using java 1.6
>>> - clone() is a method in Object and not in the interfac, and
>>> - as said, eclipse wants that annotation (if not i get a warning) and
>>> i get an error only when compiling client code.
>>>       
>>> thanks anyhow
>>> Michael
>>>       
>>> On May 25, 12:40 pm, Sripathi Krishnan <sripathi.krish...@gmail.com>
>>> wrote:
>>>       
>>>> I think it is the javac compiler failing, not GWTC. Also, I'd guess you are
>>>> using JDK 1.5.
>>>>         
>>>> In JDK 1.5, @Override annotation cannot be applied to methods that 
>>>> implement
>>>> an interface; they can only be applied to a method that overrides a method
>>>> from a class. In your case, the clone method is defined in an interface, 
>>>> and
>>>> you are implementing it, not overriding it .. and hence the error.
>>>>         
>>>> Java 6 onwards, you can apply the @Override annotation to methods that
>>>> implement an interface.. so you won't get this warning. Strangely, using
>>>> Java 6 compiler with source="1.5" does not trigger this error.
>>>>         
>>>> Finally, eclipse is the third culprit. It automatically puts in those
>>>> annotations, and I haven't yet figured out a way to tell it "don't put 
>>>> those
>>>> annotations when I am implementing an interface"..
>>>>         
>>>> --Sri
>>>>         
>>>> On 25 May 2010 15:49, mmoossen <mmoos...@gmail.com> wrote:
>>>>         
>>>>> Dear all,
>>>>>           
>>>>> I have a serializable object that overrides the Object.clone() method
>>>>> and implements the cloneable interface.
>>>>> and i have the problem that eclipse (and me too) wants to have the
>>>>> Override annotation but while compiling the GWT compiler fails with
>>>>> following error message
>>>>>           
>>>>> [java][ERROR] Line 175: The method clone() of type XXX must override
>>>>> or implement a supertype method
>>>>>           
>>>>> which sounds pretty much like a bug in the GWT compiler to me... i
>>>>> mean, why does the GWT compiler care about those annotations? and more
>>>>> over, why does it *FAIL*.
>>>>>           
>>>>> could somebody explain the issue to me?
>>>>>           
>>>>> thanks
>>>>> Michael
>>>>>           
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> google-web-toolkit+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/google-web-toolkit?hl=en.
>>     
>
>   

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to