• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

javax.annotation.concurrent.Immutable

 
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I stumble upon @Immutable annotation in javax package. I would like to know what it is actually doing to the class ??
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the javadoc for this in hibernate validation jar
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tushar, you are mentioning org.hibernate.annotations.Immutable, which is not the same annotation as what Sangel means.

There was once a proposal, JSR 305, to add some extra annotations to Java's standard library. Some of these were eventually added to the package javax.annotation, but there's no Immutable annotation in Java 8.

The purpose of the annotations of JSR 305 is to help tools understand what you mean. So, you could for example put an @Immutable annotation on a class that should be immutable, and a tool could then check if the class was indeed immutable. This is similar to how the @Override annotation works - you put it on a method that according to you should override a superclass method, and the compiler gives you an error if it doesn't.

The purpose is to help the compiler or other tools to check if your code is correct. It will not automatically make your class immutable!
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic