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

Cannot convert "1682293037722628098'(1anguage: Java, type: com.oracle.truffle.api.strings.Trufflestring) to Java type "java.lang .0bject[]':Unsupported target type #9438

Open
dandelion2 opened this issue Aug 2, 2024 · 3 comments
Assignees

Comments

@dandelion2
Copy link

While compiling a JavaScript script using GraalVM, we've encountered an intermittent issue when calling a Java interface with variable arguments defined as follows:

java
public Object queryForMap(final String sql, Object ... args);

The corresponding JavaScript call to the method is structured like this:

javascript
const selectSql = "select code, product_id as productId, ts_storage_id as tsStorageId from device where id = ?";
const deviceInfo = jdbcClient.queryForMap(selectSql, "1682293037722628098");

Initially, the script execution occasionally results in the error: "Cannot convert '1682293037722628098' to Java type 'java.lang.Object[]': Unsupported target type." Interestingly, after several attempts, the issue does not consistently manifest, making it difficult to reproduce.

@selhagani selhagani self-assigned this Aug 2, 2024
@selhagani
Copy link
Member

Hi @dandelion2,

Thank you for reaching out to us.
Could you please share the version of GraalVM you're using, your OS, your system's architecture and a concise reproducer alongside the steps needed to reproduce the issue?

I understand that the execution of the script multiple times may end up leading to the issue not manifesting consistently but we still need it to test nevertheless.

Thank you

@dandelion2
Copy link
Author

The version of GraalVM I am using is graalvm-ce-java11-linux-amd64-22.3.1. The reproduction script, with business processing logic removed, is as follows:
Java code:
// Query the database
public Map<String, Object> queryForMap(final String sql, Object ... args) {
if (StringUtils.isBlank(sql)){
throw new DandelionException("mysql queryForMap error, SQL must not be null");
}
// SQL validation
checkSql(sql);
try {
return jdbcTemplate.queryForMap(sql, args);
} catch (EmptyResultDataAccessException e){
return null;
} catch (Exception e) {
throw new DandelionException("mysql queryForMap error," e.getMessage(), e);
}
}
// Register Java object
context.eval("js", "var jdbcClient = Java.type('com.example.JsJdbc').create()");
JavaScript code:
const selectSql = "SELECT code, product_id as productId, ts_storage_id as tsStorageId FROM device WHERE id = ?";
const deviceInfo = jdbcClient.queryForMap(selectSql, "1682293037722628098");

@selhagani
Copy link
Member

Could you try testing with the latest available GraalVM version to see if the issue still presist? You can find it using this link: https://github.com/graalvm/graalvm-ce-builds/releases

@selhagani selhagani removed their assignment Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants