• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if (false == true) Universe.end(42);

 
Bruce Coleman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's late where I am, and I have a headache.

Output:
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: false, life: 2
life < 0: false, life: 28
 
Bruce Coleman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just going to be a manager. Somebody, please take my keyboard.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the problem? How does the output differ from your expectation?

 
Bobby Smallman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I appreciate the slight Hitchhiker's Guide to the Galaxy reference, I have no idea what types of responses you are looking for with this.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's really strange about this code is that when you call discoverParadox() for the third time, with the same input, it produces a different result... Really strange. I don't see how that happens.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:What's really strange about this code is that when you call discoverParadox() for the third time, with the same input, it produces a different result... Really strange. I don't see how that happens.


Me neither! The more I investigate the more strange it becomes. Changing the method name does not change anything. Setting a variable to Integer.MIN_VALUE and using that gives the same output. Setting a value to -2147483648 and using that as the argument does not change anything.

Bizarre !

Apparently it's a Hotspot bug and running with -Xint makes it run as expected.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns the same results using -Xint:

C:\Users\wouter\Desktop\Temp>java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

C:\Users\wouter\Desktop\Temp>java -Xint Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any strange behavior here, it (JDK 1.6.0_07) returns the same results with/without -Xint.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:It returns the same results using -Xint:

C:\Users\wouter\Desktop\Temp>java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

Wouter, what version of Java are you using on what operating system?

I'm using JDK 1.6.0 update 22 (64-bit) on 64-bit Windows Server 2008 R2 and I'm getting the same output as Bruce showed in his opening post.
 
Kurt Van Etten
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For whatever it's worth, I'm getting normal behavior (under Windows XP):

C:\Documents and Settings\Kurt Van Etten\Desktop\Java>javac Huh.java

C:\Documents and Settings\Kurt Van Etten\Desktop\Java>java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

C:\Documents and Settings\Kurt Van Etten\Desktop\Java>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)


I find it somewhat alarming that other people are getting the weird behavior, though. That seems like a potentially serious bug in the VM.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:Wouter, what version of Java are you using on what operating system?

I'm using JDK 1.6.0 update 22 (64-bit) on 64-bit Windows Server 2008 R2 and I'm getting the same output as Bruce showed in his opening post.

I'm using:

java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
Windows 7 Home Premium 64bit

But I'm getting the same results with:
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b112)
Java HotSpot(TM) Client VM (build 20.0-b01, mixed mode, sharing)

 
Kurt Van Etten
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a question for the people who are getting the strange behavior: if you change the for loop in the main method to iterate 4 times instead of 3, do you get something like the output below?

life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: false, life: 2
life < 0: false, life: 28
life < 0: false, life: 54

 
Bobby Smallman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kurt Van Etten wrote:Here's a question for the people who are getting the strange behavior: if you change the for loop in the main method to iterate 4 times instead of 3, do you get something like the output below?

life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: false, life: 2
life < 0: false, life: 28
life < 0: false, life: 54



No, after the third time, it consistently will print -24, 2, 28 for every additional attempt.

Also, I find it interesting that in Eclipse I will get the problem everytime if I run the program normally or in debug mode WITHOUT break points. However, if I run the program with a break point just inside the if(life > 50) statement and step through the program I will not get the extra 2 and 28 lines of output.

Another interesting aspect is that if you change line 23 to it will also prevent the extra 2 and 28 lines.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bruce Coleman wrote:I'm just going to be a manager. Somebody, please take my keyboard.


Er.... what?
 
Bruce Coleman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the confirmations. I'll log a bug with Sun --ack! ...with Oracle.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
H:\Java>java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

H:\Java>java -Xint Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

H:\Java>java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)

Windows XP Professional, version 5.1
 
Campbell Ritchie
Sheriff
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The title of your thread reads rather like . . . which I keep telling my undergraduates, always evaluates to true. So it isn't a paradox. If (false == true) then the universe will end today with a return value of 42, but it tells you nothing about what happens if (false ≠ true); in that case anything may happen. Not a paradox at all.

And will that code compile? Surely end(int) is an instance method of the Universe class
 
Bruce Coleman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A brief update, were anybody curious:

This issue still exists with the latest JRE for Windows 7 x64. Sun --pft! ...O-r-a-c-l-e (emailing from sun.com) only responded with an automated email that they'd look into the issue, and if they agreed the problem existed, then they'd identify an existing bug that covered the problem or file a new bug and send me an update. I've since received no update from them. So, I'll log the issue, again.

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've since received no update from them.

Things aren't free anymore partner
 
Henry Wong
author
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
marc weber wrote:H:\Java>java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

H:\Java>java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)

Windows XP Professional, version 5.1


This works for me too... using Java 1.6.0_17-b04. Windows 7, 64 bit.

BTW, like Marc, I am using the client JIT compiler -- while you seem to be using the server JIT compiler. Maybe that's the difference?

Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
BTW, like Marc, I am using the client JIT compiler -- while you seem to be using the server JIT compiler. Maybe that's the difference?

Good point.

 
Henry Wong
author
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
BTW, like Marc, I am using the client JIT compiler -- while you seem to be using the server JIT compiler. Maybe that's the difference?



BINGO !! Switched over to the server JIT compiler and got the error.

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\> java Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24

C:\> java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

C:\> java -server Huh
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: true, life: -24
life < 0: false, life: 2
life < 0: false, life: 28



[EDIT: beaten by less than a minute]

Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be related to this bug ?

Henry Wong wrote:[EDIT: beaten by less than a minute]Henry

RedDead Redemption made me a fast shooter.
 
Jim Newton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get the strange behavior

Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

under 32-bit Ubuntu 10.04

--------------------
... but running with -server option I do

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic