public class TextBlocks {
public static void main(String[] args) {
System.out.println("""
Hello,
text blocks!""");
}
}
Karlsruhe
October 24th, 25th
50% discount: AccJUGCH23
I have two free tickets!
A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over the format when desired.
language feature added in Java 15
triggered additions to String
:
formatted
,
indent
,
stripIndent
,
translateEscapes
Java features:
come as syntax, VM capabilities, APIs
(or any combination)
specified in JLS, JVMS, Javadoc, etc. &
implemented in openjdk/jdk
fulfill clearly defined requirements
fit in seamlessly & have good tool support
Why did this take so long?
But where does a feature come from?
Long story:
starts with an idea
refinement in explorations
prototype and proposal
preview feature
finalized feature
Features |
Previews |
Proposals |
Explorations |
Ideas |
The concept of preview features was:
introduced by JEP 12
refined by a recent JEP draft
specified by JLS (e.g., for 20)
Required artifacts for preview features:
specified in JLS:
all preview features are mentioned
JLS changes/diffs are linked
implemented in openjdk/jdk, but:
disabled by default
by compiler and runtime
Enabling:
for compiler and runtime
with --enable-preview
generates compiler warnings
pins Java version
public class TextBlocks {
public static void main(String[] args) {
System.out.println("""
Hello,
text blocks!""");
}
}
Compiling with Java 14:
$ javac TextBlocks.java
> TextBlocks.java:4: error: text blocks are a preview
> feature and are disabled by default.
> System.out.println("""
> ^
> (use --enable-preview to enable text blocks)
> 1 error
$ javac --enable-preview --release 14 TextBlocks.java
> Note: TextBlocks.java uses preview language features.
> Note: Recompile with -Xlint:preview for details.
Running with Java 14:
$ java TextBlocks
> Error: LinkageError occurred while loading main class
> TextBlocks
> java.lang.UnsupportedClassVersionError:
> Preview features are not enabled for
> TextBlocks (class file version 58.65535).
> Try running with '--enable-preview'
$ java --enable-preview TextBlocks
> Hello,
> text blocks!
Compiled with Java 14, launched with 15:
$ java --enable-preview TextBlocks
> Error: LinkageError occurred while loading main class
> TextBlocks
> java.lang.UnsupportedClassVersionError:
> TextBlocks (class file version 58.65535)
> was compiled with preview features that are
> unsupported. This version of the Java Runtime
> only recognizes preview features for class
> file version 59.65535
Goals of preview features:
prevent (accidental) use in production
foster early IDE support
user experimentation and reports
review and refinement
Considerations:
"Is it surfaced correctly?"
"Are there unforeseen edge cases?"
Preview features evolve a bit
(particularly on the surface)
and usually finalize.
My guesstimates:
duration: 12-24 months
rate of change: 5%
rate of progression: 95%
Features |
Previews |
Proposals |
Explorations |
Ideas |
JEPs were introduced by JEP 1 (in 2011).
It was superseded by JEP 2.0 draft (in 2014).
JEPs (as JBS issues) by states:
drafted: 437
open:
draft: 51
candidate & active: 33
candidate & dormant: 13
closed:
withdrawn: 18
rejected: 31
delivered: 291
drafted: 340
withdrawn: 18
rejected: 31
delivered: 291 (85%)
Proposals are defined by JEPs.
Often also come with implementations in
project forks or feature branches of openjdk/jdk, e.g.:
Goals of JEPs:
expose proposal to wider audience
seek feedback on the proposed solution
motivate, describe, archive proposals
with their contexts and consequences
Proposal considerations:
"Is this the right way to do it?"
Proposals evolve noticeably
(particularly until Candidate)
and most are delivered.
My guesstimates:
duration: 6-36 months
rate of change: 40%
rate of progression: 85%
Features |
Previews |
Proposals |
Explorations |
Ideas |
"withers" for records (design notes)
declared patterns (email thread)
shifting and constraining computation (white paper)
mailing list exchanges
meetings
design notes (e.g. for Amber)
conference talks
(Roughly in order.)
Unlike the steps so far, this one is:
mostly unspecified
mostly unstructured
without barrier for contribution
assess feasibility
shape a general idea
to a specific proposal
estimate complexity and effort
"Does it fit into Java / the ecosystem?"
"Can it be implemented?"
"Can it be introduced?"
"What priority does it have?"
During exploration, features evolve
fundamentally and many are dropped.
My guesstimates:
duration: 6-60 months
rate of change: 50-500%
rate of progression: 25-75%
Features |
Previews |
Proposals |
Explorations |
Ideas |
If only Java had $FEATURE, this would be so much more elegant.
(Stares procrastinatingly into distance…)
$FEATURE works great in $LANG.
Java needs $FEATURE!
Even Brian Goetz has so many,
he needs a bunch of notebooks
to keep track of them.
Ideas are cheap…
no specifications
no process
no barriers
no attention
…execution is everything.
Goal is to make Java / the JVM better.
Considerations:
"Is this a good idea?"
"… for Java?"
"… now and/or in the future?"
My guesstimates:
duration: 🤷🏾♂️
rate of change: 🤷🏾♂️
rate of progression: 🤷🏾♂️
Features |
Previews |
Proposals |
Explorations |
Ideas |
Feature Evolution |
Even final features aren’t final!
Considerations for feature evolution/removal:
Does it hurt?
Is it used?
Can it be extended/improved?
Would a change/removal hurt?
rarely used
prevents very useful language feature
easy to fix
maintenance cost
lots of alternative GCs
easy to fix
obsolete and disused
prevent primitive types
easy to fix
unused and unusable
easy to get wrong
peformance & maintenance cost
better mechanisms exist
Features are extremely stable
but not immutable.
My guesstimates:
rate of change: 0.5%
survival rate: 99.95%
Got everything?
Let’s rewind.
Considerations | |
---|---|
Idea | "Can it be good for Java?" |
Exploration | "How can it be implemented/introduced?" |
Proposal | "Is this the best way to implement it?" |
Preview | "Is it surfaced correctly?" |
Feature | "Does it hurt? Can it be changed/removed?" |
Spec | Artifacts | 📆 | 🧬 | 🚀 | |
---|---|---|---|---|---|
Idea | — | 🌬, 📔 | 🤷🏾♂️ | 🤷🏾♂️ | 🤷🏾♂️ |
Explorat. | — | 🎟, 📬, … | 6-60 | 50-500% | 25-75% |
Proposal | JEP 1 | JEP / jdk 🌳 | 6-36 | 40% | 85% |
Preview | JLS | JLS diff / jdk | 12-24 | 5% | 95% |
Feature | JLS | JLS / jdk | ∞ | 0.5% |
Incubating APIs:
belong into Proposal (not Preview)
come with alpha implementations
JEPs:
not all proposals need one
smaller changes rely on JBS issues
Every change impacts:
millions of developers
billions of lines of code
industry, research, games, hobbies
billions of Euros of annual revenue
Better safe than sorry.