Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to solve this warning in Eclipse?

Reply
Thread Tools

how to solve this warning in Eclipse?

 
 
Roedy Green
Guest
Posts: n/a
 
      03-13-2006
On Mon, 13 Mar 2006 00:07:55 -0500, "John C. Bollinger"
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>You might want to read
>http://java.sun.com/j2se/1.5.0/docs/.../generics.html for a


after that try http://mindprod.com/jgloss/generics.html particularly
the link to Angelika Langer's FAQ. That is the one that made most
sense for me.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
 
Timo Stamm
Guest
Posts: n/a
 
      03-13-2006
John C. Bollinger schrieb:
> Generics are not *about* type safety. They are *about* extending the
> Java type system with parameterized types. Use of such types can
> greatly reduce the need to perform type conversions that cannot be
> proved valid by the compiler; this is what most people mean when they
> talk about "type safety" with respect to Generics. Type safety in that
> sense is an important application of parameterized types, but not the
> central idea.



Java generics can only be used for type safety because the type info is
erased. What else can you use java generics for?


Timo
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      03-13-2006
On Mon, 13 Mar 2006 13:13:18 +0100, Timo Stamm <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>Java generics can only be used for type safety because the type info is
>erased. What else can you use java generics for?


I think it would be more accurate to say that Java Generics can be
used to check type consistency EVEN THOUGH the type information is
erased before run time. Generics are a purely compile time check.

They also help the compiler to generate more efficient code. Generics
give the code generator hints when it can presume something more
specific than Objects being tossed about.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
jlowery05
Guest
Posts: n/a
 
      03-13-2006
Since the type information is 'compiled out', I can't see how Generics
would allow the compiler to generate more efficient code. I've reverse
compiled some Generic constructs and they look pretty much identical to
their non-Generic cousins.

 
Reply With Quote
 
Ian Shef
Guest
Posts: n/a
 
      03-16-2006
"jlowery05" <(E-Mail Removed)> wrote in news:1142288566.230274.163740
@i39g2000cwa.googlegroups.com:

> Since the type information is 'compiled out', I can't see how Generics
> would allow the compiler to generate more efficient code. I've reverse
> compiled some Generic constructs and they look pretty much identical to
> their non-Generic cousins.


My understanding is that without Generics, the compiler sometimes must insert
casts and type checks to perform verification at runtime.
With Generics, some of these casts and type checks can be eliminated because
the checking has been performed at compile time.

I am still learning Generics (there is a lot to learn), so I hope that I got
this right.



--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *
 
Reply With Quote
 
Timo Stamm
Guest
Posts: n/a
 
      03-16-2006
Ian Shef schrieb:
> "jlowery05" <(E-Mail Removed)> wrote in news:1142288566.230274.163740
> @i39g2000cwa.googlegroups.com:
>
>> Since the type information is 'compiled out', I can't see how Generics
>> would allow the compiler to generate more efficient code. I've reverse
>> compiled some Generic constructs and they look pretty much identical to
>> their non-Generic cousins.

>
> My understanding is that without Generics, the compiler sometimes must insert
> casts and type checks to perform verification at runtime.
> With Generics, some of these casts and type checks can be eliminated because
> the checking has been performed at compile time.


No, the information is erased at compile time. From the java generics
tutorial:

| Basically, erasure gets rid of (or erases) all generic type
| information. All the type information betweeen angle brackets is
| thrown out, so, for example, a parameterized type like List<String> is
| converted into List. All remaining uses of type variables are replaced
| by the upper bound of the type variable (usually Object). And,
| whenever the resulting code isn’t type-correct, a cast to the
| appropriate type is inserted [...]



Timo
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      03-26-2006
Timo Stamm <(E-Mail Removed)> wrote:
> Java generics can only be used for type safety because the type info is
> erased. What else can you use java generics for?


By far the most important use is to communicate to other developers
using an API the exactly type of object they need to use to interact
with your classes. Generic type parameters are described by JavaDoc,
recognized and used by "auto-complete" features of development
environments, etc. This really doesn't fit under "type safety" so much
as convenience. As John said, though, it is described as a benefit of
extending the type system.

I'm saying this is a local benefit. It should not be taken to imply
that I agree generics are a net benefit to the language. I think the
jury is still out on that one.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to solve xmlsimple.rb warning: already initialized const Johnroy World Ruby 2 02-13-2009 04:52 AM
Java - how to solve this warning in Eclipse? Generic Problem princess.d Java 1 07-08-2008 11:48 AM
Java - how to solve this warning in Eclipse? princess.d Software 1 07-08-2008 11:14 AM
WARNING:Xst:795: Size of operands are different : result is <false>. how to solve it? Chao VHDL 6 07-05-2004 06:32 PM
weird 'C' warning - can you solve this? Ross C Programming 11 02-27-2004 02:59 PM



Advertisments