Skip to content

Further reduce Java usages - #40

Merged
283375 merged 17 commits into
masterfrom
refactor/replace-java-2
Jun 25, 2026
Merged

Further reduce Java usages#40
283375 merged 17 commits into
masterfrom
refactor/replace-java-2

Conversation

@283375

@283375 283375 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@283375

283375 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

/opencode /review This PR tend to reduce Java usages to minimum. Notice that some of the Java usage is acceptable, for example ArcaeaPackageHelper is only available for Android, so using Java / Apache Commons ZipFile is OK; and for date time formatting, kotlinx.datetime does not have locale support yet, so only Java formatters could be used. Other than that, check for anything that might be missed.

@opencode-agent

Copy link
Copy Markdown

Now I have a thorough understanding of the PR. Here's my review:


PR Review: Further reduce Java usages

Bug found: potentialToText rounding mode incorrectly changed

File: app/src/main/java/xyz/sevive/arcaeaoffline/ui/helpers/ArcaeaFormatters.kt:37

The original code used Java's RoundingMode.DOWN (truncation toward zero). The replacement uses bignum's RoundingMode.ROUND_HALF_TOWARDS_ZERO (round to nearest, ties toward zero). These are not equivalent:

Input DOWN (old) ROUND_HALF_TOWARDS_ZERO (new)
12.054 "12.05" "12.05"
12.055 "12.05" "12.05"
12.056 "12.05" "12.06"

The existing tests at ArcaeaFormattersTest.kt:21-22 only cover 12.054 and 12.055, which happen to produce the same result under both modes, so the bug is not caught. The correct bignum equivalent of Java's RoundingMode.DOWN is RoundingMode.ROUND_TOWARD_ZERO.


Minor observation: Java IO still in DatabaseManageViewModel.kt

app/src/main/java/xyz/sevive/arcaeaoffline/ui/screens/database/manage/DatabaseManageViewModel.kt:43-47 still imports:

import java.io.FileInputStream
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
  • FileInputStream is needed to bridge android.os.FileDescriptorSeekableByteChannel for Apache Commons Compress ZipFile — acceptable.
  • InputStream / OutputStream come from Android content resolver and Apache Commons Compress APIs — acceptable.
  • Charset / StandardCharsets could be replaced with kotlin.text.Charsets.UTF_8 for a bit more Java removal, but it's low priority.

Acceptable remaining Java (as noted in PR description)

  • ArcaeaPackageHelper.kt:23-24java.util.zip.ZipFile and ZipEntry. Android-only, explicitly scoped as acceptable.
  • DateTimeEditDialog.kt:61-62java.time.format.DateTimeFormatter / FormatStyle. No kotlinx.datetime locale support yet, acceptable.
  • DeviceOcrOnnxHelper.kt:16java.nio.ByteBuffer. Required by ONNX Runtime library API. The PR already removed the ByteOrder import, which is good.

All other changes look clean

  • java.util.UUIDkotlin.uuid.Uuid migration is thorough across entities, converters, daos, repos, serializers, and migrations.
  • java.text.DecimalFormat / java.math.RoundingModebignum in ArcaeaFormatters (aside from the bug above).
  • java.util.regex.Pattern/Matcher → Kotlin Regex in Pack.kt — clean.
  • java.io → Okio in DataStore serializers — clean.
  • java.nio.ByteBuffer/ByteOrder bit-twiddling in DeviceOcrOnnxHelper.modelVersion() replaced with bitwise ops — correctly implemented.
  • Exception / warnings removed from Room entity (OcrQueueTask) — validation moved to ViewModel, avoiding Java serialization in DB. Good architectural improvement.
  • FileInputStream → Apache Commons Compress ZipFile with SeekableByteChannel for APK importing — eliminates ZipInputStream streaming issues.
  • The self-import import xyz.sevive.arcaeaoffline.ui.helpers.ArcaeaFormatters.constantToRatingClassText inside ArcaeaFormatters.kt:14 is redundant but harmless (needed for tests in ArcaeaFormattersTest.kt, but the import landed in the wrong file). Could be cleaned up.

Summary

One real bug (rounding mode mismatch), otherwise the PR is well-scoped and correctly identifies which Java APIs cannot be replaced. Fix the rounding mode and add a test case covering truncation behavior (e.g., potentialToText(12.056) should equal "12.05") and this is good to merge.

New%20session%20-%202026-06-25T16%3A36%3A20.809Z
opencode session  |  github run

@283375
283375 merged commit 8d8ad71 into master Jun 25, 2026
5 of 6 checks passed
@283375
283375 deleted the refactor/replace-java-2 branch June 25, 2026 17:17
@283375 283375 changed the title Futher reduce Java usages Further reduce Java usages Jun 25, 2026
283375 added a commit that referenced this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants