diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7d11e6f0b..5464aa124 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,7 +12,6 @@ But first, read this page (including the small print at the end).
+ [Coding Guidelines](#coding-guidelines)
+ [Continuous Integration](#continuous-integration)
+ [Tests and documentation are not optional](#tests-and-documentation-are-not-optional)
- + [Current status](#current-status)
* [Reporting an issue](#reporting-an-issue)
* [AI Tool Use Policy](#ai-tool-use-policy)
* [Legal](#legal)
diff --git a/README.md b/README.md
index 8bea253db..8507778ac 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-
+
A Bytecode Alliance hosted project
diff --git a/cli/src/main/java/run/endive/experimental/cli/Cli.java b/cli/src/main/java/run/endive/experimental/cli/Cli.java
index 0bde54104..fd80b33e9 100644
--- a/cli/src/main/java/run/endive/experimental/cli/Cli.java
+++ b/cli/src/main/java/run/endive/experimental/cli/Cli.java
@@ -80,7 +80,7 @@ public void run() {
var export = instance.export(functionName);
var params = new long[type.params().size()];
for (var i = 0; i < type.params().size(); i++) {
- params[i] = Long.valueOf(arguments[i]);
+ params[i] = arguments[i];
}
var result = export.apply(params);
diff --git a/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java b/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java
index 1c8cb51de..ea3878c3e 100644
--- a/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java
+++ b/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java
@@ -299,7 +299,7 @@ public Map generate() {
"applyWithRefs",
NodeList.nodeList(longArrayExpr, refArrayExpr));
- if (exportType.returns().size() == 0) {
+ if (exportType.returns().isEmpty()) {
exportMethod.setType(void.class);
methodBody.addStatement(applyWithRefsCall);
methodBody.addStatement(new ReturnStmt());
@@ -352,7 +352,7 @@ public Map generate() {
new MethodCallExpr(
exportFieldName, "apply", NodeList.nodeList(handleCallArguments));
- if (exportType.returns().size() == 0) {
+ if (exportType.returns().isEmpty()) {
exportMethod.setType(void.class);
methodBody.addStatement(exportApplyHandle).addStatement(new ReturnStmt());
} else if (exportType.returns().size() > 1) {
@@ -400,7 +400,7 @@ exportApplyHandle, new IntegerLiteralExpr("0")),
});
}
- if (importedModules.size() > 0) {
+ if (!importedModules.isEmpty()) {
var toImportValuesBody = new BlockStmt();
toImportValuesBody.addStatement(
new AssignExpr(
@@ -552,7 +552,7 @@ exportApplyHandle, new IntegerLiteralExpr("0")),
importsCu.addImport("run.endive.runtime.WasmFunctionHandle");
// Set interface method return type
- if (importType.returns().size() == 0) {
+ if (importType.returns().isEmpty()) {
importMethod.setType(void.class);
} else if (importType.returns().size() == 1) {
importMethod.setType(
@@ -564,7 +564,7 @@ exportApplyHandle, new IntegerLiteralExpr("0")),
// Build applyWithRefs body
var refsBody = new BlockStmt();
- if (importType.returns().size() == 0) {
+ if (importType.returns().isEmpty()) {
refsBody.addStatement(importApplyHandle);
refsBody.addStatement(
new ReturnStmt(
@@ -639,7 +639,7 @@ exportApplyHandle, new IntegerLiteralExpr("0")),
// No object refs - use original lambda path
var functionBodyStatement = new BlockStmt();
- if (importType.returns().size() == 0) {
+ if (importType.returns().isEmpty()) {
importMethod.setType(void.class);
functionBodyStatement.addStatement(importApplyHandle);
functionBodyStatement.addStatement(
diff --git a/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java b/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java
index 52db9cf82..c89ddecda 100644
--- a/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java
+++ b/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java
@@ -72,7 +72,8 @@ private void generateAll(Generator generator) throws IOException {
generator.generateMetaWasm(interpretedFunctions);
}
- private String expectedMessageContent = "interpreter fallback mode: WASM function index: 2";
+ private final String expectedMessageContent =
+ "interpreter fallback mode: WASM function index: 2";
@Test
public void testDefaultInterpreterFallback() throws IOException {
diff --git a/compiler/src/main/java/run/endive/compiler/internal/Compiler.java b/compiler/src/main/java/run/endive/compiler/internal/Compiler.java
index 90c6412ac..28bc1f91b 100644
--- a/compiler/src/main/java/run/endive/compiler/internal/Compiler.java
+++ b/compiler/src/main/java/run/endive/compiler/internal/Compiler.java
@@ -487,7 +487,7 @@ private String classNameForFuncGroup(String prefix, int funcId) {
private Consumer emitFunctionGroup(int start, int end, String internalClassName) {
return (classWriter) -> {
for (int i = start; i < end; i++) {
- FunctionBody body = null;
+ FunctionBody body;
try {
int funcId = i;
var type = functionTypes.get(funcId);
diff --git a/compiler/src/main/java/run/endive/compiler/internal/Shaded.java b/compiler/src/main/java/run/endive/compiler/internal/Shaded.java
index b2ea0d05c..d06494de2 100644
--- a/compiler/src/main/java/run/endive/compiler/internal/Shaded.java
+++ b/compiler/src/main/java/run/endive/compiler/internal/Shaded.java
@@ -254,7 +254,7 @@ public static int i32_ge_u(int a, int b) {
var prop = System.getProperty("endive.memCopyWorkaround");
if (prop != null) {
- memCopyWorkaround = Boolean.valueOf(prop);
+ memCopyWorkaround = Boolean.parseBoolean(prop);
} else {
memCopyWorkaround = shouldUseMemWorkaround();
}
diff --git a/compiler/src/test/java/run/endive/compiler/internal/CallTest.java b/compiler/src/test/java/run/endive/compiler/internal/CallTest.java
index 8787ac472..7294564e9 100644
--- a/compiler/src/test/java/run/endive/compiler/internal/CallTest.java
+++ b/compiler/src/test/java/run/endive/compiler/internal/CallTest.java
@@ -24,7 +24,6 @@ public void callLotsOfArgs() throws InterruptedException {
}
@Test
- @SuppressWarnings("deprecation")
public void callLotsOfArgsOnDeprecatedAotMachine() throws InterruptedException {
var module = Parser.parse(CorpusResources.getResource("compiled/lots-of-args.wat.wasm"));
var instance =
diff --git a/fuzz/src/main/java/run/endive/fuzz/TestResult.java b/fuzz/src/main/java/run/endive/fuzz/TestResult.java
index c2d5f50cc..89e1e1439 100644
--- a/fuzz/src/main/java/run/endive/fuzz/TestResult.java
+++ b/fuzz/src/main/java/run/endive/fuzz/TestResult.java
@@ -2,8 +2,8 @@
public class TestResult {
- private String oracleResult;
- private String engineResult;
+ private final String oracleResult;
+ private final String engineResult;
public TestResult(String oracleResult, String engineResult) {
this.oracleResult = oracleResult;
diff --git a/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java b/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java
index 36520565a..dcef30c78 100644
--- a/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java
+++ b/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java
@@ -27,7 +27,7 @@ private static Stream crashFolders() {
.flatMap(
dir -> {
var dirs = dir.listFiles();
- return dirs != null ? Arrays.stream(dirs) : Stream.empty();
+ return dirs != null ? Arrays.stream(dirs) : Stream.empty();
})
.filter(f -> f.isDirectory() && f.getName().startsWith("crash"))
.filter(f -> new File(f, "test.wasm").exists())
diff --git a/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java b/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java
index 81f87b187..7477acd2e 100644
--- a/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java
+++ b/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java
@@ -39,8 +39,8 @@ interface LockWithTimeout {
int lock(Instance instance, int mutexAddr, long expected);
}
- private static MemoryLimits memoryLimits = new MemoryLimits(1, 1, true);
- private static List> memories =
+ private static final MemoryLimits memoryLimits = new MemoryLimits(1, 1, true);
+ private static final List> memories =
List.of(
() -> new ByteArrayMemory(memoryLimits),
() -> new ByteBufferMemory(memoryLimits));
@@ -53,7 +53,7 @@ interface LockWithTimeout {
instBuilder.withMachineFactory(MachineFactoryCompiler::compile),
// build time compiler
(instBuilder) -> instBuilder.withMachineFactory(ThreadsExampleModule::create));
- private static List locks =
+ private static final List locks =
List.of(
ThreadsProposalTest::lockMutexWithTimeout,
ThreadsProposalTest::lock64MutexWithTimeout);
@@ -309,7 +309,7 @@ public void atomicFenceOrder(
() -> {
long a;
do {
- a = (long) fencedReadAndVerify.apply()[0];
+ a = fencedReadAndVerify.apply()[0];
} while (a < minIterations);
});
done.set(true);
diff --git a/runtime-tests/src/test/java/run/endive/testing/TestModule.java b/runtime-tests/src/test/java/run/endive/testing/TestModule.java
index 46473be63..a77a0b071 100644
--- a/runtime-tests/src/test/java/run/endive/testing/TestModule.java
+++ b/runtime-tests/src/test/java/run/endive/testing/TestModule.java
@@ -12,7 +12,7 @@
public class TestModule {
- private WasmModule module;
+ private final WasmModule module;
private static final String HACK_MATCH_ALL_MALFORMED_EXCEPTION_TEXT =
"Matching keywords to get the WebAssembly testsuite to pass: "
diff --git a/runtime/src/main/java/run/endive/runtime/ImportValue.java b/runtime/src/main/java/run/endive/runtime/ImportValue.java
index af6286807..853cd4010 100644
--- a/runtime/src/main/java/run/endive/runtime/ImportValue.java
+++ b/runtime/src/main/java/run/endive/runtime/ImportValue.java
@@ -5,7 +5,7 @@
* It is an address denoting either a function instance, table instance, memory instance,
* or global instances in the shared store.
*
- * See also External Values.
+ * See also External Values.
*
* @see ExportFunction
*/
diff --git a/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java
index 616e210af..a33bebcd1 100644
--- a/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java
+++ b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java
@@ -3922,8 +3922,7 @@ private static void pushExceptionArgs(WasmException exception, MStack stack) {
var tagType = exception.instance().type(tag.tagType().typeIdx());
var params = tagType.params();
int slot = 0;
- for (int i = 0; i < params.size(); i++) {
- var p = params.get(i);
+ for (ValType p : params) {
if (p.isObjectRef()) {
// This position is a ref (even if the value is null)
stack.pushRef(refArgs != null && slot < refArgs.length ? refArgs[slot] : null);
diff --git a/runtime/src/main/java/run/endive/runtime/StackFrame.java b/runtime/src/main/java/run/endive/runtime/StackFrame.java
index 889efe324..aed2a9d4c 100644
--- a/runtime/src/main/java/run/endive/runtime/StackFrame.java
+++ b/runtime/src/main/java/run/endive/runtime/StackFrame.java
@@ -73,8 +73,7 @@ public StackFrame(Instance instance, int funcId, long[] args) {
// initialize codesegment locals.
int j = 0;
- for (var i = 0; i < localTypes.size(); i++) {
- ValType type = localTypes.get(i);
+ for (ValType type : localTypes) {
var idx = j + sizeOf(argsTypes);
if (!type.equals(ValType.V128)) {
if (type.isReference()) {
diff --git a/runtime/src/main/java/run/endive/runtime/Store.java b/runtime/src/main/java/run/endive/runtime/Store.java
index bdc3351e3..bd68e9dce 100644
--- a/runtime/src/main/java/run/endive/runtime/Store.java
+++ b/runtime/src/main/java/run/endive/runtime/Store.java
@@ -98,9 +98,8 @@ public ImportValues toImportValues() {
* All the exported functions, globals, memories, and tables are added to the store
* with the given name.
*
- * For instance, if a module named "myModule" exports a function
+ *
For instance, if a module named "myModule" exports a function
* named "myFunction", the function will be added to the store with the name "myFunction.myModule".
- *
*/
public Store register(String name, Instance instance) {
ExportSection exportSection = instance.module().exportSection();
diff --git a/runtime/src/test/java/run/endive/runtime/MemoryStressTest.java b/runtime/src/test/java/run/endive/runtime/MemoryStressTest.java
index dc78462dd..8e8f45b01 100644
--- a/runtime/src/test/java/run/endive/runtime/MemoryStressTest.java
+++ b/runtime/src/test/java/run/endive/runtime/MemoryStressTest.java
@@ -89,7 +89,7 @@ public void rwLockSurvivesContention(String name, Supplier memorySupplie
final RwLock lock = new RwLock(memorySupplier.get(), 0);
final long deadline = System.currentTimeMillis() + 3_000;
- final List threads = new ArrayList();
+ final List threads = new ArrayList<>();
for (int r = 0; r < 6; r++) {
threads.add(
new Thread(
diff --git a/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java b/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java
index a5f47e602..b38908ab8 100644
--- a/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java
+++ b/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java
@@ -227,7 +227,7 @@ public void shouldSupportMemoryFactoryOverride() {
return new ByteBufferMemory(limits);
})
.build();
- assertEquals(true, memoryCreated.get());
+ assertTrue(memoryCreated.get());
}
@Test
@@ -396,17 +396,17 @@ public void shouldConsumeStackLoopOperations() {
assertEquals(factorial(number), result[0]);
// IIUC: 3 values returning from last CALL + 1 result
- assertTrue(finalStackSize.get() == 4L);
+ assertEquals(4L, finalStackSize.get());
}
@Test
public void shouldEasilyObtainExportedEntities() {
var instance = Instance.builder(loadModule("compiled/exports.wat.wasm")).build();
- assertNotNull(instance.exports().memory("mem").pages());
- assertNotNull(instance.exports().table("tab").size());
- assertNotNull(instance.exports().tag("tag").tagType());
- assertNotNull(instance.exports().global("glob1").getValue());
+ instance.exports().memory("mem").pages();
+ instance.exports().table("tab").size();
+ instance.exports().tag("tag").tagType();
+ instance.exports().global("glob1").getValue();
assertNotNull(instance.exports().function("get-1").apply());
}
@@ -576,6 +576,7 @@ public void timeoutExecution() throws Exception {
ExecutorService service = Executors.newSingleThreadExecutor();
var future = service.submit(() -> function.apply());
assertThrows(TimeoutException.class, () -> future.get(100, TimeUnit.MILLISECONDS));
+ service.shutdown();
}
// Testing tail call edge cases
@@ -858,10 +859,7 @@ public void hostFunctionStackOverflowShouldBeWrapped() {
});
var instance =
Instance.builder(loadModule("compiled/host-function.wat.wasm"))
- .withImportValues(
- ImportValues.builder()
- .addFunction(new HostFunction[] {func})
- .build())
+ .withImportValues(ImportValues.builder().addFunction(func).build())
.build();
var logIt = instance.export("logIt");
var e = assertThrows(WasmEngineException.class, logIt::apply);
diff --git a/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java b/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
index 8e08b7c9f..d39edffe4 100644
--- a/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
+++ b/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
@@ -1376,13 +1376,9 @@ private static byte addSatU(byte a, byte b) {
}
}
- private static long addSatU(short a, Short b) {
+ private static long addSatU(short a, short b) {
int result = Short.toUnsignedInt(a) + Short.toUnsignedInt(b);
- if (result >= 0xFFFF) {
- return 0xFFFF;
- } else {
- return result;
- }
+ return Math.min(result, 0xFFFF);
}
private static byte subSatS(byte a, byte b) {
@@ -3000,7 +2996,7 @@ private static void I8x16_SWIZZLE(MStack stack) {
long resultHigh = 0L;
for (int i = 0; i < 16; i++) {
- long id = 0;
+ long id;
if (i < 8) {
id = (idxLow >> (i * 8)) & 0xFFL;
} else {
diff --git a/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java b/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java
index 4d4b11366..88b79a952 100644
--- a/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java
+++ b/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java
@@ -143,7 +143,7 @@ public CompilationUnit generate(String name, Wast wast, String wasmClasspath) {
"store",
new NameExpr("new Store().addImportValues(Spectest.toImportValues())"));
- String currentWasmFile = null;
+ String currentWasmFile;
for (var cmd : wast.commands()) {
switch (cmd.type()) {
case MODULE:
@@ -428,7 +428,7 @@ private List generateAssert(String varName, Command cmd, String modu
.collect(Collectors.toList())
: List.of();
var adaptedArgs =
- (args == null || args.size() == 0)
+ args.isEmpty()
? ""
: args.stream().collect(Collectors.joining(").add(", ".add(", ")"));
invocationMethod = ".apply(ArgsAdapter.builder()" + adaptedArgs + ".build()" + ")";
@@ -601,11 +601,11 @@ private void generateAssertThrows(
String wasmFile = getWasmFile(cmd, wasmClasspath);
- var assignementStmt = (cmd.text() != null) ? "var exception = " : "";
+ var assignmentStmt = (cmd.text() != null) ? "var exception = " : "";
var assertThrows =
new NameExpr(
- assignementStmt
+ assignmentStmt
+ "assertThrows("
+ exceptionType
+ ".class, () -> "
diff --git a/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java
index 59f61598e..68a685ea9 100644
--- a/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java
+++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java
@@ -134,7 +134,7 @@ public NameExpr toAssertion(String resultVar, String moduleName) {
if (value == null) {
// according to
// https://github.com/WebAssembly/spec/blob/05949f507908aac3ad2a21661b5c39fa013da950/interpreter/script/js.ml#L150
- // ref.func should check that its a function, and ref.extern should check the returned
+ // ref.func should check that it's a function, and ref.extern should check the returned
// reference is not null
switch (type) {
case FUNC_REF:
@@ -285,14 +285,14 @@ public String shortLaneValue(String v) {
public String intLaneValue(String v) {
var longValue = Long.parseLong(v);
- return Integer.toUnsignedString((int) (0xFFFFFFFF & longValue)) + "L";
+ return Integer.toUnsignedString((int) longValue) + "L";
}
/**
* Generate assertion for CallResult from applyWithRefs.
*
- * Object ref types use cr.refResult(i) and compare with Java null/not-null.
- * Numeric types use cr.longResult(i) and compare with expected values.
+ * Object ref types use {@code cr.refResult(i)} and compare with Java null/not-null.
+ * Numeric types use {@code cr.longResult(i)} and compare with expected values.
*/
public NameExpr toRefAssertion(String resultVar, String moduleName) {
if (value == null) {
@@ -392,7 +392,7 @@ public String toArgsValue() {
case EQ_REF:
case I31_REF:
case FUNC_REF:
- if (value[0].toString().equals("null")) {
+ if (value[0].equals("null")) {
return "Value.REF_NULL_VALUE";
}
return value[0];
diff --git a/test-gen-plugin/README.md b/test-gen-plugin/README.md
index 5534e07a5..2b1f705fe 100644
--- a/test-gen-plugin/README.md
+++ b/test-gen-plugin/README.md
@@ -1,5 +1,6 @@
# test-gen-plugin
-
+> [!WARNING]
+> internal-usage-only
-A maven plugin that handles the test generation that exercises both the wasm package and the runtime package. Tests are parsed from the [Wasm testsuite](https://github.com/WebAssembly/testsuite) and generate Java JUnit tests.
+A Maven plugin that handles the test generation that exercises both the wasm package and the runtime package. Tests are parsed from the [Wasm testsuite](https://github.com/WebAssembly/testsuite) and generate Java JUnit tests.
diff --git a/wasi/src/main/java/module-info.java b/wasi/src/main/java/module-info.java
index 7d3bbc943..7d7021799 100644
--- a/wasi/src/main/java/module-info.java
+++ b/wasi/src/main/java/module-info.java
@@ -2,6 +2,8 @@
requires static run.endive.annotations;
requires run.endive.log;
requires transitive run.endive.runtime;
+
+ // Needed for `javax.annotation.processing.Generated` annotation in generated ModuleFactory
requires static java.compiler;
exports run.endive.wasi;
diff --git a/wasi/src/test/java/wasi/WasiPreview1Test.java b/wasi/src/test/java/wasi/WasiPreview1Test.java
index 55827d78f..b56454600 100644
--- a/wasi/src/test/java/wasi/WasiPreview1Test.java
+++ b/wasi/src/test/java/wasi/WasiPreview1Test.java
@@ -42,7 +42,7 @@ public void shouldRunWasiModule() {
Instance.builder(loadModule("compiled/hello-wasi.wat.wasm"))
.withImportValues(imports)
.build();
- assertEquals(fakeStdout.output().strip(), "hello world");
+ assertEquals("hello world", fakeStdout.output().strip());
}
@Test
@@ -72,7 +72,7 @@ public void shouldRunWasiGreetRustModule() {
Instance.builder(loadModule("compiled/greet-wasi.rs.wasm"))
.withImportValues(imports)
.build();
- assertEquals(fakeStdout.output().strip(), "Hello, Benjamin!");
+ assertEquals("Hello, Benjamin!", fakeStdout.output().strip());
}
@Test
@@ -88,7 +88,7 @@ public void shouldRunWasiDemoJavyModule() {
.withImportValues(imports)
.build();
- assertEquals(fakeStdout.output(), "{\"foo\":3,\"newBar\":\"baz!\"}");
+ assertEquals("{\"foo\":3,\"newBar\":\"baz!\"}", fakeStdout.output());
}
@Test
diff --git a/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java
index 09ca5f0fc..b95a6ee61 100644
--- a/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java
+++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java
@@ -148,7 +148,7 @@ public Builder withoutFeature(WasmFeature feature) {
}
public Validate build() {
- return new Validate(Collections.unmodifiableList(new ArrayList<>(features)));
+ return new Validate(List.copyOf(features));
}
}
}
diff --git a/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java
index 7bcfbae8f..091fd4454 100644
--- a/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java
+++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java
@@ -13,7 +13,6 @@
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Collectors;
import run.endive.log.Logger;
import run.endive.log.SystemLogger;
import run.endive.runtime.ByteArrayMemory;
@@ -79,7 +78,7 @@ public void process() {
args.add("--output");
args.add(outputFolder.resolve(output.getName()).resolve("spec.json").toString());
args.addAll(List.of(options));
- logger.info("Running command: " + args.stream().collect(Collectors.joining(" ")));
+ logger.info("Running command: " + String.join(" ", args));
wasiOpts.withArguments(args);
try (var wasi =
diff --git a/wasm/src/main/java/run/endive/wasm/Parser.java b/wasm/src/main/java/run/endive/wasm/Parser.java
index 2ab569977..5c4293709 100644
--- a/wasm/src/main/java/run/endive/wasm/Parser.java
+++ b/wasm/src/main/java/run/endive/wasm/Parser.java
@@ -454,7 +454,7 @@ public void parseWithoutDecoding(InputStream in, ParserListener listener) {
// https://webassembly.github.io/spec/core/binary/modules.html#binary-module
private static class SectionsValidator {
- private List sectionsOrder = new ArrayList<>();
+ private final List sectionsOrder = new ArrayList<>();
private int maxSection = -1;
SectionsValidator() {
@@ -651,9 +651,11 @@ private static TypeSection parseTypeSection(ByteBuffer buffer) {
r.resolve(typeSection);
}
}
- if (ct.arrayType() != null
- && ct.arrayType().fieldType().storageType().valType() != null) {
- ct.arrayType().fieldType().storageType().valType().resolve(typeSection);
+ if (ct.arrayType() != null) {
+ var valType = ct.arrayType().fieldType().storageType().valType();
+ if (valType != null) {
+ valType.resolve(typeSection);
+ }
}
if (ct.structType() != null) {
for (var t : ct.structType().fieldTypes()) {
@@ -697,7 +699,7 @@ private static ImportSection parseImportSection(ByteBuffer buffer, TypeSection t
var limitType = readByte(buffer);
var min = (int) readVarUInt32(buffer);
- TableLimits limits = null;
+ TableLimits limits;
switch (limitType) {
case 0x00:
limits = new TableLimits(min);
@@ -1278,11 +1280,6 @@ private static Instruction parseInstruction(ByteBuffer buffer) {
}
var signature = OpCode.signature(op);
- switch (op) {
- default:
- break;
- }
-
// reserving an operand in those two operations to inject
// a ValType hint at validation time
switch (op) {
diff --git a/wasm/src/main/java/run/endive/wasm/Validator.java b/wasm/src/main/java/run/endive/wasm/Validator.java
index 2eb35de88..7391ff847 100644
--- a/wasm/src/main/java/run/endive/wasm/Validator.java
+++ b/wasm/src/main/java/run/endive/wasm/Validator.java
@@ -319,7 +319,7 @@ private void validateMemory(int id) {
private void validateMemAlign(long current, long expected) {
if (current != expected) {
throw new InvalidException(
- "invalid memory alignement, current: " + current + ", expected: " + expected);
+ "invalid memory alignment, current: " + current + ", expected: " + expected);
}
}
@@ -667,7 +667,7 @@ private void validateTypeRefs(java.util.List types, int validUpperBound
void validateTags() {
for (var tagType : module.tagSection().map(ts -> ts.types()).orElse(new TagType[0])) {
var type = module.typeSection().getType(tagType.typeIdx());
- if (type.returns().size() > 0) {
+ if (!type.returns().isEmpty()) {
throw new InvalidException("non-empty tag result type index: " + tagType.typeIdx());
}
}
@@ -882,7 +882,7 @@ private void validateConstantExpression(
}
}
- if (valTypeStack.size() < 1) {
+ if (valTypeStack.isEmpty()) {
throw new InvalidException("type mismatch, no constant expressions found");
}
if (valTypeStack.size() != 1) {
@@ -905,7 +905,7 @@ void validateFunctions() {
}
}
- private static int[] typesWithDefaultValue =
+ private static final int[] typesWithDefaultValue =
new int[] {
ValType.ID.F64,
ValType.ID.F32,
@@ -977,8 +977,7 @@ void validateFunction(int funcIdx, FunctionBody body, FunctionType functionType)
// and now the catches
var catches = CatchOpCode.decode(op.operands());
- for (int idx = 0; idx < catches.size(); idx++) {
- var currentCatch = catches.get(idx);
+ for (CatchOpCode.Catch currentCatch : catches) {
if (ctrlFrameStack.size() < currentCatch.label()) {
throw new InvalidException("something something");
}
@@ -1909,7 +1908,7 @@ void validateFunction(int funcIdx, FunctionBody body, FunctionType functionType)
if (global.mutabilityType() == MutabilityType.Const) {
// global.wast in the origin spec and function references
// have exact same test that exact two different errors
- // TOOD: figure out which one
+ // TODO: figure out which one
throw new InvalidException("global is immutable, immutable global");
}
popVal(global.valueType());
diff --git a/wasm/src/main/java/run/endive/wasm/WasmModule.java b/wasm/src/main/java/run/endive/wasm/WasmModule.java
index 36297e224..ed732b320 100644
--- a/wasm/src/main/java/run/endive/wasm/WasmModule.java
+++ b/wasm/src/main/java/run/endive/wasm/WasmModule.java
@@ -304,7 +304,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof WasmModule)) {
+ if (!(o instanceof WasmModule)) {
return false;
}
WasmModule that = (WasmModule) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java b/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java
index fbbbd0f8d..fcb0d4d9d 100644
--- a/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java
+++ b/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java
@@ -26,7 +26,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof ActiveDataSegment)) {
+ if (!(o instanceof ActiveDataSegment)) {
return false;
}
if (!super.equals(o)) {
diff --git a/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java b/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java
index 20fab3caf..70ae27ad7 100644
--- a/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java
+++ b/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java
@@ -221,7 +221,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof AnnotatedInstruction)) {
+ if (!(o instanceof AnnotatedInstruction)) {
return false;
}
AnnotatedInstruction that = (AnnotatedInstruction) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/CodeSection.java b/wasm/src/main/java/run/endive/wasm/types/CodeSection.java
index 38144b55f..41128694a 100644
--- a/wasm/src/main/java/run/endive/wasm/types/CodeSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/CodeSection.java
@@ -67,7 +67,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof CodeSection)) {
+ if (!(o instanceof CodeSection)) {
return false;
}
CodeSection that = (CodeSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java b/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java
index 94f33cc86..59623cac7 100644
--- a/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java
@@ -34,7 +34,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof DataCountSection)) {
+ if (!(o instanceof DataCountSection)) {
return false;
}
DataCountSection that = (DataCountSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/DataSection.java b/wasm/src/main/java/run/endive/wasm/types/DataSection.java
index d8629453a..616fff964 100644
--- a/wasm/src/main/java/run/endive/wasm/types/DataSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/DataSection.java
@@ -55,7 +55,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof DataSection)) {
+ if (!(o instanceof DataSection)) {
return false;
}
DataSection that = (DataSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/DataSegment.java b/wasm/src/main/java/run/endive/wasm/types/DataSegment.java
index de911884f..c61378225 100644
--- a/wasm/src/main/java/run/endive/wasm/types/DataSegment.java
+++ b/wasm/src/main/java/run/endive/wasm/types/DataSegment.java
@@ -19,7 +19,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof DataSegment)) {
+ if (!(o instanceof DataSegment)) {
return false;
}
DataSegment that = (DataSegment) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/Element.java b/wasm/src/main/java/run/endive/wasm/types/Element.java
index f744e5c06..f54f24e6a 100644
--- a/wasm/src/main/java/run/endive/wasm/types/Element.java
+++ b/wasm/src/main/java/run/endive/wasm/types/Element.java
@@ -51,7 +51,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof Element)) {
+ if (!(o instanceof Element)) {
return false;
}
Element element = (Element) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/ElementSection.java b/wasm/src/main/java/run/endive/wasm/types/ElementSection.java
index 29e566ebe..5eeaf3913 100644
--- a/wasm/src/main/java/run/endive/wasm/types/ElementSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/ElementSection.java
@@ -58,7 +58,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof ElementSection)) {
+ if (!(o instanceof ElementSection)) {
return false;
}
ElementSection that = (ElementSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/ExportSection.java b/wasm/src/main/java/run/endive/wasm/types/ExportSection.java
index 1e237ae5e..bbd8685a9 100644
--- a/wasm/src/main/java/run/endive/wasm/types/ExportSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/ExportSection.java
@@ -51,7 +51,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof ExportSection)) {
+ if (!(o instanceof ExportSection)) {
return false;
}
ExportSection that = (ExportSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java b/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java
index a95ae84fb..57a1427a6 100644
--- a/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java
+++ b/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java
@@ -25,7 +25,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof FunctionBody)) {
+ if (!(o instanceof FunctionBody)) {
return false;
}
FunctionBody that = (FunctionBody) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java b/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java
index f6a0cd424..3002aee73 100644
--- a/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java
@@ -54,7 +54,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof FunctionSection)) {
+ if (!(o instanceof FunctionSection)) {
return false;
}
FunctionSection that = (FunctionSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/Global.java b/wasm/src/main/java/run/endive/wasm/types/Global.java
index d16de2761..bf7e868f4 100644
--- a/wasm/src/main/java/run/endive/wasm/types/Global.java
+++ b/wasm/src/main/java/run/endive/wasm/types/Global.java
@@ -44,7 +44,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof Global)) {
+ if (!(o instanceof Global)) {
return false;
}
Global global = (Global) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java b/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java
index dce82b182..b95dc3047 100644
--- a/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java
@@ -55,7 +55,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof GlobalSection)) {
+ if (!(o instanceof GlobalSection)) {
return false;
}
GlobalSection that = (GlobalSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/ImportSection.java b/wasm/src/main/java/run/endive/wasm/types/ImportSection.java
index 52a83a291..062a6bbbe 100644
--- a/wasm/src/main/java/run/endive/wasm/types/ImportSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/ImportSection.java
@@ -60,7 +60,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof ImportSection)) {
+ if (!(o instanceof ImportSection)) {
return false;
}
ImportSection that = (ImportSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/Instruction.java b/wasm/src/main/java/run/endive/wasm/types/Instruction.java
index ab802a3be..35b7d15e3 100644
--- a/wasm/src/main/java/run/endive/wasm/types/Instruction.java
+++ b/wasm/src/main/java/run/endive/wasm/types/Instruction.java
@@ -56,7 +56,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof Instruction)) {
+ if (!(o instanceof Instruction)) {
return false;
}
Instruction that = (Instruction) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/Memory.java b/wasm/src/main/java/run/endive/wasm/types/Memory.java
index c06152991..71c57cfc6 100644
--- a/wasm/src/main/java/run/endive/wasm/types/Memory.java
+++ b/wasm/src/main/java/run/endive/wasm/types/Memory.java
@@ -32,7 +32,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof Memory)) {
+ if (!(o instanceof Memory)) {
return false;
}
Memory memory = (Memory) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/MemorySection.java b/wasm/src/main/java/run/endive/wasm/types/MemorySection.java
index ebf0c1a6e..44cb3659a 100644
--- a/wasm/src/main/java/run/endive/wasm/types/MemorySection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/MemorySection.java
@@ -51,7 +51,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof MemorySection)) {
+ if (!(o instanceof MemorySection)) {
return false;
}
MemorySection that = (MemorySection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/StartSection.java b/wasm/src/main/java/run/endive/wasm/types/StartSection.java
index 1e5551885..a44c53b7f 100644
--- a/wasm/src/main/java/run/endive/wasm/types/StartSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/StartSection.java
@@ -36,7 +36,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof StartSection)) {
+ if (!(o instanceof StartSection)) {
return false;
}
StartSection that = (StartSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/StructType.java b/wasm/src/main/java/run/endive/wasm/types/StructType.java
index 6754b548c..e21ec7572 100644
--- a/wasm/src/main/java/run/endive/wasm/types/StructType.java
+++ b/wasm/src/main/java/run/endive/wasm/types/StructType.java
@@ -35,7 +35,7 @@ public static Builder builder() {
}
public static final class Builder {
- private List fieldTypes = new ArrayList<>();
+ private final List fieldTypes = new ArrayList<>();
private Builder() {}
diff --git a/wasm/src/main/java/run/endive/wasm/types/Table.java b/wasm/src/main/java/run/endive/wasm/types/Table.java
index 5d96ec2b3..0360e1196 100644
--- a/wasm/src/main/java/run/endive/wasm/types/Table.java
+++ b/wasm/src/main/java/run/endive/wasm/types/Table.java
@@ -56,7 +56,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof Table)) {
+ if (!(o instanceof Table)) {
return false;
}
Table table = (Table) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/TableSection.java b/wasm/src/main/java/run/endive/wasm/types/TableSection.java
index 7aee063a0..d20f71133 100644
--- a/wasm/src/main/java/run/endive/wasm/types/TableSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/TableSection.java
@@ -51,7 +51,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof TableSection)) {
+ if (!(o instanceof TableSection)) {
return false;
}
TableSection that = (TableSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/TypeSection.java b/wasm/src/main/java/run/endive/wasm/types/TypeSection.java
index 85557281c..74735d3ea 100644
--- a/wasm/src/main/java/run/endive/wasm/types/TypeSection.java
+++ b/wasm/src/main/java/run/endive/wasm/types/TypeSection.java
@@ -375,7 +375,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || !(o instanceof TypeSection)) {
+ if (!(o instanceof TypeSection)) {
return false;
}
TypeSection that = (TypeSection) o;
diff --git a/wasm/src/main/java/run/endive/wasm/types/ValType.java b/wasm/src/main/java/run/endive/wasm/types/ValType.java
index adee0b2a5..e66f04a10 100644
--- a/wasm/src/main/java/run/endive/wasm/types/ValType.java
+++ b/wasm/src/main/java/run/endive/wasm/types/ValType.java
@@ -13,28 +13,29 @@ public final class ValType {
private static final long OPCODE_MASK = 0xFFFFFFFFL;
private static final long TYPEIDX_SHIFT = 32;
- public static ValType BOT = new ValType(ID.BOT);
- public static ValType F64 = new ValType(ID.F64);
-
- public static ValType F32 = new ValType(ID.F32);
- public static ValType I64 = new ValType(ID.I64);
-
- public static ValType I32 = new ValType(ID.I32);
-
- public static ValType V128 = new ValType(ID.V128);
- public static ValType FuncRef = new ValType(ID.FuncRef);
- public static ValType ExnRef = new ValType(ID.ExnRef);
- public static ValType ExternRef = new ValType(ID.ExternRef);
- public static ValType AnyRef = new ValType(ID.AnyRef);
- public static ValType EqRef = new ValType(ID.EqRef);
- public static ValType I31Ref = new ValType(ID.i31);
- public static ValType StructRef = new ValType(ID.StructRef);
- public static ValType ArrayRef = new ValType(ID.ArrayRef);
- public static ValType NoneRef = new ValType(ID.NoneRef);
- public static ValType NoFuncRef = new ValType(ID.NoFuncRef);
- public static ValType NoExternRef = new ValType(ID.NoExternRef);
-
- public static ValType RefBot = new ValType(ValType.ID.Ref, ValType.TypeIdxCode.BOT.code());
+ public static final ValType BOT = new ValType(ID.BOT);
+ public static final ValType F64 = new ValType(ID.F64);
+
+ public static final ValType F32 = new ValType(ID.F32);
+ public static final ValType I64 = new ValType(ID.I64);
+
+ public static final ValType I32 = new ValType(ID.I32);
+
+ public static final ValType V128 = new ValType(ID.V128);
+ public static final ValType FuncRef = new ValType(ID.FuncRef);
+ public static final ValType ExnRef = new ValType(ID.ExnRef);
+ public static final ValType ExternRef = new ValType(ID.ExternRef);
+ public static final ValType AnyRef = new ValType(ID.AnyRef);
+ public static final ValType EqRef = new ValType(ID.EqRef);
+ public static final ValType I31Ref = new ValType(ID.i31);
+ public static final ValType StructRef = new ValType(ID.StructRef);
+ public static final ValType ArrayRef = new ValType(ID.ArrayRef);
+ public static final ValType NoneRef = new ValType(ID.NoneRef);
+ public static final ValType NoFuncRef = new ValType(ID.NoFuncRef);
+ public static final ValType NoExternRef = new ValType(ID.NoExternRef);
+
+ public static final ValType RefBot =
+ new ValType(ValType.ID.Ref, ValType.TypeIdxCode.BOT.code());
private final long id;
diff --git a/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java b/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java
index e59fc6ee1..50f705f0e 100644
--- a/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java
+++ b/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java
@@ -21,6 +21,7 @@ public void shouldBeEquals() {
var mod1 = Parser.parse(CorpusResources.getResource("compiled/count_vowels.rs.wasm"));
var mod2 = Parser.parse(CorpusResources.getResource("compiled/count_vowels.rs.wasm"));
+ //noinspection SimplifiableAssertion; intentionally test `equals` implementation
assertTrue(mod1.equals(mod2));
}
}
diff --git a/wasm/src/test/java/run/endive/wasm/types/ValueTest.java b/wasm/src/test/java/run/endive/wasm/types/ValueTest.java
index 1c35b53b2..71ad5f17b 100644
--- a/wasm/src/test/java/run/endive/wasm/types/ValueTest.java
+++ b/wasm/src/test/java/run/endive/wasm/types/ValueTest.java
@@ -1,6 +1,7 @@
package run.endive.wasm.types;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -39,6 +40,8 @@ public void validConstruction() {
assertTrue(true);
}
+ // Suppress IntelliJ warnings for explicit `equals` calls
+ @SuppressWarnings({"SimplifiableAssertion", "EqualsWithItself", "ConstantValue"})
@Test
public void equalsContract() {
@@ -47,12 +50,13 @@ public void equalsContract() {
var i32TwentyOne = Value.i32(21);
var f32TwentyOne = Value.f32(Float.floatToIntBits(21.0f));
- assertEquals(i32FortyTwo, i32FortyTwo);
- assertEquals(i32FortyTwo, Value.i32(42));
- assertNotEquals(i32FortyTwo, i32TwentyOne);
- assertNotEquals(i32FortyTwo, null);
- assertNotEquals(i32TwentyOne, f32TwentyOne);
- assertNotEquals(i32FortyTwo, i64FortyTwo);
+ // Explicitly call `equals` here to avoid any shortcuts by JUnit `assertEquals`
+ assertTrue(i32FortyTwo.equals(i32FortyTwo));
+ assertTrue(i32FortyTwo.equals(Value.i32(42)));
+ assertFalse(i32FortyTwo.equals(i32TwentyOne));
+ assertFalse(i32FortyTwo.equals(null));
+ assertFalse(i32TwentyOne.equals(f32TwentyOne));
+ assertFalse(i32FortyTwo.equals(i64FortyTwo));
}
@Test