Java 5 Generics rules, OK?

I just worked it out: the aim of Generics is to make it near impossible to decompile java source code!

Because it was too easy using refactoring tools etc, Sun made it so that if you use a good sprinkling of generics, it’s impoosible for anyone to ever understand your code, no matter how good their decompiler. And even if you could, it won’t work because of the places where generics breaks fundamental assumptions about java (like arrays).

I mean, heck, no-one can understand the original source, so how are they going to understand the decompiled version?

It’s brilliant. Sheer genius. I doff my hat to the people in charge - and apologise unreservedly for denigrating their great achievement - I just didn’t understand, but now I have seen the light.

Could you give some examples (for example about arrays)? The way I’ve understood generics is that they exist only for the compiler, and the generated bytecode has all parameterized types replaced with Objects (or other superclass) and appropriate casts.

The arrays issue is slightly pesky, but hats off to Blah^3 for spotting Sun’s secret agenda :wink:

Cas :slight_smile: