1 /*
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
133 break;
134 case STATIC_FIELD:
135 RefHolder holder1 = new InStaticFieldHolder();
136 assertion.keepLink(holder1.hold(referenceToKeep));
137 break;
138 case STACK_LOCAL:
139 RefHolder holder2 = new InStackLocalHolder(); // UnusedThreadKiller
140 assertion.keepLink(holder2.hold(referenceToKeep));
141 break;
142 case THREAD_FIELD:
143 RefHolder holder3 = new InThreadFieldHolder(); // UnusedThreadKiller
144 assertion.keepLink(holder3.hold(referenceToKeep));
145 break;
146 case THREAD_ITSELF:
147 Thread objectThread = (Thread) object;
148 objectThread.setDaemon(true);
149 objectThread.start();
150 assertion.keepLink(new UnusedThreadKiller(objectThread.getId())); // UnusedThreadKiller
151 break;
152 case STATIC_FIELD_OF_ROOT_CLASS:
153 RefHolder holder4 = new NullClassloaderHolder();
154 Object keep = holder4.hold(referenceToKeep);
155 if (keep != null) {
156 assertion.keepLink(keep);
157 }
158 break;
159 case JNI_GLOBAL_REF:
160 JNIGlobalRefHolder holder5 = new JNIGlobalRefHolder();
161 assertion.keepLink(holder5.hold(referenceToKeep));
162 break;
163 case JNI_LOCAL_REF:
164 JNILocalRefHolder holder6 = new JNILocalRefHolder();
165 assertion.keepLink(holder6.hold(referenceToKeep));
166 break;
167 }
168
169 Collection<Assertion> returnValue = new LinkedList<>();
170 returnValue.add(assertion);
171 return returnValue;
172 }
173
|
1 /*
2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
133 break;
134 case STATIC_FIELD:
135 RefHolder holder1 = new InStaticFieldHolder();
136 assertion.keepLink(holder1.hold(referenceToKeep));
137 break;
138 case STACK_LOCAL:
139 RefHolder holder2 = new InStackLocalHolder(); // UnusedThreadKiller
140 assertion.keepLink(holder2.hold(referenceToKeep));
141 break;
142 case THREAD_FIELD:
143 RefHolder holder3 = new InThreadFieldHolder(); // UnusedThreadKiller
144 assertion.keepLink(holder3.hold(referenceToKeep));
145 break;
146 case THREAD_ITSELF:
147 Thread objectThread = (Thread) object;
148 objectThread.setDaemon(true);
149 objectThread.start();
150 assertion.keepLink(new UnusedThreadKiller(objectThread.getId())); // UnusedThreadKiller
151 break;
152 case STATIC_FIELD_OF_ROOT_CLASS:
153 RefHolder holder4 = new NullClassloaderHolder(random.nextLong());
154 Object keep = holder4.hold(referenceToKeep);
155 if (keep != null) {
156 assertion.keepLink(keep);
157 }
158 break;
159 case JNI_GLOBAL_REF:
160 JNIGlobalRefHolder holder5 = new JNIGlobalRefHolder();
161 assertion.keepLink(holder5.hold(referenceToKeep));
162 break;
163 case JNI_LOCAL_REF:
164 JNILocalRefHolder holder6 = new JNILocalRefHolder();
165 assertion.keepLink(holder6.hold(referenceToKeep));
166 break;
167 }
168
169 Collection<Assertion> returnValue = new LinkedList<>();
170 returnValue.add(assertion);
171 return returnValue;
172 }
173
|