Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Allow running tests through Gradle on JDK 10 #885

Merged
merged 2 commits into from
Jul 4, 2018
Merged

Conversation

pyokagan
Copy link
Contributor

@pyokagan pyokagan commented May 7, 2018

Fixes #884
Fixes #886

Upgrade our Gradle version to 4.8.1 so as to allow JDK 10 installations
to run our tests successfully.

Due to a JavaFX bug, JDK 10 on Windows will fail to run tests in
headless mode. Update our documentation and build.gradle script to warn
devs against using JDK 10 on Windows, and recommend that they use JDK 9
instead.

@pyokagan pyokagan force-pushed the jdk10 branch 3 times, most recently from 51514a9 to 685e45f Compare May 7, 2018 16:44
@CanIHasReview-bot
Copy link

v1

@pyokagan submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/885/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@yamgent
Copy link
Member

yamgent commented May 8, 2018

Running allTests seems OK now, however, running allTests with headless still causes an error. Reproducible on your side?

PS C:\Users\Tan Wang Leng\Documents\GitHub\yamgent\addressbook-level4> ./gradlew headless allTests

> Task :headless
Setting headless mode properties.

> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.testfx.toolkit.impl.ApplicationLauncherImpl (file:/C:/Users/Tan%20Wang%20Leng/.gradle/caches/modules-2/files-2.1/org.testfx/testfx-core/4.0.12-alpha/55d68835a7f5c0f3b5630a2a542e0880f2548e7f/testfx-core-4.0.12-alpha.jar) to field com.sun.glass.ui.PlatformFactory.instance
WARNING: Please consider reporting this to the maintainers of org.testfx.toolkit.impl.ApplicationLauncherImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8eb034e80, pid=108, tid=13276
#
# JRE version: Java(TM) SE Runtime Environment (10.0.1+10) (build 10.0.1+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.1+10, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [javafx_font.dll+0x4e80]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Tan Wang Leng\Documents\GitHub\yamgent\addressbook-level4\hs_err_pid108.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Unexpected exception thrown.
org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:2178'.
        at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:134)
        at org.gradle.internal.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:325)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
        at java.base/sun.nio.ch.SocketDispatcher.write0(Native Method)
        at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
        at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:115)
        at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:58)
        at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:50)
        at java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:473)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeWithNonBlockingRetry(SocketConnection.java:272)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeBufferToChannel(SocketConnection.java:260)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.flush(SocketConnection.java:254)
        at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:132)
        ... 7 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 10' finished with non-zero exit value 1
  This problem might be caused by incorrect test process configuration.
  Please refer to the test execution section in the user guide at https://docs.gradle.org/4.6/userguide/java_plugin.html#sec:test_execution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
9 actionable tasks: 2 executed, 7 up-to-date

@pyokagan
Copy link
Contributor Author

pyokagan commented May 8, 2018

@yamgent

Running allTests seems OK now, however, running allTests with headless still causes an error. Reproducible on your side?

Nope (on Linux), otherwise I'd have known beforehand since I tested with gradlew headless allTest myself :S

# C  [javafx_font.dll+0x4e80]

This suggests that this is a separate JavaFX-related problem.

@yamgent
Copy link
Member

yamgent commented May 8, 2018

This suggests that this is a separate JavaFX-related problem.

OK. Someone else with Windows will probably have to check whether they are getting the same issue then (to exclude the possibility that I screwed up the Java installation or something).

@yamidark
Copy link
Contributor

yamidark commented May 9, 2018

Got the exact same error on Windows 10:

C:\Stuff\SE-EDU\AddressBookL4>gradlew clean headless allTests

> Task :headless
Setting headless mode properties.

> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.testfx.toolkit.impl.ApplicationLauncherImpl (file:/C:/Users/Jun%20AN/.gradle/caches/modules-2/files-2.1/org.testfx/testfx-core/4.0.12-alpha/55d68835a7f5c0f3b5630a2a542e0880f2548e7f/testfx-core-4.0.12-alpha.jar) to field com.sun.glass.ui.PlatformFactory.instance
WARNING: Please consider reporting this to the maintainers of org.testfx.toolkit.impl.ApplicationLauncherImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffbb1be4e80, pid=3720, tid=3736
#
# JRE version: Java(TM) SE Runtime Environment (10.0.1+10) (build 10.0.1+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.1+10, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [javafx_font.dll+0x4e80]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Stuff\SE-EDU\AddressBookL4\hs_err_pid3720.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Unexpected exception thrown.
org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:62716'.
        at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:134)
        at org.gradle.internal.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:325)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
        at java.base/sun.nio.ch.SocketDispatcher.write0(Native Method)
        at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
        at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:115)
        at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:58)
        at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:50)
        at java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:473)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeWithNonBlockingRetry(SocketConnection.java:272)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeBufferToChannel(SocketConnection.java:260)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.flush(SocketConnection.java:254)
        at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:132)
        ... 7 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 3' finished with non-zero exit value 1
  This problem might be caused by incorrect test process configuration.
  Please refer to the test execution section in the user guide at https://docs.gradle.org/4.6/userguide/java_plugin.html#sec:test_execution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
10 actionable tasks: 9 executed, 1 up-to-date

@pyokagan
Copy link
Contributor Author

pyokagan commented May 9, 2018

@yamgent @yamidark Any idea why this might be happening?

@eugenepeh
Copy link
Member

@yamgent
Copy link
Member

yamgent commented May 10, 2018

@pyokagan The maintainer of TestFX ran into a similar issue: javafxports/openjdk-jfx#66

According to this comment, it seems to be a bug on JavaFX end. Apparently they forgot to call some initialisation methods when using Windows' DirectWrite library (the GUI renderer used by JavaFX on Windows):

We roughly know what the problem is: Some initialization that is done by either the D3D pipeline or Glass (either is sufficient) is needed to allow the DirectWrite calls used by the native font code to work.

The current appveyor build shows traces of the error. Our previous PRs did not have appveyor failing, so migrating to JaCoCo 0.8.1 is partially responsible for the error.

But if it is a JavaFX problem, I don't think we can do much about it, unless we can find some temporary workarounds.

I guess that's the risk we take by upgrading to new technologies too soon, since their stability cannot be taken for granted. :P.

@pyokagan
Copy link
Contributor Author

@yamgent

The maintainer of TestFX ran into a similar issue: javafxports/openjdk-jfx#66 According to this comment, it seems to be a bug on JavaFX end.

Oh, I see. Nice find 👍

The current appveyor build shows traces of the error.

If you meant:

WARNING: Illegal reflective access by org.testfx.toolkit.impl.ApplicationLauncherImpl (file:/C:/Users/appveyor/.gradle/caches/modules-2/files-2.1/org.testfx/testfx-core/4.0.12-alpha/55d68835a7f5c0f3b5630a2a542e0880f2548e7f/testfx-core-4.0.12-alpha.jar) to field com.sun.glass.ui.PlatformFactory.instance
WARNING: Please consider reporting this to the maintainers of org.testfx.toolkit.impl.ApplicationLauncherImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

That's because of TestFX/TestFX#553

Our previous PRs did not have appveyor failing, so migrating to JaCoCo 0.8.1 is partially responsible for the error.

That's because of #881 If @damithc restarts the build enough times, it should pass. Unfortunately it's quite hard to ensure PRs pass AppVeyor because if it stalls, I'll need to wait 1 hour for it to time out.

@pyokagan
Copy link
Contributor Author

I'll update the developer guide to strongly recommend Windows users to use JDK 9.

@pyokagan pyokagan removed the request for review from damithc May 10, 2018 13:46
@eugenepeh
Copy link
Member

https://docs.gradle.org/current/release-notes.html

Btw... it seems that the wrapper is still using 4.6. Would upgrading to 4.7 helps?

@eugenepeh
Copy link
Member

https://docs.gradle.org/current/release-notes.html

Btw... it seems that the wrapper is still using 4.6. Would upgrading to 4.7 helps?

nvm tried it on my machine... doesn't work

@pyokagan pyokagan force-pushed the jdk10 branch 2 times, most recently from 1eaee17 to e8668d8 Compare June 30, 2018 13:47
@CanIHasReview-bot
Copy link

v2

@pyokagan submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/885/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if a student on Windows have both JDK 9 and JDK10, should we advise them to:

  • modify JAVA_HOME,
  • uninstall JDK10,
  • or possibility even better options?

I think this will be asked a lot by students, so we may need to jot this down somewhere.

@pyokagan
Copy link
Contributor Author

pyokagan commented Jul 2, 2018

@yamgent

I think this will be asked a lot by students, so we may need to jot this down somewhere.

Yeah, someone else will need to do this. I'm just volunteering in my free time now.

@pyokagan
Copy link
Contributor Author

pyokagan commented Jul 2, 2018

build.gradle: need to change all references of gradle 4.6 to 4.8.1

pyokagan added 2 commits July 4, 2018 01:13
With JDK 10, `./gradlew allTest` fails to run tests, instead spewing out
the following errors on the console:

    Exception in thread "main" java.lang.reflect.InvocationTargetException
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:564)
            at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:510)
    FATAL ERROR in native method: processing of -javaagent failed
            at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:522)
    Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
            at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:139)
            at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:100)
            at org.jacoco.agent.rt.internal_290345e.PreMain.createRuntime(PreMain.java:55)
            at org.jacoco.agent.rt.internal_290345e.PreMain.premain(PreMain.java:47)
            ... 6 more
    Caused by: java.lang.NoSuchFieldException: $jacocoAccess
            at java.base/java.lang.Class.getField(Class.java:1958)
            at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:137)
            ... 9 more

... and so forth

According to a PR[1] on the JaCoCo's issue tracker, this occurs because
"Classes of JDK 10 EA b35 use a new classfile version number and so
JaCoCo Agent 0.7.9 as well as agent from current build of master branch
fail to start". This has been fixed as of JaCoCo 0.8.1, which also
happens to be the latest release.

We do not explicitly specify the version JaCoCo to use in our
build.gradle file, and so the `jacoco` gradle plugin just uses its
default, which happens to be 0.8.0[2] on Gradle 4.6 (the version we are
using). This version of JaCoCo still has this bug, and so we get these
errors.

Fix this by upgrading to the latest version of Gradle (4.8.1). Since
Gradle 4.7[3] the default JaCoCo plugin has been upgraded to version
0.8.1, and so upgrading to the latest version of Gradle will fix this
problem and allow us to run tests on JDK 10.

The Gradle wrapper upgrade was performed by running the command:

    ./gradlew wrapper --gradle-version 4.8.1

and then converting the line endings of gradlew.bat to unix to satisfy
our travis line ending checks.

Also, update any references to the Gradle version we are using in the
code base to 4.8.1.

[1] jacoco/jacoco#629
[2] gradle/gradle@8a09484
[3] https://docs.gradle.org/4.7/release-notes.html#default-jacoco-version-upgraded-to-0.8.1
Due to a JavaFX bug[1], JDK 10 on Windows will fail to run tests in
headless mode.

As such, let's warn developers against using JDK 10 on Windows in our
documentation, and recommend that they use JDK 9 instead.

Some developers who have both JDK 9 and JDK 10 installed on their
systems may have trouble coaxing Gradle to use JDK 10. As such, to make
it easier to troubleshoot the setup of such developers, let's teach
build.gradle to print a warning to console if it detects that it is
running with JDK 10 on Windows.

[1] javafxports/openjdk-jfx#66
@CanIHasReview-bot
Copy link

v3

@pyokagan submitted v3 for review.

(📚 Archive) (📈 Interdiff between v2 and v3)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/885/3/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@pyokagan pyokagan changed the title Cannot run tests through gradle on JDK 10 Allow running tests through Gradle on JDK 10 Jul 4, 2018
@pyokagan pyokagan merged commit 686ec9a into se-edu:master Jul 4, 2018
@pyokagan pyokagan deleted the jdk10 branch December 4, 2018 18:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants