Thursday, 31 August 2017

Method Overloading in Java

package com.mrbear;

/**
 * Hello world!
 *
 */

public class App 
{
    public String getHim(String name) 
    {
        return name;
    }

    public String getHim(Object object) 
    {
        return "Object";
    }

    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        App app = new App();
        System.out.println( app.getHim("Brian Goetz"));
        System.out.println( app.getHim((Object) "James Gosling"));
        Object object = "Joshua Bloch";
        System.out.println( app.getHim(object));
    }
}
What does the program above print to its screen?

References

Oracle The Java™ Tutorials - Defining Methods
https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

Google Takeout

The wife asked how to download all the photos in Google Photos at once, to store on her computer for easy viewing and backups and all that stuff.

It seems there's a Google producttm for that.

Google Takeout1 2 made by an engineering team at Google with a funny name3.

References

[1] Googel Product Forums
https://productforums.google.com/forum/#!topic/photos/sLseLCfw6Pw
[2] Wikipedia - Google Takeout
https://en.wikipedia.org/wiki/Google_Takeout
[3] Wikipedia - Google Data Liberation Front
https://en.wikipedia.org/wiki/Google_Data_Liberation_Front

Tuesday, 22 August 2017

Opening Up Java EE

DZone mentioned1 that David Delabassee said on The Aquarium2 that Oracle wishes to move JEE technologies including reference implementations and test compatibility kit to an Open Source Foundation.

For more information on how and why, you'll have to check out the original post of David Delabassee.

References

[1] DZone - Oracle Opening Up Java EE
https://dzone.com/articles/oracle-opening-up-java-ee
[2] The Aquarium - Opening Up Java EE
https://blogs.oracle.com/theaquarium/opening-up-java-ee
AgileJava by Ivar Grimstad
http://www.agilejava.eu/2017/08/18/oracle-opening-up-java-ee/

Wednesday, 16 August 2017

NLJUG JCP Event - Java 9

There was a session on Java 9 on Friday, the 11th of August 2017 in Utrecht1. I went. JUG-members across the world would dive into as much detail as possible in a short timeframe during an online session. It was coordinated between the NLJUG2 (Dutch Java Users Group), CJUG3 (Chicago Java Users Group) and VJUG4 (Virtual Java Users Group). The JPoint5 company provided the facilities to follow the session together with other Java people, which was very kind of them.

The session was split up into different parts:
  1. "The Pragmatic Developer’s Guide to Java 9” by Simon Maple (vJUG)
  2. "Java 9 and the impact on Maven projects” by Robert Scholte (Apache Maven)
  3. "Java 9 and Performance increases" by Jonathan Ross (CJUG)
  4. "Java EE 8 update" by Josh Juneau (CJUG)

It was quite convenient that Jonathan Ross happened to be in the neighbourhood, as he's usually found in the neighbourhood of Chicago. Apparently he is also fluent in Dutch. The coincidences were staggering.

I shall recap in short order all the subjects that passed the agenda.
Jigsaw
What the module system in Java brings to the table is the enforcement of boundaries between code. To my mind this is what is necessary to keep us programmers from unheedinly increasing the entropy in the system beyond manageable limits. Classpath will be replaced with Modulepath. We will have to see how that will work out. There is a new module-info.java file for expressing the different modules and the current module uses them.
JShell
The REPL for Java.
ProcessHandler
The "top" or "ps" command for Java.
Optional
It was already introduced in Java 8, but now it has a new stream() function, which isn't eager like map but lazy like streams are supposed to be.
Ahead-Of-Time compilation (AOT)
Causing faster startup times of your java programs, instead of Just-In-Time compilation (JIT). A big requirement for Internet Of Things stuff. (You cannot wait 10 seconds for your doorbell to start up)
CompileControl
Programmer written hints for the compiler
Compact strings
All string objects use UTF-16, which basically fits into two bytes. The vast majority of the strings in applications can be expressed by just one byte using ISO-8859-1/Latin-1. So for most strings, a byte-array makes more sense than a char-array. A special indicator if a string is UTF-8, will be used to decide upon a byte-array or a char-array for storage. The indicator does not increase memory size due to memory alignment.
Indified strings
Concatenating strings using invokeDynamic instead of StringBuilder. This is a major performance boost.
VarHandlers
A way of using primitives without having to wrap them in Objects (for example AtomicInteger). It looks a bit ugly, but it's better than using com.sun.Unsafe.
_ as keyword
Probably a first step for JDK 10 and unused parameters in Lambdas
Private methods in interfaces
Nice.
Try-with-resources small change
You can now use effectively final variables from outside the try block in the try-with-resources statement
Java 5 will no longer be supported by Java 9 compiler
Time to upgrade your ancient programs!
Jonathan Ross knows a lot about performance. I guess he needs it in his job in the Financial Markets.

Robert Scholte talked about Maven being ready for Java 9, even though our applications might not be ready. Java 9 brings some different requirements to the table, because of modules.

One of the big issues that might arise is that those different requirements might make the uptake of Java 9 a great deal slower than was the case for Java 8. Especially if you do not need modules right now.

Josh Juneau talked about JEE 8, the integration Java 8, and the new and upcoming release of the reference implementation Glassfish (with Payara being very close behind).

Other events scheduled.
August 19th, 2017
Virtual Hackday on Java 9 - https://www.meetup.com/virtualJUG/events/240545774/
Monday, October 23, 2017
Brian Goetz at the CJUG - https://www.meetup.com/ChicagoJUG/events/242432217/

References

[1] NLJUG JCP Event together with CJUG and VirtualJUG
https://www.eventbrite.nl/e/tickets-nljug-jcp-event-ism-cjug-en-virtualjug-36387496983
[2] NLJUG
http://www.nljug.org/
[3] CJUG
https://www.meetup.com/ChicagoJUG/
[4] VJUG
https://virtualjug.com/
[5] JPoint
https://www.jpoint.nl/
Java EE Guardians
https://javaee-guardians.io/
Java Public House (Podcasts)
http://www.javapubhouse.com/

Thursday, 10 August 2017

Excluding packages in DNF

In the file /etc/dnf/dnf.conf, you can enter which packages need to be excluded.

I like to exclude java packages, until I am ready for them (as they require a reboot of my application server):
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
exclude=java*
Or for instance:
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
exclude=kernel* java*
When I am ready to install all packages, regardless of excludes, I can use the commandline below.
$ dnf -y update --disableexcludes=all

References

Fedora 24: Exclude package from update
https://www.hiroom2.com/2016/07/07/fedora-24-exclude-package-from-update/
SysTutorials - Making dnf/yum Not Update Certain Packages
https://www.systutorials.com/1661/making-dnf-yum-not-update-certain-packages/

Thursday, 3 August 2017

EclipseLink Logging

In the persistence.xml I have added the following to enable logging for EclipseLink.

Just for my information (so I don't lose the info).

References

EclipseLink 2.5.x. Understanding EclipseLink - Specify Logging
http://www.eclipse.org/eclipselink/documentation/2.5/solutions/tlandgs002.htm#CIHHJIGF
Eclipse - EclipseLink/Examples/JPA/Logging
https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging