
Java 9 features announced - xngzng
http://jaxenter.com/java-9-features-announced-50896.html
======
rufugee
Nothing pollutes java source more than getters and setters. I can't believe
this _still_ isn't being address. Wish they'd move in the direction Groovy has
in this regard.

~~~
memonkey
Sorry to ask, but as a noob who just picked up Java, how do other languages
address this issue? What's wrong with getters and setters?

~~~
mythz
IMO Dart has the best implementation of properties, which you can start out as
normal fields, e.g:

    
    
        class Rectangle {
          num left, top, width, height, right bottom;
        }
    

and can access like normal:

    
    
        var height = rect.bottom - rect.top;
    

But can later be changed into a computed property without affecting the above
callsites, e.g:

    
    
        class Rectangle {
          num left, top, width, height;
    
          num get right             => left + width;
              set right(num value)  => left = value - width;
          num get bottom            => top + height;
              set bottom(num value) => top = value - height;
        }
    

C# is a close 2nd, but it's not binary (or reflection) compatible to change
from a field to a property for call-sites (i.e. it's only source-compatible).

~~~
tieTYT
Why does it matter if it's binary compatible? How does that affect the
programmer? I guess I don't understand the difference/significance between
binary and source compatibility?

I'm surprised to hear that it's not reflection compatible. As a Java
programmer, I assumed that was the main point of C# properties: Create a
property now because there's no logic needed, but if you need logic in the
future you can change the code and nobody outside needs to be aware of the
change.

~~~
dragonwriter
> As a Java programmer, I assumed that was the main point of C# properties:
> Create a property now because there's no logic needed, but if you need logic
> in the future you can change the code and nobody outside needs to be aware
> of the change.

That's the point, but its not directed at reflection, and reflection goes
around behind the scenes of the superficial access-notation compatibility.
Which does make properties a badly leaky abstraction, which is problematic
since their main reason for existing is to plug a leak in the abstraction
provided by the method/field distinction.

~~~
depoll
Another important aspect of properties in C# is that they are a target for
metadata (i.e. Attributes). This is something that's frustratingly broken with
the method getter/setter approach. And while you can fix it by convention
(e.g. a priority list for lookup on the getter, then setter, if those exist),
it ends up being inconsistent and unnecessarily painful.

Consistency of access in Java is also really problematic for the same reason.
Which pair of getter/setter methods represents a reified property? This is
often done by naming convention, that's usually, but not always consistent
(getFoo/setFoo is common, but there's also isFoo/setFoo, isFoo/setIsFoo,
foo()/foo(value), etc.). Worse (and this is something both Android's flavor of
Java SDK and Objective-C have fallen prey to), not all properties are written
symmetrically (e.g. getText() and the various setText() methods on an EditText
in Android, although there are some where all of the setters are subclasses of
the only getter -- even worse).

------
mmastrac
The lack of an official JSON API has been a huge sore point for quite some
time and has spawned dozens of libraries re-implementing the same thing over
and over (GSON, Jackson, and even my own nanojson). I do hope that we avoid
the DocumentBuilderFactory mistakes of XML and just end up with One True JSON
implementation this time.

~~~
carsongross
Are you sure that's true? As you say, look at the "standard" API for XML
parsing: a complete disaster. Dates, similar. Logging was slightly less
disastrous because they took so much from Log4j, but they still made it
unwieldy enough that the log4j guys ended up writing an API on top of _that_
which everyone uses.

Now, props where props are due: Sun crushed the collections APIs compared to
other languages at the time. And that more than makes up for everything else.

But I see little evidence that standardizing JSON parsing will improve things.

~~~
mmastrac
I'll counter that with saying that j.u.l is not actually that bad, IMO,
although I might be the only one in the world that thinks that. I always just
choose j.u.l in my projects because it works well-enough. I just shim anything
with slf4j if it speaks log4j or commons-logging (shudder).

Perhaps Sun should have just adopted slf4j and a simple console-logging stub,
but I don't think j.u.l is really any worse than the alternatives -- only a
different implementation.

Now date APIs: those do suck, but I think the new Date JSR will finally get
things to a place where we can use Java Dates rather than Joda.

------
grizzles
My Wishlist: 1\. Fix Daemonization!

Publish an official blessed and supported way of daemonizing processes. Yeah
sure, you can use Apache commons-daemon and others of it's ilk. And it will
work. But it will feel hacked together (at least it does to me).

2\. Fix Dependency hell!

Publish a blessed / supported / standard of supporting / managing different
classloaders. Java has this great mostly unused mechanism (classloaders) for
managing dependency hell. It would be great to have platform (maybe even
language) level support to make that easy to do and a standard way of building
software.

~~~
andor
_Fix Daemonization_

This is fixed by process supervision software such as systemd -- no need to
implement it yourself. Just leave your application running in the foreground.

[http://0pointer.de/public/systemd-
man/daemon.html](http://0pointer.de/public/systemd-man/daemon.html)

------
dtech
I thought one of the things promised in Java 9 was to finally fix the
primitive mess, including all of the boxing and pointer chasing. Yet I can't
find that here.

I also thought that type reification was being researched.

Does anyone know if either of these is still a thing?

~~~
pron
Yes, they are both being worked on. They're just not sure they'll be ready in
time for 9.

~~~
karianna
The project to watch here is project Valhalla - valhalla-dev AT openjdk DOT
java DOT net. Indeed the full solution of value types will not land until Java
10, but Java 9 will hopefully contain the very useful Collection of primitives
enhancement (you can currently only have Collections of Objects, primitives
are auto boxed into their Object equivalents at much greater overhead).

------
sgarlatm
This is a huge let-down after Java 8, but I guess that was inevitable. Lambdas
are a tough act to follow and are probably my favorite addition to the JDK
ever.

------
jaybna
Did they mention if spyware will continue to be in the installer?

~~~
aphistic
Why would they mention features that are still included?

\- if continues to be a keyword

\- Spyware continues to be included

------
pjmlp
List of proposed JEPs so far.

[http://openjdk.java.net/jeps/8048330](http://openjdk.java.net/jeps/8048330)

------
CodeMage
I see that their "Process API updates" still don't make it possible to get a
NIO Pipe object for redirected stdin, stdout or stderr when
ProcessBuilder.Redirect.PIPE is used. Maybe they'll fix that some day...

------
stevebot
Sooo this means it will be what 5 years if never before Android starts to
adopt some of these new Java 9 features? Kitkat introduced some Java 7
features, but I don't think anything in 8 is near to making it in.

------
haddr
I'm deeply missing hot swapping. I believed it could be included in java 9 but
i think we have to wait...

~~~
einrealist
What is wrong with restarting your application?

Edit: Real Hotswapping will requires profound changes to the memory model. It
would introduce too much complexity. I rather restart my application than to
suffer from a fragile and leaking platform.

~~~
tieTYT
It can take up to 5 minutes to restart my application.

~~~
Roboprog
So run multiple instances of the app, and put some kind of load balancer /
proxy in front of the instances.

Unfortunately, this will require externalization of state data, but if you
can't be down for 5 minutes, that's what you need to do.

You probably only need one large server running the instances, rather than a
cluster. Java apps don't seem to do well -- longer GC pauses -- when they have
over 2 GB of memory, anyway, so run multiple instances of "small" apps on a
server with say 12 cores. A single server with a large pool of RAM shared
between a large number of cores can do pretty amazing things with a collection
of "small" programs on it (DB, web service apps, message queue server, web
servers)

Of course, I'm assuming said server _isn 't_ Windows...

~~~
winterbe
I don't think he meant hotswapping in productive environments but during
development. Load balancing doesn't help here.

The webapp I'm working on currently has a startup time of 50s on my macbook.
If I restart the webapp 100 times a day, thats a total waiting time of 30+
minutes. Our team is 6 developers, so we loose 3h per day.

Real hotswapping may be extremely complex but IMO it would be absolutely worth
the effort.

~~~
Roboprog
Ah, gotcha. It's funny, I used to do _very_ frequent tests like that when I
worked in C (particularly the first few years in the language), but tend to do
much fewer test runs in Java. Fewer fatalities, but longer build/start times,
I guess.

------
dandrews
Sourced here:
[http://www.infoq.com/news/2014/08/Java9-FirstFeatures](http://www.infoq.com/news/2014/08/Java9-FirstFeatures)

------
adamlett
Still no hash literal :-(

~~~
exabrial
Not really a place for it in a strongly typed language like Java :/ I could
maybe see language support for creating Maps or something, but in Java you're
supposed to create your own Objects and let the compiler check your code for
errors.

~~~
pswenson
I assume you meant _statically_ typed, rather than strongly typed.

Swift has this: var airports: [String: String] = ["TYO": "Tokyo", "DUB":
"Dublin"]

~~~
exabrial
:D Thanks for the correction

I like the swift example... Map<String, String> map = new HashMap<>(){"TYO":
"Tokyo", "DUB": "Dublin"};

------
suprgeek
Fix the Modularity business properly! Please simplify and make a standard
system that most people can get behind. While Jigsaw started out ambitiously,
I attended some of the initial meetings and the scope was....awesome.

Then it scaled back to a re-org of the rt.jar to make it easy to run on mobile
devices (Ironically we are seeing the full circle - Java started out as a Set-
top box language, then graduated to an enterprisey kitchen-sink and now wants
to come back to a modular approach).

Now they seem to want to do some half-baked OSGI compliant approach. Have they
used OSGI on medium/larger projects? There is literally no amount of money you
can pay me to tackle something that hairy and complex.

~~~
xpto123
So the whole JDK will be based on modules that might or not be included in
potentially different profiles (for example a Java ME equivalent?), or has
that been dropped ?

I remember seeing something about that in a presentation a few years ago.

I think it's a good decision from Oracle to not include much more (compared to
Jigsaw) in Java 9, given the huge scope of the Jigsaw change, which might
probably be the change with the largest internal code impact so far ever done
in Java, or at least one of the largest (if the plan to refactor the JDK for
modules goes further).

------
cowardlydragon
A lightweight JSON API? Hopefully they don't consider the XML jdk monstrosity
lightweight. Java SDKs haven't produced superior technology to OSS libraries
for a decade, so I expect Jackson to still be better.

The http client was so basic in the JDK it has spawned TWO apache HttpClients
projects.

Jigsaw... fool me three times? Wasn't this supposed to be in JDK7?

------
gamesbrainiac
This looks more like a minor update, and not as radical as Java 8.

------
sapiogram
> improved support for multi-gigabyte heaps

I've heard this thrown around before, but what this actually mean? Is it just
some optimizations to the garbage collector?

~~~
pas
Work on G1 GC. Now it can deal better with humongous regions (can collect them
in mixed cycles, not just at the end of a slow and expensive full marking
cycle), had a lot of fine tuning work done, and all in all, it seems to me
that Oracle allocated/allowed/encouraged JVM GC developers to participate on
the hotspot mailing list. ( [http://mail.openjdk.java.net/pipermail/hotspot-
gc-use/](http://mail.openjdk.java.net/pipermail/hotspot-gc-use/) )

And see also:
[https://bugs.openjdk.java.net/issues/?jql=project%20in%20(JD...](https://bugs.openjdk.java.net/issues/?jql=project%20in%20\(JDK\)%20AND%20component%20in%20\(hotspot\)%20AND%20Subcomponent%20in%20\(gc\))

------
lafar6502
Looks like they're actually listening to developers

------
kclay
Is it possible to have native JSON parsing with JNI bindings to make parsing
faster, or will the overhead cancel out any boost in performance?

~~~
kasey_junk
Why wouldn't you be able to write JSON parsing fast in Java natively? Even if
you can't, it's precisely the kind of thing that would pay a large JNI
penalty.

~~~
azinman2
Boxing and unboxing characters is a big part of performance penalties,
especially when dealing with Unicode.

------
pswenson
yawn..

Maybe around 2020 we'll get some useful stuff like string interpolation, long
strings, default param values, and multiple return values!

------
stusmall
I had heard a rumor that there ware talks of user defined value types. Does
anyone know if there is any hope for this?

~~~
danieldk
It seems that it is almost in prototyping stage, the usual suspects have
already written a sketch of a future proposal:

[http://cr.openjdk.java.net/~jrose/values/values.html](http://cr.openjdk.java.net/~jrose/values/values.html)

~~~
stusmall
Awesome! Thanks. I don't know much about the path from idea to standardized
feature with the JVM. Is there hope for it in Java 9 or is this much farther
out in the future? Probably first and more importantly, what is the chance for
this even ever happening?

~~~
hyperpape
"the path from idea to standardized feature" Guy Steele was asking for value
types in 1998
([http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf](http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf))

~~~
Padding
Yeah, but he was also asking for operator overloading.

~~~
hyperpape
Well, I don't have a problem with that, but it's not really relevant. The
community liked one proposal and disliked the other, but it still took almost
two decades to handle the one it liked.

~~~
Padding
My point was that him simply liking/proposing it doesn't mean much.

------
derengel
Does anyone know if project jigsaw will improve the startup time for JVM
languages?

~~~
karianna
It will depend on howe small a profile the JVM language can run on. In theory
you could run some JVM languages on the compact profile resulting in a n
overall faster startup time.

------
guelo
No language features?

~~~
karianna
There maybe some small ones, but the (and I think correct) decision was made
to focus on the JVM for Java 9. Java 8 bought in enough language features to
keep Joe/Jane Java developers happy (most bleeding edge folks moved to Scala
or other languages).

------
miralabs
a new json api to be released 2016. Hopefully by that time json is still
relevant. I know most likely it will but at the pace of change that tech has,
im not betting.

is there any contender to json at the moment?

~~~
justwannareply
YAML ([http://www.yaml.org](http://www.yaml.org)) comes to mind, though I
think JSON is a much bigger improvement over XML than YAML is over JSON.

~~~
azinman2
Yaml is more for humans to read than json is, and doesn't have native
functions in any browser.

------
fortuitous
As a side note, I realized java 7's Objects class was copied from google's
Objects library class, but with name changes. They could have copied the
apache API, but nope. This is fine by itself, but these are the same jerkoffs
claiming some sort of copyright over the java JDK API. Quite disgusting.

------
arielweisberg
Still no solution for the GC fragmentation and pauses? Arbitrarily large heaps
and data structures?

They are going to improve lock performance, but do nothing to help people
avoid locking like lightweight threads. Not waking up a thread and not locking
is faster...

It's weird how so many software projects completely lose sight of the
fundamentals.

I know I am biased due to how I use Java. I care very little for syntax and
syntactic sugar. Reading and typing speed is not a problem for me. Get stuff
done on time is and working around these shortcomings eats up my time.

~~~
osi
If you want to rid yourself of GC problems, go buy Azul's Zing JVM. It works
like magic.

(disclosure: I'm a very happy customer of theirs)

~~~
arielweisberg
Zing does not do you any good if you are selling software. Your income is
reduced by the license cost of Zing in addition to the additional sales and
deployment friction.

The reality is that you have to build software that works on the Oracle JVM.

~~~
osi
ah, understood. have you been tracking shenandoah?
[http://openjdk.java.net/jeps/189](http://openjdk.java.net/jeps/189)

~~~
arielweisberg
I have heard of it but haven't read up. I think it's great that someone is
stepping up to address the issue. Interesting that both the authors listed in
the JEP work for Red Hat.

~~~
karianna
Shenandoah is unlikely to see the light of production release until Java 10. I
ran a very early piece on this -
[http://www.jclarity.com/2014/03/12/shenandoah-
experiment-1-w...](http://www.jclarity.com/2014/03/12/shenandoah-
experiment-1-will-it-run-pcgen/) \- really glad to see more experiments in
this space. I'll add that G1 from Java 8u5 onwards is pretty darn good out of
the box.

