🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
5 messages
5 total messages Started by Raul Lorenzo Tue, 04 Apr 2006 14:51
warning: [unchecked] unchecked conversion
#174
Author: Raul Lorenzo
Date: Tue, 04 Apr 2006 14:51
10 lines
1077 bytes
Hello,

I have this piece of code:

ArrayList<Element> children = new ArrayList<Element>();
children.addAll(current.getOwnedElement());

What do I need to add to second line to remove the warning?

Thanks
Re: warning: [unchecked] unchecked conversion
#175
Author: Paul Furbacher [TeamB]
Date: Tue, 04 Apr 2006 15:47
58 lines
2513 bytes
Raul Lorenzo wrote:
> Hello,
> 
> I have this piece of code:
> 
> ArrayList<Element> children = new ArrayList<Element>();
> children.addAll(current.getOwnedElement());
> 
> What do I need to add to second line to remove the warning?

What warning are you getting?

Oh, you violated rule #0 -- NEVER put valuable information
in the subject line!

What is the declared return type for "current.getOwnedElement()"?

Collection<Element>?

as in ...

public class GenericsTest {
   public GenericsTest() {
   }

   public static void main(String[] args) {
     GenericsTest test = new GenericsTest();
     Current current = new Current();
     ArrayList<Element> children = new ArrayList<Element>();
     children.addAll(current.getOwnedElement());
   }

   public static class Current {
     public Collection<Element> getOwnedElement() {
       return null;
     }
   }
}

Your choice of names seems odd: "ownedElement" doesn't
connote a collection required by "addAll".  "ownedElements"
would seem to be more appropriate.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Re: warning: [unchecked] unchecked conversion
#176
Author: Raul Lorenzo
Date: Tue, 04 Apr 2006 16:44
30 lines
2001 bytes
Paul Furbacher [TeamB] escribi�:
> Raul Lorenzo wrote:
>> Hello,
>>
>> I have this piece of code:
>>
>> ArrayList<Element> children = new ArrayList<Element>();
>> children.addAll(current.getOwnedElement());
>>
>> What do I need to add to second line to remove the warning?
> 
> What warning are you getting?
> 
> Oh, you violated rule #0 -- NEVER put valuable information
> in the subject line!
Sorry about that, I wrote a clear subject, but I should repeat the
information in body message.
> 
> What is the declared return type for "current.getOwnedElement()"?
> 
> Collection<Element>?
It returns Collection simply.
> 
> Your choice of names seems odd: "ownedElement" doesn't
> connote a collection required by "addAll".  "ownedElements"
> would seem to be more appropriate.
It isn�t my choice, that method belongs to MagicDraw OpenAPI, so I
couldn�t change it.
current is a kind of container which could have different kind of
elements, and those elements are returned by getOwnedElement().
Re: warning: [unchecked] unchecked conversion
#177
Author: Paul Furbacher [TeamB]
Date: Wed, 05 Apr 2006 03:46
28 lines
1877 bytes
Raul Lorenzo wrote:

> [the] method belongs to MagicDraw OpenAPI, so I
> couldn�t change it.
> current is a kind of container which could have different kind of
> elements, and those elements are returned by getOwnedElement().

In that case, one alternative would be to add the annotation

   @SuppressWarning("unchecked")

to stifle the warning.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Re: warning: [unchecked] unchecked conversion
#184
Author: Gillmer J. Derge [TeamB]
Date: Mon, 10 Apr 2006 14:33
23 lines
1915 bytes
Paul Furbacher [TeamB] wrote:
> In that case, one alternative would be to add the annotation
> 
>   @SuppressWarning("unchecked")
> 
> to stifle the warning.

This doesn't work in the JDK provided with JB2006.  You would need to 
upgrade to the latest JDK1.5 Update 6 in order to get support for this. 
  You would also probably need to enable "project javac" as the Java 
compiler for the project.

I haven't actually tested that this works in update 6, but the Sun Bug 
Parade implies that it should.

Fun hypothetical question to pass some time with today: WTF was the 
point of implementing a SuppressWarnings annotation but not actually 
doing anything with it in the compiler until 6 updates down the line? 
AFAIK Eclipse has supported it for a long while.  Was this some kind of 
backdoor nod to Eclipse from Sun?

-- 
Gillmer J. Derge [TeamB]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads