Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve callMethod() use for Java 21 #59

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.ballerina.lib.data.jsondata.utils.DiagnosticErrorCode;
import io.ballerina.lib.data.jsondata.utils.DiagnosticLog;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.types.MethodType;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
Expand Down Expand Up @@ -83,7 +82,7 @@ public int read() {
public void close() throws IOException {
super.close();
if (closeMethod != null) {
env.getRuntime().callMethod(iterator, closeMethod.getName(), new StrandMetadata(false, null));
env.getRuntime().callMethod(iterator, closeMethod.getName(), null);
}
}

Expand All @@ -93,7 +92,7 @@ private boolean hasBytesInCurrentChunk() {

private boolean readNextChunk() throws InterruptedException {
try {
Object result = env.getRuntime().callMethod(iterator, nextMethodName, new StrandMetadata(false, null));
Object result = env.getRuntime().callMethod(iterator, nextMethodName, null);
if (result == null) {
done = true;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ public static Object parseBytes(BArray json, BMap<BString, Object> options, BTyp

public static Object parseStream(Environment env, BStream json, BMap<BString, Object> options, BTypedesc typed) {
final BObject iteratorObj = json.getIteratorObj();
BallerinaByteBlockInputStream byteBlockSteam = new BallerinaByteBlockInputStream(env,
iteratorObj, resolveNextMethod(iteratorObj), resolveCloseMethod(iteratorObj));
Object result = JsonParser.parse(new InputStreamReader(byteBlockSteam), options, typed);
if (byteBlockSteam.getError() != null) {
return byteBlockSteam.getError();
}
return result;
return env.yieldAndRun(() -> {
BallerinaByteBlockInputStream byteBlockSteam = new BallerinaByteBlockInputStream(env, iteratorObj,
resolveNextMethod(iteratorObj), resolveCloseMethod(iteratorObj));
Object result = JsonParser.parse(new InputStreamReader(byteBlockSteam), options, typed);
if (byteBlockSteam.getError() != null) {
return byteBlockSteam.getError();
}
return result;
});
}

public static Object toJson(Object value) {
Expand Down
Loading