Skip to content

Add support for java.nio.HeapByteBuffer to ArrayBuffer conversion  #1060

@andy-maca

Description

@andy-maca

Please, provide the details below:

When I tried to use ArrayBuffer.from([java.nio.HeapByteBuffer]) I got a native exception like 'Direct ByteBuffer expected)', this function only support direct byte buffer conversion, how to convert a heap byte buffer without data copy?

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Yes

Tell us about the problem

ArrayBuffer.from() can't convert java.nio.HeapByteBuffer to ArrayBuffer

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.0.0
  • Cross-platform modules: 4.0.0
  • Runtime: 4.0.1

Did the error happen while the app was being constructed? (buildtime error)

No

Did the error happen while the app was executing? (runtime error)

Yes

Please tell us how to recreate the issue in as much detail as possible.

Consider using the playground to provide the code you have issues with.
Easy to reproduce with js code like

var bb = java.nio.ByteBuffer.allocate(12);
var ab = ArrayBuffer.from(bb);  //error 

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions