Skip to content

Commit

Permalink
Upgrade to JDK 11
Browse files Browse the repository at this point in the history
We currently advertise that we support "JDK 8". However, the public
updates of Java SE 8 for personal users will end soon [1].

JDK 11 is the next Long-Term-Support (LTS) release after JDK 8 [1].
It is better for us to keep updated with the latest release of JDK.

Let's update our target JDK to version 11, with the following steps:

  * We use openjfx-monocle version jdk-11+26 since that is the latest
      version of openjfx-monocle that supports JDK 11 [2].

  * We bump the target and source compatibility of Gradle to JDK11.

  * We update Travis and AppVoyer configs to use JDK11 as runtime
      environment.

  * We remove the add-on in Travis config because it is redundant for
      JDK 11 [3].

  * We make it clear in the User Guide / Developer Guide that we only
      support JDK 11 (not JDK 8, 9, 10).

[1]  https://www.oracle.com/technetwork/java/java-se-support-roadmap.html
[2]  https://github.com/TestFX/Monocle
[3]  https://www.deps.co/guides/travis-ci-latest-java/ (+6 squashed commit)

Squashed commit:

[b47edc6] build.gradle: remove 'prism.order' property for headless task.

For headless test task, 'prism.order' property is used to choose the
graph renderer to use. Currently, we specify this property to be 'sw'.

However, this property seems to trigger some unknown bug with
JDK11. This property will cause Java Runtime Error for Windows OS
including AppVoyer:

    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd95b64879, pid=1476, tid=2640
    #
    # JRE version: OpenJDK Runtime Environment (11.0.1+13) (build 11.0.1+13)
    # Java VM: OpenJDK 64-Bit Server VM (11.0.1+13, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
    # Problematic frame:
    # C  [javafx_font.dll+0x4879]

It is more like a JDK 11 bug with 'sw' renderer. Meanwhile, it is not so
necessary to set this property. It is acceptable to use
platform-specified graph renderer to do the test. Let’s remove this
property to solve the problem.

[c8d0e8c] build.gradle: add javafx runtime dependency for other platforms

We have added the platform specific javafx runtime dependency, so the
addressbook is able to run locally.

However, the jar file generated on one OS cannot run on other OS. The
reason is that, java SE cannot initialize the graph render correctly
without corresponding javafx dependency for the other OS.

Let’s add the javafx runtime dependency for all platforms (MacOS,
Window, Linux) so the jar file generated on one OS is able to run in
other OS [1].

The order of dependency is important because it effects the way Gradle
group dependency tree.

[1]https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing/52654791#52654791

[9f7b7be] change the entry point of addressbook

After we add the javafx runtime dependency, addressbook is still unable
to run in a jdk11 environment. It gives an error of below:

    Error: JavaFX runtime components are missing, and are required to run this application

This error comes from sun.launcher.LauncherHelper in the java.base
module. The reason for this is that the Main app extends Application
and has a main method. If that is the case, the LauncherHelper will check
for the javafx.graphics module to be present as a named module. If that
module is not present, the launch is aborted. Hence, having the JavaFX
libraries as jars on the classpath is not allowed in this case. [1]

This is more like a JDK 11 problem which cannot be solved elegantly.
One simple workaround is to have a separate main class that doesn't
extend Application. Hence it doesn't do the check on javafx.graphics
module, and when the required jars are on the classpath, it works fine.

Let’s add another main class to be the new entry point of addressbook
to solve this problem.

[1] http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-June/021977.html

[3cb5cbb] build.gradle: add javafx runtime dependency

JavaFX is not distributed with Oracle JDK any more from JDK11 onwards [1].
Our code uses javafx as our client platform. So it is unable to be compiled
in JDK11 anymore.

As we are moving to JDK11, let’s add javafx runtime dependency to gradle.

Meanwhile, the dependency provided are platform specific. Let’s use the
SystemUtils api provided by Apache [2] to specify the version of javafx
dependency.

[1]https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-roadmap-updates
[2]http://commons.apache.org/proper/commons-lang/javadocs/api-release/index.html

[18d0cab] disable TLS v1.3 protocol

We use Gradle coverall plugin to send the data generated by coverage
plugin to coverall.io, so our user can view the coverage report online.

However, the TLSv1.3 protocol used by JDK 11 is not supported by the
coverall.io, actually it gives the error bellow:

javax.net.ssl.SSLProtocolException: Connection reset by peer (Write failed)

Let’s disable TLSv1.3 protocol by restricting the scope of protocols in
gradle.properties.[1]

[1]kt3k/coveralls-gradle-plugin#85

[f0ded52] build.gradle: fix checkstyle plugin failure

The `checkstyle` plugin of Gradle fails in JDK11 and gives the error
below:

    Unable to create Root Module: config ...

The main reason is that, in JDK11, the `user.dir` cannot be reset by
Gradle [1]. So, checkstyle plugin is unable to locate the suppressions
file correctly.

Let's add ` config_loc` variable suggested by Gradle to solve the
problem [1].

[1] gradle/gradle#8286
  • Loading branch information
fzdy1914 committed Mar 18, 2019
1 parent 7c2e953 commit d47a1b7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 22 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java
matrix:
include:
- jdk: oraclejdk8
- jdk: oraclejdk11

script: >-
./config/travis/run-checks.sh &&
Expand All @@ -14,11 +14,6 @@ deploy:
on:
branch: master

addons:
apt:
packages:
- oracle-java8-installer

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_script:
- gradlew.bat --no-daemon headless allTests

environment:
JAVA_HOME: C:\Program Files\Java\jdk1.8.0 # Use 64-bit Java
JAVA_HOME: C:\Program Files\Java\jdk11 # Use 64-bit Java

# Files/folders to preserve between builds to speed them up
cache:
Expand Down
41 changes: 36 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// For more details take a look at the Java Quickstart chapter in the Gradle
// user guide available at http://gradle.org/docs/5.2.1/userguide/tutorial_java_projects.html

import org.apache.commons.lang.SystemUtils
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
Expand All @@ -15,10 +16,10 @@ plugins {
}

// Specifies the entry point of the application
mainClassName = 'seedu.address.MainApp'
mainClassName = 'seedu.address.Main'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
mavenCentral()
Expand All @@ -41,10 +42,41 @@ test {
useJUnitPlatform()
}

def platform
def firstOtherPlatform
def secondOtherPlatform
if (SystemUtils.IS_OS_WINDOWS) {
platform = 'win'
firstOtherPlatform = 'mac'
secondOtherPlatform = 'linux'
} else if (SystemUtils.IS_OS_LINUX) {
platform = 'linux'
firstOtherPlatform = 'mac'
secondOtherPlatform = 'win'
} else if (SystemUtils.IS_OS_MAC) {
platform = 'mac'
firstOtherPlatform = 'win'
secondOtherPlatform = 'linux'
}

dependencies {
String testFxVersion = '4.0.15-alpha'
String jUnitVersion = '5.1.0'
String javafxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-media', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: platform

implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: firstOtherPlatform
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: secondOtherPlatform
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: firstOtherPlatform
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: secondOtherPlatform

implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'

Expand All @@ -54,7 +86,7 @@ dependencies {

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion

testRuntimeOnly group: 'org.testfx', name: 'openjfx-monocle', version: '8u76-b04'
testRuntimeOnly group: 'org.testfx', name: 'openjfx-monocle', version: 'jdk-11+26'
testRuntimeOnly group:'org.junit.vintage', name:'junit-vintage-engine', version: jUnitVersion
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
}
Expand Down Expand Up @@ -152,7 +184,6 @@ task headless {
systemProperties = [
'testfx.robot': 'glass',
'testfx.headless': 'true',
'prism.order': 'sw',
'prism.text': 't2k',
]
}
Expand Down
2 changes: 1 addition & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</module>

<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml"/>
<property name="file" value="${config_loc}/suppressions.xml"/>
</module>


Expand Down
8 changes: 4 additions & 4 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT`

=== Prerequisites

. *JDK `8`* (revision `1.8.0_201` or later)
. *JDK `11`* (revision `11.0.1` or later)
+
[NOTE]
Only JDK 8 is supported. +
This app will not work with later major JDK releases such as JDK 9, 10, 11, etc.
Only JDK 11 is supported. +
This app will not work with earlier major JDK releases such as JDK 8, 9, 10.
+
. *IntelliJ* IDE
+
Expand Down Expand Up @@ -873,7 +873,7 @@ _{More to be added}_
[appendix]
== Non Functional Requirements

. Should work on any <<mainstream-os,mainstream OS>> as long as it has Java `8` (revision `1.8.0_201` or higher) installed.
. Should work on any <<mainstream-os,mainstream OS>> as long as it has Java `11` (revision `11.0.1` or higher) installed.
. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage.
. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.

Expand Down
6 changes: 3 additions & 3 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ AddressBook Level 4 (AB4) is for those who *prefer to use a desktop app for mana

== Quick Start

. Ensure you have Java `8` (revision `1.8.0_201` or later) installed in your Computer.
. Ensure you have Java `11` (revision `11.0.1` or later) installed in your Computer.
+
[NOTE]
Only Java 8 is supported. +
This app will not work with later major Java releases such as Java 9, 10, 11, etc.
Only JDK 11 is supported. +
This app will not work with earlier major JDK releases such as JDK 8, 9, 10.
+
. Download the latest `addressbook.jar` link:{repoURL}/releases[here].
. Copy the file to the folder you want to use as the home folder for your Address Book.
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
org.gradle.parallel=false
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=utf-8
systemProp.jdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package seedu.address;

/**
* The main entry point to the application.
*/
public class Main {
public static void main(String[] args) {
MainApp.initiate(args);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import seedu.address.ui.UiManager;

/**
* The main entry point to the application.
* The class needed to initiate the application.
*/
public class MainApp extends Application {

Expand Down Expand Up @@ -181,7 +181,7 @@ public void stop() {
}
}

public static void main(String[] args) {
public static void initiate(String[] args) {
launch(args);
}
}

0 comments on commit d47a1b7

Please sign in to comment.