Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference Between Java 7 and Java 8 (with respect to Annotations )  RSS feed

 
Rohit Kumar Singh
Ranch Hand
Posts: 105
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Can anyone Guide me through the Basic Changes or Advancement's that has been done in JAVA 8 from JAVA 7 ,

Especially with respect to Annotations ...

Any Guidance will be Highly Appreciated ...


Thanking You in Advance .
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read this https://en.wikipedia.org/wiki/Java_version_history#Java_SE_7_.28July_28.2C_2011.29 and the section below that?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All released Java version have substantive documentation of what changed; for example, this is the one for Java 7. But there isn't even a release candidate version of Java 8, so there's not a lot of documentation available yet. You can probably find something somewhere around here, or in what's been published already, like this article (which I found through a quick Google search; it should be easy to find more).
 
Rohit Kumar Singh
Ranch Hand
Posts: 105
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok let me study those...


Thanks everyone for there Responses ...
 
Cay Horstmann
author
Ranch Hand
Posts: 195
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java 8 has two enhancements to annotation processing: repeated annotations and type use annotations. Moreover, reflection has been enhanced to report method parameter names. This has the potential to simplify annotations on method parameters.

Repeated annotations are the most interesting part for most people. Right now, to specify a composite key, you have to write:



Ugh. With repeated annotations, you can write



Some future version of JavaEE is very likely to embrace this.

Type use annotations let you put annotations on many more places than before, e.g.



There isn't actually a @NonNull annotation in Java, but there is a 3rd party framework (http://types.cs.washington.edu/checker-framework/) that provides it.

With method parameter reflection, it is possible to, well, get the names of the method parameters through reflection. Instead of



you can write



if your param names are the same as the method parameter names, as they are in 99.44% of all cases.

(This is in JAX-RS.)

Unfortunately, for the necessary information to appear in the classfile, the source must be compiled as javac -parameters SourceFile.java. Let’s hope annotation writers
will enthusiastically embrace this mechanism, so there will be momentum to drop that compiler flag in the future.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!