Skip to content

Commit 35b2851

Browse files
hansonrhansonr
authored andcommitted
Unsafe fix
- uses String instead of long. Should work as in Java.
1 parent d750ccb commit 35b2851

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sources/net.sf.j2s.java.core/src/sun/misc/Unsafe.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333

3434

3535
/**
36+
*
37+
* SwingJS note:
38+
*
39+
* all offsets in SwingJS will be the String name of the field. All we are doing
40+
* is getting or putting those values. Nothing truly atomic about it.
41+
*
3642
* A collection of methods for performing low-level, unsafe operations.
3743
* Although the class and all methods are public, use of this class is
3844
* limited because only trusted code can obtain instances of it.
@@ -732,7 +738,8 @@ public Object staticFieldBase(Class<?> c) {
732738
* @see #getInt(Object, long)
733739
*/
734740
public long staticFieldOffset(Field f) {
735-
return 0;
741+
String name = f.getName();
742+
return /** @j2sNative 1 ? name : */0;
736743
}
737744

738745
/**
@@ -753,7 +760,8 @@ public long staticFieldOffset(Field f) {
753760
* @see #getInt(Object, long)
754761
*/
755762
public long objectFieldOffset(Field f) {
756-
return 0;
763+
String name = f.getName();
764+
return /** @j2sNative 1 ? name : */0;
757765
}
758766

759767
/**

0 commit comments

Comments
 (0)