wood burning stoves
The moose likes Features new in Java 7 and the fly likes Reification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "Reification" Watch "Reification" New topic


Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I don't really know the details but this looks interesting:


It's from Mark Reinhold's presentation at Devoxx.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

Hmm, run-time availability of type-information (generics).
No more type erasure? Well, there goes binary compatibility...
I don't see this happening anywhere in the immidiate future.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

I'm not convinced that type-erasure is a good idea, long term. It was a needed hack to allow pre-Java-5 bytecode to run, but it adds a lot of complexity and can bring subtle bugs.

I would be happy if it went away in some suitable future Java-like language.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

Jelle Klap wrote:Hmm, run-time availability of type-information (generics).

I probably missed something, because I didn't see anything like that. All I saw was:
- being able to use primitives as generic types
- type inference for the instantiation

How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15094

I don't know why Mark Reinhold showed this example while he was talking about type reification (see the photo: the title of the slide is "Language Futures: Reification").

Type erasure was an unfortunate idea that made it into Java, only because raw types needed to be supported for backward compatibility. Type erasure has lead to a number of warts, like the impossibility of creating arrays of a concrete parameterized type. Other languages, Scala for example, are also bothered by type erasure; in Scala there is an ugly workaround (manifests) to get generic type information at runtime.

In my opinion, generics should never have been implemented with type erasure - and now it is much harder to add type reification to Java because everything has to stay backward compatible. It would be nice if we could get rid of type erasure in Java and the JVM, but it's not going to be easy.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

I fully agree on type erasure. Without it, it would (probably) even be possible to instantiate instances and arrays (new T[10] anyone?) of generic types. I even made up a syntax for the first:
In this example, Integer can only be used with doSomething1 and doSomething3. It misses the constructors required for doSomething2 and doSomething4 and therefore cannot be used there.
I agree. Here's the link: http://aspose.com/file-tools
subject: Reification
It's not a secret anymore!