Skip to content

Commit

Permalink
Upgrade project to run on Java 9
Browse files Browse the repository at this point in the history
The project currently runs on Java 8.

Since AddressBookL4 is already running on Java 9, this project should
be upgraded to run on Java 9 as well for consistency.

Let's upgrade the project to run on Java 9 and update the
documentation accordingly.

Travis currently builds the project using JDK 8. Since we are now
running on Java 9, let's update it to build the project using JDK 9.

Java 9 introduces a module system. By default, the set of root modules
for unnamed modules is based on the java.se module instead of the
java.se.ee modules. Thus, APIs in modules from the java.se.ee module,
such as java.xml.bind, are not accessible by default[1]. As our project
is still an unnamed module which depends on the java.xml.bind module,
it is no longer compilable. To resolve this, let's update build.gradle
to import the dependencies for java.xml.bind.

UtilsTest uses the Integer(int) constructor for its equality test,
which is deprecated from Java 9[2]. Since use of deprecated APIs is
considered bad practice, let's replace this with Integer.valueOf(int).

[1]: http://openjdk.java.net/jeps/261
[2]: https://docs.oracle.com/javase/9/docs/api/java/lang/Integer.html#Integer-int-
  • Loading branch information
yamidark committed Sep 1, 2018
1 parent a1971a5 commit 68d58b2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java
matrix:
include:
- jdk: oraclejdk8
- jdk: oraclejdk9

script: >-
./gradlew test asciidoctor
Expand All @@ -16,4 +16,4 @@ deploy:
addons:
apt:
packages:
- oracle-java8-installer
- oracle-java9-installer
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ plugins {
id 'org.asciidoctor.convert' version '1.5.6'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9

repositories {
mavenCentral()
Expand All @@ -33,6 +33,11 @@ sourceSets {
}

dependencies {
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.8'
implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
implementation group: 'javax.activation', name: 'activation', version: '1.1.1'

testImplementation group: 'junit', name: 'junit', version: '4.12'
}

Expand Down
8 changes: 4 additions & 4 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

=== Prerequisites

* JDK 8 or later
* JDK 9 or later
* IntelliJ IDE

=== Importing the project into IntelliJ

. Open IntelliJ (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project dialog first)
. Set up the correct JDK version
.. Click `Configure` > `Project Defaults` > `Project Structure`
.. If JDK 8 is listed in the drop down, select it. If it is not, click `New...` and select the directory where you installed JDK 8.
.. Click `OK`.
.. If JDK 9 is listed in the drop down, select it. If it is not, click `New...` and select the directory where you installed JDK 9
.. Click `OK`
. Click `Import Project`
. Locate the `build.gradle` file and select it. Click `OK`
. Click `Open as Project`
Expand Down Expand Up @@ -80,7 +80,7 @@ Use case resumes at step 2.
[appendix]
== Non Functional Requirements

. Should work on any <<mainstream-os, mainstream OS>> as long as it has Java 8 or higher installed.
. Should work on any <<mainstream-os, mainstream OS>> as long as it has Java 9 or higher installed.
. Should be able to hold up to 1000 persons.
. Should come with automated unit tests and open source code.
. Should favor DOS style commands over Unix-style commands.
Expand Down
4 changes: 2 additions & 2 deletions test/java/seedu/addressbook/common/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void elementsAreUnique() throws Exception {
assertNotUnique("abc", "abc");
assertNotUnique("abc", "", "abc", "ABC");
assertNotUnique("", "abc", "a", "abc");
assertNotUnique(1, new Integer(1));
assertNotUnique(null, 1, new Integer(1));
assertNotUnique(1, Integer.valueOf(1));
assertNotUnique(null, 1, Integer.valueOf(1));
assertNotUnique(null, null);
assertNotUnique(null, "a", "b", null);
}
Expand Down

0 comments on commit 68d58b2

Please sign in to comment.