classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: JDK 1.5 support?


From: David Holmes
Subject: RE: JDK 1.5 support?
Date: Thu, 1 Jul 2004 08:28:42 +1000

Andrew Hughes wrote:
> The hardest thing would seem to be the generics (Java's templates -- is
> it or me or does it seem strange that Java 1.5/5.0 is basically bringing
> back in lots of C++ features, mainly as a result of C# having them?).

It's you :) Java has had generics on the cards for a long time - too long,
but that's another story - since before C# existed. C# didn't define
generics initially either - have they added it yet? Java Generics is nothing
like C++ templates except for the <> syntax. You could say that a key goal
for Java generics was to NOT provide something like C++ templates. :)

> Generics are added to a lot of the core classes, notably java.util's
> collections.  Would adding this mean that compilers and code would need
> to be 1.5 ready?

In principle because generics are based on type erasure, they are primarily
a compile-time concept. So code that uses generics that is compiled with a
1.5 compiler may be runnable on a non-1.5 JVM. That said, some of the
information is stored in the extensions to the class file format for
run-time introspection (don't know the details of what you can and can't do
here). So compiling with generics tends to produce class files that won't be
understood by non-1.5 supporting VM's. I suspect you would need a compiler
that knows how to compile generics whilst producing a non-1.5 specific class
file.

David Holmes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]