JVM

Amazon Q Code Transform: Automatic migration from JDK 1.8 to JDK 17 – JVM Weekly vol. 158

I invite you to the last edition of this year! I’m already in the holiday mood, so there will be no shortage of such themes.

Article cover

1. Java Advent Calendar talks about Jupyter Notebooks

I am a big fan of Advent Calendars and they have become one of my most anticipated aspects of the pre-Christmas period. I’ve written about Advent of Code before, but there are even more initiatives like that. In the Java world, for example, there is annual Java Advent Calendar series, where a new article on particular interesting aspect of the ecosystem is published every day. I decided to share here my favourite publication from this year edition (at least so far, there is few days left), which is great study of the topic of Jupyter Notebook and its support for JVM languages.

Day 10 of this year’s calendar – JUPYTER NOTEBOOKS AND JAVA?  – talks about the integration of Java (but Kotlin is also mentioned) with Jupyter Notebooks, emphasizing the advantages of this pairing. For those who don’t know, Jupyter Notebooks is an interactive computing platform that enables the creation of documents with live code blocks (which can be manipulated and edited), as well as with the capability to present equations, visualizations or ‘narrative’ text – everything required for all types of research (academic and beyond). Traditionally, Java hasn’t been seen as suitable for the ‘exploratory’ style of Notebook code development due to its compilation process. However, new tools like JBang and enhancements in the OpenJDK itself have made experimenting in Java simpler, making it more effective for use with Notebooks.

This article discusses the various facets of utilizing Java in Jupyter Notebooks. It highlights the benefits of the interactive mode (which allows for real-time execution and customization of code), which is quite a departure from the traditional Java application development approach, more akin what e.g. Clojure developers did with their environment. The piece also explores Java’s potential for data visualization in Jupyter Notebooks, and the convenience of IDE interfaces based on locally hosted web applications. Notably, the establishment of the jupyter-java github organization was also announced. It aims to simplify the use of Java in Jupyter environments and oversee the future prospects of this integration. Its first “artefact” is awesome-jupyter-java, a compilation of links that could be beneficial to anyone interested in the subject.

Generally, this is just one of the gems from this year’s calendar – I recommend everyone checks it out for themselves, as there should be something for everyone among the 21 articles published so far (and you can expect another three till Christmas).

And to feel the Christmas Spirit – the song “Advent Calendar” by one of the most interesting Polish artists of the last decade, Czesław Mozil, known as Czesław Śpiewa. I highly recommend the whole album it comes from, even if you don’t know Polish!
Discover more IT content selected for you
In Vived, you will find articles handpicked by devs. Download the app and read the good stuff!

phone newsletter image

2. Amazon Q AI has launched an automatic migration from JDK 1.8

Before we return to the Christmas theme, let’s discuss one leftover from AWS Re:Invent. Last year’s annual conference by Amazon introduced big announcement form Java Developers perspective – AWS Lambda SnapStart, which minimizes the Cold Start of Lambda functions written in Java. Initially, I believed there weren’t many that significant Java-related updates this year, apart from a version of the AWS SDK for the idiomatic Kotlin. However, I almost missed a piece of news that is quite intriguing, which involves Amazon’s new AI assistant, Amazon Q, announced at the conference.

Amazon Q is an AI Chat assistant that can be used with Visual Studio Code and IntelliJ by those who have a CodeWhisperer Professional licence. A crucial feature of Amazon Q is Code Transformation, which allows for smart mass refactoring and automation of repetitive tasks. Currently, its capabilities are somewhat limited, but the tool can refactor Java applications, converting code from Java 8 or Java 11 to Java 17, the most recent LTS version. The tool is currently in its Preview version, which has some restrictions – only Maven-based projects are supported for now.

We have been blessed with AI’s this season – after all, just last week we had covered similar tool from JetBrains.

The process  is described in the text Upgrade your Java applications with Amazon Q Code Transformation (preview), which provides a comprehensive view of how everything functions – Amazon ensured to offer a user-friendly method (somewhat akin to a standard Code Review) for human approval of changes. This approach surely comfort users who are wary of unnecessary “magic”.

Even though it’s likely that the whole operation will be carried out based on the well known rule:

unless our human nature takes over and we actively attempt to prove the machine incorrect 😉

Who’s taking the plunge and giving it a shot at your location 😃? In projects I’m currently involved, each is “unfortunately” using JDK 17, but I would be thrilled to implement some Proof of Concept with someone.

Discover more IT content selected for you
In Vived, you will find articles handpicked by devs. Download the app and read the good stuff!

phone newsletter image

3. CheerpJ breathes new life into a classic Applet game

Now, let’s conclude with a nostalgic, festive tone.

I suppose I’m at a point in life where during Christmas, there’s a desire to relive childhood feelings – and my childhood memories are heavily intertwined with games. For instance, last year I indulged in my favorite one, Warcraft 3, which is now thankfully accessible on all systems and devices. However, not all titles share this fortune – many original web technologies are challenging to reproduce on modern operating systems due to security measures (the early web days were filled with security bugs) or simply because they were abandoned by their initial developers. I recently faced difficulties launching applications created in Flash, and it appears that old-school enthusiasts of Java applets are also having a tough time today.

Fortunately, Digital Preservation has its advocates and numerous fascinating tales, like the recent story of Dragon Court.

Dragon Court, a game launched approximately in 1997, was built using Java Applet technology. It gained immense popularity at a certain point, largely because of its system that promoted daily logins, thereby creating a strong bond with its user base.

If you’re wondering where mobile game developers get their inspiration from, you have a source. No need to thank anyone.

However, the game became unplayable and was classified as ‘abandonware’ when support for Java applets in browsers was discontinued and the original developer neglected it. Additionally, efforts to resurrect the game by dedicated fans were hindered due to the lack of complete source material. They had to rely on fan memories, which made an accurate reconstruction unfeasible.

History concludes on a positive note. The resurgence of Dragon Court was facilitated by CheerpJ, a Java virtual machine for browsers, allowing the game to work in their modern versions. The initiative, named Dragon Court: Revived, initiated by retrieving the last known binary file of the game from the Internet Archive. A crucial aspect of the project was the decompilation of the original .jar file, which enabled fixing bugs and the addition of new features. The use of CheerpJ simplified the process of developing new patches and enhancements, such as support for touch devices and the storing of user preferences in cookies. However, fan involvement extends beyond the technical aspects – they initiated creation of new content, balance modifications and quality of life improvements, making Dragon Court: Revived a noteworthy homage to its legacy while modernizing it for contemporary players.

If that’s what today’s gamers crave… though I’ll admit I soaked it in for 30 minutes myself, so there is some magic in it 😀

CheerpJ is a fascinating project that I’ve been eager to present you for quite some time. It’s a JVM implementation that enables applications to operate directly within a web browser, eliminating the need for extra plug-ins or software installation. CheerpJ transforms Java byte code into JavaScript, facilitating applications to function in a browser sandbox. This allows these applications to remain in use, even if their original environment no longer exists – as is the case with applets and their associated plug-ins. CheerpJ breathes new life into these applications, and there’s something truly remarkable about that.

And to close the whole thing with a proper buckle – yesterday, in a fit of nostalgia, I bought myself my beloved “Jedi Knight II: Jedi Outcast” for Switch. Sometimes some memories are better not to try to recreate, because you can get a bit disappointed….

Well, we’ll see you already in 2024! I hope you will spend the Christmas-New Year period as you dreamed of it 🎄🥂.

PS: We’ll begin the upcoming year with a summary of 2023. I’ve already initiated work on that piece and I must say – it’s been quite eventful!