Declarative Immutability in Java
martijnverburg at gmail.com
Wed May 11 08:27:33 UTC 2016
Interesting stuff. Some quick feedback:
*TLDR:* I am not a JVM engineer and can't comment properly on the validity
of this proposal (I don't know what I don't know). In order for this to be
discussed with the right people I suggest you submit this to the next JVM
Language Summit (http://openjdk.java.net/projects/mlvm/jvmlangsummit/) in
August. Any proposed change like this need buy in from the core JVM team,
and the language summit is the first place to start socialising this
*General Advice / Feedback*
It's very clear that you've put a lot of proper thought into this which is
great! However to set expectations:
1.) This proposal is large and very impactful and given that the core JVM
team has a long roadmap planned already, this may not get a lot of air time
or attention right now.
2.) Chances are that the core JVM team has thought deeply about a lot of
this as well over the years, so don't be surprised if you do get a "Yeah
we've thought about this and decided not to do it because of X" response
when they do look at it.
3.) There are some interactions here with the proposed Value Types work as
well as potentially (Java 9) project Jigsaw security restrictions /
interactions that you might bump up against.
4.) Do you have any of this prototyped? It's generally a good idea to have
code 'strawmen' to discuss ideas around.
5.) Tag's seem to be a new construct for the JVM and the language to
understand, that's a barrier WRT to effort. Have you thought about an pure
annotation based approach instead? There's also going to be a real
challenge with the concept of adding tags to variable names for the
1.) I probably wouldn't use java.util.Date in your first example, as it
itself is famously mutable and not thread safe. Java 8 comes with
immutable date/time APIS, I'd swap to those.
2.) Java 7 added some 'deeper' cloning via the Objects and Arrays API which
you might want to look at for some of your early cloning code / and problem
There's more, but I'll stop there as I think the bigger questions need to
be discussed first.
On 11 May 2016 at 01:49, John Crowley <jdcrowley at gmail.com> wrote:
> Hi All,
> This has bugged me for years as a missing ingredient in Java, and was
> finally able to reduce it to a concrete proposal.
> If anyone has interest and bandwidth, would like to have some experts
> review this and provide a sanity check - is this complete, consistent,
> Summary from the beginning of the abstract:
> This note proposes a pervasive mechanism to declare that variables, object
> instances, and methods are mutable or immutable within a standard
> object-oriented language.
> The goal of this research is to make the declaration of mutability an
> integral part of the type structure of the language. This allows the
> developer to declare, and the reader (and compiler) to determine, if a
> variable or object instance is mutable or immutable within a specific
> context, or is immutable throughout the application.
> The full document is at -
> Sorry for the overall length - could only attack this as a mechanism which
> is pervasive throughout the language.
> Thanks for any help, and am available for questions or discussion.
> John Crowley
> Westport, CT
More information about the adoption-discuss