• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diamond Syntax Type Inference for Generics

 
Shiv Swaminathan
Ranch Hand
Posts: 48
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though Generics is a great feature of Java 5, we had to also make sure that we follow some coding standards to avoid the disadvantages provided by generics. (There are places where Java compiler could not identify erroneous type erasure until run-time)

For details/examples refer the following articles:
http://www.anicehumble.com/2012/05/java-generic-type-erasure-advantages.html
http://www.ibm.com/developerworks/java/library/j-jtp01255/index.html

Does the Diamond Syntax Type Inference for Generics also have the same kind of issues hidden within or has the compiler improved to identify these errors?
 
Shiv Swaminathan
Ranch Hand
Posts: 48
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Pointers...help!!!

Though Generics is a great feature of Java 5, we had to also make sure that we follow some coding standards to avoid the disadvantages provided by generics. (There are places where Java compiler could not identify erroneous type erasure until run-time)

For details/examples refer the following articles:
http://www.anicehumble.com/2012/05/java-generic-type-erasure-advantages.html
http://www.ibm.com/developerworks/java/library/j-jtp01255/index.html

Does the Diamond Syntax Type Inference for Generics also have the same kind of issues hidden within or has the compiler improved to identify these errors?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The diamond syntax is merely a shorthand in coding/typing. These two are the same



They are treated the same for the compiling process, hints to the compiler. Even before type erasure, they are treated the same. It's literally just a convenience for you.
 
Shiv Swaminathan
Ranch Hand
Posts: 48
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I think this drawback of generics is yet to be addressed in future releases...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15481
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which drawback exactly?
 
Shiv Swaminathan
Ranch Hand
Posts: 48
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant the original issues with generics (type erasure) as explained in these two articles:

http://www.anicehumble.com/2012/05/java-generic-type-erasure-advantages.html
http://www.ibm.com/developerworks/java/library/j-jtp01255/index.html
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The type erasure for generics is still in place.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic