File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,32 +22,43 @@ private long pin() {
2222 return ptr ;
2323 }
2424
25+ private void unpin () {
26+ JFNative .unpin (ref , ptr , true );
27+ ptr = 0 ;
28+ }
29+
2530 public long NewByteArray (int size ) {
31+ if (ptr != 0 ) unpin ();
2632 ref = new byte [size ];
2733 return pin ();
2834 }
2935
3036 public long NewShortArray (int size ) {
37+ if (ptr != 0 ) unpin ();
3138 ref = new short [size ];
3239 return pin ();
3340 }
3441
3542 public long NewIntArray (int size ) {
43+ if (ptr != 0 ) unpin ();
3644 ref = new int [size ];
3745 return pin ();
3846 }
3947
4048 public long NewLongArray (int size ) {
49+ if (ptr != 0 ) unpin ();
4150 ref = new long [size ];
4251 return pin ();
4352 }
4453
4554 public long NewFloatArray (int size ) {
55+ if (ptr != 0 ) unpin ();
4656 ref = new float [size ];
4757 return pin ();
4858 }
4959
5060 public long NewStringArray (int size ) {
61+ if (ptr != 0 ) unpin ();
5162 ref = new String [size ];
5263 return pin ();
5364 }
@@ -61,10 +72,7 @@ public void SetStringElement(int idx, MemorySegment str) {
6172
6273 public Object getArray () {
6374 if (ref == null ) return null ;
64- if (ptr != 0 ) {
65- JFNative .unpin (ref , ptr , true );
66- ptr = 0 ;
67- }
75+ if (ptr != 0 ) unpin ();
6876 return ref ;
6977 }
7078
You can’t perform that action at this time.
0 commit comments