From e34f33785f118caed49210f08f2b2b8c94e7aad2 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Wed, 28 Dec 2016 15:07:18 +0000 Subject: [PATCH] Prevent the node from starting if running on a version of Java with the empty Path bug (#83) --- node/src/main/kotlin/net/corda/node/Main.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/node/src/main/kotlin/net/corda/node/Main.kt b/node/src/main/kotlin/net/corda/node/Main.kt index 1d66216ac1..f5a8fe15dc 100644 --- a/node/src/main/kotlin/net/corda/node/Main.kt +++ b/node/src/main/kotlin/net/corda/node/Main.kt @@ -34,6 +34,8 @@ fun printBasicNodeInfo(description: String, info: String? = null) { } fun main(args: Array) { + checkJavaVersion() + val startTime = System.currentTimeMillis() val parser = OptionParser() @@ -115,9 +117,24 @@ fun main(args: Array) { exitProcess(0) } +private fun checkJavaVersion() { + // Check we're not running a version of Java with a known bug: https://github.com/corda/corda/issues/83 + try { + Paths.get("").normalize() + } catch (e: ArrayIndexOutOfBoundsException) { + println(""" + You are using a version of Java that is not supported (${System.getProperty("java.version")}). Please upgrade to the latest version. + Corda will now exit...""") + exitProcess(1) + } +} + private fun printPluginsAndServices(node: Node) { node.configuration.extraAdvertisedServiceIds.let { if (it.isNotEmpty()) printBasicNodeInfo("Providing network services", it) } - val plugins = node.pluginRegistries.map { it.javaClass.name }.filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") }.map { it.substringBefore('$') } + val plugins = node.pluginRegistries + .map { it.javaClass.name } + .filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") } + .map { it.substringBefore('$') } if (plugins.isNotEmpty()) printBasicNodeInfo("Loaded plugins", plugins.joinToString()) }