Martin Ahrer

Thinking outside the box

0001-01-01 1 min read

The following describes selected improvements of the Java tooling. See the Java 18 release notes.

Java 18 is introducing the following tooling enhancements.

  • JEP 408 is adding the jwebserver tool that can serve static files and support the HEAD and GET methods. This is simplifying situations where a simple web server is needed for example for testing and eliminating the need for external dependencies. In case a more customized web server is required, we can use the implementations from the package com.sun.net.httpserver which constitutes the base for jwebserver.

  • JEP 413 is adding support to include Java code snippets either from external sources of inline snippets. Nicolai Parlog has a pretty decent summary of some of the features builtin. See https://nipafx.dev/inside-java-newscast-20/#code-in-javadoc

Continue reading

0001-01-01 1 min read
To Array
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/api/CollectionApi.java[tag=toArray]

0001-01-01 1 min read
Files.readString() and Files.writeString()
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/api/FilesApi.java[tag=writeStringAndReadString]

0001-01-01 1 min read

The following describes selected improvements of the Java API. See the Java 11 release notes.

Unresolved directive in <stdin> - include::PredicateApi.adoc[leveloffset=+1] Unresolved directive in <stdin> - include::StringApi.adoc[leveloffset=+1] Unresolved directive in <stdin> - include::FilesApi.adoc[leveloffset=+1] Unresolved directive in <stdin> - include::CollectionApi.adoc[leveloffset=+1]

0001-01-01 1 min read

Before Java 11 we had to use Predicate::negate and it was not possible to use a method reference. With Predicate::not we can use method references and Predicate::not reads more natural.

Not
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/api/PredicateApi.java[tag=not]

0001-01-01 1 min read
Lines
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/api/StringApi.java[tag=lines]

With String::lines we can split any multi line String into a stream of lines.

Strip
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/api/StringApi.java[tag=strip]

String::strip is similar to String::trim but with Unicode support. String also has a stripLeading and stripTrailing method.

Continue reading

0001-01-01 1 min read
Lambda variable without type with {java10}
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/lang/LambdaLocalVariable.java[tag=beforeJava11]
Lambda variable with type with {java10}
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/eleven/lang/LambdaLocalVariable.java[tag=withTypeBeforeJava11]

The type is inferred from the initializer.

With multiple lambda variables we have to use var for all or none. Also it is not possible to mix var with explicit types.

Continue reading
Older posts Newer posts