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 and pictures from Wednesday JavaOne 2017

4 min read

Here are our notes and pictures from Wednesday at the JavaOne conference. You can find our notes from sunday (Community/NetBeans Day), monday,  tuesday, wednesday and thursday.

8.30 Analyzing HotSpot Crashes [CON2494]

All slides on internet so only 1 screenshot
Unrecoverable error
Worked through core dumo
Jcmd gives useful background data
Lower j interpreted J crashed in compiled code
Walked through out of memory errors
-xx:+crashoutofmemoryerror will give you crash file
Jhsdb useful for analysing core file
Remember to add hotspot module if needed in j9


9.30 Make Your CPU Cores Sweat with Parallel Streams [CON3363]

Reminder on streams
Streams about describing what you want not how to do it
Parallel streams allow you to leverage multi-core easily
enable parallel streams with streams() to parallelstream() or stream().parallel() – position does not matter
Fork/join framework since jdk7
All parallel streams use one common pool (CPUS -1 count). Can be changed with System property
You can create a custom pool for Parallel streams
Spliterator – can be used with streams
Always take into account how well the stream source decomposes – does not always divide evenly
Parallel streams work better where order does not matter
Avoid shared state as will create race conditions. Fixing by making synvhronized makes parallel pointless
Stream is always sequential or parallel

10.45 55 New Features In JDK 9 [CON3835]

1. Major features
Modularity – standard class libraries modularised, Most internal APIs now encapsulated (sun.misc.Unsafe), modular source code
You can totally turn off encapsulation. Big kill switch now has options ( –illegal-access={permit, warn, debug, deny}
jlink for custom runtimes – numbers do not indicate version numbering
FactoryMethods for Collections (.of)
Stream enhancements (dropWhile()/takeWhile(), Improved iterate, Parallel Files.lines() (memory mapped, divided on line break boundary), stream from optional (zero or 1 element)
multi-release jar files (can work with 8 as well)
concurrency updates – reactive streams, asynchronous, Flow (publisher, Subscriber, Processor, Subscription), SubmissionPublisher utility class
CompletableFuture additions – minimalcompletionstage
Enhanced deprecation – forRemoval()
java.awt.Component had deprecation removed on show() and hide()
jdeprscan command to create reports
Milling project coin (single underscore is reserved name now)
Private methods in interfaces
Effectively final variables in try-with-resources
Allow @SafeVarargs on private instance methods
Diamond operator with anonymous classes
Unicode 7/8 (Lower case cherokee, emojis)
HTML5 in Javadocs
property files can now use UTF-8 (emojis!)
More random random numbers
3. Inside JVM
Server now uses G1 GC as default
Better String performance – compact strings, share interned strings in CDS, indigo String concatenation
marlin graphics renderer
Smaller features
Improved contented locking, leverage CPU for GHASH and RSA update javaFX with latest GStreamer
Segmented code cache, Unified JVM and GC logging (command line options have changed)
Specialised features
Spin-wait Hints
Variable handles
AOT compilation as experimental option (jaotc command)
Control over JIT compiler
Process API updates
New version String
file structure of JD changed
Smaller features
Searchable API
Annotations pipeline
ParserAPI for Nashorn
General cleanup
Disable SHA-1
Deprecate Applet API
Following Removed
6 deprecated APIs (1st 6)
Ability to select java runtime
JVM Hprof agent
jhat tool
Lots of J8 deprecated GC options

11.45 The Power and Perils of Parallel Streams [CON7321]

Programming concurrency is very hard
Divide and conquer versus parallel array
If you are source of stream use parallelStream(), if receiver use stream().parallel()
You can actually do stream().sequential()
Last one wins so xx.parallel()….sequential() will choose sequential
observing threads – parallel uses main and fork join threads
not all streams have ordering – impacted by order
Order can be imposed by forEachOrdered() – still parallel but imposes an ordering
reduce() collates results into one. Can run in parallel. Value provided for input is identity not start. In that case add in at end
Number of threads based on cores -1
If IO tasks you can have more threads whereas not desirable with lots of computational threads. (polite monks exercising example)
Parallel is not always faster if thread count wrong
When parallel makes no sense

12.45 Designing Functional Programs [CON7318]

imperative + object-orientated => functional + object-orientated
Assignnment-less programming
Purely and hybrid functional languages
Favor immutability
Higher order functions (functions can use functions)
A method is a function
Function composition and lazy evaluation
Key features in FP are function composition and lazy evaluation
Some lang have safe defaults (Haskell) and some unsafe defaults (Java)

1.30 Java Flight Recorder in JDK 9/Java Mission Control 6 [HOL3018]

Great sessions with 73 exercises to work through now or later

4.30pm Troubleshooting Memory Problems in Java Applications [CON3825]

Talk by JVM sustaining engineer (customer issues in JVM)
Java Heap Memory issues
If Full GC not able to claim any space in Old gen of heap, could be config issue
Heap might be too small – see if larger heap fixes it
Heap usage can be tested with tools like jconsole or GC logs
-Xmx correct sizing issue and set to same as -Xms
Diagnostic data to find issues:- CG logs,Heap dumps Heap histograms
Heap dumps can be collected with jcmd, jmap, JCOnsole JMC, HeapDump -XX:+HeapDumpOnOutMemoryError
Same tools and jhsdb can grab heap histograms (objects on the heap)
In GC logs look for number of GCs,etc – GCHisto tool can analyse
You can see if Explicit GCs called and disable with -XX:+DisableExplicitGC
Eclipse MAT can analyse heap dumps.
PermGen/MetaSpace leaks can also occur. As with heap check if big enough first (-XX:PermSize=m -XXMaxPermSize=n
RemGen not in java8 and over
Compressed class space part of MetasPace
CompressedClass pointers will save space if used
jmap and icmd can collect diagnostic data for PermGen/MetaSpace
Finalization can also cause memory errors (finalize() method can delay)
JCOnsole, jmap an Heap Dumps can show finalise errors
CodeCache will not throw memory error but penalty when full. Can be configured to be bigger size
Native memory not directly controlled by JVM but can increase room by reducing threads, PermGen/MetaSpace, etc. Trouble-shoot with Native Memory tracker (NMT) (if JVM) or native tools likes pmap, libumem, valgrind, etc or core file

5.30pm Taking Java EE to the Clouds [CON3419]

Reza started saying myth Java EE does not run on cloud. Actually one of the best supported technologies
Java EE on cloud since EE6.
Easy to run on IaaS , AWS, Azure
Plays well with Docker
Many Java EE PaaS options like OpenShift, Oracle, Cloud, BlueMix, Heroku, Jelastic
Run on base JVM platforms (WildFly Swarm, Payara Micro, etc)
Demo of Cargo Tracker – design patterns on GitHub (10K lines of code so non-trivial)

IaaS (infrastructure as a service) – your datacenter on someone else’s machine. Infrastructure as a service (ie AWS, Azure). Vert flexible and low cost but high maintenance. Closest to premise. Nice demo with all code on GitHub
All providers start with a free tier level.

CaaS – Container as a Service.
Lots of providers now support Docker and JavaEE excellent fix for Docker. Only deploy changes, not whole Docker image. Every Java platform has prebuilt Docker image. Demo on EC2 Container service.

PaaS (platform as a service)
Less config but less flexible and more expensive. Higher risk of lockin and may require changes to application. Demo on Elastic.

Small number of PaaS platforms support TomCat or Jetty and JVM.

7.30pm Concert!

Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java

Are you a Developer working with PDF files?

Learn more about PDF file format
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.

Dawscon 2020 Software Conference in Pictures

The latest Dawscon software conference took place today at Dawson College, Montreal. Attendance was free and there were 2 tracks with topics including JavaScript,...
Mark Stephens
17 sec read

DevFest 2019 in Pictures

Mark Stephens
11 sec read

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.