-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.6
The JCK13 test api/java_lang/ref/PhantomReference/index.html#PhantomReference0600
failed in the build (JDK1.3-"N" was used)
JTR file:
#Test Results (version 2)
#Fri Aug 20 20:36:29 PDT 1999
#-----testdescription-----
executeArgs=-TestCaseID ALL
executeClass=javasoft.sqe.tests.api.java.lang.ref.PhantomReference.GCEnqueueingTests
file=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/api/java_lang/ref/PhantomReference/index.html
id=PhantomReference0600
keywords=api positive runtime
source=GCEnqueueingTests.java
testsuite=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests
timeout=3000
title=PhantomReference GC enqueueing
#-----testresult-----
description=file:/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/api/java_lang/ref/PhantomReference/index.html#PhantomReference0600
end=Fri Aug 20 20:36:29 PDT 1999
environment=jck-runtime-solaris
execStatus=Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
javatestVersion=JT_2.1k
script=javasoft.sqe.javatest.lib.JCKScript -runtime
sections=script_messages testExecute
start=Fri Aug 20 20:36:24 PDT 1999
status=Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
test=api/java_lang/ref/PhantomReference/index.html#PhantomReference0600
timeoutSeconds=3000
work=/net/novo35/opt/build13/jck13-tests-build/test/JCK-runtime-13beta/runtime-batch-multiJVM-jit-native/work/api/java_lang/ref/PhantomReference
#section:script_messages
----------messages:(1/24)----------
Executing test class...
#section:testExecute
----------messages:(1/499)----------
command: javasoft.sqe.javatest.lib.ExecJCKTestOtherJVMCmd CLASSPATH=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/../classes:/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/javatest.jar DISPLAY=novo35:0.0 HOME=/home/kuzm LD_LIBRARY_PATH=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/../lib /opt/build13/jdk1.3/N/solaris/bin/java -Xfuture javasoft.sqe.tests.api.java.lang.ref.PhantomReference.GCEnqueueingTests -TestCaseID ALL
----------ref:(0/0)----------
----------log:(10/427)----------
args decoded
PhantomReference0601: Passed. OKAY
PhantomReference0602: Passed. OKAY
PhantomReference0603: Passed. OKAY
PhantomReference0604: Passed. OKAY
PhantomReference0605: Failed. PhantomRef was enqueued by GC but poll()==null
PhantomReference0606: Passed. OKAY
PhantomReference0607: Passed. OKAY
PhantomReference0608: Passed. OKAY
STATUS:Failed.tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
result: Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
test result: Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
Name: akC45999 Date: 09/06/99
After GC enqueues PhantomReference created with queue
the methods enqueue() and poll() sometimes return
wrong values.
Java Platform 1.3 API Specification says:
"If the garbage collector determines at a certain point in time
that the referent of a phantom reference is phantom reachable, then
at that time or at some later time it will enqueue the reference."
According to the specification after GC enqueues the PhantomReference
object created with queue (i.e. isEnqueued() returns true) the
method enqueue() should return false. The method poll() applied to
the queue in turn should return PhantomReference object enqueued.
But the following code shows that sometimes enqueue() returns true
and poll() returns null.
The bug appears in JDK1.3-"M", JDK1.3-"N", JDK1.3-"O"
- only on Sparc, HotSpot VM
novo81% java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O-release,
1.3beta-O-release, interpreted mode)
novo81% java PhantomRef
WRONG: enqueue() returned true instead of false
OKAY
novo81% java PhantomRef
WRONG: enqueue() returned true instead of false
WRONG: poll() returned null instead of refPhantom enqueued
novo81%
------------------------------------------------------------------
import java.lang.ref.*;
public class PhantomRef {
public static void main(String args[]){
PhantomRef1();
PhantomRef2();
}
//the method enqueue() returns wrong value
public static void PhantomRef1() {
ReferenceQueue queue = new ReferenceQueue();
PhantomReference refPhantom = new PhantomReference(new Object(), queue);
System.gc();
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() < (startTime + 100000)) {
System.gc();
if (refPhantom.isEnqueued() == false) {
try {
Thread.sleep(100);
} catch (InterruptedException i) {
}
continue;
}
break;
}
if (refPhantom.isEnqueued() == false) {
// OKAY, GC have not enqueued refPhantom for the timeout period
System.out.println("OKAY");
return;
}
if (refPhantom.enqueue() == true) {
// not OKAY, enqueue() should return false since
// refPhantom is already enqueued by the GC
System.out.println("WRONG: enqueue() returned true " +
"instead of false");
return;
}
System.out.println("OKAY");
return;
}
//the method poll() returns wrong value
public static void PhantomRef2() {
ReferenceQueue queue = new ReferenceQueue();
PhantomReference refPhantom = new PhantomReference(new Object(), queue);
System.gc();
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() < (startTime + 100000)) {
System.gc();
if (refPhantom.isEnqueued() == false) {
try {
Thread.sleep(100);
} catch (InterruptedException i) {
}
continue;
}
break;
}
if (refPhantom.isEnqueued() == false) {
//OKAY, GC have not enqueued refPhantom for the timeout period
System.out.println("OKAY");
return;
}
if (queue.poll() == null) {
//not OKAY, poll() should return refPhantom enqueued by the GC
System.out.println("WRONG: poll() returned null instead " +
"of refPhantom enqueued");
return;
}
System.out.println("OKAY");
return;
}
}//end of class PhantomRef
--------------------------------------------------------------------------
======================================================================
failed in the build (JDK1.3-"N" was used)
JTR file:
#Test Results (version 2)
#Fri Aug 20 20:36:29 PDT 1999
#-----testdescription-----
executeArgs=-TestCaseID ALL
executeClass=javasoft.sqe.tests.api.java.lang.ref.PhantomReference.GCEnqueueingTests
file=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/api/java_lang/ref/PhantomReference/index.html
id=PhantomReference0600
keywords=api positive runtime
source=GCEnqueueingTests.java
testsuite=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests
timeout=3000
title=PhantomReference GC enqueueing
#-----testresult-----
description=file:/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/api/java_lang/ref/PhantomReference/index.html#PhantomReference0600
end=Fri Aug 20 20:36:29 PDT 1999
environment=jck-runtime-solaris
execStatus=Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
javatestVersion=JT_2.1k
script=javasoft.sqe.javatest.lib.JCKScript -runtime
sections=script_messages testExecute
start=Fri Aug 20 20:36:24 PDT 1999
status=Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
test=api/java_lang/ref/PhantomReference/index.html#PhantomReference0600
timeoutSeconds=3000
work=/net/novo35/opt/build13/jck13-tests-build/test/JCK-runtime-13beta/runtime-batch-multiJVM-jit-native/work/api/java_lang/ref/PhantomReference
#section:script_messages
----------messages:(1/24)----------
Executing test class...
#section:testExecute
----------messages:(1/499)----------
command: javasoft.sqe.javatest.lib.ExecJCKTestOtherJVMCmd CLASSPATH=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/../classes:/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/javatest.jar DISPLAY=novo35:0.0 HOME=/home/kuzm LD_LIBRARY_PATH=/net/novo35/opt/build13/jck13-tests-build/unzip/JCK-runtime-13beta/tests/../lib /opt/build13/jdk1.3/N/solaris/bin/java -Xfuture javasoft.sqe.tests.api.java.lang.ref.PhantomReference.GCEnqueueingTests -TestCaseID ALL
----------ref:(0/0)----------
----------log:(10/427)----------
args decoded
PhantomReference0601: Passed. OKAY
PhantomReference0602: Passed. OKAY
PhantomReference0603: Passed. OKAY
PhantomReference0604: Passed. OKAY
PhantomReference0605: Failed. PhantomRef was enqueued by GC but poll()==null
PhantomReference0606: Passed. OKAY
PhantomReference0607: Passed. OKAY
PhantomReference0608: Passed. OKAY
STATUS:Failed.tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
result: Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
test result: Failed. tests: 8; passed: 7; failed: 1; first test case failure: PhantomReference0605
Name: akC45999 Date: 09/06/99
After GC enqueues PhantomReference created with queue
the methods enqueue() and poll() sometimes return
wrong values.
Java Platform 1.3 API Specification says:
"If the garbage collector determines at a certain point in time
that the referent of a phantom reference is phantom reachable, then
at that time or at some later time it will enqueue the reference."
According to the specification after GC enqueues the PhantomReference
object created with queue (i.e. isEnqueued() returns true) the
method enqueue() should return false. The method poll() applied to
the queue in turn should return PhantomReference object enqueued.
But the following code shows that sometimes enqueue() returns true
and poll() returns null.
The bug appears in JDK1.3-"M", JDK1.3-"N", JDK1.3-"O"
- only on Sparc, HotSpot VM
novo81% java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O-release,
1.3beta-O-release, interpreted mode)
novo81% java PhantomRef
WRONG: enqueue() returned true instead of false
OKAY
novo81% java PhantomRef
WRONG: enqueue() returned true instead of false
WRONG: poll() returned null instead of refPhantom enqueued
novo81%
------------------------------------------------------------------
import java.lang.ref.*;
public class PhantomRef {
public static void main(String args[]){
PhantomRef1();
PhantomRef2();
}
//the method enqueue() returns wrong value
public static void PhantomRef1() {
ReferenceQueue queue = new ReferenceQueue();
PhantomReference refPhantom = new PhantomReference(new Object(), queue);
System.gc();
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() < (startTime + 100000)) {
System.gc();
if (refPhantom.isEnqueued() == false) {
try {
Thread.sleep(100);
} catch (InterruptedException i) {
}
continue;
}
break;
}
if (refPhantom.isEnqueued() == false) {
// OKAY, GC have not enqueued refPhantom for the timeout period
System.out.println("OKAY");
return;
}
if (refPhantom.enqueue() == true) {
// not OKAY, enqueue() should return false since
// refPhantom is already enqueued by the GC
System.out.println("WRONG: enqueue() returned true " +
"instead of false");
return;
}
System.out.println("OKAY");
return;
}
//the method poll() returns wrong value
public static void PhantomRef2() {
ReferenceQueue queue = new ReferenceQueue();
PhantomReference refPhantom = new PhantomReference(new Object(), queue);
System.gc();
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() < (startTime + 100000)) {
System.gc();
if (refPhantom.isEnqueued() == false) {
try {
Thread.sleep(100);
} catch (InterruptedException i) {
}
continue;
}
break;
}
if (refPhantom.isEnqueued() == false) {
//OKAY, GC have not enqueued refPhantom for the timeout period
System.out.println("OKAY");
return;
}
if (queue.poll() == null) {
//not OKAY, poll() should return refPhantom enqueued by the GC
System.out.println("WRONG: poll() returned null instead " +
"of refPhantom enqueued");
return;
}
System.out.println("OKAY");
return;
}
}//end of class PhantomRef
--------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4268317 (ref) Reference.isEnqueued() can return true when instance not enqueued
- Closed