Skip to content

Commit

Permalink
Add -Werror compiler option and fix existing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
incubos committed Oct 5, 2023
1 parent f5e4947 commit 47d31c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ java {
repositories {
mavenCentral()
}

dependencies {
// Checks
errorprone 'com.google.errorprone:error_prone_core:2.11.0'
Expand All @@ -37,9 +38,11 @@ checkstyle {

compileJava {
options.compilerArgs += ["--enable-preview"]

// Enforce errors
options.compilerArgs += ["-Werror"]
}

compileTestJava {
options.compilerArgs += ["--enable-preview"]
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public int compare(final MemorySegment left, final MemorySegment right) {
return Byte.compare(left.get(ValueLayout.JAVA_BYTE, mismatch),
right.get(ValueLayout.JAVA_BYTE, mismatch));
}
return (int) (leftSize - rightSize);
return Long.compare(leftSize, rightSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String toString(MemorySegment memorySegment) {

ByteBuffer byteBuffer = memorySegment.asByteBuffer();

return byteBuffer == null ? null : new String(byteBuffer.array(), StandardCharsets.UTF_8);
return byteBuffer == null ? null : new String(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.remaining(), StandardCharsets.UTF_8);
}

@Override
Expand Down

0 comments on commit 47d31c7

Please sign in to comment.