No question. No information. I just want to say that type erasure sucks and imagine a couple of heads around the world nodding in agreement.
Thanks…I feel better already.
(edit: grammar error)
No question. No information. I just want to say that type erasure sucks and imagine a couple of heads around the world nodding in agreement.
Thanks…I feel better already.
(edit: grammar error)
here have something for you
Anonymous classes don’t suffer from type erasure.
It is a bit of a pain that it erases the info but… isn’t it nice how it just retrofitted with the nice simple bytecode of yesteryear and kept everyone’s VM implementations simpler and old libraries working fine.
Cas
But that’s really just an excuse for an easier implementation. I’d have been fine with working generics which one could not compile down to older targets. My guess is that very little of that happened anyway.
As cas pointed out, all the old libarys wouldn’t be compatible like all Collections^^
No List!
What they do now for Java 8 with the class extensions thing, to handle lambda expressions in old libarys could be extendend perhaps for better generics …
It was a crafty upgrade. Sun weren’t / aren’t the only JVM vendors and forcing every licensee to completely overhaul their VMs for this one small change would have been daft. The way it is now keeps things really simple under the hood.
Cas
Type erasure isn’t really so much the problem – even Haskell uses erasure – it’s that they left it at the halfway point and didn’t add in any reification for when you do need it. It doesn’t have to be all or nothing, so Java could conceivably add reified types in the future. I just have my doubts it’ll happen. Scala is a good way toward finishing the job using manifests, but they can’t do everything.
The bytecode format did change for generics (classes have generic info, it’s instances that are erased), and having every licensee overhaul their VMs is what versioning and a rigid spec is all about. I don’t think Sun really cared about third party VMs keeping up anyway.
@Danny2: JDK4 compliant stuff would have work just fine. They could have required the VM change to be JDK5 compat. We have to make that choice anyway because of public API changes. It wouldn’t have been a big deal.
@princec: But it wouldn’t have been an big overhaul to the VM. It would have required a few change to the verifier, which they completely overhauled in the next release anyway. The amount of work to update the the new public APIs introduced was much bigger.
@sproingie: My big problem with type erasure in Java is that it makes self referencing types pretty much useless without ugly, error-prone, and pointless (as everyone BUT the VM is aware) boilerplate code.