24
24
*/
25
25
package jdk .graal .compiler .core .test .ea ;
26
26
27
- import java .lang .ref .WeakReference ;
28
27
import java .util .List ;
28
+ import java .util .concurrent .atomic .AtomicReference ;
29
29
30
30
import org .junit .Assert ;
31
31
import org .junit .Test ;
@@ -66,15 +66,15 @@ private static final class AllocatedObject {
66
66
public static String moveIntoBranchBox (int id ) {
67
67
Double box = object1 + 1 ;
68
68
if (id == 0 ) {
69
- obj1 = new WeakReference <>(box );
69
+ obj1 = new AtomicReference <>(box );
70
70
}
71
71
return "value" ;
72
72
}
73
73
74
74
public static String moveIntoBranch (int id ) {
75
75
AllocatedObject box = new AllocatedObject (object2 .value + 1 );
76
76
if (id == 0 ) {
77
- obj1 = new WeakReference <>(box );
77
+ obj1 = new AtomicReference <>(box );
78
78
}
79
79
return "value" ;
80
80
}
@@ -104,7 +104,7 @@ public static String noLoopIterationBox(int id) {
104
104
Double box = object1 + 1 ;
105
105
for (int i = 0 ; i < 100 ; i ++) {
106
106
if (id == i ) {
107
- obj1 = new WeakReference <>(box );
107
+ obj1 = new AtomicReference <>(box );
108
108
}
109
109
}
110
110
return "value" ;
@@ -114,7 +114,7 @@ public static String noLoopIteration(int id) {
114
114
AllocatedObject box = new AllocatedObject (object2 .value + 1 );
115
115
for (int i = 0 ; i < 100 ; i ++) {
116
116
if (id == i ) {
117
- obj1 = new WeakReference <>(box );
117
+ obj1 = new AtomicReference <>(box );
118
118
}
119
119
}
120
120
return "value" ;
@@ -124,7 +124,7 @@ public static String noLoopIterationEmpty(int id) {
124
124
AllocatedObject box = new AllocatedObject ();
125
125
for (int i = 0 ; i < 100 ; i ++) {
126
126
if (id == i ) {
127
- obj1 = new WeakReference <>(box );
127
+ obj1 = new AtomicReference <>(box );
128
128
}
129
129
}
130
130
return "value" ;
0 commit comments