Add JavaVersion.JAVA_19, JavaVersion.JAVA_20 and JavaVersion.JAVA_21

This commit is contained in:
Emmanuel Bourg 2023-07-05 09:42:40 +02:00
parent 71340db86f
commit 471e8da597
3 changed files with 37 additions and 1 deletions

View File

@ -173,6 +173,9 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Processor.isAarch64().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Update ArchUtils.getProcessor(String) for "aarch64".</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add JavaVersion.JAVA_18.</action>
<action type="add" dev="ebourg" due-to="Emmanuel Bourg">Add JavaVersion.JAVA_19.</action>
<action type="add" dev="ebourg" due-to="Emmanuel Bourg">Add JavaVersion.JAVA_20.</action>
<action type="add" dev="ebourg" due-to="Emmanuel Bourg">Add JavaVersion.JAVA_21.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TimeZones.toTimeZone(TimeZone).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add FutureTasks.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Memoizer(Function) and Memoizer(Function, boolean).</action>

View File

@ -150,6 +150,27 @@ public enum JavaVersion {
*/
JAVA_18(18.0f, "18"),
/**
* Java 19.
*
* @since 3.13.0
*/
JAVA_19(19.0f, "19"),
/**
* Java 20.
*
* @since 3.13.0
*/
JAVA_20(20, "20"),
/**
* Java 21.
*
* @since 3.13.0
*/
JAVA_21(21, "21"),
/**
* The most recent java version. Mainly introduced to avoid to break when a new version of Java is used.
*/
@ -269,6 +290,12 @@ public enum JavaVersion {
return JAVA_17;
case "18":
return JAVA_18;
case "19":
return JAVA_19;
case "20":
return JAVA_20;
case "21":
return JAVA_21;
default:
final float v = toFloatVersion(versionStr);
if ((v - 1.) < 1.) { // then we need to check decimals > .9

View File

@ -28,6 +28,9 @@ import static org.apache.commons.lang3.JavaVersion.JAVA_15;
import static org.apache.commons.lang3.JavaVersion.JAVA_16;
import static org.apache.commons.lang3.JavaVersion.JAVA_17;
import static org.apache.commons.lang3.JavaVersion.JAVA_18;
import static org.apache.commons.lang3.JavaVersion.JAVA_19;
import static org.apache.commons.lang3.JavaVersion.JAVA_20;
import static org.apache.commons.lang3.JavaVersion.JAVA_21;
import static org.apache.commons.lang3.JavaVersion.JAVA_1_1;
import static org.apache.commons.lang3.JavaVersion.JAVA_1_2;
import static org.apache.commons.lang3.JavaVersion.JAVA_1_3;
@ -72,10 +75,13 @@ public class JavaVersionTest extends AbstractLangTest {
assertEquals(JAVA_16, get("16"), "16 failed");
assertEquals(JAVA_17, get("17"), "17 failed");
assertEquals(JAVA_18, get("18"), "18 failed");
assertEquals(JAVA_19, get("19"), "19 failed");
assertEquals(JAVA_20, get("20"), "20 failed");
assertEquals(JAVA_21, get("21"), "21 failed");
assertEquals(JAVA_RECENT, get("1.10"), "1.10 failed");
// assertNull("2.10 unexpectedly worked", get("2.10"));
assertEquals(get("1.5"), getJavaVersion("1.5"), "Wrapper method failed");
assertEquals(JAVA_RECENT, get("19"), "Unhandled"); // LANG-1384
assertEquals(JAVA_RECENT, get("22"), "Unhandled"); // LANG-1384
}
@Test