Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Generics

Reply
Thread Tools

Generics

 
 
Smallfernandes
Guest
Posts: n/a
 
      03-17-2005
As we know, J2SE 1.5 supports generic programing, but anyone knows if
there's some performance implications about using generics in java ??
(besides code reutilization )

 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      03-17-2005
Smallfernandes wrote:

> As we know, J2SE 1.5 supports generic programing, but anyone knows if
> there's some performance implications about using generics in java ??
> (besides code reutilization )
>


Use of Java generics has no runtime performance impact whatsoever
relative to the equivalent non-generic code. The type information
associated with generics is used for compile-time checks, but it has no
runtime manifestation.

--
John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Jesper Nordenberg
Guest
Posts: n/a
 
      03-18-2005
"John C. Bollinger" <(E-Mail Removed)> wrote in message news:<d1d0pv$4r4$(E-Mail Removed)>...
> Smallfernandes wrote:
>
> > As we know, J2SE 1.5 supports generic programing, but anyone knows if
> > there's some performance implications about using generics in java ??
> > (besides code reutilization )
> >

>
> Use of Java generics has no runtime performance impact whatsoever
> relative to the equivalent non-generic code. The type information
> associated with generics is used for compile-time checks, but it has no
> runtime manifestation.


Correct, but one should know that since the JVM has no knowledge of
generic types the compiler insert casts in the code whenever a generic
type is used. So, for example:

class PointList {
...

public Point get(int index) {
...
}
}

is probably a bit more efficient than:

class List<T> {
...

public T get(int index) {
...
}
}

But that shouldn't stop you from using generic types. And often the
cast can be optimized away by HotSpot.

/Jesper Nordenberg
 
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
generics depending on generics Soul VHDL 0 02-02-2009 09:14 AM
Can't convert a generics list of objects into a generics list ofinterfaces Juergen Berchtel Java 1 05-20-2005 02:07 PM
generics in TB valentin tihomirov VHDL 4 12-18-2003 07:04 PM
Integers only as generics? Acciduzzu VHDL 4 09-23-2003 12:45 AM
Re: Multi-dimentional arrays in components using generics Willem Oosthuizen VHDL 1 07-09-2003 12:13 PM



Advertisments