mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
Update Java Version checking.
This commit is contained in:
parent
4db2447e0b
commit
804f8dc17b
@ -42,6 +42,7 @@ fun checkMinimumPlatformVersion(minimumPlatformVersion: Int, requiredMinPlatform
|
||||
}
|
||||
}
|
||||
|
||||
// JDK11: revisit (JDK 9+ uses different numbering scheme: see https://docs.oracle.com/javase/9/docs/api/java/lang/Runtime.Version.html)
|
||||
@Throws(NumberFormatException::class)
|
||||
fun getJavaUpdateVersion(javaVersion: String): Long = javaVersion.substringAfter("_").substringBefore("-").toLong()
|
||||
|
||||
|
@ -17,7 +17,6 @@ import net.corda.core.internal.concurrent.openFuture
|
||||
import net.corda.core.internal.concurrent.thenMatch
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.internal.errors.AddressBindingException
|
||||
import net.corda.core.internal.getJavaUpdateVersion
|
||||
import net.corda.core.internal.notary.NotaryService
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.messaging.RPCOps
|
||||
@ -155,14 +154,8 @@ open class Node(configuration: NodeConfiguration,
|
||||
}
|
||||
|
||||
private fun hasMinimumJavaVersion(): Boolean {
|
||||
// when the ext.java8_minUpdateVersion gradle constant changes, so must this check
|
||||
val major = SystemUtils.JAVA_VERSION_FLOAT
|
||||
return try {
|
||||
val update = getJavaUpdateVersion(SystemUtils.JAVA_VERSION) // To filter out cases like 1.8.0_202-ea
|
||||
major == 1.8F && update >= 171
|
||||
} catch (e: NumberFormatException) { // custom JDKs may not have the update version (e.g. 1.8.0-adoptopenjdk)
|
||||
false
|
||||
}
|
||||
// JDK 11: review naming convention and checking of 'minUpdateVersion' and 'distributionType` (OpenJDK, Oracle, Zulu, AdoptOpenJDK, Cornetto)
|
||||
return Runtime.version().feature() >= 11
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import net.corda.testing.internal.createNodeInfoAndSigned
|
||||
import net.corda.testing.internal.rigorousMock
|
||||
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
@ -143,6 +144,14 @@ class NodeTest {
|
||||
}
|
||||
}
|
||||
|
||||
// JDK 11 check
|
||||
@Test
|
||||
fun `test getJavaRuntimeVersion`() {
|
||||
assertThat(Runtime.version().feature()).isEqualTo(11)
|
||||
}
|
||||
|
||||
// JDK11: revisit (JDK 9+ uses different numbering scheme: see https://docs.oracle.com/javase/9/docs/api/java/lang/Runtime.Version.html)
|
||||
@Ignore
|
||||
@Test
|
||||
fun `test getJavaUpdateVersion`() {
|
||||
assertThat(getJavaUpdateVersion("1.8.0_202-ea")).isEqualTo(202)
|
||||
|
Loading…
x
Reference in New Issue
Block a user