Open
Conversation
| } | ||
| } else { | ||
| if (isUsingCse) { | ||
| const result = await runJavaCseMachine(javaCode, targetStep, context, { stdout, stderr }); |
There was a problem hiding this comment.
Bug: The raw stderr function, which expects two arguments, is passed to runJavaCseMachine. The CSE machine will likely call it with one, causing incorrect error handling.
Severity: MEDIUM
Suggested Fix
Wrap the stderr callback when passing it to runJavaCseMachine to hardcode the error type, ensuring it conforms to the expected single-argument signature. For example: stderr: (msg: string) => stderr('Runtime', msg).
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/commons/utils/JavaHelper.ts#L103
Potential issue: The `stderr` function defined in `JavaHelper.ts` requires two
arguments: `type` and `msg`. When passing this function as a callback to
`runJavaCseMachine`, it is not wrapped. External systems like the CSE machine are
expected to provide a single string argument to their I/O callbacks. This mismatch will
result in the `type` parameter receiving the error message and the `msg` parameter being
`undefined`, leading to incorrect error classification and potential runtime errors
within the `stderr` function body. A similar callback for the JVM path is correctly
wrapped, establishing a pattern that was not followed here.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change adapts the Java CSEC machine to source-academy/java-slang#79.
Type of change
How to test
These changes are extremely minimal and exist only to adapt the frontend to a modified backend system. This is tested manually.
yarn linkinjava-slang, thenyarn link "java-slang"infrontend).As it is not the responsibility of the frontend to test changes to the backend, there is no need to test the functionality introduced by source-academy/java-slang#79.
Checklist