users@glassfish.java.net

I have found that this is a JVM bug

From: <glassfish_at_javadesktop.org>
Date: Tue, 23 Sep 2008 13:07:04 PDT

> What happens if you declare "y" as:
>
> long y = 1L;
>
> ?
>
> Thanks,
> Kedar

I ended up adding more debug output. I change the code to inline instead of calling a method and broke the code down into steps:

i[i]f (__LOGPROTO.isLoggable(Level.FINER)) {
                                __LOGPROTO.finer("xxx receiveMessage inmsg.seq = " + inmsg.getSequenceNumber() + " __rcvcur = " + __rcvcur + " SEQ_PLUS = " + SEQ_PLUS(__rcvcur, 1L) + "this = " + this);
                                long x = __rcvcur;
                                final long y = 1L;
                                __LOGPROTO.finer("before x is " + x + " y is " + y);
                                long z = (x + y);
                                __LOGPROTO.finer("mid x is " + x + " y is " + y + " z is " + z);
                                z = z % 0x100000000L;
                                __LOGPROTO.finer("after x is " + x + " y is " + y + " z is " + z);
                            }[/i]

and this produced the output:

[i][#|2008-09-23T15:07:54.086-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDP
Connection.proto|_ThreadID=27;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c
anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=0c8f49f0-36
97-4d83-b397-2e15d0d7ff72;|before x is 16838 y is 1|#]
 
[#|2008-09-23T15:07:54.088-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDP
Connection.proto|_ThreadID=27;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c
anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=0c8f49f0-36
97-4d83-b397-2e15d0d7ff72;|mid x is 16838 y is 1 z is 16839|#]
 
[#|2008-09-23T15:07:54.091-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDP
Connection.proto|_ThreadID=27;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c
anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=0c8f49f0-36
97-4d83-b397-2e15d0d7ff72;|after x is 16838 y is 4294967296 z is 16839|#][/i]

As you can see, "y" is being modified to be "4294967296" as a side effect of the line that reads:

[i]
                                z = z % 0x100000000L;
[/i]

It is okay up to that point.
[Message sent by forum member 'bbergquist' (bbergquist)]

http://forums.java.net/jive/thread.jspa?messageID=301109