Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

My notes from Day Two of Oracle CodeOne conference

2 min read

Here are my notes from the talks I attended on Day Two of OracleCodeOne. Some excellent content – feel free to engage me on twitter at @markee174 if you have any questions.

Coding Your Way to Java 13 [TUT3090]

Most devs in the room still on Java8
Detailed walkthrough on modules and encapsulation
showed javac using –module-source-path
Covered Services and Service contracts as a way to decouple modules with provides and uses keyword
jlink builds on modules and really useful for Docker images and creating smaller custom JVMs. Note jlink does not follow all provides and services. Use –add-modules flag
Enterprise APIS (CORBA, xml.bind,, activation, transaction gone in Java11. Can easily be fixed by adding in module

jshell – REPL – will create variables like $1 you can then reference. Has auto-completion on commands
Writing methods can reference methods which do not yet exist – need creating before the method can run.
/vars will show variables
/methods with show methods
/edit methodName gives the basic editor

HttpClient added in 9 and finalized in 11. Also HttpRequest class and HttpResponse Async returns a completable future

Covered ReactiveStreams and new Stream additions.
Teeing Collectors allows combined function.
Demo of flatMap converting Optionals to stream

var added in Java10
Can write var var = “var”
From Java10 you cannot create a class called var
Cannot write var k = null
var arraylist = new ArrayList<> creates type ArrayList of type object

#! to run code

Optional added in Java8 and enhanced in later JDKs (ifPresentOrElse, or, isEmpty, stream)
or only evaluates if needed unlike ifElse which always runs

Switch statements (preview in 12 so needs enabling) can use switch expressions to group (and does not need a break)
case MONDAY, TUESDAY -> 6;
case WEDNESDAY -> 6;
will add the type (ie case for int values) and pattern-matching

Text blocks preview features in Java13

Oracle Java and OpenJDK no difference in implementation from Java11

Java Language Futures: 2019 Edition [DEV5937]

Aim to stay relevant
The prime directive is Compatibility. Java does not want to move fast and break things. So things can take time. First, do no harm, and if in doubt do nothing.
Java has still not done.
Quickly covered new 6 monthly release cadence – Java13 live today.
Preview features explicitly have to be enabled so less likely to accidentally creep into code.
Project Amber – small features for developer productivity (var in 10, switch in 12, Text Blocks in 13)
Text Blocks looked at 15 other languages and all do in a different way, so Java does it.
Records are a new class type which will make it easier to create small data classes and not needs lots of boilerplate.
Sealed types coming soon. Allows you to limit (optional permits keyword). ie shape is circle or Rectangle
Use case includes Multiple Return, Stream joins, Tree Nodes, Messages, etc
Pattern matching coming in phases.
if(obj instanceof Integer intValue){
// use intValue inside if
Patterns can be used as case label in switch replacing complex if/else statements with casting
Records and pattern matching work very well together.

12.30 CompletableFuture: The Promises of Java [DEV3884] 301

Good for asynchronous events, unlike streams.
Solved in JavaScript with callbacks and fixed with promises
Java has future but blocking.
Completable Futures are promised in Java
In non-blocking, if promise did, runs on main, otherwise on the thread
.complete() allows for completion
.exceptionally() allows error handling in CompletableFuture
.completeExceptionally() will allow failure to be triggered which is handled in defined error handling code in exceptionally()
In life and programming, never do anything without a timeout.
thenCombine and thenCompose allow using of multiple async together
can use thenApply if the second calc needs first value

Code examples can be downloaded.

Java on the GPU: Unlock Massive Parallel Performance [DEV2786]

Intro to GPU – specialized processor for graphics ops. GPU first appeared 1999
GPGPU – use GPU for generic processing
Lots of processing power and lots of cores
Started with shaders with c-like code
Low level so abstractions added – OPenGL, DirectX
Java had support for OpenGL until around 2008 and forgotten except for GOGL project. Used in Minecraft
2005 onwards people started to look at GPU for general processing
Stanford University produced BrookGPU with GPGPU with own subset of ANSI C.
OPenCL provides an abstract model which works with CPUs and GPUs. Abstracts to host/device
Library to access in Java – jogl
IBM patched their JVM for GPU

Hangs, Slowdowns, Starvation—Oh My! A Deep Dive into the Life of a Java Thread [DEV4356]

Day job fixing hotspot bugs.
Original monitor caused locking issues
java.util.concurrent tried to reduce lock issues but new issues
Pre-Hotspot used green threads. Now uses hardware threads
Java threads – run byte code, stop during STW, Always show in dumps, Many aliases – Execution/Mutator thread
Other threads – Runs non-Java, runs in STW, may not show.
Primordial Threads no longer used for running Java thread.
Safepoints are where we stop the thread
A thread dump is at a safepoint. Almost a snapshot.

View PDF files in a web application →

Parse PDF files as HTML →

Display PDF Forms in a web browser →

View PDF Documents in Java Applications →

Rasterize PDF Documents to image →

Read/Write images (including HEIC, JPG and WEBP) →

Convert Image files to PDF Documents →

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2022. All rights reserved.