Accessing Java class / object attributes in CheerpJ based PWA

I'm new to CheerpJ and I am working on creating a React Native module for ImageJ.js (CheerpJ translated version of Java based ImageJ aka ImJoy that runs in a progressive webapp (PWA)). I am running into an issue where attributes of Java objects on the JS side seem to have an integer after the attribute names (as shown in the image for this post). Upon further investigation I noticed a pattern where this integer seems to be the index of the attribute (eg. if a class 'Dog' has attributes 'height' and 'weight' defined in that order, they appear as height0, and weight1 in the JS console). Has anyone here seen any similar issue? Not sure if I am using CheerpJ correctly. Any help would be appreciated.
No description
7 Replies
DarkForce8
DarkForce8OP9mo ago
Steps to reproduce issue: 1. Head over to https://ij.imjoy.io/?run=https://gist.githubusercontent.com/sspathak/902c5d7d1e8de08c7232f790cb5511b6/raw/3f498140a3cd83ce3e88b34c00582ca77e3b0b72/gistfile1.txt 2. Inspect element and go to console. 3. Run let get_image = await cjResolveCall("ij.WindowManager", "getCurrentImage"); 4. Run let im = await get_image() 5. Run Object.getOwnPropertyNames(im) You'll see that the property names have an integer suffix. This integer suffix seems to follow the order in which the instance variables are defined at https://imagej.net/ij/source/ij/ImagePlus.java
ImageJ.JS
ImageJ.JS is an open source image processing web application designed for scientific multidimensional images
apignotti
apignotti9mo ago
This is all expected as part of the CheerpJ 2.x version that ImJoy is currently build on Fields used that encoding and were never really intended to be manually accessed via JavaScript
apignotti
apignotti9mo ago
CheerpJ 3 offer a new clean solution called "library mode" https://labs.leaningtech.com/cheerpj3/guides/library-mode
Leaning Technologies Developer
Library mode - CheerpJ Documentation
Use Java libraries in JavaScript
DarkForce8
DarkForce8OP9mo ago
Thanks so much for the help. I just checked out the library mode and it’s exactly what I need. I’ll try to request imjoy team to upgrade. Based on your experience would upgrading imjoy to CJ3 be challenging?
apignotti
apignotti9mo ago
They have already extensively tested the new version, so I don't know why they did not update: https://aicell.io/post/improving-imagej.js/
AICell Lab
Taking ImageJ.JS to the Next Level | AICell Lab
ImageJ, a renowned open-source image processing tool, has long been a familiar name in the scientific community. Seeking to build upon its rich legacy, we undertook an ambitious endeavor: to transition ImageJ to the web through ImageJ.
apignotti
apignotti9mo ago
This report is very positive
DarkForce8
DarkForce8OP9mo ago
Thanks for the lead
Want results from more Discord servers?
Add your server