File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
test-app/app/src/main/assets/app/tests Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,29 @@ describe("Tests garbage collection", function () {
264264 gc ( ) ;
265265 java . lang . System . gc ( ) ;
266266 } ) ;
267+
268+ it ( "should keep array-enclosed objects alive after GC" , function ( ) {
269+ function createObjects ( name ) {
270+ var arr = new Array ( ) ;
271+ arr . push ( new com . tns . tests . Class1 ( ) ) ;
272+
273+ var cb1 = new com . tns . tests . Class1 . Callback1 ( name , {
274+ getMessage : function ( ) {
275+ var msg = arr [ 0 ] . getMessage ( ) ;
276+ return msg ;
277+ }
278+ } ) ;
279+
280+ return com . tns . tests . Class1 . Class2 . printMessageWithDelay ( cb1 , 2 * 1000 ) ;
281+ }
282+
283+ expect ( createObjects ( "Callback1" ) ) . toBe ( true ) ;
284+ expect ( createObjects ( "Callback2" ) ) . toBe ( true ) ;
285+ expect ( createObjects ( "Callback3" ) ) . toBe ( true ) ;
286+
287+ gc ( ) ;
288+ java . lang . System . gc ( ) ;
289+ } )
267290
268291 it ( "should properly reintroduce Java object back in a callback" , function ( ) {
269292 function getTestObject ( ) {
You can’t perform that action at this time.
0 commit comments