node-java icon indicating copy to clipboard operation
node-java copied to clipboard

Problem with array of a type, returning empty in java method

Open vichiodo opened this issue 7 years ago • 1 comments

Hello,

I'm using a listener from Java and it's getting the posted messages as Array but when I print the message, it shows an empty array. I already tested and the same code in Java is returning an array full of objects, but in JS is empty. Some code for example:

var listener = java.newProxy(FeatureDataListener, {
       trigger: function(list) {
             if(!list.isEmptySync()) {
                    console.log("CHEGOU", list);
                    System.out.printlnSync(list.sizeSync());
             }
        },
        getTypes: function () {
              var list = new ArrayList();
              list.addSync("test");
              return list;
        }
});

The code above is my implementation in JS and in the trigger method I shoul receive the list as parameter of the function but in my print is coming an empty array.

ddsListener.addDataListener(new FeatureDataListener() {
      @Override
      public void trigger(List<PresentationFeature> list) {
               list.forEach(System.out::println);
      }

      @Override
      public List<String> getTypes() {
             return Collections.singletonList("test");
      }
});

And the code above is the Java implementation and the list is returning with objects.

I don't know if the type of the list makes difference to get the objects and transform to JSON, so if anyone had this problem or has a solution, please help me!!!

vichiodo avatar Jan 17 '19 16:01 vichiodo

@joeferner Any update on this?

maelswarm avatar Feb 15 '21 20:02 maelswarm