diff --git a/src/main/java/org/apache/commons/lang3/ArchUtils.java b/src/main/java/org/apache/commons/lang3/ArchUtils.java
index 4bc325c5e..25a644c4e 100644
--- a/src/main/java/org/apache/commons/lang3/ArchUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArchUtils.java
@@ -96,6 +96,8 @@ public class ArchUtils {
init_PPC_32Bit();
init_PPC_64Bit();
init_Aarch_64Bit();
+ init_RISCV_32Bit();
+ init_RISCV_64Bit();
}
private static void init_Aarch_64Bit() {
@@ -118,6 +120,14 @@ public class ArchUtils {
addProcessors(new Processor(Processor.Arch.BIT_64, Processor.Type.PPC), "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64");
}
+ private static void init_RISCV_32Bit() {
+ addProcessors(new Processor(Processor.Arch.BIT_32, Processor.Type.RISCV), "riscv32");
+ }
+
+ private static void init_RISCV_64Bit() {
+ addProcessors(new Processor(Processor.Arch.BIT_64, Processor.Type.RISCV), "riscv64");
+ }
+
private static void init_X86_32Bit() {
addProcessors(new Processor(Processor.Arch.BIT_32, Processor.Type.X86), "x86", "i386", "i486", "i586", "i686", "pentium");
}
diff --git a/src/main/java/org/apache/commons/lang3/arch/Processor.java b/src/main/java/org/apache/commons/lang3/arch/Processor.java
index 555bf96c4..2fc18cb65 100644
--- a/src/main/java/org/apache/commons/lang3/arch/Processor.java
+++ b/src/main/java/org/apache/commons/lang3/arch/Processor.java
@@ -79,6 +79,7 @@ public class Processor {
*
x86
* ia64
* PPC
+ * RISCV
* Unknown
*
*/
@@ -106,6 +107,13 @@ public class Processor {
*/
PPC("PPC"),
+ /**
+ * RISC-V architecture.
+ *
+ * @since 3.14.0
+ */
+ RISCV("RISC-V"),
+
/**
* Unknown architecture.
*/
@@ -225,6 +233,16 @@ public class Processor {
return Type.X86 == type;
}
+ /**
+ * Tests if {@link Processor} is type of RISC-V.
+ *
+ * @return {@code true}. if {@link Processor} is {@link Type#RISCV}, else {@code false}.
+ * @since 3.14.0
+ */
+ public boolean isRISCV() {
+ return Type.RISCV == type;
+ }
+
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
diff --git a/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
index fb23cfa08..64519e97f 100644
--- a/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
@@ -40,6 +40,8 @@ public class ArchUtilsTest extends AbstractLangTest {
private static final String X86 = "x86";
private static final String X86_64 = "x86_64";
private static final String AARCH_64 = "aarch64";
+ private static final String RISCV_64 = "riscv64";
+ private static final String RISCV_32 = "riscv32";
private void assertEqualsArchNotNull(final Processor.Arch arch, final Processor processor) {
assertNotNull(arch);
@@ -100,6 +102,14 @@ public class ArchUtilsTest extends AbstractLangTest {
processor = ArchUtils.getProcessor(AARCH_64);
assertEqualsTypeNotNull(Processor.Type.AARCH_64, processor);
assertTrue(processor.isAarch64());
+
+ processor = ArchUtils.getProcessor(RISCV_32);
+ assertEqualsTypeNotNull(Processor.Type.RISCV, processor);
+ assertTrue(processor.isRISCV());
+
+ processor = ArchUtils.getProcessor(RISCV_64);
+ assertEqualsTypeNotNull(Processor.Type.RISCV, processor);
+ assertTrue(processor.isRISCV());
}
@Test
@@ -134,6 +144,10 @@ public class ArchUtilsTest extends AbstractLangTest {
assertEqualsArchNotNull(Processor.Arch.BIT_32, processor);
processor.is32Bit();
+ processor = ArchUtils.getProcessor(RISCV_32);
+ assertEqualsArchNotNull(Processor.Arch.BIT_32, processor);
+ assertTrue(processor.is32Bit());
+
processor = ArchUtils.getProcessor(X86_64);
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
assertFalse(processor.is32Bit());
@@ -145,6 +159,10 @@ public class ArchUtilsTest extends AbstractLangTest {
processor = ArchUtils.getProcessor(IA64);
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
assertFalse(processor.is32Bit());
+
+ processor = ArchUtils.getProcessor(RISCV_64);
+ assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
+ assertFalse(processor.is32Bit());
}
@Test
@@ -161,6 +179,10 @@ public class ArchUtilsTest extends AbstractLangTest {
assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
assertTrue(processor.is64Bit());
+ processor = ArchUtils.getProcessor(RISCV_64);
+ assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
+ assertTrue(processor.is64Bit());
+
processor = ArchUtils.getProcessor(X86);
assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
assertFalse(processor.is64Bit());
@@ -173,6 +195,10 @@ public class ArchUtilsTest extends AbstractLangTest {
assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
assertFalse(processor.is64Bit());
+ processor = ArchUtils.getProcessor(RISCV_32);
+ assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
+ assertFalse(processor.is64Bit());
+
processor = ArchUtils.getProcessor(AARCH_64);
assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);